@telepath-computer/television 0.1.30 → 0.1.32

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,9 +1,9 @@
1
- var Cv=Object.defineProperty;var ku=t=>{throw TypeError(t)};var Iv=(t,e,n)=>e in t?Cv(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var v=(t,e,n)=>Iv(t,typeof e!="symbol"?e+"":e,n),fa=(t,e,n)=>e.has(t)||ku("Cannot "+n);var h=(t,e,n)=>(fa(t,e,"read from private field"),n?n.call(t):e.get(t)),x=(t,e,n)=>e.has(t)?ku("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),$=(t,e,n,r)=>(fa(t,e,"write to private field"),r?r.call(t,n):e.set(t,n),n),b=(t,e,n)=>(fa(t,e,"access private method"),n);var Eu=(t,e,n,r)=>({set _(s){$(t,e,s,n)},get _(){return h(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 Pv(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 $u=Object.prototype.toString,hf=function(e){var n=$u.call(e),r=n==="[object Arguments]";return r||(r=n!=="[object Array]"&&e!==null&&typeof e=="object"&&typeof e.length=="number"&&e.length>=0&&$u.call(e.callee)==="[object Function]"),r},pa,Au;function Rv(){if(Au)return pa;Au=1;var t;if(!Object.keys){var e=Object.prototype.hasOwnProperty,n=Object.prototype.toString,r=hf,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}(),f=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),V=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(V&&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=f(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 Dv=Array.prototype.slice,Ov=hf,xu=Object.keys,qi=xu?function(e){return xu(e)}:Rv(),Tu=Object.keys;qi.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 Ov(r)?Tu(Dv.call(r)):Tu(r)})}else Object.keys=qi;return Object.keys||qi};var zv=qi,Yi=Object.defineProperty||!1;if(Yi)try{Yi({},"a",{value:1})}catch{Yi=!1}var oi=Yi,Zt=SyntaxError,G=TypeError,Lv=Object.getOwnPropertyDescriptor,Ki=Lv;if(Ki)try{Ki([],"length")}catch{Ki=null}var Nr=Ki,Cu=oi,Mv=Zt,rr=G,Iu=Nr,df=function(e,n,r){if(!e||typeof e!="object"&&typeof e!="function")throw new rr("`obj` must be an object or a function`");if(typeof n!="string"&&typeof n!="symbol")throw new rr("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new rr("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new rr("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new rr("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new rr("`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=!!Iu&&Iu(e,n);if(Cu)Cu(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 Mv("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},nl=oi,ff=function(){return!!nl};ff.hasArrayLengthDefineBug=function(){if(!nl)return null;try{return nl([],"length",{value:1}).length!==1}catch{return!0}};var Lo=ff,Nv=zv,Uv=typeof Symbol=="function"&&typeof Symbol("foo")=="symbol",Fv=Object.prototype.toString,Zv=Array.prototype.concat,Pu=df,jv=function(t){return typeof t=="function"&&Fv.call(t)==="[object Function]"},pf=Lo(),Wv=function(t,e,n,r){if(e in t){if(r===!0){if(t[e]===n)return}else if(!jv(r)||!r())return}pf?Pu(t,e,n,!0):Pu(t,e,n)},gf=function(t,e){var n=arguments.length>2?arguments[2]:{},r=Nv(e);Uv&&(r=Zv.call(r,Object.getOwnPropertySymbols(e)));for(var s=0;s<r.length;s+=1)Wv(t,r[s],e[r[s]],n[r[s]])};gf.supportsDescriptors=!!pf;var Hn=gf,Ji={exports:{}};typeof self<"u"?Ji.exports=self:typeof window<"u"?Ji.exports=window:Ji.exports=Function("return this")();var mf=Ji.exports,Bv=mf,vf=function(){return typeof Sn!="object"||!Sn||Sn.Math!==Math||Sn.Array!==Array?Bv:Sn},Vv=Hn,Gv=Nr,Hv=vf,qv=function(){var e=Hv();if(Vv.supportsDescriptors){var n=Gv(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},Yv=Hn,Kv=mf,yf=vf,Jv=qv,Xv=yf(),bf=function(){return Xv};Yv(bf,{getPolyfill:yf,implementation:Kv,shim:Jv});var Kl=bf,jt=function(e){return!!e&&(typeof e=="function"||typeof e=="object")},Jl=Object,wf=Error,Qv=EvalError,ey=RangeError,Xl=ReferenceError,ty=URIError,ny=Math.abs,ry=Math.floor,sy=Math.max,iy=Math.min,oy=Math.pow,ay=Math.round,Ql=Number.isNaN||function(e){return e!==e},ly=Ql,cy=function(e){return ly(e)||e===0?e:e<0?-1:1},Ur=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},Ru=typeof Symbol<"u"&&Symbol,uy=Ur,ec=function(){return typeof Ru!="function"||typeof Symbol!="function"||typeof Ru("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:uy()},_f=typeof Reflect<"u"&&Reflect.getPrototypeOf||null,hy=Jl,Sf=hy.getPrototypeOf||null,dy="Function.prototype.bind called on incompatible ",fy=Object.prototype.toString,py=Math.max,gy="[object Function]",Du=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},my=function(e,n){for(var r=[],s=n,i=0;s<e.length;s+=1,i+=1)r[i]=e[s];return r},vy=function(t,e){for(var n="",r=0;r<t.length;r+=1)n+=t[r],r+1<t.length&&(n+=e);return n},yy=function(e){var n=this;if(typeof n!="function"||fy.apply(n)!==gy)throw new TypeError(dy+n);for(var r=my(arguments,1),s,i=function(){if(this instanceof s){var d=n.apply(this,Du(r,arguments));return Object(d)===d?d:this}return n.apply(e,Du(r,arguments))},o=py(0,n.length-r.length),a=[],l=0;l<o;l++)a[l]="$"+l;if(s=Function("binder","return function ("+vy(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},by=yy,ai=Function.prototype.bind||by,tc=Function.prototype.call,ga,Ou;function nc(){return Ou||(Ou=1,ga=Function.prototype.apply),ga}var wy=typeof Reflect<"u"&&Reflect&&Reflect.apply,_y=ai,Sy=nc(),ky=tc,Ey=wy,kf=Ey||_y.call(ky,Sy),$y=ai,Ay=G,xy=tc,Ty=kf,Mo=function(e){if(e.length<1||typeof e[0]!="function")throw new Ay("a function is required");return Ty($y,xy,e)},Cy=Mo,zu=Nr,Ef;try{Ef=[].__proto__===Array.prototype}catch(t){if(!t||typeof t!="object"||!("code"in t)||t.code!=="ERR_PROTO_ACCESS")throw t}var ma=!!Ef&&zu&&zu(Object.prototype,"__proto__"),$f=Object,Lu=$f.getPrototypeOf,Iy=ma&&typeof ma.get=="function"?Cy([ma.get]):typeof Lu=="function"?function(e){return Lu(e==null?e:$f(e))}:!1,Mu=_f,Nu=Sf,Uu=Iy,Af=Mu?function(e){return Mu(e)}:Nu?function(e){if(!e||typeof e!="object"&&typeof e!="function")throw new TypeError("getProto: not an object");return Nu(e)}:Uu?function(e){return Uu(e)}:null,Py=Function.prototype.call,Ry=Object.prototype.hasOwnProperty,Dy=ai,Wt=Dy.call(Py,Ry),B,Oy=Jl,zy=wf,Ly=Qv,My=ey,Ny=Xl,Rr=Zt,br=G,Uy=ty,Fy=ny,Zy=ry,jy=sy,Wy=iy,By=oy,Vy=ay,Gy=cy,xf=Function,va=function(t){try{return xf('"use strict"; return ('+t+").constructor;")()}catch{}},As=Nr,Hy=oi,ya=function(){throw new br},qy=As?function(){try{return arguments.callee,ya}catch{try{return As(arguments,"callee").get}catch{return ya}}}():ya,sr=ec(),_e=Af,Yy=Sf,Ky=_f,Tf=nc(),li=tc,ar={},Jy=typeof Uint8Array>"u"||!_e?B:_e(Uint8Array),Zn={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?B:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?B:ArrayBuffer,"%ArrayIteratorPrototype%":sr&&_e?_e([][Symbol.iterator]()):B,"%AsyncFromSyncIteratorPrototype%":B,"%AsyncFunction%":ar,"%AsyncGenerator%":ar,"%AsyncGeneratorFunction%":ar,"%AsyncIteratorPrototype%":ar,"%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%":zy,"%eval%":eval,"%EvalError%":Ly,"%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%":xf,"%GeneratorFunction%":ar,"%Int8Array%":typeof Int8Array>"u"?B:Int8Array,"%Int16Array%":typeof Int16Array>"u"?B:Int16Array,"%Int32Array%":typeof Int32Array>"u"?B:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":sr&&_e?_e(_e([][Symbol.iterator]())):B,"%JSON%":typeof JSON=="object"?JSON:B,"%Map%":typeof Map>"u"?B:Map,"%MapIteratorPrototype%":typeof Map>"u"||!sr||!_e?B:_e(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Oy,"%Object.getOwnPropertyDescriptor%":As,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?B:Promise,"%Proxy%":typeof Proxy>"u"?B:Proxy,"%RangeError%":My,"%ReferenceError%":Ny,"%Reflect%":typeof Reflect>"u"?B:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?B:Set,"%SetIteratorPrototype%":typeof Set>"u"||!sr||!_e?B:_e(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?B:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":sr&&_e?_e(""[Symbol.iterator]()):B,"%Symbol%":sr?Symbol:B,"%SyntaxError%":Rr,"%ThrowTypeError%":qy,"%TypedArray%":Jy,"%TypeError%":br,"%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%":Uy,"%WeakMap%":typeof WeakMap>"u"?B:WeakMap,"%WeakRef%":typeof WeakRef>"u"?B:WeakRef,"%WeakSet%":typeof WeakSet>"u"?B:WeakSet,"%Function.prototype.call%":li,"%Function.prototype.apply%":Tf,"%Object.defineProperty%":Hy,"%Object.getPrototypeOf%":Yy,"%Math.abs%":Fy,"%Math.floor%":Zy,"%Math.max%":jy,"%Math.min%":Wy,"%Math.pow%":By,"%Math.round%":Vy,"%Math.sign%":Gy,"%Reflect.getPrototypeOf%":Ky};if(_e)try{null.error}catch(t){var Xy=_e(_e(t));Zn["%Error.prototype%"]=Xy}var Qy=function t(e){var n;if(e==="%AsyncFunction%")n=va("async function () {}");else if(e==="%GeneratorFunction%")n=va("function* () {}");else if(e==="%AsyncGeneratorFunction%")n=va("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 Zn[e]=n,n},Fu={__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"]},ci=ai,co=Wt,eb=ci.call(li,Array.prototype.concat),tb=ci.call(Tf,Array.prototype.splice),Zu=ci.call(li,String.prototype.replace),uo=ci.call(li,String.prototype.slice),nb=ci.call(li,RegExp.prototype.exec),rb=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,sb=/\\(\\)?/g,ib=function(e){var n=uo(e,0,1),r=uo(e,-1);if(n==="%"&&r!=="%")throw new Rr("invalid intrinsic syntax, expected closing `%`");if(r==="%"&&n!=="%")throw new Rr("invalid intrinsic syntax, expected opening `%`");var s=[];return Zu(e,rb,function(i,o,a,l){s[s.length]=a?Zu(l,sb,"$1"):o||i}),s},ob=function(e,n){var r=e,s;if(co(Fu,r)&&(s=Fu[r],r="%"+s[0]+"%"),co(Zn,r)){var i=Zn[r];if(i===ar&&(i=Qy(r)),typeof i>"u"&&!n)throw new br("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:s,name:r,value:i}}throw new Rr("intrinsic "+e+" does not exist!")},tt=function(e,n){if(typeof e!="string"||e.length===0)throw new br("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof n!="boolean")throw new br('"allowMissing" argument must be a boolean');if(nb(/^%?[^%]*%?$/,e)===null)throw new Rr("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var r=ib(e),s=r.length>0?r[0]:"",i=ob("%"+s+"%",n),o=i.name,a=i.value,l=!1,c=i.alias;c&&(s=c[0],tb(r,eb([0,1],c)));for(var d=1,f=!0;d<r.length;d+=1){var y=r[d],m=uo(y,0,1),E=uo(y,-1);if((m==='"'||m==="'"||m==="`"||E==='"'||E==="'"||E==="`")&&m!==E)throw new Rr("property names with quotes must have matching quotes");if((y==="constructor"||!f)&&(l=!0),s+="."+y,o="%"+s+"%",co(Zn,o))a=Zn[o];else if(a!=null){if(!(y in a)){if(!n)throw new br("base intrinsic for "+e+" exists, but the property is not available.");return}if(As&&d+1>=r.length){var k=As(a,y);f=!!k,f&&"get"in k&&!("originalValue"in k.get)?a=k.get:a=a[y]}else f=co(a,y),a=a[y];f&&!l&&(Zn[o]=a)}}return a},ba,ju;function hn(){if(ju)return ba;ju=1;var t=tt,e=Mo,n=e([t("%String.prototype.indexOf%")]);return ba=function(s,i){var o=t(s,!!i);return typeof o=="function"&&n(s,".prototype.")>-1?e([o]):o},ba}var wa,Wu;function rc(){if(Wu)return wa;Wu=1;var t=tt,e=t("%Array%"),n=!e.isArray&&hn()("Object.prototype.toString");return wa=e.isArray||function(s){return n(s)==="[object Array]"},wa}var ab=Lo,Bu=oi,Cf=ab.hasArrayLengthDefineBug(),lb=Cf&&rc(),cb=hn(),ub=cb("Object.prototype.propertyIsEnumerable"),sc=function(e,n,r,s,i,o){if(!Bu){if(!e(o)||!o["[[Configurable]]"]||!o["[[Writable]]"]||i in s&&ub(s,i)!==!!o["[[Enumerable]]"])return!1;var a=o["[[Value]]"];return s[i]=a,n(s[i],a)}return Cf&&i==="length"&&"[[Value]]"in o&&lb(s)&&s.length!==o["[[Value]]"]?(s.length=o["[[Value]]"],s.length===o["[[Value]]"]):(Bu(s,i,r(o)),!0)},hb=G,es=Wt,db={__proto__:null,"[[Configurable]]":!0,"[[Enumerable]]":!0,"[[Get]]":!0,"[[Set]]":!0,"[[Value]]":!0,"[[Writable]]":!0},Fr=function(e){if(!e||typeof e!="object")return!1;for(var n in e)if(es(e,n)&&!db[n])return!1;var r=es(e,"[[Value]]")||es(e,"[[Writable]]"),s=es(e,"[[Get]]")||es(e,"[[Set]]");if(r&&s)throw new hb("Property Descriptors may not be both accessor and data descriptors");return!0},If=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},fb=G,pb=Fr,gb=If,Pf=function(e){if(typeof e<"u"&&!pb(e))throw new fb("Assertion failed: `Desc` must be a Property Descriptor");return gb(e)},mb=G,Vu=Wt,vb=Fr,Rf=function(e){if(typeof e>"u")return!1;if(!vb(e))throw new mb("Assertion failed: `Desc` must be a Property Descriptor");return!(!Vu(e,"[[Value]]")&&!Vu(e,"[[Writable]]"))},Zr=function(e){return typeof e=="string"||typeof e=="symbol"},Gu=Ql,Df=function(e,n){return e===n?e===0?1/e===1/n:!0:Gu(e)&&Gu(n)},Hu=G,yb=jt,bb=sc,wb=Pf,_b=Rf,Sb=Zr,kb=Df,ic=function(e,n,r){if(!yb(e))throw new Hu("Assertion failed: Type(O) is not Object");if(!Sb(n))throw new Hu("Assertion failed: P is not a Property Key");var s={"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Value]]":r,"[[Writable]]":!0};return bb(_b,kb,wb,e,n,s)},Of=Function.prototype.toString,gr=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,rl,Xi;if(typeof gr=="function"&&typeof Object.defineProperty=="function")try{rl=Object.defineProperty({},"length",{get:function(){throw Xi}}),Xi={},gr(function(){throw 42},null,rl)}catch(t){t!==Xi&&(gr=null)}else gr=null;var Eb=/^\s*class\b/,sl=function(e){try{var n=Of.call(e);return Eb.test(n)}catch{return!1}},_a=function(e){try{return sl(e)?!1:(Of.call(e),!0)}catch{return!1}},Qi=Object.prototype.toString,$b="[object Object]",Ab="[object Function]",xb="[object GeneratorFunction]",Tb="[object HTMLAllCollection]",Cb="[object HTML document.all class]",Ib="[object HTMLCollection]",Pb=typeof Symbol=="function"&&!!Symbol.toStringTag,Rb=!(0 in[,]),il=function(){return!1};if(typeof document=="object"){var Db=document.all;Qi.call(Db)===Qi.call(document.all)&&(il=function(e){if((Rb||!e)&&(typeof e>"u"||typeof e=="object"))try{var n=Qi.call(e);return(n===Tb||n===Cb||n===Ib||n===$b)&&e("")==null}catch{}return!1})}var zf=gr?function(e){if(il(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;try{gr(e,null,rl)}catch(n){if(n!==Xi)return!1}return!sl(e)&&_a(e)}:function(e){if(il(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;if(Pb)return _a(e);if(sl(e))return!1;var n=Qi.call(e);return n!==Ab&&n!==xb&&!/^\[object HTML/.test(n)?!1:_a(e)},Ob=zf,zb=function(e){return!!e},ft=Wt,Ii=G,Lb=jt,qu=Ob,Sa=zb,Mb=function(e){if(!Lb(e))throw new Ii("ToPropertyDescriptor requires an object");var n={};if(ft(e,"enumerable")&&(n["[[Enumerable]]"]=Sa(e.enumerable)),ft(e,"configurable")&&(n["[[Configurable]]"]=Sa(e.configurable)),ft(e,"value")&&(n["[[Value]]"]=e.value),ft(e,"writable")&&(n["[[Writable]]"]=Sa(e.writable)),ft(e,"get")){var r=e.get;if(typeof r<"u"&&!qu(r))throw new Ii("getter must be a function");n["[[Get]]"]=r}if(ft(e,"set")){var s=e.set;if(typeof s<"u"&&!qu(s))throw new Ii("setter must be a function");n["[[Set]]"]=s}if((ft(n,"[[Get]]")||ft(n,"[[Set]]"))&&(ft(n,"[[Value]]")||ft(n,"[[Writable]]")))throw new Ii("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute");return n},ka=G,Nb=jt,Yu=Fr,Ub=sc,Fb=Pf,Zb=Rf,jb=Zr,Wb=Df,Bb=Mb,Vb=function(e,n,r){if(!Nb(e))throw new ka("Assertion failed: Type(O) is not Object");if(!jb(n))throw new ka("Assertion failed: P is not a Property Key");var s=Yu(r)?r:Bb(r);if(!Yu(s))throw new ka("Assertion failed: Desc is not a valid Property Descriptor");return Ub(Zb,Wb,Fb,e,n,s)},Ku=G,Gb=jt,Hb=Vb,qb=Zr,Yb=function(e,n,r){if(!Gb(e))throw new Ku("Assertion failed: Type(O) is not Object");if(!qb(n))throw new Ku("Assertion failed: P is not a Property Key");var s={"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Value]]":r,"[[Writable]]":!0};return Hb(e,n,s)},Kb=typeof Reflect<"u"&&Reflect.setPrototypeOf||null,Jb=Jl,Xb=Jb.setPrototypeOf||null,Qb=Mo,Ju=Nr,ew=G,Lf={};try{Lf.__proto__=null}catch(t){if(!t||typeof t!="object"||!("code"in t)||t.code!=="ERR_PROTO_ACCESS")throw t}var tw=!("toString"in Lf),Ea=Ju&&Ju(Object.prototype,"__proto__"),nw=tw&&(!!Ea&&typeof Ea.set=="function"&&Qb([Ea.set])||function(e,n){if(e==null)throw new ew("set Object.prototype.__proto__ called on null or undefined");return e.__proto__=n,n}),Xu=Kb,rw=Xb,Qu=nw,sw=G,iw=Xu?function(e,n){if(Xu(e,n))return e;throw new sw("Reflect.setPrototypeOf: failed to set [[Prototype]]")}:rw||(Qu?function(e,n){return Qu(e,n),e}:null),eh=G,ow=jt,th=Af,aw=function(e){if(!ow(e))throw new eh("Assertion failed: O must be an Object");if(!th)throw new eh("This environment does not support fetching prototypes.");return th(e)},lw=G,cw=iw,uw=jt,hw=aw,dw=function(e,n){if(n!==null&&!uw(n))throw new lw("Assertion failed: V must be Object or Null");try{cw(e,n)}catch{return!1}return hw(e)===n},$a=ic,nh=Yb,Mf=dw,fw=Lo(),oc=wf;function ui(t,e,n){var r=new oc(n);return Mf(r,eo),delete r.constructor,nh(r,"error",t),nh(r,"suppressed",e),r}fw&&Object.defineProperty(ui,"prototype",{writable:!1});var eo=ui.prototype;if(!$a(eo,"constructor",ui)||!$a(eo,"message","")||!$a(eo,"name","SuppressedError"))throw new oc("unable to install SuppressedError.prototype properties; please report this!");Mf(ui.prototype,oc.prototype);var pw=ui,gw=pw,Nf=function(){return typeof SuppressedError=="function"?SuppressedError:gw},mw=Hn,rh=Kl(),vw=Nf,yw=function(){var e=vw();return mw(rh,{SuppressedError:e},{SuppressedError:function(){return rh.SuppressedError!==e}}),e};yw();var bw=G,ww=Fr,_w=If,Sw=function(e){if(typeof e<"u"&&!ww(e))throw new bw("Assertion failed: `Desc` must be a Property Descriptor");return _w(e)},kw=G,sh=Wt,Ew=Fr,$w=function(e){if(typeof e>"u")return!1;if(!Ew(e))throw new kw("Assertion failed: `Desc` must be a Property Descriptor");return!(!sh(e,"[[Value]]")&&!sh(e,"[[Writable]]"))},ih=Ql,Aw=function(e,n){return e===n?e===0?1/e===1/n:!0:ih(e)&&ih(n)},jr=zf,xw=function(e){return!!e},pt=Wt,Pi=G,Tw=jt,oh=jr,Aa=xw,Cw=function(e){if(!Tw(e))throw new Pi("ToPropertyDescriptor requires an object");var n={};if(pt(e,"enumerable")&&(n["[[Enumerable]]"]=Aa(e.enumerable)),pt(e,"configurable")&&(n["[[Configurable]]"]=Aa(e.configurable)),pt(e,"value")&&(n["[[Value]]"]=e.value),pt(e,"writable")&&(n["[[Writable]]"]=Aa(e.writable)),pt(e,"get")){var r=e.get;if(typeof r<"u"&&!oh(r))throw new Pi("getter must be a function");n["[[Get]]"]=r}if(pt(e,"set")){var s=e.set;if(typeof s<"u"&&!oh(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},xa=G,Iw=jt,ah=Fr,Pw=sc,Rw=Sw,Dw=$w,Ow=Zr,zw=Aw,Lw=Cw,hi=function(e,n,r){if(!Iw(e))throw new xa("Assertion failed: Type(O) is not Object");if(!Ow(n))throw new xa("Assertion failed: P is not a Property Key");var s=ah(r)?r:Lw(r);if(!ah(s))throw new xa("Assertion failed: Desc is not a valid Property Descriptor");return Pw(Dw,zw,Rw,e,n,s)},Mw=Ur(),Nw=Mw?Symbol.dispose||Symbol("Symbol.dispose"):null,Uw=Ur,Fw=Nw,ac=function(){return Uw()&&Symbol.dispose||Fw},Zw=ec,jw=hi,Ww=ac,Bw=function(){var e=Ww();return Zw()&&jw(Symbol,"dispose",{"[[Configurable]]":!1,"[[Enumerable]]":!1,"[[Writable]]":!1,"[[Value]]":e}),e},Vw=Ur(),Gw=Vw?Symbol.asyncDispose||Symbol("Symbol.asyncDispose"):null,Hw=Ur,qw=Gw,lc=function(){return Hw()&&Symbol.asyncDispose||qw},Yw=ec,Kw=hi,Jw=lc,Xw=function(){var e=Jw();return Yw()&&Kw(Symbol,"asyncDispose",{"[[Configurable]]":!1,"[[Enumerable]]":!1,"[[Writable]]":!1,"[[Value]]":e}),e},Qw=rc(),e_=tt,t_=hn(),n_=G,r_=Qw,s_=e_("%Reflect.apply%",!0)||t_("Function.prototype.apply"),No=function(e,n){var r=arguments.length>2?arguments[2]:[];if(!r_(r))throw new n_("Assertion failed: optional `argumentsList`, if provided, must be a List");return s_(e,n,r)};const i_={},o_=Object.freeze(Object.defineProperty({__proto__:null,default:i_},Symbol.toStringTag,{value:"Module"})),a_=Pv(o_);var cc=typeof Map=="function"&&Map.prototype,Ta=Object.getOwnPropertyDescriptor&&cc?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,ho=cc&&Ta&&typeof Ta.get=="function"?Ta.get:null,lh=cc&&Map.prototype.forEach,uc=typeof Set=="function"&&Set.prototype,Ca=Object.getOwnPropertyDescriptor&&uc?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,fo=uc&&Ca&&typeof Ca.get=="function"?Ca.get:null,ch=uc&&Set.prototype.forEach,l_=typeof WeakMap=="function"&&WeakMap.prototype,_s=l_?WeakMap.prototype.has:null,c_=typeof WeakSet=="function"&&WeakSet.prototype,Ss=c_?WeakSet.prototype.has:null,u_=typeof WeakRef=="function"&&WeakRef.prototype,uh=u_?WeakRef.prototype.deref:null,h_=Boolean.prototype.valueOf,d_=Object.prototype.toString,f_=Function.prototype.toString,p_=String.prototype.match,hc=String.prototype.slice,tn=String.prototype.replace,g_=String.prototype.toUpperCase,hh=String.prototype.toLowerCase,Uf=RegExp.prototype.test,dh=Array.prototype.concat,_t=Array.prototype.join,m_=Array.prototype.slice,fh=Math.floor,ol=typeof BigInt=="function"?BigInt.prototype.valueOf:null,Ia=Object.getOwnPropertySymbols,al=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,Dr=typeof Symbol=="function"&&typeof Symbol.iterator=="object",ks=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===Dr||!0)?Symbol.toStringTag:null,Ff=Object.prototype.propertyIsEnumerable,ph=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(t){return t.__proto__}:null);function gh(t,e){if(t===1/0||t===-1/0||t!==t||t&&t>-1e3&&t<1e3||Uf.call(/e/,e))return e;var n=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof t=="number"){var r=t<0?-fh(-t):fh(t);if(r!==t){var s=String(r),i=hc.call(e,s.length+1);return tn.call(s,n,"$&_")+"."+tn.call(tn.call(i,/([0-9]{3})/g,"$&_"),/_$/,"")}}return tn.call(e,n,"$&_")}var ll=a_,mh=ll.custom,vh=Wf(mh)?mh:null,Zf={__proto__:null,double:'"',single:"'"},v_={__proto__:null,double:/(["\\])/g,single:/(['\\])/g},Wr=function t(e,n,r,s){var i=n||{};if(It(i,"quoteStyle")&&!It(Zf,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 Vf(e,i);if(typeof e=="number"){if(e===0)return 1/0/e>0?"0":"-0";var l=String(e);return a?gh(e,l):l}if(typeof e=="bigint"){var c=String(e)+"n";return a?gh(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 cl(e)?"[Array]":"[Object]";var f=z_(i,r);if(typeof s>"u")s=[];else if(Bf(s,e)>=0)return"[Circular]";function y(ut,Bt,ta){if(Bt&&(s=m_.call(s),s.push(Bt)),ta){var _i={depth:i.depth};return It(i,"quoteStyle")&&(_i.quoteStyle=i.quoteStyle),t(ut,_i,r+1,s)}return t(ut,i,r+1,s)}if(typeof e=="function"&&!yh(e)){var m=A_(e),E=Ri(e,y);return"[Function"+(m?": "+m:" (anonymous)")+"]"+(E.length>0?" { "+_t.call(E,", ")+" }":"")}if(Wf(e)){var k=Dr?tn.call(String(e),/^(Symbol\(.*\))_[^)]*$/,"$1"):al.call(e);return typeof e=="object"&&!Dr?ts(k):k}if(R_(e)){for(var I="<"+hh.call(String(e.nodeName)),V=e.attributes||[],N=0;N<V.length;N++)I+=" "+V[N].name+"="+jf(y_(V[N].value),"double",i);return I+=">",e.childNodes&&e.childNodes.length&&(I+="..."),I+="</"+hh.call(String(e.nodeName))+">",I}if(cl(e)){if(e.length===0)return"[]";var j=Ri(e,y);return f&&!O_(j)?"["+ul(j,f)+"]":"[ "+_t.call(j,", ")+" ]"}if(w_(e)){var F=Ri(e,y);return!("cause"in Error.prototype)&&"cause"in e&&!Ff.call(e,"cause")?"{ ["+String(e)+"] "+_t.call(dh.call("[cause]: "+y(e.cause),F),", ")+" }":F.length===0?"["+String(e)+"]":"{ ["+String(e)+"] "+_t.call(F,", ")+" }"}if(typeof e=="object"&&o){if(vh&&typeof e[vh]=="function"&&ll)return ll(e,{depth:d-r});if(o!=="symbol"&&typeof e.inspect=="function")return e.inspect()}if(x_(e)){var L=[];return lh&&lh.call(e,function(ut,Bt){L.push(y(Bt,e,!0)+" => "+y(ut,e))}),bh("Map",ho.call(e),L,f)}if(I_(e)){var J=[];return ch&&ch.call(e,function(ut){J.push(y(ut,e))}),bh("Set",fo.call(e),J,f)}if(T_(e))return Pa("WeakMap");if(P_(e))return Pa("WeakSet");if(C_(e))return Pa("WeakRef");if(S_(e))return ts(y(Number(e)));if(E_(e))return ts(y(ol.call(e)));if(k_(e))return ts(h_.call(e));if(__(e))return ts(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(!b_(e)&&!yh(e)){var H=Ri(e,y),he=ph?ph(e)===Object.prototype:e instanceof Object||e.constructor===Object,ct=e instanceof Object?"":"null prototype",wi=!he&&ks&&Object(e)===e&&ks in e?hc.call(dn(e),8,-1):ct?"Object":"",Ee=he||typeof e.constructor!="function"?"":e.constructor.name?e.constructor.name+" ":"",gn=Ee+(wi||ct?"["+_t.call(dh.call([],wi||[],ct||[]),": ")+"] ":"");return H.length===0?gn+"{}":f?gn+"{"+ul(H,f)+"}":gn+"{ "+_t.call(H,", ")+" }"}return String(e)};function jf(t,e,n){var r=n.quoteStyle||e,s=Zf[r];return s+t+s}function y_(t){return tn.call(String(t),/"/g,"&quot;")}function qn(t){return!ks||!(typeof t=="object"&&(ks in t||typeof t[ks]<"u"))}function cl(t){return dn(t)==="[object Array]"&&qn(t)}function b_(t){return dn(t)==="[object Date]"&&qn(t)}function yh(t){return dn(t)==="[object RegExp]"&&qn(t)}function w_(t){return dn(t)==="[object Error]"&&qn(t)}function __(t){return dn(t)==="[object String]"&&qn(t)}function S_(t){return dn(t)==="[object Number]"&&qn(t)}function k_(t){return dn(t)==="[object Boolean]"&&qn(t)}function Wf(t){if(Dr)return t&&typeof t=="object"&&t instanceof Symbol;if(typeof t=="symbol")return!0;if(!t||typeof t!="object"||!al)return!1;try{return al.call(t),!0}catch{}return!1}function E_(t){if(!t||typeof t!="object"||!ol)return!1;try{return ol.call(t),!0}catch{}return!1}var $_=Object.prototype.hasOwnProperty||function(t){return t in this};function It(t,e){return $_.call(t,e)}function dn(t){return d_.call(t)}function A_(t){if(t.name)return t.name;var e=p_.call(f_.call(t),/^function\s*([\w$]+)/);return e?e[1]:null}function Bf(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 x_(t){if(!ho||!t||typeof t!="object")return!1;try{ho.call(t);try{fo.call(t)}catch{return!0}return t instanceof Map}catch{}return!1}function T_(t){if(!_s||!t||typeof t!="object")return!1;try{_s.call(t,_s);try{Ss.call(t,Ss)}catch{return!0}return t instanceof WeakMap}catch{}return!1}function C_(t){if(!uh||!t||typeof t!="object")return!1;try{return uh.call(t),!0}catch{}return!1}function I_(t){if(!fo||!t||typeof t!="object")return!1;try{fo.call(t);try{ho.call(t)}catch{return!0}return t instanceof Set}catch{}return!1}function P_(t){if(!Ss||!t||typeof t!="object")return!1;try{Ss.call(t,Ss);try{_s.call(t,_s)}catch{return!0}return t instanceof WeakSet}catch{}return!1}function R_(t){return!t||typeof t!="object"?!1:typeof HTMLElement<"u"&&t instanceof HTMLElement?!0:typeof t.nodeName=="string"&&typeof t.getAttribute=="function"}function Vf(t,e){if(t.length>e.maxStringLength){var n=t.length-e.maxStringLength,r="... "+n+" more character"+(n>1?"s":"");return Vf(hc.call(t,0,e.maxStringLength),e)+r}var s=v_[e.quoteStyle||"single"];s.lastIndex=0;var i=tn.call(tn.call(t,s,"\\$1"),/[\x00-\x1f]/g,D_);return jf(i,"single",e)}function D_(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":"")+g_.call(e.toString(16))}function ts(t){return"Object("+t+")"}function Pa(t){return t+" { ? }"}function bh(t,e,n,r){var s=r?ul(n,r):_t.call(n,", ");return t+" ("+e+") {"+s+"}"}function O_(t){for(var e=0;e<t.length;e++)if(Bf(t[e],`
2
- `)>=0)return!1;return!0}function z_(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 ul(t,e){if(t.length===0)return"";var n=`
1
+ var Tv=Object.defineProperty;var Au=t=>{throw TypeError(t)};var Iv=(t,e,n)=>e in t?Tv(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var v=(t,e,n)=>Iv(t,typeof e!="symbol"?e+"":e,n),fa=(t,e,n)=>e.has(t)||Au("Cannot "+n);var h=(t,e,n)=>(fa(t,e,"read from private field"),n?n.call(t):e.get(t)),x=(t,e,n)=>e.has(t)?Au("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),$=(t,e,n,r)=>(fa(t,e,"write to private field"),r?r.call(t,n):e.set(t,n),n),b=(t,e,n)=>(fa(t,e,"access private method"),n);var xu=(t,e,n,r)=>({set _(s){$(t,e,s,n)},get _(){return h(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 Pv(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,ff=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,Tu;function Rv(){if(Tu)return pa;Tu=1;var t;if(!Object.keys){var e=Object.prototype.hasOwnProperty,n=Object.prototype.toString,r=ff,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}(),f=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),V=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(V&&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=f(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 Dv=Array.prototype.slice,Ov=ff,Iu=Object.keys,qi=Iu?function(e){return Iu(e)}:Rv(),Pu=Object.keys;qi.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 Ov(r)?Pu(Dv.call(r)):Pu(r)})}else Object.keys=qi;return Object.keys||qi};var zv=qi,Yi=Object.defineProperty||!1;if(Yi)try{Yi({},"a",{value:1})}catch{Yi=!1}var ai=Yi,Zt=SyntaxError,G=TypeError,Lv=Object.getOwnPropertyDescriptor,Ki=Lv;if(Ki)try{Ki([],"length")}catch{Ki=null}var Nr=Ki,Ru=ai,Mv=Zt,rr=G,Du=Nr,pf=function(e,n,r){if(!e||typeof e!="object"&&typeof e!="function")throw new rr("`obj` must be an object or a function`");if(typeof n!="string"&&typeof n!="symbol")throw new rr("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new rr("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new rr("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new rr("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new rr("`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=!!Du&&Du(e,n);if(Ru)Ru(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 Mv("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},il=ai,gf=function(){return!!il};gf.hasArrayLengthDefineBug=function(){if(!il)return null;try{return il([],"length",{value:1}).length!==1}catch{return!0}};var Lo=gf,Nv=zv,Uv=typeof Symbol=="function"&&typeof Symbol("foo")=="symbol",Fv=Object.prototype.toString,Zv=Array.prototype.concat,Ou=pf,jv=function(t){return typeof t=="function"&&Fv.call(t)==="[object Function]"},mf=Lo(),Wv=function(t,e,n,r){if(e in t){if(r===!0){if(t[e]===n)return}else if(!jv(r)||!r())return}mf?Ou(t,e,n,!0):Ou(t,e,n)},vf=function(t,e){var n=arguments.length>2?arguments[2]:{},r=Nv(e);Uv&&(r=Zv.call(r,Object.getOwnPropertySymbols(e)));for(var s=0;s<r.length;s+=1)Wv(t,r[s],e[r[s]],n[r[s]])};vf.supportsDescriptors=!!mf;var Hn=vf,Ji={exports:{}};typeof self<"u"?Ji.exports=self:typeof window<"u"?Ji.exports=window:Ji.exports=Function("return this")();var yf=Ji.exports,Bv=yf,bf=function(){return typeof Sn!="object"||!Sn||Sn.Math!==Math||Sn.Array!==Array?Bv:Sn},Vv=Hn,Gv=Nr,Hv=bf,qv=function(){var e=Hv();if(Vv.supportsDescriptors){var n=Gv(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},Yv=Hn,Kv=yf,wf=bf,Jv=qv,Xv=wf(),_f=function(){return Xv};Yv(_f,{getPolyfill:wf,implementation:Kv,shim:Jv});var Ql=_f,jt=function(e){return!!e&&(typeof e=="function"||typeof e=="object")},ec=Object,Sf=Error,Qv=EvalError,ey=RangeError,tc=ReferenceError,ty=URIError,ny=Math.abs,ry=Math.floor,sy=Math.max,iy=Math.min,oy=Math.pow,ay=Math.round,nc=Number.isNaN||function(e){return e!==e},ly=nc,cy=function(e){return ly(e)||e===0?e:e<0?-1:1},Ur=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},zu=typeof Symbol<"u"&&Symbol,uy=Ur,rc=function(){return typeof zu!="function"||typeof Symbol!="function"||typeof zu("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:uy()},ga,Lu;function kf(){return Lu||(Lu=1,ga=typeof Reflect<"u"&&Reflect.getPrototypeOf||null),ga}var ma,Mu;function Ef(){if(Mu)return ma;Mu=1;var t=ec;return ma=t.getPrototypeOf||null,ma}var hy="Function.prototype.bind called on incompatible ",dy=Object.prototype.toString,fy=Math.max,py="[object Function]",Nu=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},gy=function(e,n){for(var r=[],s=n,i=0;s<e.length;s+=1,i+=1)r[i]=e[s];return r},my=function(t,e){for(var n="",r=0;r<t.length;r+=1)n+=t[r],r+1<t.length&&(n+=e);return n},vy=function(e){var n=this;if(typeof n!="function"||dy.apply(n)!==py)throw new TypeError(hy+n);for(var r=gy(arguments,1),s,i=function(){if(this instanceof s){var d=n.apply(this,Nu(r,arguments));return Object(d)===d?d:this}return n.apply(e,Nu(r,arguments))},o=fy(0,n.length-r.length),a=[],l=0;l<o;l++)a[l]="$"+l;if(s=Function("binder","return function ("+my(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},yy=vy,li=Function.prototype.bind||yy,sc=Function.prototype.call,va,Uu;function ic(){return Uu||(Uu=1,va=Function.prototype.apply),va}var by=typeof Reflect<"u"&&Reflect&&Reflect.apply,wy=li,_y=ic(),Sy=sc,ky=by,$f=ky||wy.call(Sy,_y),Ey=li,$y=G,Ay=sc,xy=$f,Mo=function(e){if(e.length<1||typeof e[0]!="function")throw new $y("a function is required");return xy(Ey,Ay,e)},ya,Fu;function Cy(){if(Fu)return ya;Fu=1;var t=Mo,e=Nr,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 ya=r&&typeof r.get=="function"?t([r.get]):typeof i=="function"?function(a){return i(a==null?a:s(a))}:!1,ya}var ba,Zu;function Af(){if(Zu)return ba;Zu=1;var t=kf(),e=Ef(),n=Cy();return ba=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,ba}var Ty=Function.prototype.call,Iy=Object.prototype.hasOwnProperty,Py=li,Wt=Py.call(Ty,Iy),B,Ry=ec,Dy=Sf,Oy=Qv,zy=ey,Ly=tc,Rr=Zt,br=G,My=ty,Ny=ny,Uy=ry,Fy=sy,Zy=iy,jy=oy,Wy=ay,By=cy,xf=Function,wa=function(t){try{return xf('"use strict"; return ('+t+").constructor;")()}catch{}},xs=Nr,Vy=ai,_a=function(){throw new br},Gy=xs?function(){try{return arguments.callee,_a}catch{try{return xs(arguments,"callee").get}catch{return _a}}}():_a,sr=rc(),_e=Af(),Hy=Ef(),qy=kf(),Cf=ic(),ci=sc,ar={},Yy=typeof Uint8Array>"u"||!_e?B:_e(Uint8Array),Zn={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?B:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?B:ArrayBuffer,"%ArrayIteratorPrototype%":sr&&_e?_e([][Symbol.iterator]()):B,"%AsyncFromSyncIteratorPrototype%":B,"%AsyncFunction%":ar,"%AsyncGenerator%":ar,"%AsyncGeneratorFunction%":ar,"%AsyncIteratorPrototype%":ar,"%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%":Dy,"%eval%":eval,"%EvalError%":Oy,"%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%":xf,"%GeneratorFunction%":ar,"%Int8Array%":typeof Int8Array>"u"?B:Int8Array,"%Int16Array%":typeof Int16Array>"u"?B:Int16Array,"%Int32Array%":typeof Int32Array>"u"?B:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":sr&&_e?_e(_e([][Symbol.iterator]())):B,"%JSON%":typeof JSON=="object"?JSON:B,"%Map%":typeof Map>"u"?B:Map,"%MapIteratorPrototype%":typeof Map>"u"||!sr||!_e?B:_e(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Ry,"%Object.getOwnPropertyDescriptor%":xs,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?B:Promise,"%Proxy%":typeof Proxy>"u"?B:Proxy,"%RangeError%":zy,"%ReferenceError%":Ly,"%Reflect%":typeof Reflect>"u"?B:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?B:Set,"%SetIteratorPrototype%":typeof Set>"u"||!sr||!_e?B:_e(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?B:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":sr&&_e?_e(""[Symbol.iterator]()):B,"%Symbol%":sr?Symbol:B,"%SyntaxError%":Rr,"%ThrowTypeError%":Gy,"%TypedArray%":Yy,"%TypeError%":br,"%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%":My,"%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%":Cf,"%Object.defineProperty%":Vy,"%Object.getPrototypeOf%":Hy,"%Math.abs%":Ny,"%Math.floor%":Uy,"%Math.max%":Fy,"%Math.min%":Zy,"%Math.pow%":jy,"%Math.round%":Wy,"%Math.sign%":By,"%Reflect.getPrototypeOf%":qy};if(_e)try{null.error}catch(t){var Ky=_e(_e(t));Zn["%Error.prototype%"]=Ky}var Jy=function t(e){var n;if(e==="%AsyncFunction%")n=wa("async function () {}");else if(e==="%GeneratorFunction%")n=wa("function* () {}");else if(e==="%AsyncGeneratorFunction%")n=wa("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 Zn[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,co=Wt,Xy=ui.call(ci,Array.prototype.concat),Qy=ui.call(Cf,Array.prototype.splice),Wu=ui.call(ci,String.prototype.replace),uo=ui.call(ci,String.prototype.slice),eb=ui.call(ci,RegExp.prototype.exec),tb=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,nb=/\\(\\)?/g,rb=function(e){var n=uo(e,0,1),r=uo(e,-1);if(n==="%"&&r!=="%")throw new Rr("invalid intrinsic syntax, expected closing `%`");if(r==="%"&&n!=="%")throw new Rr("invalid intrinsic syntax, expected opening `%`");var s=[];return Wu(e,tb,function(i,o,a,l){s[s.length]=a?Wu(l,nb,"$1"):o||i}),s},sb=function(e,n){var r=e,s;if(co(ju,r)&&(s=ju[r],r="%"+s[0]+"%"),co(Zn,r)){var i=Zn[r];if(i===ar&&(i=Jy(r)),typeof i>"u"&&!n)throw new br("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:s,name:r,value:i}}throw new Rr("intrinsic "+e+" does not exist!")},tt=function(e,n){if(typeof e!="string"||e.length===0)throw new br("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof n!="boolean")throw new br('"allowMissing" argument must be a boolean');if(eb(/^%?[^%]*%?$/,e)===null)throw new Rr("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var r=rb(e),s=r.length>0?r[0]:"",i=sb("%"+s+"%",n),o=i.name,a=i.value,l=!1,c=i.alias;c&&(s=c[0],Qy(r,Xy([0,1],c)));for(var d=1,f=!0;d<r.length;d+=1){var y=r[d],m=uo(y,0,1),E=uo(y,-1);if((m==='"'||m==="'"||m==="`"||E==='"'||E==="'"||E==="`")&&m!==E)throw new Rr("property names with quotes must have matching quotes");if((y==="constructor"||!f)&&(l=!0),s+="."+y,o="%"+s+"%",co(Zn,o))a=Zn[o];else if(a!=null){if(!(y in a)){if(!n)throw new br("base intrinsic for "+e+" exists, but the property is not available.");return}if(xs&&d+1>=r.length){var k=xs(a,y);f=!!k,f&&"get"in k&&!("originalValue"in k.get)?a=k.get:a=a[y]}else f=co(a,y),a=a[y];f&&!l&&(Zn[o]=a)}}return a},Sa,Bu;function hn(){if(Bu)return Sa;Bu=1;var t=tt,e=Mo,n=e([t("%String.prototype.indexOf%")]);return Sa=function(s,i){var o=t(s,!!i);return typeof o=="function"&&n(s,".prototype.")>-1?e([o]):o},Sa}var ka,Vu;function oc(){if(Vu)return ka;Vu=1;var t=tt,e=t("%Array%"),n=!e.isArray&&hn()("Object.prototype.toString");return ka=e.isArray||function(s){return n(s)==="[object Array]"},ka}var ib=Lo,Gu=ai,Tf=ib.hasArrayLengthDefineBug(),ob=Tf&&oc(),ab=hn(),lb=ab("Object.prototype.propertyIsEnumerable"),ac=function(e,n,r,s,i,o){if(!Gu){if(!e(o)||!o["[[Configurable]]"]||!o["[[Writable]]"]||i in s&&lb(s,i)!==!!o["[[Enumerable]]"])return!1;var a=o["[[Value]]"];return s[i]=a,n(s[i],a)}return Tf&&i==="length"&&"[[Value]]"in o&&ob(s)&&s.length!==o["[[Value]]"]?(s.length=o["[[Value]]"],s.length===o["[[Value]]"]):(Gu(s,i,r(o)),!0)},cb=G,ts=Wt,ub={__proto__:null,"[[Configurable]]":!0,"[[Enumerable]]":!0,"[[Get]]":!0,"[[Set]]":!0,"[[Value]]":!0,"[[Writable]]":!0},Fr=function(e){if(!e||typeof e!="object")return!1;for(var n in e)if(ts(e,n)&&!ub[n])return!1;var r=ts(e,"[[Value]]")||ts(e,"[[Writable]]"),s=ts(e,"[[Get]]")||ts(e,"[[Set]]");if(r&&s)throw new cb("Property Descriptors may not be both accessor and data descriptors");return!0},If=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},hb=G,db=Fr,fb=If,Pf=function(e){if(typeof e<"u"&&!db(e))throw new hb("Assertion failed: `Desc` must be a Property Descriptor");return fb(e)},pb=G,Hu=Wt,gb=Fr,Rf=function(e){if(typeof e>"u")return!1;if(!gb(e))throw new pb("Assertion failed: `Desc` must be a Property Descriptor");return!(!Hu(e,"[[Value]]")&&!Hu(e,"[[Writable]]"))},Zr=function(e){return typeof e=="string"||typeof e=="symbol"},qu=nc,Df=function(e,n){return e===n?e===0?1/e===1/n:!0:qu(e)&&qu(n)},Yu=G,mb=jt,vb=ac,yb=Pf,bb=Rf,wb=Zr,_b=Df,lc=function(e,n,r){if(!mb(e))throw new Yu("Assertion failed: Type(O) is not Object");if(!wb(n))throw new Yu("Assertion failed: P is not a Property Key");var s={"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Value]]":r,"[[Writable]]":!0};return vb(bb,_b,yb,e,n,s)},Of=Function.prototype.toString,gr=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,ol,Xi;if(typeof gr=="function"&&typeof Object.defineProperty=="function")try{ol=Object.defineProperty({},"length",{get:function(){throw Xi}}),Xi={},gr(function(){throw 42},null,ol)}catch(t){t!==Xi&&(gr=null)}else gr=null;var Sb=/^\s*class\b/,al=function(e){try{var n=Of.call(e);return Sb.test(n)}catch{return!1}},Ea=function(e){try{return al(e)?!1:(Of.call(e),!0)}catch{return!1}},Qi=Object.prototype.toString,kb="[object Object]",Eb="[object Function]",$b="[object GeneratorFunction]",Ab="[object HTMLAllCollection]",xb="[object HTML document.all class]",Cb="[object HTMLCollection]",Tb=typeof Symbol=="function"&&!!Symbol.toStringTag,Ib=!(0 in[,]),ll=function(){return!1};if(typeof document=="object"){var Pb=document.all;Qi.call(Pb)===Qi.call(document.all)&&(ll=function(e){if((Ib||!e)&&(typeof e>"u"||typeof e=="object"))try{var n=Qi.call(e);return(n===Ab||n===xb||n===Cb||n===kb)&&e("")==null}catch{}return!1})}var zf=gr?function(e){if(ll(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;try{gr(e,null,ol)}catch(n){if(n!==Xi)return!1}return!al(e)&&Ea(e)}:function(e){if(ll(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;if(Tb)return Ea(e);if(al(e))return!1;var n=Qi.call(e);return n!==Eb&&n!==$b&&!/^\[object HTML/.test(n)?!1:Ea(e)},Rb=zf,Db=function(e){return!!e},ft=Wt,Ii=G,Ob=jt,Ku=Rb,$a=Db,zb=function(e){if(!Ob(e))throw new Ii("ToPropertyDescriptor requires an object");var n={};if(ft(e,"enumerable")&&(n["[[Enumerable]]"]=$a(e.enumerable)),ft(e,"configurable")&&(n["[[Configurable]]"]=$a(e.configurable)),ft(e,"value")&&(n["[[Value]]"]=e.value),ft(e,"writable")&&(n["[[Writable]]"]=$a(e.writable)),ft(e,"get")){var r=e.get;if(typeof r<"u"&&!Ku(r))throw new Ii("getter must be a function");n["[[Get]]"]=r}if(ft(e,"set")){var s=e.set;if(typeof s<"u"&&!Ku(s))throw new Ii("setter must be a function");n["[[Set]]"]=s}if((ft(n,"[[Get]]")||ft(n,"[[Set]]"))&&(ft(n,"[[Value]]")||ft(n,"[[Writable]]")))throw new Ii("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute");return n},Aa=G,Lb=jt,Ju=Fr,Mb=ac,Nb=Pf,Ub=Rf,Fb=Zr,Zb=Df,jb=zb,Wb=function(e,n,r){if(!Lb(e))throw new Aa("Assertion failed: Type(O) is not Object");if(!Fb(n))throw new Aa("Assertion failed: P is not a Property Key");var s=Ju(r)?r:jb(r);if(!Ju(s))throw new Aa("Assertion failed: Desc is not a valid Property Descriptor");return Mb(Ub,Zb,Nb,e,n,s)},Xu=G,Bb=jt,Vb=Wb,Gb=Zr,Hb=function(e,n,r){if(!Bb(e))throw new Xu("Assertion failed: Type(O) is not Object");if(!Gb(n))throw new Xu("Assertion failed: P is not a Property Key");var s={"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Value]]":r,"[[Writable]]":!0};return Vb(e,n,s)},qb=typeof Reflect<"u"&&Reflect.setPrototypeOf||null,Yb=ec,Kb=Yb.setPrototypeOf||null,Jb=Mo,Qu=Nr,Xb=G,Lf={};try{Lf.__proto__=null}catch(t){if(!t||typeof t!="object"||!("code"in t)||t.code!=="ERR_PROTO_ACCESS")throw t}var Qb=!("toString"in Lf),xa=Qu&&Qu(Object.prototype,"__proto__"),ew=Qb&&(!!xa&&typeof xa.set=="function"&&Jb([xa.set])||function(e,n){if(e==null)throw new Xb("set Object.prototype.__proto__ called on null or undefined");return e.__proto__=n,n}),eh=qb,tw=Kb,th=ew,nw=G,rw=eh?function(e,n){if(eh(e,n))return e;throw new nw("Reflect.setPrototypeOf: failed to set [[Prototype]]")}:tw||(th?function(e,n){return th(e,n),e}:null),nh=G,sw=jt,rh=Af(),iw=function(e){if(!sw(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)},ow=G,aw=rw,lw=jt,cw=iw,uw=function(e,n){if(n!==null&&!lw(n))throw new ow("Assertion failed: V must be Object or Null");try{aw(e,n)}catch{return!1}return cw(e)===n},Ca=lc,sh=Hb,Mf=uw,hw=Lo(),cc=Sf;function hi(t,e,n){var r=new cc(n);return Mf(r,eo),delete r.constructor,sh(r,"error",t),sh(r,"suppressed",e),r}hw&&Object.defineProperty(hi,"prototype",{writable:!1});var eo=hi.prototype;if(!Ca(eo,"constructor",hi)||!Ca(eo,"message","")||!Ca(eo,"name","SuppressedError"))throw new cc("unable to install SuppressedError.prototype properties; please report this!");Mf(hi.prototype,cc.prototype);var dw=hi,fw=dw,Nf=function(){return typeof SuppressedError=="function"?SuppressedError:fw},pw=Hn,ih=Ql(),gw=Nf,mw=function(){var e=gw();return pw(ih,{SuppressedError:e},{SuppressedError:function(){return ih.SuppressedError!==e}}),e};mw();var vw=G,yw=Fr,bw=If,ww=function(e){if(typeof e<"u"&&!yw(e))throw new vw("Assertion failed: `Desc` must be a Property Descriptor");return bw(e)},_w=G,oh=Wt,Sw=Fr,kw=function(e){if(typeof e>"u")return!1;if(!Sw(e))throw new _w("Assertion failed: `Desc` must be a Property Descriptor");return!(!oh(e,"[[Value]]")&&!oh(e,"[[Writable]]"))},ah=nc,Ew=function(e,n){return e===n?e===0?1/e===1/n:!0:ah(e)&&ah(n)},jr=zf,$w=function(e){return!!e},pt=Wt,Pi=G,Aw=jt,lh=jr,Ta=$w,xw=function(e){if(!Aw(e))throw new Pi("ToPropertyDescriptor requires an object");var n={};if(pt(e,"enumerable")&&(n["[[Enumerable]]"]=Ta(e.enumerable)),pt(e,"configurable")&&(n["[[Configurable]]"]=Ta(e.configurable)),pt(e,"value")&&(n["[[Value]]"]=e.value),pt(e,"writable")&&(n["[[Writable]]"]=Ta(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},Ia=G,Cw=jt,ch=Fr,Tw=ac,Iw=ww,Pw=kw,Rw=Zr,Dw=Ew,Ow=xw,di=function(e,n,r){if(!Cw(e))throw new Ia("Assertion failed: Type(O) is not Object");if(!Rw(n))throw new Ia("Assertion failed: P is not a Property Key");var s=ch(r)?r:Ow(r);if(!ch(s))throw new Ia("Assertion failed: Desc is not a valid Property Descriptor");return Tw(Pw,Dw,Iw,e,n,s)},zw=Ur(),Lw=zw?Symbol.dispose||Symbol("Symbol.dispose"):null,Mw=Ur,Nw=Lw,uc=function(){return Mw()&&Symbol.dispose||Nw},Uw=rc,Fw=di,Zw=uc,jw=function(){var e=Zw();return Uw()&&Fw(Symbol,"dispose",{"[[Configurable]]":!1,"[[Enumerable]]":!1,"[[Writable]]":!1,"[[Value]]":e}),e},Ww=Ur(),Bw=Ww?Symbol.asyncDispose||Symbol("Symbol.asyncDispose"):null,Vw=Ur,Gw=Bw,hc=function(){return Vw()&&Symbol.asyncDispose||Gw},Hw=rc,qw=di,Yw=hc,Kw=function(){var e=Yw();return Hw()&&qw(Symbol,"asyncDispose",{"[[Configurable]]":!1,"[[Enumerable]]":!1,"[[Writable]]":!1,"[[Value]]":e}),e},Jw=oc(),Xw=tt,Qw=hn(),e_=G,t_=Jw,n_=Xw("%Reflect.apply%",!0)||Qw("Function.prototype.apply"),No=function(e,n){var r=arguments.length>2?arguments[2]:[];if(!t_(r))throw new e_("Assertion failed: optional `argumentsList`, if provided, must be a List");return n_(e,n,r)};const r_={},s_=Object.freeze(Object.defineProperty({__proto__:null,default:r_},Symbol.toStringTag,{value:"Module"})),i_=Pv(s_);var dc=typeof Map=="function"&&Map.prototype,Pa=Object.getOwnPropertyDescriptor&&dc?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,ho=dc&&Pa&&typeof Pa.get=="function"?Pa.get:null,uh=dc&&Map.prototype.forEach,fc=typeof Set=="function"&&Set.prototype,Ra=Object.getOwnPropertyDescriptor&&fc?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,fo=fc&&Ra&&typeof Ra.get=="function"?Ra.get:null,hh=fc&&Set.prototype.forEach,o_=typeof WeakMap=="function"&&WeakMap.prototype,Ss=o_?WeakMap.prototype.has:null,a_=typeof WeakSet=="function"&&WeakSet.prototype,ks=a_?WeakSet.prototype.has:null,l_=typeof WeakRef=="function"&&WeakRef.prototype,dh=l_?WeakRef.prototype.deref:null,c_=Boolean.prototype.valueOf,u_=Object.prototype.toString,h_=Function.prototype.toString,d_=String.prototype.match,pc=String.prototype.slice,tn=String.prototype.replace,f_=String.prototype.toUpperCase,fh=String.prototype.toLowerCase,Uf=RegExp.prototype.test,ph=Array.prototype.concat,_t=Array.prototype.join,p_=Array.prototype.slice,gh=Math.floor,cl=typeof BigInt=="function"?BigInt.prototype.valueOf:null,Da=Object.getOwnPropertySymbols,ul=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,Dr=typeof Symbol=="function"&&typeof Symbol.iterator=="object",Es=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===Dr||!0)?Symbol.toStringTag:null,Ff=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||Uf.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=pc.call(e,s.length+1);return tn.call(s,n,"$&_")+"."+tn.call(tn.call(i,/([0-9]{3})/g,"$&_"),/_$/,"")}}return tn.call(e,n,"$&_")}var hl=i_,yh=hl.custom,bh=Wf(yh)?yh:null,Zf={__proto__:null,double:'"',single:"'"},g_={__proto__:null,double:/(["\\])/g,single:/(['\\])/g},Wr=function t(e,n,r,s){var i=n||{};if(It(i,"quoteStyle")&&!It(Zf,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 Vf(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 dl(e)?"[Array]":"[Object]";var f=D_(i,r);if(typeof s>"u")s=[];else if(Bf(s,e)>=0)return"[Circular]";function y(ut,Bt,ta){if(Bt&&(s=p_.call(s),s.push(Bt)),ta){var _i={depth:i.depth};return It(i,"quoteStyle")&&(_i.quoteStyle=i.quoteStyle),t(ut,_i,r+1,s)}return t(ut,i,r+1,s)}if(typeof e=="function"&&!wh(e)){var m=E_(e),E=Ri(e,y);return"[Function"+(m?": "+m:" (anonymous)")+"]"+(E.length>0?" { "+_t.call(E,", ")+" }":"")}if(Wf(e)){var k=Dr?tn.call(String(e),/^(Symbol\(.*\))_[^)]*$/,"$1"):ul.call(e);return typeof e=="object"&&!Dr?ns(k):k}if(I_(e)){for(var I="<"+fh.call(String(e.nodeName)),V=e.attributes||[],N=0;N<V.length;N++)I+=" "+V[N].name+"="+jf(m_(V[N].value),"double",i);return I+=">",e.childNodes&&e.childNodes.length&&(I+="..."),I+="</"+fh.call(String(e.nodeName))+">",I}if(dl(e)){if(e.length===0)return"[]";var j=Ri(e,y);return f&&!R_(j)?"["+fl(j,f)+"]":"[ "+_t.call(j,", ")+" ]"}if(y_(e)){var F=Ri(e,y);return!("cause"in Error.prototype)&&"cause"in e&&!Ff.call(e,"cause")?"{ ["+String(e)+"] "+_t.call(ph.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"&&hl)return hl(e,{depth:d-r});if(o!=="symbol"&&typeof e.inspect=="function")return e.inspect()}if($_(e)){var L=[];return uh&&uh.call(e,function(ut,Bt){L.push(y(Bt,e,!0)+" => "+y(ut,e))}),_h("Map",ho.call(e),L,f)}if(C_(e)){var J=[];return hh&&hh.call(e,function(ut){J.push(y(ut,e))}),_h("Set",fo.call(e),J,f)}if(A_(e))return Oa("WeakMap");if(T_(e))return Oa("WeakSet");if(x_(e))return Oa("WeakRef");if(w_(e))return ns(y(Number(e)));if(S_(e))return ns(y(cl.call(e)));if(__(e))return ns(c_.call(e));if(b_(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(!v_(e)&&!wh(e)){var H=Ri(e,y),he=mh?mh(e)===Object.prototype:e instanceof Object||e.constructor===Object,ct=e instanceof Object?"":"null prototype",wi=!he&&Es&&Object(e)===e&&Es in e?pc.call(dn(e),8,-1):ct?"Object":"",Ee=he||typeof e.constructor!="function"?"":e.constructor.name?e.constructor.name+" ":"",gn=Ee+(wi||ct?"["+_t.call(ph.call([],wi||[],ct||[]),": ")+"] ":"");return H.length===0?gn+"{}":f?gn+"{"+fl(H,f)+"}":gn+"{ "+_t.call(H,", ")+" }"}return String(e)};function jf(t,e,n){var r=n.quoteStyle||e,s=Zf[r];return s+t+s}function m_(t){return tn.call(String(t),/"/g,"&quot;")}function qn(t){return!Es||!(typeof t=="object"&&(Es in t||typeof t[Es]<"u"))}function dl(t){return dn(t)==="[object Array]"&&qn(t)}function v_(t){return dn(t)==="[object Date]"&&qn(t)}function wh(t){return dn(t)==="[object RegExp]"&&qn(t)}function y_(t){return dn(t)==="[object Error]"&&qn(t)}function b_(t){return dn(t)==="[object String]"&&qn(t)}function w_(t){return dn(t)==="[object Number]"&&qn(t)}function __(t){return dn(t)==="[object Boolean]"&&qn(t)}function Wf(t){if(Dr)return t&&typeof t=="object"&&t instanceof Symbol;if(typeof t=="symbol")return!0;if(!t||typeof t!="object"||!ul)return!1;try{return ul.call(t),!0}catch{}return!1}function S_(t){if(!t||typeof t!="object"||!cl)return!1;try{return cl.call(t),!0}catch{}return!1}var k_=Object.prototype.hasOwnProperty||function(t){return t in this};function It(t,e){return k_.call(t,e)}function dn(t){return u_.call(t)}function E_(t){if(t.name)return t.name;var e=d_.call(h_.call(t),/^function\s*([\w$]+)/);return e?e[1]:null}function Bf(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 $_(t){if(!ho||!t||typeof t!="object")return!1;try{ho.call(t);try{fo.call(t)}catch{return!0}return t instanceof Map}catch{}return!1}function A_(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 x_(t){if(!dh||!t||typeof t!="object")return!1;try{return dh.call(t),!0}catch{}return!1}function C_(t){if(!fo||!t||typeof t!="object")return!1;try{fo.call(t);try{ho.call(t)}catch{return!0}return t instanceof Set}catch{}return!1}function T_(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 I_(t){return!t||typeof t!="object"?!1:typeof HTMLElement<"u"&&t instanceof HTMLElement?!0:typeof t.nodeName=="string"&&typeof t.getAttribute=="function"}function Vf(t,e){if(t.length>e.maxStringLength){var n=t.length-e.maxStringLength,r="... "+n+" more character"+(n>1?"s":"");return Vf(pc.call(t,0,e.maxStringLength),e)+r}var s=g_[e.quoteStyle||"single"];s.lastIndex=0;var i=tn.call(tn.call(t,s,"\\$1"),/[\x00-\x1f]/g,P_);return jf(i,"single",e)}function P_(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":"")+f_.call(e.toString(16))}function ns(t){return"Object("+t+")"}function Oa(t){return t+" { ? }"}function _h(t,e,n,r){var s=r?fl(n,r):_t.call(n,", ");return t+" ("+e+") {"+s+"}"}function R_(t){for(var e=0;e<t.length;e++)if(Bf(t[e],`
2
+ `)>=0)return!1;return!0}function D_(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 fl(t,e){if(t.length===0)return"";var n=`
3
3
  `+e.prev+e.base;return n+_t.call(t,","+n)+`
4
- `+e.prev}function Ri(t,e){var n=cl(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 Ia=="function"?Ia(t):[],o;if(Dr){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||Dr&&o["$"+l]instanceof Symbol||(Uf.call(/[^\w$]/,l)?r.push(e(l,t)+": "+e(t[l],t)):r.push(l+": "+e(t[l],t))));if(typeof Ia=="function")for(var c=0;c<i.length;c++)Ff.call(t,i[c])&&r.push("["+e(i[c])+"]: "+e(t[i[c]],t));return r}var L_=Wr,M_=G,Uo=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},N_=function(t,e){if(t){var n=Uo(t,e);return n&&n.value}},U_=function(t,e,n){var r=Uo(t,e);r?r.value=n:t.next={key:e,next:t.next,value:n}},F_=function(t,e){return t?!!Uo(t,e):!1},Z_=function(t,e){if(t)return Uo(t,e,!0)},j_=function(){var e,n={assert:function(r){if(!n.has(r))throw new M_("Side channel does not contain "+L_(r))},delete:function(r){var s=e&&e.next,i=Z_(e,r);return i&&s&&s===i&&(e=void 0),!!i},get:function(r){return N_(e,r)},has:function(r){return F_(e,r)},set:function(r,s){e||(e={next:void 0}),U_(e,r,s)}};return n},W_=tt,di=hn(),B_=Wr,V_=G,wh=W_("%Map%",!0),G_=di("Map.prototype.get",!0),H_=di("Map.prototype.set",!0),q_=di("Map.prototype.has",!0),Y_=di("Map.prototype.delete",!0),K_=di("Map.prototype.size",!0),Gf=!!wh&&function(){var e,n={assert:function(r){if(!n.has(r))throw new V_("Side channel does not contain "+B_(r))},delete:function(r){if(e){var s=Y_(e,r);return K_(e)===0&&(e=void 0),s}return!1},get:function(r){if(e)return G_(e,r)},has:function(r){return e?q_(e,r):!1},set:function(r,s){e||(e=new wh),H_(e,r,s)}};return n},J_=tt,Fo=hn(),X_=Wr,Di=Gf,Q_=G,ir=J_("%WeakMap%",!0),eS=Fo("WeakMap.prototype.get",!0),tS=Fo("WeakMap.prototype.set",!0),nS=Fo("WeakMap.prototype.has",!0),rS=Fo("WeakMap.prototype.delete",!0),sS=ir?function(){var e,n,r={assert:function(s){if(!r.has(s))throw new Q_("Side channel does not contain "+X_(s))},delete:function(s){if(ir&&s&&(typeof s=="object"||typeof s=="function")){if(e)return rS(e,s)}else if(Di&&n)return n.delete(s);return!1},get:function(s){return ir&&s&&(typeof s=="object"||typeof s=="function")&&e?eS(e,s):n&&n.get(s)},has:function(s){return ir&&s&&(typeof s=="object"||typeof s=="function")&&e?nS(e,s):!!n&&n.has(s)},set:function(s,i){ir&&s&&(typeof s=="object"||typeof s=="function")?(e||(e=new ir),tS(e,s,i)):Di&&(n||(n=Di()),n.set(s,i))}};return r}:Di,iS=G,oS=Wr,aS=j_,lS=Gf,cS=sS,uS=cS||lS||aS,hS=function(){var e,n={assert:function(r){if(!n.has(r))throw new iS("Side channel does not contain "+oS(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=uS()),e.set(r,s)}};return n},dS=Wt,ns=hS(),xt=G,dc={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(ns.assert(t),!dc.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=ns.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=ns.get(t);return!!n&&dS(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=ns.get(t);r||(r={},ns.set(t,r)),r["$"+e]=n}};Object.freeze&&Object.freeze(dc);var fc=dc,Hf=Zt,sn=fc,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 Hf('Assertion failed: `type` must be one of "normal", "break", "continue", "return", or "throw"');sn.set(this,"[[Type]]",e),sn.set(this,"[[Value]]",n)};fi.prototype.type=function(){return sn.get(this,"[[Type]]")};fi.prototype.value=function(){return sn.get(this,"[[Value]]")};fi.prototype["?"]=function(){var e=sn.get(this,"[[Type]]"),n=sn.get(this,"[[Value]]");if(e==="throw")throw n;return n};fi.prototype["!"]=function(){var e=sn.get(this,"[[Type]]");if(e!=="normal")throw new Hf('Assertion failed: Completion Record is not of type "normal"');return sn.get(this,"[[Value]]")};var pc=fi,fS=pc,gc=function(e){return new fS("normal",e)},Ra,_h;function pS(){if(_h)return Ra;_h=1;var t=Ur;return Ra=function(){return t()&&!!Symbol.toStringTag},Ra}var gS=tt,Sh=gS("%Object.defineProperty%",!0),mS=pS()(),vS=Wt,yS=G,Oi=mS?Symbol.toStringTag:null,qf=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 yS("if provided, the `overrideIfSet` and `nonConfigurable` options must be booleans");Oi&&(r||!vS(e,Oi))&&(Sh?Sh(e,Oi,{configurable:!s,enumerable:!1,value:n,writable:!1}):e[Oi]=n)},Yf={exports:{}},bS=tt,kh=df,wS=Lo(),Eh=Nr,$h=G,_S=bS("%Math.floor%"),SS=function(e,n){if(typeof e!="function")throw new $h("`fn` is not a function");if(typeof n!="number"||n<0||n>4294967295||_S(n)!==n)throw new $h("`length` must be a positive 32-bit integer");var r=arguments.length>2&&!!arguments[2],s=!0,i=!0;if("length"in e&&Eh){var o=Eh(e,"length");o&&!o.configurable&&(s=!1),o&&!o.writable&&(i=!1)}return(s||i||!r)&&(wS?kh(e,"length",n,!0,!0):kh(e,"length",n)),e},kS=ai,ES=nc(),$S=kf,AS=function(){return $S(kS,ES,arguments)};(function(t){var e=SS,n=oi,r=Mo,s=AS;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})(Yf);var mc=Yf.exports,xS=function(e,n){for(var r=0;r<e.length;r+=1)if(!n(e[r],r,e))return!1;return!0},TS=Object,CS=function(e){return e&&typeof e=="object"&&(typeof e["[[ResourceValue]]"]>"u"||TS(e["[[ResourceValue]]"])===e["[[ResourceValue]]"])&&(e["[[Hint]]"]==="SYNC-DISPOSE"||e["[[Hint]]"]==="ASYNC-DISPOSE")&&(typeof e["[[DisposeMethod]]"]=="function"||typeof e["[[DisposeMethod]]"]>"u")},IS=Wt,PS=rc(),RS=xS,DS=CS,OS=function(e){return e&&typeof e=="object"&&IS(e,"[[DisposableResourceStack]]")&&PS(e["[[DisposableResourceStack]]"])&&(e["[[DisposableResourceStack]]"].length===0||RS(e["[[DisposableResourceStack]]"],DS))},zS=jt,LS=function(e){if(e===null)return"Null";if(typeof e>"u")return"Undefined";if(zS(e))return"Object";if(typeof e=="number")return"Number";if(typeof e=="boolean")return"Boolean";if(typeof e=="string")return"String"},MS=LS,vc=function(e){return typeof e=="symbol"?"Symbol":typeof e=="bigint"?"BigInt":MS(e)},NS=G,US=Wr,FS=Zr,ZS=function(e,n){if(!FS(n))throw new NS("Assertion failed: P is not a Property Key, got "+US(n));return e[n]},Ah=G,jS=ZS,WS=jr,BS=Zr,xh=Wr,VS=function(e,n){if(!BS(n))throw new Ah("Assertion failed: P is not a Property Key");var r=jS(e,n);if(r!=null){if(!WS(r))throw new Ah(xh(n)+" is not a function: "+xh(r));return r}},hl={exports:{}},GS=tt,HS=GS,Th=HS("%Reflect.construct%",!0),po=hi;try{po({},"",{"[[Get]]":function(){}})}catch{po=null}if(po&&Th){var Ch={},Ih={};po(Ih,"length",{"[[Get]]":function(){throw Ch},"[[Enumerable]]":!0}),hl.exports=function(e){try{Th(e,Ih)}catch(n){return n===Ch}}}else hl.exports=function(e){return typeof e=="function"&&!!e.prototype};var qS=hl.exports,Da=G,Ph=jr,YS=qS,KS=function(e){if(!YS(e))throw new Da("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 Da("executor has already been called");n["[[Resolve]]"]=s,n["[[Reject]]"]=i});if(!Ph(n["[[Resolve]]"])||!Ph(n["[[Reject]]"]))throw new Da("executor must provide valid resolve and reject functions");return{"[[Promise]]":r,"[[Resolve]]":n["[[Resolve]]"],"[[Reject]]":n["[[Reject]]"]}},Rh=Zt,JS=G,Oa=No,Dh=VS,XS=KS,QS=vc,Oh=ac(),zh=lc(),ek=function(e,n){if(QS(e)!=="Object")throw new JS("`V` must be an Object");if(n!=="SYNC-DISPOSE"&&n!=="ASYNC-DISPOSE")throw new Rh("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");var r;if(n==="ASYNC-DISPOSE"&&zh&&(r=Dh(e,zh)),!r){if(!Oh)throw new Rh("`Symbol.dispose` is not supported");if(r=Dh(e,Oh),typeof r<"u")return function(){var s=this;if(n==="ASYNC-DISPOSE"){var i=XS(Promise);try{Oa(r,s),Oa(i["[[Resolve]]"],void 0,[void 0])}catch(o){i["[[Reject]]"](o)}return i["[[Promise]]"]}Oa(r,s)}}return r},tk=Zt,za=G,nk=jr,rk=vc,sk=ek,ik=function(e,n){if(n!=="SYNC-DISPOSE"&&n!=="ASYNC-DISPOSE")throw new tk("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"&&rk(e)!=="Object")throw new za("`V` must be an Object, or `null` or `undefined`");if(r=sk(e,n),typeof r>"u")throw new za("dispose method must not be `undefined` on `V` when an object `V` is provided")}else if(r=arguments[2],!nk(r))throw new za("`method`, when provided, must be a function");return{"[[ResourceValue]]":e,"[[Hint]]":n,"[[DisposeMethod]]":r}},ok=Zt,zi=G,ak=OS,Lh=ik,lk=hn(),ck=lk("Array.prototype.push"),Kf=function(e,n,r){if(!ak(e))throw new zi("Assertion failed: `disposeCapability` must be a DisposeCapability Record");if(r!=="SYNC-DISPOSE"&&r!=="ASYNC-DISPOSE")throw new ok("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=Lh(n,r)}else{if(typeof n<"u")throw new zi("Assertion failed: `V` must be undefined when `method` is present");i=Lh(void 0,r,s)}return ck(e["[[DisposableResourceStack]]"],i),"UNUSED"},La,Mh;function yc(){if(Mh)return La;Mh=1;var t=tt,e=mc,n=Zt,r=t("%Promise.resolve%",!0),s=r&&e(r);return La=function(o,a){if(!s)throw new n("This environment does not support Promises.");return s(o,a)},La}var Ma,Nh;function uk(){if(Nh)return Ma;Nh=1;var t=tt,e=Zt,n=t("%Promise%",!0),r=No,s=yc(),i=vc;return Ma=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)},Ma}var Na,Uh;function hk(){if(Uh)return Na;Uh=1;var t=pc;return Na=function(n){return new t("throw",n)},Na}var dk=tt,Ua=Zt,Fh=G,fk=dk("%Promise%",!0),pk=hn(),Zh=pk("Promise.prototype.then",!0),gk=pc,jh=uk(),mk=gc,vk=yc(),Wh=hk(),yk=Nf(),Jf=function(e,n){if(!(n instanceof gk))throw new Fh("`completion` must be a Completion Record");var r=e["[[DisposableResourceStack]]"];if(!r)throw new Fh("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 Ua("mixed hint stacks are not supported");for(var o=s==="ASYNC-DISPOSE"&&vk(fk,n),a=function(y){if(n.type()==="throw"){var m=n.value(),E=new yk(y,m);n=Wh(E)}else n=Wh(y)},l=s==="ASYNC-DISPOSE"&&function(m){return Zh(o,function(){var E=jh(m["[[ResourceValue]]"],m["[[Hint]]"],m["[[DisposeMethod]]"]);if(!E)throw new Ua("Assertion failed: non-`~ASYNC-DISPOSE~` resource returned a promise from Dispose");return Zh(E,mk)},a)},c=r.length-1;c>=0;c-=1)if(s==="ASYNC-DISPOSE")o=l(r[c]);else{var d=r[c];try{var f=jh(d["[[ResourceValue]]"],d["[[Hint]]"],d["[[DisposeMethod]]"]);if(f)throw new Ua("Assertion failed: `~SYNC-DISPOSE~` resource returned something from Dispose")}catch(y){a(y)}}return e["[[DisposableResourceStack]]"]=null,s==="ASYNC-DISPOSE"?o:n},Xf=function(){var e=[];return{"[[DisposableResourceStack]]":e}},Zo=Xl,bc=G,bk=No,Br=ic,wk=hi,Qf=jr,_k=gc,je=fc,Sk=qf,ep=Hn.supportsDescriptors,kk=mc,wc=Kf,Ek=Jf,tp=Xf,Bh=ac(),Xe=function t(){if(!(this instanceof t)||je.has(this,"[[DisposableState]]")||je.has(this,"[[DisposeCapability]]"))throw new bc("can only be used with new");je.set(this,"[[DisposableState]]","PENDING"),je.set(this,"[[DisposeCapability]]",tp())},np=function(){var e=this;return je.assert(e,"[[DisposableState]]"),je.get(e,"[[DisposableState]]")==="DISPOSED"},pi=kk(np);ep?wk(Xe.prototype,"disposed",{"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Get]]":np}):Xe.prototype.disposed=!1;var rp=function(e){je.set(e,"[[DisposableState]]","DISPOSED"),ep||(e.disposed=!0)};Br(Xe.prototype,"dispose",function(){var e=this;if(!pi(e))return rp(e),Ek(je.get(e,"[[DisposeCapability]]"),_k())["?"]()});Br(Xe.prototype,"use",function(e){var n=this;if(pi(n))throw new Zo("a disposed stack can not use anything new");return wc(je.get(n,"[[DisposeCapability]]"),e,"SYNC-DISPOSE"),e});Br(Xe.prototype,"adopt",function(e,n){var r=this;if(pi(r))throw new Zo("a disposed stack can not use anything new");if(!Qf(n))throw new bc("`onDispose` must be a function");var s=function(){return bk(n,void 0,[e])};return wc(je.get(r,"[[DisposeCapability]]"),void 0,"SYNC-DISPOSE",s),e});Br(Xe.prototype,"defer",function(e){var n=this;if(pi(n))throw new Zo("a disposed stack can not defer anything new");if(!Qf(e))throw new bc("`onDispose` must be a function");wc(je.get(n,"[[DisposeCapability]]"),void 0,"SYNC-DISPOSE",e)});Br(Xe.prototype,"move",function(){var e=this;if(pi(e))throw new Zo("a disposed stack can not use anything new");var n=new Xe;return je.set(n,"[[DisposeCapability]]",je.get(e,"[[DisposeCapability]]")),je.set(e,"[[DisposeCapability]]",tp()),rp(e),n});Bh&&Br(Xe.prototype,Bh,Xe.prototype.dispose);Sk(Xe.prototype,"DisposableStack");var $k=Xe,Ak=$k,xk=function(){return typeof DisposableStack=="function"?DisposableStack:Ak},Tk=Hn,Ck=Kl(),Ik=xk,Pk=function(){var e=Ik();return Tk(Ck,{DisposableStack:e},{DisposableStack:!0}),e},Rk=tt,jo=Xl,_c=G,Vh=Rk("%Promise%",!0),Sc=Kf,Dk=No,Vr=ic,Ok=hi,zk=Jf,sp=jr,ip=Xf,Lk=gc,Gh=yc(),We=fc,Mk=qf,op=Hn.supportsDescriptors,Nk=mc,Uk=hn(),Fk=Uk("Promise.prototype.then",!0),Hh=lc(),Qe=function t(){if(!(this instanceof t)||We.has(this,"[[AsyncDisposableState]]")||We.has(this,"[[DisposeCapability]]"))throw new _c("can only be used with new");We.set(this,"[[AsyncDisposableState]]","pending"),We.set(this,"[[DisposeCapability]]",ip())},ap=function(){var e=this;return We.assert(e,"[[AsyncDisposableState]]"),We.get(e,"[[AsyncDisposableState]]")==="disposed"},gi=Nk(ap);op?Ok(Qe.prototype,"disposed",{"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Get]]":ap}):Qe.prototype.disposed=!1;var lp=function(e){We.set(e,"[[AsyncDisposableState]]","disposed"),op||(e.disposed=!0)};Vr(Qe.prototype,"disposeAsync",function(){var e=this;return gi(e)?Gh(Vh):(lp(e),Fk(Gh(Vh,zk(We.get(e,"[[DisposeCapability]]"),Lk())),function(n){return n["?"]()}))});Vr(Qe.prototype,"use",function(e){var n=this;if(gi(n))throw new jo("a disposed stack can not use anything new");return Sc(We.get(n,"[[DisposeCapability]]"),e,"ASYNC-DISPOSE"),e});Vr(Qe.prototype,"adopt",function(e,n){var r=this;if(gi(r))throw new jo("a disposed stack can not use anything new");if(!sp(n))throw new _c("`onDisposeAsync` must be a function");var s=function(){return Dk(n,void 0,[e])};return s.value=e,Sc(We.get(r,"[[DisposeCapability]]"),void 0,"ASYNC-DISPOSE",s),e});Vr(Qe.prototype,"defer",function(e){var n=this;if(gi(n))throw new jo("a disposed stack can not defer anything new");if(!sp(e))throw new _c("`onDispose` must be a function");Sc(We.get(n,"[[DisposeCapability]]"),void 0,"ASYNC-DISPOSE",e)});Vr(Qe.prototype,"move",function(){var e=this;if(gi(e))throw new jo("a disposed stack can not use anything new");var n=new Qe;return We.set(n,"[[DisposeCapability]]",We.get(e,"[[DisposeCapability]]")),We.set(e,"[[DisposeCapability]]",ip()),lp(e),n});Hh&&Vr(Qe.prototype,Hh,Qe.prototype.disposeAsync);Mk(Qe.prototype,"AsyncDisposableStack");var Zk=Qe,jk=Zk,Wk=function(){return typeof AsyncDisposableStack=="function"?AsyncDisposableStack:jk},Bk=Hn,Vk=Kl(),Gk=Wk,Hk=function(){var e=Gk();return Bk(Vk,{AsyncDisposableStack:e},{AsyncDisposableStack:!0}),e},qk=Bw,Yk=Xw,Kk=Pk,Jk=Hk,Xk=function(){qk(),Yk(),Kk(),Jk()};Xk();const qh=new WeakMap;function Qk(t){return(typeof t=="object"||typeof t=="function")&&t!==null&&"then"in t&&typeof t.then=="function"}function or(t){return typeof t=="string"?t:typeof t=="symbol"?t.description??t.toString():t.name||"(anonymous class)"}function Yh(){return new Error("register(Key, factory) requires a factory function. Wrap existing instances as () => instance.")}function eE(){return new Error("register(Key, factory) does not accept async factories. Await setup before registering.")}class tE{constructor(){v(this,"entries",new Map);v(this,"constructionStack",[])}register(e,n){if(n===void 0){if(typeof e!="function")throw Yh();this.validateClassRegistration(e),this.storeFactory(e,()=>this.instantiateClass(e));return}if(typeof n!="function")throw Yh();if(n.constructor.name==="AsyncFunction")throw eE();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=qh.get(e);if(n){if(e.length!==n.length)throw new Error(`${or(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(`${or(e)} cannot be registered with register(Class). Undecorated classes must have zero required constructor parameters. Use register(Key, () => value) instead.`)}instantiateClass(e){const n=qh.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(`${or(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=>or(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 ${or(e.key)} returned a Promise. Await setup before registering.`);if(typeof r!="object"||r===null)throw new Error(`Factory for ${or(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 Ye=new tE,nE=new Set(["target","currentTarget","eventPhase","defaultPrevented","isTrusted","timeStamp","srcElement","returnValue","cancelBubble","NONE","CAPTURING_PHASE","AT_TARGET","BUBBLING_PHASE","composedPath","stopPropagation","stopImmediatePropagation","preventDefault","initEvent"]);function rE(t){for(const e of Object.keys(t))if(nE.has(e))throw new Error(`Event payload key "${e}" is reserved; choose a different property name`)}function sE(t,e){rE(e);for(const n of Object.keys(e))Object.defineProperty(t,n,{value:e[n],writable:!0,enumerable:!0,configurable:!0})}function Be(){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}),sE(this,l)}}return t}class kt extends globalThis.EventTarget{}function iE(t,e,n){const r=t.dispose.bind(t);t.dispose=()=>{if(!e())return n(),r()}}function Gr(t){var n;class e extends t{constructor(...i){super(...i);x(this,n,!1);iE(this,()=>h(this,n),()=>{$(this,n,!0)})}[Symbol.dispose](){this.dispose()}get disposed(){return h(this,n)}}return n=new WeakMap,e}const oE=Be(),to=Be(),cp="0123456789ABCDEFGHJKMNPQRSTVWXYZ",go=32,aE=16,up=10,Kh=0xffffffffffff;var An;(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"})(An||(An={}));class fs extends Error{constructor(e,n){super(`${n} (${e})`),this.name="ULIDError",this.code=e}}function lE(t){const e=Math.floor(t()*go)%go;return cp.charAt(e)}function cE(t){const e=uE(),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(An.PRNGDetectFailure,"Failed to find a reliable PRNG")}function uE(){return fE()?self:typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:null}function hE(t,e){let n="";for(;t>0;t--)n=lE(e)+n;return n}function dE(t,e=up){if(isNaN(t))throw new fs(An.EncodeTimeValueMalformed,`Time must be a number: ${t}`);if(t>Kh)throw new fs(An.EncodeTimeSizeExceeded,`Cannot encode a time larger than ${Kh}: ${t}`);if(t<0)throw new fs(An.EncodeTimeNegative,`Time must be positive: ${t}`);if(Number.isInteger(t)===!1)throw new fs(An.EncodeTimeValueMalformed,`Time must be an integer: ${t}`);let n,r="";for(let s=e;s>0;s--)n=t%go,r=cp.charAt(n)+r,t=(t-n)/go;return r}function fE(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}function kc(t,e){const n=cE(),r=Date.now();return dE(r,up)+hE(aE,n)}const St=4,Ke=6,hp=2,dl=2,pE=St,gE=Ke,Ec="auto",on="auto",kn=120,Jh=75,de=16,nn=kn*St+de*(St-1),mr=kn*Ke+de*(Ke-1),mE=200,vE=4,Li=150,yE=10,Xh=2,bE=4,wE=/^[0-9A-HJKMNP-TV-Z]{26}$/;function dp(t){return gp(t)}function fp(t,e){return gp(t.flatMap(n=>vp(n,e)))}function pp(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}yp(r,"strip",e,n)}return{valid:e.length===0,errors:e}}function Es(t){const e=dp(t),n=pp(e);if(!n.valid)throw new Error(`Invalid layout: ${n.errors.join("; ")}`);return{totalNodes:e.length,nodes:e.filter(r=>r.type!=="row").map(EE)}}function gp(t){const e=[];for(const n of t){const r=mp(n);for(const s of r){if(s.type==="row"){e.push(...s.children.map(Ft));continue}e.push(s)}}return e}function mp(t){switch(t.type){case"card":return[Ft(t)];case"row":{const e=t.children.map(Ft);return e.length===0?[]:e.length===1?[e[0]]:[{...t,children:e}]}case"stack":{const e=[];for(const n of t.children){const r=mp(n);for(const s of r){if(s.type==="stack"){e.push(...s.children.map(fl));continue}if(s.type==="row"){e.push({...s,children:s.children.map(Ft)});continue}e.push(Ft(s))}}return e.length===0?[]:e.length===1?[fl(e[0])]:[{...t,children:e}]}}}function vp(t,e){switch(t.type){case"card":return t.artifactID===e?[]:[Ft(t)];case"row":{const n=t.children.filter(r=>r.artifactID!==e).map(Ft);return n.length===0?[]:n.length===1?[n[0]]:[{...t,children:n}]}case"stack":{const n=t.children.flatMap(r=>vp(r,e).filter(i=>i.type!=="stack"));return n.length===0?[]:n.length===1?[fl(n[0])]:[{...t,children:n}]}}}function yp(t,e,n,r){switch(t.type){case"card":bp(t,e,n,r);return;case"row":_E(t,e,n,r);return;case"stack":SE(t,e,n,r);return}}function bp(t,e,n,r){$c(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),kE(t.width)||n.push(`Card ${t.id} width must be an integer in the range 2-4`),wp(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<hp&&n.push(`Row child ${t.id} must be at least 2 columns wide`)}function _E(t,e,n,r){if($c(t.id,n),e!=="stack"&&n.push(`Row ${t.id} may only appear inside a stack`),wp(t.height,bE)||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}bp(i,"row",n,r),s+=En(i.width)}s!==St&&n.push(`Row ${t.id} children must sum to 4 columns`)}function SE(t,e,n,r){if($c(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(yp(a,"stack",n,r),a.height===on){i+=1;continue}s+=a.height}if(s>Ke&&n.push(`Stack ${t.id} exceeds the 6-row budget`),i===0)return;const o=Ke-s;if(o<i*dl||o%i!==0){n.push(`Stack ${t.id} has auto-height children that cannot resolve to whole height >= 2`);return}o/i<dl&&n.push(`Stack ${t.id} has auto-height children below the minimum row size`)}function $c(t,e){(typeof t!="string"||!wE.test(t))&&e.push(`Node id must be a ULID: ${String(t)}`)}function kE(t){return t===Ec||Number.isInteger(t)&&t>=hp&&t<=pE}function wp(t,e=gE){return t===on||Number.isInteger(t)&&t>=dl&&t<=e}function En(t){return t===Ec?St:t}function EE(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:_p(t.height,Ke)}]};const e=$E(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 $E(t){let e=0,n=0;for(const s of t)s.height===on?n+=1:e+=s.height;const r=n>0?(Ke-e)/n:0;return t.map(s=>_p(s.height,r))}function _p(t,e){return t===on?e:t}function Ft(t){return{...t}}function fl(t){return t.type==="card"?Ft(t):{...t,children:t.children.map(Ft)}}function Sp(t,e={}){return{id:e.id??kc(),type:"card",artifactID:t,width:e.width??Ec,height:e.height??on}}function kp(t,e){return t.some(n=>Ep(n,e))}function Ep(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=>Ep(n,e))}}function Qh(t){return t.layout.flatMap($p)}function $p(t){switch(t.type){case"card":return[t.artifactID];case"row":return t.children.map(e=>e.artifactID);case"stack":return t.children.flatMap($p)}}const te=Be(),Ap=Be(),rs=Be(),AE=Be();function xE(t){class e extends Error{constructor(r,s){super(r),this.name=t,s&&Object.assign(this,s)}}return e}const TE=xE("RequestError"),CE=200,IE=300;class PE{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 RE(s);if(!s.ok||s.status<CE||s.status>=IE)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 Fa(r,r.statusText),r.status)}async requestText(e,n){const r=await this.request(e,n);if(!r.ok)throw this.createError(await Fa(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 Fa(s,s.statusText),s.status)}createError(e,n){const r={serverURL:this.serverURL};return n!==void 0&&(r.status=n),new TE(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 RE(t){try{return await t.json()}catch{const e=await t.text().catch(()=>"");return e?{message:e}:{}}}async function Fa(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 xp(t){return t.map(e=>`${e.name} (${e.id})`).join(", ")}var vt,Ao,Tp;class DE{constructor(e){x(this,Ao);x(this,vt);$(this,vt,e)}list(){return h(this,vt).requestJSON("GET","/screens")}async get(e={}){const n=await b(this,Ao,Tp).call(this,e.screenID);return h(this,vt).requestJSON("GET",`/screens/${encodeURIComponent(n)}`)}create(e){const n={name:e.name};return e.id!==void 0&&(n.id=e.id),h(this,vt).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),h(this,vt).requestJSON("PATCH",`/screens/${encodeURIComponent(e.screenID)}`,n)}remove(e){return h(this,vt).requestJSON("DELETE",`/screens/${encodeURIComponent(e.screenID)}`)}}vt=new WeakMap,Ao=new WeakSet,Tp=async function(e){if(e!==void 0)return e;const{screens:n}=await this.list();if(n.length===1)return n[0].id;throw h(this,vt).createError(`screenID is required when multiple screens exist. Available screens: ${xp(n)}`)};var Ue,Os,xo,Cp;class OE{constructor(e,n){x(this,xo);x(this,Ue);x(this,Os);$(this,Ue,e),$(this,Os,n)}async create(e){const n=await b(this,xo,Cp).call(this,e.screenID);return h(this,Ue).requestJSON("POST",`/screens/${encodeURIComponent(n)}/artifact`,{type:e.type,title:e.title,externalFilePath:e.externalFilePath})}get(e){return h(this,Ue).requestJSON("GET",`/artifacts/${encodeURIComponent(e.artifactID)}`)}update(e){const n={};return e.title!==void 0&&(n.title=e.title),h(this,Ue).requestJSON("PATCH",`/artifacts/${encodeURIComponent(e.artifactID)}`,n)}edit(e){return h(this,Ue).requestJSON("POST",`/artifacts/${encodeURIComponent(e.artifactID)}/edit`)}commitPending(e){return h(this,Ue).requestJSON("POST",`/artifacts/${encodeURIComponent(e.artifactID)}/commit`)}abandonPending(e){return h(this,Ue).requestVoid("POST",`/artifacts/${encodeURIComponent(e.artifactID)}/abandon`)}remove(e){return h(this,Ue).requestJSON("DELETE",`/screens/${encodeURIComponent(e.screenID)}/artifacts/${encodeURIComponent(e.artifactID)}`)}getContent(e){return h(this,Ue).requestText("GET",`/artifacts/${encodeURIComponent(e.artifactID)}/content`)}putContent(e){return h(this,Ue).requestRawVoid("PUT",`/artifacts/${encodeURIComponent(e.artifactID)}/content`,e.content)}}Ue=new WeakMap,Os=new WeakMap,xo=new WeakSet,Cp=async function(e){if(e!==void 0)return e;const{screens:n}=await h(this,Os).list();if(n.length===1)return n[0].id;throw h(this,Ue).createError(`screenID is required when multiple screens exist. Available screens: ${xp(n)}`)};var zs;class zE{constructor(e){x(this,zs);$(this,zs,e)}async list(){const{views:e}=await h(this,zs).requestJSON("GET","/views");return e}}zs=new WeakMap;var Ht;class LE{constructor(e,n={}){v(this,"screens");v(this,"artifacts");v(this,"views");x(this,Ht);$(this,Ht,new PE(e,n)),this.screens=new DE(h(this,Ht)),this.artifacts=new OE(h(this,Ht),this.screens),this.views=new zE(h(this,Ht))}health(){return h(this,Ht).requestJSON("GET","/health")}}Ht=new WeakMap;const ME=Gr(kt);var Tn,Fe,Cn,Oe,qt,Yt,Q,lr,Ip,Ls,Pp,Rp,Dp,Op,pl,gl,ml,zp;class NE extends ME{constructor(n){var s;super();x(this,Q);v(this,"id");v(this,"server");x(this,Tn);x(this,Fe,new Map);x(this,Cn);x(this,Oe);x(this,qt);x(this,Yt,null);x(this,Ls,n=>{if(this.disposed)return;const r=n.event;switch(r.type){case"screen-updated":r.screen.id===this.id&&b(this,Q,Pp).call(this,r.screen);break;case"artifact-created":r.screenID===this.id&&b(this,Q,Rp).call(this,r.artifact);break;case"artifact-updated":b(this,Q,Dp).call(this,r.artifact);break;case"artifact-removed":r.screenID===this.id&&b(this,Q,Op).call(this,r.artifactID);break;case"artifact-content-changed":h(this,Fe).has(r.artifactID)&&this.dispatchEvent(new AE("artifact-content-changed",{artifactID:r.artifactID}));break}});this.id=n.screen.id,this.server=n.server,$(this,Tn,n.localStore),$(this,Cn,n.screen.name),$(this,Oe,structuredClone(n.screen.layout));const r=((s=h(this,Tn).get().screens[this.id])==null?void 0:s.scrollPosition)??0;$(this,qt,Math.max(0,r)),this.server.addEventListener("server-event",h(this,Ls)),b(this,Q,Ip).call(this)}get name(){return h(this,Cn)}get layout(){return h(this,Oe)}get scrollPosition(){return h(this,qt)}get artifacts(){return h(this,Fe)}setScrollPosition(n){b(this,Q,lr).call(this);const r=Math.max(0,n);r!==h(this,qt)&&($(this,qt,r),b(this,Q,zp).call(this),this.dispatchEvent(new te("change")))}setLayout(n){b(this,Q,lr).call(this);const r=dp(n);if(!pp(r).valid)return;const i=b(this,Q,gl).call(this);$(this,Oe,r),$(this,Yt,{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=h(this,Yt))==null?void 0:o.layout)===r&&($(this,Yt,null),b(this,Q,ml).call(this,i),this.dispatchEvent(new te("change")))})}rename(n){b(this,Q,lr).call(this),$(this,Cn,n),this.dispatchEvent(new te("change")),this.server.client.screens.update({screenID:this.id,name:n}).catch(()=>{})}async remove(){b(this,Q,lr).call(this),await this.server.client.screens.remove({screenID:this.id})}removeArtifact(n){if(b(this,Q,lr).call(this),!h(this,Fe).has(n))return;const r=b(this,Q,gl).call(this);b(this,Q,pl).call(this,n),this.dispatchEvent(new te("change")),this.server.client.artifacts.remove({artifactID:n,screenID:this.id}).catch(()=>{this.disposed||(b(this,Q,ml).call(this,r),this.dispatchEvent(new te("change")))})}dispose(){this.server.removeEventListener("server-event",h(this,Ls))}}Tn=new WeakMap,Fe=new WeakMap,Cn=new WeakMap,Oe=new WeakMap,qt=new WeakMap,Yt=new WeakMap,Q=new WeakSet,lr=function(){if(this.disposed)throw new Error("ScreenModel is disposed")},Ip=async function(){try{const n=await this.server.client.screens.get({screenID:this.id});if(this.disposed)return;for(const r of n.artifacts)h(this,Fe).set(r.id,r);this.dispatchEvent(new te("change"))}catch{}},Ls=new WeakMap,Pp=function(n){h(this,Yt)&&$(this,Yt,null),$(this,Cn,n.name),$(this,Oe,structuredClone(n.layout)),this.dispatchEvent(new te("change"))},Rp=function(n){kp(h(this,Oe),n.id)||$(this,Oe,[...h(this,Oe),Sp(n.id)]),h(this,Fe).set(n.id,n),this.dispatchEvent(new te("change"))},Dp=function(n){const r=h(this,Fe).get(n.id);r&&(h(this,Fe).set(n.id,{...r,...n}),this.dispatchEvent(new te("change")))},Op=function(n){b(this,Q,pl).call(this,n)&&this.dispatchEvent(new te("change"))},pl=function(n){const r=h(this,Fe).delete(n),s=Qh({layout:h(this,Oe)}).length,i=fp(h(this,Oe),n),o=Qh({layout:i}).length;return $(this,Oe,i),r||s!==o},gl=function(){return{layout:structuredClone(h(this,Oe)),artifacts:new Map([...h(this,Fe).entries()].map(([n,r])=>[n,structuredClone(r)]))}},ml=function(n){$(this,Oe,structuredClone(n.layout)),h(this,Fe).clear();for(const[r,s]of n.artifacts)h(this,Fe).set(r,structuredClone(s))},zp=function(){const n=h(this,Tn).get();h(this,Tn).set({...n,screens:{...n.screens,[this.id]:{scrollPosition:h(this,qt)}}})};const UE=Gr(kt);var Ze,yt,rt,Ms,Ns,Us,rn,no,Lp;class FE extends UE{constructor(n){super();x(this,rn);x(this,Ze);x(this,yt);x(this,rt,null);x(this,Ms,()=>{this.disposed||b(this,rn,no).call(this)});x(this,Ns,()=>{this.disposed||b(this,rn,no).call(this)});x(this,Us,n=>{var s;if(this.disposed)return;const r=n.event;r.type==="screen-removed"&&((s=h(this,rt))==null?void 0:s.id)===r.screenID&&this.clearActive()});$(this,Ze,n.localStore),$(this,yt,n.serverManager),h(this,Ze).addEventListener("change",h(this,Ms)),h(this,yt).addEventListener("change",h(this,Ns)),h(this,yt).addEventListener("server-event",h(this,Us)),b(this,rn,no).call(this)}get activeScreen(){return h(this,rt)}setActive(n,r){const s=h(this,Ze).get();s.activeServerURL===n&&s.activeScreenID===r||h(this,Ze).set({...s,activeServerURL:n,activeScreenID:r})}clearActive(){const n=h(this,Ze).get();n.activeServerURL===null&&n.activeScreenID===null||h(this,Ze).set({...n,activeServerURL:null,activeScreenID:null})}dispose(){var n;h(this,Ze).removeEventListener("change",h(this,Ms)),h(this,yt).removeEventListener("change",h(this,Ns)),h(this,yt).removeEventListener("server-event",h(this,Us)),(n=h(this,rt))==null||n.dispose(),$(this,rt,null)}}Ze=new WeakMap,yt=new WeakMap,rt=new WeakMap,Ms=new WeakMap,Ns=new WeakMap,Us=new WeakMap,rn=new WeakSet,no=function(){var l,c,d;const{activeServerURL:n,activeScreenID:r}=h(this,Ze).get();let s=n?h(this,yt).servers.get(n)??null:null,i=s&&r?s.screens.get(r)??null:null;if(!i){const f=b(this,rn,Lp).call(this);if(f){s=f.server,i=f.screen,h(this,Ze).set({...h(this,Ze).get(),activeServerURL:f.server.url,activeScreenID:f.screen.id});return}}const o=((l=h(this,rt))==null?void 0:l.id)??null,a=(i==null?void 0:i.id)??null;o===a&&((c=h(this,rt))==null?void 0:c.server)===s||((d=h(this,rt))==null||d.dispose(),$(this,rt,s&&i?new NE({screen:i,server:s,localStore:h(this,Ze)}):null),this.dispatchEvent(new oE("active-screen-changed")))},Lp=function(){for(const n of h(this,yt).servers.values()){const r=n.screens.values().next().value;if(r)return{server:n,screen:r}}return null};const ZE="Local",jE="store-";function Pt(t){return new URL(t).origin}function WE(t){return{servers:[{url:Pt(t),name:ZE}],activeServerURL:null,activeScreenID:null,screens:{}}}var In,Pn,Rn;class BE extends kt{constructor(n,r,s={}){super();x(this,In);x(this,Pn);x(this,Rn);$(this,In,`${jE}${n}`),$(this,Pn,s.storage??VE());const i=h(this,Pn).getItem(h(this,In));i===null?($(this,Rn,r),h(this,Pn).setItem(h(this,In),JSON.stringify(r))):$(this,Rn,JSON.parse(i))}get(){return h(this,Rn)}set(n){$(this,Rn,n),h(this,Pn).setItem(h(this,In),JSON.stringify(n)),this.dispatchEvent(new te("change"))}}In=new WeakMap,Pn=new WeakMap,Rn=new WeakMap;function VE(){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 f=0;f<d.length;f++){const y=d[f];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 wr extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Mp extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}}const Np={};function an(t){return Np}function Up(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 vl(t,e){return typeof e=="bigint"?e.toString():e}function Ac(t){return{get value(){{const e=t();return Object.defineProperty(this,"value",{value:e}),e}}}}function xc(t){return t==null}function Tc(t){const e=t.startsWith("^")?1:0,n=t.endsWith("$")?t.length-1:t.length;return t.slice(e,n)}function GE(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 ed=Symbol("evaluating");function ee(t,e,n){let r;Object.defineProperty(t,e,{get(){if(r!==ed)return r===void 0&&(r=ed,r=n()),r},set(s){Object.defineProperty(t,e,{value:s})},configurable:!0})}function Yn(t,e,n){Object.defineProperty(t,e,{value:n,writable:!0,enumerable:!0,configurable:!0})}function fn(...t){const e={};for(const n of t){const r=Object.getOwnPropertyDescriptors(n);Object.assign(e,r)}return Object.defineProperties({},e)}function td(t){return JSON.stringify(t)}function HE(t){return t.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Fp="captureStackTrace"in Error?Error.captureStackTrace:(...t)=>{};function mo(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}const qE=Ac(()=>{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 Or(t){if(mo(t)===!1)return!1;const e=t.constructor;if(e===void 0||typeof e!="function")return!0;const n=e.prototype;return!(mo(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function Zp(t){return Or(t)?{...t}:Array.isArray(t)?[...t]:t}const YE=new Set(["string","number","symbol"]);function zr(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function pn(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 D(t){const e=t;if(!e)return{};if(typeof e=="string")return{error:()=>e};if((e==null?void 0:e.message)!==void 0){if((e==null?void 0:e.error)!==void 0)throw new Error("Cannot specify both `message` and `error` params");e.error=e.message}return delete e.message,typeof e.error=="string"?{...e,error:()=>e.error}:e}function KE(t){return Object.keys(t).filter(e=>t[e]._zod.optin==="optional"&&t[e]._zod.optout==="optional")}const JE={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 XE(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=fn(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 Yn(this,"shape",o),o},checks:[]});return pn(t,i)}function QE(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=fn(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 Yn(this,"shape",o),o},checks:[]});return pn(t,i)}function e$(t,e){if(!Or(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=fn(t._zod.def,{get shape(){const i={...t._zod.def.shape,...e};return Yn(this,"shape",i),i}});return pn(t,s)}function t$(t,e){if(!Or(e))throw new Error("Invalid input to safeExtend: expected a plain object");const n=fn(t._zod.def,{get shape(){const r={...t._zod.def.shape,...e};return Yn(this,"shape",r),r}});return pn(t,n)}function n$(t,e){const n=fn(t._zod.def,{get shape(){const r={...t._zod.def.shape,...e._zod.def.shape};return Yn(this,"shape",r),r},get catchall(){return e._zod.def.catchall},checks:[]});return pn(t,n)}function r$(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=fn(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 Yn(this,"shape",l),l},checks:[]});return pn(e,o)}function s$(t,e,n){const r=fn(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 Yn(this,"shape",i),i}});return pn(e,r)}function vr(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 yr(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 ln(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 Cc(t){return Array.isArray(t)?"array":typeof t=="string"?"string":"unknown"}function xs(...t){const[e,n,r]=t;return typeof e=="string"?{message:e,code:"custom",input:n,inst:r}:{...e}}const jp=(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,vl,2),Object.defineProperty(t,"toString",{value:()=>t.message,enumerable:!1})},Wp=S("$ZodError",jp),Bp=S("$ZodError",jp,{Parent:Error});function i$(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 o$(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 Ic=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 wr;if(o.issues.length){const a=new((s==null?void 0:s.Err)??t)(o.issues.map(l=>ln(l,i,an())));throw Fp(a,s==null?void 0:s.callee),a}return o.value},Pc=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=>ln(l,i,an())));throw Fp(a,s==null?void 0:s.callee),a}return o.value},Wo=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 wr;return i.issues.length?{success:!1,error:new(t??Wp)(i.issues.map(o=>ln(o,s,an())))}:{success:!0,data:i.value}},a$=Wo(Bp),Bo=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=>ln(o,s,an())))}:{success:!0,data:i.value}},l$=Bo(Bp),c$=t=>(e,n,r)=>{const s=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Ic(t)(e,n,s)},u$=t=>(e,n,r)=>Ic(t)(e,n,r),h$=t=>async(e,n,r)=>{const s=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Pc(t)(e,n,s)},d$=t=>async(e,n,r)=>Pc(t)(e,n,r),f$=t=>(e,n,r)=>{const s=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Wo(t)(e,n,s)},p$=t=>(e,n,r)=>Wo(t)(e,n,r),g$=t=>async(e,n,r)=>{const s=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Bo(t)(e,n,s)},m$=t=>async(e,n,r)=>Bo(t)(e,n,r),v$=/^[cC][^\s-]{8,}$/,y$=/^[0-9a-z]+$/,b$=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,w$=/^[0-9a-vA-V]{20}$/,_$=/^[A-Za-z0-9]{27}$/,S$=/^[a-zA-Z0-9_-]{21}$/,k$=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,E$=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,nd=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)$/,$$=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,A$="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function x$(){return new RegExp(A$,"u")}const T$=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,C$=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,I$=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,P$=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,R$=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Vp=/^[A-Za-z0-9_-]*$/,D$=/^\+[1-9]\d{6,14}$/,Gp="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",O$=new RegExp(`^${Gp}$`);function Hp(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 z$(t){return new RegExp(`^${Hp(t)}$`)}function L$(t){const e=Hp({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(`^${Gp}T(?:${r})$`)}const M$=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}$`)},N$=/^-?\d+$/,qp=/^-?\d+(?:\.\d+)?$/,U$=/^(?:true|false)$/i,F$=/^[^A-Z]*$/,Z$=/^[^a-z]*$/,Ve=S("$ZodCheck",(t,e)=>{var n;t._zod??(t._zod={}),t._zod.def=e,(n=t._zod).onattach??(n.onattach=[])}),Yp={number:"number",bigint:"bigint",object:"date"},Kp=S("$ZodCheckLessThan",(t,e)=>{Ve.init(t,e);const n=Yp[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})}}),Jp=S("$ZodCheckGreaterThan",(t,e)=>{Ve.init(t,e);const n=Yp[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})}}),j$=S("$ZodCheckMultipleOf",(t,e)=>{Ve.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):GE(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})}}),W$=S("$ZodCheckNumberFormat",(t,e)=>{var o;Ve.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]=JE[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=N$)}),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})}}),B$=S("$ZodCheckMaxLength",(t,e)=>{var n;Ve.init(t,e),(n=t._zod.def).when??(n.when=r=>{const s=r.value;return!xc(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=Cc(s);r.issues.push({origin:o,code:"too_big",maximum:e.maximum,inclusive:!0,input:s,inst:t,continue:!e.abort})}}),V$=S("$ZodCheckMinLength",(t,e)=>{var n;Ve.init(t,e),(n=t._zod.def).when??(n.when=r=>{const s=r.value;return!xc(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=Cc(s);r.issues.push({origin:o,code:"too_small",minimum:e.minimum,inclusive:!0,input:s,inst:t,continue:!e.abort})}}),G$=S("$ZodCheckLengthEquals",(t,e)=>{var n;Ve.init(t,e),(n=t._zod.def).when??(n.when=r=>{const s=r.value;return!xc(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=Cc(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})}}),Vo=S("$ZodCheckStringFormat",(t,e)=>{var n,r;Ve.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=()=>{})}),H$=S("$ZodCheckRegex",(t,e)=>{Vo.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})}}),q$=S("$ZodCheckLowerCase",(t,e)=>{e.pattern??(e.pattern=F$),Vo.init(t,e)}),Y$=S("$ZodCheckUpperCase",(t,e)=>{e.pattern??(e.pattern=Z$),Vo.init(t,e)}),K$=S("$ZodCheckIncludes",(t,e)=>{Ve.init(t,e);const n=zr(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})}}),J$=S("$ZodCheckStartsWith",(t,e)=>{Ve.init(t,e);const n=new RegExp(`^${zr(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})}}),X$=S("$ZodCheckEndsWith",(t,e)=>{Ve.init(t,e);const n=new RegExp(`.*${zr(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})}}),Q$=S("$ZodCheckOverwrite",(t,e)=>{Ve.init(t,e),t._zod.check=n=>{n.value=e.tx(n.value)}});class e0{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(`
4
+ `+e.prev}function Ri(t,e){var n=dl(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 Da=="function"?Da(t):[],o;if(Dr){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||Dr&&o["$"+l]instanceof Symbol||(Uf.call(/[^\w$]/,l)?r.push(e(l,t)+": "+e(t[l],t)):r.push(l+": "+e(t[l],t))));if(typeof Da=="function")for(var c=0;c<i.length;c++)Ff.call(t,i[c])&&r.push("["+e(i[c])+"]: "+e(t[i[c]],t));return r}var O_=Wr,z_=G,Uo=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},L_=function(t,e){if(t){var n=Uo(t,e);return n&&n.value}},M_=function(t,e,n){var r=Uo(t,e);r?r.value=n:t.next={key:e,next:t.next,value:n}},N_=function(t,e){return t?!!Uo(t,e):!1},U_=function(t,e){if(t)return Uo(t,e,!0)},F_=function(){var e,n={assert:function(r){if(!n.has(r))throw new z_("Side channel does not contain "+O_(r))},delete:function(r){var s=e&&e.next,i=U_(e,r);return i&&s&&s===i&&(e=void 0),!!i},get:function(r){return L_(e,r)},has:function(r){return N_(e,r)},set:function(r,s){e||(e={next:void 0}),M_(e,r,s)}};return n},Z_=tt,fi=hn(),j_=Wr,W_=G,Sh=Z_("%Map%",!0),B_=fi("Map.prototype.get",!0),V_=fi("Map.prototype.set",!0),G_=fi("Map.prototype.has",!0),H_=fi("Map.prototype.delete",!0),q_=fi("Map.prototype.size",!0),Gf=!!Sh&&function(){var e,n={assert:function(r){if(!n.has(r))throw new W_("Side channel does not contain "+j_(r))},delete:function(r){if(e){var s=H_(e,r);return q_(e)===0&&(e=void 0),s}return!1},get:function(r){if(e)return B_(e,r)},has:function(r){return e?G_(e,r):!1},set:function(r,s){e||(e=new Sh),V_(e,r,s)}};return n},Y_=tt,Fo=hn(),K_=Wr,Di=Gf,J_=G,ir=Y_("%WeakMap%",!0),X_=Fo("WeakMap.prototype.get",!0),Q_=Fo("WeakMap.prototype.set",!0),eS=Fo("WeakMap.prototype.has",!0),tS=Fo("WeakMap.prototype.delete",!0),nS=ir?function(){var e,n,r={assert:function(s){if(!r.has(s))throw new J_("Side channel does not contain "+K_(s))},delete:function(s){if(ir&&s&&(typeof s=="object"||typeof s=="function")){if(e)return tS(e,s)}else if(Di&&n)return n.delete(s);return!1},get:function(s){return ir&&s&&(typeof s=="object"||typeof s=="function")&&e?X_(e,s):n&&n.get(s)},has:function(s){return ir&&s&&(typeof s=="object"||typeof s=="function")&&e?eS(e,s):!!n&&n.has(s)},set:function(s,i){ir&&s&&(typeof s=="object"||typeof s=="function")?(e||(e=new ir),Q_(e,s,i)):Di&&(n||(n=Di()),n.set(s,i))}};return r}:Di,rS=G,sS=Wr,iS=F_,oS=Gf,aS=nS,lS=aS||oS||iS,cS=function(){var e,n={assert:function(r){if(!n.has(r))throw new rS("Side channel does not contain "+sS(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=lS()),e.set(r,s)}};return n},uS=Wt,rs=cS(),xt=G,gc={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),!gc.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&&uS(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(gc);var mc=gc,Hf=Zt,sn=mc,pi=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 Hf('Assertion failed: `type` must be one of "normal", "break", "continue", "return", or "throw"');sn.set(this,"[[Type]]",e),sn.set(this,"[[Value]]",n)};pi.prototype.type=function(){return sn.get(this,"[[Type]]")};pi.prototype.value=function(){return sn.get(this,"[[Value]]")};pi.prototype["?"]=function(){var e=sn.get(this,"[[Type]]"),n=sn.get(this,"[[Value]]");if(e==="throw")throw n;return n};pi.prototype["!"]=function(){var e=sn.get(this,"[[Type]]");if(e!=="normal")throw new Hf('Assertion failed: Completion Record is not of type "normal"');return sn.get(this,"[[Value]]")};var vc=pi,hS=vc,yc=function(e){return new hS("normal",e)},za,kh;function dS(){if(kh)return za;kh=1;var t=Ur;return za=function(){return t()&&!!Symbol.toStringTag},za}var fS=tt,Eh=fS("%Object.defineProperty%",!0),pS=dS()(),gS=Wt,mS=G,Oi=pS?Symbol.toStringTag:null,qf=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 mS("if provided, the `overrideIfSet` and `nonConfigurable` options must be booleans");Oi&&(r||!gS(e,Oi))&&(Eh?Eh(e,Oi,{configurable:!s,enumerable:!1,value:n,writable:!1}):e[Oi]=n)},Yf={exports:{}},vS=tt,$h=pf,yS=Lo(),Ah=Nr,xh=G,bS=vS("%Math.floor%"),wS=function(e,n){if(typeof e!="function")throw new xh("`fn` is not a function");if(typeof n!="number"||n<0||n>4294967295||bS(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)&&(yS?$h(e,"length",n,!0,!0):$h(e,"length",n)),e},_S=li,SS=ic(),kS=$f,ES=function(){return kS(_S,SS,arguments)};(function(t){var e=wS,n=ai,r=Mo,s=ES;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})(Yf);var bc=Yf.exports,$S=function(e,n){for(var r=0;r<e.length;r+=1)if(!n(e[r],r,e))return!1;return!0},AS=Object,xS=function(e){return e&&typeof e=="object"&&(typeof e["[[ResourceValue]]"]>"u"||AS(e["[[ResourceValue]]"])===e["[[ResourceValue]]"])&&(e["[[Hint]]"]==="SYNC-DISPOSE"||e["[[Hint]]"]==="ASYNC-DISPOSE")&&(typeof e["[[DisposeMethod]]"]=="function"||typeof e["[[DisposeMethod]]"]>"u")},CS=Wt,TS=oc(),IS=$S,PS=xS,RS=function(e){return e&&typeof e=="object"&&CS(e,"[[DisposableResourceStack]]")&&TS(e["[[DisposableResourceStack]]"])&&(e["[[DisposableResourceStack]]"].length===0||IS(e["[[DisposableResourceStack]]"],PS))},DS=jt,OS=function(e){if(e===null)return"Null";if(typeof e>"u")return"Undefined";if(DS(e))return"Object";if(typeof e=="number")return"Number";if(typeof e=="boolean")return"Boolean";if(typeof e=="string")return"String"},zS=OS,wc=function(e){return typeof e=="symbol"?"Symbol":typeof e=="bigint"?"BigInt":zS(e)},LS=G,MS=Wr,NS=Zr,US=function(e,n){if(!NS(n))throw new LS("Assertion failed: P is not a Property Key, got "+MS(n));return e[n]},Ch=G,FS=US,ZS=jr,jS=Zr,Th=Wr,WS=function(e,n){if(!jS(n))throw new Ch("Assertion failed: P is not a Property Key");var r=FS(e,n);if(r!=null){if(!ZS(r))throw new Ch(Th(n)+" is not a function: "+Th(r));return r}},pl={exports:{}},BS=tt,VS=BS,Ih=VS("%Reflect.construct%",!0),po=di;try{po({},"",{"[[Get]]":function(){}})}catch{po=null}if(po&&Ih){var Ph={},Rh={};po(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 GS=pl.exports,La=G,Dh=jr,HS=GS,qS=function(e){if(!HS(e))throw new La("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 La("executor has already been called");n["[[Resolve]]"]=s,n["[[Reject]]"]=i});if(!Dh(n["[[Resolve]]"])||!Dh(n["[[Reject]]"]))throw new La("executor must provide valid resolve and reject functions");return{"[[Promise]]":r,"[[Resolve]]":n["[[Resolve]]"],"[[Reject]]":n["[[Reject]]"]}},Oh=Zt,YS=G,Ma=No,zh=WS,KS=qS,JS=wc,Lh=uc(),Mh=hc(),XS=function(e,n){if(JS(e)!=="Object")throw new YS("`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=KS(Promise);try{Ma(r,s),Ma(i["[[Resolve]]"],void 0,[void 0])}catch(o){i["[[Reject]]"](o)}return i["[[Promise]]"]}Ma(r,s)}}return r},QS=Zt,Na=G,ek=jr,tk=wc,nk=XS,rk=function(e,n){if(n!=="SYNC-DISPOSE"&&n!=="ASYNC-DISPOSE")throw new QS("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"&&tk(e)!=="Object")throw new Na("`V` must be an Object, or `null` or `undefined`");if(r=nk(e,n),typeof r>"u")throw new Na("dispose method must not be `undefined` on `V` when an object `V` is provided")}else if(r=arguments[2],!ek(r))throw new Na("`method`, when provided, must be a function");return{"[[ResourceValue]]":e,"[[Hint]]":n,"[[DisposeMethod]]":r}},sk=Zt,zi=G,ik=RS,Nh=rk,ok=hn(),ak=ok("Array.prototype.push"),Kf=function(e,n,r){if(!ik(e))throw new zi("Assertion failed: `disposeCapability` must be a DisposeCapability Record");if(r!=="SYNC-DISPOSE"&&r!=="ASYNC-DISPOSE")throw new sk("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 ak(e["[[DisposableResourceStack]]"],i),"UNUSED"},Ua,Uh;function _c(){if(Uh)return Ua;Uh=1;var t=tt,e=bc,n=Zt,r=t("%Promise.resolve%",!0),s=r&&e(r);return Ua=function(o,a){if(!s)throw new n("This environment does not support Promises.");return s(o,a)},Ua}var Fa,Fh;function lk(){if(Fh)return Fa;Fh=1;var t=tt,e=Zt,n=t("%Promise%",!0),r=No,s=_c(),i=wc;return Fa=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)},Fa}var Za,Zh;function ck(){if(Zh)return Za;Zh=1;var t=vc;return Za=function(n){return new t("throw",n)},Za}var uk=tt,ja=Zt,jh=G,hk=uk("%Promise%",!0),dk=hn(),Wh=dk("Promise.prototype.then",!0),fk=vc,Bh=lk(),pk=yc,gk=_c(),Vh=ck(),mk=Nf(),Jf=function(e,n){if(!(n instanceof fk))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 ja("mixed hint stacks are not supported");for(var o=s==="ASYNC-DISPOSE"&&gk(hk,n),a=function(y){if(n.type()==="throw"){var m=n.value(),E=new mk(y,m);n=Vh(E)}else n=Vh(y)},l=s==="ASYNC-DISPOSE"&&function(m){return Wh(o,function(){var E=Bh(m["[[ResourceValue]]"],m["[[Hint]]"],m["[[DisposeMethod]]"]);if(!E)throw new ja("Assertion failed: non-`~ASYNC-DISPOSE~` resource returned a promise from Dispose");return Wh(E,pk)},a)},c=r.length-1;c>=0;c-=1)if(s==="ASYNC-DISPOSE")o=l(r[c]);else{var d=r[c];try{var f=Bh(d["[[ResourceValue]]"],d["[[Hint]]"],d["[[DisposeMethod]]"]);if(f)throw new ja("Assertion failed: `~SYNC-DISPOSE~` resource returned something from Dispose")}catch(y){a(y)}}return e["[[DisposableResourceStack]]"]=null,s==="ASYNC-DISPOSE"?o:n},Xf=function(){var e=[];return{"[[DisposableResourceStack]]":e}},Zo=tc,Sc=G,vk=No,Br=lc,yk=di,Qf=jr,bk=yc,je=mc,wk=qf,ep=Hn.supportsDescriptors,_k=bc,kc=Kf,Sk=Jf,tp=Xf,Gh=uc(),Xe=function t(){if(!(this instanceof t)||je.has(this,"[[DisposableState]]")||je.has(this,"[[DisposeCapability]]"))throw new Sc("can only be used with new");je.set(this,"[[DisposableState]]","PENDING"),je.set(this,"[[DisposeCapability]]",tp())},np=function(){var e=this;return je.assert(e,"[[DisposableState]]"),je.get(e,"[[DisposableState]]")==="DISPOSED"},gi=_k(np);ep?yk(Xe.prototype,"disposed",{"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Get]]":np}):Xe.prototype.disposed=!1;var rp=function(e){je.set(e,"[[DisposableState]]","DISPOSED"),ep||(e.disposed=!0)};Br(Xe.prototype,"dispose",function(){var e=this;if(!gi(e))return rp(e),Sk(je.get(e,"[[DisposeCapability]]"),bk())["?"]()});Br(Xe.prototype,"use",function(e){var n=this;if(gi(n))throw new Zo("a disposed stack can not use anything new");return kc(je.get(n,"[[DisposeCapability]]"),e,"SYNC-DISPOSE"),e});Br(Xe.prototype,"adopt",function(e,n){var r=this;if(gi(r))throw new Zo("a disposed stack can not use anything new");if(!Qf(n))throw new Sc("`onDispose` must be a function");var s=function(){return vk(n,void 0,[e])};return kc(je.get(r,"[[DisposeCapability]]"),void 0,"SYNC-DISPOSE",s),e});Br(Xe.prototype,"defer",function(e){var n=this;if(gi(n))throw new Zo("a disposed stack can not defer anything new");if(!Qf(e))throw new Sc("`onDispose` must be a function");kc(je.get(n,"[[DisposeCapability]]"),void 0,"SYNC-DISPOSE",e)});Br(Xe.prototype,"move",function(){var e=this;if(gi(e))throw new Zo("a disposed stack can not use anything new");var n=new Xe;return je.set(n,"[[DisposeCapability]]",je.get(e,"[[DisposeCapability]]")),je.set(e,"[[DisposeCapability]]",tp()),rp(e),n});Gh&&Br(Xe.prototype,Gh,Xe.prototype.dispose);wk(Xe.prototype,"DisposableStack");var kk=Xe,Ek=kk,$k=function(){return typeof DisposableStack=="function"?DisposableStack:Ek},Ak=Hn,xk=Ql(),Ck=$k,Tk=function(){var e=Ck();return Ak(xk,{DisposableStack:e},{DisposableStack:!0}),e},Ik=tt,jo=tc,Ec=G,Hh=Ik("%Promise%",!0),$c=Kf,Pk=No,Vr=lc,Rk=di,Dk=Jf,sp=jr,ip=Xf,Ok=yc,qh=_c(),We=mc,zk=qf,op=Hn.supportsDescriptors,Lk=bc,Mk=hn(),Nk=Mk("Promise.prototype.then",!0),Yh=hc(),Qe=function t(){if(!(this instanceof t)||We.has(this,"[[AsyncDisposableState]]")||We.has(this,"[[DisposeCapability]]"))throw new Ec("can only be used with new");We.set(this,"[[AsyncDisposableState]]","pending"),We.set(this,"[[DisposeCapability]]",ip())},ap=function(){var e=this;return We.assert(e,"[[AsyncDisposableState]]"),We.get(e,"[[AsyncDisposableState]]")==="disposed"},mi=Lk(ap);op?Rk(Qe.prototype,"disposed",{"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Get]]":ap}):Qe.prototype.disposed=!1;var lp=function(e){We.set(e,"[[AsyncDisposableState]]","disposed"),op||(e.disposed=!0)};Vr(Qe.prototype,"disposeAsync",function(){var e=this;return mi(e)?qh(Hh):(lp(e),Nk(qh(Hh,Dk(We.get(e,"[[DisposeCapability]]"),Ok())),function(n){return n["?"]()}))});Vr(Qe.prototype,"use",function(e){var n=this;if(mi(n))throw new jo("a disposed stack can not use anything new");return $c(We.get(n,"[[DisposeCapability]]"),e,"ASYNC-DISPOSE"),e});Vr(Qe.prototype,"adopt",function(e,n){var r=this;if(mi(r))throw new jo("a disposed stack can not use anything new");if(!sp(n))throw new Ec("`onDisposeAsync` must be a function");var s=function(){return Pk(n,void 0,[e])};return s.value=e,$c(We.get(r,"[[DisposeCapability]]"),void 0,"ASYNC-DISPOSE",s),e});Vr(Qe.prototype,"defer",function(e){var n=this;if(mi(n))throw new jo("a disposed stack can not defer anything new");if(!sp(e))throw new Ec("`onDispose` must be a function");$c(We.get(n,"[[DisposeCapability]]"),void 0,"ASYNC-DISPOSE",e)});Vr(Qe.prototype,"move",function(){var e=this;if(mi(e))throw new jo("a disposed stack can not use anything new");var n=new Qe;return We.set(n,"[[DisposeCapability]]",We.get(e,"[[DisposeCapability]]")),We.set(e,"[[DisposeCapability]]",ip()),lp(e),n});Yh&&Vr(Qe.prototype,Yh,Qe.prototype.disposeAsync);zk(Qe.prototype,"AsyncDisposableStack");var Uk=Qe,Fk=Uk,Zk=function(){return typeof AsyncDisposableStack=="function"?AsyncDisposableStack:Fk},jk=Hn,Wk=Ql(),Bk=Zk,Vk=function(){var e=Bk();return jk(Wk,{AsyncDisposableStack:e},{AsyncDisposableStack:!0}),e},Gk=jw,Hk=Kw,qk=Tk,Yk=Vk,Kk=function(){Gk(),Hk(),qk(),Yk()};Kk();const Kh=new WeakMap;function Jk(t){return(typeof t=="object"||typeof t=="function")&&t!==null&&"then"in t&&typeof t.then=="function"}function or(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 Xk(){return new Error("register(Key, factory) does not accept async factories. Await setup before registering.")}class Qk{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 Xk();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(`${or(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(`${or(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(`${or(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=>or(s)).join(" -> ");throw new Error(`Circular dependency detected: ${r}`)}this.constructionStack.push(e.key);try{const r=e.factory();if(Jk(r))throw new Error(`Factory for ${or(e.key)} returned a Promise. Await setup before registering.`);if(typeof r!="object"||r===null)throw new Error(`Factory for ${or(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 Ye=new Qk,eE=new Set(["target","currentTarget","eventPhase","defaultPrevented","isTrusted","timeStamp","srcElement","returnValue","cancelBubble","NONE","CAPTURING_PHASE","AT_TARGET","BUBBLING_PHASE","composedPath","stopPropagation","stopImmediatePropagation","preventDefault","initEvent"]);function tE(t){for(const e of Object.keys(t))if(eE.has(e))throw new Error(`Event payload key "${e}" is reserved; choose a different property name`)}function nE(t,e){tE(e);for(const n of Object.keys(e))Object.defineProperty(t,n,{value:e[n],writable:!0,enumerable:!0,configurable:!0})}function Be(){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}),nE(this,l)}}return t}class kt extends globalThis.EventTarget{}function rE(t,e,n){const r=t.dispose.bind(t);t.dispose=()=>{if(!e())return n(),r()}}function Gr(t){var n;class e extends t{constructor(...i){super(...i);x(this,n,!1);rE(this,()=>h(this,n),()=>{$(this,n,!0)})}[Symbol.dispose](){this.dispose()}get disposed(){return h(this,n)}}return n=new WeakMap,e}const sE=Be(),to=Be(),cp="0123456789ABCDEFGHJKMNPQRSTVWXYZ",go=32,iE=16,up=10,Xh=0xffffffffffff;var An;(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"})(An||(An={}));class ps extends Error{constructor(e,n){super(`${n} (${e})`),this.name="ULIDError",this.code=e}}function oE(t){const e=Math.floor(t()*go)%go;return cp.charAt(e)}function aE(t){const e=lE(),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 ps(An.PRNGDetectFailure,"Failed to find a reliable PRNG")}function lE(){return hE()?self:typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:null}function cE(t,e){let n="";for(;t>0;t--)n=oE(e)+n;return n}function uE(t,e=up){if(isNaN(t))throw new ps(An.EncodeTimeValueMalformed,`Time must be a number: ${t}`);if(t>Xh)throw new ps(An.EncodeTimeSizeExceeded,`Cannot encode a time larger than ${Xh}: ${t}`);if(t<0)throw new ps(An.EncodeTimeNegative,`Time must be positive: ${t}`);if(Number.isInteger(t)===!1)throw new ps(An.EncodeTimeValueMalformed,`Time must be an integer: ${t}`);let n,r="";for(let s=e;s>0;s--)n=t%go,r=cp.charAt(n)+r,t=(t-n)/go;return r}function hE(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}function Ac(t,e){const n=aE(),r=Date.now();return uE(r,up)+cE(iE,n)}const St=4,Ke=6,hp=2,gl=2,dE=St,fE=Ke,xc="auto",on="auto",kn=120,Qh=75,de=16,nn=kn*St+de*(St-1),mr=kn*Ke+de*(Ke-1),pE=200,gE=4,Li=150,mE=10,ed=2,vE=4;function dp(t){return gp(t)}function fp(t,e){return gp(t.flatMap(n=>vp(n,e)))}function pp(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}yp(r,"strip",e,n)}return{valid:e.length===0,errors:e}}function $s(t){const e=dp(t),n=pp(e);if(!n.valid)throw new Error(`Invalid layout: ${n.errors.join("; ")}`);return{totalNodes:e.length,nodes:e.filter(r=>r.type!=="row").map(_E)}}function gp(t){const e=[];for(const n of t){const r=mp(n);for(const s of r){if(s.type==="row"){e.push(...s.children.map(Ft));continue}e.push(s)}}return e}function mp(t){switch(t.type){case"card":return[Ft(t)];case"row":{const e=t.children.map(Ft);return e.length===0?[]:e.length===1?[e[0]]:[{...t,children:e}]}case"stack":{const e=[];for(const n of t.children){const r=mp(n);for(const s of r){if(s.type==="stack"){e.push(...s.children.map(ml));continue}if(s.type==="row"){e.push({...s,children:s.children.map(Ft)});continue}e.push(Ft(s))}}return e.length===0?[]:e.length===1?[ml(e[0])]:[{...t,children:e}]}}}function vp(t,e){switch(t.type){case"card":return t.artifactID===e?[]:[Ft(t)];case"row":{const n=t.children.filter(r=>r.artifactID!==e).map(Ft);return n.length===0?[]:n.length===1?[n[0]]:[{...t,children:n}]}case"stack":{const n=t.children.flatMap(r=>vp(r,e).filter(i=>i.type!=="stack"));return n.length===0?[]:n.length===1?[ml(n[0])]:[{...t,children:n}]}}}function yp(t,e,n,r){switch(t.type){case"card":bp(t,e,n,r);return;case"row":yE(t,e,n,r);return;case"stack":bE(t,e,n,r);return}}function bp(t,e,n,r){Cc(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),wE(t.width)||n.push(`Card ${t.id} width must be an integer in the range 2-4`),wp(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<hp&&n.push(`Row child ${t.id} must be at least 2 columns wide`)}function yE(t,e,n,r){if(Cc(t.id,n),e!=="stack"&&n.push(`Row ${t.id} may only appear inside a stack`),wp(t.height,vE)||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}bp(i,"row",n,r),s+=En(i.width)}s!==St&&n.push(`Row ${t.id} children must sum to 4 columns`)}function bE(t,e,n,r){if(Cc(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(yp(a,"stack",n,r),a.height===on){i+=1;continue}s+=a.height}if(s>Ke&&n.push(`Stack ${t.id} exceeds the 6-row budget`),i===0)return;const o=Ke-s;if(o<i*gl||o%i!==0){n.push(`Stack ${t.id} has auto-height children that cannot resolve to whole height >= 2`);return}o/i<gl&&n.push(`Stack ${t.id} has auto-height children below the minimum row size`)}function Cc(t,e){(typeof t!="string"||t.length===0)&&e.push(`Node id must be a non-empty string: ${String(t)}`)}function wE(t){return t===xc||Number.isInteger(t)&&t>=hp&&t<=dE}function wp(t,e=fE){return t===on||Number.isInteger(t)&&t>=gl&&t<=e}function En(t){return t===xc?St:t}function _E(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:_p(t.height,Ke)}]};const e=SE(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 SE(t){let e=0,n=0;for(const s of t)s.height===on?n+=1:e+=s.height;const r=n>0?(Ke-e)/n:0;return t.map(s=>_p(s.height,r))}function _p(t,e){return t===on?e:t}function Ft(t){return{...t}}function ml(t){return t.type==="card"?Ft(t):{...t,children:t.children.map(Ft)}}function Sp(t,e={}){return{id:e.id??Ac(),type:"card",artifactID:t,width:e.width??xc,height:e.height??on}}function kp(t,e){return t.some(n=>Ep(n,e))}function Ep(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=>Ep(n,e))}}function td(t){return t.layout.flatMap($p)}function $p(t){switch(t.type){case"card":return[t.artifactID];case"row":return t.children.map(e=>e.artifactID);case"stack":return t.children.flatMap($p)}}const te=Be(),Ap=Be(),ss=Be(),kE=Be();function EE(t){class e extends Error{constructor(r,s){super(r),this.name=t,s&&Object.assign(this,s)}}return e}const $E=EE("RequestError"),AE=200,xE=300;class CE{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 TE(s);if(!s.ok||s.status<AE||s.status>=xE)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 Wa(r,r.statusText),r.status)}async requestText(e,n){const r=await this.request(e,n);if(!r.ok)throw this.createError(await Wa(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 Wa(s,s.statusText),s.status)}createError(e,n){const r={serverURL:this.serverURL};return n!==void 0&&(r.status=n),new $E(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 TE(t){try{return await t.json()}catch{const e=await t.text().catch(()=>"");return e?{message:e}:{}}}async function Wa(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 xp(t){return t.map(e=>`${e.name} (${e.id})`).join(", ")}var vt,Ao,Cp;class IE{constructor(e){x(this,Ao);x(this,vt);$(this,vt,e)}list(){return h(this,vt).requestJSON("GET","/screens")}async get(e={}){const n=await b(this,Ao,Cp).call(this,e.screenID);return h(this,vt).requestJSON("GET",`/screens/${encodeURIComponent(n)}`)}create(e){const n={name:e.name};return e.id!==void 0&&(n.id=e.id),h(this,vt).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),h(this,vt).requestJSON("PATCH",`/screens/${encodeURIComponent(e.screenID)}`,n)}remove(e){return h(this,vt).requestJSON("DELETE",`/screens/${encodeURIComponent(e.screenID)}`)}}vt=new WeakMap,Ao=new WeakSet,Cp=async function(e){if(e!==void 0)return e;const{screens:n}=await this.list();if(n.length===1)return n[0].id;throw h(this,vt).createError(`screenID is required when multiple screens exist. Available screens: ${xp(n)}`)};var Ue,zs,xo,Tp;class PE{constructor(e,n){x(this,xo);x(this,Ue);x(this,zs);$(this,Ue,e),$(this,zs,n)}async create(e){const n=await b(this,xo,Tp).call(this,e.screenID);return h(this,Ue).requestJSON("POST",`/screens/${encodeURIComponent(n)}/artifact`,{type:e.type,title:e.title,externalFilePath:e.externalFilePath})}get(e){return h(this,Ue).requestJSON("GET",`/artifacts/${encodeURIComponent(e.artifactID)}`)}update(e){const n={};return e.title!==void 0&&(n.title=e.title),h(this,Ue).requestJSON("PATCH",`/artifacts/${encodeURIComponent(e.artifactID)}`,n)}edit(e){return h(this,Ue).requestJSON("POST",`/artifacts/${encodeURIComponent(e.artifactID)}/edit`)}commitPending(e){return h(this,Ue).requestJSON("POST",`/artifacts/${encodeURIComponent(e.artifactID)}/commit`)}abandonPending(e){return h(this,Ue).requestVoid("POST",`/artifacts/${encodeURIComponent(e.artifactID)}/abandon`)}remove(e){return h(this,Ue).requestJSON("DELETE",`/screens/${encodeURIComponent(e.screenID)}/artifacts/${encodeURIComponent(e.artifactID)}`)}getContent(e){return h(this,Ue).requestText("GET",`/artifacts/${encodeURIComponent(e.artifactID)}/content`)}putContent(e){return h(this,Ue).requestRawVoid("PUT",`/artifacts/${encodeURIComponent(e.artifactID)}/content`,e.content)}}Ue=new WeakMap,zs=new WeakMap,xo=new WeakSet,Tp=async function(e){if(e!==void 0)return e;const{screens:n}=await h(this,zs).list();if(n.length===1)return n[0].id;throw h(this,Ue).createError(`screenID is required when multiple screens exist. Available screens: ${xp(n)}`)};var Ls;class RE{constructor(e){x(this,Ls);$(this,Ls,e)}async list(){const{views:e}=await h(this,Ls).requestJSON("GET","/views");return e}}Ls=new WeakMap;var Ht;class DE{constructor(e,n={}){v(this,"screens");v(this,"artifacts");v(this,"views");x(this,Ht);$(this,Ht,new CE(e,n)),this.screens=new IE(h(this,Ht)),this.artifacts=new PE(h(this,Ht),this.screens),this.views=new RE(h(this,Ht))}health(){return h(this,Ht).requestJSON("GET","/health")}}Ht=new WeakMap;const OE=Gr(kt);var Cn,Fe,Tn,Oe,qt,Yt,Q,lr,Ip,Ms,Pp,Rp,Dp,Op,vl,yl,bl,zp;class zE extends OE{constructor(n){var s;super();x(this,Q);v(this,"id");v(this,"server");x(this,Cn);x(this,Fe,new Map);x(this,Tn);x(this,Oe);x(this,qt);x(this,Yt,null);x(this,Ms,n=>{if(this.disposed)return;const r=n.event;switch(r.type){case"screen-updated":r.screen.id===this.id&&b(this,Q,Pp).call(this,r.screen);break;case"artifact-created":r.screenID===this.id&&b(this,Q,Rp).call(this,r.artifact);break;case"artifact-updated":b(this,Q,Dp).call(this,r.artifact);break;case"artifact-removed":r.screenID===this.id&&b(this,Q,Op).call(this,r.artifactID);break;case"artifact-content-changed":h(this,Fe).has(r.artifactID)&&this.dispatchEvent(new kE("artifact-content-changed",{artifactID:r.artifactID}));break}});this.id=n.screen.id,this.server=n.server,$(this,Cn,n.localStore),$(this,Tn,n.screen.name),$(this,Oe,structuredClone(n.screen.layout));const r=((s=h(this,Cn).get().screens[this.id])==null?void 0:s.scrollPosition)??0;$(this,qt,Math.max(0,r)),this.server.addEventListener("server-event",h(this,Ms)),b(this,Q,Ip).call(this)}get name(){return h(this,Tn)}get layout(){return h(this,Oe)}get scrollPosition(){return h(this,qt)}get artifacts(){return h(this,Fe)}setScrollPosition(n){b(this,Q,lr).call(this);const r=Math.max(0,n);r!==h(this,qt)&&($(this,qt,r),b(this,Q,zp).call(this),this.dispatchEvent(new te("change")))}setLayout(n){b(this,Q,lr).call(this);const r=dp(n);if(!pp(r).valid)return;const i=b(this,Q,yl).call(this);$(this,Oe,r),$(this,Yt,{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=h(this,Yt))==null?void 0:o.layout)===r&&($(this,Yt,null),b(this,Q,bl).call(this,i),this.dispatchEvent(new te("change")))})}rename(n){b(this,Q,lr).call(this),$(this,Tn,n),this.dispatchEvent(new te("change")),this.server.client.screens.update({screenID:this.id,name:n}).catch(()=>{})}async remove(){b(this,Q,lr).call(this),await this.server.client.screens.remove({screenID:this.id})}removeArtifact(n){if(b(this,Q,lr).call(this),!h(this,Fe).has(n))return;const r=b(this,Q,yl).call(this);b(this,Q,vl).call(this,n),this.dispatchEvent(new te("change")),this.server.client.artifacts.remove({artifactID:n,screenID:this.id}).catch(()=>{this.disposed||(b(this,Q,bl).call(this,r),this.dispatchEvent(new te("change")))})}dispose(){this.server.removeEventListener("server-event",h(this,Ms))}}Cn=new WeakMap,Fe=new WeakMap,Tn=new WeakMap,Oe=new WeakMap,qt=new WeakMap,Yt=new WeakMap,Q=new WeakSet,lr=function(){if(this.disposed)throw new Error("ScreenModel is disposed")},Ip=async function(){try{const n=await this.server.client.screens.get({screenID:this.id});if(this.disposed)return;for(const r of n.artifacts)h(this,Fe).set(r.id,r);this.dispatchEvent(new te("change"))}catch{}},Ms=new WeakMap,Pp=function(n){h(this,Yt)&&$(this,Yt,null),$(this,Tn,n.name),$(this,Oe,structuredClone(n.layout)),this.dispatchEvent(new te("change"))},Rp=function(n){kp(h(this,Oe),n.id)||$(this,Oe,[...h(this,Oe),Sp(n.id)]),h(this,Fe).set(n.id,n),this.dispatchEvent(new te("change"))},Dp=function(n){const r=h(this,Fe).get(n.id);r&&(h(this,Fe).set(n.id,{...r,...n}),this.dispatchEvent(new te("change")))},Op=function(n){b(this,Q,vl).call(this,n)&&this.dispatchEvent(new te("change"))},vl=function(n){const r=h(this,Fe).delete(n),s=td({layout:h(this,Oe)}).length,i=fp(h(this,Oe),n),o=td({layout:i}).length;return $(this,Oe,i),r||s!==o},yl=function(){return{layout:structuredClone(h(this,Oe)),artifacts:new Map([...h(this,Fe).entries()].map(([n,r])=>[n,structuredClone(r)]))}},bl=function(n){$(this,Oe,structuredClone(n.layout)),h(this,Fe).clear();for(const[r,s]of n.artifacts)h(this,Fe).set(r,structuredClone(s))},zp=function(){const n=h(this,Cn).get();h(this,Cn).set({...n,screens:{...n.screens,[this.id]:{scrollPosition:h(this,qt)}}})};const LE=Gr(kt);var Ze,yt,rt,Ns,Us,Fs,rn,no,Lp;class ME extends LE{constructor(n){super();x(this,rn);x(this,Ze);x(this,yt);x(this,rt,null);x(this,Ns,()=>{this.disposed||b(this,rn,no).call(this)});x(this,Us,()=>{this.disposed||b(this,rn,no).call(this)});x(this,Fs,n=>{var s;if(this.disposed)return;const r=n.event;r.type==="screen-removed"&&((s=h(this,rt))==null?void 0:s.id)===r.screenID&&this.clearActive()});$(this,Ze,n.localStore),$(this,yt,n.serverManager),h(this,Ze).addEventListener("change",h(this,Ns)),h(this,yt).addEventListener("change",h(this,Us)),h(this,yt).addEventListener("server-event",h(this,Fs)),b(this,rn,no).call(this)}get activeScreen(){return h(this,rt)}setActive(n,r){const s=h(this,Ze).get();s.activeServerURL===n&&s.activeScreenID===r||h(this,Ze).set({...s,activeServerURL:n,activeScreenID:r})}clearActive(){const n=h(this,Ze).get();n.activeServerURL===null&&n.activeScreenID===null||h(this,Ze).set({...n,activeServerURL:null,activeScreenID:null})}dispose(){var n;h(this,Ze).removeEventListener("change",h(this,Ns)),h(this,yt).removeEventListener("change",h(this,Us)),h(this,yt).removeEventListener("server-event",h(this,Fs)),(n=h(this,rt))==null||n.dispose(),$(this,rt,null)}}Ze=new WeakMap,yt=new WeakMap,rt=new WeakMap,Ns=new WeakMap,Us=new WeakMap,Fs=new WeakMap,rn=new WeakSet,no=function(){var l,c,d;const{activeServerURL:n,activeScreenID:r}=h(this,Ze).get();let s=n?h(this,yt).servers.get(n)??null:null,i=s&&r?s.screens.get(r)??null:null;if(!i){const f=b(this,rn,Lp).call(this);if(f){s=f.server,i=f.screen,h(this,Ze).set({...h(this,Ze).get(),activeServerURL:f.server.url,activeScreenID:f.screen.id});return}}const o=((l=h(this,rt))==null?void 0:l.id)??null,a=(i==null?void 0:i.id)??null;o===a&&((c=h(this,rt))==null?void 0:c.server)===s||((d=h(this,rt))==null||d.dispose(),$(this,rt,s&&i?new zE({screen:i,server:s,localStore:h(this,Ze)}):null),this.dispatchEvent(new sE("active-screen-changed")))},Lp=function(){for(const n of h(this,yt).servers.values()){const r=n.screens.values().next().value;if(r)return{server:n,screen:r}}return null};const NE="Local",UE="store-";function Pt(t){return new URL(t).origin}function FE(t){return{servers:[{url:Pt(t),name:NE}],activeServerURL:null,activeScreenID:null,screens:{}}}var In,Pn,Rn;class ZE extends kt{constructor(n,r,s={}){super();x(this,In);x(this,Pn);x(this,Rn);$(this,In,`${UE}${n}`),$(this,Pn,s.storage??jE());const i=h(this,Pn).getItem(h(this,In));i===null?($(this,Rn,r),h(this,Pn).setItem(h(this,In),JSON.stringify(r))):$(this,Rn,JSON.parse(i))}get(){return h(this,Rn)}set(n){$(this,Rn,n),h(this,Pn).setItem(h(this,In),JSON.stringify(n)),this.dispatchEvent(new te("change"))}}In=new WeakMap,Pn=new WeakMap,Rn=new WeakMap;function jE(){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 f=0;f<d.length;f++){const y=d[f];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 wr extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Mp extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}}const Np={};function an(t){return Np}function Up(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 wl(t,e){return typeof e=="bigint"?e.toString():e}function Tc(t){return{get value(){{const e=t();return Object.defineProperty(this,"value",{value:e}),e}}}}function Ic(t){return t==null}function Pc(t){const e=t.startsWith("^")?1:0,n=t.endsWith("$")?t.length-1:t.length;return t.slice(e,n)}function WE(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 Yn(t,e,n){Object.defineProperty(t,e,{value:n,writable:!0,enumerable:!0,configurable:!0})}function fn(...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 BE(t){return t.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Fp="captureStackTrace"in Error?Error.captureStackTrace:(...t)=>{};function mo(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}const VE=Tc(()=>{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 Or(t){if(mo(t)===!1)return!1;const e=t.constructor;if(e===void 0||typeof e!="function")return!0;const n=e.prototype;return!(mo(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function Zp(t){return Or(t)?{...t}:Array.isArray(t)?[...t]:t}const GE=new Set(["string","number","symbol"]);function zr(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function pn(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 D(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 HE(t){return Object.keys(t).filter(e=>t[e]._zod.optin==="optional"&&t[e]._zod.optout==="optional")}const qE={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 YE(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=fn(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 Yn(this,"shape",o),o},checks:[]});return pn(t,i)}function KE(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=fn(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 Yn(this,"shape",o),o},checks:[]});return pn(t,i)}function JE(t,e){if(!Or(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=fn(t._zod.def,{get shape(){const i={...t._zod.def.shape,...e};return Yn(this,"shape",i),i}});return pn(t,s)}function XE(t,e){if(!Or(e))throw new Error("Invalid input to safeExtend: expected a plain object");const n=fn(t._zod.def,{get shape(){const r={...t._zod.def.shape,...e};return Yn(this,"shape",r),r}});return pn(t,n)}function QE(t,e){const n=fn(t._zod.def,{get shape(){const r={...t._zod.def.shape,...e._zod.def.shape};return Yn(this,"shape",r),r},get catchall(){return e._zod.def.catchall},checks:[]});return pn(t,n)}function e0(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=fn(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 Yn(this,"shape",l),l},checks:[]});return pn(e,o)}function t0(t,e,n){const r=fn(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 Yn(this,"shape",i),i}});return pn(e,r)}function vr(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 yr(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 ln(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 Rc(t){return Array.isArray(t)?"array":typeof t=="string"?"string":"unknown"}function Cs(...t){const[e,n,r]=t;return typeof e=="string"?{message:e,code:"custom",input:n,inst:r}:{...e}}const jp=(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,wl,2),Object.defineProperty(t,"toString",{value:()=>t.message,enumerable:!1})},Wp=S("$ZodError",jp),Bp=S("$ZodError",jp,{Parent:Error});function n0(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 r0(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 Dc=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 wr;if(o.issues.length){const a=new((s==null?void 0:s.Err)??t)(o.issues.map(l=>ln(l,i,an())));throw Fp(a,s==null?void 0:s.callee),a}return o.value},Oc=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=>ln(l,i,an())));throw Fp(a,s==null?void 0:s.callee),a}return o.value},Wo=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 wr;return i.issues.length?{success:!1,error:new(t??Wp)(i.issues.map(o=>ln(o,s,an())))}:{success:!0,data:i.value}},s0=Wo(Bp),Bo=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=>ln(o,s,an())))}:{success:!0,data:i.value}},i0=Bo(Bp),o0=t=>(e,n,r)=>{const s=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Dc(t)(e,n,s)},a0=t=>(e,n,r)=>Dc(t)(e,n,r),l0=t=>async(e,n,r)=>{const s=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Oc(t)(e,n,s)},c0=t=>async(e,n,r)=>Oc(t)(e,n,r),u0=t=>(e,n,r)=>{const s=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Wo(t)(e,n,s)},h0=t=>(e,n,r)=>Wo(t)(e,n,r),d0=t=>async(e,n,r)=>{const s=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Bo(t)(e,n,s)},f0=t=>async(e,n,r)=>Bo(t)(e,n,r),p0=/^[cC][^\s-]{8,}$/,g0=/^[0-9a-z]+$/,m0=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,v0=/^[0-9a-vA-V]{20}$/,y0=/^[A-Za-z0-9]{27}$/,b0=/^[a-zA-Z0-9_-]{21}$/,w0=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,_0=/^([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)$/,S0=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,k0="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function E0(){return new RegExp(k0,"u")}const $0=/^(?:(?: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])$/,A0=/^(([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}|:))$/,x0=/^((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])$/,C0=/^(([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])$/,T0=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Vp=/^[A-Za-z0-9_-]*$/,I0=/^\+[1-9]\d{6,14}$/,Gp="(?:(?:\\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])))",P0=new RegExp(`^${Gp}$`);function Hp(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 R0(t){return new RegExp(`^${Hp(t)}$`)}function D0(t){const e=Hp({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(`^${Gp}T(?:${r})$`)}const O0=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}$`)},z0=/^-?\d+$/,qp=/^-?\d+(?:\.\d+)?$/,L0=/^(?:true|false)$/i,M0=/^[^A-Z]*$/,N0=/^[^a-z]*$/,Ve=S("$ZodCheck",(t,e)=>{var n;t._zod??(t._zod={}),t._zod.def=e,(n=t._zod).onattach??(n.onattach=[])}),Yp={number:"number",bigint:"bigint",object:"date"},Kp=S("$ZodCheckLessThan",(t,e)=>{Ve.init(t,e);const n=Yp[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})}}),Jp=S("$ZodCheckGreaterThan",(t,e)=>{Ve.init(t,e);const n=Yp[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})}}),U0=S("$ZodCheckMultipleOf",(t,e)=>{Ve.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):WE(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})}}),F0=S("$ZodCheckNumberFormat",(t,e)=>{var o;Ve.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]=qE[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=z0)}),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})}}),Z0=S("$ZodCheckMaxLength",(t,e)=>{var n;Ve.init(t,e),(n=t._zod.def).when??(n.when=r=>{const s=r.value;return!Ic(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=Rc(s);r.issues.push({origin:o,code:"too_big",maximum:e.maximum,inclusive:!0,input:s,inst:t,continue:!e.abort})}}),j0=S("$ZodCheckMinLength",(t,e)=>{var n;Ve.init(t,e),(n=t._zod.def).when??(n.when=r=>{const s=r.value;return!Ic(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=Rc(s);r.issues.push({origin:o,code:"too_small",minimum:e.minimum,inclusive:!0,input:s,inst:t,continue:!e.abort})}}),W0=S("$ZodCheckLengthEquals",(t,e)=>{var n;Ve.init(t,e),(n=t._zod.def).when??(n.when=r=>{const s=r.value;return!Ic(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=Rc(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})}}),Vo=S("$ZodCheckStringFormat",(t,e)=>{var n,r;Ve.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=()=>{})}),B0=S("$ZodCheckRegex",(t,e)=>{Vo.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})}}),V0=S("$ZodCheckLowerCase",(t,e)=>{e.pattern??(e.pattern=M0),Vo.init(t,e)}),G0=S("$ZodCheckUpperCase",(t,e)=>{e.pattern??(e.pattern=N0),Vo.init(t,e)}),H0=S("$ZodCheckIncludes",(t,e)=>{Ve.init(t,e);const n=zr(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})}}),q0=S("$ZodCheckStartsWith",(t,e)=>{Ve.init(t,e);const n=new RegExp(`^${zr(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})}}),Y0=S("$ZodCheckEndsWith",(t,e)=>{Ve.init(t,e);const n=new RegExp(`.*${zr(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})}}),K0=S("$ZodCheckOverwrite",(t,e)=>{Ve.init(t,e),t._zod.check=n=>{n.value=e.tx(n.value)}});class J0{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
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 t0={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=t0;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=vr(a),f;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 wr;if(f||E instanceof Promise)f=(f??Promise.resolve()).then(async()=>{await E,a.issues.length!==m&&(d||(d=vr(a,m)))});else{if(a.issues.length===m)continue;d||(d=vr(a,m))}}return f?f.then(()=>a):a},o=(a,l,c)=>{if(vr(a))return a.aborted=!0,a;const d=i(l,r,c);if(d instanceof Promise){if(c.async===!1)throw new wr;return d.then(f=>t._zod.parse(f,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(f=>o(f,a,l)):o(d,a,l)}const c=t._zod.parse(a,l);if(c instanceof Promise){if(l.async===!1)throw new wr;return c.then(d=>i(d,r,l))}return i(c,r,l)}}ee(t,"~standard",()=>({validate:i=>{var o;try{const a=a$(t,i);return a.success?{value:a.data}:{issues:(o=a.error)==null?void 0:o.issues}}catch{return l$(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}))}),Rc=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()??M$(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)=>{Vo.init(t,e),Rc.init(t,e)}),n0=S("$ZodGUID",(t,e)=>{e.pattern??(e.pattern=E$),oe.init(t,e)}),r0=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=nd(r))}else e.pattern??(e.pattern=nd());oe.init(t,e)}),s0=S("$ZodEmail",(t,e)=>{e.pattern??(e.pattern=$$),oe.init(t,e)}),i0=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})}}}),o0=S("$ZodEmoji",(t,e)=>{e.pattern??(e.pattern=x$()),oe.init(t,e)}),a0=S("$ZodNanoID",(t,e)=>{e.pattern??(e.pattern=S$),oe.init(t,e)}),l0=S("$ZodCUID",(t,e)=>{e.pattern??(e.pattern=v$),oe.init(t,e)}),c0=S("$ZodCUID2",(t,e)=>{e.pattern??(e.pattern=y$),oe.init(t,e)}),u0=S("$ZodULID",(t,e)=>{e.pattern??(e.pattern=b$),oe.init(t,e)}),h0=S("$ZodXID",(t,e)=>{e.pattern??(e.pattern=w$),oe.init(t,e)}),d0=S("$ZodKSUID",(t,e)=>{e.pattern??(e.pattern=_$),oe.init(t,e)}),f0=S("$ZodISODateTime",(t,e)=>{e.pattern??(e.pattern=L$(e)),oe.init(t,e)}),p0=S("$ZodISODate",(t,e)=>{e.pattern??(e.pattern=O$),oe.init(t,e)}),g0=S("$ZodISOTime",(t,e)=>{e.pattern??(e.pattern=z$(e)),oe.init(t,e)}),m0=S("$ZodISODuration",(t,e)=>{e.pattern??(e.pattern=k$),oe.init(t,e)}),v0=S("$ZodIPv4",(t,e)=>{e.pattern??(e.pattern=T$),oe.init(t,e),t._zod.bag.format="ipv4"}),y0=S("$ZodIPv6",(t,e)=>{e.pattern??(e.pattern=C$),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})}}}),b0=S("$ZodCIDRv4",(t,e)=>{e.pattern??(e.pattern=I$),oe.init(t,e)}),w0=S("$ZodCIDRv6",(t,e)=>{e.pattern??(e.pattern=P$),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 Xp(t){if(t==="")return!0;if(t.length%4!==0)return!1;try{return atob(t),!0}catch{return!1}}const _0=S("$ZodBase64",(t,e)=>{e.pattern??(e.pattern=R$),oe.init(t,e),t._zod.bag.contentEncoding="base64",t._zod.check=n=>{Xp(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:t,continue:!e.abort})}});function S0(t){if(!Vp.test(t))return!1;const e=t.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=e.padEnd(Math.ceil(e.length/4)*4,"=");return Xp(n)}const k0=S("$ZodBase64URL",(t,e)=>{e.pattern??(e.pattern=Vp),oe.init(t,e),t._zod.bag.contentEncoding="base64url",t._zod.check=n=>{S0(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:t,continue:!e.abort})}}),E0=S("$ZodE164",(t,e)=>{e.pattern??(e.pattern=D$),oe.init(t,e)});function $0(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 A0=S("$ZodJWT",(t,e)=>{oe.init(t,e),t._zod.check=n=>{$0(n.value,e.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:t,continue:!e.abort})}}),Qp=S("$ZodNumber",(t,e)=>{le.init(t,e),t._zod.pattern=t._zod.bag.pattern??qp,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}}),x0=S("$ZodNumberFormat",(t,e)=>{W$.init(t,e),Qp.init(t,e)}),T0=S("$ZodBoolean",(t,e)=>{le.init(t,e),t._zod.pattern=U$,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}}),C0=S("$ZodUnknown",(t,e)=>{le.init(t,e),t._zod.parse=n=>n}),I0=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 rd(t,e,n){t.issues.length&&e.issues.push(...yr(n,t.issues)),e.value[n]=t.value}const P0=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=>rd(c,n,o))):rd(l,n,o)}return i.length?Promise.all(i).then(()=>n):n}});function vo(t,e,n,r,s){if(t.issues.length){if(s&&!(n in r))return;e.issues.push(...yr(n,t.issues))}t.value===void 0?n in r&&(e.value[n]=void 0):e.value[n]=t.value}function eg(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=KE(t.shape);return{...t,keys:e,keySet:new Set(e),numKeys:e.length,optionalKeys:new Set(n)}}function tg(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 f in e){if(a.has(f))continue;if(c==="never"){o.push(f);continue}const y=l.run({value:e[f],issues:[]},r);y instanceof Promise?t.push(y.then(m=>vo(m,n,f,e,d))):vo(y,n,f,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 R0=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=Ac(()=>eg(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 f of d.values)l[c].add(f)}}return l});const s=mo,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=[],f=o.shape;for(const y of o.keys){const m=f[y],E=m._zod.optout==="optional",k=m._zod.run({value:c[y],issues:[]},l);k instanceof Promise?d.push(k.then(I=>vo(I,a,y,c,E))):vo(k,a,y,c,E)}return i?tg(d,c,a,l,r.value,t):d.length?Promise.all(d).then(()=>a):a}}),D0=S("$ZodObjectJIT",(t,e)=>{R0.init(t,e);const n=t._zod.parse,r=Ac(()=>eg(e)),s=y=>{var j;const m=new e0(["shape","payload","ctx"]),E=r.value,k=F=>{const L=td(F);return`shape[${L}]._zod.run({ value: input[${L}], issues: [] }, ctx)`};m.write("const input = payload.value;");const I=Object.create(null);let V=0;for(const F of E.keys)I[F]=`key_${V++}`;m.write("const newResult = {};");for(const F of E.keys){const L=I[F],J=td(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(`
6
+ `))}}const X0={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=X0;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=vr(a),f;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 wr;if(f||E instanceof Promise)f=(f??Promise.resolve()).then(async()=>{await E,a.issues.length!==m&&(d||(d=vr(a,m)))});else{if(a.issues.length===m)continue;d||(d=vr(a,m))}}return f?f.then(()=>a):a},o=(a,l,c)=>{if(vr(a))return a.aborted=!0,a;const d=i(l,r,c);if(d instanceof Promise){if(c.async===!1)throw new wr;return d.then(f=>t._zod.parse(f,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(f=>o(f,a,l)):o(d,a,l)}const c=t._zod.parse(a,l);if(c instanceof Promise){if(l.async===!1)throw new wr;return c.then(d=>i(d,r,l))}return i(c,r,l)}}ee(t,"~standard",()=>({validate:i=>{var o;try{const a=s0(t,i);return a.success?{value:a.data}:{issues:(o=a.error)==null?void 0:o.issues}}catch{return i0(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}))}),zc=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()??O0(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)=>{Vo.init(t,e),zc.init(t,e)}),Q0=S("$ZodGUID",(t,e)=>{e.pattern??(e.pattern=_0),oe.init(t,e)}),e$=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)}),t$=S("$ZodEmail",(t,e)=>{e.pattern??(e.pattern=S0),oe.init(t,e)}),n$=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})}}}),r$=S("$ZodEmoji",(t,e)=>{e.pattern??(e.pattern=E0()),oe.init(t,e)}),s$=S("$ZodNanoID",(t,e)=>{e.pattern??(e.pattern=b0),oe.init(t,e)}),i$=S("$ZodCUID",(t,e)=>{e.pattern??(e.pattern=p0),oe.init(t,e)}),o$=S("$ZodCUID2",(t,e)=>{e.pattern??(e.pattern=g0),oe.init(t,e)}),a$=S("$ZodULID",(t,e)=>{e.pattern??(e.pattern=m0),oe.init(t,e)}),l$=S("$ZodXID",(t,e)=>{e.pattern??(e.pattern=v0),oe.init(t,e)}),c$=S("$ZodKSUID",(t,e)=>{e.pattern??(e.pattern=y0),oe.init(t,e)}),u$=S("$ZodISODateTime",(t,e)=>{e.pattern??(e.pattern=D0(e)),oe.init(t,e)}),h$=S("$ZodISODate",(t,e)=>{e.pattern??(e.pattern=P0),oe.init(t,e)}),d$=S("$ZodISOTime",(t,e)=>{e.pattern??(e.pattern=R0(e)),oe.init(t,e)}),f$=S("$ZodISODuration",(t,e)=>{e.pattern??(e.pattern=w0),oe.init(t,e)}),p$=S("$ZodIPv4",(t,e)=>{e.pattern??(e.pattern=$0),oe.init(t,e),t._zod.bag.format="ipv4"}),g$=S("$ZodIPv6",(t,e)=>{e.pattern??(e.pattern=A0),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})}}}),m$=S("$ZodCIDRv4",(t,e)=>{e.pattern??(e.pattern=x0),oe.init(t,e)}),v$=S("$ZodCIDRv6",(t,e)=>{e.pattern??(e.pattern=C0),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 Xp(t){if(t==="")return!0;if(t.length%4!==0)return!1;try{return atob(t),!0}catch{return!1}}const y$=S("$ZodBase64",(t,e)=>{e.pattern??(e.pattern=T0),oe.init(t,e),t._zod.bag.contentEncoding="base64",t._zod.check=n=>{Xp(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:t,continue:!e.abort})}});function b$(t){if(!Vp.test(t))return!1;const e=t.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=e.padEnd(Math.ceil(e.length/4)*4,"=");return Xp(n)}const w$=S("$ZodBase64URL",(t,e)=>{e.pattern??(e.pattern=Vp),oe.init(t,e),t._zod.bag.contentEncoding="base64url",t._zod.check=n=>{b$(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:t,continue:!e.abort})}}),_$=S("$ZodE164",(t,e)=>{e.pattern??(e.pattern=I0),oe.init(t,e)});function S$(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 k$=S("$ZodJWT",(t,e)=>{oe.init(t,e),t._zod.check=n=>{S$(n.value,e.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:t,continue:!e.abort})}}),Qp=S("$ZodNumber",(t,e)=>{le.init(t,e),t._zod.pattern=t._zod.bag.pattern??qp,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}}),E$=S("$ZodNumberFormat",(t,e)=>{F0.init(t,e),Qp.init(t,e)}),$$=S("$ZodBoolean",(t,e)=>{le.init(t,e),t._zod.pattern=L0,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}}),A$=S("$ZodUnknown",(t,e)=>{le.init(t,e),t._zod.parse=n=>n}),x$=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(...yr(n,t.issues)),e.value[n]=t.value}const C$=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 vo(t,e,n,r,s){if(t.issues.length){if(s&&!(n in r))return;e.issues.push(...yr(n,t.issues))}t.value===void 0?n in r&&(e.value[n]=void 0):e.value[n]=t.value}function eg(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=HE(t.shape);return{...t,keys:e,keySet:new Set(e),numKeys:e.length,optionalKeys:new Set(n)}}function tg(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 f in e){if(a.has(f))continue;if(c==="never"){o.push(f);continue}const y=l.run({value:e[f],issues:[]},r);y instanceof Promise?t.push(y.then(m=>vo(m,n,f,e,d))):vo(y,n,f,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 T$=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=Tc(()=>eg(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 f of d.values)l[c].add(f)}}return l});const s=mo,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=[],f=o.shape;for(const y of o.keys){const m=f[y],E=m._zod.optout==="optional",k=m._zod.run({value:c[y],issues:[]},l);k instanceof Promise?d.push(k.then(I=>vo(I,a,y,c,E))):vo(k,a,y,c,E)}return i?tg(d,c,a,l,r.value,t):d.length?Promise.all(d).then(()=>a):a}}),I$=S("$ZodObjectJIT",(t,e)=>{T$.init(t,e);const n=t._zod.parse,r=Tc(()=>eg(e)),s=y=>{var j;const m=new J0(["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 V=0;for(const F of E.keys)I[F]=`key_${V++}`;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
7
  if (${L}.issues.length) {
8
8
  if (${J} in input) {
9
9
  payload.issues = payload.issues.concat(${L}.issues.map(iss => ({
@@ -37,40 +37,40 @@ var Cv=Object.defineProperty;var ku=t=>{throw TypeError(t)};var Iv=(t,e,n)=>e in
37
37
  newResult[${J}] = ${L}.value;
38
38
  }
39
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=mo,a=!Np.jitless,c=a&&qE.value,d=e.catchall;let f;t._zod.parse=(y,m)=>{f??(f=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?tg([],E,y,m,f,t):y):n(y,m):(y.issues.push({expected:"object",code:"invalid_type",input:E,inst:t}),y)}});function sd(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=>!vr(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=>ln(o,r,an())))}),e)}const O0=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=>Tc(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=>sd(l,s,t,i)):sd(a,s,t,i)}}),z0=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])=>id(n,l,c)):id(n,i,o)}});function yl(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(Or(t)&&Or(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=yl(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=yl(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 id(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}),vr(t))return t;const o=yl(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 L0=S("$ZodRecord",(t,e)=>{le.init(t,e),t._zod.parse=(n,r)=>{const s=n.value;if(!Or(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(f=>{f.issues.length&&n.issues.push(...yr(c,f.issues)),n.value[c]=f.value})):(d.issues.length&&n.issues.push(...yr(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"&&qp.test(a)&&l.issues.length){const f=e.keyType._zod.run({value:Number(a),issues:[]},r);if(f instanceof Promise)throw new Error("Async schemas not supported in object keys currently");f.issues.length===0&&(l=f)}if(l.issues.length){e.mode==="loose"?n.value[a]=s[a]:n.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map(f=>ln(f,r,an())),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(f=>{f.issues.length&&n.issues.push(...yr(a,f.issues)),n.value[l.value]=f.value})):(d.issues.length&&n.issues.push(...yr(a,d.issues)),n.value[l.value]=d.value)}}return i.length?Promise.all(i).then(()=>n):n}}),M0=S("$ZodEnum",(t,e)=>{le.init(t,e);const n=Up(e.entries),r=new Set(n);t._zod.values=r,t._zod.pattern=new RegExp(`^(${n.filter(s=>YE.has(typeof s)).map(s=>typeof s=="string"?zr(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}}),N0=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"?zr(r):r?zr(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}}),U0=S("$ZodTransform",(t,e)=>{le.init(t,e),t._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Mp(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 wr;return n.value=s,n}});function od(t,e){return t.issues.length&&e===void 0?{issues:[],value:void 0}:t}const ng=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(`^(${Tc(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=>od(i,n.value)):od(s,n.value)}return n.value===void 0?n:e.innerType._zod.run(n,r)}}),F0=S("$ZodExactOptional",(t,e)=>{ng.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)}),Z0=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(`^(${Tc(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)}),j0=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=>ad(i,e)):ad(s,e)}});function ad(t,e){return t.value===void 0&&(t.value=e.defaultValue),t}const W0=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))}),B0=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=>ld(i,t)):ld(s,t)}});function ld(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 V0=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=>ln(o,r,an()))},input:n.value}),n.issues=[]),n)):(n.value=s.value,s.issues.length&&(n.value=e.catchValue({...n,error:{issues:s.issues.map(i=>ln(i,r,an()))},input:n.value}),n.issues=[]),n)}}),G0=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 H0=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(cd):cd(s)}});function cd(t){return t.value=Object.freeze(t.value),t}const q0=S("$ZodCustom",(t,e)=>{Ve.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=>ud(i,n,r,t));ud(s,n,r,t)}});function ud(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(xs(s))}}var hd;class Y0{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 K0(){return new Y0}(hd=globalThis).__zod_globalRegistry??(hd.__zod_globalRegistry=K0());const ps=globalThis.__zod_globalRegistry;function J0(t,e){return new t({type:"string",...D(e)})}function X0(t,e){return new t({type:"string",format:"email",check:"string_format",abort:!1,...D(e)})}function dd(t,e){return new t({type:"string",format:"guid",check:"string_format",abort:!1,...D(e)})}function Q0(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,...D(e)})}function eA(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...D(e)})}function tA(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...D(e)})}function nA(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...D(e)})}function rA(t,e){return new t({type:"string",format:"url",check:"string_format",abort:!1,...D(e)})}function sA(t,e){return new t({type:"string",format:"emoji",check:"string_format",abort:!1,...D(e)})}function iA(t,e){return new t({type:"string",format:"nanoid",check:"string_format",abort:!1,...D(e)})}function oA(t,e){return new t({type:"string",format:"cuid",check:"string_format",abort:!1,...D(e)})}function aA(t,e){return new t({type:"string",format:"cuid2",check:"string_format",abort:!1,...D(e)})}function lA(t,e){return new t({type:"string",format:"ulid",check:"string_format",abort:!1,...D(e)})}function cA(t,e){return new t({type:"string",format:"xid",check:"string_format",abort:!1,...D(e)})}function uA(t,e){return new t({type:"string",format:"ksuid",check:"string_format",abort:!1,...D(e)})}function hA(t,e){return new t({type:"string",format:"ipv4",check:"string_format",abort:!1,...D(e)})}function dA(t,e){return new t({type:"string",format:"ipv6",check:"string_format",abort:!1,...D(e)})}function fA(t,e){return new t({type:"string",format:"cidrv4",check:"string_format",abort:!1,...D(e)})}function pA(t,e){return new t({type:"string",format:"cidrv6",check:"string_format",abort:!1,...D(e)})}function gA(t,e){return new t({type:"string",format:"base64",check:"string_format",abort:!1,...D(e)})}function mA(t,e){return new t({type:"string",format:"base64url",check:"string_format",abort:!1,...D(e)})}function vA(t,e){return new t({type:"string",format:"e164",check:"string_format",abort:!1,...D(e)})}function yA(t,e){return new t({type:"string",format:"jwt",check:"string_format",abort:!1,...D(e)})}function bA(t,e){return new t({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...D(e)})}function wA(t,e){return new t({type:"string",format:"date",check:"string_format",...D(e)})}function _A(t,e){return new t({type:"string",format:"time",check:"string_format",precision:null,...D(e)})}function SA(t,e){return new t({type:"string",format:"duration",check:"string_format",...D(e)})}function kA(t,e){return new t({type:"number",checks:[],...D(e)})}function EA(t,e){return new t({type:"number",check:"number_format",abort:!1,format:"safeint",...D(e)})}function $A(t,e){return new t({type:"boolean",...D(e)})}function AA(t){return new t({type:"unknown"})}function xA(t,e){return new t({type:"never",...D(e)})}function fd(t,e){return new Kp({check:"less_than",...D(e),value:t,inclusive:!1})}function Za(t,e){return new Kp({check:"less_than",...D(e),value:t,inclusive:!0})}function pd(t,e){return new Jp({check:"greater_than",...D(e),value:t,inclusive:!1})}function ja(t,e){return new Jp({check:"greater_than",...D(e),value:t,inclusive:!0})}function gd(t,e){return new j$({check:"multiple_of",...D(e),value:t})}function rg(t,e){return new B$({check:"max_length",...D(e),maximum:t})}function yo(t,e){return new V$({check:"min_length",...D(e),minimum:t})}function sg(t,e){return new G$({check:"length_equals",...D(e),length:t})}function TA(t,e){return new H$({check:"string_format",format:"regex",...D(e),pattern:t})}function CA(t){return new q$({check:"string_format",format:"lowercase",...D(t)})}function IA(t){return new Y$({check:"string_format",format:"uppercase",...D(t)})}function PA(t,e){return new K$({check:"string_format",format:"includes",...D(e),includes:t})}function RA(t,e){return new J$({check:"string_format",format:"starts_with",...D(e),prefix:t})}function DA(t,e){return new X$({check:"string_format",format:"ends_with",...D(e),suffix:t})}function Hr(t){return new Q$({check:"overwrite",tx:t})}function OA(t){return Hr(e=>e.normalize(t))}function zA(){return Hr(t=>t.trim())}function LA(){return Hr(t=>t.toLowerCase())}function MA(){return Hr(t=>t.toUpperCase())}function NA(){return Hr(t=>HE(t))}function UA(t,e,n){return new t({type:"array",element:e,...D(n)})}function FA(t,e,n){return new t({type:"custom",check:"custom",fn:e,...D(n)})}function ZA(t){const e=jA(n=>(n.addIssue=r=>{if(typeof r=="string")n.issues.push(xs(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(xs(s))}},t(n.value,n)));return e}function jA(t,e){const n=new Ve({check:"custom",...D(e)});return n._zod.check=t,n}function ig(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)??ps,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,f;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=(f=(d=t._zod).toJSONSchema)==null?void 0:f.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"&&De(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 og(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 f=(o=t.metadataRegistry.get(d[0]))==null?void 0:o.id;if(f){const y=r.get(f);if(y&&y!==d[0])throw new Error(`Duplicate schema id "${f}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(f,d[0])}}const s=d=>{var k;const f=t.target==="draft-2020-12"?"$defs":"definitions";if(t.external){const I=(k=t.external.registry.get(d[0]))==null?void 0:k.id,V=t.external.uri??(j=>j);if(I)return{ref:V(I)};const N=d[1].defId??d[1].schema.id??`schema${t.counter++}`;return d[1].defId=N,{defId:N,ref:`${V("__shared")}#/${f}/${N}`}}if(d[1]===n)return{ref:"#"};const m=`#/${f}/`,E=d[1].schema.id??`__schema${t.counter++}`;return{defId:E,ref:m+E}},i=d=>{if(d[1].schema.$ref)return;const f=d[1],{ref:y,defId:m}=s(d);f.def={...f.schema},m&&(f.defId=m);const E=f.schema;for(const k in E)delete E[k];E.$ref=y};if(t.cycles==="throw")for(const d of t.seen.entries()){const f=d[1];if(f.cycle)throw new Error(`Cycle detected: #/${(a=f.cycle)==null?void 0:a.join("/")}/<root>
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=mo,a=!Np.jitless,c=a&&VE.value,d=e.catchall;let f;t._zod.parse=(y,m)=>{f??(f=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?tg([],E,y,m,f,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=>!vr(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=>ln(o,r,an())))}),e)}const P$=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=>Pc(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)}}),R$=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 _l(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(Or(t)&&Or(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=_l(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=_l(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}),vr(t))return t;const o=_l(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 D$=S("$ZodRecord",(t,e)=>{le.init(t,e),t._zod.parse=(n,r)=>{const s=n.value;if(!Or(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(f=>{f.issues.length&&n.issues.push(...yr(c,f.issues)),n.value[c]=f.value})):(d.issues.length&&n.issues.push(...yr(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"&&qp.test(a)&&l.issues.length){const f=e.keyType._zod.run({value:Number(a),issues:[]},r);if(f instanceof Promise)throw new Error("Async schemas not supported in object keys currently");f.issues.length===0&&(l=f)}if(l.issues.length){e.mode==="loose"?n.value[a]=s[a]:n.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map(f=>ln(f,r,an())),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(f=>{f.issues.length&&n.issues.push(...yr(a,f.issues)),n.value[l.value]=f.value})):(d.issues.length&&n.issues.push(...yr(a,d.issues)),n.value[l.value]=d.value)}}return i.length?Promise.all(i).then(()=>n):n}}),O$=S("$ZodEnum",(t,e)=>{le.init(t,e);const n=Up(e.entries),r=new Set(n);t._zod.values=r,t._zod.pattern=new RegExp(`^(${n.filter(s=>GE.has(typeof s)).map(s=>typeof s=="string"?zr(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}}),z$=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"?zr(r):r?zr(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}}),L$=S("$ZodTransform",(t,e)=>{le.init(t,e),t._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Mp(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 wr;return n.value=s,n}});function ld(t,e){return t.issues.length&&e===void 0?{issues:[],value:void 0}:t}const ng=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(`^(${Pc(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)}}),M$=S("$ZodExactOptional",(t,e)=>{ng.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)}),N$=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(`^(${Pc(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)}),U$=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 F$=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))}),Z$=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 j$=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=>ln(o,r,an()))},input:n.value}),n.issues=[]),n)):(n.value=s.value,s.issues.length&&(n.value=e.catchValue({...n,error:{issues:s.issues.map(i=>ln(i,r,an()))},input:n.value}),n.issues=[]),n)}}),W$=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 B$=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 V$=S("$ZodCustom",(t,e)=>{Ve.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(Cs(s))}}var fd;class G${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 H$(){return new G$}(fd=globalThis).__zod_globalRegistry??(fd.__zod_globalRegistry=H$());const gs=globalThis.__zod_globalRegistry;function q$(t,e){return new t({type:"string",...D(e)})}function Y$(t,e){return new t({type:"string",format:"email",check:"string_format",abort:!1,...D(e)})}function pd(t,e){return new t({type:"string",format:"guid",check:"string_format",abort:!1,...D(e)})}function K$(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,...D(e)})}function J$(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...D(e)})}function X$(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...D(e)})}function Q$(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...D(e)})}function eA(t,e){return new t({type:"string",format:"url",check:"string_format",abort:!1,...D(e)})}function tA(t,e){return new t({type:"string",format:"emoji",check:"string_format",abort:!1,...D(e)})}function nA(t,e){return new t({type:"string",format:"nanoid",check:"string_format",abort:!1,...D(e)})}function rA(t,e){return new t({type:"string",format:"cuid",check:"string_format",abort:!1,...D(e)})}function sA(t,e){return new t({type:"string",format:"cuid2",check:"string_format",abort:!1,...D(e)})}function iA(t,e){return new t({type:"string",format:"ulid",check:"string_format",abort:!1,...D(e)})}function oA(t,e){return new t({type:"string",format:"xid",check:"string_format",abort:!1,...D(e)})}function aA(t,e){return new t({type:"string",format:"ksuid",check:"string_format",abort:!1,...D(e)})}function lA(t,e){return new t({type:"string",format:"ipv4",check:"string_format",abort:!1,...D(e)})}function cA(t,e){return new t({type:"string",format:"ipv6",check:"string_format",abort:!1,...D(e)})}function uA(t,e){return new t({type:"string",format:"cidrv4",check:"string_format",abort:!1,...D(e)})}function hA(t,e){return new t({type:"string",format:"cidrv6",check:"string_format",abort:!1,...D(e)})}function dA(t,e){return new t({type:"string",format:"base64",check:"string_format",abort:!1,...D(e)})}function fA(t,e){return new t({type:"string",format:"base64url",check:"string_format",abort:!1,...D(e)})}function pA(t,e){return new t({type:"string",format:"e164",check:"string_format",abort:!1,...D(e)})}function gA(t,e){return new t({type:"string",format:"jwt",check:"string_format",abort:!1,...D(e)})}function mA(t,e){return new t({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...D(e)})}function vA(t,e){return new t({type:"string",format:"date",check:"string_format",...D(e)})}function yA(t,e){return new t({type:"string",format:"time",check:"string_format",precision:null,...D(e)})}function bA(t,e){return new t({type:"string",format:"duration",check:"string_format",...D(e)})}function wA(t,e){return new t({type:"number",checks:[],...D(e)})}function _A(t,e){return new t({type:"number",check:"number_format",abort:!1,format:"safeint",...D(e)})}function SA(t,e){return new t({type:"boolean",...D(e)})}function kA(t){return new t({type:"unknown"})}function EA(t,e){return new t({type:"never",...D(e)})}function gd(t,e){return new Kp({check:"less_than",...D(e),value:t,inclusive:!1})}function Ba(t,e){return new Kp({check:"less_than",...D(e),value:t,inclusive:!0})}function md(t,e){return new Jp({check:"greater_than",...D(e),value:t,inclusive:!1})}function Va(t,e){return new Jp({check:"greater_than",...D(e),value:t,inclusive:!0})}function vd(t,e){return new U0({check:"multiple_of",...D(e),value:t})}function rg(t,e){return new Z0({check:"max_length",...D(e),maximum:t})}function yo(t,e){return new j0({check:"min_length",...D(e),minimum:t})}function sg(t,e){return new W0({check:"length_equals",...D(e),length:t})}function $A(t,e){return new B0({check:"string_format",format:"regex",...D(e),pattern:t})}function AA(t){return new V0({check:"string_format",format:"lowercase",...D(t)})}function xA(t){return new G0({check:"string_format",format:"uppercase",...D(t)})}function CA(t,e){return new H0({check:"string_format",format:"includes",...D(e),includes:t})}function TA(t,e){return new q0({check:"string_format",format:"starts_with",...D(e),prefix:t})}function IA(t,e){return new Y0({check:"string_format",format:"ends_with",...D(e),suffix:t})}function Hr(t){return new K0({check:"overwrite",tx:t})}function PA(t){return Hr(e=>e.normalize(t))}function RA(){return Hr(t=>t.trim())}function DA(){return Hr(t=>t.toLowerCase())}function OA(){return Hr(t=>t.toUpperCase())}function zA(){return Hr(t=>BE(t))}function LA(t,e,n){return new t({type:"array",element:e,...D(n)})}function MA(t,e,n){return new t({type:"custom",check:"custom",fn:e,...D(n)})}function NA(t){const e=UA(n=>(n.addIssue=r=>{if(typeof r=="string")n.issues.push(Cs(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(Cs(s))}},t(n.value,n)));return e}function UA(t,e){const n=new Ve({check:"custom",...D(e)});return n._zod.check=t,n}function ig(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,f;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=(f=(d=t._zod).toJSONSchema)==null?void 0:f.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"&&De(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 og(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 f=(o=t.metadataRegistry.get(d[0]))==null?void 0:o.id;if(f){const y=r.get(f);if(y&&y!==d[0])throw new Error(`Duplicate schema id "${f}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(f,d[0])}}const s=d=>{var k;const f=t.target==="draft-2020-12"?"$defs":"definitions";if(t.external){const I=(k=t.external.registry.get(d[0]))==null?void 0:k.id,V=t.external.uri??(j=>j);if(I)return{ref:V(I)};const N=d[1].defId??d[1].schema.id??`schema${t.counter++}`;return d[1].defId=N,{defId:N,ref:`${V("__shared")}#/${f}/${N}`}}if(d[1]===n)return{ref:"#"};const m=`#/${f}/`,E=d[1].schema.id??`__schema${t.counter++}`;return{defId:E,ref:m+E}},i=d=>{if(d[1].schema.$ref)return;const f=d[1],{ref:y,defId:m}=s(d);f.def={...f.schema},m&&(f.defId=m);const E=f.schema;for(const k in E)delete E[k];E.$ref=y};if(t.cycles==="throw")for(const d of t.seen.entries()){const f=d[1];if(f.cycle)throw new Error(`Cycle detected: #/${(a=f.cycle)==null?void 0:a.join("/")}/<root>
41
41
 
42
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const d of t.seen.entries()){const f=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(f.cycle){i(d);continue}if(f.count>1&&t.reused==="ref"){i(d);continue}}}function ag(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 f=d.def??d.schema,y={...f},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")?(f.allOf=f.allOf??[],f.allOf.push(I)):Object.assign(f,I),Object.assign(f,y),c._zod.parent===m)for(const N in f)N==="$ref"||N==="allOf"||N in y||delete f[N];if(I.$ref&&k.def)for(const N in f)N==="$ref"||N==="allOf"||N in k.def&&JSON.stringify(f[N])===JSON.stringify(k.def[N])&&delete f[N]}const E=c._zod.parent;if(E&&E!==m){r(E);const k=t.seen.get(E);if(k!=null&&k.schema.$ref&&(f.$ref=k.schema.$ref,k.def))for(const I in f)I==="$ref"||I==="allOf"||I in k.def&&JSON.stringify(f[I])===JSON.stringify(k.def[I])&&delete f[I]}t.override({zodSchema:c,jsonSchema:f,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:bo(e,"input",t.processors),output:bo(e,"output",t.processors)}},enumerable:!1,writable:!1}),c}catch{throw new Error("Error converting schema to JSON.")}}function De(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 De(r.element,n);if(r.type==="set")return De(r.valueType,n);if(r.type==="lazy")return De(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 De(r.innerType,n);if(r.type==="intersection")return De(r.left,n)||De(r.right,n);if(r.type==="record"||r.type==="map")return De(r.keyType,n)||De(r.valueType,n);if(r.type==="pipe")return De(r.in,n)||De(r.out,n);if(r.type==="object"){for(const s in r.shape)if(De(r.shape[s],n))return!0;return!1}if(r.type==="union"){for(const s of r.options)if(De(s,n))return!0;return!1}if(r.type==="tuple"){for(const s of r.items)if(De(s,n))return!0;return!!(r.rest&&De(r.rest,n))}return!1}const WA=(t,e={})=>n=>{const r=ig({...n,processors:e});return me(t,r),og(r,t),ag(r,t)},bo=(t,e,n={})=>r=>{const{libraryOptions:s,target:i}=r??{},o=ig({...s??{},target:i,io:e,processors:n});return me(t,o),og(o,t),ag(o,t)},BA={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},VA=(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=BA[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(f=>({...e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"?{type:"string"}:{},pattern:f.source}))])}},GA=(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)},HA=(t,e,n,r)=>{n.type="boolean"},qA=(t,e,n,r)=>{n.not={}},YA=(t,e,n,r)=>{},KA=(t,e,n,r)=>{const s=t._zod.def,i=Up(s.entries);i.every(o=>typeof o=="number")&&(n.type="number"),i.every(o=>typeof o=="string")&&(n.type="string"),n.enum=i},JA=(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},XA=(t,e,n,r)=>{if(e.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},QA=(t,e,n,r)=>{if(e.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},ex=(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"]})},tx=(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 f=i.shape[d]._zod;return e.io==="input"?f.optin===void 0:f.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)},nx=(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},rx=(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},sx=(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 f of l)s.patternProperties[f.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(f=>typeof f=="string"||typeof f=="number");d.length>0&&(s.required=d)}},ix=(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"}]},ox=(t,e,n,r)=>{const s=t._zod.def;me(s.innerType,e,r);const i=e.seen.get(t);i.ref=s.innerType},ax=(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))},lx=(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)))},cx=(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},ux=(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},hx=(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},lg=(t,e,n,r)=>{const s=t._zod.def;me(s.innerType,e,r);const i=e.seen.get(t);i.ref=s.innerType},dx=S("ZodISODateTime",(t,e)=>{f0.init(t,e),ue.init(t,e)});function fx(t){return bA(dx,t)}const px=S("ZodISODate",(t,e)=>{p0.init(t,e),ue.init(t,e)});function gx(t){return wA(px,t)}const mx=S("ZodISOTime",(t,e)=>{g0.init(t,e),ue.init(t,e)});function vx(t){return _A(mx,t)}const yx=S("ZodISODuration",(t,e)=>{m0.init(t,e),ue.init(t,e)});function bx(t){return SA(yx,t)}const cg=(t,e)=>{Wp.init(t,e),t.name="ZodError",Object.defineProperties(t,{format:{value:n=>o$(t,n)},flatten:{value:n=>i$(t,n)},addIssue:{value:n=>{t.issues.push(n),t.message=JSON.stringify(t.issues,vl,2)}},addIssues:{value:n=>{t.issues.push(...n),t.message=JSON.stringify(t.issues,vl,2)}},isEmpty:{get(){return t.issues.length===0}}})},md=S("ZodError",cg),nt=S("ZodError",cg,{Parent:Error}),wx=Ic(nt),_x=Pc(nt),Sx=Wo(nt),kx=Bo(nt),Ex=c$(nt),$x=u$(nt),Ax=h$(nt),xx=d$(nt),Tx=f$(nt),Cx=p$(nt),Ix=g$(nt),Px=m$(nt),ce=S("ZodType",(t,e)=>(le.init(t,e),Object.assign(t["~standard"],{jsonSchema:{input:bo(t,"input"),output:bo(t,"output")}}),t.toJSONSchema=WA(t,{}),t.def=e,t.type=e.type,Object.defineProperty(t,"_def",{value:e}),t.check=(...n)=>t.clone(fn(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)=>pn(t,n,r),t.brand=()=>t,t.register=(n,r)=>(n.add(t,r),t),t.parse=(n,r)=>wx(t,n,r,{callee:t.parse}),t.safeParse=(n,r)=>Sx(t,n,r),t.parseAsync=async(n,r)=>_x(t,n,r,{callee:t.parseAsync}),t.safeParseAsync=async(n,r)=>kx(t,n,r),t.spa=t.safeParseAsync,t.encode=(n,r)=>Ex(t,n,r),t.decode=(n,r)=>$x(t,n,r),t.encodeAsync=async(n,r)=>Ax(t,n,r),t.decodeAsync=async(n,r)=>xx(t,n,r),t.safeEncode=(n,r)=>Tx(t,n,r),t.safeDecode=(n,r)=>Cx(t,n,r),t.safeEncodeAsync=async(n,r)=>Ix(t,n,r),t.safeDecodeAsync=async(n,r)=>Px(t,n,r),t.refine=(n,r)=>t.check(ST(n,r)),t.superRefine=n=>t.check(kT(n)),t.overwrite=n=>t.check(Hr(n)),t.optional=()=>bd(t),t.exactOptional=()=>cT(t),t.nullable=()=>wd(t),t.nullish=()=>bd(wd(t)),t.nonoptional=n=>gT(t,n),t.array=()=>R(t),t.or=n=>Z([t,n]),t.and=n=>Go(t,n),t.transform=n=>_d(t,aT(n)),t.default=n=>dT(t,n),t.prefault=n=>pT(t,n),t.catch=n=>vT(t,n),t.pipe=n=>_d(t,n),t.readonly=()=>wT(t),t.describe=n=>{const r=t.clone();return ps.add(r,{description:n}),r},Object.defineProperty(t,"description",{get(){var n;return(n=ps.get(t))==null?void 0:n.description},configurable:!0}),t.meta=(...n)=>{if(n.length===0)return ps.get(t);const r=t.clone();return ps.add(r,n[0]),r},t.isOptional=()=>t.safeParse(void 0).success,t.isNullable=()=>t.safeParse(null).success,t.apply=n=>n(t),t)),ug=S("_ZodString",(t,e)=>{Rc.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(r,s,i)=>VA(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(TA(...r)),t.includes=(...r)=>t.check(PA(...r)),t.startsWith=(...r)=>t.check(RA(...r)),t.endsWith=(...r)=>t.check(DA(...r)),t.min=(...r)=>t.check(yo(...r)),t.max=(...r)=>t.check(rg(...r)),t.length=(...r)=>t.check(sg(...r)),t.nonempty=(...r)=>t.check(yo(1,...r)),t.lowercase=r=>t.check(CA(r)),t.uppercase=r=>t.check(IA(r)),t.trim=()=>t.check(zA()),t.normalize=(...r)=>t.check(OA(...r)),t.toLowerCase=()=>t.check(LA()),t.toUpperCase=()=>t.check(MA()),t.slugify=()=>t.check(NA())}),Rx=S("ZodString",(t,e)=>{Rc.init(t,e),ug.init(t,e),t.email=n=>t.check(X0(Dx,n)),t.url=n=>t.check(rA(Ox,n)),t.jwt=n=>t.check(yA(Yx,n)),t.emoji=n=>t.check(sA(zx,n)),t.guid=n=>t.check(dd(vd,n)),t.uuid=n=>t.check(Q0(Ui,n)),t.uuidv4=n=>t.check(eA(Ui,n)),t.uuidv6=n=>t.check(tA(Ui,n)),t.uuidv7=n=>t.check(nA(Ui,n)),t.nanoid=n=>t.check(iA(Lx,n)),t.guid=n=>t.check(dd(vd,n)),t.cuid=n=>t.check(oA(Mx,n)),t.cuid2=n=>t.check(aA(Nx,n)),t.ulid=n=>t.check(lA(Ux,n)),t.base64=n=>t.check(gA(Gx,n)),t.base64url=n=>t.check(mA(Hx,n)),t.xid=n=>t.check(cA(Fx,n)),t.ksuid=n=>t.check(uA(Zx,n)),t.ipv4=n=>t.check(hA(jx,n)),t.ipv6=n=>t.check(dA(Wx,n)),t.cidrv4=n=>t.check(fA(Bx,n)),t.cidrv6=n=>t.check(pA(Vx,n)),t.e164=n=>t.check(vA(qx,n)),t.datetime=n=>t.check(fx(n)),t.date=n=>t.check(gx(n)),t.time=n=>t.check(vx(n)),t.duration=n=>t.check(bx(n))});function u(t){return J0(Rx,t)}const ue=S("ZodStringFormat",(t,e)=>{oe.init(t,e),ug.init(t,e)}),Dx=S("ZodEmail",(t,e)=>{s0.init(t,e),ue.init(t,e)}),vd=S("ZodGUID",(t,e)=>{n0.init(t,e),ue.init(t,e)}),Ui=S("ZodUUID",(t,e)=>{r0.init(t,e),ue.init(t,e)}),Ox=S("ZodURL",(t,e)=>{i0.init(t,e),ue.init(t,e)}),zx=S("ZodEmoji",(t,e)=>{o0.init(t,e),ue.init(t,e)}),Lx=S("ZodNanoID",(t,e)=>{a0.init(t,e),ue.init(t,e)}),Mx=S("ZodCUID",(t,e)=>{l0.init(t,e),ue.init(t,e)}),Nx=S("ZodCUID2",(t,e)=>{c0.init(t,e),ue.init(t,e)}),Ux=S("ZodULID",(t,e)=>{u0.init(t,e),ue.init(t,e)}),Fx=S("ZodXID",(t,e)=>{h0.init(t,e),ue.init(t,e)}),Zx=S("ZodKSUID",(t,e)=>{d0.init(t,e),ue.init(t,e)}),jx=S("ZodIPv4",(t,e)=>{v0.init(t,e),ue.init(t,e)}),Wx=S("ZodIPv6",(t,e)=>{y0.init(t,e),ue.init(t,e)}),Bx=S("ZodCIDRv4",(t,e)=>{b0.init(t,e),ue.init(t,e)}),Vx=S("ZodCIDRv6",(t,e)=>{w0.init(t,e),ue.init(t,e)}),Gx=S("ZodBase64",(t,e)=>{_0.init(t,e),ue.init(t,e)}),Hx=S("ZodBase64URL",(t,e)=>{k0.init(t,e),ue.init(t,e)}),qx=S("ZodE164",(t,e)=>{E0.init(t,e),ue.init(t,e)}),Yx=S("ZodJWT",(t,e)=>{A0.init(t,e),ue.init(t,e)}),hg=S("ZodNumber",(t,e)=>{Qp.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(r,s,i)=>GA(t,r,s),t.gt=(r,s)=>t.check(pd(r,s)),t.gte=(r,s)=>t.check(ja(r,s)),t.min=(r,s)=>t.check(ja(r,s)),t.lt=(r,s)=>t.check(fd(r,s)),t.lte=(r,s)=>t.check(Za(r,s)),t.max=(r,s)=>t.check(Za(r,s)),t.int=r=>t.check(yd(r)),t.safe=r=>t.check(yd(r)),t.positive=r=>t.check(pd(0,r)),t.nonnegative=r=>t.check(ja(0,r)),t.negative=r=>t.check(fd(0,r)),t.nonpositive=r=>t.check(Za(0,r)),t.multipleOf=(r,s)=>t.check(gd(r,s)),t.step=(r,s)=>t.check(gd(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 kA(hg,t)}const Kx=S("ZodNumberFormat",(t,e)=>{x0.init(t,e),hg.init(t,e)});function yd(t){return EA(Kx,t)}const Jx=S("ZodBoolean",(t,e)=>{T0.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>HA(t,n,r)});function ke(t){return $A(Jx,t)}const Xx=S("ZodUnknown",(t,e)=>{C0.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>YA()});function w(){return AA(Xx)}const Qx=S("ZodNever",(t,e)=>{I0.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>qA(t,n,r)});function eT(t){return xA(Qx,t)}const tT=S("ZodArray",(t,e)=>{P0.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>ex(t,n,r,s),t.element=e.element,t.min=(n,r)=>t.check(yo(n,r)),t.nonempty=n=>t.check(yo(1,n)),t.max=(n,r)=>t.check(rg(n,r)),t.length=(n,r)=>t.check(sg(n,r)),t.unwrap=()=>t.element});function R(t,e){return UA(tT,t,e)}const dg=S("ZodObject",(t,e)=>{D0.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>tx(t,n,r,s),ee(t,"shape",()=>e.shape),t.keyof=()=>wo(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:eT()}),t.strip=()=>t.clone({...t._zod.def,catchall:void 0}),t.extend=n=>e$(t,n),t.safeExtend=n=>t$(t,n),t.merge=n=>n$(t,n),t.pick=n=>XE(t,n),t.omit=n=>QE(t,n),t.partial=(...n)=>r$(pg,t,n[0]),t.required=(...n)=>s$(gg,t,n[0])});function fg(t,e){const n={type:"object",shape:t??{},...D(e)};return new dg(n)}function p(t,e){return new dg({type:"object",shape:t,catchall:w(),...D(e)})}const nT=S("ZodUnion",(t,e)=>{O0.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>nx(t,n,r,s),t.options=e.options});function Z(t,e){return new nT({type:"union",options:t,...D(e)})}const rT=S("ZodIntersection",(t,e)=>{z0.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>rx(t,n,r,s)});function Go(t,e){return new rT({type:"intersection",left:t,right:e})}const sT=S("ZodRecord",(t,e)=>{L0.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>sx(t,n,r,s),t.keyType=e.keyType,t.valueType=e.valueType});function _(t,e,n){return new sT({type:"record",keyType:t,valueType:e,...D(n)})}const bl=S("ZodEnum",(t,e)=>{M0.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(r,s,i)=>KA(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 bl({...e,checks:[],...D(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 bl({...e,checks:[],...D(s),entries:i})}});function wo(t,e){const n=Array.isArray(t)?Object.fromEntries(t.map(r=>[r,r])):t;return new bl({type:"enum",entries:n,...D(e)})}const iT=S("ZodLiteral",(t,e)=>{N0.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>JA(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 iT({type:"literal",values:Array.isArray(t)?t:[t],...D(e)})}const oT=S("ZodTransform",(t,e)=>{U0.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>QA(t,n),t._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Mp(t.constructor.name);n.addIssue=i=>{if(typeof i=="string")n.issues.push(xs(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(xs(o))}};const s=e.transform(n.value,n);return s instanceof Promise?s.then(i=>(n.value=i,n)):(n.value=s,n)}});function aT(t){return new oT({type:"transform",transform:t})}const pg=S("ZodOptional",(t,e)=>{ng.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>lg(t,n,r,s),t.unwrap=()=>t._zod.def.innerType});function bd(t){return new pg({type:"optional",innerType:t})}const lT=S("ZodExactOptional",(t,e)=>{F0.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>lg(t,n,r,s),t.unwrap=()=>t._zod.def.innerType});function cT(t){return new lT({type:"optional",innerType:t})}const uT=S("ZodNullable",(t,e)=>{Z0.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>ix(t,n,r,s),t.unwrap=()=>t._zod.def.innerType});function wd(t){return new uT({type:"nullable",innerType:t})}const hT=S("ZodDefault",(t,e)=>{j0.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>ax(t,n,r,s),t.unwrap=()=>t._zod.def.innerType,t.removeDefault=t.unwrap});function dT(t,e){return new hT({type:"default",innerType:t,get defaultValue(){return typeof e=="function"?e():Zp(e)}})}const fT=S("ZodPrefault",(t,e)=>{W0.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>lx(t,n,r,s),t.unwrap=()=>t._zod.def.innerType});function pT(t,e){return new fT({type:"prefault",innerType:t,get defaultValue(){return typeof e=="function"?e():Zp(e)}})}const gg=S("ZodNonOptional",(t,e)=>{B0.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>ox(t,n,r,s),t.unwrap=()=>t._zod.def.innerType});function gT(t,e){return new gg({type:"nonoptional",innerType:t,...D(e)})}const mT=S("ZodCatch",(t,e)=>{V0.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>cx(t,n,r,s),t.unwrap=()=>t._zod.def.innerType,t.removeCatch=t.unwrap});function vT(t,e){return new mT({type:"catch",innerType:t,catchValue:typeof e=="function"?e:()=>e})}const yT=S("ZodPipe",(t,e)=>{G0.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>ux(t,n,r,s),t.in=e.in,t.out=e.out});function _d(t,e){return new yT({type:"pipe",in:t,out:e})}const bT=S("ZodReadonly",(t,e)=>{H0.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>hx(t,n,r,s),t.unwrap=()=>t._zod.def.innerType});function wT(t){return new bT({type:"readonly",innerType:t})}const _T=S("ZodCustom",(t,e)=>{q0.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>XA(t,n)});function ST(t,e={}){return FA(_T,t,e)}function kT(t){return ZA(t)}const ET=["text/markdown","text/html"],$T=["committed","pending"];fg({id:u().min(1),type:wo(ET),title:u(),status:wo($T),externalFilePath:u().optional()});fg({name:u().min(1),description:u(),accepts:R(u().min(1)).min(1)});function Dc(t){return typeof t=="object"&&t!==null}function AT(t){return!Dc(t)||t.type!=="ready"?!1:!("id"in t)}function xT(t){return!(!Dc(t)||t.type!=="update-content"||typeof t.id!="string"||typeof t.content!="string")}function TT(t){return!Dc(t)||t.type!=="wheel"||typeof t.deltaX!="number"||typeof t.deltaY!="number"||typeof t.shiftKey!="boolean"?!1:!("id"in t)}function CT(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 IT(t,e){let n=null;for(const r of t.accepts){const s=CT(r,e);s!==null&&(n===null||s>n)&&(n=s)}return n}function PT(t,e){let n=-1,r=null;for(const s of e){const i=IT(s,t);i!==null&&(i>n||i===n&&r!==null&&s.id<r.id)&&(n=i,r=s)}return r}const RT=4401;class wl extends Error{constructor(e="Authentication required"){super(e),this.name="AuthError"}}class _l 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 LE(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(DT(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=f=>{a||this.connectAttempt!==n||(a=!0,this.status="disconnected",this.dispatchEvent(new te("change")),o(f))},d=async()=>{try{const[{screens:f},y]=await Promise.all([this.client.screens.list(),this.client.views.list()]);this.screens=new Map(f.map(m=>[m.id,structuredClone(m)])),this.views=y,this.dispatchEvent(new te("change")),l()}catch(f){c(f instanceof Error?f:new Error(String(f)))}};r.addEventListener("open",()=>{d()}),r.addEventListener("message",f=>{const y=zT(f);y&&(this.applyServerEvent(y),this.dispatchEvent(new Ap("server-event",{serverURL:this.url,event:y})))}),r.addEventListener("close",f=>{if(this.connectAttempt===n){if(this.socket=null,OT(f)===RT){c(new wl);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=PT(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 to("screens-changed"));break;case"screen-updated":this.screens.set(n.screen.id,structuredClone(n.screen)),this.dispatchEvent(new to("screens-changed"));break;case"screen-removed":this.screens.delete(n.screenID),this.dispatchEvent(new to("screens-changed"));break;case"artifact-created":{const r=this.screens.get(n.screenID);r&&!kp(r.layout,n.artifact.id)&&(r.layout=[...r.layout,Sp(n.artifact.id)]);break}case"artifact-removed":{const r=this.screens.get(n.screenID);r&&(r.layout=fp(r.layout,n.artifactID));break}}}}function DT(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 OT(t){return typeof t=="object"&&t!==null&&"code"in t&&typeof t.code=="number"?t.code:null}function zT(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 LT 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 Ap("server-event",{serverURL:l.serverURL,event:l.event}))},a=()=>{this.dispatchEvent(new to("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 _l({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 _l({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"},MT=1,NT=p({_meta:_(u(),w()).nullish(),terminal:ke().optional().default(!1)}),UT=p({_meta:_(u(),w()).nullish(),label:u().nullish(),name:u(),optional:ke().optional().default(!1),secret:ke().optional().default(!0)}),FT=p({_meta:_(u(),w()).nullish(),description:u().nullish(),id:u(),name:u()}),ZT=p({_meta:_(u(),w()).nullish(),description:u().nullish(),id:u(),link:u().nullish(),name:u(),vars:R(UT)}),jT=p({_meta:_(u(),w()).nullish(),args:R(u()).optional(),description:u().nullish(),env:_(u(),u()).optional(),id:u(),name:u()}),WT=Z([ZT.and(p({type:A("env_var")})),jT.and(p({type:A("terminal")})),FT]),BT=p({_meta:_(u(),w()).nullish(),methodId:u()}),VT=p({_meta:_(u(),w()).nullish()}),GT=p({_meta:_(u(),w()).nullish(),blob:u(),mimeType:u().nullish(),uri:u()}),HT=p({default:ke().nullish(),description:u().nullish(),title:u().nullish()}),qT=p({_meta:_(u(),w()).nullish()}),YT=p({_meta:_(u(),w()).nullish()}),KT=p({amount:U(),currency:u()}),JT=p({_meta:_(u(),w()).nullish(),terminalId:u()}),XT=p({_meta:_(u(),w()).nullish(),newText:u(),oldText:u().nullish(),path:u()}),QT=Z([u(),U(),U(),ke(),R(u())]),eC=p({content:_(u(),QT).nullish()}),tC=Z([eC.and(p({action:A("accept")})),p({action:A("decline")}),p({action:A("cancel")})]),nC=p({_meta:_(u(),w()).nullish()}),mg=u(),rC=p({_meta:_(u(),w()).nullish(),elicitationId:mg}),sC=p({_meta:_(u(),w()).nullish(),action:tC}),iC=A("object"),oC=A("string"),aC=p({_meta:_(u(),w()).nullish()}),lC=p({_meta:_(u(),w()).nullish(),form:nC.nullish(),url:aC.nullish()}),cC=p({elicitationId:mg,url:u().url()}),vg=p({const:u(),title:u()}),yg=p({_meta:_(u(),w()).nullish(),name:u(),value:u()}),uC=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"})]),bg=p({code:uC,data:w().optional(),message:u()}),wg=w(),_g=w(),Sg=w(),hC=p({_meta:_(u(),w()).nullish(),readTextFile:ke().optional().default(!1),writeTextFile:ke().optional().default(!1)}),kg=p({_meta:_(u(),w()).nullish(),name:u(),value:u()}),Eg=p({_meta:_(u(),w()).nullish(),name:u(),title:u().nullish(),version:u()}),dC=p({default:U().nullish(),description:u().nullish(),maximum:U().nullish(),minimum:U().nullish(),title:u().nullish()}),fC=p({_meta:_(u(),w()).nullish()}),pC=p({_meta:_(u(),w()).nullish(),additionalDirectories:R(u()).optional(),cursor:u().nullish(),cwd:u().nullish()}),gC=p({_meta:_(u(),w()).nullish()}),mC=p({_meta:_(u(),w()).nullish(),logout:gC.nullish()}),vC=p({_meta:_(u(),w()).nullish()}),yC=p({_meta:_(u(),w()).nullish()}),bC=p({_meta:_(u(),w()).nullish(),http:ke().optional().default(!1),sse:ke().optional().default(!1)}),wC=p({_meta:_(u(),w()).nullish(),headers:R(kg),name:u(),url:u()}),_C=p({_meta:_(u(),w()).nullish(),headers:R(kg),name:u(),url:u()}),SC=p({_meta:_(u(),w()).nullish(),args:R(u()),command:u(),env:R(yg),name:u()}),Ho=Z([wC.and(p({type:A("http")})),_C.and(p({type:A("sse")})),SC]),Oc=u(),kC=p({_meta:_(u(),w()).nullish(),description:u().nullish(),modelId:Oc,name:u()}),EC=Z([A("error"),A("warning"),A("information"),A("hint")]),$C=p({_meta:_(u(),w()).nullish()}),AC=p({_meta:_(u(),w()).nullish()}),xC=p({_meta:_(u(),w()).nullish()}),TC=p({_meta:_(u(),w()).nullish()}),CC=p({_meta:_(u(),w()).nullish()}),IC=p({_meta:_(u(),w()).nullish(),maxCount:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),PC=p({diff:u(),uri:u()}),RC=p({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:u()}),DC=p({_meta:_(u(),w()).nullish()}),OC=p({_meta:_(u(),w()).nullish()}),zC=p({languageId:u(),text:u(),uri:u()}),LC=p({_meta:_(u(),w()).nullish(),maxCount:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),MC=Z([A("rejected"),A("ignored"),A("replaced"),A("cancelled")]),NC=p({excerpts:R(RC),uri:u()}),UC=p({_meta:_(u(),w()).nullish()}),FC=p({_meta:_(u(),w()).nullish()}),ZC=p({name:u(),owner:u(),remoteUrl:u()}),jC=p({_meta:_(u(),w()).nullish()}),WC=p({_meta:_(u(),w()).nullish(),jump:DC.nullish(),rename:FC.nullish(),searchAndReplace:jC.nullish()}),BC=p({id:u(),isRegex:ke().nullish(),replace:u(),search:u(),uri:u()}),VC=Z([A("automatic"),A("diagnostic"),A("manual")]),GC=p({_meta:_(u(),w()).nullish(),maxCount:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),HC=p({_meta:_(u(),w()).nullish(),diagnostics:$C.nullish(),editHistory:IC.nullish(),openFiles:OC.nullish(),recentFiles:LC.nullish(),relatedSnippets:UC.nullish(),userActions:GC.nullish()}),qC=p({_meta:_(u(),w()).nullish(),additionalDirectories:R(u()).optional(),cwd:u(),mcpServers:R(Ho)}),YC=p({default:U().nullish(),description:u().nullish(),maximum:U().nullish(),minimum:U().nullish(),title:u().nullish()}),$g=u(),KC=Z([A("allow_once"),A("allow_always"),A("reject_once"),A("reject_always")]),JC=p({_meta:_(u(),w()).nullish(),kind:KC,name:u(),optionId:$g}),XC=Z([A("high"),A("medium"),A("low")]),QC=Z([A("pending"),A("in_progress"),A("completed")]),eI=p({_meta:_(u(),w()).nullish(),content:u(),priority:XC,status:QC}),tI=p({_meta:_(u(),w()).nullish(),entries:R(eI)}),cn=p({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"})}),nI=p({id:u(),position:cn,uri:u()}),rI=p({id:u(),newName:u(),position:cn,uri:u()}),sI=p({action:u(),position:cn,timestampMs:U(),uri:u()}),Ag=Z([A("utf-16"),A("utf-32"),A("utf-8")]),iI=p({_meta:_(u(),w()).nullish(),auth:NT.optional().default({terminal:!1}),elicitation:lC.nullish(),fs:hC.optional().default({readTextFile:!1,writeTextFile:!1}),nes:WC.nullish(),positionEncodings:R(Ag).optional(),terminal:ke().optional().default(!1)}),oI=p({_meta:_(u(),w()).nullish(),audio:ke().optional().default(!1),embeddedContext:ke().optional().default(!1),image:ke().optional().default(!1)}),xg=U().int().gte(0).lte(65535),aI=p({_meta:_(u(),w()).nullish(),clientCapabilities:iI.optional().default({auth:{terminal:!1},fs:{readTextFile:!1,writeTextFile:!1},terminal:!1}),clientInfo:Eg.nullish(),protocolVersion:xg}),qr=p({end:cn,start:cn}),lI=p({message:u(),range:qr,severity:EC,uri:u()}),cI=p({languageId:u(),lastFocusedMs:U().nullish(),uri:u(),visibleRange:qr.nullish()}),uI=p({_meta:_(u(),w()).nullish(),diagnostics:R(lI).nullish(),editHistory:R(PC).nullish(),openFiles:R(cI).nullish(),recentFiles:R(zC).nullish(),relatedSnippets:R(NC).nullish(),userActions:R(sI).nullish()}),hI=p({newText:u(),range:qr}),dI=p({cursorPosition:cn.nullish(),edits:R(hI),id:u(),uri:u()}),fI=Z([dI.and(p({kind:A("edit")})),nI.and(p({kind:A("jump")})),rI.and(p({kind:A("rename")})),BC.and(p({kind:A("searchAndReplace")}))]),pI=p({_meta:_(u(),w()).nullish(),content:u()}),gI=p({_meta:_(u(),w()).nullish()}),jn=Z([U(),u()]).nullable();p({_meta:_(u(),w()).nullish(),requestId:jn});const mI=wo(["assistant","user"]),mi=p({_meta:_(u(),w()).nullish(),audience:R(mI).nullish(),lastModified:u().nullish(),priority:U().nullish()}),vI=p({_meta:_(u(),w()).nullish(),annotations:mi.nullish(),data:u(),mimeType:u()}),yI=p({_meta:_(u(),w()).nullish(),annotations:mi.nullish(),data:u(),mimeType:u(),uri:u().nullish()}),bI=p({_meta:_(u(),w()).nullish(),annotations:mi.nullish(),description:u().nullish(),mimeType:u().nullish(),name:u(),size:U().nullish(),title:u().nullish(),uri:u()}),wI=p({_meta:_(u(),w()).nullish(),optionId:$g}),_I=Z([p({outcome:A("cancelled")}),wI.and(p({outcome:A("selected")}))]),SI=p({_meta:_(u(),w()).nullish(),outcome:_I}),kI=p({_meta:_(u(),w()).nullish()}),EI=p({_meta:_(u(),w()).nullish()}),$I=p({currentValue:ke()}),AI=u(),Tg=u(),xI=Z([A("mode"),A("model"),A("thought_level"),u()]),zc=u(),Cg=p({_meta:_(u(),w()).nullish(),description:u().nullish(),name:u(),value:zc}),TI=p({_meta:_(u(),w()).nullish(),group:AI,name:u(),options:R(Cg)}),CI=Z([R(Cg),R(TI)]),II=p({currentValue:zc,options:CI}),Yr=Go(Z([II.and(p({type:A("select")})),$I.and(p({type:A("boolean")}))]),p({_meta:_(u(),w()).nullish(),category:xI.nullish(),description:u().nullish(),id:Tg,name:u()})),PI=p({_meta:_(u(),w()).nullish(),configOptions:R(Yr)}),RI=p({_meta:_(u(),w()).nullish()}),K=u(),DI=p({_meta:_(u(),w()).nullish(),id:u(),sessionId:K}),OI=p({_meta:_(u(),w()).nullish(),sessionId:K}),zI=p({_meta:_(u(),w()).nullish(),sessionId:K}),LI=p({_meta:_(u(),w()).nullish(),sessionId:K}),Ig=p({_meta:_(u(),w()).nullish(),args:R(u()).optional(),command:u(),cwd:u().nullish(),env:R(yg).optional(),outputByteLimit:U().nullish(),sessionId:K}),MI=p({_meta:_(u(),w()).nullish(),sessionId:K,uri:u()}),NI=p({_meta:_(u(),w()).nullish(),position:cn,sessionId:K,uri:u(),version:U(),visibleRange:qr}),UI=p({_meta:_(u(),w()).nullish(),languageId:u(),sessionId:K,text:u(),uri:u(),version:U()}),FI=p({_meta:_(u(),w()).nullish(),sessionId:K,uri:u()}),ZI=p({_meta:_(u(),w()).nullish(),additionalDirectories:R(u()).optional(),cwd:u(),mcpServers:R(Ho).optional(),sessionId:K}),Pg=p({_meta:_(u(),w()).nullish(),sessionId:K,terminalId:u()}),jI=p({_meta:_(u(),w()).nullish(),additionalDirectories:R(u()).optional(),cwd:u(),mcpServers:R(Ho),sessionId:K}),Rg=p({_meta:_(u(),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:u(),sessionId:K}),WI=p({_meta:_(u(),w()).nullish(),id:u(),reason:MC.nullish(),sessionId:K}),Dg=p({_meta:_(u(),w()).nullish(),sessionId:K,terminalId:u()}),BI=p({_meta:_(u(),w()).nullish(),additionalDirectories:R(u()).optional(),cwd:u(),mcpServers:R(Ho).optional(),sessionId:K}),VI=p({_meta:_(u(),w()).nullish(),additionalDirectories:R(u()).optional(),cwd:u(),sessionId:K,title:u().nullish(),updatedAt:u().nullish()}),GI=p({_meta:_(u(),w()).nullish(),nextCursor:u().nullish(),sessions:R(VI)}),HI=p({_meta:_(u(),w()).nullish(),title:u().nullish(),updatedAt:u().nullish()}),qI=p({_meta:_(u(),w()).nullish()}),qo=u(),YI=p({_meta:_(u(),w()).nullish(),currentModeId:qo}),KI=p({_meta:_(u(),w()).nullish(),description:u().nullish(),id:qo,name:u()}),Yo=p({_meta:_(u(),w()).nullish(),availableModes:R(KI),currentModeId:qo}),Ko=p({_meta:_(u(),w()).nullish(),availableModels:R(kC),currentModelId:Oc}),JI=p({_meta:_(u(),w()).nullish(),configOptions:R(Yr).nullish(),models:Ko.nullish(),modes:Yo.nullish(),sessionId:K}),XI=p({_meta:_(u(),w()).nullish(),configOptions:R(Yr).nullish(),models:Ko.nullish(),modes:Yo.nullish()}),QI=p({_meta:_(u(),w()).nullish(),configOptions:R(Yr).nullish(),models:Ko.nullish(),modes:Yo.nullish(),sessionId:K}),eP=p({_meta:_(u(),w()).nullish(),configOptions:R(Yr).nullish(),models:Ko.nullish(),modes:Yo.nullish()}),tP=p({_meta:_(u(),w()).nullish()}),nP=p({_meta:_(u(),w()).nullish(),additionalDirectories:kI.nullish(),close:EI.nullish(),fork:RI.nullish(),list:qI.nullish(),resume:tP.nullish()}),rP=Go(Z([p({type:A("boolean"),value:ke()}),p({value:zc})]),p({_meta:_(u(),w()).nullish(),configId:Tg,sessionId:K})),sP=p({_meta:_(u(),w()).nullish(),configOptions:R(Yr)}),iP=p({_meta:_(u(),w()).nullish(),modeId:qo,sessionId:K}),oP=p({_meta:_(u(),w()).nullish()}),aP=p({_meta:_(u(),w()).nullish(),modelId:Oc,sessionId:K}),lP=p({_meta:_(u(),w()).nullish()}),cP=p({_meta:_(u(),w()).nullish(),sessionId:K}),uP=Z([A("end_turn"),A("max_tokens"),A("max_turn_requests"),A("refusal"),A("cancelled")]),hP=Z([A("email"),A("uri"),A("date"),A("date-time")]),dP=p({default:u().nullish(),description:u().nullish(),enum:R(u()).nullish(),format:hP.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(vg).nullish(),pattern:u().nullish(),title:u().nullish()}),fP=p({_meta:_(u(),w()).nullish(),context:uI.nullish(),position:cn,selection:qr.nullish(),sessionId:K,triggerKind:VC,uri:u(),version:U()}),pP=p({_meta:_(u(),w()).nullish(),suggestions:R(fI)}),gP=p({_meta:_(u(),w()).nullish(),terminalId:u()}),mP=p({_meta:_(u(),w()).nullish(),exitCode:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:u().nullish()}),Og=p({_meta:_(u(),w()).nullish(),sessionId:K,terminalId:u()}),vP=p({_meta:_(u(),w()).nullish(),exitStatus:mP.nullish(),output:u(),truncated:ke()}),yP=p({_meta:_(u(),w()).nullish(),annotations:mi.nullish(),text:u()}),bP=p({range:qr.nullish(),text:u()}),wP=p({_meta:_(u(),w()).nullish(),contentChanges:R(bP),sessionId:K,uri:u(),version:U()});p({method:u(),params:Z([OI,UI,wP,MI,FI,NI,DI,WI,wg]).nullish()});const _P=Z([A("full"),A("incremental")]),SP=p({_meta:_(u(),w()).nullish(),syncKind:_P}),kP=p({_meta:_(u(),w()).nullish(),didChange:SP.nullish(),didClose:AC.nullish(),didFocus:xC.nullish(),didOpen:TC.nullish(),didSave:CC.nullish()}),EP=p({_meta:_(u(),w()).nullish(),document:kP.nullish()}),$P=p({_meta:_(u(),w()).nullish(),context:HC.nullish(),events:EP.nullish()}),AP=p({_meta:_(u(),w()).nullish(),auth:mC.optional().default({}),loadSession:ke().optional().default(!1),mcpCapabilities:bC.optional().default({http:!1,sse:!1}),nes:$P.nullish(),positionEncoding:Ag.nullish(),promptCapabilities:oI.optional().default({audio:!1,embeddedContext:!1,image:!1}),sessionCapabilities:nP.optional().default({})}),xP=p({_meta:_(u(),w()).nullish(),agentCapabilities:AP.optional().default({auth:{},loadSession:!1,mcpCapabilities:{http:!1,sse:!1},promptCapabilities:{audio:!1,embeddedContext:!1,image:!1},sessionCapabilities:{}}),agentInfo:Eg.nullish(),authMethods:R(WT).optional().default([]),protocolVersion:xg}),TP=p({_meta:_(u(),w()).nullish(),mimeType:u().nullish(),text:u(),uri:u()}),CP=Z([TP,GT]),IP=p({_meta:_(u(),w()).nullish(),annotations:mi.nullish(),resource:CP}),Lc=Z([yP.and(p({type:A("text")})),yI.and(p({type:A("image")})),vI.and(p({type:A("audio")})),bI.and(p({type:A("resource_link")})),IP.and(p({type:A("resource")}))]),PP=p({_meta:_(u(),w()).nullish(),content:Lc}),Wa=p({_meta:_(u(),w()).nullish(),content:Lc,messageId:u().nullish()}),RP=p({_meta:_(u(),w()).nullish(),messageId:u().nullish(),prompt:R(Lc),sessionId:K}),DP=p({anyOf:R(vg)}),zg=Z([PP.and(p({type:A("content")})),XT.and(p({type:A("diff")})),gP.and(p({type:A("terminal")}))]),Lg=u(),Mg=p({_meta:_(u(),w()).nullish(),line:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:u()}),Ng=Z([A("pending"),A("in_progress"),A("completed"),A("failed")]),Ug=Z([A("read"),A("edit"),A("delete"),A("move"),A("search"),A("execute"),A("think"),A("fetch"),A("switch_mode"),A("other")]),OP=p({_meta:_(u(),w()).nullish(),content:R(zg).optional(),kind:Ug.optional(),locations:R(Mg).optional(),rawInput:w().optional(),rawOutput:w().optional(),status:Ng.optional(),title:u(),toolCallId:Lg}),Fg=p({_meta:_(u(),w()).nullish(),content:R(zg).nullish(),kind:Ug.nullish(),locations:R(Mg).nullish(),rawInput:w().optional(),rawOutput:w().optional(),status:Ng.nullish(),title:u().nullish(),toolCallId:Lg}),Zg=p({_meta:_(u(),w()).nullish(),options:R(JC),sessionId:K,toolCall:Fg}),zP=p({_meta:_(u(),w()).nullish(),hint:u()}),LP=zP,MP=p({_meta:_(u(),w()).nullish(),description:u(),input:LP.nullish(),name:u()}),NP=p({_meta:_(u(),w()).nullish(),availableCommands:R(MP)}),UP=p({enum:R(u()),type:oC}),FP=Z([UP,DP]),ZP=p({default:R(u()).nullish(),description:u().nullish(),items:FP,maxItems:U().nullish(),minItems:U().nullish(),title:u().nullish()}),jP=Z([dP.and(p({type:A("string")})),YC.and(p({type:A("number")})),dC.and(p({type:A("integer")})),HT.and(p({type:A("boolean")})),ZP.and(p({type:A("array")}))]),WP=p({description:u().nullish(),properties:_(u(),jP).optional().default({}),required:R(u()).nullish(),title:u().nullish(),type:iC.optional().default("object")}),BP=p({requestedSchema:WP}),VP=Go(Z([BP.and(p({mode:A("form")})),cC.and(p({mode:A("url")}))]),p({_meta:_(u(),w()).nullish(),message:u(),sessionId:K})),GP=p({cachedReadTokens:U().nullish(),cachedWriteTokens:U().nullish(),inputTokens:U(),outputTokens:U(),thoughtTokens:U().nullish(),totalTokens:U()}),HP=p({_meta:_(u(),w()).nullish(),stopReason:uP,usage:GP.nullish(),userMessageId:u().nullish()});Z([p({id:jn,result:Z([xP,VT,yC,QI,XI,GI,JI,eP,YT,oP,sP,HP,lP,cP,pP,qT,Sg])}),p({error:bg,id:jn})]);const qP=p({_meta:_(u(),w()).nullish(),cost:KT.nullish(),size:U(),used:U()}),YP=Z([Wa.and(p({sessionUpdate:A("user_message_chunk")})),Wa.and(p({sessionUpdate:A("agent_message_chunk")})),Wa.and(p({sessionUpdate:A("agent_thought_chunk")})),OP.and(p({sessionUpdate:A("tool_call")})),Fg.and(p({sessionUpdate:A("tool_call_update")})),tI.and(p({sessionUpdate:A("plan")})),NP.and(p({sessionUpdate:A("available_commands_update")})),YI.and(p({sessionUpdate:A("current_mode_update")})),PI.and(p({sessionUpdate:A("config_option_update")})),HI.and(p({sessionUpdate:A("session_info_update")})),qP.and(p({sessionUpdate:A("usage_update")}))]),jg=p({_meta:_(u(),w()).nullish(),sessionId:K,update:YP});p({method:u(),params:Z([jg,rC,wg]).nullish()});const Wg=p({_meta:_(u(),w()).nullish(),sessionId:K,terminalId:u()}),KP=p({_meta:_(u(),w()).nullish(),exitCode:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:u().nullish()}),JP=p({name:u(),uri:u()}),XP=p({_meta:_(u(),w()).nullish(),repository:ZC.nullish(),workspaceFolders:R(JP).nullish(),workspaceUri:u().nullish()});p({id:jn,method:u(),params:Z([aI,BT,vC,qC,jI,pC,ZI,BI,LI,iP,rP,RP,aP,XP,fP,zI,_g]).nullish()});const Bg=p({_meta:_(u(),w()).nullish(),content:u(),path:u(),sessionId:K});p({id:jn,method:u(),params:Z([Bg,Rg,Zg,Ig,Og,Dg,Wg,Pg,VP,_g]).nullish()});const QP=p({_meta:_(u(),w()).nullish()});Z([p({id:jn,result:Z([QP,pI,SI,JT,vP,gI,KP,fC,sC,Sg])}),p({error:bg,id:jn})]);var Y;class eR{constructor(e,n){x(this,Y);const r=e(this),s=async(o,a)=>{var l,c,d,f,y,m,E;switch(o){case Tt.fs_write_text_file:{const k=Bg.parse(a);return(l=r.writeTextFile)==null?void 0:l.call(r,k)}case Tt.fs_read_text_file:{const k=Rg.parse(a);return(c=r.readTextFile)==null?void 0:c.call(r,k)}case Tt.session_request_permission:{const k=Zg.parse(a);return r.requestPermission(k)}case Tt.terminal_create:{const k=Ig.parse(a);return(d=r.createTerminal)==null?void 0:d.call(r,k)}case Tt.terminal_output:{const k=Og.parse(a);return(f=r.terminalOutput)==null?void 0:f.call(r,k)}case Tt.terminal_release:{const k=Dg.parse(a);return await((y=r.releaseTerminal)==null?void 0:y.call(r,k))??{}}case Tt.terminal_wait_for_exit:{const k=Wg.parse(a);return(m=r.waitForTerminalExit)==null?void 0:m.call(r,k)}case Tt.terminal_kill:{const k=Pg.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=jg.parse(a);return r.sessionUpdate(l)}default:if(r.extNotification)return r.extNotification(o,a);throw ye.methodNotFound(o)}};$(this,Y,new tR(s,i,n))}async initialize(e){return await h(this,Y).sendRequest(ie.initialize,e)}async newSession(e){return await h(this,Y).sendRequest(ie.session_new,e)}async loadSession(e){return await h(this,Y).sendRequest(ie.session_load,e)??{}}async unstable_forkSession(e){return await h(this,Y).sendRequest(ie.session_fork,e)}async listSessions(e){return await h(this,Y).sendRequest(ie.session_list,e)}async unstable_resumeSession(e){return await h(this,Y).sendRequest(ie.session_resume,e)}async unstable_closeSession(e){return await h(this,Y).sendRequest(ie.session_close,e)}async setSessionMode(e){return await h(this,Y).sendRequest(ie.session_set_mode,e)??{}}async unstable_setSessionModel(e){return await h(this,Y).sendRequest(ie.session_set_model,e)??{}}async setSessionConfigOption(e){return await h(this,Y).sendRequest(ie.session_set_config_option,e)}async authenticate(e){return await h(this,Y).sendRequest(ie.authenticate,e)??{}}async unstable_logout(e){return await h(this,Y).sendRequest(ie.logout,e)??{}}async prompt(e){return await h(this,Y).sendRequest(ie.session_prompt,e)}async cancel(e){return await h(this,Y).sendNotification(ie.session_cancel,e)}async unstable_startNes(e){return await h(this,Y).sendRequest(ie.nes_start,e)}async unstable_suggestNes(e){return await h(this,Y).sendRequest(ie.nes_suggest,e)}async unstable_closeNes(e){return await h(this,Y).sendRequest(ie.nes_close,e)??{}}async unstable_didOpenDocument(e){return await h(this,Y).sendNotification(ie.document_did_open,e)}async unstable_didChangeDocument(e){return await h(this,Y).sendNotification(ie.document_did_change,e)}async unstable_didCloseDocument(e){return await h(this,Y).sendNotification(ie.document_did_close,e)}async unstable_didSaveDocument(e){return await h(this,Y).sendNotification(ie.document_did_save,e)}async unstable_didFocusDocument(e){return await h(this,Y).sendNotification(ie.document_did_focus,e)}async unstable_acceptNes(e){return await h(this,Y).sendNotification(ie.nes_accept,e)}async unstable_rejectNes(e){return await h(this,Y).sendNotification(ie.nes_reject,e)}async extMethod(e,n){return await h(this,Y).sendRequest(e,n)}async extNotification(e,n){return await h(this,Y).sendNotification(e,n)}get signal(){return h(this,Y).signal}get closed(){return h(this,Y).closed}}Y=new WeakMap;var Kt,To,Fs,Zs,_r,Sr,bt,js,ae,Vg,Sl,Gg,Hg,qg,Yg,kl,gs;class tR{constructor(e,n,r){x(this,ae);x(this,Kt,new Map);x(this,To,0);x(this,Fs);x(this,Zs);x(this,_r);x(this,Sr,Promise.resolve());x(this,bt,new AbortController);x(this,js);$(this,Fs,e),$(this,Zs,n),$(this,_r,r),$(this,js,new Promise(s=>{h(this,bt).signal.addEventListener("abort",()=>s())})),b(this,ae,Vg).call(this)}get signal(){return h(this,bt).signal}get closed(){return h(this,js)}async sendRequest(e,n){b(this,ae,kl).call(this);const r=Eu(this,To)._++,s=new Promise((i,o)=>{h(this,Kt).set(r,{resolve:i,reject:o})});return await b(this,ae,gs).call(this,{jsonrpc:"2.0",id:r,method:e,params:n}),s}async sendNotification(e,n){b(this,ae,kl).call(this),await b(this,ae,gs).call(this,{jsonrpc:"2.0",method:e,params:n})}}Kt=new WeakMap,To=new WeakMap,Fs=new WeakMap,Zs=new WeakMap,_r=new WeakMap,Sr=new WeakMap,bt=new WeakMap,js=new WeakMap,ae=new WeakSet,Vg=async function(){let e;try{const n=h(this,_r).readable.getReader();try{for(;!h(this,bt).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,gs).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,Sl).call(this,e)}},Sl=function(e){if(h(this,bt).signal.aborted)return;const n=e??new Error("ACP connection closed");for(const r of h(this,Kt).values())r.reject(n);h(this,Kt).clear(),h(this,bt).abort(n)},Gg=async function(e){if("method"in e&&"id"in e){const n=await b(this,ae,Hg).call(this,e.method,e.params);"error"in n&&console.error("Error handling request",e,n.error),await b(this,ae,gs).call(this,{jsonrpc:"2.0",id:e.id,...n})}else if("method"in e){const n=await b(this,ae,qg).call(this,e.method,e.params);"error"in n&&console.error("Error handling notification",e,n.error)}else"id"in e?b(this,ae,Yg).call(this,e):console.error("Invalid message",{message:e})},Hg=async function(e,n){try{return{result:await h(this,Fs).call(this,e,n)??null}}catch(r){if(r instanceof ye)return r.toResult();if(r instanceof md)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=async function(e,n){try{return await h(this,Zs).call(this,e,n),{result:null}}catch(r){if(r instanceof ye)return r.toResult();if(r instanceof md)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()}}},Yg=function(e){const n=h(this,Kt).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))}h(this,Kt).delete(e.id)}else console.error("Got response to unknown request",e.id)},kl=function(){if(h(this,bt).signal.aborted)throw h(this,bt).signal.reason??new Error("ACP connection closed")},gs=async function(e){return $(this,Sr,h(this,Sr).then(async()=>{const n=h(this,_r).writable.getWriter();try{await n.write(e)}finally{n.releaseLock()}}).catch(n=>{b(this,ae,Sl).call(this,n)})),h(this,Sr)};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 nR=/^Sender \(untrusted metadata\):\n```json\n[\s\S]*?\n```\n\n?/,rR=/^\[[^\n]*Working directory:[^\n]*\]\n\n?/,sR=/\[Television screen context\][\s\S]*?\[\/Television screen context\]\n*/,iR=/\[\[\s*(?:reply_to_current|reply_to\s*:\s*[^\]\n]+|audio_as_voice)\s*\]\]\s*/gi,oR="single_session",aR={name:"television-acp-client",version:"0.0.0"},Kg="agent:main:television",lR=Gr(kt);var re,Rt,kr,Dt,Dn,On,Jt,Er,wt,st,Xt,zn,Ot,Qt,Ws,zt,it,Co,Lt,C,Jg,Xg,El,Qg,em,tm,nm,rm,sm,im,wn,cr,ur,Ge,om,hr,$l,Al,ro,am,Bs,Vs,xl,dr,lm,cm;class cR extends lR{constructor(n){super();x(this,C);x(this,re,uR());x(this,Rt,null);x(this,kr,null);x(this,Dt,null);x(this,Dn,null);x(this,On,null);x(this,Jt,null);x(this,Er,1);x(this,wt,null);x(this,st,null);x(this,Xt,!1);x(this,zn,!1);x(this,Ot,null);x(this,Qt,new Set);x(this,Ws);x(this,zt);x(this,it);x(this,Co,n=>{b(this,C,Xg).call(this,n)});x(this,Lt,null);x(this,Bs,()=>{b(this,C,dr).call(this,"ACP bridge websocket closed")});x(this,Vs,()=>{b(this,C,dr).call(this,"ACP bridge websocket error")});$(this,zt,n),$(this,it,n.sessionMode??oR),$(this,Ws,n.createSocket??(r=>new WebSocket(r)))}getState(){return h(this,re)}async connect(){if(this.disposed)throw new Error("ACPClient has been disposed");if(h(this,re).lifecycle.status!=="ready"){b(this,C,Ge).call(this,{lifecycle:{status:"connecting"}}),h(this,kr)??$(this,kr,b(this,C,Jg).call(this));try{await h(this,kr),await b(this,C,El).call(this)}catch(n){throw b(this,C,dr).call(this,Fi(n)),n}}}dispose(){b(this,C,xl).call(this),b(this,C,Ge).call(this,{lifecycle:{status:"disposed"},run:{status:"idle",stopReason:null,canCancel:!1,error:null}})}async sendMessage(n){if(await this.connect(),h(this,re).lifecycle.status!=="ready"||h(this,re).run.status==="running"||h(this,re).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,cr).call(this,{id:b(this,C,hr).call(this,"user"),kind:"user",text:r,status:"final"}),b(this,C,Ge).call(this,{run:{status:"running",stopReason:null,canCancel:!0,error:null}});try{const s=await b(this,C,ro).call(this).prompt({sessionId:b(this,C,Al).call(this),prompt:[{type:"text",text:b(this,C,om).call(this,r)}]});b(this,C,wn).call(this,s.stopReason==="cancelled"?"cancelled":"final"),b(this,C,Ge).call(this,{run:{status:s.stopReason==="cancelled"?"cancelled":"completed",stopReason:s.stopReason,canCancel:!1,error:null}})}catch(s){throw b(this,C,cm).call(this)||(b(this,C,wn).call(this,"error"),b(this,C,Ge).call(this,{run:{status:"error",stopReason:null,canCancel:!1,error:Fi(s)}})),s}}async cancel(){if(await this.connect(),!h(this,re).run.canCancel||h(this,re).run.status!=="running")throw new Error("No active cancellable run");b(this,C,Ge).call(this,{run:{...h(this,re).run,status:"cancelling"}}),await b(this,C,ro).call(this).cancel({sessionId:b(this,C,Al).call(this)})}setScreenContext(n){var i,o,a;const r={screenID:n.screenID,screenName:n.screenName};if(((i=h(this,st))==null?void 0:i.screenID)===r.screenID&&((o=h(this,st))==null?void 0:o.screenName)===r.screenName)return;const s=((a=h(this,st))==null?void 0:a.screenID)??null;if($(this,st,r),h(this,it)==="single_session"){(!h(this,Jt)||s!==r.screenID)&&$(this,Xt,!0);return}h(this,Jt)!==Sd(h(this,it),r.screenID,h(this,zt).clientGUID??"default-client")&&($(this,Dt,null),$(this,Dn,null),h(this,Rt)&&h(this,re).run.status==="idle"&&b(this,C,El).call(this).catch(l=>{b(this,C,dr).call(this,Fi(l))}))}}re=new WeakMap,Rt=new WeakMap,kr=new WeakMap,Dt=new WeakMap,Dn=new WeakMap,On=new WeakMap,Jt=new WeakMap,Er=new WeakMap,wt=new WeakMap,st=new WeakMap,Xt=new WeakMap,zn=new WeakMap,Ot=new WeakMap,Qt=new WeakMap,Ws=new WeakMap,zt=new WeakMap,it=new WeakMap,Co=new WeakMap,Lt=new WeakMap,C=new WeakSet,Jg=async function(){try{b(this,C,Ge).call(this,{lifecycle:{status:"connecting"}});const{stream:n,socket:r}=await fR({serverURL:h(this,zt).serverURL,token:h(this,zt).token,createSocket:h(this,Ws),onDisconnect:h(this,Co)});$(this,Lt,r),r.addEventListener("close",h(this,Bs)),r.addEventListener("error",h(this,Vs)),$(this,Rt,new eR(s=>({connection:s,sessionUpdate:async i=>{await b(this,C,em).call(this,i)},requestPermission:async i=>b(this,C,tm).call(this,i)}),n)),await h(this,Rt).initialize({protocolVersion:MT,clientCapabilities:{},clientInfo:aR})}catch(n){throw n}},Xg=function(n){b(this,C,dr).call(this,Fi(n))},El=async function(){const n=b(this,C,am).call(this);if(h(this,Dt)&&h(this,Dn)===n){await h(this,Dt);return}$(this,Dn,n),$(this,Dt,b(this,C,Qg).call(this,n)),await h(this,Dt)},Qg=async function(n){const r=b(this,C,ro).call(this);b(this,C,lm).call(this);let s,i=!1;try{$(this,zn,!0),$(this,Ot,null),await r.loadSession({sessionId:n,cwd:"/",mcpServers:[],_meta:{sessionKey:n}}),s=n,i=h(this,re).messageOrder.length>0}catch{s=(await r.newSession({cwd:"/",mcpServers:[],_meta:{sessionKey:n}})).sessionId,i=!1}finally{$(this,zn,!1),$(this,Ot,null),b(this,C,wn).call(this,"final")}await r.setSessionConfigOption({sessionId:s,configId:"verbose_level",value:"full"}),$(this,On,s),$(this,Jt,n),i?(h(this,Qt).add(n),h(this,it)==="single_session"&&$(this,Xt,!1)):(h(this,Qt).delete(n),$(this,Xt,h(this,it)==="single_session")),b(this,C,Ge).call(this,{lifecycle:{status:"ready"}})},em=async function(n){const r=n.update;switch(r.sessionUpdate){case"user_message_chunk":r.content.type==="text"&&b(this,C,im).call(this,r.content.text);return;case"agent_message_chunk":r.content.type==="text"&&b(this,C,nm).call(this,r.content.text);return;case"tool_call":b(this,C,rm).call(this,r);return;case"tool_call_update":b(this,C,sm).call(this,r);return;case"agent_thought_chunk":return;default:return}},tm=async function(n){return{outcome:{outcome:"cancelled"}}},nm=function(n){$(this,Ot,null);const r=hR(n);if(!r)return;if(!h(this,wt)){const i={id:b(this,C,hr).call(this,"assistant"),kind:"assistant",text:r,status:"streaming"};$(this,wt,i.id),b(this,C,cr).call(this,i);return}const s=h(this,re).messagesById[h(this,wt)];if(!s||s.kind!=="assistant")throw new Error("Open assistant message invariant violated");b(this,C,ur).call(this,{...s,text:`${s.text}${r}`,status:"streaming"})},rm=function(n){b(this,C,wn).call(this,"final");const r=b(this,C,$l).call(this,n.toolCallId),s={id:(r==null?void 0:r.id)??b(this,C,hr).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,ur).call(this,s);return}b(this,C,cr).call(this,s)},sm=function(n){const r=b(this,C,$l).call(this,n.toolCallId),s=(r==null?void 0:r.text)??"",i=dR(n.content),o=i?`${s}${i}`:s,a={id:(r==null?void 0:r.id)??b(this,C,hr).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,ur).call(this,a);return}b(this,C,cr).call(this,a)},im=function(n){if(b(this,C,wn).call(this,"final"),!n)return;const r=h(this,zn)?h(this,Ot):null;if(!r){const i=kd(n);if(!i)return;const o={id:b(this,C,hr).call(this,"user"),kind:"user",text:i,status:"final"};b(this,C,cr).call(this,o),h(this,zn)&&$(this,Ot,o.id);return}const s=h(this,re).messagesById[r];if(!s||s.kind!=="user")throw new Error("Replay user message invariant violated");b(this,C,ur).call(this,{...s,text:kd(`${s.text}${n}`)})},wn=function(n){if(!h(this,wt))return;const r=h(this,re).messagesById[h(this,wt)];(r==null?void 0:r.kind)==="assistant"&&b(this,C,ur).call(this,{...r,status:n}),$(this,wt,null)},cr=function(n){b(this,C,Ge).call(this,{messagesById:{...h(this,re).messagesById,[n.id]:n},messageOrder:[...h(this,re).messageOrder,n.id]})},ur=function(n){b(this,C,Ge).call(this,{messagesById:{...h(this,re).messagesById,[n.id]:n}})},Ge=function(n){const r={...h(this,re),...n};$(this,re,{...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"))},om=function(n){const r=h(this,Jt);return!h(this,st)||!r||!(h(this,it)==="single_session"?h(this,Xt)||!h(this,Qt).has(r):!h(this,Qt).has(r))?n:($(this,Xt,!1),h(this,Qt).add(r),["[Television screen context]","This chat session is coming from a Television client in the screen below.",`screen_id: ${h(this,st).screenID}`,`screen_name: ${h(this,st).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
- `))},hr=function(n){const r=`${n}-${h(this,Er)}`;return $(this,Er,h(this,Er)+1),r},$l=function(n){for(const r of h(this,re).messageOrder){const s=h(this,re).messagesById[r];if((s==null?void 0:s.kind)==="tool_call"&&s.toolCallId===n)return s}return null},Al=function(){if(!h(this,On))throw new Error("ACP session is not ready");return h(this,On)},ro=function(){if(!h(this,Rt))throw new Error("ACP connection is not ready");return h(this,Rt)},am=function(){var r;if(h(this,it)==="single_session")return`${Kg}-${(h(this,zt).clientGUID??"default-client").toLowerCase()}`;const n=(r=h(this,st))==null?void 0:r.screenID;if(!n)throw new Error("Screen context is required for per-screen session mode");return Sd(h(this,it),n,h(this,zt).clientGUID??"default-client")},Bs=new WeakMap,Vs=new WeakMap,xl=function(){$(this,Rt,null),$(this,kr,null),$(this,Dt,null),$(this,Dn,null),$(this,On,null),$(this,Jt,null),h(this,Lt)&&(h(this,Lt).removeEventListener("close",h(this,Bs)),h(this,Lt).removeEventListener("error",h(this,Vs)),h(this,Lt).close(),$(this,Lt,null))},dr=function(n){this.disposed||h(this,re).lifecycle.status==="disconnected"||(b(this,C,wn).call(this,"error"),b(this,C,xl).call(this),b(this,C,Ge).call(this,{lifecycle:{status:"disconnected",...n?{error:n}:{}},run:{status:"idle",stopReason:null,canCancel:!1,error:null}}))},lm=function(){$(this,wt,null),$(this,Ot,null),$(this,Er,1),b(this,C,Ge).call(this,{run:{status:"idle",stopReason:null,canCancel:!1,error:null},messagesById:{},messageOrder:[]})},cm=function(){return h(this,re).lifecycle.status==="disconnected"};function uR(){return{lifecycle:{status:"connecting"},run:{status:"idle",stopReason:null,canCancel:!1,error:null},messagesById:{},messageOrder:[],sendDisabled:!0,cancelDisabled:!0}}function Sd(t,e,n){return t==="single_session"?`${Kg}-${n.toLowerCase()}`:`agent:main:television-${n.toLowerCase()}-${e.toLowerCase()}`}function um(t){return t.replace(/^(?:\s*\n)+/,"")}function kd(t){let e=t;return e=e.replace(nR,""),e=e.replace(rR,""),e=e.replace(sR,""),e=um(e),e}function hR(t){let e=t;return e=e.replace(iR,""),e=um(e),e}function dR(t){return!t||t.length===0?"":t.flatMap(e=>e.type==="content"&&e.content.type==="text"?[e.content.text]:[]).join("")}async function fR(t){const e=t.createSocket(gR(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"}))},f=E=>{const k=pR(E);if(!k)return;let I;try{I=JSON.parse(k)}catch(V){const N=V instanceof Error?V:new Error(String(V));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 V=new Error(I.error??`ACP bridge ${I.status}`);n||s(V),l.error(V)}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",f),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 pR(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 gR(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 Ed="television.acpClientGUID",mR=Gr(kt);class vR extends mR{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??yR(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 cR({...this.options,sessionMode:this.sessionMode,clientGUID:this.clientGUID}),this.clients.set(r,s)),s.setScreenContext({screenID:n.id,screenName:n.name}),s}}function yR(t){const e=t.getItem(Ed);if(e)return e;const n=kc().toLowerCase();return t.setItem(Ed,n),n}const bR="serverURL",wR="token",_R="mode",SR="electron";function hm(t=window.location.search,e=window.location.origin){const r=new URLSearchParams(t).get(bR);return r?new URL(r).origin:new URL(e).origin}function dm(t=window.location.search){return new URLSearchParams(t).get(wR)}function fm(t=window.location.search){return new URLSearchParams(t).get(_R)===SR}/**
42
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const d of t.seen.entries()){const f=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(f.cycle){i(d);continue}if(f.count>1&&t.reused==="ref"){i(d);continue}}}function ag(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 f=d.def??d.schema,y={...f},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")?(f.allOf=f.allOf??[],f.allOf.push(I)):Object.assign(f,I),Object.assign(f,y),c._zod.parent===m)for(const N in f)N==="$ref"||N==="allOf"||N in y||delete f[N];if(I.$ref&&k.def)for(const N in f)N==="$ref"||N==="allOf"||N in k.def&&JSON.stringify(f[N])===JSON.stringify(k.def[N])&&delete f[N]}const E=c._zod.parent;if(E&&E!==m){r(E);const k=t.seen.get(E);if(k!=null&&k.schema.$ref&&(f.$ref=k.schema.$ref,k.def))for(const I in f)I==="$ref"||I==="allOf"||I in k.def&&JSON.stringify(f[I])===JSON.stringify(k.def[I])&&delete f[I]}t.override({zodSchema:c,jsonSchema:f,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:bo(e,"input",t.processors),output:bo(e,"output",t.processors)}},enumerable:!1,writable:!1}),c}catch{throw new Error("Error converting schema to JSON.")}}function De(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 De(r.element,n);if(r.type==="set")return De(r.valueType,n);if(r.type==="lazy")return De(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 De(r.innerType,n);if(r.type==="intersection")return De(r.left,n)||De(r.right,n);if(r.type==="record"||r.type==="map")return De(r.keyType,n)||De(r.valueType,n);if(r.type==="pipe")return De(r.in,n)||De(r.out,n);if(r.type==="object"){for(const s in r.shape)if(De(r.shape[s],n))return!0;return!1}if(r.type==="union"){for(const s of r.options)if(De(s,n))return!0;return!1}if(r.type==="tuple"){for(const s of r.items)if(De(s,n))return!0;return!!(r.rest&&De(r.rest,n))}return!1}const FA=(t,e={})=>n=>{const r=ig({...n,processors:e});return me(t,r),og(r,t),ag(r,t)},bo=(t,e,n={})=>r=>{const{libraryOptions:s,target:i}=r??{},o=ig({...s??{},target:i,io:e,processors:n});return me(t,o),og(o,t),ag(o,t)},ZA={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},jA=(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=ZA[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(f=>({...e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"?{type:"string"}:{},pattern:f.source}))])}},WA=(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)},BA=(t,e,n,r)=>{n.type="boolean"},VA=(t,e,n,r)=>{n.not={}},GA=(t,e,n,r)=>{},HA=(t,e,n,r)=>{const s=t._zod.def,i=Up(s.entries);i.every(o=>typeof o=="number")&&(n.type="number"),i.every(o=>typeof o=="string")&&(n.type="string"),n.enum=i},qA=(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},YA=(t,e,n,r)=>{if(e.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},KA=(t,e,n,r)=>{if(e.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},JA=(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"]})},XA=(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 f=i.shape[d]._zod;return e.io==="input"?f.optin===void 0:f.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)},QA=(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},ex=(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},tx=(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 f of l)s.patternProperties[f.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(f=>typeof f=="string"||typeof f=="number");d.length>0&&(s.required=d)}},nx=(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"}]},rx=(t,e,n,r)=>{const s=t._zod.def;me(s.innerType,e,r);const i=e.seen.get(t);i.ref=s.innerType},sx=(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))},ix=(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)))},ox=(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},ax=(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},lx=(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},lg=(t,e,n,r)=>{const s=t._zod.def;me(s.innerType,e,r);const i=e.seen.get(t);i.ref=s.innerType},cx=S("ZodISODateTime",(t,e)=>{u$.init(t,e),ue.init(t,e)});function ux(t){return mA(cx,t)}const hx=S("ZodISODate",(t,e)=>{h$.init(t,e),ue.init(t,e)});function dx(t){return vA(hx,t)}const fx=S("ZodISOTime",(t,e)=>{d$.init(t,e),ue.init(t,e)});function px(t){return yA(fx,t)}const gx=S("ZodISODuration",(t,e)=>{f$.init(t,e),ue.init(t,e)});function mx(t){return bA(gx,t)}const cg=(t,e)=>{Wp.init(t,e),t.name="ZodError",Object.defineProperties(t,{format:{value:n=>r0(t,n)},flatten:{value:n=>n0(t,n)},addIssue:{value:n=>{t.issues.push(n),t.message=JSON.stringify(t.issues,wl,2)}},addIssues:{value:n=>{t.issues.push(...n),t.message=JSON.stringify(t.issues,wl,2)}},isEmpty:{get(){return t.issues.length===0}}})},yd=S("ZodError",cg),nt=S("ZodError",cg,{Parent:Error}),vx=Dc(nt),yx=Oc(nt),bx=Wo(nt),wx=Bo(nt),_x=o0(nt),Sx=a0(nt),kx=l0(nt),Ex=c0(nt),$x=u0(nt),Ax=h0(nt),xx=d0(nt),Cx=f0(nt),ce=S("ZodType",(t,e)=>(le.init(t,e),Object.assign(t["~standard"],{jsonSchema:{input:bo(t,"input"),output:bo(t,"output")}}),t.toJSONSchema=FA(t,{}),t.def=e,t.type=e.type,Object.defineProperty(t,"_def",{value:e}),t.check=(...n)=>t.clone(fn(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)=>pn(t,n,r),t.brand=()=>t,t.register=(n,r)=>(n.add(t,r),t),t.parse=(n,r)=>vx(t,n,r,{callee:t.parse}),t.safeParse=(n,r)=>bx(t,n,r),t.parseAsync=async(n,r)=>yx(t,n,r,{callee:t.parseAsync}),t.safeParseAsync=async(n,r)=>wx(t,n,r),t.spa=t.safeParseAsync,t.encode=(n,r)=>_x(t,n,r),t.decode=(n,r)=>Sx(t,n,r),t.encodeAsync=async(n,r)=>kx(t,n,r),t.decodeAsync=async(n,r)=>Ex(t,n,r),t.safeEncode=(n,r)=>$x(t,n,r),t.safeDecode=(n,r)=>Ax(t,n,r),t.safeEncodeAsync=async(n,r)=>xx(t,n,r),t.safeDecodeAsync=async(n,r)=>Cx(t,n,r),t.refine=(n,r)=>t.check(bC(n,r)),t.superRefine=n=>t.check(wC(n)),t.overwrite=n=>t.check(Hr(n)),t.optional=()=>_d(t),t.exactOptional=()=>oC(t),t.nullable=()=>Sd(t),t.nullish=()=>_d(Sd(t)),t.nonoptional=n=>dC(t,n),t.array=()=>R(t),t.or=n=>Z([t,n]),t.and=n=>Go(t,n),t.transform=n=>kd(t,sC(n)),t.default=n=>cC(t,n),t.prefault=n=>hC(t,n),t.catch=n=>pC(t,n),t.pipe=n=>kd(t,n),t.readonly=()=>vC(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)),ug=S("_ZodString",(t,e)=>{zc.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(r,s,i)=>jA(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($A(...r)),t.includes=(...r)=>t.check(CA(...r)),t.startsWith=(...r)=>t.check(TA(...r)),t.endsWith=(...r)=>t.check(IA(...r)),t.min=(...r)=>t.check(yo(...r)),t.max=(...r)=>t.check(rg(...r)),t.length=(...r)=>t.check(sg(...r)),t.nonempty=(...r)=>t.check(yo(1,...r)),t.lowercase=r=>t.check(AA(r)),t.uppercase=r=>t.check(xA(r)),t.trim=()=>t.check(RA()),t.normalize=(...r)=>t.check(PA(...r)),t.toLowerCase=()=>t.check(DA()),t.toUpperCase=()=>t.check(OA()),t.slugify=()=>t.check(zA())}),Tx=S("ZodString",(t,e)=>{zc.init(t,e),ug.init(t,e),t.email=n=>t.check(Y$(Ix,n)),t.url=n=>t.check(eA(Px,n)),t.jwt=n=>t.check(gA(Gx,n)),t.emoji=n=>t.check(tA(Rx,n)),t.guid=n=>t.check(pd(bd,n)),t.uuid=n=>t.check(K$(Ui,n)),t.uuidv4=n=>t.check(J$(Ui,n)),t.uuidv6=n=>t.check(X$(Ui,n)),t.uuidv7=n=>t.check(Q$(Ui,n)),t.nanoid=n=>t.check(nA(Dx,n)),t.guid=n=>t.check(pd(bd,n)),t.cuid=n=>t.check(rA(Ox,n)),t.cuid2=n=>t.check(sA(zx,n)),t.ulid=n=>t.check(iA(Lx,n)),t.base64=n=>t.check(dA(Wx,n)),t.base64url=n=>t.check(fA(Bx,n)),t.xid=n=>t.check(oA(Mx,n)),t.ksuid=n=>t.check(aA(Nx,n)),t.ipv4=n=>t.check(lA(Ux,n)),t.ipv6=n=>t.check(cA(Fx,n)),t.cidrv4=n=>t.check(uA(Zx,n)),t.cidrv6=n=>t.check(hA(jx,n)),t.e164=n=>t.check(pA(Vx,n)),t.datetime=n=>t.check(ux(n)),t.date=n=>t.check(dx(n)),t.time=n=>t.check(px(n)),t.duration=n=>t.check(mx(n))});function u(t){return q$(Tx,t)}const ue=S("ZodStringFormat",(t,e)=>{oe.init(t,e),ug.init(t,e)}),Ix=S("ZodEmail",(t,e)=>{t$.init(t,e),ue.init(t,e)}),bd=S("ZodGUID",(t,e)=>{Q0.init(t,e),ue.init(t,e)}),Ui=S("ZodUUID",(t,e)=>{e$.init(t,e),ue.init(t,e)}),Px=S("ZodURL",(t,e)=>{n$.init(t,e),ue.init(t,e)}),Rx=S("ZodEmoji",(t,e)=>{r$.init(t,e),ue.init(t,e)}),Dx=S("ZodNanoID",(t,e)=>{s$.init(t,e),ue.init(t,e)}),Ox=S("ZodCUID",(t,e)=>{i$.init(t,e),ue.init(t,e)}),zx=S("ZodCUID2",(t,e)=>{o$.init(t,e),ue.init(t,e)}),Lx=S("ZodULID",(t,e)=>{a$.init(t,e),ue.init(t,e)}),Mx=S("ZodXID",(t,e)=>{l$.init(t,e),ue.init(t,e)}),Nx=S("ZodKSUID",(t,e)=>{c$.init(t,e),ue.init(t,e)}),Ux=S("ZodIPv4",(t,e)=>{p$.init(t,e),ue.init(t,e)}),Fx=S("ZodIPv6",(t,e)=>{g$.init(t,e),ue.init(t,e)}),Zx=S("ZodCIDRv4",(t,e)=>{m$.init(t,e),ue.init(t,e)}),jx=S("ZodCIDRv6",(t,e)=>{v$.init(t,e),ue.init(t,e)}),Wx=S("ZodBase64",(t,e)=>{y$.init(t,e),ue.init(t,e)}),Bx=S("ZodBase64URL",(t,e)=>{w$.init(t,e),ue.init(t,e)}),Vx=S("ZodE164",(t,e)=>{_$.init(t,e),ue.init(t,e)}),Gx=S("ZodJWT",(t,e)=>{k$.init(t,e),ue.init(t,e)}),hg=S("ZodNumber",(t,e)=>{Qp.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(r,s,i)=>WA(t,r,s),t.gt=(r,s)=>t.check(md(r,s)),t.gte=(r,s)=>t.check(Va(r,s)),t.min=(r,s)=>t.check(Va(r,s)),t.lt=(r,s)=>t.check(gd(r,s)),t.lte=(r,s)=>t.check(Ba(r,s)),t.max=(r,s)=>t.check(Ba(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(Va(0,r)),t.negative=r=>t.check(gd(0,r)),t.nonpositive=r=>t.check(Ba(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 wA(hg,t)}const Hx=S("ZodNumberFormat",(t,e)=>{E$.init(t,e),hg.init(t,e)});function wd(t){return _A(Hx,t)}const qx=S("ZodBoolean",(t,e)=>{$$.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>BA(t,n,r)});function ke(t){return SA(qx,t)}const Yx=S("ZodUnknown",(t,e)=>{A$.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>GA()});function w(){return kA(Yx)}const Kx=S("ZodNever",(t,e)=>{x$.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>VA(t,n,r)});function Jx(t){return EA(Kx,t)}const Xx=S("ZodArray",(t,e)=>{C$.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>JA(t,n,r,s),t.element=e.element,t.min=(n,r)=>t.check(yo(n,r)),t.nonempty=n=>t.check(yo(1,n)),t.max=(n,r)=>t.check(rg(n,r)),t.length=(n,r)=>t.check(sg(n,r)),t.unwrap=()=>t.element});function R(t,e){return LA(Xx,t,e)}const dg=S("ZodObject",(t,e)=>{I$.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>XA(t,n,r,s),ee(t,"shape",()=>e.shape),t.keyof=()=>wo(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:Jx()}),t.strip=()=>t.clone({...t._zod.def,catchall:void 0}),t.extend=n=>JE(t,n),t.safeExtend=n=>XE(t,n),t.merge=n=>QE(t,n),t.pick=n=>YE(t,n),t.omit=n=>KE(t,n),t.partial=(...n)=>e0(pg,t,n[0]),t.required=(...n)=>t0(gg,t,n[0])});function fg(t,e){const n={type:"object",shape:t??{},...D(e)};return new dg(n)}function p(t,e){return new dg({type:"object",shape:t,catchall:w(),...D(e)})}const Qx=S("ZodUnion",(t,e)=>{P$.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>QA(t,n,r,s),t.options=e.options});function Z(t,e){return new Qx({type:"union",options:t,...D(e)})}const eC=S("ZodIntersection",(t,e)=>{R$.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>ex(t,n,r,s)});function Go(t,e){return new eC({type:"intersection",left:t,right:e})}const tC=S("ZodRecord",(t,e)=>{D$.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>tx(t,n,r,s),t.keyType=e.keyType,t.valueType=e.valueType});function _(t,e,n){return new tC({type:"record",keyType:t,valueType:e,...D(n)})}const Sl=S("ZodEnum",(t,e)=>{O$.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(r,s,i)=>HA(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 Sl({...e,checks:[],...D(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 Sl({...e,checks:[],...D(s),entries:i})}});function wo(t,e){const n=Array.isArray(t)?Object.fromEntries(t.map(r=>[r,r])):t;return new Sl({type:"enum",entries:n,...D(e)})}const nC=S("ZodLiteral",(t,e)=>{z$.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>qA(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 nC({type:"literal",values:Array.isArray(t)?t:[t],...D(e)})}const rC=S("ZodTransform",(t,e)=>{L$.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>KA(t,n),t._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Mp(t.constructor.name);n.addIssue=i=>{if(typeof i=="string")n.issues.push(Cs(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(Cs(o))}};const s=e.transform(n.value,n);return s instanceof Promise?s.then(i=>(n.value=i,n)):(n.value=s,n)}});function sC(t){return new rC({type:"transform",transform:t})}const pg=S("ZodOptional",(t,e)=>{ng.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>lg(t,n,r,s),t.unwrap=()=>t._zod.def.innerType});function _d(t){return new pg({type:"optional",innerType:t})}const iC=S("ZodExactOptional",(t,e)=>{M$.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>lg(t,n,r,s),t.unwrap=()=>t._zod.def.innerType});function oC(t){return new iC({type:"optional",innerType:t})}const aC=S("ZodNullable",(t,e)=>{N$.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>nx(t,n,r,s),t.unwrap=()=>t._zod.def.innerType});function Sd(t){return new aC({type:"nullable",innerType:t})}const lC=S("ZodDefault",(t,e)=>{U$.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>sx(t,n,r,s),t.unwrap=()=>t._zod.def.innerType,t.removeDefault=t.unwrap});function cC(t,e){return new lC({type:"default",innerType:t,get defaultValue(){return typeof e=="function"?e():Zp(e)}})}const uC=S("ZodPrefault",(t,e)=>{F$.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>ix(t,n,r,s),t.unwrap=()=>t._zod.def.innerType});function hC(t,e){return new uC({type:"prefault",innerType:t,get defaultValue(){return typeof e=="function"?e():Zp(e)}})}const gg=S("ZodNonOptional",(t,e)=>{Z$.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>rx(t,n,r,s),t.unwrap=()=>t._zod.def.innerType});function dC(t,e){return new gg({type:"nonoptional",innerType:t,...D(e)})}const fC=S("ZodCatch",(t,e)=>{j$.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>ox(t,n,r,s),t.unwrap=()=>t._zod.def.innerType,t.removeCatch=t.unwrap});function pC(t,e){return new fC({type:"catch",innerType:t,catchValue:typeof e=="function"?e:()=>e})}const gC=S("ZodPipe",(t,e)=>{W$.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>ax(t,n,r,s),t.in=e.in,t.out=e.out});function kd(t,e){return new gC({type:"pipe",in:t,out:e})}const mC=S("ZodReadonly",(t,e)=>{B$.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>lx(t,n,r,s),t.unwrap=()=>t._zod.def.innerType});function vC(t){return new mC({type:"readonly",innerType:t})}const yC=S("ZodCustom",(t,e)=>{V$.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>YA(t,n)});function bC(t,e={}){return MA(yC,t,e)}function wC(t){return NA(t)}const _C=["text/markdown","text/html"],SC=["committed","pending"];fg({id:u().min(1),type:wo(_C),title:u(),status:wo(SC),externalFilePath:u().optional()});fg({name:u().min(1),description:u(),accepts:R(u().min(1)).min(1)});function Lc(t){return typeof t=="object"&&t!==null}function kC(t){return!Lc(t)||t.type!=="ready"?!1:!("id"in t)}function EC(t){return!(!Lc(t)||t.type!=="update-content"||typeof t.id!="string"||typeof t.content!="string")}function $C(t){return!Lc(t)||t.type!=="wheel"||typeof t.deltaX!="number"||typeof t.deltaY!="number"||typeof t.shiftKey!="boolean"?!1:!("id"in t)}function AC(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 xC(t,e){let n=null;for(const r of t.accepts){const s=AC(r,e);s!==null&&(n===null||s>n)&&(n=s)}return n}function CC(t,e){let n=-1,r=null;for(const s of e){const i=xC(s,t);i!==null&&(i>n||i===n&&r!==null&&s.id<r.id)&&(n=i,r=s)}return r}const TC=4401;class kl extends Error{constructor(e="Authentication required"){super(e),this.name="AuthError"}}class El 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 DE(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(IC(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=f=>{a||this.connectAttempt!==n||(a=!0,this.status="disconnected",this.dispatchEvent(new te("change")),o(f))},d=async()=>{try{const[{screens:f},y]=await Promise.all([this.client.screens.list(),this.client.views.list()]);this.screens=new Map(f.map(m=>[m.id,structuredClone(m)])),this.views=y,this.dispatchEvent(new te("change")),l()}catch(f){c(f instanceof Error?f:new Error(String(f)))}};r.addEventListener("open",()=>{d()}),r.addEventListener("message",f=>{const y=RC(f);y&&(this.applyServerEvent(y),this.dispatchEvent(new Ap("server-event",{serverURL:this.url,event:y})))}),r.addEventListener("close",f=>{if(this.connectAttempt===n){if(this.socket=null,PC(f)===TC){c(new kl);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=CC(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 to("screens-changed"));break;case"screen-updated":this.screens.set(n.screen.id,structuredClone(n.screen)),this.dispatchEvent(new to("screens-changed"));break;case"screen-removed":this.screens.delete(n.screenID),this.dispatchEvent(new to("screens-changed"));break;case"artifact-created":{const r=this.screens.get(n.screenID);r&&!kp(r.layout,n.artifact.id)&&(r.layout=[...r.layout,Sp(n.artifact.id)]);break}case"artifact-removed":{const r=this.screens.get(n.screenID);r&&(r.layout=fp(r.layout,n.artifactID));break}}}}function IC(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 PC(t){return typeof t=="object"&&t!==null&&"code"in t&&typeof t.code=="number"?t.code:null}function RC(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 DC 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 Ap("server-event",{serverURL:l.serverURL,event:l.event}))},a=()=>{this.dispatchEvent(new to("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 El({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 El({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"},Ct={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"},OC=1,zC=p({_meta:_(u(),w()).nullish(),terminal:ke().optional().default(!1)}),LC=p({_meta:_(u(),w()).nullish(),label:u().nullish(),name:u(),optional:ke().optional().default(!1),secret:ke().optional().default(!0)}),MC=p({_meta:_(u(),w()).nullish(),description:u().nullish(),id:u(),name:u()}),NC=p({_meta:_(u(),w()).nullish(),description:u().nullish(),id:u(),link:u().nullish(),name:u(),vars:R(LC)}),UC=p({_meta:_(u(),w()).nullish(),args:R(u()).optional(),description:u().nullish(),env:_(u(),u()).optional(),id:u(),name:u()}),FC=Z([NC.and(p({type:A("env_var")})),UC.and(p({type:A("terminal")})),MC]),ZC=p({_meta:_(u(),w()).nullish(),methodId:u()}),jC=p({_meta:_(u(),w()).nullish()}),WC=p({_meta:_(u(),w()).nullish(),blob:u(),mimeType:u().nullish(),uri:u()}),BC=p({default:ke().nullish(),description:u().nullish(),title:u().nullish()}),VC=p({_meta:_(u(),w()).nullish()}),GC=p({_meta:_(u(),w()).nullish()}),HC=p({amount:U(),currency:u()}),qC=p({_meta:_(u(),w()).nullish(),terminalId:u()}),YC=p({_meta:_(u(),w()).nullish(),newText:u(),oldText:u().nullish(),path:u()}),KC=Z([u(),U(),U(),ke(),R(u())]),JC=p({content:_(u(),KC).nullish()}),XC=Z([JC.and(p({action:A("accept")})),p({action:A("decline")}),p({action:A("cancel")})]),QC=p({_meta:_(u(),w()).nullish()}),mg=u(),eT=p({_meta:_(u(),w()).nullish(),elicitationId:mg}),tT=p({_meta:_(u(),w()).nullish(),action:XC}),nT=A("object"),rT=A("string"),sT=p({_meta:_(u(),w()).nullish()}),iT=p({_meta:_(u(),w()).nullish(),form:QC.nullish(),url:sT.nullish()}),oT=p({elicitationId:mg,url:u().url()}),vg=p({const:u(),title:u()}),yg=p({_meta:_(u(),w()).nullish(),name:u(),value:u()}),aT=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"})]),bg=p({code:aT,data:w().optional(),message:u()}),wg=w(),_g=w(),Sg=w(),lT=p({_meta:_(u(),w()).nullish(),readTextFile:ke().optional().default(!1),writeTextFile:ke().optional().default(!1)}),kg=p({_meta:_(u(),w()).nullish(),name:u(),value:u()}),Eg=p({_meta:_(u(),w()).nullish(),name:u(),title:u().nullish(),version:u()}),cT=p({default:U().nullish(),description:u().nullish(),maximum:U().nullish(),minimum:U().nullish(),title:u().nullish()}),uT=p({_meta:_(u(),w()).nullish()}),hT=p({_meta:_(u(),w()).nullish(),additionalDirectories:R(u()).optional(),cursor:u().nullish(),cwd:u().nullish()}),dT=p({_meta:_(u(),w()).nullish()}),fT=p({_meta:_(u(),w()).nullish(),logout:dT.nullish()}),pT=p({_meta:_(u(),w()).nullish()}),gT=p({_meta:_(u(),w()).nullish()}),mT=p({_meta:_(u(),w()).nullish(),http:ke().optional().default(!1),sse:ke().optional().default(!1)}),vT=p({_meta:_(u(),w()).nullish(),headers:R(kg),name:u(),url:u()}),yT=p({_meta:_(u(),w()).nullish(),headers:R(kg),name:u(),url:u()}),bT=p({_meta:_(u(),w()).nullish(),args:R(u()),command:u(),env:R(yg),name:u()}),Ho=Z([vT.and(p({type:A("http")})),yT.and(p({type:A("sse")})),bT]),Mc=u(),wT=p({_meta:_(u(),w()).nullish(),description:u().nullish(),modelId:Mc,name:u()}),_T=Z([A("error"),A("warning"),A("information"),A("hint")]),ST=p({_meta:_(u(),w()).nullish()}),kT=p({_meta:_(u(),w()).nullish()}),ET=p({_meta:_(u(),w()).nullish()}),$T=p({_meta:_(u(),w()).nullish()}),AT=p({_meta:_(u(),w()).nullish()}),xT=p({_meta:_(u(),w()).nullish(),maxCount:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),CT=p({diff:u(),uri:u()}),TT=p({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:u()}),IT=p({_meta:_(u(),w()).nullish()}),PT=p({_meta:_(u(),w()).nullish()}),RT=p({languageId:u(),text:u(),uri:u()}),DT=p({_meta:_(u(),w()).nullish(),maxCount:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),OT=Z([A("rejected"),A("ignored"),A("replaced"),A("cancelled")]),zT=p({excerpts:R(TT),uri:u()}),LT=p({_meta:_(u(),w()).nullish()}),MT=p({_meta:_(u(),w()).nullish()}),NT=p({name:u(),owner:u(),remoteUrl:u()}),UT=p({_meta:_(u(),w()).nullish()}),FT=p({_meta:_(u(),w()).nullish(),jump:IT.nullish(),rename:MT.nullish(),searchAndReplace:UT.nullish()}),ZT=p({id:u(),isRegex:ke().nullish(),replace:u(),search:u(),uri:u()}),jT=Z([A("automatic"),A("diagnostic"),A("manual")]),WT=p({_meta:_(u(),w()).nullish(),maxCount:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),BT=p({_meta:_(u(),w()).nullish(),diagnostics:ST.nullish(),editHistory:xT.nullish(),openFiles:PT.nullish(),recentFiles:DT.nullish(),relatedSnippets:LT.nullish(),userActions:WT.nullish()}),VT=p({_meta:_(u(),w()).nullish(),additionalDirectories:R(u()).optional(),cwd:u(),mcpServers:R(Ho)}),GT=p({default:U().nullish(),description:u().nullish(),maximum:U().nullish(),minimum:U().nullish(),title:u().nullish()}),$g=u(),HT=Z([A("allow_once"),A("allow_always"),A("reject_once"),A("reject_always")]),qT=p({_meta:_(u(),w()).nullish(),kind:HT,name:u(),optionId:$g}),YT=Z([A("high"),A("medium"),A("low")]),KT=Z([A("pending"),A("in_progress"),A("completed")]),JT=p({_meta:_(u(),w()).nullish(),content:u(),priority:YT,status:KT}),XT=p({_meta:_(u(),w()).nullish(),entries:R(JT)}),cn=p({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"})}),QT=p({id:u(),position:cn,uri:u()}),eI=p({id:u(),newName:u(),position:cn,uri:u()}),tI=p({action:u(),position:cn,timestampMs:U(),uri:u()}),Ag=Z([A("utf-16"),A("utf-32"),A("utf-8")]),nI=p({_meta:_(u(),w()).nullish(),auth:zC.optional().default({terminal:!1}),elicitation:iT.nullish(),fs:lT.optional().default({readTextFile:!1,writeTextFile:!1}),nes:FT.nullish(),positionEncodings:R(Ag).optional(),terminal:ke().optional().default(!1)}),rI=p({_meta:_(u(),w()).nullish(),audio:ke().optional().default(!1),embeddedContext:ke().optional().default(!1),image:ke().optional().default(!1)}),xg=U().int().gte(0).lte(65535),sI=p({_meta:_(u(),w()).nullish(),clientCapabilities:nI.optional().default({auth:{terminal:!1},fs:{readTextFile:!1,writeTextFile:!1},terminal:!1}),clientInfo:Eg.nullish(),protocolVersion:xg}),qr=p({end:cn,start:cn}),iI=p({message:u(),range:qr,severity:_T,uri:u()}),oI=p({languageId:u(),lastFocusedMs:U().nullish(),uri:u(),visibleRange:qr.nullish()}),aI=p({_meta:_(u(),w()).nullish(),diagnostics:R(iI).nullish(),editHistory:R(CT).nullish(),openFiles:R(oI).nullish(),recentFiles:R(RT).nullish(),relatedSnippets:R(zT).nullish(),userActions:R(tI).nullish()}),lI=p({newText:u(),range:qr}),cI=p({cursorPosition:cn.nullish(),edits:R(lI),id:u(),uri:u()}),uI=Z([cI.and(p({kind:A("edit")})),QT.and(p({kind:A("jump")})),eI.and(p({kind:A("rename")})),ZT.and(p({kind:A("searchAndReplace")}))]),hI=p({_meta:_(u(),w()).nullish(),content:u()}),dI=p({_meta:_(u(),w()).nullish()}),jn=Z([U(),u()]).nullable();p({_meta:_(u(),w()).nullish(),requestId:jn});const fI=wo(["assistant","user"]),vi=p({_meta:_(u(),w()).nullish(),audience:R(fI).nullish(),lastModified:u().nullish(),priority:U().nullish()}),pI=p({_meta:_(u(),w()).nullish(),annotations:vi.nullish(),data:u(),mimeType:u()}),gI=p({_meta:_(u(),w()).nullish(),annotations:vi.nullish(),data:u(),mimeType:u(),uri:u().nullish()}),mI=p({_meta:_(u(),w()).nullish(),annotations:vi.nullish(),description:u().nullish(),mimeType:u().nullish(),name:u(),size:U().nullish(),title:u().nullish(),uri:u()}),vI=p({_meta:_(u(),w()).nullish(),optionId:$g}),yI=Z([p({outcome:A("cancelled")}),vI.and(p({outcome:A("selected")}))]),bI=p({_meta:_(u(),w()).nullish(),outcome:yI}),wI=p({_meta:_(u(),w()).nullish()}),_I=p({_meta:_(u(),w()).nullish()}),SI=p({currentValue:ke()}),kI=u(),Cg=u(),EI=Z([A("mode"),A("model"),A("thought_level"),u()]),Nc=u(),Tg=p({_meta:_(u(),w()).nullish(),description:u().nullish(),name:u(),value:Nc}),$I=p({_meta:_(u(),w()).nullish(),group:kI,name:u(),options:R(Tg)}),AI=Z([R(Tg),R($I)]),xI=p({currentValue:Nc,options:AI}),Yr=Go(Z([xI.and(p({type:A("select")})),SI.and(p({type:A("boolean")}))]),p({_meta:_(u(),w()).nullish(),category:EI.nullish(),description:u().nullish(),id:Cg,name:u()})),CI=p({_meta:_(u(),w()).nullish(),configOptions:R(Yr)}),TI=p({_meta:_(u(),w()).nullish()}),K=u(),II=p({_meta:_(u(),w()).nullish(),id:u(),sessionId:K}),PI=p({_meta:_(u(),w()).nullish(),sessionId:K}),RI=p({_meta:_(u(),w()).nullish(),sessionId:K}),DI=p({_meta:_(u(),w()).nullish(),sessionId:K}),Ig=p({_meta:_(u(),w()).nullish(),args:R(u()).optional(),command:u(),cwd:u().nullish(),env:R(yg).optional(),outputByteLimit:U().nullish(),sessionId:K}),OI=p({_meta:_(u(),w()).nullish(),sessionId:K,uri:u()}),zI=p({_meta:_(u(),w()).nullish(),position:cn,sessionId:K,uri:u(),version:U(),visibleRange:qr}),LI=p({_meta:_(u(),w()).nullish(),languageId:u(),sessionId:K,text:u(),uri:u(),version:U()}),MI=p({_meta:_(u(),w()).nullish(),sessionId:K,uri:u()}),NI=p({_meta:_(u(),w()).nullish(),additionalDirectories:R(u()).optional(),cwd:u(),mcpServers:R(Ho).optional(),sessionId:K}),Pg=p({_meta:_(u(),w()).nullish(),sessionId:K,terminalId:u()}),UI=p({_meta:_(u(),w()).nullish(),additionalDirectories:R(u()).optional(),cwd:u(),mcpServers:R(Ho),sessionId:K}),Rg=p({_meta:_(u(),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:u(),sessionId:K}),FI=p({_meta:_(u(),w()).nullish(),id:u(),reason:OT.nullish(),sessionId:K}),Dg=p({_meta:_(u(),w()).nullish(),sessionId:K,terminalId:u()}),ZI=p({_meta:_(u(),w()).nullish(),additionalDirectories:R(u()).optional(),cwd:u(),mcpServers:R(Ho).optional(),sessionId:K}),jI=p({_meta:_(u(),w()).nullish(),additionalDirectories:R(u()).optional(),cwd:u(),sessionId:K,title:u().nullish(),updatedAt:u().nullish()}),WI=p({_meta:_(u(),w()).nullish(),nextCursor:u().nullish(),sessions:R(jI)}),BI=p({_meta:_(u(),w()).nullish(),title:u().nullish(),updatedAt:u().nullish()}),VI=p({_meta:_(u(),w()).nullish()}),qo=u(),GI=p({_meta:_(u(),w()).nullish(),currentModeId:qo}),HI=p({_meta:_(u(),w()).nullish(),description:u().nullish(),id:qo,name:u()}),Yo=p({_meta:_(u(),w()).nullish(),availableModes:R(HI),currentModeId:qo}),Ko=p({_meta:_(u(),w()).nullish(),availableModels:R(wT),currentModelId:Mc}),qI=p({_meta:_(u(),w()).nullish(),configOptions:R(Yr).nullish(),models:Ko.nullish(),modes:Yo.nullish(),sessionId:K}),YI=p({_meta:_(u(),w()).nullish(),configOptions:R(Yr).nullish(),models:Ko.nullish(),modes:Yo.nullish()}),KI=p({_meta:_(u(),w()).nullish(),configOptions:R(Yr).nullish(),models:Ko.nullish(),modes:Yo.nullish(),sessionId:K}),JI=p({_meta:_(u(),w()).nullish(),configOptions:R(Yr).nullish(),models:Ko.nullish(),modes:Yo.nullish()}),XI=p({_meta:_(u(),w()).nullish()}),QI=p({_meta:_(u(),w()).nullish(),additionalDirectories:wI.nullish(),close:_I.nullish(),fork:TI.nullish(),list:VI.nullish(),resume:XI.nullish()}),eP=Go(Z([p({type:A("boolean"),value:ke()}),p({value:Nc})]),p({_meta:_(u(),w()).nullish(),configId:Cg,sessionId:K})),tP=p({_meta:_(u(),w()).nullish(),configOptions:R(Yr)}),nP=p({_meta:_(u(),w()).nullish(),modeId:qo,sessionId:K}),rP=p({_meta:_(u(),w()).nullish()}),sP=p({_meta:_(u(),w()).nullish(),modelId:Mc,sessionId:K}),iP=p({_meta:_(u(),w()).nullish()}),oP=p({_meta:_(u(),w()).nullish(),sessionId:K}),aP=Z([A("end_turn"),A("max_tokens"),A("max_turn_requests"),A("refusal"),A("cancelled")]),lP=Z([A("email"),A("uri"),A("date"),A("date-time")]),cP=p({default:u().nullish(),description:u().nullish(),enum:R(u()).nullish(),format:lP.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(vg).nullish(),pattern:u().nullish(),title:u().nullish()}),uP=p({_meta:_(u(),w()).nullish(),context:aI.nullish(),position:cn,selection:qr.nullish(),sessionId:K,triggerKind:jT,uri:u(),version:U()}),hP=p({_meta:_(u(),w()).nullish(),suggestions:R(uI)}),dP=p({_meta:_(u(),w()).nullish(),terminalId:u()}),fP=p({_meta:_(u(),w()).nullish(),exitCode:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:u().nullish()}),Og=p({_meta:_(u(),w()).nullish(),sessionId:K,terminalId:u()}),pP=p({_meta:_(u(),w()).nullish(),exitStatus:fP.nullish(),output:u(),truncated:ke()}),gP=p({_meta:_(u(),w()).nullish(),annotations:vi.nullish(),text:u()}),mP=p({range:qr.nullish(),text:u()}),vP=p({_meta:_(u(),w()).nullish(),contentChanges:R(mP),sessionId:K,uri:u(),version:U()});p({method:u(),params:Z([PI,LI,vP,OI,MI,zI,II,FI,wg]).nullish()});const yP=Z([A("full"),A("incremental")]),bP=p({_meta:_(u(),w()).nullish(),syncKind:yP}),wP=p({_meta:_(u(),w()).nullish(),didChange:bP.nullish(),didClose:kT.nullish(),didFocus:ET.nullish(),didOpen:$T.nullish(),didSave:AT.nullish()}),_P=p({_meta:_(u(),w()).nullish(),document:wP.nullish()}),SP=p({_meta:_(u(),w()).nullish(),context:BT.nullish(),events:_P.nullish()}),kP=p({_meta:_(u(),w()).nullish(),auth:fT.optional().default({}),loadSession:ke().optional().default(!1),mcpCapabilities:mT.optional().default({http:!1,sse:!1}),nes:SP.nullish(),positionEncoding:Ag.nullish(),promptCapabilities:rI.optional().default({audio:!1,embeddedContext:!1,image:!1}),sessionCapabilities:QI.optional().default({})}),EP=p({_meta:_(u(),w()).nullish(),agentCapabilities:kP.optional().default({auth:{},loadSession:!1,mcpCapabilities:{http:!1,sse:!1},promptCapabilities:{audio:!1,embeddedContext:!1,image:!1},sessionCapabilities:{}}),agentInfo:Eg.nullish(),authMethods:R(FC).optional().default([]),protocolVersion:xg}),$P=p({_meta:_(u(),w()).nullish(),mimeType:u().nullish(),text:u(),uri:u()}),AP=Z([$P,WC]),xP=p({_meta:_(u(),w()).nullish(),annotations:vi.nullish(),resource:AP}),Uc=Z([gP.and(p({type:A("text")})),gI.and(p({type:A("image")})),pI.and(p({type:A("audio")})),mI.and(p({type:A("resource_link")})),xP.and(p({type:A("resource")}))]),CP=p({_meta:_(u(),w()).nullish(),content:Uc}),Ga=p({_meta:_(u(),w()).nullish(),content:Uc,messageId:u().nullish()}),TP=p({_meta:_(u(),w()).nullish(),messageId:u().nullish(),prompt:R(Uc),sessionId:K}),IP=p({anyOf:R(vg)}),zg=Z([CP.and(p({type:A("content")})),YC.and(p({type:A("diff")})),dP.and(p({type:A("terminal")}))]),Lg=u(),Mg=p({_meta:_(u(),w()).nullish(),line:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:u()}),Ng=Z([A("pending"),A("in_progress"),A("completed"),A("failed")]),Ug=Z([A("read"),A("edit"),A("delete"),A("move"),A("search"),A("execute"),A("think"),A("fetch"),A("switch_mode"),A("other")]),PP=p({_meta:_(u(),w()).nullish(),content:R(zg).optional(),kind:Ug.optional(),locations:R(Mg).optional(),rawInput:w().optional(),rawOutput:w().optional(),status:Ng.optional(),title:u(),toolCallId:Lg}),Fg=p({_meta:_(u(),w()).nullish(),content:R(zg).nullish(),kind:Ug.nullish(),locations:R(Mg).nullish(),rawInput:w().optional(),rawOutput:w().optional(),status:Ng.nullish(),title:u().nullish(),toolCallId:Lg}),Zg=p({_meta:_(u(),w()).nullish(),options:R(qT),sessionId:K,toolCall:Fg}),RP=p({_meta:_(u(),w()).nullish(),hint:u()}),DP=RP,OP=p({_meta:_(u(),w()).nullish(),description:u(),input:DP.nullish(),name:u()}),zP=p({_meta:_(u(),w()).nullish(),availableCommands:R(OP)}),LP=p({enum:R(u()),type:rT}),MP=Z([LP,IP]),NP=p({default:R(u()).nullish(),description:u().nullish(),items:MP,maxItems:U().nullish(),minItems:U().nullish(),title:u().nullish()}),UP=Z([cP.and(p({type:A("string")})),GT.and(p({type:A("number")})),cT.and(p({type:A("integer")})),BC.and(p({type:A("boolean")})),NP.and(p({type:A("array")}))]),FP=p({description:u().nullish(),properties:_(u(),UP).optional().default({}),required:R(u()).nullish(),title:u().nullish(),type:nT.optional().default("object")}),ZP=p({requestedSchema:FP}),jP=Go(Z([ZP.and(p({mode:A("form")})),oT.and(p({mode:A("url")}))]),p({_meta:_(u(),w()).nullish(),message:u(),sessionId:K})),WP=p({cachedReadTokens:U().nullish(),cachedWriteTokens:U().nullish(),inputTokens:U(),outputTokens:U(),thoughtTokens:U().nullish(),totalTokens:U()}),BP=p({_meta:_(u(),w()).nullish(),stopReason:aP,usage:WP.nullish(),userMessageId:u().nullish()});Z([p({id:jn,result:Z([EP,jC,gT,KI,YI,WI,qI,JI,GC,rP,tP,BP,iP,oP,hP,VC,Sg])}),p({error:bg,id:jn})]);const VP=p({_meta:_(u(),w()).nullish(),cost:HC.nullish(),size:U(),used:U()}),GP=Z([Ga.and(p({sessionUpdate:A("user_message_chunk")})),Ga.and(p({sessionUpdate:A("agent_message_chunk")})),Ga.and(p({sessionUpdate:A("agent_thought_chunk")})),PP.and(p({sessionUpdate:A("tool_call")})),Fg.and(p({sessionUpdate:A("tool_call_update")})),XT.and(p({sessionUpdate:A("plan")})),zP.and(p({sessionUpdate:A("available_commands_update")})),GI.and(p({sessionUpdate:A("current_mode_update")})),CI.and(p({sessionUpdate:A("config_option_update")})),BI.and(p({sessionUpdate:A("session_info_update")})),VP.and(p({sessionUpdate:A("usage_update")}))]),jg=p({_meta:_(u(),w()).nullish(),sessionId:K,update:GP});p({method:u(),params:Z([jg,eT,wg]).nullish()});const Wg=p({_meta:_(u(),w()).nullish(),sessionId:K,terminalId:u()}),HP=p({_meta:_(u(),w()).nullish(),exitCode:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:u().nullish()}),qP=p({name:u(),uri:u()}),YP=p({_meta:_(u(),w()).nullish(),repository:NT.nullish(),workspaceFolders:R(qP).nullish(),workspaceUri:u().nullish()});p({id:jn,method:u(),params:Z([sI,ZC,pT,VT,UI,hT,NI,ZI,DI,nP,eP,TP,sP,YP,uP,RI,_g]).nullish()});const Bg=p({_meta:_(u(),w()).nullish(),content:u(),path:u(),sessionId:K});p({id:jn,method:u(),params:Z([Bg,Rg,Zg,Ig,Og,Dg,Wg,Pg,jP,_g]).nullish()});const KP=p({_meta:_(u(),w()).nullish()});Z([p({id:jn,result:Z([KP,hI,bI,qC,pP,dI,HP,uT,tT,Sg])}),p({error:bg,id:jn})]);var Y;class JP{constructor(e,n){x(this,Y);const r=e(this),s=async(o,a)=>{var l,c,d,f,y,m,E;switch(o){case Ct.fs_write_text_file:{const k=Bg.parse(a);return(l=r.writeTextFile)==null?void 0:l.call(r,k)}case Ct.fs_read_text_file:{const k=Rg.parse(a);return(c=r.readTextFile)==null?void 0:c.call(r,k)}case Ct.session_request_permission:{const k=Zg.parse(a);return r.requestPermission(k)}case Ct.terminal_create:{const k=Ig.parse(a);return(d=r.createTerminal)==null?void 0:d.call(r,k)}case Ct.terminal_output:{const k=Og.parse(a);return(f=r.terminalOutput)==null?void 0:f.call(r,k)}case Ct.terminal_release:{const k=Dg.parse(a);return await((y=r.releaseTerminal)==null?void 0:y.call(r,k))??{}}case Ct.terminal_wait_for_exit:{const k=Wg.parse(a);return(m=r.waitForTerminalExit)==null?void 0:m.call(r,k)}case Ct.terminal_kill:{const k=Pg.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 Ct.session_update:{const l=jg.parse(a);return r.sessionUpdate(l)}default:if(r.extNotification)return r.extNotification(o,a);throw ye.methodNotFound(o)}};$(this,Y,new XP(s,i,n))}async initialize(e){return await h(this,Y).sendRequest(ie.initialize,e)}async newSession(e){return await h(this,Y).sendRequest(ie.session_new,e)}async loadSession(e){return await h(this,Y).sendRequest(ie.session_load,e)??{}}async unstable_forkSession(e){return await h(this,Y).sendRequest(ie.session_fork,e)}async listSessions(e){return await h(this,Y).sendRequest(ie.session_list,e)}async unstable_resumeSession(e){return await h(this,Y).sendRequest(ie.session_resume,e)}async unstable_closeSession(e){return await h(this,Y).sendRequest(ie.session_close,e)}async setSessionMode(e){return await h(this,Y).sendRequest(ie.session_set_mode,e)??{}}async unstable_setSessionModel(e){return await h(this,Y).sendRequest(ie.session_set_model,e)??{}}async setSessionConfigOption(e){return await h(this,Y).sendRequest(ie.session_set_config_option,e)}async authenticate(e){return await h(this,Y).sendRequest(ie.authenticate,e)??{}}async unstable_logout(e){return await h(this,Y).sendRequest(ie.logout,e)??{}}async prompt(e){return await h(this,Y).sendRequest(ie.session_prompt,e)}async cancel(e){return await h(this,Y).sendNotification(ie.session_cancel,e)}async unstable_startNes(e){return await h(this,Y).sendRequest(ie.nes_start,e)}async unstable_suggestNes(e){return await h(this,Y).sendRequest(ie.nes_suggest,e)}async unstable_closeNes(e){return await h(this,Y).sendRequest(ie.nes_close,e)??{}}async unstable_didOpenDocument(e){return await h(this,Y).sendNotification(ie.document_did_open,e)}async unstable_didChangeDocument(e){return await h(this,Y).sendNotification(ie.document_did_change,e)}async unstable_didCloseDocument(e){return await h(this,Y).sendNotification(ie.document_did_close,e)}async unstable_didSaveDocument(e){return await h(this,Y).sendNotification(ie.document_did_save,e)}async unstable_didFocusDocument(e){return await h(this,Y).sendNotification(ie.document_did_focus,e)}async unstable_acceptNes(e){return await h(this,Y).sendNotification(ie.nes_accept,e)}async unstable_rejectNes(e){return await h(this,Y).sendNotification(ie.nes_reject,e)}async extMethod(e,n){return await h(this,Y).sendRequest(e,n)}async extNotification(e,n){return await h(this,Y).sendNotification(e,n)}get signal(){return h(this,Y).signal}get closed(){return h(this,Y).closed}}Y=new WeakMap;var Kt,Co,Zs,js,_r,Sr,bt,Ws,ae,Vg,$l,Gg,Hg,qg,Yg,Al,ms;class XP{constructor(e,n,r){x(this,ae);x(this,Kt,new Map);x(this,Co,0);x(this,Zs);x(this,js);x(this,_r);x(this,Sr,Promise.resolve());x(this,bt,new AbortController);x(this,Ws);$(this,Zs,e),$(this,js,n),$(this,_r,r),$(this,Ws,new Promise(s=>{h(this,bt).signal.addEventListener("abort",()=>s())})),b(this,ae,Vg).call(this)}get signal(){return h(this,bt).signal}get closed(){return h(this,Ws)}async sendRequest(e,n){b(this,ae,Al).call(this);const r=xu(this,Co)._++,s=new Promise((i,o)=>{h(this,Kt).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,Al).call(this),await b(this,ae,ms).call(this,{jsonrpc:"2.0",method:e,params:n})}}Kt=new WeakMap,Co=new WeakMap,Zs=new WeakMap,js=new WeakMap,_r=new WeakMap,Sr=new WeakMap,bt=new WeakMap,Ws=new WeakMap,ae=new WeakSet,Vg=async function(){let e;try{const n=h(this,_r).readable.getReader();try{for(;!h(this,bt).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,$l).call(this,e)}},$l=function(e){if(h(this,bt).signal.aborted)return;const n=e??new Error("ACP connection closed");for(const r of h(this,Kt).values())r.reject(n);h(this,Kt).clear(),h(this,bt).abort(n)},Gg=async function(e){if("method"in e&&"id"in e){const n=await b(this,ae,Hg).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,qg).call(this,e.method,e.params);"error"in n&&console.error("Error handling notification",e,n.error)}else"id"in e?b(this,ae,Yg).call(this,e):console.error("Invalid message",{message:e})},Hg=async function(e,n){try{return{result:await h(this,Zs).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()}}},qg=async function(e,n){try{return await h(this,js).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()}}},Yg=function(e){const n=h(this,Kt).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))}h(this,Kt).delete(e.id)}else console.error("Got response to unknown request",e.id)},Al=function(){if(h(this,bt).signal.aborted)throw h(this,bt).signal.reason??new Error("ACP connection closed")},ms=async function(e){return $(this,Sr,h(this,Sr).then(async()=>{const n=h(this,_r).writable.getWriter();try{await n.write(e)}finally{n.releaseLock()}}).catch(n=>{b(this,ae,$l).call(this,n)})),h(this,Sr)};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 QP=/^Sender \(untrusted metadata\):\n```json\n[\s\S]*?\n```\n\n?/,eR=/^\[[^\n]*Working directory:[^\n]*\]\n\n?/,tR=/\[Television screen context\][\s\S]*?\[\/Television screen context\]\n*/,nR=/\[\[\s*(?:reply_to_current|reply_to\s*:\s*[^\]\n]+|audio_as_voice)\s*\]\]\s*/gi,rR="single_session",sR={name:"television-acp-client",version:"0.0.0"},Kg="agent:main:television",iR=Gr(kt);var re,Rt,kr,Dt,Dn,On,Jt,Er,wt,st,Xt,zn,Ot,Qt,Bs,zt,it,To,Lt,T,Jg,Xg,xl,Qg,em,tm,nm,rm,sm,im,wn,cr,ur,Ge,om,hr,Cl,Tl,ro,am,Vs,Gs,Il,dr,lm,cm;class oR extends iR{constructor(n){super();x(this,T);x(this,re,aR());x(this,Rt,null);x(this,kr,null);x(this,Dt,null);x(this,Dn,null);x(this,On,null);x(this,Jt,null);x(this,Er,1);x(this,wt,null);x(this,st,null);x(this,Xt,!1);x(this,zn,!1);x(this,Ot,null);x(this,Qt,new Set);x(this,Bs);x(this,zt);x(this,it);x(this,To,n=>{b(this,T,Xg).call(this,n)});x(this,Lt,null);x(this,Vs,()=>{b(this,T,dr).call(this,"ACP bridge websocket closed")});x(this,Gs,()=>{b(this,T,dr).call(this,"ACP bridge websocket error")});$(this,zt,n),$(this,it,n.sessionMode??rR),$(this,Bs,n.createSocket??(r=>new WebSocket(r)))}getState(){return h(this,re)}async connect(){if(this.disposed)throw new Error("ACPClient has been disposed");if(h(this,re).lifecycle.status!=="ready"){b(this,T,Ge).call(this,{lifecycle:{status:"connecting"}}),h(this,kr)??$(this,kr,b(this,T,Jg).call(this));try{await h(this,kr),await b(this,T,xl).call(this)}catch(n){throw b(this,T,dr).call(this,Fi(n)),n}}}dispose(){b(this,T,Il).call(this),b(this,T,Ge).call(this,{lifecycle:{status:"disposed"},run:{status:"idle",stopReason:null,canCancel:!1,error:null}})}async sendMessage(n){if(await this.connect(),h(this,re).lifecycle.status!=="ready"||h(this,re).run.status==="running"||h(this,re).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,T,cr).call(this,{id:b(this,T,hr).call(this,"user"),kind:"user",text:r,status:"final"}),b(this,T,Ge).call(this,{run:{status:"running",stopReason:null,canCancel:!0,error:null}});try{const s=await b(this,T,ro).call(this).prompt({sessionId:b(this,T,Tl).call(this),prompt:[{type:"text",text:b(this,T,om).call(this,r)}]});b(this,T,wn).call(this,s.stopReason==="cancelled"?"cancelled":"final"),b(this,T,Ge).call(this,{run:{status:s.stopReason==="cancelled"?"cancelled":"completed",stopReason:s.stopReason,canCancel:!1,error:null}})}catch(s){throw b(this,T,cm).call(this)||(b(this,T,wn).call(this,"error"),b(this,T,Ge).call(this,{run:{status:"error",stopReason:null,canCancel:!1,error:Fi(s)}})),s}}async cancel(){if(await this.connect(),!h(this,re).run.canCancel||h(this,re).run.status!=="running")throw new Error("No active cancellable run");b(this,T,Ge).call(this,{run:{...h(this,re).run,status:"cancelling"}}),await b(this,T,ro).call(this).cancel({sessionId:b(this,T,Tl).call(this)})}setScreenContext(n){var i,o,a;const r={screenID:n.screenID,screenName:n.screenName};if(((i=h(this,st))==null?void 0:i.screenID)===r.screenID&&((o=h(this,st))==null?void 0:o.screenName)===r.screenName)return;const s=((a=h(this,st))==null?void 0:a.screenID)??null;if($(this,st,r),h(this,it)==="single_session"){(!h(this,Jt)||s!==r.screenID)&&$(this,Xt,!0);return}h(this,Jt)!==Ed(h(this,it),r.screenID,h(this,zt).clientGUID??"default-client")&&($(this,Dt,null),$(this,Dn,null),h(this,Rt)&&h(this,re).run.status==="idle"&&b(this,T,xl).call(this).catch(l=>{b(this,T,dr).call(this,Fi(l))}))}}re=new WeakMap,Rt=new WeakMap,kr=new WeakMap,Dt=new WeakMap,Dn=new WeakMap,On=new WeakMap,Jt=new WeakMap,Er=new WeakMap,wt=new WeakMap,st=new WeakMap,Xt=new WeakMap,zn=new WeakMap,Ot=new WeakMap,Qt=new WeakMap,Bs=new WeakMap,zt=new WeakMap,it=new WeakMap,To=new WeakMap,Lt=new WeakMap,T=new WeakSet,Jg=async function(){try{b(this,T,Ge).call(this,{lifecycle:{status:"connecting"}});const{stream:n,socket:r}=await uR({serverURL:h(this,zt).serverURL,token:h(this,zt).token,createSocket:h(this,Bs),onDisconnect:h(this,To)});$(this,Lt,r),r.addEventListener("close",h(this,Vs)),r.addEventListener("error",h(this,Gs)),$(this,Rt,new JP(s=>({connection:s,sessionUpdate:async i=>{await b(this,T,em).call(this,i)},requestPermission:async i=>b(this,T,tm).call(this,i)}),n)),await h(this,Rt).initialize({protocolVersion:OC,clientCapabilities:{},clientInfo:sR})}catch(n){throw n}},Xg=function(n){b(this,T,dr).call(this,Fi(n))},xl=async function(){const n=b(this,T,am).call(this);if(h(this,Dt)&&h(this,Dn)===n){await h(this,Dt);return}$(this,Dn,n),$(this,Dt,b(this,T,Qg).call(this,n)),await h(this,Dt)},Qg=async function(n){const r=b(this,T,ro).call(this);b(this,T,lm).call(this);let s,i=!1;try{$(this,zn,!0),$(this,Ot,null),await r.loadSession({sessionId:n,cwd:"/",mcpServers:[],_meta:{sessionKey:n}}),s=n,i=h(this,re).messageOrder.length>0}catch{s=(await r.newSession({cwd:"/",mcpServers:[],_meta:{sessionKey:n}})).sessionId,i=!1}finally{$(this,zn,!1),$(this,Ot,null),b(this,T,wn).call(this,"final")}await r.setSessionConfigOption({sessionId:s,configId:"verbose_level",value:"full"}),$(this,On,s),$(this,Jt,n),i?(h(this,Qt).add(n),h(this,it)==="single_session"&&$(this,Xt,!1)):(h(this,Qt).delete(n),$(this,Xt,h(this,it)==="single_session")),b(this,T,Ge).call(this,{lifecycle:{status:"ready"}})},em=async function(n){const r=n.update;switch(r.sessionUpdate){case"user_message_chunk":r.content.type==="text"&&b(this,T,im).call(this,r.content.text);return;case"agent_message_chunk":r.content.type==="text"&&b(this,T,nm).call(this,r.content.text);return;case"tool_call":b(this,T,rm).call(this,r);return;case"tool_call_update":b(this,T,sm).call(this,r);return;case"agent_thought_chunk":return;default:return}},tm=async function(n){return{outcome:{outcome:"cancelled"}}},nm=function(n){$(this,Ot,null);const r=lR(n);if(!r)return;if(!h(this,wt)){const i={id:b(this,T,hr).call(this,"assistant"),kind:"assistant",text:r,status:"streaming"};$(this,wt,i.id),b(this,T,cr).call(this,i);return}const s=h(this,re).messagesById[h(this,wt)];if(!s||s.kind!=="assistant")throw new Error("Open assistant message invariant violated");b(this,T,ur).call(this,{...s,text:`${s.text}${r}`,status:"streaming"})},rm=function(n){b(this,T,wn).call(this,"final");const r=b(this,T,Cl).call(this,n.toolCallId),s={id:(r==null?void 0:r.id)??b(this,T,hr).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,T,ur).call(this,s);return}b(this,T,cr).call(this,s)},sm=function(n){const r=b(this,T,Cl).call(this,n.toolCallId),s=(r==null?void 0:r.text)??"",i=cR(n.content),o=i?`${s}${i}`:s,a={id:(r==null?void 0:r.id)??b(this,T,hr).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,T,ur).call(this,a);return}b(this,T,cr).call(this,a)},im=function(n){if(b(this,T,wn).call(this,"final"),!n)return;const r=h(this,zn)?h(this,Ot):null;if(!r){const i=$d(n);if(!i)return;const o={id:b(this,T,hr).call(this,"user"),kind:"user",text:i,status:"final"};b(this,T,cr).call(this,o),h(this,zn)&&$(this,Ot,o.id);return}const s=h(this,re).messagesById[r];if(!s||s.kind!=="user")throw new Error("Replay user message invariant violated");b(this,T,ur).call(this,{...s,text:$d(`${s.text}${n}`)})},wn=function(n){if(!h(this,wt))return;const r=h(this,re).messagesById[h(this,wt)];(r==null?void 0:r.kind)==="assistant"&&b(this,T,ur).call(this,{...r,status:n}),$(this,wt,null)},cr=function(n){b(this,T,Ge).call(this,{messagesById:{...h(this,re).messagesById,[n.id]:n},messageOrder:[...h(this,re).messageOrder,n.id]})},ur=function(n){b(this,T,Ge).call(this,{messagesById:{...h(this,re).messagesById,[n.id]:n}})},Ge=function(n){const r={...h(this,re),...n};$(this,re,{...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"))},om=function(n){const r=h(this,Jt);return!h(this,st)||!r||!(h(this,it)==="single_session"?h(this,Xt)||!h(this,Qt).has(r):!h(this,Qt).has(r))?n:($(this,Xt,!1),h(this,Qt).add(r),["[Television screen context]","This chat session is coming from a Television client in the screen below.",`screen_id: ${h(this,st).screenID}`,`screen_name: ${h(this,st).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
+ `))},hr=function(n){const r=`${n}-${h(this,Er)}`;return $(this,Er,h(this,Er)+1),r},Cl=function(n){for(const r of h(this,re).messageOrder){const s=h(this,re).messagesById[r];if((s==null?void 0:s.kind)==="tool_call"&&s.toolCallId===n)return s}return null},Tl=function(){if(!h(this,On))throw new Error("ACP session is not ready");return h(this,On)},ro=function(){if(!h(this,Rt))throw new Error("ACP connection is not ready");return h(this,Rt)},am=function(){var r;if(h(this,it)==="single_session")return`${Kg}-${(h(this,zt).clientGUID??"default-client").toLowerCase()}`;const n=(r=h(this,st))==null?void 0:r.screenID;if(!n)throw new Error("Screen context is required for per-screen session mode");return Ed(h(this,it),n,h(this,zt).clientGUID??"default-client")},Vs=new WeakMap,Gs=new WeakMap,Il=function(){$(this,Rt,null),$(this,kr,null),$(this,Dt,null),$(this,Dn,null),$(this,On,null),$(this,Jt,null),h(this,Lt)&&(h(this,Lt).removeEventListener("close",h(this,Vs)),h(this,Lt).removeEventListener("error",h(this,Gs)),h(this,Lt).close(),$(this,Lt,null))},dr=function(n){this.disposed||h(this,re).lifecycle.status==="disconnected"||(b(this,T,wn).call(this,"error"),b(this,T,Il).call(this),b(this,T,Ge).call(this,{lifecycle:{status:"disconnected",...n?{error:n}:{}},run:{status:"idle",stopReason:null,canCancel:!1,error:null}}))},lm=function(){$(this,wt,null),$(this,Ot,null),$(this,Er,1),b(this,T,Ge).call(this,{run:{status:"idle",stopReason:null,canCancel:!1,error:null},messagesById:{},messageOrder:[]})},cm=function(){return h(this,re).lifecycle.status==="disconnected"};function aR(){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"?`${Kg}-${n.toLowerCase()}`:`agent:main:television-${n.toLowerCase()}-${e.toLowerCase()}`}function um(t){return t.replace(/^(?:\s*\n)+/,"")}function $d(t){let e=t;return e=e.replace(QP,""),e=e.replace(eR,""),e=e.replace(tR,""),e=um(e),e}function lR(t){let e=t;return e=e.replace(nR,""),e=um(e),e}function cR(t){return!t||t.length===0?"":t.flatMap(e=>e.type==="content"&&e.content.type==="text"?[e.content.text]:[]).join("")}async function uR(t){const e=t.createSocket(dR(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"}))},f=E=>{const k=hR(E);if(!k)return;let I;try{I=JSON.parse(k)}catch(V){const N=V instanceof Error?V:new Error(String(V));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 V=new Error(I.error??`ACP bridge ${I.status}`);n||s(V),l.error(V)}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",f),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 hR(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 dR(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",fR=Gr(kt);class pR extends fR{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??gR(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 oR({...this.options,sessionMode:this.sessionMode,clientGUID:this.clientGUID}),this.clients.set(r,s)),s.setScreenContext({screenID:n.id,screenName:n.name}),s}}function gR(t){const e=t.getItem(Ad);if(e)return e;const n=Ac().toLowerCase();return t.setItem(Ad,n),n}const mR="serverURL",vR="token",yR="mode",bR="electron";function hm(t=window.location.search,e=window.location.origin){const r=new URLSearchParams(t).get(mR);return r?new URL(r).origin:new URL(e).origin}function dm(t=window.location.search){return new URLSearchParams(t).get(vR)}function fm(t=window.location.search){return new URLSearchParams(t).get(yR)===bR}/**
44
44
  * @license
45
45
  * Copyright 2017 Google LLC
46
46
  * SPDX-License-Identifier: BSD-3-Clause
47
- */const $s=globalThis,$d=t=>t,_o=$s.trustedTypes,Ad=_o?_o.createPolicy("lit-html",{createHTML:t=>t}):void 0,pm="$lit$",Gt=`lit$${Math.random().toFixed(9).slice(2)}$`,gm="?"+Gt,kR=`<${gm}>`,Wn=document,Ts=()=>Wn.createComment(""),Cs=t=>t===null||typeof t!="object"&&typeof t!="function",Mc=Array.isArray,ER=t=>Mc(t)||typeof(t==null?void 0:t[Symbol.iterator])=="function",Ba=`[
48
- \f\r]`,ss=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,xd=/-->/g,Td=/>/g,yn=RegExp(`>|${Ba}(?:([^\\s"'>=/]+)(${Ba}*=${Ba}*(?:[^
49
- \f\r"'\`<>=]|("|')|))|$)`,"g"),Cd=/'/g,Id=/"/g,mm=/^(?:script|style|textarea|title)$/i,$R=t=>(e,...n)=>({_$litType$:t,strings:e,values:n}),M=$R(1),Lr=Symbol.for("lit-noChange"),ge=Symbol.for("lit-nothing"),Pd=new WeakMap,xn=Wn.createTreeWalker(Wn,129);function vm(t,e){if(!Mc(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return Ad!==void 0?Ad.createHTML(e):e}const AR=(t,e)=>{const n=t.length-1,r=[];let s,i=e===2?"<svg>":e===3?"<math>":"",o=ss;for(let a=0;a<n;a++){const l=t[a];let c,d,f=-1,y=0;for(;y<l.length&&(o.lastIndex=y,d=o.exec(l),d!==null);)y=o.lastIndex,o===ss?d[1]==="!--"?o=xd:d[1]!==void 0?o=Td:d[2]!==void 0?(mm.test(d[2])&&(s=RegExp("</"+d[2],"g")),o=yn):d[3]!==void 0&&(o=yn):o===yn?d[0]===">"?(o=s??ss,f=-1):d[1]===void 0?f=-2:(f=o.lastIndex-d[2].length,c=d[1],o=d[3]===void 0?yn:d[3]==='"'?Id:Cd):o===Id||o===Cd?o=yn:o===xd||o===Td?o=ss:(o=yn,s=void 0);const m=o===yn&&t[a+1].startsWith("/>")?" ":"";i+=o===ss?l+kR:f>=0?(r.push(c),l.slice(0,f)+pm+l.slice(f)+Gt+m):l+Gt+(f===-2?a:m)}return[vm(t,i+(t[n]||"<?>")+(e===2?"</svg>":e===3?"</math>":"")),r]};class Is{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]=AR(e,n);if(this.el=Is.createElement(c,r),xn.currentNode=this.el.content,n===2||n===3){const f=this.el.content.firstChild;f.replaceWith(...f.childNodes)}for(;(s=xn.nextNode())!==null&&l.length<a;){if(s.nodeType===1){if(s.hasAttributes())for(const f of s.getAttributeNames())if(f.endsWith(pm)){const y=d[o++],m=s.getAttribute(f).split(Gt),E=/([.?@])?(.*)/.exec(y);l.push({type:1,index:i,name:E[2],strings:m,ctor:E[1]==="."?TR:E[1]==="?"?CR:E[1]==="@"?IR:Jo}),s.removeAttribute(f)}else f.startsWith(Gt)&&(l.push({type:6,index:i}),s.removeAttribute(f));if(mm.test(s.tagName)){const f=s.textContent.split(Gt),y=f.length-1;if(y>0){s.textContent=_o?_o.emptyScript:"";for(let m=0;m<y;m++)s.append(f[m],Ts()),xn.nextNode(),l.push({type:2,index:++i});s.append(f[y],Ts())}}}else if(s.nodeType===8)if(s.data===gm)l.push({type:2,index:i});else{let f=-1;for(;(f=s.data.indexOf(Gt,f+1))!==-1;)l.push({type:7,index:i}),f+=Gt.length-1}i++}}static createElement(e,n){const r=Wn.createElement("template");return r.innerHTML=e,r}}function Mr(t,e,n=t,r){var o,a;if(e===Lr)return e;let s=r!==void 0?(o=n._$Co)==null?void 0:o[r]:n._$Cl;const i=Cs(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=Mr(t,s._$AS(t,e.values),s,r)),e}class xR{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)??Wn).importNode(n,!0);xn.currentNode=s;let i=xn.nextNode(),o=0,a=0,l=r[0];for(;l!==void 0;){if(o===l.index){let c;l.type===2?c=new Nc(i,i.nextSibling,this,e):l.type===1?c=new l.ctor(i,l.name,l.strings,this,e):l.type===6&&(c=new PR(i,this,e)),this._$AV.push(c),l=r[++a]}o!==(l==null?void 0:l.index)&&(i=xn.nextNode(),o++)}return xn.currentNode=Wn,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 Nc=class ym{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=Mr(this,e,n),Cs(e)?e===ge||e==null||e===""?(this._$AH!==ge&&this._$AR(),this._$AH=ge):e!==this._$AH&&e!==Lr&&this._(e):e._$litType$!==void 0?this.$(e):e.nodeType!==void 0?this.T(e):ER(e)?this.k(e):this._(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==ge&&Cs(this._$AH)?this._$AA.nextSibling.data=e:this.T(Wn.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=Is.createElement(vm(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 xR(s,this),a=o.u(this.options);o.p(n),this.T(a),this._$AH=o}}_$AC(e){let n=Pd.get(e.strings);return n===void 0&&Pd.set(e.strings,n=new Is(e)),n}k(e){Mc(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 ym(this.O(Ts()),this.O(Ts()),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=$d(e).nextSibling;$d(e).remove(),e=s}}setConnected(e){var n;this._$AM===void 0&&(this._$Cv=e,(n=this._$AP)==null||n.call(this,e))}},Jo=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=Mr(this,e,n,0),o=!Cs(e)||e!==this._$AH&&e!==Lr,o&&(this._$AH=e);else{const a=e;let l,c;for(e=i[0],l=0;l<i.length-1;l++)c=Mr(this,a[r+l],n,l),c===Lr&&(c=this._$AH[l]),o||(o=!Cs(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??"")}},TR=class extends Jo{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===ge?void 0:e}},CR=class extends Jo{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==ge)}},IR=class extends Jo{constructor(e,n,r,s,i){super(e,n,r,s,i),this.type=5}_$AI(e,n=this){if((e=Mr(this,e,n,0)??ge)===Lr)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 PR{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){Mr(this,e)}}const Va=$s.litHtmlPolyfillSupport;Va==null||Va(Is,Nc),($s.litHtmlVersions??($s.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 Nc(e.insertBefore(Ts(),null),null,void 0,{})),s._$AI(t),s};/**
47
+ */const As=globalThis,xd=t=>t,_o=As.trustedTypes,Cd=_o?_o.createPolicy("lit-html",{createHTML:t=>t}):void 0,pm="$lit$",Gt=`lit$${Math.random().toFixed(9).slice(2)}$`,gm="?"+Gt,wR=`<${gm}>`,Wn=document,Ts=()=>Wn.createComment(""),Is=t=>t===null||typeof t!="object"&&typeof t!="function",Fc=Array.isArray,_R=t=>Fc(t)||typeof(t==null?void 0:t[Symbol.iterator])=="function",Ha=`[
48
+ \f\r]`,is=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Td=/-->/g,Id=/>/g,yn=RegExp(`>|${Ha}(?:([^\\s"'>=/]+)(${Ha}*=${Ha}*(?:[^
49
+ \f\r"'\`<>=]|("|')|))|$)`,"g"),Pd=/'/g,Rd=/"/g,mm=/^(?:script|style|textarea|title)$/i,SR=t=>(e,...n)=>({_$litType$:t,strings:e,values:n}),M=SR(1),Lr=Symbol.for("lit-noChange"),ge=Symbol.for("lit-nothing"),Dd=new WeakMap,xn=Wn.createTreeWalker(Wn,129);function vm(t,e){if(!Fc(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return Cd!==void 0?Cd.createHTML(e):e}const kR=(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,f=-1,y=0;for(;y<l.length&&(o.lastIndex=y,d=o.exec(l),d!==null);)y=o.lastIndex,o===is?d[1]==="!--"?o=Td:d[1]!==void 0?o=Id:d[2]!==void 0?(mm.test(d[2])&&(s=RegExp("</"+d[2],"g")),o=yn):d[3]!==void 0&&(o=yn):o===yn?d[0]===">"?(o=s??is,f=-1):d[1]===void 0?f=-2:(f=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===Td||o===Id?o=is:(o=yn,s=void 0);const m=o===yn&&t[a+1].startsWith("/>")?" ":"";i+=o===is?l+wR:f>=0?(r.push(c),l.slice(0,f)+pm+l.slice(f)+Gt+m):l+Gt+(f===-2?a:m)}return[vm(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]=kR(e,n);if(this.el=Ps.createElement(c,r),xn.currentNode=this.el.content,n===2||n===3){const f=this.el.content.firstChild;f.replaceWith(...f.childNodes)}for(;(s=xn.nextNode())!==null&&l.length<a;){if(s.nodeType===1){if(s.hasAttributes())for(const f of s.getAttributeNames())if(f.endsWith(pm)){const y=d[o++],m=s.getAttribute(f).split(Gt),E=/([.?@])?(.*)/.exec(y);l.push({type:1,index:i,name:E[2],strings:m,ctor:E[1]==="."?$R:E[1]==="?"?AR:E[1]==="@"?xR:Jo}),s.removeAttribute(f)}else f.startsWith(Gt)&&(l.push({type:6,index:i}),s.removeAttribute(f));if(mm.test(s.tagName)){const f=s.textContent.split(Gt),y=f.length-1;if(y>0){s.textContent=_o?_o.emptyScript:"";for(let m=0;m<y;m++)s.append(f[m],Ts()),xn.nextNode(),l.push({type:2,index:++i});s.append(f[y],Ts())}}}else if(s.nodeType===8)if(s.data===gm)l.push({type:2,index:i});else{let f=-1;for(;(f=s.data.indexOf(Gt,f+1))!==-1;)l.push({type:7,index:i}),f+=Gt.length-1}i++}}static createElement(e,n){const r=Wn.createElement("template");return r.innerHTML=e,r}}function Mr(t,e,n=t,r){var o,a;if(e===Lr)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=Mr(t,s._$AS(t,e.values),s,r)),e}class ER{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)??Wn).importNode(n,!0);xn.currentNode=s;let i=xn.nextNode(),o=0,a=0,l=r[0];for(;l!==void 0;){if(o===l.index){let c;l.type===2?c=new Zc(i,i.nextSibling,this,e):l.type===1?c=new l.ctor(i,l.name,l.strings,this,e):l.type===6&&(c=new CR(i,this,e)),this._$AV.push(c),l=r[++a]}o!==(l==null?void 0:l.index)&&(i=xn.nextNode(),o++)}return xn.currentNode=Wn,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 Zc=class ym{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=Mr(this,e,n),Is(e)?e===ge||e==null||e===""?(this._$AH!==ge&&this._$AR(),this._$AH=ge):e!==this._$AH&&e!==Lr&&this._(e):e._$litType$!==void 0?this.$(e):e.nodeType!==void 0?this.T(e):_R(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(Wn.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(vm(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 ER(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){Fc(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 ym(this.O(Ts()),this.O(Ts()),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))}},Jo=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=Mr(this,e,n,0),o=!Is(e)||e!==this._$AH&&e!==Lr,o&&(this._$AH=e);else{const a=e;let l,c;for(e=i[0],l=0;l<i.length-1;l++)c=Mr(this,a[r+l],n,l),c===Lr&&(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??"")}},$R=class extends Jo{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===ge?void 0:e}},AR=class extends Jo{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==ge)}},xR=class extends Jo{constructor(e,n,r,s,i){super(e,n,r,s,i),this.type=5}_$AI(e,n=this){if((e=Mr(this,e,n,0)??ge)===Lr)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 CR{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){Mr(this,e)}}const qa=As.litHtmlPolyfillSupport;qa==null||qa(Ps,Zc),(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 Zc(e.insertBefore(Ts(),null),null,void 0,{})),s._$AI(t),s};/**
50
50
  * @license
51
51
  * Copyright 2017 Google LLC
52
52
  * SPDX-License-Identifier: BSD-3-Clause
53
- */const RR={CHILD:2},bm=t=>(...e)=>({_$litDirective$:t,values:e});class DR{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)}}/**
53
+ */const TR={CHILD:2},bm=t=>(...e)=>({_$litDirective$:t,values:e});class IR{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
54
  * @license
55
55
  * Copyright 2017 Google LLC
56
56
  * SPDX-License-Identifier: BSD-3-Clause
57
- */class So extends DR{constructor(e){if(super(e),this.it=ge,e.type!==RR.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===Lr)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:[]}}}So.directiveName="unsafeHTML",So.resultType=1;const OR=bm(So);/**
57
+ */class So extends IR{constructor(e){if(super(e),this.it=ge,e.type!==TR.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===Lr)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:[]}}}So.directiveName="unsafeHTML",So.resultType=1;const PR=bm(So);/**
58
58
  * @license
59
59
  * Copyright 2017 Google LLC
60
60
  * SPDX-License-Identifier: BSD-3-Clause
61
- */class Tl extends So{}Tl.directiveName="unsafeSVG",Tl.resultType=2;const zR=bm(Tl),LR={size:16,color:"currentColor",weight:"regular"};function MR(t){return typeof t=="string"?{regular:t}:t}function vi(t,e="0 0 256 256"){const n=MR(t);return r=>{const{size:s,color:i,weight:o}={...LR,...r},a=n[o]??n.regular;return M`<svg
61
+ */class Pl extends So{}Pl.directiveName="unsafeSVG",Pl.resultType=2;const RR=bm(Pl),DR={size:16,color:"currentColor",weight:"regular"};function OR(t){return typeof t=="string"?{regular:t}:t}function Kr(t,e="0 0 256 256"){const n=OR(t);return r=>{const{size:s,color:i,weight:o}={...DR,...r},a=n[o]??n.regular;return M`<svg
62
62
  xmlns="http://www.w3.org/2000/svg"
63
63
  data-ui-icon=""
64
64
  width="${s}"
65
65
  height="${s}"
66
66
  viewBox="${e}"
67
67
  fill="${i}"
68
- >${zR(a)}</svg>`}}const wm=vi('<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"/>'),NR=vi('<path d="M216,56V200a16,16,0,0,1-16,16H56a16,16,0,0,1-16-16V56A16,16,0,0,1,56,40H200A16,16,0,0,1,216,56Z"/>'),UR=vi({regular:'<path d="M231.87,114l-168-95.89A16,16,0,0,0,40.92,37.34L71.55,128,40.92,218.67A16,16,0,0,0,56,240a16.15,16.15,0,0,0,7.93-2.1l167.92-96.05a16,16,0,0,0,.05-27.89ZM56,224a.56.56,0,0,0,0-.12L85.74,136H144a8,8,0,0,0,0-16H85.74L56.06,32.16A.46.46,0,0,0,56,32l168,95.83Z"/>',bold:'<path d="M233.86,110.48,65.8,14.58A20,20,0,0,0,37.15,38.64L67.33,128,37.15,217.36A20,20,0,0,0,56,244a20.1,20.1,0,0,0,9.81-2.58l.09-.06,168-96.07a20,20,0,0,0,0-34.81ZM63.19,215.26,88.61,140H144a12,12,0,0,0,0-24H88.61L63.18,40.72l152.76,87.17Z"/>'}),Cl=vi('<path d="M213.66,101.66l-80,80a8,8,0,0,1-11.32,0l-80-80A8,8,0,0,1,53.66,90.34L128,164.69l74.34-74.35a8,8,0,0,1,11.32,11.32Z"/>'),FR=vi('<path d="M128,80a48,48,0,1,0,48,48A48.05,48.05,0,0,0,128,80Zm0,80a32,32,0,1,1,32-32A32,32,0,0,1,128,160Zm88-29.84q.06-2.16,0-4.32l14.92-18.64a8,8,0,0,0,1.48-7.06,107.21,107.21,0,0,0-10.88-26.25,8,8,0,0,0-6-3.93l-23.72-2.64q-1.48-1.56-3-3L186,40.54a8,8,0,0,0-3.94-6,107.71,107.71,0,0,0-26.25-10.87,8,8,0,0,0-7.06,1.49L130.16,40Q128,40,125.84,40L107.2,25.11a8,8,0,0,0-7.06-1.48A107.6,107.6,0,0,0,73.89,34.51a8,8,0,0,0-3.93,6L67.32,64.27q-1.56,1.49-3,3L40.54,70a8,8,0,0,0-6,3.94,107.71,107.71,0,0,0-10.87,26.25,8,8,0,0,0,1.49,7.06L40,125.84Q40,128,40,130.16L25.11,148.8a8,8,0,0,0-1.48,7.06,107.21,107.21,0,0,0,10.88,26.25,8,8,0,0,0,6,3.93l23.72,2.64q1.49,1.56,3,3L70,215.46a8,8,0,0,0,3.94,6,107.71,107.71,0,0,0,26.25,10.87,8,8,0,0,0,7.06-1.49L125.84,216q2.16.06,4.32,0l18.64,14.92a8,8,0,0,0,7.06,1.48,107.21,107.21,0,0,0,26.25-10.88,8,8,0,0,0,3.93-6l2.64-23.72q1.56-1.48,3-3L215.46,186a8,8,0,0,0,6-3.94,107.71,107.71,0,0,0,10.87-26.25,8,8,0,0,0-1.49-7.06Zm-16.1-6.5a73.93,73.93,0,0,1,0,8.68,8,8,0,0,0,1.74,5.48l14.19,17.73a91.57,91.57,0,0,1-6.23,15L187,173.11a8,8,0,0,0-5.1,2.64,74.11,74.11,0,0,1-6.14,6.14,8,8,0,0,0-2.64,5.1l-2.51,22.58a91.32,91.32,0,0,1-15,6.23l-17.74-14.19a8,8,0,0,0-5-1.75h-.48a73.93,73.93,0,0,1-8.68,0,8,8,0,0,0-5.48,1.74L100.45,215.8a91.57,91.57,0,0,1-15-6.23L82.89,187a8,8,0,0,0-2.64-5.1,74.11,74.11,0,0,1-6.14-6.14,8,8,0,0,0-5.1-2.64L46.43,170.6a91.32,91.32,0,0,1-6.23-15l14.19-17.74a8,8,0,0,0,1.74-5.48,73.93,73.93,0,0,1,0-8.68,8,8,0,0,0-1.74-5.48L40.2,100.45a91.57,91.57,0,0,1,6.23-15L69,82.89a8,8,0,0,0,5.1-2.64,74.11,74.11,0,0,1,6.14-6.14A8,8,0,0,0,82.89,69L85.4,46.43a91.32,91.32,0,0,1,15-6.23l17.74,14.19a8,8,0,0,0,5.48,1.74,73.93,73.93,0,0,1,8.68,0,8,8,0,0,0,5.48-1.74L155.55,40.2a91.57,91.57,0,0,1,15,6.23L173.11,69a8,8,0,0,0,2.64,5.1,74.11,74.11,0,0,1,6.14,6.14,8,8,0,0,0,5.1,2.64l22.58,2.51a91.32,91.32,0,0,1,6.23,15l-14.19,17.74A8,8,0,0,0,199.87,123.66Z"/>');class _m extends Event{constructor(n){super("dropdown-item-select",{bubbles:!0,composed:!0});v(this,"value");this.value=n}}class ZR extends Event{constructor(n){super("select",{bubbles:!0,composed:!0});v(this,"value");this.value=n}}var Je,ot,en,$r,ne,Gs,z,km,ms,Em,$m,Il,Pl,so,_n,Ln,Hs,qs,Ys,Io,Am,xm,Rl,vs,Dl,Ct;class Sm extends HTMLElement{constructor(){super();x(this,z);x(this,Je,!1);x(this,ot,null);x(this,en,null);x(this,$r);x(this,ne,null);x(this,Gs,new MutationObserver(n=>b(this,z,Am).call(this,n)));x(this,Ln,()=>{b(this,z,so).call(this,!h(this,Je))});x(this,Hs,n=>{n.key!=="Enter"&&n.key!==" "||(n.preventDefault(),h(this,Ln).call(this))});x(this,qs,n=>{h(this,Je)&&(n.composedPath().includes(this)||b(this,z,so).call(this,!1))});x(this,Ys,n=>{n instanceof _m&&(n.stopPropagation(),$(this,Je,!1),b(this,z,ms).call(this,n.value),b(this,z,Ct).call(this),this.dispatchEvent(new ZR(n.value)))});x(this,Io,()=>{b(this,z,Rl).call(this)});$(this,$r,this.attachShadow({mode:"open"}))}connectedCallback(){this.addEventListener("dropdown-item-select",h(this,Ys)),document.addEventListener("click",h(this,qs),!0),b(this,z,km).call(this),h(this,Gs).observe(this,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["selected","value","slot"]}),b(this,z,Ct).call(this)}disconnectedCallback(){this.removeEventListener("dropdown-item-select",h(this,Ys)),document.removeEventListener("click",h(this,qs),!0),h(this,Gs).disconnect(),b(this,z,Dl).call(this)}attributeChangedCallback(){b(this,z,Ct).call(this)}get title(){return this.getAttribute("title")??""}get value(){return h(this,ot)}set value(n){n===null?(b(this,z,_n).call(this,null,null),b(this,z,Em).call(this)):b(this,z,ms).call(this,n),b(this,z,Ct).call(this)}close(){b(this,z,so).call(this,!1)}}Je=new WeakMap,ot=new WeakMap,en=new WeakMap,$r=new WeakMap,ne=new WeakMap,Gs=new WeakMap,z=new WeakSet,km=function(){var r;const n=this.querySelector("dropdown-item[selected]");n&&b(this,z,_n).call(this,n.value,((r=n.textContent)==null?void 0:r.trim())??null)},ms=function(n){var r;for(const s of h(this,z,Il))s.value===n?(b(this,z,_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 h(this,z,Il))if(r.value===n)return r;return null},Il=function(){return this.querySelectorAll("dropdown-item")},Pl=function(){return h(this,en)??this.title},so=function(n){h(this,Je)!==n&&($(this,Je,n),b(this,z,Ct).call(this))},_n=function(n,r){$(this,ot,n),$(this,en,r)},Ln=new WeakMap,Hs=new WeakMap,qs=new WeakMap,Ys=new WeakMap,Io=new WeakMap,Am=function(n){n.every(s=>s.target instanceof Element?s.target.closest('[slot="trigger"]')!==null:!1)||b(this,z,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=h(this,ot)!==i||h(this,en)!==o;b(this,z,_n).call(this,i,o),b(this,z,ms).call(this,i),a?b(this,z,Ct).call(this):b(this,z,vs).call(this);return}if(h(this,ot)!==null){const i=b(this,z,$m).call(this,h(this,ot));if(i){const o=((s=i.textContent)==null?void 0:s.trim())??null,a=h(this,en)!==o;b(this,z,_n).call(this,h(this,ot),o),b(this,z,ms).call(this,h(this,ot)),a?b(this,z,Ct).call(this):b(this,z,vs).call(this);return}}if(h(this,ot)!==null||h(this,en)!==null){b(this,z,_n).call(this,null,null),b(this,z,Ct).call(this);return}b(this,z,vs).call(this)},Rl=function(){const n=h(this,$r).querySelector('slot[name="trigger"]'),r=n instanceof HTMLSlotElement?n.assignedElements()[0]??null:null;h(this,ne)!==r&&(b(this,z,Dl).call(this),$(this,ne,r),h(this,ne)&&(h(this,ne).addEventListener("click",h(this,Ln)),h(this,ne)instanceof HTMLButtonElement?h(this,ne).hasAttribute("type")||(h(this,ne).type="button"):(h(this,ne).hasAttribute("role")||h(this,ne).setAttribute("role","button"),h(this,ne).hasAttribute("tabindex")||(h(this,ne).tabIndex=0),h(this,ne).addEventListener("keydown",h(this,Hs))))),b(this,z,vs).call(this)},vs=function(){h(this,ne)&&(h(this,ne).setAttribute("data-dropdown-trigger",""),h(this,ne).setAttribute("aria-haspopup","listbox"),h(this,ne).setAttribute("aria-expanded",h(this,Je)?"true":"false"),be(M`
69
- <span class="trigger-label" data-dropdown-trigger-label>${h(this,z,Pl)}</span>
68
+ >${RR(a)}</svg>`}}const zR=Kr('<path fill="none" stroke="currentColor" stroke-width="1" vector-effect="non-scaling-stroke" 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="1" vector-effect="non-scaling-stroke" stroke-linecap="round" stroke-linejoin="round" d="M152 32V88H208"/><path fill="none" stroke="currentColor" stroke-width="1" vector-effect="non-scaling-stroke" stroke-linecap="round" d="M80 88H124.5"/><path fill="none" stroke="currentColor" stroke-width="1" vector-effect="non-scaling-stroke" stroke-linecap="round" d="M80 128H175"/><path fill="none" stroke="currentColor" stroke-width="1" vector-effect="non-scaling-stroke" stroke-linecap="round" d="M80 169H175"/>'),wm=Kr('<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"/>'),LR=Kr('<path d="M216,56V200a16,16,0,0,1-16,16H56a16,16,0,0,1-16-16V56A16,16,0,0,1,56,40H200A16,16,0,0,1,216,56Z"/>'),MR=Kr({regular:'<path d="M231.87,114l-168-95.89A16,16,0,0,0,40.92,37.34L71.55,128,40.92,218.67A16,16,0,0,0,56,240a16.15,16.15,0,0,0,7.93-2.1l167.92-96.05a16,16,0,0,0,.05-27.89ZM56,224a.56.56,0,0,0,0-.12L85.74,136H144a8,8,0,0,0,0-16H85.74L56.06,32.16A.46.46,0,0,0,56,32l168,95.83Z"/>',bold:'<path d="M233.86,110.48,65.8,14.58A20,20,0,0,0,37.15,38.64L67.33,128,37.15,217.36A20,20,0,0,0,56,244a20.1,20.1,0,0,0,9.81-2.58l.09-.06,168-96.07a20,20,0,0,0,0-34.81ZM63.19,215.26,88.61,140H144a12,12,0,0,0,0-24H88.61L63.18,40.72l152.76,87.17Z"/>'}),Rl=Kr('<path d="M213.66,101.66l-80,80a8,8,0,0,1-11.32,0l-80-80A8,8,0,0,1,53.66,90.34L128,164.69l74.34-74.35a8,8,0,0,1,11.32,11.32Z"/>'),NR=Kr('<path d="M128,80a48,48,0,1,0,48,48A48.05,48.05,0,0,0,128,80Zm0,80a32,32,0,1,1,32-32A32,32,0,0,1,128,160Zm88-29.84q.06-2.16,0-4.32l14.92-18.64a8,8,0,0,0,1.48-7.06,107.21,107.21,0,0,0-10.88-26.25,8,8,0,0,0-6-3.93l-23.72-2.64q-1.48-1.56-3-3L186,40.54a8,8,0,0,0-3.94-6,107.71,107.71,0,0,0-26.25-10.87,8,8,0,0,0-7.06,1.49L130.16,40Q128,40,125.84,40L107.2,25.11a8,8,0,0,0-7.06-1.48A107.6,107.6,0,0,0,73.89,34.51a8,8,0,0,0-3.93,6L67.32,64.27q-1.56,1.49-3,3L40.54,70a8,8,0,0,0-6,3.94,107.71,107.71,0,0,0-10.87,26.25,8,8,0,0,0,1.49,7.06L40,125.84Q40,128,40,130.16L25.11,148.8a8,8,0,0,0-1.48,7.06,107.21,107.21,0,0,0,10.88,26.25,8,8,0,0,0,6,3.93l23.72,2.64q1.49,1.56,3,3L70,215.46a8,8,0,0,0,3.94,6,107.71,107.71,0,0,0,26.25,10.87,8,8,0,0,0,7.06-1.49L125.84,216q2.16.06,4.32,0l18.64,14.92a8,8,0,0,0,7.06,1.48,107.21,107.21,0,0,0,26.25-10.88,8,8,0,0,0,3.93-6l2.64-23.72q1.56-1.48,3-3L215.46,186a8,8,0,0,0,6-3.94,107.71,107.71,0,0,0,10.87-26.25,8,8,0,0,0-1.49-7.06Zm-16.1-6.5a73.93,73.93,0,0,1,0,8.68,8,8,0,0,0,1.74,5.48l14.19,17.73a91.57,91.57,0,0,1-6.23,15L187,173.11a8,8,0,0,0-5.1,2.64,74.11,74.11,0,0,1-6.14,6.14,8,8,0,0,0-2.64,5.1l-2.51,22.58a91.32,91.32,0,0,1-15,6.23l-17.74-14.19a8,8,0,0,0-5-1.75h-.48a73.93,73.93,0,0,1-8.68,0,8,8,0,0,0-5.48,1.74L100.45,215.8a91.57,91.57,0,0,1-15-6.23L82.89,187a8,8,0,0,0-2.64-5.1,74.11,74.11,0,0,1-6.14-6.14,8,8,0,0,0-5.1-2.64L46.43,170.6a91.32,91.32,0,0,1-6.23-15l14.19-17.74a8,8,0,0,0,1.74-5.48,73.93,73.93,0,0,1,0-8.68,8,8,0,0,0-1.74-5.48L40.2,100.45a91.57,91.57,0,0,1,6.23-15L69,82.89a8,8,0,0,0,5.1-2.64,74.11,74.11,0,0,1,6.14-6.14A8,8,0,0,0,82.89,69L85.4,46.43a91.32,91.32,0,0,1,15-6.23l17.74,14.19a8,8,0,0,0,5.48,1.74,73.93,73.93,0,0,1,8.68,0,8,8,0,0,0,5.48-1.74L155.55,40.2a91.57,91.57,0,0,1,15,6.23L173.11,69a8,8,0,0,0,2.64,5.1,74.11,74.11,0,0,1,6.14,6.14,8,8,0,0,0,5.1,2.64l22.58,2.51a91.32,91.32,0,0,1,6.23,15l-14.19,17.74A8,8,0,0,0,199.87,123.66Z"/>');class _m extends Event{constructor(n){super("dropdown-item-select",{bubbles:!0,composed:!0});v(this,"value");this.value=n}}class UR extends Event{constructor(n){super("select",{bubbles:!0,composed:!0});v(this,"value");this.value=n}}var Je,ot,en,$r,ne,Hs,z,km,vs,Em,$m,Dl,Ol,so,_n,Ln,qs,Ys,Ks,Io,Am,xm,zl,ys,Ll,Tt;class Sm extends HTMLElement{constructor(){super();x(this,z);x(this,Je,!1);x(this,ot,null);x(this,en,null);x(this,$r);x(this,ne,null);x(this,Hs,new MutationObserver(n=>b(this,z,Am).call(this,n)));x(this,Ln,()=>{b(this,z,so).call(this,!h(this,Je))});x(this,qs,n=>{n.key!=="Enter"&&n.key!==" "||(n.preventDefault(),h(this,Ln).call(this))});x(this,Ys,n=>{h(this,Je)&&(n.composedPath().includes(this)||b(this,z,so).call(this,!1))});x(this,Ks,n=>{n instanceof _m&&(n.stopPropagation(),$(this,Je,!1),b(this,z,vs).call(this,n.value),b(this,z,Tt).call(this),this.dispatchEvent(new UR(n.value)))});x(this,Io,()=>{b(this,z,zl).call(this)});$(this,$r,this.attachShadow({mode:"open"}))}connectedCallback(){this.addEventListener("dropdown-item-select",h(this,Ks)),document.addEventListener("click",h(this,Ys),!0),b(this,z,km).call(this),h(this,Hs).observe(this,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["selected","value","slot"]}),b(this,z,Tt).call(this)}disconnectedCallback(){this.removeEventListener("dropdown-item-select",h(this,Ks)),document.removeEventListener("click",h(this,Ys),!0),h(this,Hs).disconnect(),b(this,z,Ll).call(this)}attributeChangedCallback(){b(this,z,Tt).call(this)}get title(){return this.getAttribute("title")??""}get value(){return h(this,ot)}set value(n){n===null?(b(this,z,_n).call(this,null,null),b(this,z,Em).call(this)):b(this,z,vs).call(this,n),b(this,z,Tt).call(this)}close(){b(this,z,so).call(this,!1)}}Je=new WeakMap,ot=new WeakMap,en=new WeakMap,$r=new WeakMap,ne=new WeakMap,Hs=new WeakMap,z=new WeakSet,km=function(){var r;const n=this.querySelector("dropdown-item[selected]");n&&b(this,z,_n).call(this,n.value,((r=n.textContent)==null?void 0:r.trim())??null)},vs=function(n){var r;for(const s of h(this,z,Dl))s.value===n?(b(this,z,_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 h(this,z,Dl))if(r.value===n)return r;return null},Dl=function(){return this.querySelectorAll("dropdown-item")},Ol=function(){return h(this,en)??this.title},so=function(n){h(this,Je)!==n&&($(this,Je,n),b(this,z,Tt).call(this))},_n=function(n,r){$(this,ot,n),$(this,en,r)},Ln=new WeakMap,qs=new WeakMap,Ys=new WeakMap,Ks=new WeakMap,Io=new WeakMap,Am=function(n){n.every(s=>s.target instanceof Element?s.target.closest('[slot="trigger"]')!==null:!1)||b(this,z,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=h(this,ot)!==i||h(this,en)!==o;b(this,z,_n).call(this,i,o),b(this,z,vs).call(this,i),a?b(this,z,Tt).call(this):b(this,z,ys).call(this);return}if(h(this,ot)!==null){const i=b(this,z,$m).call(this,h(this,ot));if(i){const o=((s=i.textContent)==null?void 0:s.trim())??null,a=h(this,en)!==o;b(this,z,_n).call(this,h(this,ot),o),b(this,z,vs).call(this,h(this,ot)),a?b(this,z,Tt).call(this):b(this,z,ys).call(this);return}}if(h(this,ot)!==null||h(this,en)!==null){b(this,z,_n).call(this,null,null),b(this,z,Tt).call(this);return}b(this,z,ys).call(this)},zl=function(){const n=h(this,$r).querySelector('slot[name="trigger"]'),r=n instanceof HTMLSlotElement?n.assignedElements()[0]??null:null;h(this,ne)!==r&&(b(this,z,Ll).call(this),$(this,ne,r),h(this,ne)&&(h(this,ne).addEventListener("click",h(this,Ln)),h(this,ne)instanceof HTMLButtonElement?h(this,ne).hasAttribute("type")||(h(this,ne).type="button"):(h(this,ne).hasAttribute("role")||h(this,ne).setAttribute("role","button"),h(this,ne).hasAttribute("tabindex")||(h(this,ne).tabIndex=0),h(this,ne).addEventListener("keydown",h(this,qs))))),b(this,z,ys).call(this)},ys=function(){h(this,ne)&&(h(this,ne).setAttribute("data-dropdown-trigger",""),h(this,ne).setAttribute("aria-haspopup","listbox"),h(this,ne).setAttribute("aria-expanded",h(this,Je)?"true":"false"),be(M`
69
+ <span class="trigger-label" data-dropdown-trigger-label>${h(this,z,Ol)}</span>
70
70
  <span class="trigger-icon" data-dropdown-trigger-icon aria-hidden="true">
71
- ${Cl({size:14})}
71
+ ${Rl({size:14})}
72
72
  </span>
73
- `,h(this,ne)))},Dl=function(){h(this,ne)&&(h(this,ne).removeEventListener("click",h(this,Ln)),h(this,ne).removeEventListener("keydown",h(this,Hs)),h(this,ne).removeAttribute("data-dropdown-trigger"),h(this,ne).removeAttribute("aria-haspopup"),h(this,ne).removeAttribute("aria-expanded"),$(this,ne,null))},Ct=function(){this.toggleAttribute("open",h(this,Je)),be(M`
73
+ `,h(this,ne)))},Ll=function(){h(this,ne)&&(h(this,ne).removeEventListener("click",h(this,Ln)),h(this,ne).removeEventListener("keydown",h(this,qs)),h(this,ne).removeAttribute("data-dropdown-trigger"),h(this,ne).removeAttribute("aria-haspopup"),h(this,ne).removeAttribute("aria-expanded"),$(this,ne,null))},Tt=function(){this.toggleAttribute("open",h(this,Je)),be(M`
74
74
  <slot name="trigger" @slotchange=${h(this,Io)}>
75
75
  <button
76
76
  class="fallback-trigger"
@@ -80,9 +80,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
80
80
  aria-expanded=${h(this,Je)?"true":"false"}
81
81
  @click=${h(this,Ln)}
82
82
  >
83
- <span class="trigger-label" part="trigger-label">${h(this,z,Pl)}</span>
83
+ <span class="trigger-label" part="trigger-label">${h(this,z,Ol)}</span>
84
84
  <span class="trigger-icon" part="trigger-icon" aria-hidden="true">
85
- ${Cl({size:14})}
85
+ ${Rl({size:14})}
86
86
  </span>
87
87
  </button>
88
88
  </slot>
@@ -91,13 +91,13 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
91
91
  <slot></slot>
92
92
  </div>
93
93
  `:null}
94
- `,h(this,$r)),queueMicrotask(()=>b(this,z,Rl).call(this))},v(Sm,"observedAttributes",["title"]);class jR extends HTMLElement{}class WR extends HTMLElement{}class BR extends HTMLElement{}var Gn,Ol,Cm,Ks,Js;class Tm extends HTMLElement{constructor(){super(...arguments);x(this,Gn);x(this,Ks,()=>{this.action||b(this,Gn,Cm).call(this)});x(this,Js,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",h(this,Ks)),this.addEventListener("keydown",h(this,Js)),b(this,Gn,Ol).call(this)}disconnectedCallback(){this.removeEventListener("click",h(this,Ks)),this.removeEventListener("keydown",h(this,Js))}attributeChangedCallback(){b(this,Gn,Ol).call(this)}get value(){return this.getAttribute("value")??""}get selected(){return this.hasAttribute("selected")}get action(){return this.hasAttribute("action")}}Gn=new WeakSet,Ol=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))},Ks=new WeakMap,Js=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",jR);customElements.get("dropdown-label")||customElements.define("dropdown-label",WR);customElements.get("dropdown-divider")||customElements.define("dropdown-divider",BR);customElements.get("dropdown-item")||customElements.define("dropdown-item",Tm);class VR extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}var Xs,un,zl,Po,Qs,Ll;class Im extends HTMLElement{constructor(){super();x(this,un);x(this,Xs);x(this,Po,n=>{n.target===n.currentTarget&&b(this,un,zl).call(this)});x(this,Qs,n=>{this.open&&n.key==="Escape"&&b(this,un,zl).call(this)});$(this,Xs,this.attachShadow({mode:"open"}))}connectedCallback(){document.addEventListener("keydown",h(this,Qs)),b(this,un,Ll).call(this)}disconnectedCallback(){document.removeEventListener("keydown",h(this,Qs))}attributeChangedCallback(){b(this,un,Ll).call(this)}get open(){return this.hasAttribute("open")}}Xs=new WeakMap,un=new WeakSet,zl=function(){this.dispatchEvent(new VR)},Po=new WeakMap,Qs=new WeakMap,Ll=function(){be(M`
94
+ `,h(this,$r)),queueMicrotask(()=>b(this,z,zl).call(this))},v(Sm,"observedAttributes",["title"]);class FR extends HTMLElement{}class ZR extends HTMLElement{}class jR extends HTMLElement{}var Gn,Ml,Tm,Js,Xs;class Cm extends HTMLElement{constructor(){super(...arguments);x(this,Gn);x(this,Js,()=>{this.action||b(this,Gn,Tm).call(this)});x(this,Xs,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",h(this,Js)),this.addEventListener("keydown",h(this,Xs)),b(this,Gn,Ml).call(this)}disconnectedCallback(){this.removeEventListener("click",h(this,Js)),this.removeEventListener("keydown",h(this,Xs))}attributeChangedCallback(){b(this,Gn,Ml).call(this)}get value(){return this.getAttribute("value")??""}get selected(){return this.hasAttribute("selected")}get action(){return this.hasAttribute("action")}}Gn=new WeakSet,Ml=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")},Tm=function(){this.dispatchEvent(new _m(this.value))},Js=new WeakMap,Xs=new WeakMap,v(Cm,"observedAttributes",["action","selected","value"]);customElements.get("dropdown-menu")||customElements.define("dropdown-menu",Sm);customElements.get("dropdown-group")||customElements.define("dropdown-group",FR);customElements.get("dropdown-label")||customElements.define("dropdown-label",ZR);customElements.get("dropdown-divider")||customElements.define("dropdown-divider",jR);customElements.get("dropdown-item")||customElements.define("dropdown-item",Cm);class WR extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}var Qs,un,Nl,Po,ei,Ul;class Im extends HTMLElement{constructor(){super();x(this,un);x(this,Qs);x(this,Po,n=>{n.target===n.currentTarget&&b(this,un,Nl).call(this)});x(this,ei,n=>{this.open&&n.key==="Escape"&&b(this,un,Nl).call(this)});$(this,Qs,this.attachShadow({mode:"open"}))}connectedCallback(){document.addEventListener("keydown",h(this,ei)),b(this,un,Ul).call(this)}disconnectedCallback(){document.removeEventListener("keydown",h(this,ei))}attributeChangedCallback(){b(this,un,Ul).call(this)}get open(){return this.hasAttribute("open")}}Qs=new WeakMap,un=new WeakSet,Nl=function(){this.dispatchEvent(new WR)},Po=new WeakMap,ei=new WeakMap,Ul=function(){be(M`
95
95
  ${this.open?M`
96
96
  <div class="backdrop" part="backdrop" @click=${h(this,Po)}>
97
97
  <slot></slot>
98
98
  </div>
99
99
  `:null}
100
- `,h(this,Xs))},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 GR extends HTMLElement{}var ei,ti,Ml;class Rm extends HTMLElement{constructor(){super();x(this,ti);x(this,ei);$(this,ei,this.attachShadow({mode:"open"}))}connectedCallback(){b(this,ti,Ml).call(this)}attributeChangedCallback(){b(this,ti,Ml).call(this)}get closable(){return this.hasAttribute("closable")}}ei=new WeakMap,ti=new WeakSet,Ml=function(){const n=this.querySelector("panel-page");be(M`
100
+ `,h(this,Qs))},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 BR extends HTMLElement{}var ti,ni,Fl;class Rm extends HTMLElement{constructor(){super();x(this,ni);x(this,ti);$(this,ti,this.attachShadow({mode:"open"}))}connectedCallback(){b(this,ni,Fl).call(this)}attributeChangedCallback(){b(this,ni,Fl).call(this)}get closable(){return this.hasAttribute("closable")}}ti=new WeakMap,ni=new WeakSet,Fl=function(){const n=this.querySelector("panel-page");be(M`
101
101
  <section class="panel" part="panel">
102
102
  <header class="title-bar" part="header">
103
103
  <h2 class="title" part="title">${(n==null?void 0:n.getAttribute("title"))??""}</h2>
@@ -115,8 +115,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
115
115
  </header>
116
116
  <slot></slot>
117
117
  </section>
118
- `,h(this,ei))},v(Rm,"observedAttributes",["closable"]);customElements.get("panel-view")||customElements.define("panel-view",Rm);customElements.get("panel-page")||customElements.define("panel-page",GR);const HR=Be(),qR="No handler registered for update-content",YR="handleUpdateContent: handler already registered";function KR(t){return t instanceof Error&&typeof t.message=="string"?t.message:String(t)}const JR=Gr(kt);var Ar,xr,Tr,Mn,Nn,ni,Ce,Nl,Dm,Om,ys,Ul,uf;let XR=(uf=class extends JR{constructor(n){super();x(this,Ce);x(this,Ar);x(this,xr);x(this,Tr);x(this,Mn,null);x(this,Nn,null);x(this,ni,!1);$(this,Ar,n);const r=n.ownerDocument.defaultView;if(!r)throw new Error("ArtifactView: iframe has no owner window");$(this,xr,r),$(this,Tr,s=>b(this,Ce,Dm).call(this,s)),h(this,xr).addEventListener("message",h(this,Tr))}get content(){return h(this,Nn)}set content(n){b(this,Ce,Ul).call(this),$(this,Nn,n),h(this,ni)&&b(this,Ce,Nl).call(this,n)}handleUpdateContent(n){if(b(this,Ce,Ul).call(this),h(this,Mn)!==null)throw new Error(YR);$(this,Mn,n)}dispose(){h(this,xr).removeEventListener("message",h(this,Tr)),$(this,Mn,null)}},Ar=new WeakMap,xr=new WeakMap,Tr=new WeakMap,Mn=new WeakMap,Nn=new WeakMap,ni=new WeakMap,Ce=new WeakSet,Nl=function(n){const r={type:"content-updated",content:n};b(this,Ce,ys).call(this,r)},Dm=function(n){if(this.disposed||n.source!==h(this,Ar).contentWindow)return;const r=n.data;if(AT(r)){$(this,ni,!0),this.dispatchEvent(new HR("ready")),h(this,Nn)!==null&&b(this,Ce,Nl).call(this,h(this,Nn));return}if(xT(r)){b(this,Ce,Om).call(this,r);return}},Om=async function(n){const r=h(this,Mn);if(r===null){b(this,Ce,ys).call(this,{type:"response",id:n.id,error:{message:qR}});return}try{await r(n.content)}catch(s){if(this.disposed)return;b(this,Ce,ys).call(this,{type:"response",id:n.id,error:{message:KR(s)}});return}this.disposed||b(this,Ce,ys).call(this,{type:"response",id:n.id,result:{}})},ys=function(n){const r=h(this,Ar).contentWindow;r&&r.postMessage(n,"*")},Ul=function(){if(this.disposed)throw new Error("ArtifactView is disposed")},uf);function QR(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 e1(){return`(${QR.toString()})(window);`}async function t1(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=e1(),r.head.appendChild(i);const o=new Blob([`<!DOCTYPE html>
119
- ${r.documentElement.outerHTML}`],{type:"text/html"});return URL.createObjectURL(o)}const zm=Be();class n1 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}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 XR(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 t1(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`
118
+ `,h(this,ti))},v(Rm,"observedAttributes",["closable"]);customElements.get("panel-view")||customElements.define("panel-view",Rm);customElements.get("panel-page")||customElements.define("panel-page",BR);const VR=Be(),GR="No handler registered for update-content",HR="handleUpdateContent: handler already registered";function qR(t){return t instanceof Error&&typeof t.message=="string"?t.message:String(t)}const YR=Gr(kt);var Ar,xr,Cr,Mn,Nn,ri,Te,Zl,Dm,Om,bs,jl,df;let KR=(df=class extends YR{constructor(n){super();x(this,Te);x(this,Ar);x(this,xr);x(this,Cr);x(this,Mn,null);x(this,Nn,null);x(this,ri,!1);$(this,Ar,n);const r=n.ownerDocument.defaultView;if(!r)throw new Error("ArtifactView: iframe has no owner window");$(this,xr,r),$(this,Cr,s=>b(this,Te,Dm).call(this,s)),h(this,xr).addEventListener("message",h(this,Cr))}get content(){return h(this,Nn)}set content(n){b(this,Te,jl).call(this),$(this,Nn,n),h(this,ri)&&b(this,Te,Zl).call(this,n)}handleUpdateContent(n){if(b(this,Te,jl).call(this),h(this,Mn)!==null)throw new Error(HR);$(this,Mn,n)}dispose(){h(this,xr).removeEventListener("message",h(this,Cr)),$(this,Mn,null)}},Ar=new WeakMap,xr=new WeakMap,Cr=new WeakMap,Mn=new WeakMap,Nn=new WeakMap,ri=new WeakMap,Te=new WeakSet,Zl=function(n){const r={type:"content-updated",content:n};b(this,Te,bs).call(this,r)},Dm=function(n){if(this.disposed||n.source!==h(this,Ar).contentWindow)return;const r=n.data;if(kC(r)){$(this,ri,!0),this.dispatchEvent(new VR("ready")),h(this,Nn)!==null&&b(this,Te,Zl).call(this,h(this,Nn));return}if(EC(r)){b(this,Te,Om).call(this,r);return}},Om=async function(n){const r=h(this,Mn);if(r===null){b(this,Te,bs).call(this,{type:"response",id:n.id,error:{message:GR}});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:qR(s)}});return}this.disposed||b(this,Te,bs).call(this,{type:"response",id:n.id,result:{}})},bs=function(n){const r=h(this,Ar).contentWindow;r&&r.postMessage(n,"*")},jl=function(){if(this.disposed)throw new Error("ArtifactView is disposed")},df);function JR(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 XR(){return`(${JR.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=XR(),r.head.appendChild(i);const o=new Blob([`<!DOCTYPE html>
119
+ ${r.documentElement.outerHTML}`],{type:"text/html"});return URL.createObjectURL(o)}const zm=Be();class e1 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 KR(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`
120
120
  <div class="artifact-content artifact-placeholder">
121
121
  <em>Failed to load content</em>
122
122
  </div>
@@ -131,8 +131,12 @@ ${r.documentElement.outerHTML}`],{type:"text/html"});return URL.createObjectURL(
131
131
  <em>Artifact unavailable</em>
132
132
  </div>
133
133
  `}template(){const n=this._artifact;return M`
134
- <header class="artifact-title-bar" drag-handle>
135
- <span class="artifact-title">${n.title}</span>
134
+ ${this.contentTemplate()}
135
+ <footer class="artifact-title-bar" drag-handle>
136
+ <div class="artifact-title-group">
137
+ <span class="artifact-title-icon">${zR({size:16})}</span>
138
+ <span class="artifact-title">${n.title}</span>
139
+ </div>
136
140
  <button
137
141
  class="artifact-close-btn"
138
142
  @click=${()=>this.handleClose()}
@@ -140,9 +144,8 @@ ${r.documentElement.outerHTML}`],{type:"text/html"});return URL.createObjectURL(
140
144
  >
141
145
  ${wm({size:14})}
142
146
  </button>
143
- </header>
144
- ${this.contentTemplate()}
145
- `}render(){this._artifact&&(this.setAttribute("type",this._artifact.type),be(this.template(),this))}}customElements.define("artifact-view",n1);const Se=t=>({type:"px",...t}),Te=t=>({type:"unit",...t}),Zi=2,r1=2;class s1{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??nn,r=this._viewport.y??mr,s=this._gap.x??de,i=this._gap.y??de,o=nn+s*r1,a=n<=o,l=a?n-s*Zi:Math.min(nn,n-s*Zi),c=a?r-i*Zi:Math.min(mr,r-i*Zi),d=(l-s*(St-1))/St,f=(c-i*(Ke-1))/Ke,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,f)}:{x:Math.max(E,Math.min(y,d)),y:Math.max(k,Math.min(m,f))})}get unit(){return this._unit}get viewport(){return this._viewport}get gap(){return this._gap}toUnits(e){return Te({x:e.x==null?void 0:e.x/(this._unit.x??1),y:e.y==null?void 0:e.y/(this._unit.y??1)})}toPixels(e){const 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 Bn=1e-4,Ut=1e-6,i1=40,o1=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+Bn)break;r=a,s+=1}return Math.max(1,s)}function a1(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+Bn)break;r=a,s+=1}return Math.max(1,s)}function l1(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+Bn)break;n=o,r+=1}return Math.max(1,r)}function Uc(t,e){if(t.length===0)return 0;const n=l1(t,e);return Math.max(0,t.length-n)}function Rd(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 Fl(t,e,n){const r=t[e]??0;return n-r}function fr(t,e,n,r,s){if(t.length===0)return 0;const i=Uc(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+Bn){l=L;break}l=L+1}const c=Math.min(l+1,i),d=e[l]??0,f=e[c]??d,y=Math.max(f-d,Bn),m=c===l?0:(a-d)/y,E=Nm(t),k=Rd(t,l,s),I=Rd(t,c,s),V=(r-k)/2,N=(r-I)/2,j=Fl(E,l,V),F=Fl(E,c,N);return j+(F-j)*m}function Dd(t,e,n,r,s){const i=Uc(t,r),o=e[i]??0;let a=0,l=o;for(let c=0;c<i1;c+=1){const d=(a+l)/2;fr(t,e,d,n,r)>s?a=d:l=d}return(a+l)/2}function Od(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 Fl(r,s,l)}function c1(t,e,n){const r=Um(t,e,n);return[e,Math.min(t.length-1,e+r-1)]}function u1(t,e,n){const r=a1(t,e,n);return[Math.max(0,e-r+1),e]}function h1(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)<=Ut||(e.add(s),n.push(r))}return n}function d1(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=Uc(n,i),l=o[a]??0,c=[];for(let d=0;d<=a;d+=1){const f=c1(n,d,i),y=Od(n,f,r),m=Dd(n,o,r,i,y);c.push({nodeRange:f,anchor:Math.max(0,Math.min(l,m))})}for(let d=n.length-1;d>=0;d-=1){const f=u1(n,d,i),y=`${f[0]}:${f[1]}`;if(c.some(k=>`${k.nodeRange[0]}:${k.nodeRange[1]}`===y))continue;const m=Od(n,f,r),E=Dd(n,o,r,i,m);c.push({nodeRange:f,anchor:Math.max(0,Math.min(l,E))})}return c.sort((d,f)=>Math.abs(d.anchor-f.anchor)>Ut?d.anchor-f.anchor:d.nodeRange[0]!==f.nodeRange[0]?d.nodeRange[0]-f.nodeRange[0]:d.nodeRange[1]-f.nodeRange[1]),{viewspans:h1(c),minScroll:0,maxScroll:l}}function f1(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+Ut<r){r=o,n=i;continue}Math.abs(o-r)<=Ut&&i<n&&(n=i)}return n}function p1(t,e,n){return n<=0?0:Math.max(0,Math.min(n-1,t+e))}function is(t,e,n){return Math.max(e,Math.min(n,t))}class g1 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 Te({x:this._scroll})}get translate(){return Se({x:fr(this.nodeWidthsPx,this.boundaryCols,this._scroll,this.viewportWidthPx,this.framedViewportWidthPx)})}set scroll(n){const r=is(n.x??this._scroll,this.minScroll,this.maxScroll);Math.abs(r-this._scroll)<=Ut||(this._scroll=r,this.activeViewspanIndex=null,this.dispatchEvent(new rs("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(Te({x:c})).x??0),i=n.grid.viewport.x??0,o=n.grid.gap.x??de,a=d1({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=is(this._scroll,this.minScroll,this.maxScroll);Math.abs(l-this._scroll)>Ut&&(this._scroll=l,this.dispatchEvent(new rs("layout-scroll",{scroll:this.scroll})))}step(n){var a;if(this.viewspans.length===0)return;const r=this.activeViewspanIndex??f1(this.viewspans,this._scroll),s=p1(r,n,this.viewspans.length),i=((a=this.viewspans[s])==null?void 0:a.anchor)??this._scroll,o=is(i,this.minScroll,this.maxScroll);this.activeViewspanIndex=s,!(Math.abs(o-this._scroll)<=Ut)&&(this._scroll=o,this.dispatchEvent(new rs("layout-scroll",{scroll:this.scroll})))}wheel(n){const r=is(this._scroll+(n.x??0),this.minScroll,this.maxScroll);this.activeViewspanIndex=null,!(Math.abs(r-this._scroll)<=Ut)&&(this._scroll=r,this.dispatchEvent(new rs("layout-scroll",{scroll:this.scroll})))}wheelPixels(n){const r=n.x??0;if(Math.abs(r)<=Bn)return;this.activeViewspanIndex=null;const s=fr(this.nodeWidthsPx,this.boundaryCols,this._scroll,this.viewportWidthPx,this.framedViewportWidthPx),i=s-r,o=fr(this.nodeWidthsPx,this.boundaryCols,this.maxScroll,this.viewportWidthPx,this.framedViewportWidthPx),a=fr(this.nodeWidthsPx,this.boundaryCols,this.minScroll,this.viewportWidthPx,this.framedViewportWidthPx),l=Math.max(o,Math.min(a,i));if(Math.abs(l-s)<=Bn)return;let c=this.minScroll,d=this.maxScroll;for(let y=0;y<o1;y+=1){const m=(c+d)/2;fr(this.nodeWidthsPx,this.boundaryCols,m,this.viewportWidthPx,this.framedViewportWidthPx)>l?c=m:d=m}const f=is((c+d)/2,this.minScroll,this.maxScroll);Math.abs(f-this._scroll)<=Ut||(this._scroll=f,this.dispatchEvent(new rs("layout-scroll",{scroll:this.scroll})))}}const Ga={"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}},m1=["stack-above","stack-below","reorder-before","reorder-after"];function Ha(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 Fc(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 Zl(t){return t.height===Ke||t.height===on?{...t,height:on}:t}function jl(t){return t.height===on?{...t,height:Ke}:t}function v1(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"?jl(d):d}else l[s]={...i,children:a};const c=Math.max(0,Math.min(r,l.length));return l.splice(c,0,jl(o)),l}const y1=Be(),b1=Be(),w1=50;function _1(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 zd(t){return t.map(k1)}function S1(t){return t.type==="drop-target"?{id:t.id,type:"card",artifactID:t.id,width:t.width,height:t.height}:t}function k1(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(S1)}:t}function Fm(t,e){return t.find(r=>r.type==="card"&&r.id===e)??null}function Ld(t,e){return t.find(r=>r.type==="stack"&&r.id===e)??null}function E1(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 $1(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=Zl(a),c=Zl(o),d=yi(l),f=n.position==="above"?[d,c]:[c,d];return s[i]={id:o.id,type:"stack",children:f},s}function qa(t,e){return t.parentStackId?x1(t,e):A1(t,e)}function A1(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=E1(t,e);return r?$1(r,t,n,e)??[...e]:[...e]}return[...e]}function x1(t,e){const n=t.hitTarget;switch(n.type){case"stack-child-reorder":return T1(t,e,n.position);case"stack-child-extract":return C1(t,e,n.toIndex);case"stack-child-noop":return I1(t,e);default:return[...e]}}function T1(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],f=[...e];return f[r]={...s,children:d},f}function C1(t,e,n){if(!t.parentStackId)return[...e];const r=v1(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 I1(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 P1(t,e){return e.find(r=>r.type==="stack"&&r.id===t.id)?t.id:kc()}function R1(t,e,n){if(t.type==="drop-target"){const r=Fc(e,n);if(!r)throw new Error(`finalize: missing dragged card ${n}`);return Zl(r)}return t}function D1(t,e,n){const r=t.children.map(i=>R1(i,e,n));return{id:P1(t,e),type:"stack",children:r}}function O1(t,e,n){if(t.type==="drop-target"){const r=Fc(e,n);if(!r)throw new Error(`finalize: missing dragged card ${n}`);return Fm(e,n)!==null?r:jl(r)}return t.type==="card"||t.type==="row"?t:D1(t,e,n)}function z1(t,e,n){return t.map(r=>O1(r,e,n))}function L1(t,e){return JSON.stringify(t)===JSON.stringify(e)}const M1=Gr(kt);class N1 extends M1{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)>=vE&&(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=qa(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&&_1(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=qa(this.active,n),i=z1(s,n,this.active.nodeId);L1(i,n)||(r=i)}catch{r=null}this.reset(),r&&this.dispatchEvent(new b1("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=qa(this.active,this.active.baseLayout);this.dispatchEvent(new y1("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=Ld(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=Ld(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)<=w1;for(const I of o){const V=I.rect;if(!bn(n,r,V))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)),f=this.resolveTopLevelTargetForCard(d,r,c,c.logicalIndex,l);if(f)return f;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 f of o){if(!bn(n,r,f.rect))continue;const y=Ha(f.rect,Ga["reorder-before"]);if(bn(n,r,y))return f.logicalIndex;const m=Ha(f.rect,Ga["reorder-after"]);if(bn(n,r,m))return f.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 m1){if(!o&&(l==="stack-above"||l==="stack-below"))continue;const c=Ga[l],d=Ha(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 Md=60,U1=80,Nd=.5,Ud=10;class F1{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>=Md&&(this.activeGestureType="none");const l=r&&i!==0,c=l?i:s,d=Math.abs(c),f=Math.abs(i);return this.activeGestureType==="vertical-artifact"&&o?d>=Nd&&d>=f*Ud?this.classifyHorizontal(n,c):(this.lastWheelGestureAt=n,{type:"scroll-native"}):this.activeGestureType==="horizontal-filmstrip"?!l&&o&&f>0&&f>=d*Ud?(this.activeGestureType="vertical-artifact",this.lastWheelGestureAt=n,{type:"scroll-native"}):this.classifyHorizontal(n,c):d<Nd?(o&&(this.activeGestureType="vertical-artifact"),this.lastWheelGestureAt=n,{type:"scroll-native"}):l||d>f?this.classifyHorizontal(n,c):f>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)+U1;return this.awaitingFreshWheelGesture&&r<Md&&!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 Z1=2,Fd=1e3,ji=1e-4;function Zd(t,e,n){if(t===0)return 0;const r=e.toPixels(Te({y:Ke})).y??0;return(n-r)/Z1}class j1 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 W1 extends HTMLElement{constructor(){super();v(this,"_layout",[]);v(this,"_scrollPosition",0);v(this,"layoutGrid",null);v(this,"layoutScroll",new g1(Te({x:0})));v(this,"scrollModelKey","");v(this,"resizeObserver",null);v(this,"renderPending",!1);v(this,"animateNextRender",!0);v(this,"wheelGesture",new F1);v(this,"dragController",new N1);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=zd(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)||!TT(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=V1(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)/Fd;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=Te({x:this._scrollPosition}),this.scheduleRender()}get layout(){return this._layout}commitLayout(n){this.layout=n,this.emitLayoutChanged()}set scrollPosition(n){Math.abs(n-this._scrollPosition)<ji||(this.animateNextRender=!1,this.syncScrollModel(),this.layoutScroll.scroll=Te({x:n}))}get scrollPosition(){return this._scrollPosition}connectedCallback(){this.hasAttribute("tabindex")||(this.tabIndex=0),this.focus(),this.addEventListener("keydown",this.handleKeyDown),this.addEventListener("wheel",this.handleWheel,{passive:!1}),this.addEventListener("pointerdown",this.handlePointerDown),window.addEventListener("message",this.handleWindowMessage),typeof ResizeObserver<"u"&&(this.resizeObserver=new ResizeObserver(()=>this.render()),this.resizeObserver.observe(this)),this.render()}disconnectedCallback(){var n;this.removeEventListener("keydown",this.handleKeyDown),this.removeEventListener("wheel",this.handleWheel),this.removeEventListener("pointerdown",this.handlePointerDown),window.removeEventListener("message",this.handleWindowMessage),(n=this.resizeObserver)==null||n.disconnect(),this.resizeObserver=null,this.wheelGesture.reset(),this.detachDragListeners(),this.dragController.removeEventListener("change",this.onDragControllerChange),this.dragController.removeEventListener("drag",this.onDragControllerDrag),this.dragController.removeEventListener("drop",this.onDragControllerDrop),this.layoutScroll.removeEventListener("layout-scroll",this.onLayoutScrollInternal),this.dragController.dispose(),this.stopDragFrameLoop()}scheduleRender(){this.renderPending||(this.renderPending=!0,queueMicrotask(()=>{this.renderPending=!1,this.render()}))}createGrid(n,r){return new s1({basis:Se({x:kn,y:kn}),min:Se({x:Jh,y:Jh}),viewport:Se({x:n,y:r}),gap:Se({x:de,y:de})})}syncScrollModel(){const n=this.clientWidth>0?this.clientWidth:nn,r=this.clientHeight>0?this.clientHeight:mr,i=Es(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=>Te({x:a}))}))}emitScrollPositionChanged(n){this.dispatchEvent(new j1(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(Te({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:zd(this.dragState.projectedLayout),activePlaceholderId:this.dragState.nodeId,placeholdersById:n}}render(){const n=this.clientWidth>0?this.clientWidth:nn,r=this.clientHeight>0?this.clientHeight:mr,s=this.createGrid(n,r);this.layoutGrid=s;const i=this.getDisplayModel(),o=i.layout,a=this.dragController.status==="active",l=Es(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=>Te({x:L}))}),this._scrollPosition=this.layoutScroll.scroll.x??this._scrollPosition);const f=B1(o),y=s.unit.x??kn,m=s.unit.y??kn,E=a?this.dragTrackOffsetXPx:0,k=(this.layoutScroll.translate.x??0)+E,I=Zd(l.nodes.length,s,r),V=this.animateNextRender&&!a,N=[`transform: translate(${k}px, ${I}px);`,`transition-duration: ${V?mE: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`
147
+ </footer>
148
+ `}render(){this._artifact&&(this.setAttribute("type",this._artifact.type),be(this.template(),this))}}customElements.define("artifact-view",e1);const Se=t=>({type:"px",...t}),Ce=t=>({type:"unit",...t}),Zi=2,t1=2;class n1{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??nn,r=this._viewport.y??mr,s=this._gap.x??de,i=this._gap.y??de,o=nn+s*t1,a=n<=o,l=a?n-s*Zi:Math.min(nn,n-s*Zi),c=a?r-i*Zi:Math.min(mr,r-i*Zi),d=(l-s*(St-1))/St,f=(c-i*(Ke-1))/Ke,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,f)}:{x:Math.max(E,Math.min(y,d)),y:Math.max(k,Math.min(m,f))})}get unit(){return this._unit}get viewport(){return this._viewport}get gap(){return this._gap}toUnits(e){return Ce({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 Bn=1e-4,Ut=1e-6,r1=40,s1=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+Bn)break;r=a,s+=1}return Math.max(1,s)}function i1(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+Bn)break;r=a,s+=1}return Math.max(1,s)}function o1(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+Bn)break;n=o,r+=1}return Math.max(1,r)}function jc(t,e){if(t.length===0)return 0;const n=o1(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 Wl(t,e,n){const r=t[e]??0;return n-r}function fr(t,e,n,r,s){if(t.length===0)return 0;const i=jc(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+Bn){l=L;break}l=L+1}const c=Math.min(l+1,i),d=e[l]??0,f=e[c]??d,y=Math.max(f-d,Bn),m=c===l?0:(a-d)/y,E=Nm(t),k=Od(t,l,s),I=Od(t,c,s),V=(r-k)/2,N=(r-I)/2,j=Wl(E,l,V),F=Wl(E,c,N);return j+(F-j)*m}function zd(t,e,n,r,s){const i=jc(t,r),o=e[i]??0;let a=0,l=o;for(let c=0;c<r1;c+=1){const d=(a+l)/2;fr(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 Wl(r,s,l)}function a1(t,e,n){const r=Um(t,e,n);return[e,Math.min(t.length-1,e+r-1)]}function l1(t,e,n){const r=i1(t,e,n);return[Math.max(0,e-r+1),e]}function c1(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)<=Ut||(e.add(s),n.push(r))}return n}function u1(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=jc(n,i),l=o[a]??0,c=[];for(let d=0;d<=a;d+=1){const f=a1(n,d,i),y=Ld(n,f,r),m=zd(n,o,r,i,y);c.push({nodeRange:f,anchor:Math.max(0,Math.min(l,m))})}for(let d=n.length-1;d>=0;d-=1){const f=l1(n,d,i),y=`${f[0]}:${f[1]}`;if(c.some(k=>`${k.nodeRange[0]}:${k.nodeRange[1]}`===y))continue;const m=Ld(n,f,r),E=zd(n,o,r,i,m);c.push({nodeRange:f,anchor:Math.max(0,Math.min(l,E))})}return c.sort((d,f)=>Math.abs(d.anchor-f.anchor)>Ut?d.anchor-f.anchor:d.nodeRange[0]!==f.nodeRange[0]?d.nodeRange[0]-f.nodeRange[0]:d.nodeRange[1]-f.nodeRange[1]),{viewspans:c1(c),minScroll:0,maxScroll:l}}function h1(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+Ut<r){r=o,n=i;continue}Math.abs(o-r)<=Ut&&i<n&&(n=i)}return n}function d1(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 f1 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 Ce({x:this._scroll})}get translate(){return Se({x:fr(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)<=Ut||(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(Ce({x:c})).x??0),i=n.grid.viewport.x??0,o=n.grid.gap.x??de,a=u1({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)>Ut&&(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??h1(this.viewspans,this._scroll),s=d1(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)<=Ut)&&(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)<=Ut)&&(this._scroll=r,this.dispatchEvent(new ss("layout-scroll",{scroll:this.scroll})))}wheelPixels(n){const r=n.x??0;if(Math.abs(r)<=Bn)return;this.activeViewspanIndex=null;const s=fr(this.nodeWidthsPx,this.boundaryCols,this._scroll,this.viewportWidthPx,this.framedViewportWidthPx),i=s-r,o=fr(this.nodeWidthsPx,this.boundaryCols,this.maxScroll,this.viewportWidthPx,this.framedViewportWidthPx),a=fr(this.nodeWidthsPx,this.boundaryCols,this.minScroll,this.viewportWidthPx,this.framedViewportWidthPx),l=Math.max(o,Math.min(a,i));if(Math.abs(l-s)<=Bn)return;let c=this.minScroll,d=this.maxScroll;for(let y=0;y<s1;y+=1){const m=(c+d)/2;fr(this.nodeWidthsPx,this.boundaryCols,m,this.viewportWidthPx,this.framedViewportWidthPx)>l?c=m:d=m}const f=os((c+d)/2,this.minScroll,this.maxScroll);Math.abs(f-this._scroll)<=Ut||(this._scroll=f,this.dispatchEvent(new ss("layout-scroll",{scroll:this.scroll})))}}const Ya={"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}},p1=["stack-above","stack-below","reorder-before","reorder-after"];function Ka(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 Wc(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 Bl(t){return t.height===Ke||t.height===on?{...t,height:on}:t}function Vl(t){return t.height===on?{...t,height:Ke}:t}function g1(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"?Vl(d):d}else l[s]={...i,children:a};const c=Math.max(0,Math.min(r,l.length));return l.splice(c,0,Vl(o)),l}const m1=Be(),v1=Be(),y1=50;function b1(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(_1)}function w1(t){return t.type==="drop-target"?{id:t.id,type:"card",artifactID:t.id,width:t.width,height:t.height}:t}function _1(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(w1)}: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 S1(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 k1(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=Bl(a),c=Bl(o),d=yi(l),f=n.position==="above"?[d,c]:[c,d];return s[i]={id:o.id,type:"stack",children:f},s}function Ja(t,e){return t.parentStackId?$1(t,e):E1(t,e)}function E1(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=S1(t,e);return r?k1(r,t,n,e)??[...e]:[...e]}return[...e]}function $1(t,e){const n=t.hitTarget;switch(n.type){case"stack-child-reorder":return A1(t,e,n.position);case"stack-child-extract":return x1(t,e,n.toIndex);case"stack-child-noop":return C1(t,e);default:return[...e]}}function A1(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],f=[...e];return f[r]={...s,children:d},f}function x1(t,e,n){if(!t.parentStackId)return[...e];const r=g1(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 C1(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 T1(t,e){return e.find(r=>r.type==="stack"&&r.id===t.id)?t.id:Ac()}function I1(t,e,n){if(t.type==="drop-target"){const r=Wc(e,n);if(!r)throw new Error(`finalize: missing dragged card ${n}`);return Bl(r)}return t}function P1(t,e,n){const r=t.children.map(i=>I1(i,e,n));return{id:T1(t,e),type:"stack",children:r}}function R1(t,e,n){if(t.type==="drop-target"){const r=Wc(e,n);if(!r)throw new Error(`finalize: missing dragged card ${n}`);return Fm(e,n)!==null?r:Vl(r)}return t.type==="card"||t.type==="row"?t:P1(t,e,n)}function D1(t,e,n){return t.map(r=>R1(r,e,n))}function O1(t,e){return JSON.stringify(t)===JSON.stringify(e)}const z1=Gr(kt);class L1 extends z1{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)>=gE&&(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=Ja(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&&b1(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=Ja(this.active,n),i=D1(s,n,this.active.nodeId);O1(i,n)||(r=i)}catch{r=null}this.reset(),r&&this.dispatchEvent(new v1("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=Ja(this.active,this.active.baseLayout);this.dispatchEvent(new m1("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)<=y1;for(const I of o){const V=I.rect;if(!bn(n,r,V))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)),f=this.resolveTopLevelTargetForCard(d,r,c,c.logicalIndex,l);if(f)return f;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 f of o){if(!bn(n,r,f.rect))continue;const y=Ka(f.rect,Ya["reorder-before"]);if(bn(n,r,y))return f.logicalIndex;const m=Ka(f.rect,Ya["reorder-after"]);if(bn(n,r,m))return f.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 p1){if(!o&&(l==="stack-above"||l==="stack-below"))continue;const c=Ya[l],d=Ka(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,M1=80,Fd=.5,Zd=10;class N1{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),f=Math.abs(i);return this.activeGestureType==="vertical-artifact"&&o?d>=Fd&&d>=f*Zd?this.classifyHorizontal(n,c):(this.lastWheelGestureAt=n,{type:"scroll-native"}):this.activeGestureType==="horizontal-filmstrip"?!l&&o&&f>0&&f>=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>f?this.classifyHorizontal(n,c):f>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)+M1;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 U1=2,jd=1e3,ji=1e-4;function Wd(t,e,n){if(t===0)return 0;const r=e.toPixels(Ce({y:Ke})).y??0;return(n-r)/U1}class F1 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 Z1 extends HTMLElement{constructor(){super();v(this,"_layout",[]);v(this,"_scrollPosition",0);v(this,"layoutGrid",null);v(this,"layoutScroll",new f1(Ce({x:0})));v(this,"scrollModelKey","");v(this,"resizeObserver",null);v(this,"renderPending",!1);v(this,"animateNextRender",!0);v(this,"wheelGesture",new N1);v(this,"dragController",new L1);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)||!$C(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=W1(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=Ce({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=Ce({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 n1({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:nn,r=this.clientHeight>0?this.clientHeight:mr,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=>Ce({x:a}))}))}emitScrollPositionChanged(n){this.dispatchEvent(new F1(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(Ce({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:nn,r=this.clientHeight>0?this.clientHeight:mr,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=>Ce({x:L}))}),this._scrollPosition=this.layoutScroll.scroll.x??this._scrollPosition);const f=j1(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),V=this.animateNextRender&&!a,N=[`transform: translate(${k}px, ${I}px);`,`transition-duration: ${V?pE: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`
146
149
  <div class="track" style=${N}>
147
150
  ${l.nodes.map((L,J)=>M`
148
151
  <div
@@ -151,7 +154,7 @@ ${r.documentElement.outerHTML}`],{type:"text/html"});return URL.createObjectURL(
151
154
  data-layout-node-id=${L.id}
152
155
  data-layout-placeholder=${String(i.activePlaceholderId===L.id)}
153
156
  layout-node-cols=${String(L.width)}
154
- style=${`grid-template-columns: repeat(${L.width}, var(--layout-unit-x)); width: ${s.toPixels(Te({x:L.width})).x}px;`}
157
+ style=${`grid-template-columns: repeat(${L.width}, var(--layout-unit-x)); width: ${s.toPixels(Ce({x:L.width})).x}px;`}
155
158
  >
156
159
  ${L.cards.map(H=>{const he=i.placeholdersById.get(H.id);if(j&&he)return M`
157
160
  <div
@@ -170,7 +173,7 @@ ${r.documentElement.outerHTML}`],{type:"text/html"});return URL.createObjectURL(
170
173
  layout-rows=${String(H.height)}
171
174
  style=${`grid-column: ${H.col} / span ${H.width}; grid-row: ${H.row} / span ${H.height};`}
172
175
  >
173
- ${this.renderContent(ct)}
176
+ ${this.renderContent(ct,{isDragging:!1})}
174
177
  </div>
175
178
  `:null})}
176
179
  </div>
@@ -185,21 +188,22 @@ ${r.documentElement.outerHTML}`],{type:"text/html"});return URL.createObjectURL(
185
188
  ${this.renderDraggedPreview(j.nodeId)}
186
189
  </div>
187
190
  `})():null}
188
- `,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*Fd,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=yE*a;if(n<i){const d=Math.max(0,Math.min(1,(i-n)/Li));return-(l*d**Xh)*s}if(n>o){const d=Math.max(0,Math.min(1,(n-o)/Li));return l*d**Xh*s}return 0}measureLayoutGeometry(n,r,s=0){const i=this.layoutGrid;if(!i)return[];const o=Es(n),a=new Map(o.nodes.map(E=>[E.id,E.width])),l=i.toPixels(Te({y:Ke})).y??mr,c=this.clientHeight>0?this.clientHeight:mr,d=(this.layoutScroll.translate.x??0)+s,f=Zd(o.nodes.length,i,c),y=[];let m=d;for(const E of n){const k=a.get(E.id)??St,I=i.toPixels(Te({x:k})).x??nn,V={left:m,top:f,width:I,height:l};y.push({id:E.id,rect:V}),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(Te({x:a.width})).x??i.width,height:s.toPixels(Te({y:a.height})).y??i.height};return i}renderDraggedPreview(n){const r=Fc(this._layout,n);return r?this.renderContent(r):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?Wd(n,l,this.layoutGrid):Bd(n,l,this.layoutGrid),d=i?Wd(r,l,this.layoutGrid):Bd(r,l,this.layoutGrid);return c===null||d===null?a:a+(c-d)}getStableAnchorCardId(n,r,s){const i=jd(n),o=new Set(jd(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 B1(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 V1(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 jd(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 Wd(t,e,n){if(!n)return null;const r=Es(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(Te({x:a})).x??nn;i+=l+de}return null}function Bd(t,e,n){if(!n)return null;const r=Es(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(Te({x:a})).x??nn;i+=l+de}return null}customElements.get("layout-view")||customElements.define("layout-view",W1);class G1 extends HTMLElement{constructor(){super(...arguments);v(this,"screenManager",Ye.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`
191
+ `,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=mE*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(Ce({y:Ke})).y??mr,c=this.clientHeight>0?this.clientHeight:mr,d=(this.layoutScroll.translate.x??0)+s,f=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(Ce({x:k})).x??nn,V={left:m,top:f,width:I,height:l};y.push({id:E.id,rect:V}),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(Ce({x:a.width})).x??i.width,height:s.toPixels(Ce({y:a.height})).y??i.height};return i}renderDraggedPreview(n){const r=Wc(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?Vd(n,l,this.layoutGrid):Gd(n,l,this.layoutGrid),d=i?Vd(r,l,this.layoutGrid):Gd(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 j1(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 W1(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 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.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(Ce({x:a})).x??nn;i+=l+de}return null}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.id===e)return i;const a=s.get(o.id)??St,l=n.toPixels(Ce({x:a})).x??nn;i+=l+de}return null}customElements.get("layout-view")||customElements.define("layout-view",Z1);class B1 extends HTMLElement{constructor(){super(...arguments);v(this,"screenManager",Ye.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`
189
192
  <layout-view
190
193
  .layout=${r}
191
- .renderContent=${o=>{const a=s.get(o.artifactID);return!a||!n?M``:M`<artifact-view
192
- .artifact=${a}
194
+ .renderContent=${(o,a)=>{const l=s.get(o.artifactID);return!l||!n?M``:M`<artifact-view
195
+ .artifact=${l}
193
196
  .screen=${n}
194
- .viewURL=${n.server.getViewURL(a)}
195
- .contentURL=${n.server.getContentURL(a.id)}
197
+ .viewURL=${n.server.getViewURL(l)}
198
+ .contentURL=${n.server.getContentURL(l.id)}
199
+ .dragging=${a.isDragging}
196
200
  ></artifact-view>`}}
197
201
  .scrollPosition=${(n==null?void 0:n.scrollPosition)??0}
198
202
  @scroll=${this.handleScrollPositionChanged}
199
203
  @layout-change=${this.handleLayoutChanged}
200
204
  @close-artifact=${this.handleCloseArtifact}
201
205
  ></layout-view>
202
- `,this)}}customElements.define("screen-view",G1);const Ya=Be();class H1 extends HTMLElement{constructor(){super(...arguments);v(this,"screenManager",Ye.resolve("ScreenManager"));v(this,"serverManager",Ye.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 Ya("edit-screen",{bubbles:!0,composed:!0})))}handleCreateScreen(n){this.closeDropdown(),this.dispatchEvent(new Ya("create-screen",{serverURL:n,bubbles:!0,composed:!0}))}handleDeleteScreen(){this.screenManager.activeScreen&&(this.closeDropdown(),this.dispatchEvent(new Ya("delete-screen",{bubbles:!0,composed:!0})))}render(){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()].map(o=>({url:o.url,name:o.name,sortedScreens:[...o.screens.values()].sort((a,l)=>a.name.localeCompare(l.name,void 0,{sensitivity:"base"}))}));be(M`
206
+ `,this)}}customElements.define("screen-view",B1);const Xa=Be();class V1 extends HTMLElement{constructor(){super(...arguments);v(this,"screenManager",Ye.resolve("ScreenManager"));v(this,"serverManager",Ye.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 Xa("edit-screen",{bubbles:!0,composed:!0})))}handleCreateScreen(n){this.closeDropdown(),this.dispatchEvent(new Xa("create-screen",{serverURL:n,bubbles:!0,composed:!0}))}handleDeleteScreen(){this.screenManager.activeScreen&&(this.closeDropdown(),this.dispatchEvent(new Xa("delete-screen",{bubbles:!0,composed:!0})))}render(){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()].map(o=>({url:o.url,name:o.name,sortedScreens:[...o.screens.values()].sort((a,l)=>a.name.localeCompare(l.name,void 0,{sensitivity:"base"}))}));be(M`
203
207
  <dropdown-menu
204
208
  title=${r}
205
209
  @select=${o=>this.handleSelect(o)}
@@ -245,13 +249,13 @@ ${r.documentElement.outerHTML}`],{type:"text/html"});return URL.createObjectURL(
245
249
  <dropdown-item value=${n.id} ?selected=${i}>
246
250
  ${o}
247
251
  </dropdown-item>
248
- `}}customElements.define("screen-picker",H1);const Vd=new WeakMap,Gd=new WeakSet,jm=new WeakMap,Wm=new WeakMap,Wi=new WeakSet,Bm=t=>t;function Vm(t,e){return t===Boolean?e===null?!1:e!=="false":e===null?null:t===Number?Number(e):t===Object?JSON.parse(e):e}function q1(t,e){return e==null?null:t===Boolean?e?"":"false":t===Object?JSON.stringify(e):String(e)}function Y1(t){const e=new Map;if(!t)return e;if(Array.isArray(t)){for(const n of t)e.set(n,{attribute:!1});return e}for(const[n,r]of Object.entries(t))e.set(n,{type:r.type,attribute:r.attribute??!1});return e}function Ps(t){let e=Vd.get(t);return e||(e={constructing:!0,syncingFromAttribute:null,syncingToAttribute:null,values:new Map},Vd.set(t,e)),e}function Zc(t){return Wm.get(t)??new Map}function Gm(t,e){var n;return((n=jm.get(t))==null?void 0:n.has(e))??!1}function Rs(t){return typeof t.attribute=="string"?t.attribute:null}function K1(t,e){for(const[n,r]of Zc(t))if(Rs(r)===e)return{prop:n,config:r};return null}function io(t){if(Gd.has(t))return;const e=Y1(t.observedProperties);Wm.set(t,e);const n=new Set;jm.set(t,n);for(const[r,s]of e){if(Rs(s)&&!s.type)throw new Error(`Observed property "${r}" requires a "type" when "attribute" is set.`);const o=Object.getOwnPropertyDescriptor(t.prototype,r);if(o!=null&&o.get||o!=null&&o.set)throw new Error(`Observed property "${r}" cannot define a custom getter/setter. Use propertyChangedCallback for side effects instead.`);o||(n.add(r),Object.defineProperty(t.prototype,r,{enumerable:!0,configurable:!0,get(){return Ps(this).values.get(r)},set(a){const l=Ps(this),c=l.values.get(r);if(Object.is(c,a))return;l.values.set(r,a);const d=Rs(s);if(d&&l.syncingFromAttribute!==d&&l.syncingToAttribute!==d){const f=q1(s.type,a);l.syncingToAttribute=d;try{const y=this;f===null?y.removeAttribute(d):y.setAttribute(d,f)}finally{l.syncingToAttribute=null}}(!l.constructing||l.syncingFromAttribute!==null||c!==void 0)&&this.propertyChangedCallback(r,c,a)}}))}Gd.add(t)}function J1(t,e){io(e);const n=Ps(t),r=Bm(t),s=Zc(e);for(const[i,o]of s){if(!Gm(e,i))continue;const a=Object.prototype.hasOwnProperty.call(t,i),l=a?r[i]:void 0;a&&delete r[i];const c=Rs(o);if(c&&t.hasAttribute(c)){const d=Vm(o.type,t.getAttribute(c));n.syncingFromAttribute=c;try{r[i]=d}finally{n.syncingFromAttribute=null}continue}a&&(r[i]=l)}n.constructing=!1}class Ds extends globalThis.HTMLElement{static get observedAttributes(){const e=this;return io(e),X1(e),[...Zc(e).values()].map(n=>Rs(n)).filter(n=>!!n)}constructor(){super();const e=this.constructor;io(e),Ps(this),queueMicrotask(()=>J1(this,e))}attributeChangedCallback(e,n,r){const s=this.constructor;io(s);const i=K1(s,e);if(!i||!Gm(s,i.prop))return;const o=Ps(this);if(o.syncingToAttribute===e)return;const a=Bm(this);Object.prototype.hasOwnProperty.call(this,i.prop)&&delete a[i.prop],o.syncingFromAttribute=e;try{a[i.prop]=Vm(i.config.type,r)}finally{o.syncingFromAttribute=null}}propertyChangedCallback(e,n,r){}}v(Ds,"observedProperties");function X1(t){if(Wi.has(t))return;const e=Object.getOwnPropertyDescriptor(t.prototype,"attributeChangedCallback");if(!e||typeof e.value!="function"){Wi.add(t);return}const n=e.value;if(n===Ds.prototype.attributeChangedCallback){Wi.add(t);return}Object.defineProperty(t.prototype,"attributeChangedCallback",{configurable:!0,writable:!0,value(r,s,i){Ds.prototype.attributeChangedCallback.call(this,r,s,i),n.call(this,r,s,i)}}),Wi.add(t)}/*! @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:Hm,setPrototypeOf:Hd,isFrozen:Q1,getPrototypeOf:eD,getOwnPropertyDescriptor:tD}=Object;let{freeze:Le,seal:et,create:oo}=Object,{apply:Wl,construct:Bl}=typeof Reflect<"u"&&Reflect;Le||(Le=function(e){return e});et||(et=function(e){return e});Wl||(Wl=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)});Bl||(Bl=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 Bi=Me(Array.prototype.forEach),nD=Me(Array.prototype.lastIndexOf),qd=Me(Array.prototype.pop),os=Me(Array.prototype.push),rD=Me(Array.prototype.splice),ao=Me(String.prototype.toLowerCase),Ka=Me(String.prototype.toString),Ja=Me(String.prototype.match),as=Me(String.prototype.replace),sD=Me(String.prototype.indexOf),iD=Me(String.prototype.trim),He=Me(Object.prototype.hasOwnProperty),Re=Me(RegExp.prototype.test),ls=oD(TypeError);function Me(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 Wl(t,e,r)}}function oD(t){return function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return Bl(t,n)}}function W(t,e){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:ao;Hd&&Hd(t,null);let r=e.length;for(;r--;){let s=e[r];if(typeof s=="string"){const i=n(s);i!==s&&(Q1(e)||(e[r]=i),s=i)}t[s]=!0}return t}function aD(t){for(let e=0;e<t.length;e++)He(t,e)||(t[e]=null);return t}function gt(t){const e=oo(null);for(const[n,r]of Hm(t))He(t,n)&&(Array.isArray(r)?e[n]=aD(r):r&&typeof r=="object"&&r.constructor===Object?e[n]=gt(r):e[n]=r);return e}function cs(t,e){for(;t!==null;){const r=tD(t,e);if(r){if(r.get)return Me(r.get);if(typeof r.value=="function")return Me(r.value)}t=eD(t)}function n(){return null}return n}const Yd=Le(["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"]),Xa=Le(["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"]),Qa=Le(["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"]),lD=Le(["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"]),el=Le(["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"]),cD=Le(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Kd=Le(["#text"]),Jd=Le(["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"]),tl=Le(["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"]),Xd=Le(["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"]),Vi=Le(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),uD=et(/\{\{[\w\W]*|[\w\W]*\}\}/gm),hD=et(/<%[\w\W]*|[\w\W]*%>/gm),dD=et(/\$\{[\w\W]*/gm),fD=et(/^data-[\-\w.\u00B7-\uFFFF]+$/),pD=et(/^aria-[\-\w]+$/),qm=et(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),gD=et(/^(?:\w+script|data):/i),mD=et(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Ym=et(/^html$/i),vD=et(/^[a-z][.\w]*(-[.\w]+)+$/i);var Qd=Object.freeze({__proto__:null,ARIA_ATTR:pD,ATTR_WHITESPACE:mD,CUSTOM_ELEMENT:vD,DATA_ATTR:fD,DOCTYPE_NAME:Ym,ERB_EXPR:hD,IS_ALLOWED_URI:qm,IS_SCRIPT_OR_DATA:gD,MUSTACHE_EXPR:uD,TMPLIT_EXPR:dD});const us={element:1,text:3,progressingInstruction:7,comment:8,document:9},yD=function(){return typeof window>"u"?null:window},bD=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}},ef=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Km(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:yD();const e=O=>Km(O);if(e.version="3.3.3",e.removed=[],!t||!t.document||t.document.nodeType!==us.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:f,DOMParser:y,trustedTypes:m}=t,E=l.prototype,k=cs(E,"cloneNode"),I=cs(E,"remove"),V=cs(E,"nextSibling"),N=cs(E,"childNodes"),j=cs(E,"parentNode");if(typeof o=="function"){const O=n.createElement("template");O.content&&O.content.ownerDocument&&(n=O.content.ownerDocument)}let F,L="";const{implementation:J,createNodeIterator:H,createDocumentFragment:he,getElementsByTagName:ct}=n,{importNode:wi}=r;let Ee=ef();e.isSupported=typeof Hm=="function"&&typeof j=="function"&&J&&J.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:gn,ERB_EXPR:ut,TMPLIT_EXPR:Bt,DATA_ATTR:ta,ARIA_ATTR:_i,IS_SCRIPT_OR_DATA:bv,ATTR_WHITESPACE:Qc,CUSTOM_ELEMENT:wv}=Qd;let{IS_ALLOWED_URI:eu}=Qd,we=null;const tu=W({},[...Yd,...Xa,...Qa,...el,...Kd]);let $e=null;const nu=W({},[...Jd,...tl,...Xd,...Vi]);let fe=Object.seal(oo(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}})),Jr=null,Si=null;const Vt=Object.seal(oo(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let ru=!0,na=!0,su=!1,iu=!0,Jn=!1,ki=!0,mn=!1,ra=!1,sa=!1,Xn=!1,Ei=!1,$i=!1,ou=!0,au=!1;const _v="user-content-";let ia=!0,Xr=!1,Qn={},ht=null;const oa=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 lu=null;const cu=W({},["audio","video","img","source","image","track"]);let aa=null;const uu=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 er=Et,la=!1,ca=null;const Sv=W({},[Ai,xi,Et],Ka);let Ti=W({},["mi","mo","mn","ms","mtext"]),Ci=W({},["annotation-xml"]);const kv=W({},["title","style","font","a","script"]);let Qr=null;const Ev=["application/xhtml+xml","text/html"],$v="text/html";let ve=null,tr=null;const Av=n.createElement("form"),hu=function(g){return g instanceof RegExp||g instanceof Function},ua=function(){let g=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(tr&&tr===g)){if((!g||typeof g!="object")&&(g={}),g=gt(g),Qr=Ev.indexOf(g.PARSER_MEDIA_TYPE)===-1?$v:g.PARSER_MEDIA_TYPE,ve=Qr==="application/xhtml+xml"?Ka:ao,we=He(g,"ALLOWED_TAGS")?W({},g.ALLOWED_TAGS,ve):tu,$e=He(g,"ALLOWED_ATTR")?W({},g.ALLOWED_ATTR,ve):nu,ca=He(g,"ALLOWED_NAMESPACES")?W({},g.ALLOWED_NAMESPACES,Ka):Sv,aa=He(g,"ADD_URI_SAFE_ATTR")?W(gt(uu),g.ADD_URI_SAFE_ATTR,ve):uu,lu=He(g,"ADD_DATA_URI_TAGS")?W(gt(cu),g.ADD_DATA_URI_TAGS,ve):cu,ht=He(g,"FORBID_CONTENTS")?W({},g.FORBID_CONTENTS,ve):oa,Jr=He(g,"FORBID_TAGS")?W({},g.FORBID_TAGS,ve):gt({}),Si=He(g,"FORBID_ATTR")?W({},g.FORBID_ATTR,ve):gt({}),Qn=He(g,"USE_PROFILES")?g.USE_PROFILES:!1,ru=g.ALLOW_ARIA_ATTR!==!1,na=g.ALLOW_DATA_ATTR!==!1,su=g.ALLOW_UNKNOWN_PROTOCOLS||!1,iu=g.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Jn=g.SAFE_FOR_TEMPLATES||!1,ki=g.SAFE_FOR_XML!==!1,mn=g.WHOLE_DOCUMENT||!1,Xn=g.RETURN_DOM||!1,Ei=g.RETURN_DOM_FRAGMENT||!1,$i=g.RETURN_TRUSTED_TYPE||!1,sa=g.FORCE_BODY||!1,ou=g.SANITIZE_DOM!==!1,au=g.SANITIZE_NAMED_PROPS||!1,ia=g.KEEP_CONTENT!==!1,Xr=g.IN_PLACE||!1,eu=g.ALLOWED_URI_REGEXP||qm,er=g.NAMESPACE||Et,Ti=g.MATHML_TEXT_INTEGRATION_POINTS||Ti,Ci=g.HTML_INTEGRATION_POINTS||Ci,fe=g.CUSTOM_ELEMENT_HANDLING||{},g.CUSTOM_ELEMENT_HANDLING&&hu(g.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(fe.tagNameCheck=g.CUSTOM_ELEMENT_HANDLING.tagNameCheck),g.CUSTOM_ELEMENT_HANDLING&&hu(g.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(fe.attributeNameCheck=g.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),g.CUSTOM_ELEMENT_HANDLING&&typeof g.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(fe.allowCustomizedBuiltInElements=g.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Jn&&(na=!1),Ei&&(Xn=!0),Qn&&(we=W({},Kd),$e=oo(null),Qn.html===!0&&(W(we,Yd),W($e,Jd)),Qn.svg===!0&&(W(we,Xa),W($e,tl),W($e,Vi)),Qn.svgFilters===!0&&(W(we,Qa),W($e,tl),W($e,Vi)),Qn.mathMl===!0&&(W(we,el),W($e,Xd),W($e,Vi))),He(g,"ADD_TAGS")||(Vt.tagCheck=null),He(g,"ADD_ATTR")||(Vt.attributeCheck=null),g.ADD_TAGS&&(typeof g.ADD_TAGS=="function"?Vt.tagCheck=g.ADD_TAGS:(we===tu&&(we=gt(we)),W(we,g.ADD_TAGS,ve))),g.ADD_ATTR&&(typeof g.ADD_ATTR=="function"?Vt.attributeCheck=g.ADD_ATTR:($e===nu&&($e=gt($e)),W($e,g.ADD_ATTR,ve))),g.ADD_URI_SAFE_ATTR&&W(aa,g.ADD_URI_SAFE_ATTR,ve),g.FORBID_CONTENTS&&(ht===oa&&(ht=gt(ht)),W(ht,g.FORBID_CONTENTS,ve)),g.ADD_FORBID_CONTENTS&&(ht===oa&&(ht=gt(ht)),W(ht,g.ADD_FORBID_CONTENTS,ve)),ia&&(we["#text"]=!0),mn&&W(we,["html","head","body"]),we.table&&(W(we,["tbody"]),delete Jr.tbody),g.TRUSTED_TYPES_POLICY){if(typeof g.TRUSTED_TYPES_POLICY.createHTML!="function")throw ls('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof g.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw ls('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');F=g.TRUSTED_TYPES_POLICY,L=F.createHTML("")}else F===void 0&&(F=bD(m,s)),F!==null&&typeof L=="string"&&(L=F.createHTML(""));Le&&Le(g),tr=g}},du=W({},[...Xa,...Qa,...lD]),fu=W({},[...el,...cD]),xv=function(g){let T=j(g);(!T||!T.tagName)&&(T={namespaceURI:er,tagName:"template"});const P=ao(g.tagName),se=ao(T.tagName);return ca[g.namespaceURI]?g.namespaceURI===xi?T.namespaceURI===Et?P==="svg":T.namespaceURI===Ai?P==="svg"&&(se==="annotation-xml"||Ti[se]):!!du[P]:g.namespaceURI===Ai?T.namespaceURI===Et?P==="math":T.namespaceURI===xi?P==="math"&&Ci[se]:!!fu[P]:g.namespaceURI===Et?T.namespaceURI===xi&&!Ci[se]||T.namespaceURI===Ai&&!Ti[se]?!1:!fu[P]&&(kv[P]||!du[P]):!!(Qr==="application/xhtml+xml"&&ca[g.namespaceURI]):!1},dt=function(g){os(e.removed,{element:g});try{j(g).removeChild(g)}catch{I(g)}},vn=function(g,T){try{os(e.removed,{attribute:T.getAttributeNode(g),from:T})}catch{os(e.removed,{attribute:null,from:T})}if(T.removeAttribute(g),g==="is")if(Xn||Ei)try{dt(T)}catch{}else try{T.setAttribute(g,"")}catch{}},pu=function(g){let T=null,P=null;if(sa)g="<remove></remove>"+g;else{const pe=Ja(g,/^[\r\n\t ]+/);P=pe&&pe[0]}Qr==="application/xhtml+xml"&&er===Et&&(g='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+g+"</body></html>");const se=F?F.createHTML(g):g;if(er===Et)try{T=new y().parseFromString(se,Qr)}catch{}if(!T||!T.documentElement){T=J.createDocument(er,"template",null);try{T.documentElement.innerHTML=la?L:se}catch{}}const Ie=T.body||T.documentElement;return g&&P&&Ie.insertBefore(n.createTextNode(P),Ie.childNodes[0]||null),er===Et?ct.call(T,mn?"html":"body")[0]:mn?T.documentElement:Ie},gu=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)},ha=function(g){return g instanceof f&&(typeof g.nodeName!="string"||typeof g.textContent!="string"||typeof g.removeChild!="function"||!(g.attributes instanceof d)||typeof g.removeAttribute!="function"||typeof g.setAttribute!="function"||typeof g.namespaceURI!="string"||typeof g.insertBefore!="function"||typeof g.hasChildNodes!="function")},mu=function(g){return typeof a=="function"&&g instanceof a};function $t(O,g,T){Bi(O,P=>{P.call(e,g,T,tr)})}const vu=function(g){let T=null;if($t(Ee.beforeSanitizeElements,g,null),ha(g))return dt(g),!0;const P=ve(g.nodeName);if($t(Ee.uponSanitizeElement,g,{tagName:P,allowedTags:we}),ki&&g.hasChildNodes()&&!mu(g.firstElementChild)&&Re(/<[/\w!]/g,g.innerHTML)&&Re(/<[/\w!]/g,g.textContent)||g.nodeType===us.progressingInstruction||ki&&g.nodeType===us.comment&&Re(/<[/\w]/g,g.data))return dt(g),!0;if(!(Vt.tagCheck instanceof Function&&Vt.tagCheck(P))&&(!we[P]||Jr[P])){if(!Jr[P]&&bu(P)&&(fe.tagNameCheck instanceof RegExp&&Re(fe.tagNameCheck,P)||fe.tagNameCheck instanceof Function&&fe.tagNameCheck(P)))return!1;if(ia&&!ht[P]){const se=j(g)||g.parentNode,Ie=N(g)||g.childNodes;if(Ie&&se){const pe=Ie.length;for(let Ne=pe-1;Ne>=0;--Ne){const At=k(Ie[Ne],!0);At.__removalCount=(g.__removalCount||0)+1,se.insertBefore(At,V(g))}}}return dt(g),!0}return g instanceof l&&!xv(g)||(P==="noscript"||P==="noembed"||P==="noframes")&&Re(/<\/no(script|embed|frames)/i,g.innerHTML)?(dt(g),!0):(Jn&&g.nodeType===us.text&&(T=g.textContent,Bi([gn,ut,Bt],se=>{T=as(T,se," ")}),g.textContent!==T&&(os(e.removed,{element:g.cloneNode()}),g.textContent=T)),$t(Ee.afterSanitizeElements,g,null),!1)},yu=function(g,T,P){if(Si[T]||ou&&(T==="id"||T==="name")&&(P in n||P in Av))return!1;if(!(na&&!Si[T]&&Re(ta,T))){if(!(ru&&Re(_i,T))){if(!(Vt.attributeCheck instanceof Function&&Vt.attributeCheck(T,g))){if(!$e[T]||Si[T]){if(!(bu(g)&&(fe.tagNameCheck instanceof RegExp&&Re(fe.tagNameCheck,g)||fe.tagNameCheck instanceof Function&&fe.tagNameCheck(g))&&(fe.attributeNameCheck instanceof RegExp&&Re(fe.attributeNameCheck,T)||fe.attributeNameCheck instanceof Function&&fe.attributeNameCheck(T,g))||T==="is"&&fe.allowCustomizedBuiltInElements&&(fe.tagNameCheck instanceof RegExp&&Re(fe.tagNameCheck,P)||fe.tagNameCheck instanceof Function&&fe.tagNameCheck(P))))return!1}else if(!aa[T]){if(!Re(eu,as(P,Qc,""))){if(!((T==="src"||T==="xlink:href"||T==="href")&&g!=="script"&&sD(P,"data:")===0&&lu[g])){if(!(su&&!Re(bv,as(P,Qc,"")))){if(P)return!1}}}}}}}return!0},bu=function(g){return g!=="annotation-xml"&&Ja(g,wv)},wu=function(g){$t(Ee.beforeSanitizeAttributes,g,null);const{attributes:T}=g;if(!T||ha(g))return;const P={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:$e,forceKeepAttr:void 0};let se=T.length;for(;se--;){const Ie=T[se],{name:pe,namespaceURI:Ne,value:At}=Ie,nr=ve(pe),da=At;let Ae=pe==="value"?da:iD(da);if(P.attrName=nr,P.attrValue=Ae,P.keepAttr=!0,P.forceKeepAttr=void 0,$t(Ee.uponSanitizeAttribute,g,P),Ae=P.attrValue,au&&(nr==="id"||nr==="name")&&(vn(pe,g),Ae=_v+Ae),ki&&Re(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,Ae)){vn(pe,g);continue}if(nr==="attributename"&&Ja(Ae,"href")){vn(pe,g);continue}if(P.forceKeepAttr)continue;if(!P.keepAttr){vn(pe,g);continue}if(!iu&&Re(/\/>/i,Ae)){vn(pe,g);continue}Jn&&Bi([gn,ut,Bt],Su=>{Ae=as(Ae,Su," ")});const _u=ve(g.nodeName);if(!yu(_u,nr,Ae)){vn(pe,g);continue}if(F&&typeof m=="object"&&typeof m.getAttributeType=="function"&&!Ne)switch(m.getAttributeType(_u,nr)){case"TrustedHTML":{Ae=F.createHTML(Ae);break}case"TrustedScriptURL":{Ae=F.createScriptURL(Ae);break}}if(Ae!==da)try{Ne?g.setAttributeNS(Ne,pe,Ae):g.setAttribute(pe,Ae),ha(g)?dt(g):qd(e.removed)}catch{vn(pe,g)}}$t(Ee.afterSanitizeAttributes,g,null)},Tv=function O(g){let T=null;const P=gu(g);for($t(Ee.beforeSanitizeShadowDOM,g,null);T=P.nextNode();)$t(Ee.uponSanitizeShadowNode,T,null),vu(T),wu(T),T.content instanceof i&&O(T.content);$t(Ee.afterSanitizeShadowDOM,g,null)};return e.sanitize=function(O){let g=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},T=null,P=null,se=null,Ie=null;if(la=!O,la&&(O="<!-->"),typeof O!="string"&&!mu(O))if(typeof O.toString=="function"){if(O=O.toString(),typeof O!="string")throw ls("dirty is not a string, aborting")}else throw ls("toString is not a function");if(!e.isSupported)return O;if(ra||ua(g),e.removed=[],typeof O=="string"&&(Xr=!1),Xr){if(O.nodeName){const At=ve(O.nodeName);if(!we[At]||Jr[At])throw ls("root node is forbidden and cannot be sanitized in-place")}}else if(O instanceof a)T=pu("<!---->"),P=T.ownerDocument.importNode(O,!0),P.nodeType===us.element&&P.nodeName==="BODY"||P.nodeName==="HTML"?T=P:T.appendChild(P);else{if(!Xn&&!Jn&&!mn&&O.indexOf("<")===-1)return F&&$i?F.createHTML(O):O;if(T=pu(O),!T)return Xn?null:$i?L:""}T&&sa&&dt(T.firstChild);const pe=gu(Xr?O:T);for(;se=pe.nextNode();)vu(se),wu(se),se.content instanceof i&&Tv(se.content);if(Xr)return O;if(Xn){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 Ne=mn?T.outerHTML:T.innerHTML;return mn&&we["!doctype"]&&T.ownerDocument&&T.ownerDocument.doctype&&T.ownerDocument.doctype.name&&Re(Ym,T.ownerDocument.doctype.name)&&(Ne="<!DOCTYPE "+T.ownerDocument.doctype.name+`>
249
- `+Ne),Jn&&Bi([gn,ut,Bt],At=>{Ne=as(Ne,At," ")}),F&&$i?F.createHTML(Ne):Ne},e.setConfig=function(){let O=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};ua(O),ra=!0},e.clearConfig=function(){tr=null,ra=!1},e.isValidAttribute=function(O,g,T){tr||ua({});const P=ve(O),se=ve(g);return yu(P,se,T)},e.addHook=function(O,g){typeof g=="function"&&os(Ee[O],g)},e.removeHook=function(O,g){if(g!==void 0){const T=nD(Ee[O],g);return T===-1?void 0:rD(Ee[O],T,1)[0]}return qd(Ee[O])},e.removeHooks=function(O){Ee[O]=[]},e.removeAllHooks=function(){Ee=ef()},e}var Jm=Km();function jc(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Kn=jc();function Xm(t){Kn=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(ze.caret,"$1"),n=n.replace(s,o),r},getRegex:()=>new RegExp(n,e)};return r}var wD=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),ze={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)}}>`)},_D=/^(?:[ \t]*(?:\n|$))+/,SD=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,kD=/^ {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+|$)/,ED=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Wc=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Qm=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,ev=q(Qm).replace(/bull/g,Wc).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(),$D=q(Qm).replace(/bull/g,Wc).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(),Bc=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,AD=/^[^\n]+/,Vc=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,xD=q(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Vc).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),TD=q(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Wc).getRegex(),Xo="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",Gc=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,CD=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",Gc).replace("tag",Xo).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),tv=q(Bc).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",Xo).getRegex(),ID=q(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",tv).getRegex(),Hc={blockquote:ID,code:SD,def:xD,fences:kD,heading:ED,hr:bi,html:CD,lheading:ev,list:TD,newline:_D,paragraph:tv,table:$n,text:AD},tf=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",Xo).getRegex(),PD={...Hc,lheading:$D,table:tf,paragraph:q(Bc).replace("hr",bi).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",tf).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",Xo).getRegex()},RD={...Hc,html:q(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Gc).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(Bc).replace("hr",bi).replace("heading",` *#{1,6} *[^
250
- ]`).replace("lheading",ev).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},DD=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,OD=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,nv=/^( {2,}|\\)\n(?!\s*$)/,zD=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Kr=/[\p{P}\p{S}]/u,Qo=/[\s\p{P}\p{S}]/u,qc=/[^\s\p{P}\p{S}]/u,LD=q(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Qo).getRegex(),rv=/(?!~)[\p{P}\p{S}]/u,MD=/(?!~)[\s\p{P}\p{S}]/u,ND=/(?:[^\s\p{P}\p{S}]|~)/u,UD=q(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",wD?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),sv=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,FD=q(sv,"u").replace(/punct/g,Kr).getRegex(),ZD=q(sv,"u").replace(/punct/g,rv).getRegex(),iv="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",jD=q(iv,"gu").replace(/notPunctSpace/g,qc).replace(/punctSpace/g,Qo).replace(/punct/g,Kr).getRegex(),WD=q(iv,"gu").replace(/notPunctSpace/g,ND).replace(/punctSpace/g,MD).replace(/punct/g,rv).getRegex(),BD=q("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,qc).replace(/punctSpace/g,Qo).replace(/punct/g,Kr).getRegex(),VD=q(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,Kr).getRegex(),GD="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",HD=q(GD,"gu").replace(/notPunctSpace/g,qc).replace(/punctSpace/g,Qo).replace(/punct/g,Kr).getRegex(),qD=q(/\\(punct)/,"gu").replace(/punct/g,Kr).getRegex(),YD=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(),KD=q(Gc).replace("(?:-->|$)","-->").getRegex(),JD=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",KD).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),ko=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,XD=q(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",ko).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),ov=q(/^!?\[(label)\]\[(ref)\]/).replace("label",ko).replace("ref",Vc).getRegex(),av=q(/^!?\[(ref)\](?:\[\])?/).replace("ref",Vc).getRegex(),QD=q("reflink|nolink(?!\\()","g").replace("reflink",ov).replace("nolink",av).getRegex(),nf=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Yc={_backpedal:$n,anyPunctuation:qD,autolink:YD,blockSkip:UD,br:nv,code:OD,del:$n,delLDelim:$n,delRDelim:$n,emStrongLDelim:FD,emStrongRDelimAst:jD,emStrongRDelimUnd:BD,escape:DD,link:XD,nolink:av,punctuation:LD,reflink:ov,reflinkSearch:QD,tag:JD,text:zD,url:$n},eO={...Yc,link:q(/^!?\[(label)\]\((.*?)\)/).replace("label",ko).getRegex(),reflink:q(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",ko).getRegex()},Vl={...Yc,emStrongRDelimAst:WD,emStrongLDelim:ZD,delLDelim:VD,delRDelim:HD,url:q(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",nf).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",nf).getRegex()},tO={...Vl,br:q(nv).replace("{2,}","*").getRegex(),text:q(Vl.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Gi={normal:Hc,gfm:PD,pedantic:RD},hs={normal:Yc,gfm:Vl,breaks:tO,pedantic:eO},nO={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},rf=t=>nO[t];function mt(t,e){if(e){if(ze.escapeTest.test(t))return t.replace(ze.escapeReplace,rf)}else if(ze.escapeTestNoEncode.test(t))return t.replace(ze.escapeReplaceNoEncode,rf);return t}function sf(t){try{t=encodeURI(t).replace(ze.percentDecode,"%")}catch{return null}return t}function of(t,e){var i;let n=t.replace(ze.findPipe,(o,a,l)=>{let c=!1,d=a;for(;--d>=0&&l[d]==="\\";)c=!c;return c?"|":" |"}),r=n.split(ze.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(ze.slashPipe,"|");return r}function ds(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 rO(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 sO(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 af(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 iO(t,e,n){let r=t.match(n.other.indentCodeCompensation);if(r===null)return e;let s=r[1];return e.split(`
252
+ `}}customElements.define("screen-picker",V1);const Hd=new WeakMap,qd=new WeakSet,jm=new WeakMap,Wm=new WeakMap,Wi=new WeakSet,Bm=t=>t;function Vm(t,e){return t===Boolean?e===null?!1:e!=="false":e===null?null:t===Number?Number(e):t===Object?JSON.parse(e):e}function G1(t,e){return e==null?null:t===Boolean?e?"":"false":t===Object?JSON.stringify(e):String(e)}function H1(t){const e=new Map;if(!t)return e;if(Array.isArray(t)){for(const n of t)e.set(n,{attribute:!1});return e}for(const[n,r]of Object.entries(t))e.set(n,{type:r.type,attribute:r.attribute??!1});return e}function Rs(t){let e=Hd.get(t);return e||(e={constructing:!0,syncingFromAttribute:null,syncingToAttribute:null,values:new Map},Hd.set(t,e)),e}function Bc(t){return Wm.get(t)??new Map}function Gm(t,e){var n;return((n=jm.get(t))==null?void 0:n.has(e))??!1}function Ds(t){return typeof t.attribute=="string"?t.attribute:null}function q1(t,e){for(const[n,r]of Bc(t))if(Ds(r)===e)return{prop:n,config:r};return null}function io(t){if(qd.has(t))return;const e=H1(t.observedProperties);Wm.set(t,e);const n=new Set;jm.set(t,n);for(const[r,s]of e){if(Ds(s)&&!s.type)throw new Error(`Observed property "${r}" requires a "type" when "attribute" is set.`);const o=Object.getOwnPropertyDescriptor(t.prototype,r);if(o!=null&&o.get||o!=null&&o.set)throw new Error(`Observed property "${r}" cannot define a custom getter/setter. Use propertyChangedCallback for side effects instead.`);o||(n.add(r),Object.defineProperty(t.prototype,r,{enumerable:!0,configurable:!0,get(){return Rs(this).values.get(r)},set(a){const l=Rs(this),c=l.values.get(r);if(Object.is(c,a))return;l.values.set(r,a);const d=Ds(s);if(d&&l.syncingFromAttribute!==d&&l.syncingToAttribute!==d){const f=G1(s.type,a);l.syncingToAttribute=d;try{const y=this;f===null?y.removeAttribute(d):y.setAttribute(d,f)}finally{l.syncingToAttribute=null}}(!l.constructing||l.syncingFromAttribute!==null||c!==void 0)&&this.propertyChangedCallback(r,c,a)}}))}qd.add(t)}function Y1(t,e){io(e);const n=Rs(t),r=Bm(t),s=Bc(e);for(const[i,o]of s){if(!Gm(e,i))continue;const a=Object.prototype.hasOwnProperty.call(t,i),l=a?r[i]:void 0;a&&delete r[i];const c=Ds(o);if(c&&t.hasAttribute(c)){const d=Vm(o.type,t.getAttribute(c));n.syncingFromAttribute=c;try{r[i]=d}finally{n.syncingFromAttribute=null}continue}a&&(r[i]=l)}n.constructing=!1}class Os extends globalThis.HTMLElement{static get observedAttributes(){const e=this;return io(e),K1(e),[...Bc(e).values()].map(n=>Ds(n)).filter(n=>!!n)}constructor(){super();const e=this.constructor;io(e),Rs(this),queueMicrotask(()=>Y1(this,e))}attributeChangedCallback(e,n,r){const s=this.constructor;io(s);const i=q1(s,e);if(!i||!Gm(s,i.prop))return;const o=Rs(this);if(o.syncingToAttribute===e)return;const a=Bm(this);Object.prototype.hasOwnProperty.call(this,i.prop)&&delete a[i.prop],o.syncingFromAttribute=e;try{a[i.prop]=Vm(i.config.type,r)}finally{o.syncingFromAttribute=null}}propertyChangedCallback(e,n,r){}}v(Os,"observedProperties");function K1(t){if(Wi.has(t))return;const e=Object.getOwnPropertyDescriptor(t.prototype,"attributeChangedCallback");if(!e||typeof e.value!="function"){Wi.add(t);return}const n=e.value;if(n===Os.prototype.attributeChangedCallback){Wi.add(t);return}Object.defineProperty(t.prototype,"attributeChangedCallback",{configurable:!0,writable:!0,value(r,s,i){Os.prototype.attributeChangedCallback.call(this,r,s,i),n.call(this,r,s,i)}}),Wi.add(t)}/*! @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:Hm,setPrototypeOf:Yd,isFrozen:J1,getPrototypeOf:X1,getOwnPropertyDescriptor:Q1}=Object;let{freeze:Le,seal:et,create:oo}=Object,{apply:Gl,construct:Hl}=typeof Reflect<"u"&&Reflect;Le||(Le=function(e){return e});et||(et=function(e){return e});Gl||(Gl=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 Bi=Me(Array.prototype.forEach),eD=Me(Array.prototype.lastIndexOf),Kd=Me(Array.prototype.pop),as=Me(Array.prototype.push),tD=Me(Array.prototype.splice),ao=Me(String.prototype.toLowerCase),Qa=Me(String.prototype.toString),el=Me(String.prototype.match),ls=Me(String.prototype.replace),nD=Me(String.prototype.indexOf),rD=Me(String.prototype.trim),He=Me(Object.prototype.hasOwnProperty),Re=Me(RegExp.prototype.test),cs=sD(TypeError);function Me(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 Gl(t,e,r)}}function sD(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]:ao;Yd&&Yd(t,null);let r=e.length;for(;r--;){let s=e[r];if(typeof s=="string"){const i=n(s);i!==s&&(J1(e)||(e[r]=i),s=i)}t[s]=!0}return t}function iD(t){for(let e=0;e<t.length;e++)He(t,e)||(t[e]=null);return t}function gt(t){const e=oo(null);for(const[n,r]of Hm(t))He(t,n)&&(Array.isArray(r)?e[n]=iD(r):r&&typeof r=="object"&&r.constructor===Object?e[n]=gt(r):e[n]=r);return e}function us(t,e){for(;t!==null;){const r=Q1(t,e);if(r){if(r.get)return Me(r.get);if(typeof r.value=="function")return Me(r.value)}t=X1(t)}function n(){return null}return n}const Jd=Le(["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"]),tl=Le(["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"]),nl=Le(["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"]),oD=Le(["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"]),rl=Le(["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"]),aD=Le(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Xd=Le(["#text"]),Qd=Le(["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"]),sl=Le(["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"]),ef=Le(["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"]),Vi=Le(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),lD=et(/\{\{[\w\W]*|[\w\W]*\}\}/gm),cD=et(/<%[\w\W]*|[\w\W]*%>/gm),uD=et(/\$\{[\w\W]*/gm),hD=et(/^data-[\-\w.\u00B7-\uFFFF]+$/),dD=et(/^aria-[\-\w]+$/),qm=et(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),fD=et(/^(?:\w+script|data):/i),pD=et(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Ym=et(/^html$/i),gD=et(/^[a-z][.\w]*(-[.\w]+)+$/i);var tf=Object.freeze({__proto__:null,ARIA_ATTR:dD,ATTR_WHITESPACE:pD,CUSTOM_ELEMENT:gD,DATA_ATTR:hD,DOCTYPE_NAME:Ym,ERB_EXPR:cD,IS_ALLOWED_URI:qm,IS_SCRIPT_OR_DATA:fD,MUSTACHE_EXPR:lD,TMPLIT_EXPR:uD});const hs={element:1,text:3,progressingInstruction:7,comment:8,document:9},mD=function(){return typeof window>"u"?null:window},vD=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}},nf=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Km(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:mD();const e=O=>Km(O);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:f,DOMParser:y,trustedTypes:m}=t,E=l.prototype,k=us(E,"cloneNode"),I=us(E,"remove"),V=us(E,"nextSibling"),N=us(E,"childNodes"),j=us(E,"parentNode");if(typeof o=="function"){const O=n.createElement("template");O.content&&O.content.ownerDocument&&(n=O.content.ownerDocument)}let F,L="";const{implementation:J,createNodeIterator:H,createDocumentFragment:he,getElementsByTagName:ct}=n,{importNode:wi}=r;let Ee=nf();e.isSupported=typeof Hm=="function"&&typeof j=="function"&&J&&J.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:gn,ERB_EXPR:ut,TMPLIT_EXPR:Bt,DATA_ATTR:ta,ARIA_ATTR:_i,IS_SCRIPT_OR_DATA:bv,ATTR_WHITESPACE:nu,CUSTOM_ELEMENT:wv}=tf;let{IS_ALLOWED_URI:ru}=tf,we=null;const su=W({},[...Jd,...tl,...nl,...rl,...Xd]);let $e=null;const iu=W({},[...Qd,...sl,...ef,...Vi]);let fe=Object.seal(oo(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 Vt=Object.seal(oo(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let ou=!0,na=!0,au=!1,lu=!0,Jn=!1,ki=!0,mn=!1,ra=!1,sa=!1,Xn=!1,Ei=!1,$i=!1,cu=!0,uu=!1;const _v="user-content-";let ia=!0,Qr=!1,Qn={},ht=null;const oa=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 hu=null;const du=W({},["audio","video","img","source","image","track"]);let aa=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 er=Et,la=!1,ca=null;const Sv=W({},[Ai,xi,Et],Qa);let Ci=W({},["mi","mo","mn","ms","mtext"]),Ti=W({},["annotation-xml"]);const kv=W({},["title","style","font","a","script"]);let es=null;const Ev=["application/xhtml+xml","text/html"],$v="text/html";let ve=null,tr=null;const Av=n.createElement("form"),pu=function(g){return g instanceof RegExp||g instanceof Function},ua=function(){let g=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(tr&&tr===g)){if((!g||typeof g!="object")&&(g={}),g=gt(g),es=Ev.indexOf(g.PARSER_MEDIA_TYPE)===-1?$v:g.PARSER_MEDIA_TYPE,ve=es==="application/xhtml+xml"?Qa:ao,we=He(g,"ALLOWED_TAGS")?W({},g.ALLOWED_TAGS,ve):su,$e=He(g,"ALLOWED_ATTR")?W({},g.ALLOWED_ATTR,ve):iu,ca=He(g,"ALLOWED_NAMESPACES")?W({},g.ALLOWED_NAMESPACES,Qa):Sv,aa=He(g,"ADD_URI_SAFE_ATTR")?W(gt(fu),g.ADD_URI_SAFE_ATTR,ve):fu,hu=He(g,"ADD_DATA_URI_TAGS")?W(gt(du),g.ADD_DATA_URI_TAGS,ve):du,ht=He(g,"FORBID_CONTENTS")?W({},g.FORBID_CONTENTS,ve):oa,Xr=He(g,"FORBID_TAGS")?W({},g.FORBID_TAGS,ve):gt({}),Si=He(g,"FORBID_ATTR")?W({},g.FORBID_ATTR,ve):gt({}),Qn=He(g,"USE_PROFILES")?g.USE_PROFILES:!1,ou=g.ALLOW_ARIA_ATTR!==!1,na=g.ALLOW_DATA_ATTR!==!1,au=g.ALLOW_UNKNOWN_PROTOCOLS||!1,lu=g.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Jn=g.SAFE_FOR_TEMPLATES||!1,ki=g.SAFE_FOR_XML!==!1,mn=g.WHOLE_DOCUMENT||!1,Xn=g.RETURN_DOM||!1,Ei=g.RETURN_DOM_FRAGMENT||!1,$i=g.RETURN_TRUSTED_TYPE||!1,sa=g.FORCE_BODY||!1,cu=g.SANITIZE_DOM!==!1,uu=g.SANITIZE_NAMED_PROPS||!1,ia=g.KEEP_CONTENT!==!1,Qr=g.IN_PLACE||!1,ru=g.ALLOWED_URI_REGEXP||qm,er=g.NAMESPACE||Et,Ci=g.MATHML_TEXT_INTEGRATION_POINTS||Ci,Ti=g.HTML_INTEGRATION_POINTS||Ti,fe=g.CUSTOM_ELEMENT_HANDLING||{},g.CUSTOM_ELEMENT_HANDLING&&pu(g.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(fe.tagNameCheck=g.CUSTOM_ELEMENT_HANDLING.tagNameCheck),g.CUSTOM_ELEMENT_HANDLING&&pu(g.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(fe.attributeNameCheck=g.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),g.CUSTOM_ELEMENT_HANDLING&&typeof g.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(fe.allowCustomizedBuiltInElements=g.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Jn&&(na=!1),Ei&&(Xn=!0),Qn&&(we=W({},Xd),$e=oo(null),Qn.html===!0&&(W(we,Jd),W($e,Qd)),Qn.svg===!0&&(W(we,tl),W($e,sl),W($e,Vi)),Qn.svgFilters===!0&&(W(we,nl),W($e,sl),W($e,Vi)),Qn.mathMl===!0&&(W(we,rl),W($e,ef),W($e,Vi))),He(g,"ADD_TAGS")||(Vt.tagCheck=null),He(g,"ADD_ATTR")||(Vt.attributeCheck=null),g.ADD_TAGS&&(typeof g.ADD_TAGS=="function"?Vt.tagCheck=g.ADD_TAGS:(we===su&&(we=gt(we)),W(we,g.ADD_TAGS,ve))),g.ADD_ATTR&&(typeof g.ADD_ATTR=="function"?Vt.attributeCheck=g.ADD_ATTR:($e===iu&&($e=gt($e)),W($e,g.ADD_ATTR,ve))),g.ADD_URI_SAFE_ATTR&&W(aa,g.ADD_URI_SAFE_ATTR,ve),g.FORBID_CONTENTS&&(ht===oa&&(ht=gt(ht)),W(ht,g.FORBID_CONTENTS,ve)),g.ADD_FORBID_CONTENTS&&(ht===oa&&(ht=gt(ht)),W(ht,g.ADD_FORBID_CONTENTS,ve)),ia&&(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=vD(m,s)),F!==null&&typeof L=="string"&&(L=F.createHTML(""));Le&&Le(g),tr=g}},gu=W({},[...tl,...nl,...oD]),mu=W({},[...rl,...aD]),xv=function(g){let C=j(g);(!C||!C.tagName)&&(C={namespaceURI:er,tagName:"template"});const P=ao(g.tagName),se=ao(C.tagName);return ca[g.namespaceURI]?g.namespaceURI===xi?C.namespaceURI===Et?P==="svg":C.namespaceURI===Ai?P==="svg"&&(se==="annotation-xml"||Ci[se]):!!gu[P]:g.namespaceURI===Ai?C.namespaceURI===Et?P==="math":C.namespaceURI===xi?P==="math"&&Ti[se]:!!mu[P]:g.namespaceURI===Et?C.namespaceURI===xi&&!Ti[se]||C.namespaceURI===Ai&&!Ci[se]?!1:!mu[P]&&(kv[P]||!gu[P]):!!(es==="application/xhtml+xml"&&ca[g.namespaceURI]):!1},dt=function(g){as(e.removed,{element:g});try{j(g).removeChild(g)}catch{I(g)}},vn=function(g,C){try{as(e.removed,{attribute:C.getAttributeNode(g),from:C})}catch{as(e.removed,{attribute:null,from:C})}if(C.removeAttribute(g),g==="is")if(Xn||Ei)try{dt(C)}catch{}else try{C.setAttribute(g,"")}catch{}},vu=function(g){let C=null,P=null;if(sa)g="<remove></remove>"+g;else{const pe=el(g,/^[\r\n\t ]+/);P=pe&&pe[0]}es==="application/xhtml+xml"&&er===Et&&(g='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+g+"</body></html>");const se=F?F.createHTML(g):g;if(er===Et)try{C=new y().parseFromString(se,es)}catch{}if(!C||!C.documentElement){C=J.createDocument(er,"template",null);try{C.documentElement.innerHTML=la?L:se}catch{}}const Ie=C.body||C.documentElement;return g&&P&&Ie.insertBefore(n.createTextNode(P),Ie.childNodes[0]||null),er===Et?ct.call(C,mn?"html":"body")[0]:mn?C.documentElement:Ie},yu=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)},ha=function(g){return g instanceof f&&(typeof g.nodeName!="string"||typeof g.textContent!="string"||typeof g.removeChild!="function"||!(g.attributes instanceof d)||typeof g.removeAttribute!="function"||typeof g.setAttribute!="function"||typeof g.namespaceURI!="string"||typeof g.insertBefore!="function"||typeof g.hasChildNodes!="function")},bu=function(g){return typeof a=="function"&&g instanceof a};function $t(O,g,C){Bi(O,P=>{P.call(e,g,C,tr)})}const wu=function(g){let C=null;if($t(Ee.beforeSanitizeElements,g,null),ha(g))return dt(g),!0;const P=ve(g.nodeName);if($t(Ee.uponSanitizeElement,g,{tagName:P,allowedTags:we}),ki&&g.hasChildNodes()&&!bu(g.firstElementChild)&&Re(/<[/\w!]/g,g.innerHTML)&&Re(/<[/\w!]/g,g.textContent)||g.nodeType===hs.progressingInstruction||ki&&g.nodeType===hs.comment&&Re(/<[/\w]/g,g.data))return dt(g),!0;if(!(Vt.tagCheck instanceof Function&&Vt.tagCheck(P))&&(!we[P]||Xr[P])){if(!Xr[P]&&Su(P)&&(fe.tagNameCheck instanceof RegExp&&Re(fe.tagNameCheck,P)||fe.tagNameCheck instanceof Function&&fe.tagNameCheck(P)))return!1;if(ia&&!ht[P]){const se=j(g)||g.parentNode,Ie=N(g)||g.childNodes;if(Ie&&se){const pe=Ie.length;for(let Ne=pe-1;Ne>=0;--Ne){const At=k(Ie[Ne],!0);At.__removalCount=(g.__removalCount||0)+1,se.insertBefore(At,V(g))}}}return dt(g),!0}return g instanceof l&&!xv(g)||(P==="noscript"||P==="noembed"||P==="noframes")&&Re(/<\/no(script|embed|frames)/i,g.innerHTML)?(dt(g),!0):(Jn&&g.nodeType===hs.text&&(C=g.textContent,Bi([gn,ut,Bt],se=>{C=ls(C,se," ")}),g.textContent!==C&&(as(e.removed,{element:g.cloneNode()}),g.textContent=C)),$t(Ee.afterSanitizeElements,g,null),!1)},_u=function(g,C,P){if(Si[C]||cu&&(C==="id"||C==="name")&&(P in n||P in Av))return!1;if(!(na&&!Si[C]&&Re(ta,C))){if(!(ou&&Re(_i,C))){if(!(Vt.attributeCheck instanceof Function&&Vt.attributeCheck(C,g))){if(!$e[C]||Si[C]){if(!(Su(g)&&(fe.tagNameCheck instanceof RegExp&&Re(fe.tagNameCheck,g)||fe.tagNameCheck instanceof Function&&fe.tagNameCheck(g))&&(fe.attributeNameCheck instanceof RegExp&&Re(fe.attributeNameCheck,C)||fe.attributeNameCheck instanceof Function&&fe.attributeNameCheck(C,g))||C==="is"&&fe.allowCustomizedBuiltInElements&&(fe.tagNameCheck instanceof RegExp&&Re(fe.tagNameCheck,P)||fe.tagNameCheck instanceof Function&&fe.tagNameCheck(P))))return!1}else if(!aa[C]){if(!Re(ru,ls(P,nu,""))){if(!((C==="src"||C==="xlink:href"||C==="href")&&g!=="script"&&nD(P,"data:")===0&&hu[g])){if(!(au&&!Re(bv,ls(P,nu,"")))){if(P)return!1}}}}}}}return!0},Su=function(g){return g!=="annotation-xml"&&el(g,wv)},ku=function(g){$t(Ee.beforeSanitizeAttributes,g,null);const{attributes:C}=g;if(!C||ha(g))return;const P={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:$e,forceKeepAttr:void 0};let se=C.length;for(;se--;){const Ie=C[se],{name:pe,namespaceURI:Ne,value:At}=Ie,nr=ve(pe),da=At;let Ae=pe==="value"?da:rD(da);if(P.attrName=nr,P.attrValue=Ae,P.keepAttr=!0,P.forceKeepAttr=void 0,$t(Ee.uponSanitizeAttribute,g,P),Ae=P.attrValue,uu&&(nr==="id"||nr==="name")&&(vn(pe,g),Ae=_v+Ae),ki&&Re(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,Ae)){vn(pe,g);continue}if(nr==="attributename"&&el(Ae,"href")){vn(pe,g);continue}if(P.forceKeepAttr)continue;if(!P.keepAttr){vn(pe,g);continue}if(!lu&&Re(/\/>/i,Ae)){vn(pe,g);continue}Jn&&Bi([gn,ut,Bt],$u=>{Ae=ls(Ae,$u," ")});const Eu=ve(g.nodeName);if(!_u(Eu,nr,Ae)){vn(pe,g);continue}if(F&&typeof m=="object"&&typeof m.getAttributeType=="function"&&!Ne)switch(m.getAttributeType(Eu,nr)){case"TrustedHTML":{Ae=F.createHTML(Ae);break}case"TrustedScriptURL":{Ae=F.createScriptURL(Ae);break}}if(Ae!==da)try{Ne?g.setAttributeNS(Ne,pe,Ae):g.setAttribute(pe,Ae),ha(g)?dt(g):Kd(e.removed)}catch{vn(pe,g)}}$t(Ee.afterSanitizeAttributes,g,null)},Cv=function O(g){let C=null;const P=yu(g);for($t(Ee.beforeSanitizeShadowDOM,g,null);C=P.nextNode();)$t(Ee.uponSanitizeShadowNode,C,null),wu(C),ku(C),C.content instanceof i&&O(C.content);$t(Ee.afterSanitizeShadowDOM,g,null)};return e.sanitize=function(O){let g=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},C=null,P=null,se=null,Ie=null;if(la=!O,la&&(O="<!-->"),typeof O!="string"&&!bu(O))if(typeof O.toString=="function"){if(O=O.toString(),typeof O!="string")throw cs("dirty is not a string, aborting")}else throw cs("toString is not a function");if(!e.isSupported)return O;if(ra||ua(g),e.removed=[],typeof O=="string"&&(Qr=!1),Qr){if(O.nodeName){const At=ve(O.nodeName);if(!we[At]||Xr[At])throw cs("root node is forbidden and cannot be sanitized in-place")}}else if(O instanceof a)C=vu("<!---->"),P=C.ownerDocument.importNode(O,!0),P.nodeType===hs.element&&P.nodeName==="BODY"||P.nodeName==="HTML"?C=P:C.appendChild(P);else{if(!Xn&&!Jn&&!mn&&O.indexOf("<")===-1)return F&&$i?F.createHTML(O):O;if(C=vu(O),!C)return Xn?null:$i?L:""}C&&sa&&dt(C.firstChild);const pe=yu(Qr?O:C);for(;se=pe.nextNode();)wu(se),ku(se),se.content instanceof i&&Cv(se.content);if(Qr)return O;if(Xn){if(Ei)for(Ie=he.call(C.ownerDocument);C.firstChild;)Ie.appendChild(C.firstChild);else Ie=C;return($e.shadowroot||$e.shadowrootmode)&&(Ie=wi.call(r,Ie,!0)),Ie}let Ne=mn?C.outerHTML:C.innerHTML;return mn&&we["!doctype"]&&C.ownerDocument&&C.ownerDocument.doctype&&C.ownerDocument.doctype.name&&Re(Ym,C.ownerDocument.doctype.name)&&(Ne="<!DOCTYPE "+C.ownerDocument.doctype.name+`>
253
+ `+Ne),Jn&&Bi([gn,ut,Bt],At=>{Ne=ls(Ne,At," ")}),F&&$i?F.createHTML(Ne):Ne},e.setConfig=function(){let O=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};ua(O),ra=!0},e.clearConfig=function(){tr=null,ra=!1},e.isValidAttribute=function(O,g,C){tr||ua({});const P=ve(O),se=ve(g);return _u(P,se,C)},e.addHook=function(O,g){typeof g=="function"&&as(Ee[O],g)},e.removeHook=function(O,g){if(g!==void 0){const C=eD(Ee[O],g);return C===-1?void 0:tD(Ee[O],C,1)[0]}return Kd(Ee[O])},e.removeHooks=function(O){Ee[O]=[]},e.removeAllHooks=function(){Ee=nf()},e}var Jm=Km();function Vc(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Kn=Vc();function Xm(t){Kn=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(ze.caret,"$1"),n=n.replace(s,o),r},getRegex:()=>new RegExp(n,e)};return r}var yD=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),ze={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)}}>`)},bD=/^(?:[ \t]*(?:\n|$))+/,wD=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,_D=/^ {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+|$)/,SD=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Gc=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Qm=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,ev=q(Qm).replace(/bull/g,Gc).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(),kD=q(Qm).replace(/bull/g,Gc).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(),Hc=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,ED=/^[^\n]+/,qc=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,$D=q(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",qc).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),AD=q(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Gc).getRegex(),Xo="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",Yc=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,xD=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",Yc).replace("tag",Xo).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),tv=q(Hc).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",Xo).getRegex(),CD=q(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",tv).getRegex(),Kc={blockquote:CD,code:wD,def:$D,fences:_D,heading:SD,hr:bi,html:xD,lheading:ev,list:AD,newline:bD,paragraph:tv,table:$n,text:ED},rf=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",Xo).getRegex(),TD={...Kc,lheading:kD,table:rf,paragraph:q(Hc).replace("hr",bi).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",rf).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",Xo).getRegex()},ID={...Kc,html:q(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Yc).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(Hc).replace("hr",bi).replace("heading",` *#{1,6} *[^
254
+ ]`).replace("lheading",ev).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},PD=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,RD=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,nv=/^( {2,}|\\)\n(?!\s*$)/,DD=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Jr=/[\p{P}\p{S}]/u,Qo=/[\s\p{P}\p{S}]/u,Jc=/[^\s\p{P}\p{S}]/u,OD=q(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Qo).getRegex(),rv=/(?!~)[\p{P}\p{S}]/u,zD=/(?!~)[\s\p{P}\p{S}]/u,LD=/(?:[^\s\p{P}\p{S}]|~)/u,MD=q(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",yD?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),sv=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,ND=q(sv,"u").replace(/punct/g,Jr).getRegex(),UD=q(sv,"u").replace(/punct/g,rv).getRegex(),iv="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",FD=q(iv,"gu").replace(/notPunctSpace/g,Jc).replace(/punctSpace/g,Qo).replace(/punct/g,Jr).getRegex(),ZD=q(iv,"gu").replace(/notPunctSpace/g,LD).replace(/punctSpace/g,zD).replace(/punct/g,rv).getRegex(),jD=q("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Jc).replace(/punctSpace/g,Qo).replace(/punct/g,Jr).getRegex(),WD=q(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,Jr).getRegex(),BD="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",VD=q(BD,"gu").replace(/notPunctSpace/g,Jc).replace(/punctSpace/g,Qo).replace(/punct/g,Jr).getRegex(),GD=q(/\\(punct)/,"gu").replace(/punct/g,Jr).getRegex(),HD=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(),qD=q(Yc).replace("(?:-->|$)","-->").getRegex(),YD=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",qD).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),ko=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,KD=q(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",ko).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),ov=q(/^!?\[(label)\]\[(ref)\]/).replace("label",ko).replace("ref",qc).getRegex(),av=q(/^!?\[(ref)\](?:\[\])?/).replace("ref",qc).getRegex(),JD=q("reflink|nolink(?!\\()","g").replace("reflink",ov).replace("nolink",av).getRegex(),sf=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Xc={_backpedal:$n,anyPunctuation:GD,autolink:HD,blockSkip:MD,br:nv,code:RD,del:$n,delLDelim:$n,delRDelim:$n,emStrongLDelim:ND,emStrongRDelimAst:FD,emStrongRDelimUnd:jD,escape:PD,link:KD,nolink:av,punctuation:OD,reflink:ov,reflinkSearch:JD,tag:YD,text:DD,url:$n},XD={...Xc,link:q(/^!?\[(label)\]\((.*?)\)/).replace("label",ko).getRegex(),reflink:q(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",ko).getRegex()},ql={...Xc,emStrongRDelimAst:ZD,emStrongLDelim:UD,delLDelim:WD,delRDelim:VD,url:q(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",sf).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",sf).getRegex()},QD={...ql,br:q(nv).replace("{2,}","*").getRegex(),text:q(ql.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Gi={normal:Kc,gfm:TD,pedantic:ID},ds={normal:Xc,gfm:ql,breaks:QD,pedantic:XD},eO={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},of=t=>eO[t];function mt(t,e){if(e){if(ze.escapeTest.test(t))return t.replace(ze.escapeReplace,of)}else if(ze.escapeTestNoEncode.test(t))return t.replace(ze.escapeReplaceNoEncode,of);return t}function af(t){try{t=encodeURI(t).replace(ze.percentDecode,"%")}catch{return null}return t}function lf(t,e){var i;let n=t.replace(ze.findPipe,(o,a,l)=>{let c=!1,d=a;for(;--d>=0&&l[d]==="\\";)c=!c;return c?"|":" |"}),r=n.split(ze.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(ze.slashPipe,"|");return r}function fs(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 tO(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 nO(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 cf(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 rO(t,e,n){let r=t.match(n.other.indentCodeCompensation);if(r===null)return e;let s=r[1];return e.split(`
251
255
  `).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(`
252
- `)}var Eo=class{constructor(t){v(this,"options");v(this,"rules");v(this,"lexer");this.options=t||Kn}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:ds(n,`
253
- `)}}}fences(t){let e=this.rules.block.fences.exec(t);if(e){let n=e[0],r=iO(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=ds(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:ds(e[0],`
254
- `)}}blockquote(t){let e=this.rules.block.blockquote.exec(t);if(e){let n=ds(e[0],`
256
+ `)}var Eo=class{constructor(t){v(this,"options");v(this,"rules");v(this,"lexer");this.options=t||Kn}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:fs(n,`
257
+ `)}}}fences(t){let e=this.rules.block.fences.exec(t);if(e){let n=e[0],r=rO(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=fs(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:fs(e[0],`
258
+ `)}}blockquote(t){let e=this.rules.block.blockquote.exec(t);if(e){let n=fs(e[0],`
255
259
  `).split(`
256
260
  `),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(`
257
261
  `),d=c.replace(this.rules.other.blockquoteSetextReplace,`
@@ -262,16 +266,16 @@ ${d}`:d;let f=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTo
262
266
  `),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+`
263
267
  `+n.join(`
264
268
  `),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(`
265
- `);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,f="",y="";if(!(e=a.exec(t))||this.rules.block.hr.test(t))break;f=e[0],t=t.substring(f.length);let m=sO(e[2].split(`
269
+ `);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,f="",y="";if(!(e=a.exec(t))||this.rules.block.hr.test(t))break;f=e[0],t=t.substring(f.length);let m=nO(e[2].split(`
266
270
  `,1)[0],e[1].length),E=t.split(`
267
271
  `,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)&&(f+=E+`
268
272
  `,t=t.substring(E.length+1),d=!0),!d){let V=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(`
269
273
  `,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)||V.test(E)||N.test(E))break;if(he.search(this.rules.other.nonSpaceChar)>=I||!E.trim())y+=`
270
274
  `+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+=`
271
275
  `+E}k=!E.trim(),f+=H+`
272
- `,t=t.substring(H.length+1),m=he.slice(I)}}o.loose||(l?o.loose=!0:this.rules.other.doubleBlankLine.test(f)&&(l=!0)),o.items.push({type:"list_item",raw:f,task:!!this.options.gfm&&this.rules.other.listIsTask.test(y),loose:!1,text:y,tokens:[]}),o.raw+=f}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 f=this.rules.other.listTaskCheckbox.exec(d.raw);if(f){let y={type:"checkbox",raw:f[0]+" ",checked:f[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 f=d.tokens.filter(m=>m.type==="space"),y=f.length>0&&f.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 f of d.tokens)f.type==="text"&&(f.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=of(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(`
273
- `):[],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(of(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)===`
274
- `?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=ds(n.slice(0,-1),"\\");if((n.length-i.length)%2===0)return}else{let i=rO(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)),af(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 af(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,f=t.slice(0,s+r.index+d+o);if(Math.min(s,o)%2){let m=f.slice(1,-1);return{type:"em",raw:f,text:m,tokens:this.lexer.inlineTokens(m)}}let y=f.slice(2,-2);return{type:"strong",raw:f,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),f=d.slice(s,-s);return{type:"del",raw:d,text:f,tokens:this.lexer.inlineTokens(f)}}}}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}}}},at=class Gl{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||Kn,this.options.tokenizer=this.options.tokenizer||new Eo,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:ze,block:Gi.normal,inline:hs.normal};this.options.pedantic?(n.block=Gi.pedantic,n.inline=hs.pedantic):this.options.gfm&&(n.block=Gi.gfm,this.options.breaks?n.inline=hs.breaks:n.inline=hs.gfm),this.tokenizer.rules=n}static get rules(){return{block:Gi,inline:hs}}static lex(e,n){return new Gl(n).lex(e)}static lexInline(e,n){return new Gl(n).inlineTokens(e)}lex(e){e=e.replace(ze.carriageReturn,`
276
+ `,t=t.substring(H.length+1),m=he.slice(I)}}o.loose||(l?o.loose=!0:this.rules.other.doubleBlankLine.test(f)&&(l=!0)),o.items.push({type:"list_item",raw:f,task:!!this.options.gfm&&this.rules.other.listIsTask.test(y),loose:!1,text:y,tokens:[]}),o.raw+=f}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 f=this.rules.other.listTaskCheckbox.exec(d.raw);if(f){let y={type:"checkbox",raw:f[0]+" ",checked:f[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 f=d.tokens.filter(m=>m.type==="space"),y=f.length>0&&f.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 f of d.tokens)f.type==="text"&&(f.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=lf(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(`
277
+ `):[],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(lf(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)===`
278
+ `?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=fs(n.slice(0,-1),"\\");if((n.length-i.length)%2===0)return}else{let i=tO(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)),cf(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 cf(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,f=t.slice(0,s+r.index+d+o);if(Math.min(s,o)%2){let m=f.slice(1,-1);return{type:"em",raw:f,text:m,tokens:this.lexer.inlineTokens(m)}}let y=f.slice(2,-2);return{type:"strong",raw:f,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),f=d.slice(s,-s);return{type:"del",raw:d,text:f,tokens:this.lexer.inlineTokens(f)}}}}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}}}},at=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||Kn,this.options.tokenizer=this.options.tokenizer||new Eo,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:ze,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(ze.carriageReturn,`
275
279
  `),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(ze.tabCharGlobal," ").replace(ze.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+=`
276
280
  `: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(`
277
281
  `)?"":`
@@ -303,13 +307,13 @@ ${this.parser.parse(t)}</blockquote>
303
307
  `}tablerow({text:t}){return`<tr>
304
308
  ${t}</tr>
305
309
  `}tablecell(t){let e=this.parser.parseInline(t.tokens),n=t.header?"th":"td";return(t.align?`<${n} align="${t.align}">`:`<${n}>`)+e+`</${n}>
306
- `}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>${mt(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=sf(t);if(s===null)return r;t=s;let i='<a href="'+t+'"';return e&&(i+=' title="'+mt(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=sf(t);if(s===null)return mt(n);t=s;let i=`<img src="${t}" alt="${mt(n)}"`;return e&&(i+=` title="${mt(e)}"`),i+=">",i}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:mt(t.text)}},Kc=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}},lt=class Hl{constructor(e){v(this,"options");v(this,"renderer");v(this,"textRenderer");this.options=e||Kn,this.options.renderer=this.options.renderer||new $o,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Kc}static parse(e,n){return new Hl(n).parse(e)}static parseInline(e,n){return new Hl(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}},Hi,bs=(Hi=class{constructor(t){v(this,"options");v(this,"block");this.options=t||Kn}preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}emStrongMask(t){return t}provideLexer(){return this.block?at.lex:at.lexInline}provideParser(){return this.block?lt.parse:lt.parseInline}},v(Hi,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),v(Hi,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),Hi),oO=class{constructor(...t){v(this,"defaults",jc());v(this,"options",this.setOptions);v(this,"parse",this.parseMarkdown(!0));v(this,"parseInline",this.parseMarkdown(!1));v(this,"Parser",lt);v(this,"Renderer",$o);v(this,"TextRenderer",Kc);v(this,"Lexer",at);v(this,"Tokenizer",Eo);v(this,"Hooks",bs);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 $o(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 Eo(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 bs;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];bs.passThroughHooks.has(i)?s[o]=c=>{if(this.defaults.async&&bs.passThroughHooksRespectAsync.has(i))return(async()=>{let f=await a.call(s,c);return l.call(s,f)})();let d=a.call(s,c);return l.call(s,d)}:s[o]=(...c)=>{if(this.defaults.async)return(async()=>{let f=await a.apply(s,c);return f===!1&&(f=await l.apply(s,c)),f})();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 at.lex(t,e??this.defaults)}parser(t,e){return lt.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?at.lex:at.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?lt.parse:lt.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?at.lex:at.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?lt.parse:lt.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+=`
307
- Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error occurred:</p><pre>"+mt(n.message+"",!0)+"</pre>";return e?Promise.resolve(r):r}if(e)return Promise.reject(n);throw n}}},Vn=new oO;function X(t,e){return Vn.parse(t,e)}X.options=X.setOptions=function(t){return Vn.setOptions(t),X.defaults=Vn.defaults,Xm(X.defaults),X};X.getDefaults=jc;X.defaults=Kn;X.use=function(...t){return Vn.use(...t),X.defaults=Vn.defaults,Xm(X.defaults),X};X.walkTokens=function(t,e){return Vn.walkTokens(t,e)};X.parseInline=Vn.parseInline;X.Parser=lt;X.parser=lt.parse;X.Renderer=$o;X.TextRenderer=Kc;X.Lexer=at;X.lexer=at.lex;X.Tokenizer=Eo;X.Hooks=bs;X.parse=X;X.options;X.setOptions;X.use;X.walkTokens;X.parseInline;lt.parse;at.lex;const aO=8;let lf=!1;function lO(){lf||(lf=!0,Jm.addHook("afterSanitizeAttributes",t=>{t.tagName==="A"&&(t.setAttribute("target","_blank"),t.setAttribute("rel","noopener noreferrer"))}))}function cO(t){lO();const e=X.parse(t,{async:!1});return Jm.sanitize(e,{USE_PROFILES:{html:!0}})}function uO(t){return t.kind==="user"||t.kind==="assistant"}function cf(t,e){for(let n=t.length-1;n>=0;n-=1){const r=t[n];if(r&&r.kind===e)return r.id}return null}var Mt,Cr,Nt,Ir,qe,ws,cv,ri,Ro,lo;class lv extends Ds{constructor(){super(...arguments);x(this,qe);v(this,"messages",[]);x(this,Mt,!0);x(this,Cr,null);x(this,Nt,null);x(this,Ir,!1);x(this,ri,()=>{const n=h(this,Nt);if(!n)return;const s=n.scrollHeight-n.clientHeight-n.scrollTop<=aO;s!==h(this,Mt)&&($(this,Mt,s),b(this,qe,ws).call(this))});x(this,Ro,()=>{$(this,Mt,!0),b(this,qe,ws).call(this),b(this,qe,lo).call(this,{force:!0})})}connectedCallback(){$(this,Ir,!0),$(this,Cr,cf(this.messages??[],"user")),b(this,qe,ws).call(this),b(this,qe,lo).call(this,{force:!0})}disconnectedCallback(){$(this,Ir,!1),$(this,Nt,null)}propertyChangedCallback(n,r,s){if(n!=="messages"||!h(this,Ir))return;const i=this.messages??[],o=cf(i,"user"),a=o!==null&&o!==h(this,Cr);$(this,Cr,o),a&&$(this,Mt,!0),b(this,qe,ws).call(this),b(this,qe,lo).call(this,{force:a})}}Mt=new WeakMap,Cr=new WeakMap,Nt=new WeakMap,Ir=new WeakMap,qe=new WeakSet,ws=function(){var i;const n=(this.messages??[]).filter(uO),r=h(this,Mt);be(M`
310
+ `}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>${mt(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=af(t);if(s===null)return r;t=s;let i='<a href="'+t+'"';return e&&(i+=' title="'+mt(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=af(t);if(s===null)return mt(n);t=s;let i=`<img src="${t}" alt="${mt(n)}"`;return e&&(i+=` title="${mt(e)}"`),i+=">",i}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:mt(t.text)}},Qc=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}},lt=class Kl{constructor(e){v(this,"options");v(this,"renderer");v(this,"textRenderer");this.options=e||Kn,this.options.renderer=this.options.renderer||new $o,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Qc}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}},Hi,ws=(Hi=class{constructor(t){v(this,"options");v(this,"block");this.options=t||Kn}preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}emStrongMask(t){return t}provideLexer(){return this.block?at.lex:at.lexInline}provideParser(){return this.block?lt.parse:lt.parseInline}},v(Hi,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),v(Hi,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),Hi),sO=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",lt);v(this,"Renderer",$o);v(this,"TextRenderer",Qc);v(this,"Lexer",at);v(this,"Tokenizer",Eo);v(this,"Hooks",ws);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 $o(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 Eo(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 ws;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];ws.passThroughHooks.has(i)?s[o]=c=>{if(this.defaults.async&&ws.passThroughHooksRespectAsync.has(i))return(async()=>{let f=await a.call(s,c);return l.call(s,f)})();let d=a.call(s,c);return l.call(s,d)}:s[o]=(...c)=>{if(this.defaults.async)return(async()=>{let f=await a.apply(s,c);return f===!1&&(f=await l.apply(s,c)),f})();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 at.lex(t,e??this.defaults)}parser(t,e){return lt.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?at.lex:at.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?lt.parse:lt.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?at.lex:at.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?lt.parse:lt.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+=`
311
+ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error occurred:</p><pre>"+mt(n.message+"",!0)+"</pre>";return e?Promise.resolve(r):r}if(e)return Promise.reject(n);throw n}}},Vn=new sO;function X(t,e){return Vn.parse(t,e)}X.options=X.setOptions=function(t){return Vn.setOptions(t),X.defaults=Vn.defaults,Xm(X.defaults),X};X.getDefaults=Vc;X.defaults=Kn;X.use=function(...t){return Vn.use(...t),X.defaults=Vn.defaults,Xm(X.defaults),X};X.walkTokens=function(t,e){return Vn.walkTokens(t,e)};X.parseInline=Vn.parseInline;X.Parser=lt;X.parser=lt.parse;X.Renderer=$o;X.TextRenderer=Qc;X.Lexer=at;X.lexer=at.lex;X.Tokenizer=Eo;X.Hooks=ws;X.parse=X;X.options;X.setOptions;X.use;X.walkTokens;X.parseInline;lt.parse;at.lex;const iO=8;let uf=!1;function oO(){uf||(uf=!0,Jm.addHook("afterSanitizeAttributes",t=>{t.tagName==="A"&&(t.setAttribute("target","_blank"),t.setAttribute("rel","noopener noreferrer"))}))}function aO(t){oO();const e=X.parse(t,{async:!1});return Jm.sanitize(e,{USE_PROFILES:{html:!0}})}function lO(t){return t.kind==="user"||t.kind==="assistant"}function hf(t,e){for(let n=t.length-1;n>=0;n-=1){const r=t[n];if(r&&r.kind===e)return r.id}return null}var Mt,Tr,Nt,Ir,qe,_s,cv,si,Ro,lo;class lv extends Os{constructor(){super(...arguments);x(this,qe);v(this,"messages",[]);x(this,Mt,!0);x(this,Tr,null);x(this,Nt,null);x(this,Ir,!1);x(this,si,()=>{const n=h(this,Nt);if(!n)return;const s=n.scrollHeight-n.clientHeight-n.scrollTop<=iO;s!==h(this,Mt)&&($(this,Mt,s),b(this,qe,_s).call(this))});x(this,Ro,()=>{$(this,Mt,!0),b(this,qe,_s).call(this),b(this,qe,lo).call(this,{force:!0})})}connectedCallback(){$(this,Ir,!0),$(this,Tr,hf(this.messages??[],"user")),b(this,qe,_s).call(this),b(this,qe,lo).call(this,{force:!0})}disconnectedCallback(){$(this,Ir,!1),$(this,Nt,null)}propertyChangedCallback(n,r,s){if(n!=="messages"||!h(this,Ir))return;const i=this.messages??[],o=hf(i,"user"),a=o!==null&&o!==h(this,Tr);$(this,Tr,o),a&&$(this,Mt,!0),b(this,qe,_s).call(this),b(this,qe,lo).call(this,{force:a})}}Mt=new WeakMap,Tr=new WeakMap,Nt=new WeakMap,Ir=new WeakMap,qe=new WeakSet,_s=function(){var i;const n=(this.messages??[]).filter(lO),r=h(this,Mt);be(M`
308
312
  <div
309
313
  class="chat-history-scroll"
310
314
  role="log"
311
315
  aria-live="polite"
312
- @scroll=${h(this,ri)}
316
+ @scroll=${h(this,si)}
313
317
  >
314
318
  ${n.map(o=>b(this,qe,cv).call(this,o))}
315
319
  </div>
@@ -320,10 +324,10 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
320
324
  ?hidden=${r}
321
325
  @click=${h(this,Ro)}
322
326
  >
323
- ${Cl({size:14})}
327
+ ${Rl({size:14})}
324
328
  <span>Jump to latest</span>
325
329
  </button>
326
- `,this);const s=this.querySelector(".chat-history-scroll");s&&s!==h(this,Nt)&&((i=h(this,Nt))==null||i.removeEventListener("scroll",h(this,ri)),$(this,Nt,s))},cv=function(n){const r=OR(cO(n.text));if(n.kind==="user")return M`
330
+ `,this);const s=this.querySelector(".chat-history-scroll");s&&s!==h(this,Nt)&&((i=h(this,Nt))==null||i.removeEventListener("scroll",h(this,si)),$(this,Nt,s))},cv=function(n){const r=PR(aO(n.text));if(n.kind==="user")return M`
327
331
  <div class="chat-message chat-message-user">
328
332
  <div class="chat-message-body">${r}</div>
329
333
  </div>
@@ -331,7 +335,7 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
331
335
  <div class="chat-message chat-message-assistant">
332
336
  <div class="chat-message-body">${r}${s}</div>
333
337
  </div>
334
- `},ri=new WeakMap,Ro=new WeakMap,lo=function(n){requestAnimationFrame(()=>{const r=h(this,Nt);r&&(!h(this,Mt)&&!n.force||(r.scrollTop=r.scrollHeight-r.clientHeight))})},v(lv,"observedProperties",{messages:{type:Object}});customElements.define("chat-history",lv);const hO=Be(),dO=Be(),fO=Be(),pO=3;class uv extends Ds{constructor(){super(...arguments);v(this,"value","");v(this,"disabled",!1);v(this,"disabledPlaceholder","");v(this,"action","send");v(this,"handleInput",n=>{const s=n.currentTarget.value??"";this.value=s,this.dispatchEvent(new hO("change",{value:s,bubbles:!0,composed:!0}))});v(this,"handleKeyDown",n=>{n.key==="Enter"&&(n.shiftKey||n.isComposing||(n.preventDefault(),!this.disabled&&this.action==="send"&&this.submitMessage()))});v(this,"handleButtonClick",()=>{this.disabled||(this.action==="send"?this.submitMessage():this.dispatchEvent(new fO("cancel",{bubbles:!0,composed:!0})))})}connectedCallback(){this.render()}propertyChangedCallback(){this.render()}get textareaEl(){return this.querySelector("textarea")}submitMessage(){var r;const n=(this.value??"").trim();n.length!==0&&(this.dispatchEvent(new dO("submit",{text:n,bubbles:!0,composed:!0})),(r=this.textareaEl)==null||r.focus())}computeRows(){const n=(this.value??"").split(/\r?\n/).length;return Math.min(pO,Math.max(1,n))}render(){const n=this.action==="send",r=n?"Send message":"Cancel",s=n?UR({size:16}):NR({size:16}),i=this.computeRows(),o=this.value??"",a=this.disabled?"":o,l=this.disabled?this.disabledPlaceholder:"";be(M`
338
+ `},si=new WeakMap,Ro=new WeakMap,lo=function(n){requestAnimationFrame(()=>{const r=h(this,Nt);r&&(!h(this,Mt)&&!n.force||(r.scrollTop=r.scrollHeight-r.clientHeight))})},v(lv,"observedProperties",{messages:{type:Object}});customElements.define("chat-history",lv);const cO=Be(),uO=Be(),hO=Be(),dO=3;class uv extends Os{constructor(){super(...arguments);v(this,"value","");v(this,"disabled",!1);v(this,"disabledPlaceholder","");v(this,"action","send");v(this,"handleInput",n=>{const s=n.currentTarget.value??"";this.value=s,this.dispatchEvent(new cO("change",{value:s,bubbles:!0,composed:!0}))});v(this,"handleKeyDown",n=>{n.key==="Enter"&&(n.shiftKey||n.isComposing||(n.preventDefault(),!this.disabled&&this.action==="send"&&this.submitMessage()))});v(this,"handleButtonClick",()=>{this.disabled||(this.action==="send"?this.submitMessage():this.dispatchEvent(new hO("cancel",{bubbles:!0,composed:!0})))})}connectedCallback(){this.render()}propertyChangedCallback(){this.render()}get textareaEl(){return this.querySelector("textarea")}submitMessage(){var r;const n=(this.value??"").trim();n.length!==0&&(this.dispatchEvent(new uO("submit",{text:n,bubbles:!0,composed:!0})),(r=this.textareaEl)==null||r.focus())}computeRows(){const n=(this.value??"").split(/\r?\n/).length;return Math.min(dO,Math.max(1,n))}render(){const n=this.action==="send",r=n?"Send message":"Cancel",s=n?MR({size:16}):LR({size:16}),i=this.computeRows(),o=this.value??"",a=this.disabled?"":o,l=this.disabled?this.disabledPlaceholder:"";be(M`
335
339
  <textarea
336
340
  .value=${a}
337
341
  placeholder=${l}
@@ -348,7 +352,7 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
348
352
  >
349
353
  ${s}
350
354
  </button>
351
- `,this)}}v(uv,"observedProperties",{value:{type:String},disabled:{type:Boolean},disabledPlaceholder:{type:String},action:{type:String}});customElements.define("chat-input",uv);var Un,xe,Pr,Fn,si,Pe,ql,Yl,ii,Do,Oo,zo,hv,pr;class gO extends HTMLElement{constructor(){super(...arguments);x(this,Pe);x(this,Un,Ye.resolve("ACPClientManager"));x(this,xe,null);x(this,Pr,"");x(this,Fn,!1);x(this,si,()=>{if(!h(this,Fn))return;const n=h(this,Un).getActiveClient();n!==h(this,xe)&&(b(this,Pe,Yl).call(this),b(this,Pe,ql).call(this,n)),b(this,Pe,pr).call(this)});x(this,ii,()=>{h(this,Fn)&&b(this,Pe,pr).call(this)});x(this,Do,n=>{const r=n.value;$(this,Pr,r),b(this,Pe,pr).call(this)});x(this,Oo,n=>{if(!h(this,xe))return;const r=n.text;$(this,Pr,""),b(this,Pe,pr).call(this),h(this,xe).sendMessage({text:r}).catch(s=>{console.error("ACPClient.sendMessage() failed",s)})});x(this,zo,n=>{h(this,xe)&&h(this,xe).cancel().catch(r=>{console.error("ACPClient.cancel() failed",r)})})}connectedCallback(){$(this,Fn,!0),h(this,Un).addEventListener("change",h(this,si)),b(this,Pe,ql).call(this,h(this,Un).getActiveClient()),b(this,Pe,pr).call(this)}disconnectedCallback(){$(this,Fn,!1),h(this,Un).removeEventListener("change",h(this,si)),b(this,Pe,Yl).call(this)}}Un=new WeakMap,xe=new WeakMap,Pr=new WeakMap,Fn=new WeakMap,si=new WeakMap,Pe=new WeakSet,ql=function(n){$(this,xe,n),h(this,xe)&&(h(this,xe).addEventListener("change",h(this,ii)),h(this,xe).connect().catch(r=>{console.error("ACPClient.connect() failed",r)}))},Yl=function(){h(this,xe)&&(h(this,xe).removeEventListener("change",h(this,ii)),$(this,xe,null))},ii=new WeakMap,Do=new WeakMap,Oo=new WeakMap,zo=new WeakMap,hv=function(n){return n.lifecycle.status==="connecting"?"Connecting to agent…":n.lifecycle.status==="disconnected"?n.lifecycle.error?"Agent unavailable":"Agent disconnected":n.lifecycle.status==="disposed"?"Agent unavailable":n.run.status==="cancelling"?"Cancelling…":""},pr=function(){if(!h(this,xe)){this.hidden=!0;return}const n=h(this,xe).getState();this.hidden=n.lifecycle.status!=="ready";const r=n.messageOrder.map(a=>n.messagesById[a]).filter(a=>a!==void 0),s=n.run.canCancel&&n.run.status==="running"?"cancel":"send",i=n.lifecycle.status!=="ready"||n.run.status==="cancelling",o=b(this,Pe,hv).call(this,n);be(M`
355
+ `,this)}}v(uv,"observedProperties",{value:{type:String},disabled:{type:Boolean},disabledPlaceholder:{type:String},action:{type:String}});customElements.define("chat-input",uv);var Un,xe,Pr,Fn,ii,Pe,Jl,Xl,oi,Do,Oo,zo,hv,pr;class fO extends HTMLElement{constructor(){super(...arguments);x(this,Pe);x(this,Un,Ye.resolve("ACPClientManager"));x(this,xe,null);x(this,Pr,"");x(this,Fn,!1);x(this,ii,()=>{if(!h(this,Fn))return;const n=h(this,Un).getActiveClient();n!==h(this,xe)&&(b(this,Pe,Xl).call(this),b(this,Pe,Jl).call(this,n)),b(this,Pe,pr).call(this)});x(this,oi,()=>{h(this,Fn)&&b(this,Pe,pr).call(this)});x(this,Do,n=>{const r=n.value;$(this,Pr,r),b(this,Pe,pr).call(this)});x(this,Oo,n=>{if(!h(this,xe))return;const r=n.text;$(this,Pr,""),b(this,Pe,pr).call(this),h(this,xe).sendMessage({text:r}).catch(s=>{console.error("ACPClient.sendMessage() failed",s)})});x(this,zo,n=>{h(this,xe)&&h(this,xe).cancel().catch(r=>{console.error("ACPClient.cancel() failed",r)})})}connectedCallback(){$(this,Fn,!0),h(this,Un).addEventListener("change",h(this,ii)),b(this,Pe,Jl).call(this,h(this,Un).getActiveClient()),b(this,Pe,pr).call(this)}disconnectedCallback(){$(this,Fn,!1),h(this,Un).removeEventListener("change",h(this,ii)),b(this,Pe,Xl).call(this)}}Un=new WeakMap,xe=new WeakMap,Pr=new WeakMap,Fn=new WeakMap,ii=new WeakMap,Pe=new WeakSet,Jl=function(n){$(this,xe,n),h(this,xe)&&(h(this,xe).addEventListener("change",h(this,oi)),h(this,xe).connect().catch(r=>{console.error("ACPClient.connect() failed",r)}))},Xl=function(){h(this,xe)&&(h(this,xe).removeEventListener("change",h(this,oi)),$(this,xe,null))},oi=new WeakMap,Do=new WeakMap,Oo=new WeakMap,zo=new WeakMap,hv=function(n){return n.lifecycle.status==="connecting"?"Connecting to agent…":n.lifecycle.status==="disconnected"?n.lifecycle.error?"Agent unavailable":"Agent disconnected":n.lifecycle.status==="disposed"?"Agent unavailable":n.run.status==="cancelling"?"Cancelling…":""},pr=function(){if(!h(this,xe)){this.hidden=!0;return}const n=h(this,xe).getState();this.hidden=n.lifecycle.status!=="ready";const r=n.messageOrder.map(a=>n.messagesById[a]).filter(a=>a!==void 0),s=n.run.canCancel&&n.run.status==="running"?"cancel":"send",i=n.lifecycle.status!=="ready"||n.run.status==="cancelling",o=b(this,Pe,hv).call(this,n);be(M`
352
356
  <chat-history .messages=${r}></chat-history>
353
357
  <div class="chat-panel-input">
354
358
  <chat-input
@@ -361,7 +365,7 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
361
365
  @cancel=${h(this,zo)}
362
366
  ></chat-input>
363
367
  </div>
364
- `,this)};customElements.get("chat-panel")||customElements.define("chat-panel",gO);class dv extends HTMLElement{constructor(){super(...arguments);v(this,"screenManager",Ye.resolve("ScreenManager"));v(this,"serverManager",Ye.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`
368
+ `,this)};customElements.get("chat-panel")||customElements.define("chat-panel",fO);class dv extends HTMLElement{constructor(){super(...arguments);v(this,"screenManager",Ye.resolve("ScreenManager"));v(this,"serverManager",Ye.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`
365
369
  <modal-overlay ?open=${this.open}>
366
370
  <section class="screen-modal">
367
371
  <form class="screen-form" @submit=${o=>void this.handleSubmit(o)}>
@@ -476,7 +480,7 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
476
480
  </panel-view>
477
481
  </section>
478
482
  </modal-overlay>
479
- `,this)}}v(pv,"observedAttributes",["open"]);customElements.define("settings-modal",pv);class gv extends Event{constructor(n){super("auth-submit",{bubbles:!0,composed:!0});v(this,"token");this.token=n}}class mO 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 gv(r))}render(){be(M`
483
+ `,this)}}v(pv,"observedAttributes",["open"]);customElements.define("settings-modal",pv);class gv extends Event{constructor(n){super("auth-submit",{bubbles:!0,composed:!0});v(this,"token");this.token=n}}class pO 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 gv(r))}render(){be(M`
480
484
  <modal-overlay open>
481
485
  <section class="auth-modal">
482
486
  <form class="auth-form" @submit=${n=>this.handleSubmit(n)}>
@@ -497,7 +501,7 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
497
501
  </form>
498
502
  </section>
499
503
  </modal-overlay>
500
- `,this)}}customElements.get("auth-modal")||customElements.define("auth-modal",mO);class vO extends HTMLElement{constructor(){super(...arguments);v(this,"runtimeServerURL",hm());v(this,"electronMode",fm());v(this,"serverManager",Ye.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 gv?n.token:n instanceof CustomEvent&&typeof((s=n.detail)==null?void 0:s.token)=="string"?n.detail.token:null;r&&this.handleAuthSubmit(r)}),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 _l({url:this.runtimeServerURL,name:"Server",token:dm()});this.serverManager.add(n),this.serverManager.setActive(n);try{await n.connect(),this.connectError=null}catch(r){this.connectError=r instanceof Error&&!(r instanceof wl)?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 wl||(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`
504
+ `,this)}}customElements.get("auth-modal")||customElements.define("auth-modal",pO);class gO extends HTMLElement{constructor(){super(...arguments);v(this,"runtimeServerURL",hm());v(this,"electronMode",fm());v(this,"serverManager",Ye.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 gv?n.token:n instanceof CustomEvent&&typeof((s=n.detail)==null?void 0:s.token)=="string"?n.detail.token:null;r&&this.handleAuthSubmit(r)}),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 El({url:this.runtimeServerURL,name:"Server",token:dm()});this.serverManager.add(n),this.serverManager.setActive(n);try{await n.connect(),this.connectError=null}catch(r){this.connectError=r instanceof Error&&!(r instanceof kl)?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 kl||(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`
501
505
  <main class="auth-gate"><p>Connecting...</p></main>
502
506
  `,this);return}if(r==="disconnected"){const i=n;if(!i)return;be(M`
503
507
  <main class="auth-gate">
@@ -522,7 +526,7 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
522
526
  aria-label="Settings"
523
527
  @click=${()=>{this.modals.settings={open:!this.modals.settings.open},this.render()}}
524
528
  >
525
- ${FR({size:16,weight:"bold"})}
529
+ ${NR({size:16,weight:"bold"})}
526
530
  </button>
527
531
  </header>
528
532
  <main>
@@ -545,4 +549,4 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
545
549
  ?open=${this.modals.settings.open}
546
550
  @close=${()=>{this.modals.settings={open:!1},this.render()}}
547
551
  ></settings-modal>
548
- `;be(s,this)}}customElements.get("television-app")||customElements.define("television-app",vO);const Jc=fm(),ea=hm(),mv=new BE(Jc?"television-electron":"television-browser",WE(ea)),vv=new LT({localStore:mv,localServerURL:ea}),yv=new FE({localStore:mv,serverManager:vv}),yO=new vR({serverURL:ea,token:dm()??"",screenManager:yv});Ye.register("ServerManager",()=>vv);Ye.register("ScreenManager",()=>yv);Ye.register("ACPClientManager",()=>yO);const Xc=document.createElement("television-app");Xc.runtimeServerURL=ea;Xc.electronMode=Jc;Jc&&document.body.classList.add("electron");document.body.appendChild(Xc);
552
+ `;be(s,this)}}customElements.get("television-app")||customElements.define("television-app",gO);const eu=fm(),ea=hm(),mv=new ZE(eu?"television-electron":"television-browser",FE(ea)),vv=new DC({localStore:mv,localServerURL:ea}),yv=new ME({localStore:mv,serverManager:vv}),mO=new pR({serverURL:ea,token:dm()??"",screenManager:yv});Ye.register("ServerManager",()=>vv);Ye.register("ScreenManager",()=>yv);Ye.register("ACPClientManager",()=>mO);const tu=document.createElement("television-app");tu.runtimeServerURL=ea;tu.electronMode=eu;eu&&document.body.classList.add("electron");document.body.appendChild(tu);