@telepath-computer/television 0.1.72 → 0.1.73

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 xb=Object.defineProperty;var Yh=n=>{throw TypeError(n)};var Ab=(n,e,t)=>e in n?xb(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var b=(n,e,t)=>Ab(n,typeof e!="symbol"?e+"":e,t),Sl=(n,e,t)=>e.has(n)||Yh("Cannot "+t);var l=(n,e,t)=>(Sl(n,e,"read from private field"),t?t.call(n):e.get(n)),w=(n,e,t)=>e.has(n)?Yh("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(n):e.set(n,t),x=(n,e,t,r)=>(Sl(n,e,"write to private field"),r?r.call(n,t):e.set(n,t),t),m=(n,e,t)=>(Sl(n,e,"access private method"),t);var Xh=(n,e,t,r)=>({set _(i){x(n,e,i,t)},get _(){return l(n,e,r)}});(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const s of i)if(s.type==="childList")for(const o of s.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function t(i){const s={};return i.integrity&&(s.integrity=i.integrity),i.referrerPolicy&&(s.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?s.credentials="include":i.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function r(i){if(i.ep)return;i.ep=!0;const s=t(i);fetch(i.href,s)}})();var Ln=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function $b(n){if(n.__esModule)return n;var e=n.default;if(typeof e=="function"){var t=function r(){return this instanceof r?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(n).forEach(function(r){var i=Object.getOwnPropertyDescriptor(n,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:function(){return n[r]}})}),t}var Kh=Object.prototype.toString,Gf=function(e){var t=Kh.call(e),r=t==="[object Arguments]";return r||(r=t!=="[object Array]"&&e!==null&&typeof e=="object"&&typeof e.length=="number"&&e.length>=0&&Kh.call(e.callee)==="[object Function]"),r},_l,Jh;function Tb(){if(Jh)return _l;Jh=1;var n;if(!Object.keys){var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,r=Gf,i=Object.prototype.propertyIsEnumerable,s=!i.call({toString:null},"toString"),o=i.call(function(){},"prototype"),a=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],c=function(v){var g=v.constructor;return g&&g.prototype===v},u={$applicationCache:!0,$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$onmozfullscreenchange:!0,$onmozfullscreenerror:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},h=function(){if(typeof window>"u")return!1;for(var v in window)try{if(!u["$"+v]&&e.call(window,v)&&window[v]!==null&&typeof window[v]=="object")try{c(window[v])}catch{return!0}}catch{return!0}return!1}(),p=function(v){if(typeof window>"u"||!h)return c(v);try{return c(v)}catch{return!1}};n=function(g){var E=g!==null&&typeof g=="object",_=t.call(g)==="[object Function]",C=r(g),N=E&&t.call(g)==="[object String]",P=[];if(!E&&!_&&!C)throw new TypeError("Object.keys called on a non-object");var W=o&&_;if(N&&g.length>0&&!e.call(g,0))for(var L=0;L<g.length;++L)P.push(String(L));if(C&&g.length>0)for(var H=0;H<g.length;++H)P.push(String(H));else for(var F in g)!(W&&F==="prototype")&&e.call(g,F)&&P.push(String(F));if(s)for(var ce=p(g),ue=0;ue<a.length;++ue)!(ce&&a[ue]==="constructor")&&e.call(g,a[ue])&&P.push(a[ue]);return P}}return _l=n,_l}var Ib=Array.prototype.slice,Cb=Gf,Qh=Object.keys,Fo=Qh?function(e){return Qh(e)}:Tb(),ed=Object.keys;Fo.shim=function(){if(Object.keys){var e=function(){var t=Object.keys(arguments);return t&&t.length===arguments.length}(1,2);e||(Object.keys=function(r){return Cb(r)?ed(Ib.call(r)):ed(r)})}else Object.keys=Fo;return Object.keys||Fo};var Pb=Fo,Zo=Object.defineProperty||!1;if(Zo)try{Zo({},"a",{value:1})}catch{Zo=!1}var Xs=Zo,Qt=SyntaxError,j=TypeError,Rb=Object.getOwnPropertyDescriptor,Ho=Rb;if(Ho)try{Ho([],"length")}catch{Ho=null}var gi=Ho,td=Xs,Db=Qt,$r=j,nd=gi,jf=function(e,t,r){if(!e||typeof e!="object"&&typeof e!="function")throw new $r("`obj` must be an object or a function`");if(typeof t!="string"&&typeof t!="symbol")throw new $r("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new $r("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new $r("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new $r("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new $r("`loose`, if provided, must be a boolean");var i=arguments.length>3?arguments[3]:null,s=arguments.length>4?arguments[4]:null,o=arguments.length>5?arguments[5]:null,a=arguments.length>6?arguments[6]:!1,c=!!nd&&nd(e,t);if(td)td(e,t,{configurable:o===null&&c?c.configurable:!o,enumerable:i===null&&c?c.enumerable:!i,value:r,writable:s===null&&c?c.writable:!s});else if(a||!i&&!s&&!o)e[t]=r;else throw new Db("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},vc=Xs,qf=function(){return!!vc};qf.hasArrayLengthDefineBug=function(){if(!vc)return null;try{return vc([],"length",{value:1}).length!==1}catch{return!0}};var Wa=qf,Lb=Pb,Ob=typeof Symbol=="function"&&typeof Symbol("foo")=="symbol",Mb=Object.prototype.toString,zb=Array.prototype.concat,rd=jf,Nb=function(n){return typeof n=="function"&&Mb.call(n)==="[object Function]"},Yf=Wa(),Ub=function(n,e,t,r){if(e in n){if(r===!0){if(n[e]===t)return}else if(!Nb(r)||!r())return}Yf?rd(n,e,t,!0):rd(n,e,t)},Xf=function(n,e){var t=arguments.length>2?arguments[2]:{},r=Lb(e);Ob&&(r=zb.call(r,Object.getOwnPropertySymbols(e)));for(var i=0;i<r.length;i+=1)Ub(n,r[i],e[r[i]],t[r[i]])};Xf.supportsDescriptors=!!Yf;var vr=Xf,Wo={exports:{}};typeof self<"u"?Wo.exports=self:typeof window<"u"?Wo.exports=window:Wo.exports=Function("return this")();var Kf=Wo.exports,Fb=Kf,Jf=function(){return typeof Ln!="object"||!Ln||Ln.Math!==Math||Ln.Array!==Array?Fb:Ln},Zb=vr,Hb=gi,Wb=Jf,Bb=function(){var e=Wb();if(Zb.supportsDescriptors){var t=Hb(e,"globalThis");(!t||t.configurable&&(t.enumerable||!t.writable||globalThis!==e))&&Object.defineProperty(e,"globalThis",{configurable:!0,enumerable:!1,value:e,writable:!0})}else(typeof globalThis!="object"||globalThis!==e)&&(e.globalThis=e);return e},Vb=vr,Gb=Kf,Qf=Jf,jb=Bb,qb=Qf(),eg=function(){return qb};Vb(eg,{getPolyfill:Qf,implementation:Gb,shim:jb});var wu=eg,en=function(e){return!!e&&(typeof e=="function"||typeof e=="object")},Su=Object,tg=Error,Yb=EvalError,Xb=RangeError,_u=ReferenceError,Kb=URIError,Jb=Math.abs,Qb=Math.floor,ew=Math.max,tw=Math.min,nw=Math.pow,rw=Math.round,ku=Number.isNaN||function(e){return e!==e},iw=ku,sw=function(e){return iw(e)||e===0?e:e<0?-1:1},mi=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var e={},t=Symbol("test"),r=Object(t);if(typeof t=="string"||Object.prototype.toString.call(t)!=="[object Symbol]"||Object.prototype.toString.call(r)!=="[object Symbol]")return!1;var i=42;e[t]=i;for(var s in e)return!1;if(typeof Object.keys=="function"&&Object.keys(e).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(e).length!==0)return!1;var o=Object.getOwnPropertySymbols(e);if(o.length!==1||o[0]!==t||!Object.prototype.propertyIsEnumerable.call(e,t))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var a=Object.getOwnPropertyDescriptor(e,t);if(a.value!==i||a.enumerable!==!0)return!1}return!0},id=typeof Symbol<"u"&&Symbol,ow=mi,Eu=function(){return typeof id!="function"||typeof Symbol!="function"||typeof id("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:ow()},ng=typeof Reflect<"u"&&Reflect.getPrototypeOf||null,aw=Su,rg=aw.getPrototypeOf||null,lw="Function.prototype.bind called on incompatible ",cw=Object.prototype.toString,uw=Math.max,hw="[object Function]",sd=function(e,t){for(var r=[],i=0;i<e.length;i+=1)r[i]=e[i];for(var s=0;s<t.length;s+=1)r[s+e.length]=t[s];return r},dw=function(e,t){for(var r=[],i=t,s=0;i<e.length;i+=1,s+=1)r[s]=e[i];return r},pw=function(n,e){for(var t="",r=0;r<n.length;r+=1)t+=n[r],r+1<n.length&&(t+=e);return t},fw=function(e){var t=this;if(typeof t!="function"||cw.apply(t)!==hw)throw new TypeError(lw+t);for(var r=dw(arguments,1),i,s=function(){if(this instanceof i){var h=t.apply(this,sd(r,arguments));return Object(h)===h?h:this}return t.apply(e,sd(r,arguments))},o=uw(0,t.length-r.length),a=[],c=0;c<o;c++)a[c]="$"+c;if(i=Function("binder","return function ("+pw(a,",")+"){ return binder.apply(this,arguments); }")(s),t.prototype){var u=function(){};u.prototype=t.prototype,i.prototype=new u,u.prototype=null}return i},gw=fw,Ks=Function.prototype.bind||gw,xu=Function.prototype.call,kl,od;function Au(){return od||(od=1,kl=Function.prototype.apply),kl}var mw=typeof Reflect<"u"&&Reflect&&Reflect.apply,vw=Ks,yw=Au(),bw=xu,ww=mw,ig=ww||vw.call(bw,yw),Sw=Ks,_w=j,kw=xu,Ew=ig,Ba=function(e){if(e.length<1||typeof e[0]!="function")throw new _w("a function is required");return Ew(Sw,kw,e)},xw=Ba,ad=gi,sg;try{sg=[].__proto__===Array.prototype}catch(n){if(!n||typeof n!="object"||!("code"in n)||n.code!=="ERR_PROTO_ACCESS")throw n}var El=!!sg&&ad&&ad(Object.prototype,"__proto__"),og=Object,ld=og.getPrototypeOf,Aw=El&&typeof El.get=="function"?xw([El.get]):typeof ld=="function"?function(e){return ld(e==null?e:og(e))}:!1,cd=ng,ud=rg,hd=Aw,ag=cd?function(e){return cd(e)}:ud?function(e){if(!e||typeof e!="object"&&typeof e!="function")throw new TypeError("getProto: not an object");return ud(e)}:hd?function(e){return hd(e)}:null,$w=Function.prototype.call,Tw=Object.prototype.hasOwnProperty,Iw=Ks,tn=Iw.call($w,Tw),G,Cw=Su,Pw=tg,Rw=Yb,Dw=Xb,Lw=_u,ci=Qt,Wr=j,Ow=Kb,Mw=Jb,zw=Qb,Nw=ew,Uw=tw,Fw=nw,Zw=rw,Hw=sw,lg=Function,xl=function(n){try{return lg('"use strict"; return ('+n+").constructor;")()}catch{}},is=gi,Ww=Xs,Al=function(){throw new Wr},Bw=is?function(){try{return arguments.callee,Al}catch{try{return is(arguments,"callee").get}catch{return Al}}}():Al,Tr=Eu(),ke=ag,Vw=rg,Gw=ng,cg=Au(),Js=xu,Dr={},jw=typeof Uint8Array>"u"||!ke?G:ke(Uint8Array),ur={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?G:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?G:ArrayBuffer,"%ArrayIteratorPrototype%":Tr&&ke?ke([][Symbol.iterator]()):G,"%AsyncFromSyncIteratorPrototype%":G,"%AsyncFunction%":Dr,"%AsyncGenerator%":Dr,"%AsyncGeneratorFunction%":Dr,"%AsyncIteratorPrototype%":Dr,"%Atomics%":typeof Atomics>"u"?G:Atomics,"%BigInt%":typeof BigInt>"u"?G:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?G:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?G:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?G:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Pw,"%eval%":eval,"%EvalError%":Rw,"%Float16Array%":typeof Float16Array>"u"?G:Float16Array,"%Float32Array%":typeof Float32Array>"u"?G:Float32Array,"%Float64Array%":typeof Float64Array>"u"?G:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?G:FinalizationRegistry,"%Function%":lg,"%GeneratorFunction%":Dr,"%Int8Array%":typeof Int8Array>"u"?G:Int8Array,"%Int16Array%":typeof Int16Array>"u"?G:Int16Array,"%Int32Array%":typeof Int32Array>"u"?G:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":Tr&&ke?ke(ke([][Symbol.iterator]())):G,"%JSON%":typeof JSON=="object"?JSON:G,"%Map%":typeof Map>"u"?G:Map,"%MapIteratorPrototype%":typeof Map>"u"||!Tr||!ke?G:ke(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Cw,"%Object.getOwnPropertyDescriptor%":is,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?G:Promise,"%Proxy%":typeof Proxy>"u"?G:Proxy,"%RangeError%":Dw,"%ReferenceError%":Lw,"%Reflect%":typeof Reflect>"u"?G:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?G:Set,"%SetIteratorPrototype%":typeof Set>"u"||!Tr||!ke?G:ke(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?G:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":Tr&&ke?ke(""[Symbol.iterator]()):G,"%Symbol%":Tr?Symbol:G,"%SyntaxError%":ci,"%ThrowTypeError%":Bw,"%TypedArray%":jw,"%TypeError%":Wr,"%Uint8Array%":typeof Uint8Array>"u"?G:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?G:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?G:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?G:Uint32Array,"%URIError%":Ow,"%WeakMap%":typeof WeakMap>"u"?G:WeakMap,"%WeakRef%":typeof WeakRef>"u"?G:WeakRef,"%WeakSet%":typeof WeakSet>"u"?G:WeakSet,"%Function.prototype.call%":Js,"%Function.prototype.apply%":cg,"%Object.defineProperty%":Ww,"%Object.getPrototypeOf%":Vw,"%Math.abs%":Mw,"%Math.floor%":zw,"%Math.max%":Nw,"%Math.min%":Uw,"%Math.pow%":Fw,"%Math.round%":Zw,"%Math.sign%":Hw,"%Reflect.getPrototypeOf%":Gw};if(ke)try{null.error}catch(n){var qw=ke(ke(n));ur["%Error.prototype%"]=qw}var Yw=function n(e){var t;if(e==="%AsyncFunction%")t=xl("async function () {}");else if(e==="%GeneratorFunction%")t=xl("function* () {}");else if(e==="%AsyncGeneratorFunction%")t=xl("async function* () {}");else if(e==="%AsyncGenerator%"){var r=n("%AsyncGeneratorFunction%");r&&(t=r.prototype)}else if(e==="%AsyncIteratorPrototype%"){var i=n("%AsyncGenerator%");i&&ke&&(t=ke(i.prototype))}return ur[e]=t,t},dd={__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"]},Qs=Ks,ia=tn,Xw=Qs.call(Js,Array.prototype.concat),Kw=Qs.call(cg,Array.prototype.splice),pd=Qs.call(Js,String.prototype.replace),sa=Qs.call(Js,String.prototype.slice),Jw=Qs.call(Js,RegExp.prototype.exec),Qw=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,e0=/\\(\\)?/g,t0=function(e){var t=sa(e,0,1),r=sa(e,-1);if(t==="%"&&r!=="%")throw new ci("invalid intrinsic syntax, expected closing `%`");if(r==="%"&&t!=="%")throw new ci("invalid intrinsic syntax, expected opening `%`");var i=[];return pd(e,Qw,function(s,o,a,c){i[i.length]=a?pd(c,e0,"$1"):o||s}),i},n0=function(e,t){var r=e,i;if(ia(dd,r)&&(i=dd[r],r="%"+i[0]+"%"),ia(ur,r)){var s=ur[r];if(s===Dr&&(s=Yw(r)),typeof s>"u"&&!t)throw new Wr("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:i,name:r,value:s}}throw new ci("intrinsic "+e+" does not exist!")},ct=function(e,t){if(typeof e!="string"||e.length===0)throw new Wr("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof t!="boolean")throw new Wr('"allowMissing" argument must be a boolean');if(Jw(/^%?[^%]*%?$/,e)===null)throw new ci("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var r=t0(e),i=r.length>0?r[0]:"",s=n0("%"+i+"%",t),o=s.name,a=s.value,c=!1,u=s.alias;u&&(i=u[0],Kw(r,Xw([0,1],u)));for(var h=1,p=!0;h<r.length;h+=1){var v=r[h],g=sa(v,0,1),E=sa(v,-1);if((g==='"'||g==="'"||g==="`"||E==='"'||E==="'"||E==="`")&&g!==E)throw new ci("property names with quotes must have matching quotes");if((v==="constructor"||!p)&&(c=!0),i+="."+v,o="%"+i+"%",ia(ur,o))a=ur[o];else if(a!=null){if(!(v in a)){if(!t)throw new Wr("base intrinsic for "+e+" exists, but the property is not available.");return}if(is&&h+1>=r.length){var _=is(a,v);p=!!_,p&&"get"in _&&!("originalValue"in _.get)?a=_.get:a=a[v]}else p=ia(a,v),a=a[v];p&&!c&&(ur[o]=a)}}return a},$l,fd;function _n(){if(fd)return $l;fd=1;var n=ct,e=Ba,t=e([n("%String.prototype.indexOf%")]);return $l=function(i,s){var o=n(i,!!s);return typeof o=="function"&&t(i,".prototype.")>-1?e([o]):o},$l}var Tl,gd;function $u(){if(gd)return Tl;gd=1;var n=ct,e=n("%Array%"),t=!e.isArray&&_n()("Object.prototype.toString");return Tl=e.isArray||function(i){return t(i)==="[object Array]"},Tl}var r0=Wa,md=Xs,ug=r0.hasArrayLengthDefineBug(),i0=ug&&$u(),s0=_n(),o0=s0("Object.prototype.propertyIsEnumerable"),Tu=function(e,t,r,i,s,o){if(!md){if(!e(o)||!o["[[Configurable]]"]||!o["[[Writable]]"]||s in i&&o0(i,s)!==!!o["[[Enumerable]]"])return!1;var a=o["[[Value]]"];return i[s]=a,t(i[s],a)}return ug&&s==="length"&&"[[Value]]"in o&&i0(i)&&i.length!==o["[[Value]]"]?(i.length=o["[[Value]]"],i.length===o["[[Value]]"]):(md(i,s,r(o)),!0)},a0=j,Ri=tn,l0={__proto__:null,"[[Configurable]]":!0,"[[Enumerable]]":!0,"[[Get]]":!0,"[[Set]]":!0,"[[Value]]":!0,"[[Writable]]":!0},vi=function(e){if(!e||typeof e!="object")return!1;for(var t in e)if(Ri(e,t)&&!l0[t])return!1;var r=Ri(e,"[[Value]]")||Ri(e,"[[Writable]]"),i=Ri(e,"[[Get]]")||Ri(e,"[[Set]]");if(r&&i)throw new a0("Property Descriptors may not be both accessor and data descriptors");return!0},hg=function(e){if(typeof e>"u")return e;var t={};return"[[Value]]"in e&&(t.value=e["[[Value]]"]),"[[Writable]]"in e&&(t.writable=!!e["[[Writable]]"]),"[[Get]]"in e&&(t.get=e["[[Get]]"]),"[[Set]]"in e&&(t.set=e["[[Set]]"]),"[[Enumerable]]"in e&&(t.enumerable=!!e["[[Enumerable]]"]),"[[Configurable]]"in e&&(t.configurable=!!e["[[Configurable]]"]),t},c0=j,u0=vi,h0=hg,dg=function(e){if(typeof e<"u"&&!u0(e))throw new c0("Assertion failed: `Desc` must be a Property Descriptor");return h0(e)},d0=j,vd=tn,p0=vi,pg=function(e){if(typeof e>"u")return!1;if(!p0(e))throw new d0("Assertion failed: `Desc` must be a Property Descriptor");return!(!vd(e,"[[Value]]")&&!vd(e,"[[Writable]]"))},yi=function(e){return typeof e=="string"||typeof e=="symbol"},yd=ku,fg=function(e,t){return e===t?e===0?1/e===1/t:!0:yd(e)&&yd(t)},bd=j,f0=en,g0=Tu,m0=dg,v0=pg,y0=yi,b0=fg,Iu=function(e,t,r){if(!f0(e))throw new bd("Assertion failed: Type(O) is not Object");if(!y0(t))throw new bd("Assertion failed: P is not a Property Key");var i={"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Value]]":r,"[[Writable]]":!0};return g0(v0,b0,m0,e,t,i)},gg=Function.prototype.toString,Ur=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,yc,Bo;if(typeof Ur=="function"&&typeof Object.defineProperty=="function")try{yc=Object.defineProperty({},"length",{get:function(){throw Bo}}),Bo={},Ur(function(){throw 42},null,yc)}catch(n){n!==Bo&&(Ur=null)}else Ur=null;var w0=/^\s*class\b/,bc=function(e){try{var t=gg.call(e);return w0.test(t)}catch{return!1}},Il=function(e){try{return bc(e)?!1:(gg.call(e),!0)}catch{return!1}},Vo=Object.prototype.toString,S0="[object Object]",_0="[object Function]",k0="[object GeneratorFunction]",E0="[object HTMLAllCollection]",x0="[object HTML document.all class]",A0="[object HTMLCollection]",$0=typeof Symbol=="function"&&!!Symbol.toStringTag,T0=!(0 in[,]),wc=function(){return!1};if(typeof document=="object"){var I0=document.all;Vo.call(I0)===Vo.call(document.all)&&(wc=function(e){if((T0||!e)&&(typeof e>"u"||typeof e=="object"))try{var t=Vo.call(e);return(t===E0||t===x0||t===A0||t===S0)&&e("")==null}catch{}return!1})}var mg=Ur?function(e){if(wc(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;try{Ur(e,null,yc)}catch(t){if(t!==Bo)return!1}return!bc(e)&&Il(e)}:function(e){if(wc(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;if($0)return Il(e);if(bc(e))return!1;var t=Vo.call(e);return t!==_0&&t!==k0&&!/^\[object HTML/.test(t)?!1:Il(e)},C0=mg,P0=function(e){return!!e},Et=tn,wo=j,R0=en,wd=C0,Cl=P0,D0=function(e){if(!R0(e))throw new wo("ToPropertyDescriptor requires an object");var t={};if(Et(e,"enumerable")&&(t["[[Enumerable]]"]=Cl(e.enumerable)),Et(e,"configurable")&&(t["[[Configurable]]"]=Cl(e.configurable)),Et(e,"value")&&(t["[[Value]]"]=e.value),Et(e,"writable")&&(t["[[Writable]]"]=Cl(e.writable)),Et(e,"get")){var r=e.get;if(typeof r<"u"&&!wd(r))throw new wo("getter must be a function");t["[[Get]]"]=r}if(Et(e,"set")){var i=e.set;if(typeof i<"u"&&!wd(i))throw new wo("setter must be a function");t["[[Set]]"]=i}if((Et(t,"[[Get]]")||Et(t,"[[Set]]"))&&(Et(t,"[[Value]]")||Et(t,"[[Writable]]")))throw new wo("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute");return t},Pl=j,L0=en,Sd=vi,O0=Tu,M0=dg,z0=pg,N0=yi,U0=fg,F0=D0,Z0=function(e,t,r){if(!L0(e))throw new Pl("Assertion failed: Type(O) is not Object");if(!N0(t))throw new Pl("Assertion failed: P is not a Property Key");var i=Sd(r)?r:F0(r);if(!Sd(i))throw new Pl("Assertion failed: Desc is not a valid Property Descriptor");return O0(z0,U0,M0,e,t,i)},_d=j,H0=en,W0=Z0,B0=yi,V0=function(e,t,r){if(!H0(e))throw new _d("Assertion failed: Type(O) is not Object");if(!B0(t))throw new _d("Assertion failed: P is not a Property Key");var i={"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Value]]":r,"[[Writable]]":!0};return W0(e,t,i)},G0=typeof Reflect<"u"&&Reflect.setPrototypeOf||null,j0=Su,q0=j0.setPrototypeOf||null,Y0=Ba,kd=gi,X0=j,vg={};try{vg.__proto__=null}catch(n){if(!n||typeof n!="object"||!("code"in n)||n.code!=="ERR_PROTO_ACCESS")throw n}var K0=!("toString"in vg),Rl=kd&&kd(Object.prototype,"__proto__"),J0=K0&&(!!Rl&&typeof Rl.set=="function"&&Y0([Rl.set])||function(e,t){if(e==null)throw new X0("set Object.prototype.__proto__ called on null or undefined");return e.__proto__=t,t}),Ed=G0,Q0=q0,xd=J0,eS=j,tS=Ed?function(e,t){if(Ed(e,t))return e;throw new eS("Reflect.setPrototypeOf: failed to set [[Prototype]]")}:Q0||(xd?function(e,t){return xd(e,t),e}:null),Ad=j,nS=en,$d=ag,rS=function(e){if(!nS(e))throw new Ad("Assertion failed: O must be an Object");if(!$d)throw new Ad("This environment does not support fetching prototypes.");return $d(e)},iS=j,sS=tS,oS=en,aS=rS,lS=function(e,t){if(t!==null&&!oS(t))throw new iS("Assertion failed: V must be Object or Null");try{sS(e,t)}catch{return!1}return aS(e)===t},Dl=Iu,Td=V0,yg=lS,cS=Wa(),Cu=tg;function eo(n,e,t){var r=new Cu(t);return yg(r,Go),delete r.constructor,Td(r,"error",n),Td(r,"suppressed",e),r}cS&&Object.defineProperty(eo,"prototype",{writable:!1});var Go=eo.prototype;if(!Dl(Go,"constructor",eo)||!Dl(Go,"message","")||!Dl(Go,"name","SuppressedError"))throw new Cu("unable to install SuppressedError.prototype properties; please report this!");yg(eo.prototype,Cu.prototype);var uS=eo,hS=uS,bg=function(){return typeof SuppressedError=="function"?SuppressedError:hS},dS=vr,Id=wu(),pS=bg,fS=function(){var e=pS();return dS(Id,{SuppressedError:e},{SuppressedError:function(){return Id.SuppressedError!==e}}),e};fS();var gS=j,mS=vi,vS=hg,yS=function(e){if(typeof e<"u"&&!mS(e))throw new gS("Assertion failed: `Desc` must be a Property Descriptor");return vS(e)},bS=j,Cd=tn,wS=vi,SS=function(e){if(typeof e>"u")return!1;if(!wS(e))throw new bS("Assertion failed: `Desc` must be a Property Descriptor");return!(!Cd(e,"[[Value]]")&&!Cd(e,"[[Writable]]"))},Pd=ku,_S=function(e,t){return e===t?e===0?1/e===1/t:!0:Pd(e)&&Pd(t)},bi=mg,kS=function(e){return!!e},xt=tn,So=j,ES=en,Rd=bi,Ll=kS,xS=function(e){if(!ES(e))throw new So("ToPropertyDescriptor requires an object");var t={};if(xt(e,"enumerable")&&(t["[[Enumerable]]"]=Ll(e.enumerable)),xt(e,"configurable")&&(t["[[Configurable]]"]=Ll(e.configurable)),xt(e,"value")&&(t["[[Value]]"]=e.value),xt(e,"writable")&&(t["[[Writable]]"]=Ll(e.writable)),xt(e,"get")){var r=e.get;if(typeof r<"u"&&!Rd(r))throw new So("getter must be a function");t["[[Get]]"]=r}if(xt(e,"set")){var i=e.set;if(typeof i<"u"&&!Rd(i))throw new So("setter must be a function");t["[[Set]]"]=i}if((xt(t,"[[Get]]")||xt(t,"[[Set]]"))&&(xt(t,"[[Value]]")||xt(t,"[[Writable]]")))throw new So("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute");return t},Ol=j,AS=en,Dd=vi,$S=Tu,TS=yS,IS=SS,CS=yi,PS=_S,RS=xS,to=function(e,t,r){if(!AS(e))throw new Ol("Assertion failed: Type(O) is not Object");if(!CS(t))throw new Ol("Assertion failed: P is not a Property Key");var i=Dd(r)?r:RS(r);if(!Dd(i))throw new Ol("Assertion failed: Desc is not a valid Property Descriptor");return $S(IS,PS,TS,e,t,i)},DS=mi(),LS=DS?Symbol.dispose||Symbol("Symbol.dispose"):null,OS=mi,MS=LS,Pu=function(){return OS()&&Symbol.dispose||MS},zS=Eu,NS=to,US=Pu,FS=function(){var e=US();return zS()&&NS(Symbol,"dispose",{"[[Configurable]]":!1,"[[Enumerable]]":!1,"[[Writable]]":!1,"[[Value]]":e}),e},ZS=mi(),HS=ZS?Symbol.asyncDispose||Symbol("Symbol.asyncDispose"):null,WS=mi,BS=HS,Ru=function(){return WS()&&Symbol.asyncDispose||BS},VS=Eu,GS=to,jS=Ru,qS=function(){var e=jS();return VS()&&GS(Symbol,"asyncDispose",{"[[Configurable]]":!1,"[[Enumerable]]":!1,"[[Writable]]":!1,"[[Value]]":e}),e},YS=$u(),XS=ct,KS=_n(),JS=j,QS=YS,e_=XS("%Reflect.apply%",!0)||KS("Function.prototype.apply"),Va=function(e,t){var r=arguments.length>2?arguments[2]:[];if(!QS(r))throw new JS("Assertion failed: optional `argumentsList`, if provided, must be a List");return e_(e,t,r)};const t_={},n_=Object.freeze(Object.defineProperty({__proto__:null,default:t_},Symbol.toStringTag,{value:"Module"})),r_=$b(n_);var Du=typeof Map=="function"&&Map.prototype,Ml=Object.getOwnPropertyDescriptor&&Du?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,oa=Du&&Ml&&typeof Ml.get=="function"?Ml.get:null,Ld=Du&&Map.prototype.forEach,Lu=typeof Set=="function"&&Set.prototype,zl=Object.getOwnPropertyDescriptor&&Lu?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,aa=Lu&&zl&&typeof zl.get=="function"?zl.get:null,Od=Lu&&Set.prototype.forEach,i_=typeof WeakMap=="function"&&WeakMap.prototype,Qi=i_?WeakMap.prototype.has:null,s_=typeof WeakSet=="function"&&WeakSet.prototype,es=s_?WeakSet.prototype.has:null,o_=typeof WeakRef=="function"&&WeakRef.prototype,Md=o_?WeakRef.prototype.deref:null,a_=Boolean.prototype.valueOf,l_=Object.prototype.toString,c_=Function.prototype.toString,u_=String.prototype.match,Ou=String.prototype.slice,fn=String.prototype.replace,h_=String.prototype.toUpperCase,zd=String.prototype.toLowerCase,wg=RegExp.prototype.test,Nd=Array.prototype.concat,Dt=Array.prototype.join,d_=Array.prototype.slice,Ud=Math.floor,Sc=typeof BigInt=="function"?BigInt.prototype.valueOf:null,Nl=Object.getOwnPropertySymbols,_c=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,ui=typeof Symbol=="function"&&typeof Symbol.iterator=="object",ts=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===ui||!0)?Symbol.toStringTag:null,Sg=Object.prototype.propertyIsEnumerable,Fd=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(n){return n.__proto__}:null);function Zd(n,e){if(n===1/0||n===-1/0||n!==n||n&&n>-1e3&&n<1e3||wg.call(/e/,e))return e;var t=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof n=="number"){var r=n<0?-Ud(-n):Ud(n);if(r!==n){var i=String(r),s=Ou.call(e,i.length+1);return fn.call(i,t,"$&_")+"."+fn.call(fn.call(s,/([0-9]{3})/g,"$&_"),/_$/,"")}}return fn.call(e,t,"$&_")}var kc=r_,Hd=kc.custom,Wd=Eg(Hd)?Hd:null,_g={__proto__:null,double:'"',single:"'"},p_={__proto__:null,double:/(["\\])/g,single:/(['\\])/g},wi=function n(e,t,r,i){var s=t||{};if(Ht(s,"quoteStyle")&&!Ht(_g,s.quoteStyle))throw new TypeError('option "quoteStyle" must be "single" or "double"');if(Ht(s,"maxStringLength")&&(typeof s.maxStringLength=="number"?s.maxStringLength<0&&s.maxStringLength!==1/0:s.maxStringLength!==null))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var o=Ht(s,"customInspect")?s.customInspect:!0;if(typeof o!="boolean"&&o!=="symbol")throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(Ht(s,"indent")&&s.indent!==null&&s.indent!==" "&&!(parseInt(s.indent,10)===s.indent&&s.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(Ht(s,"numericSeparator")&&typeof s.numericSeparator!="boolean")throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var a=s.numericSeparator;if(typeof e>"u")return"undefined";if(e===null)return"null";if(typeof e=="boolean")return e?"true":"false";if(typeof e=="string")return Ag(e,s);if(typeof e=="number"){if(e===0)return 1/0/e>0?"0":"-0";var c=String(e);return a?Zd(e,c):c}if(typeof e=="bigint"){var u=String(e)+"n";return a?Zd(e,u):u}var h=typeof s.depth>"u"?5:s.depth;if(typeof r>"u"&&(r=0),r>=h&&h>0&&typeof e=="object")return Ec(e)?"[Array]":"[Object]";var p=P_(s,r);if(typeof i>"u")i=[];else if(xg(i,e)>=0)return"[Circular]";function v(St,nn,cl){if(nn&&(i=d_.call(i),i.push(nn)),cl){var uo={depth:s.depth};return Ht(s,"quoteStyle")&&(uo.quoteStyle=s.quoteStyle),n(St,uo,r+1,i)}return n(St,s,r+1,i)}if(typeof e=="function"&&!Bd(e)){var g=__(e),E=_o(e,v);return"[Function"+(g?": "+g:" (anonymous)")+"]"+(E.length>0?" { "+Dt.call(E,", ")+" }":"")}if(Eg(e)){var _=ui?fn.call(String(e),/^(Symbol\(.*\))_[^)]*$/,"$1"):_c.call(e);return typeof e=="object"&&!ui?Di(_):_}if(T_(e)){for(var C="<"+zd.call(String(e.nodeName)),N=e.attributes||[],P=0;P<N.length;P++)C+=" "+N[P].name+"="+kg(f_(N[P].value),"double",s);return C+=">",e.childNodes&&e.childNodes.length&&(C+="..."),C+="</"+zd.call(String(e.nodeName))+">",C}if(Ec(e)){if(e.length===0)return"[]";var W=_o(e,v);return p&&!C_(W)?"["+xc(W,p)+"]":"[ "+Dt.call(W,", ")+" ]"}if(m_(e)){var L=_o(e,v);return!("cause"in Error.prototype)&&"cause"in e&&!Sg.call(e,"cause")?"{ ["+String(e)+"] "+Dt.call(Nd.call("[cause]: "+v(e.cause),L),", ")+" }":L.length===0?"["+String(e)+"]":"{ ["+String(e)+"] "+Dt.call(L,", ")+" }"}if(typeof e=="object"&&o){if(Wd&&typeof e[Wd]=="function"&&kc)return kc(e,{depth:h-r});if(o!=="symbol"&&typeof e.inspect=="function")return e.inspect()}if(k_(e)){var H=[];return Ld&&Ld.call(e,function(St,nn){H.push(v(nn,e,!0)+" => "+v(St,e))}),Vd("Map",oa.call(e),H,p)}if(A_(e)){var F=[];return Od&&Od.call(e,function(St){F.push(v(St,e))}),Vd("Set",aa.call(e),F,p)}if(E_(e))return Ul("WeakMap");if($_(e))return Ul("WeakSet");if(x_(e))return Ul("WeakRef");if(y_(e))return Di(v(Number(e)));if(w_(e))return Di(v(Sc.call(e)));if(b_(e))return Di(a_.call(e));if(v_(e))return Di(v(String(e)));if(typeof window<"u"&&e===window)return"{ [object Window] }";if(typeof globalThis<"u"&&e===globalThis||typeof Ln<"u"&&e===Ln)return"{ [object globalThis] }";if(!g_(e)&&!Bd(e)){var ce=_o(e,v),ue=Fd?Fd(e)===Object.prototype:e instanceof Object||e.constructor===Object,Ti=e instanceof Object?"":"null prototype",co=!ue&&ts&&Object(e)===e&&ts in e?Ou.call(kn(e),8,-1):Ti?"Object":"",xe=ue||typeof e.constructor!="function"?"":e.constructor.name?e.constructor.name+" ":"",An=xe+(co||Ti?"["+Dt.call(Nd.call([],co||[],Ti||[]),": ")+"] ":"");return ce.length===0?An+"{}":p?An+"{"+xc(ce,p)+"}":An+"{ "+Dt.call(ce,", ")+" }"}return String(e)};function kg(n,e,t){var r=t.quoteStyle||e,i=_g[r];return i+n+i}function f_(n){return fn.call(String(n),/"/g,"&quot;")}function yr(n){return!ts||!(typeof n=="object"&&(ts in n||typeof n[ts]<"u"))}function Ec(n){return kn(n)==="[object Array]"&&yr(n)}function g_(n){return kn(n)==="[object Date]"&&yr(n)}function Bd(n){return kn(n)==="[object RegExp]"&&yr(n)}function m_(n){return kn(n)==="[object Error]"&&yr(n)}function v_(n){return kn(n)==="[object String]"&&yr(n)}function y_(n){return kn(n)==="[object Number]"&&yr(n)}function b_(n){return kn(n)==="[object Boolean]"&&yr(n)}function Eg(n){if(ui)return n&&typeof n=="object"&&n instanceof Symbol;if(typeof n=="symbol")return!0;if(!n||typeof n!="object"||!_c)return!1;try{return _c.call(n),!0}catch{}return!1}function w_(n){if(!n||typeof n!="object"||!Sc)return!1;try{return Sc.call(n),!0}catch{}return!1}var S_=Object.prototype.hasOwnProperty||function(n){return n in this};function Ht(n,e){return S_.call(n,e)}function kn(n){return l_.call(n)}function __(n){if(n.name)return n.name;var e=u_.call(c_.call(n),/^function\s*([\w$]+)/);return e?e[1]:null}function xg(n,e){if(n.indexOf)return n.indexOf(e);for(var t=0,r=n.length;t<r;t++)if(n[t]===e)return t;return-1}function k_(n){if(!oa||!n||typeof n!="object")return!1;try{oa.call(n);try{aa.call(n)}catch{return!0}return n instanceof Map}catch{}return!1}function E_(n){if(!Qi||!n||typeof n!="object")return!1;try{Qi.call(n,Qi);try{es.call(n,es)}catch{return!0}return n instanceof WeakMap}catch{}return!1}function x_(n){if(!Md||!n||typeof n!="object")return!1;try{return Md.call(n),!0}catch{}return!1}function A_(n){if(!aa||!n||typeof n!="object")return!1;try{aa.call(n);try{oa.call(n)}catch{return!0}return n instanceof Set}catch{}return!1}function $_(n){if(!es||!n||typeof n!="object")return!1;try{es.call(n,es);try{Qi.call(n,Qi)}catch{return!0}return n instanceof WeakSet}catch{}return!1}function T_(n){return!n||typeof n!="object"?!1:typeof HTMLElement<"u"&&n instanceof HTMLElement?!0:typeof n.nodeName=="string"&&typeof n.getAttribute=="function"}function Ag(n,e){if(n.length>e.maxStringLength){var t=n.length-e.maxStringLength,r="... "+t+" more character"+(t>1?"s":"");return Ag(Ou.call(n,0,e.maxStringLength),e)+r}var i=p_[e.quoteStyle||"single"];i.lastIndex=0;var s=fn.call(fn.call(n,i,"\\$1"),/[\x00-\x1f]/g,I_);return kg(s,"single",e)}function I_(n){var e=n.charCodeAt(0),t={8:"b",9:"t",10:"n",12:"f",13:"r"}[e];return t?"\\"+t:"\\x"+(e<16?"0":"")+h_.call(e.toString(16))}function Di(n){return"Object("+n+")"}function Ul(n){return n+" { ? }"}function Vd(n,e,t,r){var i=r?xc(t,r):Dt.call(t,", ");return n+" ("+e+") {"+i+"}"}function C_(n){for(var e=0;e<n.length;e++)if(xg(n[e],`
2
- `)>=0)return!1;return!0}function P_(n,e){var t;if(n.indent===" ")t=" ";else if(typeof n.indent=="number"&&n.indent>0)t=Dt.call(Array(n.indent+1)," ");else return null;return{base:t,prev:Dt.call(Array(e+1),t)}}function xc(n,e){if(n.length===0)return"";var t=`
1
+ var $b=Object.defineProperty;var Jh=n=>{throw TypeError(n)};var Tb=(n,e,t)=>e in n?$b(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var b=(n,e,t)=>Tb(n,typeof e!="symbol"?e+"":e,t),Sl=(n,e,t)=>e.has(n)||Jh("Cannot "+t);var l=(n,e,t)=>(Sl(n,e,"read from private field"),t?t.call(n):e.get(n)),w=(n,e,t)=>e.has(n)?Jh("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(n):e.set(n,t),x=(n,e,t,r)=>(Sl(n,e,"write to private field"),r?r.call(n,t):e.set(n,t),t),m=(n,e,t)=>(Sl(n,e,"access private method"),t);var Qh=(n,e,t,r)=>({set _(i){x(n,e,i,t)},get _(){return l(n,e,r)}});(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const s of i)if(s.type==="childList")for(const o of s.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function t(i){const s={};return i.integrity&&(s.integrity=i.integrity),i.referrerPolicy&&(s.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?s.credentials="include":i.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function r(i){if(i.ep)return;i.ep=!0;const s=t(i);fetch(i.href,s)}})();var Ln=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ib(n){if(n.__esModule)return n;var e=n.default;if(typeof e=="function"){var t=function r(){return this instanceof r?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(n).forEach(function(r){var i=Object.getOwnPropertyDescriptor(n,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:function(){return n[r]}})}),t}var ed=Object.prototype.toString,qf=function(e){var t=ed.call(e),r=t==="[object Arguments]";return r||(r=t!=="[object Array]"&&e!==null&&typeof e=="object"&&typeof e.length=="number"&&e.length>=0&&ed.call(e.callee)==="[object Function]"),r},_l,td;function Cb(){if(td)return _l;td=1;var n;if(!Object.keys){var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,r=qf,i=Object.prototype.propertyIsEnumerable,s=!i.call({toString:null},"toString"),o=i.call(function(){},"prototype"),a=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],c=function(v){var g=v.constructor;return g&&g.prototype===v},u={$applicationCache:!0,$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$onmozfullscreenchange:!0,$onmozfullscreenerror:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},h=function(){if(typeof window>"u")return!1;for(var v in window)try{if(!u["$"+v]&&e.call(window,v)&&window[v]!==null&&typeof window[v]=="object")try{c(window[v])}catch{return!0}}catch{return!0}return!1}(),p=function(v){if(typeof window>"u"||!h)return c(v);try{return c(v)}catch{return!1}};n=function(g){var E=g!==null&&typeof g=="object",_=t.call(g)==="[object Function]",C=r(g),N=E&&t.call(g)==="[object String]",P=[];if(!E&&!_&&!C)throw new TypeError("Object.keys called on a non-object");var W=o&&_;if(N&&g.length>0&&!e.call(g,0))for(var L=0;L<g.length;++L)P.push(String(L));if(C&&g.length>0)for(var H=0;H<g.length;++H)P.push(String(H));else for(var F in g)!(W&&F==="prototype")&&e.call(g,F)&&P.push(String(F));if(s)for(var ce=p(g),ue=0;ue<a.length;++ue)!(ce&&a[ue]==="constructor")&&e.call(g,a[ue])&&P.push(a[ue]);return P}}return _l=n,_l}var Pb=Array.prototype.slice,Rb=qf,nd=Object.keys,Fo=nd?function(e){return nd(e)}:Cb(),rd=Object.keys;Fo.shim=function(){if(Object.keys){var e=function(){var t=Object.keys(arguments);return t&&t.length===arguments.length}(1,2);e||(Object.keys=function(r){return Rb(r)?rd(Pb.call(r)):rd(r)})}else Object.keys=Fo;return Object.keys||Fo};var Db=Fo,Zo=Object.defineProperty||!1;if(Zo)try{Zo({},"a",{value:1})}catch{Zo=!1}var Xs=Zo,Qt=SyntaxError,j=TypeError,Lb=Object.getOwnPropertyDescriptor,Ho=Lb;if(Ho)try{Ho([],"length")}catch{Ho=null}var gi=Ho,id=Xs,Ob=Qt,$r=j,sd=gi,Yf=function(e,t,r){if(!e||typeof e!="object"&&typeof e!="function")throw new $r("`obj` must be an object or a function`");if(typeof t!="string"&&typeof t!="symbol")throw new $r("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new $r("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new $r("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new $r("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new $r("`loose`, if provided, must be a boolean");var i=arguments.length>3?arguments[3]:null,s=arguments.length>4?arguments[4]:null,o=arguments.length>5?arguments[5]:null,a=arguments.length>6?arguments[6]:!1,c=!!sd&&sd(e,t);if(id)id(e,t,{configurable:o===null&&c?c.configurable:!o,enumerable:i===null&&c?c.enumerable:!i,value:r,writable:s===null&&c?c.writable:!s});else if(a||!i&&!s&&!o)e[t]=r;else throw new Ob("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},wc=Xs,Xf=function(){return!!wc};Xf.hasArrayLengthDefineBug=function(){if(!wc)return null;try{return wc([],"length",{value:1}).length!==1}catch{return!0}};var Wa=Xf,Mb=Db,zb=typeof Symbol=="function"&&typeof Symbol("foo")=="symbol",Nb=Object.prototype.toString,Ub=Array.prototype.concat,od=Yf,Fb=function(n){return typeof n=="function"&&Nb.call(n)==="[object Function]"},Kf=Wa(),Zb=function(n,e,t,r){if(e in n){if(r===!0){if(n[e]===t)return}else if(!Fb(r)||!r())return}Kf?od(n,e,t,!0):od(n,e,t)},Jf=function(n,e){var t=arguments.length>2?arguments[2]:{},r=Mb(e);zb&&(r=Ub.call(r,Object.getOwnPropertySymbols(e)));for(var i=0;i<r.length;i+=1)Zb(n,r[i],e[r[i]],t[r[i]])};Jf.supportsDescriptors=!!Kf;var vr=Jf,Wo={exports:{}};typeof self<"u"?Wo.exports=self:typeof window<"u"?Wo.exports=window:Wo.exports=Function("return this")();var Qf=Wo.exports,Hb=Qf,eg=function(){return typeof Ln!="object"||!Ln||Ln.Math!==Math||Ln.Array!==Array?Hb:Ln},Wb=vr,Gb=gi,Vb=eg,Bb=function(){var e=Vb();if(Wb.supportsDescriptors){var t=Gb(e,"globalThis");(!t||t.configurable&&(t.enumerable||!t.writable||globalThis!==e))&&Object.defineProperty(e,"globalThis",{configurable:!0,enumerable:!1,value:e,writable:!0})}else(typeof globalThis!="object"||globalThis!==e)&&(e.globalThis=e);return e},jb=vr,qb=Qf,tg=eg,Yb=Bb,Xb=tg(),ng=function(){return Xb};jb(ng,{getPolyfill:tg,implementation:qb,shim:Yb});var ku=ng,en=function(e){return!!e&&(typeof e=="function"||typeof e=="object")},Eu=Object,rg=Error,Kb=EvalError,Jb=RangeError,xu=ReferenceError,Qb=URIError,ew=Math.abs,tw=Math.floor,nw=Math.max,rw=Math.min,iw=Math.pow,sw=Math.round,Au=Number.isNaN||function(e){return e!==e},ow=Au,aw=function(e){return ow(e)||e===0?e:e<0?-1:1},mi=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var e={},t=Symbol("test"),r=Object(t);if(typeof t=="string"||Object.prototype.toString.call(t)!=="[object Symbol]"||Object.prototype.toString.call(r)!=="[object Symbol]")return!1;var i=42;e[t]=i;for(var s in e)return!1;if(typeof Object.keys=="function"&&Object.keys(e).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(e).length!==0)return!1;var o=Object.getOwnPropertySymbols(e);if(o.length!==1||o[0]!==t||!Object.prototype.propertyIsEnumerable.call(e,t))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var a=Object.getOwnPropertyDescriptor(e,t);if(a.value!==i||a.enumerable!==!0)return!1}return!0},ad=typeof Symbol<"u"&&Symbol,lw=mi,$u=function(){return typeof ad!="function"||typeof Symbol!="function"||typeof ad("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:lw()},kl,ld;function ig(){return ld||(ld=1,kl=typeof Reflect<"u"&&Reflect.getPrototypeOf||null),kl}var El,cd;function sg(){if(cd)return El;cd=1;var n=Eu;return El=n.getPrototypeOf||null,El}var cw="Function.prototype.bind called on incompatible ",uw=Object.prototype.toString,hw=Math.max,dw="[object Function]",ud=function(e,t){for(var r=[],i=0;i<e.length;i+=1)r[i]=e[i];for(var s=0;s<t.length;s+=1)r[s+e.length]=t[s];return r},pw=function(e,t){for(var r=[],i=t,s=0;i<e.length;i+=1,s+=1)r[s]=e[i];return r},fw=function(n,e){for(var t="",r=0;r<n.length;r+=1)t+=n[r],r+1<n.length&&(t+=e);return t},gw=function(e){var t=this;if(typeof t!="function"||uw.apply(t)!==dw)throw new TypeError(cw+t);for(var r=pw(arguments,1),i,s=function(){if(this instanceof i){var h=t.apply(this,ud(r,arguments));return Object(h)===h?h:this}return t.apply(e,ud(r,arguments))},o=hw(0,t.length-r.length),a=[],c=0;c<o;c++)a[c]="$"+c;if(i=Function("binder","return function ("+fw(a,",")+"){ return binder.apply(this,arguments); }")(s),t.prototype){var u=function(){};u.prototype=t.prototype,i.prototype=new u,u.prototype=null}return i},mw=gw,Ks=Function.prototype.bind||mw,xl,hd;function Tu(){return hd||(hd=1,xl=Function.prototype.call),xl}var Al,dd;function Iu(){return dd||(dd=1,Al=Function.prototype.apply),Al}var vw=typeof Reflect<"u"&&Reflect&&Reflect.apply,yw=Ks,bw=Iu(),ww=Tu(),Sw=vw,og=Sw||yw.call(ww,bw),_w=Ks,kw=j,Ew=Tu(),xw=og,Ga=function(e){if(e.length<1||typeof e[0]!="function")throw new kw("a function is required");return xw(_w,Ew,e)},$l,pd;function Aw(){if(pd)return $l;pd=1;var n=Ga,e=gi,t;try{t=[].__proto__===Array.prototype}catch(o){if(!o||typeof o!="object"||!("code"in o)||o.code!=="ERR_PROTO_ACCESS")throw o}var r=!!t&&e&&e(Object.prototype,"__proto__"),i=Object,s=i.getPrototypeOf;return $l=r&&typeof r.get=="function"?n([r.get]):typeof s=="function"?function(a){return s(a==null?a:i(a))}:!1,$l}var Tl,fd;function ag(){if(fd)return Tl;fd=1;var n=ig(),e=sg(),t=Aw();return Tl=n?function(i){return n(i)}:e?function(i){if(!i||typeof i!="object"&&typeof i!="function")throw new TypeError("getProto: not an object");return e(i)}:t?function(i){return t(i)}:null,Tl}var $w=Function.prototype.call,Tw=Object.prototype.hasOwnProperty,Iw=Ks,tn=Iw.call($w,Tw),B,Cw=Eu,Pw=rg,Rw=Kb,Dw=Jb,Lw=xu,ci=Qt,Wr=j,Ow=Qb,Mw=ew,zw=tw,Nw=nw,Uw=rw,Fw=iw,Zw=sw,Hw=aw,lg=Function,Il=function(n){try{return lg('"use strict"; return ('+n+").constructor;")()}catch{}},is=gi,Ww=Xs,Cl=function(){throw new Wr},Gw=is?function(){try{return arguments.callee,Cl}catch{try{return is(arguments,"callee").get}catch{return Cl}}}():Cl,Tr=$u(),ke=ag(),Vw=sg(),Bw=ig(),cg=Iu(),Js=Tu(),Dr={},jw=typeof Uint8Array>"u"||!ke?B:ke(Uint8Array),ur={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?B:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?B:ArrayBuffer,"%ArrayIteratorPrototype%":Tr&&ke?ke([][Symbol.iterator]()):B,"%AsyncFromSyncIteratorPrototype%":B,"%AsyncFunction%":Dr,"%AsyncGenerator%":Dr,"%AsyncGeneratorFunction%":Dr,"%AsyncIteratorPrototype%":Dr,"%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%":Pw,"%eval%":eval,"%EvalError%":Rw,"%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%":lg,"%GeneratorFunction%":Dr,"%Int8Array%":typeof Int8Array>"u"?B:Int8Array,"%Int16Array%":typeof Int16Array>"u"?B:Int16Array,"%Int32Array%":typeof Int32Array>"u"?B:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":Tr&&ke?ke(ke([][Symbol.iterator]())):B,"%JSON%":typeof JSON=="object"?JSON:B,"%Map%":typeof Map>"u"?B:Map,"%MapIteratorPrototype%":typeof Map>"u"||!Tr||!ke?B:ke(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Cw,"%Object.getOwnPropertyDescriptor%":is,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?B:Promise,"%Proxy%":typeof Proxy>"u"?B:Proxy,"%RangeError%":Dw,"%ReferenceError%":Lw,"%Reflect%":typeof Reflect>"u"?B:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?B:Set,"%SetIteratorPrototype%":typeof Set>"u"||!Tr||!ke?B:ke(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?B:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":Tr&&ke?ke(""[Symbol.iterator]()):B,"%Symbol%":Tr?Symbol:B,"%SyntaxError%":ci,"%ThrowTypeError%":Gw,"%TypedArray%":jw,"%TypeError%":Wr,"%Uint8Array%":typeof Uint8Array>"u"?B:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?B:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?B:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?B:Uint32Array,"%URIError%":Ow,"%WeakMap%":typeof WeakMap>"u"?B:WeakMap,"%WeakRef%":typeof WeakRef>"u"?B:WeakRef,"%WeakSet%":typeof WeakSet>"u"?B:WeakSet,"%Function.prototype.call%":Js,"%Function.prototype.apply%":cg,"%Object.defineProperty%":Ww,"%Object.getPrototypeOf%":Vw,"%Math.abs%":Mw,"%Math.floor%":zw,"%Math.max%":Nw,"%Math.min%":Uw,"%Math.pow%":Fw,"%Math.round%":Zw,"%Math.sign%":Hw,"%Reflect.getPrototypeOf%":Bw};if(ke)try{null.error}catch(n){var qw=ke(ke(n));ur["%Error.prototype%"]=qw}var Yw=function n(e){var t;if(e==="%AsyncFunction%")t=Il("async function () {}");else if(e==="%GeneratorFunction%")t=Il("function* () {}");else if(e==="%AsyncGeneratorFunction%")t=Il("async function* () {}");else if(e==="%AsyncGenerator%"){var r=n("%AsyncGeneratorFunction%");r&&(t=r.prototype)}else if(e==="%AsyncIteratorPrototype%"){var i=n("%AsyncGenerator%");i&&ke&&(t=ke(i.prototype))}return ur[e]=t,t},gd={__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"]},Qs=Ks,ia=tn,Xw=Qs.call(Js,Array.prototype.concat),Kw=Qs.call(cg,Array.prototype.splice),md=Qs.call(Js,String.prototype.replace),sa=Qs.call(Js,String.prototype.slice),Jw=Qs.call(Js,RegExp.prototype.exec),Qw=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,e0=/\\(\\)?/g,t0=function(e){var t=sa(e,0,1),r=sa(e,-1);if(t==="%"&&r!=="%")throw new ci("invalid intrinsic syntax, expected closing `%`");if(r==="%"&&t!=="%")throw new ci("invalid intrinsic syntax, expected opening `%`");var i=[];return md(e,Qw,function(s,o,a,c){i[i.length]=a?md(c,e0,"$1"):o||s}),i},n0=function(e,t){var r=e,i;if(ia(gd,r)&&(i=gd[r],r="%"+i[0]+"%"),ia(ur,r)){var s=ur[r];if(s===Dr&&(s=Yw(r)),typeof s>"u"&&!t)throw new Wr("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:i,name:r,value:s}}throw new ci("intrinsic "+e+" does not exist!")},ct=function(e,t){if(typeof e!="string"||e.length===0)throw new Wr("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof t!="boolean")throw new Wr('"allowMissing" argument must be a boolean');if(Jw(/^%?[^%]*%?$/,e)===null)throw new ci("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var r=t0(e),i=r.length>0?r[0]:"",s=n0("%"+i+"%",t),o=s.name,a=s.value,c=!1,u=s.alias;u&&(i=u[0],Kw(r,Xw([0,1],u)));for(var h=1,p=!0;h<r.length;h+=1){var v=r[h],g=sa(v,0,1),E=sa(v,-1);if((g==='"'||g==="'"||g==="`"||E==='"'||E==="'"||E==="`")&&g!==E)throw new ci("property names with quotes must have matching quotes");if((v==="constructor"||!p)&&(c=!0),i+="."+v,o="%"+i+"%",ia(ur,o))a=ur[o];else if(a!=null){if(!(v in a)){if(!t)throw new Wr("base intrinsic for "+e+" exists, but the property is not available.");return}if(is&&h+1>=r.length){var _=is(a,v);p=!!_,p&&"get"in _&&!("originalValue"in _.get)?a=_.get:a=a[v]}else p=ia(a,v),a=a[v];p&&!c&&(ur[o]=a)}}return a},ug=ct,hg=Ga,r0=hg([ug("%String.prototype.indexOf%")]),_n=function(e,t){var r=ug(e,!!t);return typeof r=="function"&&r0(e,".prototype.")>-1?hg([r]):r},Pl,vd;function Cu(){if(vd)return Pl;vd=1;var n=ct,e=n("%Array%"),t=!e.isArray&&_n("Object.prototype.toString");return Pl=e.isArray||function(i){return t(i)==="[object Array]"},Pl}var i0=Wa,yd=Xs,dg=i0.hasArrayLengthDefineBug(),s0=dg&&Cu(),o0=_n,a0=o0("Object.prototype.propertyIsEnumerable"),Pu=function(e,t,r,i,s,o){if(!yd){if(!e(o)||!o["[[Configurable]]"]||!o["[[Writable]]"]||s in i&&a0(i,s)!==!!o["[[Enumerable]]"])return!1;var a=o["[[Value]]"];return i[s]=a,t(i[s],a)}return dg&&s==="length"&&"[[Value]]"in o&&s0(i)&&i.length!==o["[[Value]]"]?(i.length=o["[[Value]]"],i.length===o["[[Value]]"]):(yd(i,s,r(o)),!0)},l0=j,Ri=tn,c0={__proto__:null,"[[Configurable]]":!0,"[[Enumerable]]":!0,"[[Get]]":!0,"[[Set]]":!0,"[[Value]]":!0,"[[Writable]]":!0},vi=function(e){if(!e||typeof e!="object")return!1;for(var t in e)if(Ri(e,t)&&!c0[t])return!1;var r=Ri(e,"[[Value]]")||Ri(e,"[[Writable]]"),i=Ri(e,"[[Get]]")||Ri(e,"[[Set]]");if(r&&i)throw new l0("Property Descriptors may not be both accessor and data descriptors");return!0},pg=function(e){if(typeof e>"u")return e;var t={};return"[[Value]]"in e&&(t.value=e["[[Value]]"]),"[[Writable]]"in e&&(t.writable=!!e["[[Writable]]"]),"[[Get]]"in e&&(t.get=e["[[Get]]"]),"[[Set]]"in e&&(t.set=e["[[Set]]"]),"[[Enumerable]]"in e&&(t.enumerable=!!e["[[Enumerable]]"]),"[[Configurable]]"in e&&(t.configurable=!!e["[[Configurable]]"]),t},u0=j,h0=vi,d0=pg,fg=function(e){if(typeof e<"u"&&!h0(e))throw new u0("Assertion failed: `Desc` must be a Property Descriptor");return d0(e)},p0=j,bd=tn,f0=vi,gg=function(e){if(typeof e>"u")return!1;if(!f0(e))throw new p0("Assertion failed: `Desc` must be a Property Descriptor");return!(!bd(e,"[[Value]]")&&!bd(e,"[[Writable]]"))},yi=function(e){return typeof e=="string"||typeof e=="symbol"},wd=Au,mg=function(e,t){return e===t?e===0?1/e===1/t:!0:wd(e)&&wd(t)},Sd=j,g0=en,m0=Pu,v0=fg,y0=gg,b0=yi,w0=mg,Ru=function(e,t,r){if(!g0(e))throw new Sd("Assertion failed: Type(O) is not Object");if(!b0(t))throw new Sd("Assertion failed: P is not a Property Key");var i={"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Value]]":r,"[[Writable]]":!0};return m0(y0,w0,v0,e,t,i)},vg=Function.prototype.toString,Ur=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,Sc,Go;if(typeof Ur=="function"&&typeof Object.defineProperty=="function")try{Sc=Object.defineProperty({},"length",{get:function(){throw Go}}),Go={},Ur(function(){throw 42},null,Sc)}catch(n){n!==Go&&(Ur=null)}else Ur=null;var S0=/^\s*class\b/,_c=function(e){try{var t=vg.call(e);return S0.test(t)}catch{return!1}},Rl=function(e){try{return _c(e)?!1:(vg.call(e),!0)}catch{return!1}},Vo=Object.prototype.toString,_0="[object Object]",k0="[object Function]",E0="[object GeneratorFunction]",x0="[object HTMLAllCollection]",A0="[object HTML document.all class]",$0="[object HTMLCollection]",T0=typeof Symbol=="function"&&!!Symbol.toStringTag,I0=!(0 in[,]),kc=function(){return!1};if(typeof document=="object"){var C0=document.all;Vo.call(C0)===Vo.call(document.all)&&(kc=function(e){if((I0||!e)&&(typeof e>"u"||typeof e=="object"))try{var t=Vo.call(e);return(t===x0||t===A0||t===$0||t===_0)&&e("")==null}catch{}return!1})}var yg=Ur?function(e){if(kc(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;try{Ur(e,null,Sc)}catch(t){if(t!==Go)return!1}return!_c(e)&&Rl(e)}:function(e){if(kc(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;if(T0)return Rl(e);if(_c(e))return!1;var t=Vo.call(e);return t!==k0&&t!==E0&&!/^\[object HTML/.test(t)?!1:Rl(e)},P0=yg,R0=function(e){return!!e},Et=tn,wo=j,D0=en,_d=P0,Dl=R0,L0=function(e){if(!D0(e))throw new wo("ToPropertyDescriptor requires an object");var t={};if(Et(e,"enumerable")&&(t["[[Enumerable]]"]=Dl(e.enumerable)),Et(e,"configurable")&&(t["[[Configurable]]"]=Dl(e.configurable)),Et(e,"value")&&(t["[[Value]]"]=e.value),Et(e,"writable")&&(t["[[Writable]]"]=Dl(e.writable)),Et(e,"get")){var r=e.get;if(typeof r<"u"&&!_d(r))throw new wo("getter must be a function");t["[[Get]]"]=r}if(Et(e,"set")){var i=e.set;if(typeof i<"u"&&!_d(i))throw new wo("setter must be a function");t["[[Set]]"]=i}if((Et(t,"[[Get]]")||Et(t,"[[Set]]"))&&(Et(t,"[[Value]]")||Et(t,"[[Writable]]")))throw new wo("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute");return t},Ll=j,O0=en,kd=vi,M0=Pu,z0=fg,N0=gg,U0=yi,F0=mg,Z0=L0,H0=function(e,t,r){if(!O0(e))throw new Ll("Assertion failed: Type(O) is not Object");if(!U0(t))throw new Ll("Assertion failed: P is not a Property Key");var i=kd(r)?r:Z0(r);if(!kd(i))throw new Ll("Assertion failed: Desc is not a valid Property Descriptor");return M0(N0,F0,z0,e,t,i)},Ed=j,W0=en,G0=H0,V0=yi,B0=function(e,t,r){if(!W0(e))throw new Ed("Assertion failed: Type(O) is not Object");if(!V0(t))throw new Ed("Assertion failed: P is not a Property Key");var i={"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Value]]":r,"[[Writable]]":!0};return G0(e,t,i)},j0=typeof Reflect<"u"&&Reflect.setPrototypeOf||null,q0=Eu,Y0=q0.setPrototypeOf||null,X0=Ga,xd=gi,K0=j,bg={};try{bg.__proto__=null}catch(n){if(!n||typeof n!="object"||!("code"in n)||n.code!=="ERR_PROTO_ACCESS")throw n}var J0=!("toString"in bg),Ol=xd&&xd(Object.prototype,"__proto__"),Q0=J0&&(!!Ol&&typeof Ol.set=="function"&&X0([Ol.set])||function(e,t){if(e==null)throw new K0("set Object.prototype.__proto__ called on null or undefined");return e.__proto__=t,t}),Ad=j0,eS=Y0,$d=Q0,tS=j,nS=Ad?function(e,t){if(Ad(e,t))return e;throw new tS("Reflect.setPrototypeOf: failed to set [[Prototype]]")}:eS||($d?function(e,t){return $d(e,t),e}:null),Td=j,rS=en,Id=ag(),iS=function(e){if(!rS(e))throw new Td("Assertion failed: O must be an Object");if(!Id)throw new Td("This environment does not support fetching prototypes.");return Id(e)},sS=j,oS=nS,aS=en,lS=iS,cS=function(e,t){if(t!==null&&!aS(t))throw new sS("Assertion failed: V must be Object or Null");try{oS(e,t)}catch{return!1}return lS(e)===t},Ml=Ru,Cd=B0,wg=cS,uS=Wa(),Du=rg;function eo(n,e,t){var r=new Du(t);return wg(r,Bo),delete r.constructor,Cd(r,"error",n),Cd(r,"suppressed",e),r}uS&&Object.defineProperty(eo,"prototype",{writable:!1});var Bo=eo.prototype;if(!Ml(Bo,"constructor",eo)||!Ml(Bo,"message","")||!Ml(Bo,"name","SuppressedError"))throw new Du("unable to install SuppressedError.prototype properties; please report this!");wg(eo.prototype,Du.prototype);var hS=eo,dS=hS,Sg=function(){return typeof SuppressedError=="function"?SuppressedError:dS},pS=vr,Pd=ku(),fS=Sg,gS=function(){var e=fS();return pS(Pd,{SuppressedError:e},{SuppressedError:function(){return Pd.SuppressedError!==e}}),e};gS();var mS=j,vS=vi,yS=pg,bS=function(e){if(typeof e<"u"&&!vS(e))throw new mS("Assertion failed: `Desc` must be a Property Descriptor");return yS(e)},wS=j,Rd=tn,SS=vi,_S=function(e){if(typeof e>"u")return!1;if(!SS(e))throw new wS("Assertion failed: `Desc` must be a Property Descriptor");return!(!Rd(e,"[[Value]]")&&!Rd(e,"[[Writable]]"))},Dd=Au,kS=function(e,t){return e===t?e===0?1/e===1/t:!0:Dd(e)&&Dd(t)},bi=yg,ES=function(e){return!!e},xt=tn,So=j,xS=en,Ld=bi,zl=ES,AS=function(e){if(!xS(e))throw new So("ToPropertyDescriptor requires an object");var t={};if(xt(e,"enumerable")&&(t["[[Enumerable]]"]=zl(e.enumerable)),xt(e,"configurable")&&(t["[[Configurable]]"]=zl(e.configurable)),xt(e,"value")&&(t["[[Value]]"]=e.value),xt(e,"writable")&&(t["[[Writable]]"]=zl(e.writable)),xt(e,"get")){var r=e.get;if(typeof r<"u"&&!Ld(r))throw new So("getter must be a function");t["[[Get]]"]=r}if(xt(e,"set")){var i=e.set;if(typeof i<"u"&&!Ld(i))throw new So("setter must be a function");t["[[Set]]"]=i}if((xt(t,"[[Get]]")||xt(t,"[[Set]]"))&&(xt(t,"[[Value]]")||xt(t,"[[Writable]]")))throw new So("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute");return t},Nl=j,$S=en,Od=vi,TS=Pu,IS=bS,CS=_S,PS=yi,RS=kS,DS=AS,to=function(e,t,r){if(!$S(e))throw new Nl("Assertion failed: Type(O) is not Object");if(!PS(t))throw new Nl("Assertion failed: P is not a Property Key");var i=Od(r)?r:DS(r);if(!Od(i))throw new Nl("Assertion failed: Desc is not a valid Property Descriptor");return TS(CS,RS,IS,e,t,i)},LS=mi(),OS=LS?Symbol.dispose||Symbol("Symbol.dispose"):null,MS=mi,zS=OS,Lu=function(){return MS()&&Symbol.dispose||zS},NS=$u,US=to,FS=Lu,ZS=function(){var e=FS();return NS()&&US(Symbol,"dispose",{"[[Configurable]]":!1,"[[Enumerable]]":!1,"[[Writable]]":!1,"[[Value]]":e}),e},HS=mi(),WS=HS?Symbol.asyncDispose||Symbol("Symbol.asyncDispose"):null,GS=mi,VS=WS,Ou=function(){return GS()&&Symbol.asyncDispose||VS},BS=$u,jS=to,qS=Ou,YS=function(){var e=qS();return BS()&&jS(Symbol,"asyncDispose",{"[[Configurable]]":!1,"[[Enumerable]]":!1,"[[Writable]]":!1,"[[Value]]":e}),e},XS=Cu(),KS=ct,JS=_n,QS=j,e_=XS,t_=KS("%Reflect.apply%",!0)||JS("Function.prototype.apply"),Va=function(e,t){var r=arguments.length>2?arguments[2]:[];if(!e_(r))throw new QS("Assertion failed: optional `argumentsList`, if provided, must be a List");return t_(e,t,r)};const n_={},r_=Object.freeze(Object.defineProperty({__proto__:null,default:n_},Symbol.toStringTag,{value:"Module"})),i_=Ib(r_);var Mu=typeof Map=="function"&&Map.prototype,Ul=Object.getOwnPropertyDescriptor&&Mu?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,oa=Mu&&Ul&&typeof Ul.get=="function"?Ul.get:null,Md=Mu&&Map.prototype.forEach,zu=typeof Set=="function"&&Set.prototype,Fl=Object.getOwnPropertyDescriptor&&zu?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,aa=zu&&Fl&&typeof Fl.get=="function"?Fl.get:null,zd=zu&&Set.prototype.forEach,s_=typeof WeakMap=="function"&&WeakMap.prototype,Qi=s_?WeakMap.prototype.has:null,o_=typeof WeakSet=="function"&&WeakSet.prototype,es=o_?WeakSet.prototype.has:null,a_=typeof WeakRef=="function"&&WeakRef.prototype,Nd=a_?WeakRef.prototype.deref:null,l_=Boolean.prototype.valueOf,c_=Object.prototype.toString,u_=Function.prototype.toString,h_=String.prototype.match,Nu=String.prototype.slice,fn=String.prototype.replace,d_=String.prototype.toUpperCase,Ud=String.prototype.toLowerCase,_g=RegExp.prototype.test,Fd=Array.prototype.concat,Dt=Array.prototype.join,p_=Array.prototype.slice,Zd=Math.floor,Ec=typeof BigInt=="function"?BigInt.prototype.valueOf:null,Zl=Object.getOwnPropertySymbols,xc=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,ui=typeof Symbol=="function"&&typeof Symbol.iterator=="object",ts=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===ui||!0)?Symbol.toStringTag:null,kg=Object.prototype.propertyIsEnumerable,Hd=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(n){return n.__proto__}:null);function Wd(n,e){if(n===1/0||n===-1/0||n!==n||n&&n>-1e3&&n<1e3||_g.call(/e/,e))return e;var t=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof n=="number"){var r=n<0?-Zd(-n):Zd(n);if(r!==n){var i=String(r),s=Nu.call(e,i.length+1);return fn.call(i,t,"$&_")+"."+fn.call(fn.call(s,/([0-9]{3})/g,"$&_"),/_$/,"")}}return fn.call(e,t,"$&_")}var Ac=i_,Gd=Ac.custom,Vd=Ag(Gd)?Gd:null,Eg={__proto__:null,double:'"',single:"'"},f_={__proto__:null,double:/(["\\])/g,single:/(['\\])/g},wi=function n(e,t,r,i){var s=t||{};if(Ht(s,"quoteStyle")&&!Ht(Eg,s.quoteStyle))throw new TypeError('option "quoteStyle" must be "single" or "double"');if(Ht(s,"maxStringLength")&&(typeof s.maxStringLength=="number"?s.maxStringLength<0&&s.maxStringLength!==1/0:s.maxStringLength!==null))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var o=Ht(s,"customInspect")?s.customInspect:!0;if(typeof o!="boolean"&&o!=="symbol")throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(Ht(s,"indent")&&s.indent!==null&&s.indent!==" "&&!(parseInt(s.indent,10)===s.indent&&s.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(Ht(s,"numericSeparator")&&typeof s.numericSeparator!="boolean")throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var a=s.numericSeparator;if(typeof e>"u")return"undefined";if(e===null)return"null";if(typeof e=="boolean")return e?"true":"false";if(typeof e=="string")return Tg(e,s);if(typeof e=="number"){if(e===0)return 1/0/e>0?"0":"-0";var c=String(e);return a?Wd(e,c):c}if(typeof e=="bigint"){var u=String(e)+"n";return a?Wd(e,u):u}var h=typeof s.depth>"u"?5:s.depth;if(typeof r>"u"&&(r=0),r>=h&&h>0&&typeof e=="object")return $c(e)?"[Array]":"[Object]";var p=R_(s,r);if(typeof i>"u")i=[];else if($g(i,e)>=0)return"[Circular]";function v(St,nn,cl){if(nn&&(i=p_.call(i),i.push(nn)),cl){var uo={depth:s.depth};return Ht(s,"quoteStyle")&&(uo.quoteStyle=s.quoteStyle),n(St,uo,r+1,i)}return n(St,s,r+1,i)}if(typeof e=="function"&&!Bd(e)){var g=k_(e),E=_o(e,v);return"[Function"+(g?": "+g:" (anonymous)")+"]"+(E.length>0?" { "+Dt.call(E,", ")+" }":"")}if(Ag(e)){var _=ui?fn.call(String(e),/^(Symbol\(.*\))_[^)]*$/,"$1"):xc.call(e);return typeof e=="object"&&!ui?Di(_):_}if(I_(e)){for(var C="<"+Ud.call(String(e.nodeName)),N=e.attributes||[],P=0;P<N.length;P++)C+=" "+N[P].name+"="+xg(g_(N[P].value),"double",s);return C+=">",e.childNodes&&e.childNodes.length&&(C+="..."),C+="</"+Ud.call(String(e.nodeName))+">",C}if($c(e)){if(e.length===0)return"[]";var W=_o(e,v);return p&&!P_(W)?"["+Tc(W,p)+"]":"[ "+Dt.call(W,", ")+" ]"}if(v_(e)){var L=_o(e,v);return!("cause"in Error.prototype)&&"cause"in e&&!kg.call(e,"cause")?"{ ["+String(e)+"] "+Dt.call(Fd.call("[cause]: "+v(e.cause),L),", ")+" }":L.length===0?"["+String(e)+"]":"{ ["+String(e)+"] "+Dt.call(L,", ")+" }"}if(typeof e=="object"&&o){if(Vd&&typeof e[Vd]=="function"&&Ac)return Ac(e,{depth:h-r});if(o!=="symbol"&&typeof e.inspect=="function")return e.inspect()}if(E_(e)){var H=[];return Md&&Md.call(e,function(St,nn){H.push(v(nn,e,!0)+" => "+v(St,e))}),jd("Map",oa.call(e),H,p)}if($_(e)){var F=[];return zd&&zd.call(e,function(St){F.push(v(St,e))}),jd("Set",aa.call(e),F,p)}if(x_(e))return Hl("WeakMap");if(T_(e))return Hl("WeakSet");if(A_(e))return Hl("WeakRef");if(b_(e))return Di(v(Number(e)));if(S_(e))return Di(v(Ec.call(e)));if(w_(e))return Di(l_.call(e));if(y_(e))return Di(v(String(e)));if(typeof window<"u"&&e===window)return"{ [object Window] }";if(typeof globalThis<"u"&&e===globalThis||typeof Ln<"u"&&e===Ln)return"{ [object globalThis] }";if(!m_(e)&&!Bd(e)){var ce=_o(e,v),ue=Hd?Hd(e)===Object.prototype:e instanceof Object||e.constructor===Object,Ti=e instanceof Object?"":"null prototype",co=!ue&&ts&&Object(e)===e&&ts in e?Nu.call(kn(e),8,-1):Ti?"Object":"",xe=ue||typeof e.constructor!="function"?"":e.constructor.name?e.constructor.name+" ":"",An=xe+(co||Ti?"["+Dt.call(Fd.call([],co||[],Ti||[]),": ")+"] ":"");return ce.length===0?An+"{}":p?An+"{"+Tc(ce,p)+"}":An+"{ "+Dt.call(ce,", ")+" }"}return String(e)};function xg(n,e,t){var r=t.quoteStyle||e,i=Eg[r];return i+n+i}function g_(n){return fn.call(String(n),/"/g,"&quot;")}function yr(n){return!ts||!(typeof n=="object"&&(ts in n||typeof n[ts]<"u"))}function $c(n){return kn(n)==="[object Array]"&&yr(n)}function m_(n){return kn(n)==="[object Date]"&&yr(n)}function Bd(n){return kn(n)==="[object RegExp]"&&yr(n)}function v_(n){return kn(n)==="[object Error]"&&yr(n)}function y_(n){return kn(n)==="[object String]"&&yr(n)}function b_(n){return kn(n)==="[object Number]"&&yr(n)}function w_(n){return kn(n)==="[object Boolean]"&&yr(n)}function Ag(n){if(ui)return n&&typeof n=="object"&&n instanceof Symbol;if(typeof n=="symbol")return!0;if(!n||typeof n!="object"||!xc)return!1;try{return xc.call(n),!0}catch{}return!1}function S_(n){if(!n||typeof n!="object"||!Ec)return!1;try{return Ec.call(n),!0}catch{}return!1}var __=Object.prototype.hasOwnProperty||function(n){return n in this};function Ht(n,e){return __.call(n,e)}function kn(n){return c_.call(n)}function k_(n){if(n.name)return n.name;var e=h_.call(u_.call(n),/^function\s*([\w$]+)/);return e?e[1]:null}function $g(n,e){if(n.indexOf)return n.indexOf(e);for(var t=0,r=n.length;t<r;t++)if(n[t]===e)return t;return-1}function E_(n){if(!oa||!n||typeof n!="object")return!1;try{oa.call(n);try{aa.call(n)}catch{return!0}return n instanceof Map}catch{}return!1}function x_(n){if(!Qi||!n||typeof n!="object")return!1;try{Qi.call(n,Qi);try{es.call(n,es)}catch{return!0}return n instanceof WeakMap}catch{}return!1}function A_(n){if(!Nd||!n||typeof n!="object")return!1;try{return Nd.call(n),!0}catch{}return!1}function $_(n){if(!aa||!n||typeof n!="object")return!1;try{aa.call(n);try{oa.call(n)}catch{return!0}return n instanceof Set}catch{}return!1}function T_(n){if(!es||!n||typeof n!="object")return!1;try{es.call(n,es);try{Qi.call(n,Qi)}catch{return!0}return n instanceof WeakSet}catch{}return!1}function I_(n){return!n||typeof n!="object"?!1:typeof HTMLElement<"u"&&n instanceof HTMLElement?!0:typeof n.nodeName=="string"&&typeof n.getAttribute=="function"}function Tg(n,e){if(n.length>e.maxStringLength){var t=n.length-e.maxStringLength,r="... "+t+" more character"+(t>1?"s":"");return Tg(Nu.call(n,0,e.maxStringLength),e)+r}var i=f_[e.quoteStyle||"single"];i.lastIndex=0;var s=fn.call(fn.call(n,i,"\\$1"),/[\x00-\x1f]/g,C_);return xg(s,"single",e)}function C_(n){var e=n.charCodeAt(0),t={8:"b",9:"t",10:"n",12:"f",13:"r"}[e];return t?"\\"+t:"\\x"+(e<16?"0":"")+d_.call(e.toString(16))}function Di(n){return"Object("+n+")"}function Hl(n){return n+" { ? }"}function jd(n,e,t,r){var i=r?Tc(t,r):Dt.call(t,", ");return n+" ("+e+") {"+i+"}"}function P_(n){for(var e=0;e<n.length;e++)if($g(n[e],`
2
+ `)>=0)return!1;return!0}function R_(n,e){var t;if(n.indent===" ")t=" ";else if(typeof n.indent=="number"&&n.indent>0)t=Dt.call(Array(n.indent+1)," ");else return null;return{base:t,prev:Dt.call(Array(e+1),t)}}function Tc(n,e){if(n.length===0)return"";var t=`
3
3
  `+e.prev+e.base;return t+Dt.call(n,","+t)+`
4
- `+e.prev}function _o(n,e){var t=Ec(n),r=[];if(t){r.length=n.length;for(var i=0;i<n.length;i++)r[i]=Ht(n,i)?e(n[i],n):""}var s=typeof Nl=="function"?Nl(n):[],o;if(ui){o={};for(var a=0;a<s.length;a++)o["$"+s[a]]=s[a]}for(var c in n)Ht(n,c)&&(t&&String(Number(c))===c&&c<n.length||ui&&o["$"+c]instanceof Symbol||(wg.call(/[^\w$]/,c)?r.push(e(c,n)+": "+e(n[c],n)):r.push(c+": "+e(n[c],n))));if(typeof Nl=="function")for(var u=0;u<s.length;u++)Sg.call(n,s[u])&&r.push("["+e(s[u])+"]: "+e(n[s[u]],n));return r}var R_=wi,D_=j,Ga=function(n,e,t){for(var r=n,i;(i=r.next)!=null;r=i)if(i.key===e)return r.next=i.next,t||(i.next=n.next,n.next=i),i},L_=function(n,e){if(n){var t=Ga(n,e);return t&&t.value}},O_=function(n,e,t){var r=Ga(n,e);r?r.value=t:n.next={key:e,next:n.next,value:t}},M_=function(n,e){return n?!!Ga(n,e):!1},z_=function(n,e){if(n)return Ga(n,e,!0)},N_=function(){var e,t={assert:function(r){if(!t.has(r))throw new D_("Side channel does not contain "+R_(r))},delete:function(r){var i=e&&e.next,s=z_(e,r);return s&&i&&i===s&&(e=void 0),!!s},get:function(r){return L_(e,r)},has:function(r){return M_(e,r)},set:function(r,i){e||(e={next:void 0}),O_(e,r,i)}};return t},U_=ct,no=_n(),F_=wi,Z_=j,Gd=U_("%Map%",!0),H_=no("Map.prototype.get",!0),W_=no("Map.prototype.set",!0),B_=no("Map.prototype.has",!0),V_=no("Map.prototype.delete",!0),G_=no("Map.prototype.size",!0),$g=!!Gd&&function(){var e,t={assert:function(r){if(!t.has(r))throw new Z_("Side channel does not contain "+F_(r))},delete:function(r){if(e){var i=V_(e,r);return G_(e)===0&&(e=void 0),i}return!1},get:function(r){if(e)return H_(e,r)},has:function(r){return e?B_(e,r):!1},set:function(r,i){e||(e=new Gd),W_(e,r,i)}};return t},j_=ct,ja=_n(),q_=wi,ko=$g,Y_=j,Ir=j_("%WeakMap%",!0),X_=ja("WeakMap.prototype.get",!0),K_=ja("WeakMap.prototype.set",!0),J_=ja("WeakMap.prototype.has",!0),Q_=ja("WeakMap.prototype.delete",!0),ek=Ir?function(){var e,t,r={assert:function(i){if(!r.has(i))throw new Y_("Side channel does not contain "+q_(i))},delete:function(i){if(Ir&&i&&(typeof i=="object"||typeof i=="function")){if(e)return Q_(e,i)}else if(ko&&t)return t.delete(i);return!1},get:function(i){return Ir&&i&&(typeof i=="object"||typeof i=="function")&&e?X_(e,i):t&&t.get(i)},has:function(i){return Ir&&i&&(typeof i=="object"||typeof i=="function")&&e?J_(e,i):!!t&&t.has(i)},set:function(i,s){Ir&&i&&(typeof i=="object"||typeof i=="function")?(e||(e=new Ir),K_(e,i,s)):ko&&(t||(t=ko()),t.set(i,s))}};return r}:ko,tk=j,nk=wi,rk=N_,ik=$g,sk=ek,ok=sk||ik||rk,ak=function(){var e,t={assert:function(r){if(!t.has(r))throw new tk("Side channel does not contain "+nk(r))},delete:function(r){return!!e&&e.delete(r)},get:function(r){return e&&e.get(r)},has:function(r){return!!e&&e.has(r)},set:function(r,i){e||(e=ok()),e.set(r,i)}};return t},lk=tn,Li=ak(),Ut=j,Mu={assert:function(n,e){if(!n||typeof n!="object"&&typeof n!="function")throw new Ut("`O` is not an object");if(typeof e!="string")throw new Ut("`slot` must be a string");if(Li.assert(n),!Mu.has(n,e))throw new Ut("`"+e+"` is not present on `O`")},get:function(n,e){if(!n||typeof n!="object"&&typeof n!="function")throw new Ut("`O` is not an object");if(typeof e!="string")throw new Ut("`slot` must be a string");var t=Li.get(n);return t&&t["$"+e]},has:function(n,e){if(!n||typeof n!="object"&&typeof n!="function")throw new Ut("`O` is not an object");if(typeof e!="string")throw new Ut("`slot` must be a string");var t=Li.get(n);return!!t&&lk(t,"$"+e)},set:function(n,e,t){if(!n||typeof n!="object"&&typeof n!="function")throw new Ut("`O` is not an object");if(typeof e!="string")throw new Ut("`slot` must be a string");var r=Li.get(n);r||(r={},Li.set(n,r)),r["$"+e]=t}};Object.freeze&&Object.freeze(Mu);var zu=Mu,Tg=Qt,gn=zu,ro=function n(e,t){if(!(this instanceof n))return new n(e,t);if(e!=="normal"&&e!=="break"&&e!=="continue"&&e!=="return"&&e!=="throw")throw new Tg('Assertion failed: `type` must be one of "normal", "break", "continue", "return", or "throw"');gn.set(this,"[[Type]]",e),gn.set(this,"[[Value]]",t)};ro.prototype.type=function(){return gn.get(this,"[[Type]]")};ro.prototype.value=function(){return gn.get(this,"[[Value]]")};ro.prototype["?"]=function(){var e=gn.get(this,"[[Type]]"),t=gn.get(this,"[[Value]]");if(e==="throw")throw t;return t};ro.prototype["!"]=function(){var e=gn.get(this,"[[Type]]");if(e!=="normal")throw new Tg('Assertion failed: Completion Record is not of type "normal"');return gn.get(this,"[[Value]]")};var Nu=ro,ck=Nu,Uu=function(e){return new ck("normal",e)},Fl,jd;function uk(){if(jd)return Fl;jd=1;var n=mi;return Fl=function(){return n()&&!!Symbol.toStringTag},Fl}var hk=ct,qd=hk("%Object.defineProperty%",!0),dk=uk()(),pk=tn,fk=j,Eo=dk?Symbol.toStringTag:null,Ig=function(e,t){var r=arguments.length>2&&!!arguments[2]&&arguments[2].force,i=arguments.length>2&&!!arguments[2]&&arguments[2].nonConfigurable;if(typeof r<"u"&&typeof r!="boolean"||typeof i<"u"&&typeof i!="boolean")throw new fk("if provided, the `overrideIfSet` and `nonConfigurable` options must be booleans");Eo&&(r||!pk(e,Eo))&&(qd?qd(e,Eo,{configurable:!i,enumerable:!1,value:t,writable:!1}):e[Eo]=t)},Cg={exports:{}},gk=ct,Yd=jf,mk=Wa(),Xd=gi,Kd=j,vk=gk("%Math.floor%"),yk=function(e,t){if(typeof e!="function")throw new Kd("`fn` is not a function");if(typeof t!="number"||t<0||t>4294967295||vk(t)!==t)throw new Kd("`length` must be a positive 32-bit integer");var r=arguments.length>2&&!!arguments[2],i=!0,s=!0;if("length"in e&&Xd){var o=Xd(e,"length");o&&!o.configurable&&(i=!1),o&&!o.writable&&(s=!1)}return(i||s||!r)&&(mk?Yd(e,"length",t,!0,!0):Yd(e,"length",t)),e},bk=Ks,wk=Au(),Sk=ig,_k=function(){return Sk(bk,wk,arguments)};(function(n){var e=yk,t=Xs,r=Ba,i=_k;n.exports=function(o){var a=r(arguments),c=1+o.length-(arguments.length-1);return e(a,c>0?c:0,!0)},t?t(n.exports,"apply",{value:i}):n.exports.apply=i})(Cg);var Fu=Cg.exports,kk=function(e,t){for(var r=0;r<e.length;r+=1)if(!t(e[r],r,e))return!1;return!0},Ek=Object,xk=function(e){return e&&typeof e=="object"&&(typeof e["[[ResourceValue]]"]>"u"||Ek(e["[[ResourceValue]]"])===e["[[ResourceValue]]"])&&(e["[[Hint]]"]==="SYNC-DISPOSE"||e["[[Hint]]"]==="ASYNC-DISPOSE")&&(typeof e["[[DisposeMethod]]"]=="function"||typeof e["[[DisposeMethod]]"]>"u")},Ak=tn,$k=$u(),Tk=kk,Ik=xk,Ck=function(e){return e&&typeof e=="object"&&Ak(e,"[[DisposableResourceStack]]")&&$k(e["[[DisposableResourceStack]]"])&&(e["[[DisposableResourceStack]]"].length===0||Tk(e["[[DisposableResourceStack]]"],Ik))},Pk=en,Rk=function(e){if(e===null)return"Null";if(typeof e>"u")return"Undefined";if(Pk(e))return"Object";if(typeof e=="number")return"Number";if(typeof e=="boolean")return"Boolean";if(typeof e=="string")return"String"},Dk=Rk,Zu=function(e){return typeof e=="symbol"?"Symbol":typeof e=="bigint"?"BigInt":Dk(e)},Lk=j,Ok=wi,Mk=yi,zk=function(e,t){if(!Mk(t))throw new Lk("Assertion failed: P is not a Property Key, got "+Ok(t));return e[t]},Jd=j,Nk=zk,Uk=bi,Fk=yi,Qd=wi,Zk=function(e,t){if(!Fk(t))throw new Jd("Assertion failed: P is not a Property Key");var r=Nk(e,t);if(r!=null){if(!Uk(r))throw new Jd(Qd(t)+" is not a function: "+Qd(r));return r}},Ac={exports:{}},Hk=ct,Wk=Hk,ep=Wk("%Reflect.construct%",!0),la=to;try{la({},"",{"[[Get]]":function(){}})}catch{la=null}if(la&&ep){var tp={},np={};la(np,"length",{"[[Get]]":function(){throw tp},"[[Enumerable]]":!0}),Ac.exports=function(e){try{ep(e,np)}catch(t){return t===tp}}}else Ac.exports=function(e){return typeof e=="function"&&!!e.prototype};var Bk=Ac.exports,Zl=j,rp=bi,Vk=Bk,Gk=function(e){if(!Vk(e))throw new Zl("C must be a constructor");var t={"[[Resolve]]":void 0,"[[Reject]]":void 0},r=new e(function(i,s){if(typeof t["[[Resolve]]"]<"u"||typeof t["[[Reject]]"]<"u")throw new Zl("executor has already been called");t["[[Resolve]]"]=i,t["[[Reject]]"]=s});if(!rp(t["[[Resolve]]"])||!rp(t["[[Reject]]"]))throw new Zl("executor must provide valid resolve and reject functions");return{"[[Promise]]":r,"[[Resolve]]":t["[[Resolve]]"],"[[Reject]]":t["[[Reject]]"]}},ip=Qt,jk=j,Hl=Va,sp=Zk,qk=Gk,Yk=Zu,op=Pu(),ap=Ru(),Xk=function(e,t){if(Yk(e)!=="Object")throw new jk("`V` must be an Object");if(t!=="SYNC-DISPOSE"&&t!=="ASYNC-DISPOSE")throw new ip("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");var r;if(t==="ASYNC-DISPOSE"&&ap&&(r=sp(e,ap)),!r){if(!op)throw new ip("`Symbol.dispose` is not supported");if(r=sp(e,op),typeof r<"u")return function(){var i=this;if(t==="ASYNC-DISPOSE"){var s=qk(Promise);try{Hl(r,i),Hl(s["[[Resolve]]"],void 0,[void 0])}catch(o){s["[[Reject]]"](o)}return s["[[Promise]]"]}Hl(r,i)}}return r},Kk=Qt,Wl=j,Jk=bi,Qk=Zu,eE=Xk,tE=function(e,t){if(t!=="SYNC-DISPOSE"&&t!=="ASYNC-DISPOSE")throw new Kk("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"&&Qk(e)!=="Object")throw new Wl("`V` must be an Object, or `null` or `undefined`");if(r=eE(e,t),typeof r>"u")throw new Wl("dispose method must not be `undefined` on `V` when an object `V` is provided")}else if(r=arguments[2],!Jk(r))throw new Wl("`method`, when provided, must be a function");return{"[[ResourceValue]]":e,"[[Hint]]":t,"[[DisposeMethod]]":r}},nE=Qt,xo=j,rE=Ck,lp=tE,iE=_n(),sE=iE("Array.prototype.push"),Pg=function(e,t,r){if(!rE(e))throw new xo("Assertion failed: `disposeCapability` must be a DisposeCapability Record");if(r!=="SYNC-DISPOSE"&&r!=="ASYNC-DISPOSE")throw new nE("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");var i=arguments.length>3?arguments[3]:void 0;if(arguments.length>3&&typeof i!="function")throw new xo("Assertion failed: `method`, when present, must be a function");if(!e["[[DisposableResourceStack]]"])throw new xo("Assertion failed: `disposeCapability.[[DisposableResourceStack]]` must not be ~EMPTY~");var s;if(arguments.length<4){if(t==null&&r==="SYNC_DISPOSE")return"UNUSED";s=lp(t,r)}else{if(typeof t<"u")throw new xo("Assertion failed: `V` must be undefined when `method` is present");s=lp(void 0,r,i)}return sE(e["[[DisposableResourceStack]]"],s),"UNUSED"},Bl,cp;function Hu(){if(cp)return Bl;cp=1;var n=ct,e=Fu,t=Qt,r=n("%Promise.resolve%",!0),i=r&&e(r);return Bl=function(o,a){if(!i)throw new t("This environment does not support Promises.");return i(o,a)},Bl}var Vl,up;function oE(){if(up)return Vl;up=1;var n=ct,e=Qt,t=n("%Promise%",!0),r=Va,i=Hu(),s=Zu;return Vl=function(a,c,u){if(typeof a<"u"&&s(a)!=="Object")throw new e("Assertion failed: `V` must be `undefined` or an Object");if(c!=="SYNC-DISPOSE"&&c!=="ASYNC-DISPOSE")throw new e("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");if(typeof u<"u"&&typeof u!="function")throw new e("Assertion failed: `method` must be `undefined` or a function");var h=typeof u>"u"?u:r(u,a);if(c==="ASYNC-DISPOSE")return i(t,h)},Vl}var Gl,hp;function aE(){if(hp)return Gl;hp=1;var n=Nu;return Gl=function(t){return new n("throw",t)},Gl}var lE=ct,jl=Qt,dp=j,cE=lE("%Promise%",!0),uE=_n(),pp=uE("Promise.prototype.then",!0),hE=Nu,fp=oE(),dE=Uu,pE=Hu(),gp=aE(),fE=bg(),Rg=function(e,t){if(!(t instanceof hE))throw new dp("`completion` must be a Completion Record");var r=e["[[DisposableResourceStack]]"];if(!r)throw new dp("Assertion failed: `disposeCapability.[[DisposableResourceStack]]` must not be ~EMPTY~");for(var i,s=r.length-1;s>=0;s-=1)if(!i)i=r[s]["[[Hint]]"];else if(i!==r[s]["[[Hint]]"])throw new jl("mixed hint stacks are not supported");for(var o=i==="ASYNC-DISPOSE"&&pE(cE,t),a=function(v){if(t.type()==="throw"){var g=t.value(),E=new fE(v,g);t=gp(E)}else t=gp(v)},c=i==="ASYNC-DISPOSE"&&function(g){return pp(o,function(){var E=fp(g["[[ResourceValue]]"],g["[[Hint]]"],g["[[DisposeMethod]]"]);if(!E)throw new jl("Assertion failed: non-`~ASYNC-DISPOSE~` resource returned a promise from Dispose");return pp(E,dE)},a)},u=r.length-1;u>=0;u-=1)if(i==="ASYNC-DISPOSE")o=c(r[u]);else{var h=r[u];try{var p=fp(h["[[ResourceValue]]"],h["[[Hint]]"],h["[[DisposeMethod]]"]);if(p)throw new jl("Assertion failed: `~SYNC-DISPOSE~` resource returned something from Dispose")}catch(v){a(v)}}return e["[[DisposableResourceStack]]"]=null,i==="ASYNC-DISPOSE"?o:t},Dg=function(){var e=[];return{"[[DisposableResourceStack]]":e}},qa=_u,Wu=j,gE=Va,Si=Iu,mE=to,Lg=bi,vE=Uu,Ge=zu,yE=Ig,Og=vr.supportsDescriptors,bE=Fu,Bu=Pg,wE=Rg,Mg=Dg,mp=Pu(),ot=function n(){if(!(this instanceof n)||Ge.has(this,"[[DisposableState]]")||Ge.has(this,"[[DisposeCapability]]"))throw new Wu("can only be used with new");Ge.set(this,"[[DisposableState]]","PENDING"),Ge.set(this,"[[DisposeCapability]]",Mg())},zg=function(){var e=this;return Ge.assert(e,"[[DisposableState]]"),Ge.get(e,"[[DisposableState]]")==="DISPOSED"},io=bE(zg);Og?mE(ot.prototype,"disposed",{"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Get]]":zg}):ot.prototype.disposed=!1;var Ng=function(e){Ge.set(e,"[[DisposableState]]","DISPOSED"),Og||(e.disposed=!0)};Si(ot.prototype,"dispose",function(){var e=this;if(!io(e))return Ng(e),wE(Ge.get(e,"[[DisposeCapability]]"),vE())["?"]()});Si(ot.prototype,"use",function(e){var t=this;if(io(t))throw new qa("a disposed stack can not use anything new");return Bu(Ge.get(t,"[[DisposeCapability]]"),e,"SYNC-DISPOSE"),e});Si(ot.prototype,"adopt",function(e,t){var r=this;if(io(r))throw new qa("a disposed stack can not use anything new");if(!Lg(t))throw new Wu("`onDispose` must be a function");var i=function(){return gE(t,void 0,[e])};return Bu(Ge.get(r,"[[DisposeCapability]]"),void 0,"SYNC-DISPOSE",i),e});Si(ot.prototype,"defer",function(e){var t=this;if(io(t))throw new qa("a disposed stack can not defer anything new");if(!Lg(e))throw new Wu("`onDispose` must be a function");Bu(Ge.get(t,"[[DisposeCapability]]"),void 0,"SYNC-DISPOSE",e)});Si(ot.prototype,"move",function(){var e=this;if(io(e))throw new qa("a disposed stack can not use anything new");var t=new ot;return Ge.set(t,"[[DisposeCapability]]",Ge.get(e,"[[DisposeCapability]]")),Ge.set(e,"[[DisposeCapability]]",Mg()),Ng(e),t});mp&&Si(ot.prototype,mp,ot.prototype.dispose);yE(ot.prototype,"DisposableStack");var SE=ot,_E=SE,kE=function(){return typeof DisposableStack=="function"?DisposableStack:_E},EE=vr,xE=wu(),AE=kE,$E=function(){var e=AE();return EE(xE,{DisposableStack:e},{DisposableStack:!0}),e},TE=ct,Ya=_u,Vu=j,vp=TE("%Promise%",!0),Gu=Pg,IE=Va,_i=Iu,CE=to,PE=Rg,Ug=bi,Fg=Dg,RE=Uu,yp=Hu(),je=zu,DE=Ig,Zg=vr.supportsDescriptors,LE=Fu,OE=_n(),ME=OE("Promise.prototype.then",!0),bp=Ru(),at=function n(){if(!(this instanceof n)||je.has(this,"[[AsyncDisposableState]]")||je.has(this,"[[DisposeCapability]]"))throw new Vu("can only be used with new");je.set(this,"[[AsyncDisposableState]]","pending"),je.set(this,"[[DisposeCapability]]",Fg())},Hg=function(){var e=this;return je.assert(e,"[[AsyncDisposableState]]"),je.get(e,"[[AsyncDisposableState]]")==="disposed"},so=LE(Hg);Zg?CE(at.prototype,"disposed",{"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Get]]":Hg}):at.prototype.disposed=!1;var Wg=function(e){je.set(e,"[[AsyncDisposableState]]","disposed"),Zg||(e.disposed=!0)};_i(at.prototype,"disposeAsync",function(){var e=this;return so(e)?yp(vp):(Wg(e),ME(yp(vp,PE(je.get(e,"[[DisposeCapability]]"),RE())),function(t){return t["?"]()}))});_i(at.prototype,"use",function(e){var t=this;if(so(t))throw new Ya("a disposed stack can not use anything new");return Gu(je.get(t,"[[DisposeCapability]]"),e,"ASYNC-DISPOSE"),e});_i(at.prototype,"adopt",function(e,t){var r=this;if(so(r))throw new Ya("a disposed stack can not use anything new");if(!Ug(t))throw new Vu("`onDisposeAsync` must be a function");var i=function(){return IE(t,void 0,[e])};return i.value=e,Gu(je.get(r,"[[DisposeCapability]]"),void 0,"ASYNC-DISPOSE",i),e});_i(at.prototype,"defer",function(e){var t=this;if(so(t))throw new Ya("a disposed stack can not defer anything new");if(!Ug(e))throw new Vu("`onDispose` must be a function");Gu(je.get(t,"[[DisposeCapability]]"),void 0,"ASYNC-DISPOSE",e)});_i(at.prototype,"move",function(){var e=this;if(so(e))throw new Ya("a disposed stack can not use anything new");var t=new at;return je.set(t,"[[DisposeCapability]]",je.get(e,"[[DisposeCapability]]")),je.set(e,"[[DisposeCapability]]",Fg()),Wg(e),t});bp&&_i(at.prototype,bp,at.prototype.disposeAsync);DE(at.prototype,"AsyncDisposableStack");var zE=at,NE=zE,UE=function(){return typeof AsyncDisposableStack=="function"?AsyncDisposableStack:NE},FE=vr,ZE=wu(),HE=UE,WE=function(){var e=HE();return FE(ZE,{AsyncDisposableStack:e},{AsyncDisposableStack:!0}),e},BE=FS,VE=qS,GE=$E,jE=WE,qE=function(){BE(),VE(),GE(),jE()};qE();const wp=new WeakMap;function YE(n){return(typeof n=="object"||typeof n=="function")&&n!==null&&"then"in n&&typeof n.then=="function"}function Cr(n){return typeof n=="string"?n:typeof n=="symbol"?n.description??n.toString():n.name||"(anonymous class)"}function Sp(){return new Error("register(Key, factory) requires a factory function. Wrap existing instances as () => instance.")}function XE(){return new Error("register(Key, factory) does not accept async factories. Await setup before registering.")}class KE{constructor(){b(this,"entries",new Map);b(this,"constructionStack",[])}register(e,t){if(t===void 0){if(typeof e!="function")throw Sp();this.validateClassRegistration(e),this.storeFactory(e,()=>this.instantiateClass(e));return}if(typeof t!="function")throw Sp();if(t.constructor.name==="AsyncFunction")throw XE();this.storeFactory(e,t)}has(e){var t;return((t=this.entries.get(e))==null?void 0:t.factory)!==void 0}resolve(e){return this.resolveAny(e)}storeFactory(e,t){const r=this.getOrCreateEntry(e);r.factory=t,r.instance=void 0,r.error=void 0}validateClassRegistration(e){const t=wp.get(e);if(t){if(e.length!==t.length)throw new Error(`${Cr(e)} cannot be registered with register(Class). @injectable(...) declared ${t.length} dependencies but constructor arity is ${e.length}. Use register(Key, () => value) instead.`);return}if(e.length!==0)throw new Error(`${Cr(e)} cannot be registered with register(Class). Undecorated classes must have zero required constructor parameters. Use register(Key, () => value) instead.`)}instantiateClass(e){const t=wp.get(e);if(!t)return new e;const r=t.map(i=>this.resolveAny(i));return new e(...r)}resolveAny(e){return this.getOrCreateEntry(e).proxy}getOrCreateEntry(e){let t=this.entries.get(e);return t||(t={key:e},t.proxy=this.createProxy(t),this.entries.set(e,t),t)}createProxy(e){return new Proxy({},{get:(t,r)=>{if(r==="then")return;const i=this.getInstance(e),s=Reflect.get(i,r,i);return typeof s=="function"?s.bind(i):s},set:(t,r,i)=>{const s=this.getInstance(e);return Reflect.set(s,r,i,s)},has:(t,r)=>{const i=this.getInstance(e);return r in i}})}getInstance(e){if(e.instance)return e.instance;if(e.error)throw e.error;if(!e.factory)throw new Error(`${Cr(e.key)} was resolved but never registered`);const t=this.constructionStack.indexOf(e.key);if(t!==-1){const r=[...this.constructionStack.slice(t),e.key].map(i=>Cr(i)).join(" -> ");throw new Error(`Circular dependency detected: ${r}`)}this.constructionStack.push(e.key);try{const r=e.factory();if(YE(r))throw new Error(`Factory for ${Cr(e.key)} returned a Promise. Await setup before registering.`);if(typeof r!="object"||r===null)throw new Error(`Factory for ${Cr(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 qe=new KE,JE=new Set(["target","currentTarget","eventPhase","defaultPrevented","isTrusted","timeStamp","srcElement","returnValue","cancelBubble","NONE","CAPTURING_PHASE","AT_TARGET","BUBBLING_PHASE","composedPath","stopPropagation","stopImmediatePropagation","preventDefault","initEvent"]);function QE(n){for(const e of Object.keys(n))if(JE.has(e))throw new Error(`Event payload key "${e}" is reserved; choose a different property name`)}function ex(n,e){QE(e);for(const t of Object.keys(e))Object.defineProperty(n,t,{value:e[t],writable:!0,enumerable:!0,configurable:!0})}function tt(){class n extends Event{constructor(t,r){const{type:i,bubbles:s,cancelable:o,composed:a,...c}=r??{};if(i!==void 0)throw new Error('Do not pass "type" in init; use the constructor argument instead');super(t,{bubbles:s,cancelable:o,composed:a}),ex(this,c)}}return n}class wt extends globalThis.EventTarget{}function tx(n,e,t){const r=n.dispose.bind(n);n.dispose=()=>{if(!e())return t(),r()}}function ki(n){var t;class e extends n{constructor(...s){super(...s);w(this,t,!1);tx(this,()=>l(this,t),()=>{x(this,t,!0)})}[Symbol.dispose](){this.dispose()}get disposed(){return l(this,t)}}return t=new WeakMap,e}const nx=tt(),rx=tt(),jo=tt(),Bg="0123456789ABCDEFGHJKMNPQRSTVWXYZ",ca=32,ix=16,Vg=10,_p=0xffffffffffff;var Un;(function(n){n.Base32IncorrectEncoding="B32_ENC_INVALID",n.DecodeTimeInvalidCharacter="DEC_TIME_CHAR",n.DecodeTimeValueMalformed="DEC_TIME_MALFORMED",n.EncodeTimeNegative="ENC_TIME_NEG",n.EncodeTimeSizeExceeded="ENC_TIME_SIZE_EXCEED",n.EncodeTimeValueMalformed="ENC_TIME_MALFORMED",n.PRNGDetectFailure="PRNG_DETECT",n.ULIDInvalid="ULID_INVALID",n.Unexpected="UNEXPECTED",n.UUIDInvalid="UUID_INVALID"})(Un||(Un={}));class Wi extends Error{constructor(e,t){super(`${t} (${e})`),this.name="ULIDError",this.code=e}}function sx(n){const e=Math.floor(n()*ca)%ca;return Bg.charAt(e)}function ox(n){const e=ax(),t=e&&(e.crypto||e.msCrypto)||null;if(typeof(t==null?void 0:t.getRandomValues)=="function")return()=>{const r=new Uint8Array(1);return t.getRandomValues(r),r[0]/256};if(typeof(t==null?void 0:t.randomBytes)=="function")return()=>t.randomBytes(1).readUInt8()/256;throw new Wi(Un.PRNGDetectFailure,"Failed to find a reliable PRNG")}function ax(){return ux()?self:typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:null}function lx(n,e){let t="";for(;n>0;n--)t=sx(e)+t;return t}function cx(n,e=Vg){if(isNaN(n))throw new Wi(Un.EncodeTimeValueMalformed,`Time must be a number: ${n}`);if(n>_p)throw new Wi(Un.EncodeTimeSizeExceeded,`Cannot encode a time larger than ${_p}: ${n}`);if(n<0)throw new Wi(Un.EncodeTimeNegative,`Time must be positive: ${n}`);if(Number.isInteger(n)===!1)throw new Wi(Un.EncodeTimeValueMalformed,`Time must be an integer: ${n}`);let t,r="";for(let i=e;i>0;i--)t=n%ca,r=Bg.charAt(t)+r,n=(n-t)/ca;return r}function ux(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}function ju(n,e){const t=ox(),r=Date.now();return cx(r,Vg)+lx(ix,t)}const Lt=4,et=6,Gg=2,$c=2,hx=Lt,dx=et,qu="auto",mn="auto",On=120,kp=50,he=16,hr=On*Lt+he*(Lt-1),ua=On*et+he*(et-1),px=hr+he*2,fx=200,gx=4,Ao=150,mx=10,Ep=2,xp=8,vx=300,yx=4;function jg(n){return Xg(n)}function qg(n,e){return Xg(n.flatMap(t=>Jg(t,e)))}function Yg(n){const e=[],t=new Set;for(const r of n){if(r.type==="row"){e.push(`Top-level rows are invalid: ${r.id}`);continue}Qg(r,"strip",e,t)}return{valid:e.length===0,errors:e}}function Fr(n){const e=jg(n),t=Yg(e);if(!t.valid)throw new Error(`Invalid layout: ${t.errors.join("; ")}`);return{totalNodes:e.length,nodes:e.filter(r=>r.type!=="row").map(_x)}}function Xg(n){const e=[];for(const t of n){const r=Kg(t);for(const i of r){if(i.type==="row"){e.push(...i.children.map(Kt));continue}e.push(i)}}return e}function Kg(n){switch(n.type){case"card":return[Kt(n)];case"row":{const e=n.children.map(Kt);return e.length===0?[]:e.length===1?[e[0]]:[{...n,children:e}]}case"stack":{const e=[];for(const t of n.children){const r=Kg(t);for(const i of r){if(i.type==="stack"){e.push(...i.children.map(Tc));continue}if(i.type==="row"){e.push({...i,children:i.children.map(Kt)});continue}e.push(Kt(i))}}return e.length===0?[]:e.length===1?[Tc(e[0])]:[{...n,children:e}]}}}function Jg(n,e){switch(n.type){case"card":return n.artifactID===e?[]:[Kt(n)];case"row":{const t=n.children.filter(r=>r.artifactID!==e).map(Kt);return t.length===0?[]:t.length===1?[t[0]]:[{...n,children:t}]}case"stack":{const t=n.children.flatMap(r=>Jg(r,e).filter(s=>s.type!=="stack"));return t.length===0?[]:t.length===1?[Tc(t[0])]:[{...n,children:t}]}}}function Qg(n,e,t,r){switch(n.type){case"card":em(n,e,t,r);return;case"row":bx(n,e,t,r);return;case"stack":wx(n,e,t,r);return}}function em(n,e,t,r){Yu(n.id,t),typeof n.artifactID!="string"||n.artifactID.length===0?t.push(`Card ${n.id} is missing artifactID`):r.has(n.artifactID)?t.push(`Duplicate artifactID in layout: ${n.artifactID}`):r.add(n.artifactID),Sx(n.width)||t.push(`Card ${n.id} width must be an integer in the range 2-4`),tm(n.height)||t.push(`Card ${n.id} height must be an integer in the range 2-6 or "auto"`);const i=Mn(n.width);e==="row"&&i<Gg&&t.push(`Row child ${n.id} must be at least 2 columns wide`)}function bx(n,e,t,r){if(Yu(n.id,t),e!=="stack"&&t.push(`Row ${n.id} may only appear inside a stack`),tm(n.height,yx)||t.push(`Row ${n.id} height must be an integer in the range 2-4 or "auto"`),!Array.isArray(n.children)||n.children.length===0){t.push(`Row ${n.id} must contain card nodes`);return}let i=0;for(const s of n.children){if(s.type!=="card"){t.push(`Row ${n.id} must contain only card nodes`);continue}em(s,"row",t,r),i+=Mn(s.width)}i!==Lt&&t.push(`Row ${n.id} children must sum to 4 columns`)}function wx(n,e,t,r){if(Yu(n.id,t),e!=="strip"&&t.push(`Invalid nested stack at ${n.id}; stack children cannot contain another nested stack`),!Array.isArray(n.children)||n.children.length===0){t.push(`Stack ${n.id} must contain at least one child`);return}let i=0,s=0;for(const a of n.children){if(a.type==="stack"){t.push(`Stack ${n.id} cannot contain another nested stack`);continue}if(Qg(a,"stack",t,r),a.height===mn){s+=1;continue}i+=a.height}if(i>et&&t.push(`Stack ${n.id} exceeds the 6-row budget`),s===0)return;const o=et-i;if(o<s*$c||o%s!==0){t.push(`Stack ${n.id} has auto-height children that cannot resolve to whole height >= 2`);return}o/s<$c&&t.push(`Stack ${n.id} has auto-height children below the minimum row size`)}function Yu(n,e){(typeof n!="string"||n.length===0)&&e.push(`Node id must be a non-empty string: ${String(n)}`)}function Sx(n){return n===qu||Number.isInteger(n)&&n>=Gg&&n<=hx}function tm(n,e=dx){return n===mn||Number.isInteger(n)&&n>=$c&&n<=e}function Mn(n){return n===qu?Lt:n}function _x(n){if(n.type==="card")return{id:n.id,type:"card",width:Mn(n.width),cards:[{id:n.id,artifactID:n.artifactID,col:1,row:1,width:Mn(n.width),height:nm(n.height,et)}]};const e=kx(n.children),t=[];let r=1;for(let i=0;i<n.children.length;i+=1){const s=n.children[i],o=e[i];if(s.type==="card")t.push({id:s.id,artifactID:s.artifactID,col:1,row:r,width:Mn(s.width),height:o});else{let a=1;for(const c of s.children)t.push({id:c.id,artifactID:c.artifactID,col:a,row:r,width:Mn(c.width),height:o}),a+=Mn(c.width)}r+=o}return{id:n.id,type:"stack",width:t.reduce((i,s)=>Math.max(i,s.col+s.width-1),1),cards:t}}function kx(n){let e=0,t=0;for(const i of n)i.height===mn?t+=1:e+=i.height;const r=t>0?(et-e)/t:0;return n.map(i=>nm(i.height,r))}function nm(n,e){return n===mn?e:n}function Kt(n){return{...n}}function Tc(n){return n.type==="card"?Kt(n):{...n,children:n.children.map(Kt)}}function rm(n,e={}){return{id:e.id??ju(),type:"card",artifactID:n,width:e.width??qu,height:e.height??mn}}function im(n,e){return n.some(t=>sm(t,e))}function sm(n,e){switch(n.type){case"card":return n.artifactID===e;case"row":return n.children.some(t=>t.artifactID===e);case"stack":return n.children.some(t=>sm(t,e))}}function Ap(n){return n.layout.flatMap(om)}function om(n){switch(n.type){case"card":return[n.artifactID];case"row":return n.children.map(e=>e.artifactID);case"stack":return n.children.flatMap(om)}}const K=tt(),am=tt(),Pr=tt(),Ex=tt();function xx(n){class e extends Error{constructor(r,i){super(r),this.name=n,i&&Object.assign(this,i)}}return e}const Ax=xx("RequestError"),$x=200,Tx=300;class Ix{constructor(e,t){b(this,"serverURL");b(this,"token");this.serverURL=e.replace(/\/$/,""),this.token=t.token}async requestJSON(e,t,r){const i=await this.request(e,t,r!==void 0?JSON.stringify(r):void 0,r!==void 0?{"content-type":"application/json"}:void 0),s=await Cx(i);if(!i.ok||i.status<$x||i.status>=Tx)throw this.createError(typeof s.error=="string"?s.error:i.statusText,i.status);return s}async requestVoid(e,t){const r=await this.request(e,t);if(!r.ok)throw this.createError(await ql(r,r.statusText),r.status)}async requestText(e,t){const r=await this.request(e,t);if(!r.ok)throw this.createError(await ql(r,r.statusText),r.status);return r.text()}async requestRawVoid(e,t,r){const i=await this.request(e,t,r,{"content-type":"text/plain"});if(!i.ok)throw this.createError(await ql(i,i.statusText),i.status)}createError(e,t){const r={serverURL:this.serverURL};return t!==void 0&&(r.status=t),new Ax(e,r)}async request(e,t,r,i){const s=`${this.serverURL}${t}`;try{return await fetch(s,{method:e,headers:this.buildHeaders(i),body:r})}catch(o){throw this.createError(o instanceof Error?o.message:"Failed to reach server")}}buildHeaders(e){const t={...e??{}};return this.token&&(t.Authorization=`Bearer ${this.token}`),Object.keys(t).length>0?t:void 0}}async function Cx(n){try{return await n.json()}catch{const e=await n.text().catch(()=>"");return e?{message:e}:{}}}async function ql(n,e){try{const t=await n.json();if(typeof t.error=="string")return t.error;if(typeof t.message=="string")return t.message}catch{}return e}function Px(n){return n.map(e=>`${e.name} (${e.id})`).join(", ")}var Tt,_a,lm;class Rx{constructor(e){w(this,_a);w(this,Tt);x(this,Tt,e)}list(){return l(this,Tt).requestJSON("GET","/screens")}async get(e={}){const t=await m(this,_a,lm).call(this,e.screenID);return l(this,Tt).requestJSON("GET",`/screens/${encodeURIComponent(t)}`)}create(e){const t={name:e.name};return e.id!==void 0&&(t.id=e.id),l(this,Tt).requestJSON("POST","/screens",t)}update(e){const{screenID:t,...r}=e;return l(this,Tt).requestJSON("PATCH",`/screens/${encodeURIComponent(t)}`,r)}remove(e){return l(this,Tt).requestJSON("DELETE",`/screens/${encodeURIComponent(e.screenID)}`)}}Tt=new WeakMap,_a=new WeakSet,lm=async function(e){if(e!==void 0)return e;const{screens:t}=await this.list();if(t.length===1)return t[0].id;throw l(this,Tt).createError(`screenID is required when multiple screens exist. Available screens: ${Px(t)}`)};var Le;class Dx{constructor(e){w(this,Le);x(this,Le,e)}create(e){const t={type:e.type,title:e.title};return e.externalFilePath!==void 0&&(t.externalFilePath=e.externalFilePath),e.externalURL!==void 0&&(t.externalURL=e.externalURL),e.screenID!==void 0&&(t.screenID=e.screenID),l(this,Le).requestJSON("POST","/artifacts",t)}list(e={}){const t=new URLSearchParams;e.screenID!==void 0&&t.set("screenID",e.screenID),e.unplaced&&t.set("unplaced","true");const r=t.toString();return l(this,Le).requestJSON("GET",r?`/artifacts?${r}`:"/artifacts")}get(e){return l(this,Le).requestJSON("GET",`/artifacts/${encodeURIComponent(e.artifactID)}`)}update(e){const t={};return e.title!==void 0&&(t.title=e.title),l(this,Le).requestJSON("PATCH",`/artifacts/${encodeURIComponent(e.artifactID)}`,t)}edit(e){return l(this,Le).requestJSON("POST",`/artifacts/${encodeURIComponent(e.artifactID)}/edit`)}commitPending(e){return l(this,Le).requestJSON("POST",`/artifacts/${encodeURIComponent(e.artifactID)}/commit`)}abandonPending(e){return l(this,Le).requestVoid("POST",`/artifacts/${encodeURIComponent(e.artifactID)}/abandon`)}attach(e){return l(this,Le).requestJSON("POST",`/screens/${encodeURIComponent(e.screenID)}/artifacts/${encodeURIComponent(e.artifactID)}`)}detach(e){return l(this,Le).requestJSON("DELETE",`/screens/${encodeURIComponent(e.screenID)}/artifacts/${encodeURIComponent(e.artifactID)}`)}delete(e){return l(this,Le).requestJSON("DELETE",`/artifacts/${encodeURIComponent(e.artifactID)}`)}getContent(e){return l(this,Le).requestText("GET",`/artifacts/${encodeURIComponent(e.artifactID)}/content`)}putContent(e){return l(this,Le).requestRawVoid("PUT",`/artifacts/${encodeURIComponent(e.artifactID)}/content`,e.content)}}Le=new WeakMap;var Hn;class Lx{constructor(e){w(this,Hn);x(this,Hn,e)}state(){return l(this,Hn).requestJSON("GET","/viewer/state")}setActive(e){return l(this,Hn).requestJSON("PUT","/viewer/active-screen",{screenID:e.screenID})}focus(e){const t={artifactID:e.artifactID};return e.screenID!==void 0&&(t.screenID=e.screenID),l(this,Hn).requestJSON("POST","/viewer/focus",t)}}Hn=new WeakMap;var us;class Ox{constructor(e){w(this,us);x(this,us,e)}async list(){const{views:e}=await l(this,us).requestJSON("GET","/views");return e}}us=new WeakMap;var Wt;class Mx{constructor(e,t={}){b(this,"screens");b(this,"artifacts");b(this,"viewer");b(this,"views");w(this,Wt);x(this,Wt,new Ix(e,t)),this.screens=new Rx(l(this,Wt)),this.artifacts=new Dx(l(this,Wt)),this.viewer=new Lx(l(this,Wt)),this.views=new Ox(l(this,Wt))}health(){return l(this,Wt).requestJSON("GET","/health")}}Wt=new WeakMap;const zx={focusCommandInput:{label:"Focus Command Input",trigger:{key:"k",meta:!0}}},Nx=ki(wt);var Wn,We,Bn,ze,dt,on,an,J,Pn,cm,hs,um,hm,dm,pm,Ic,Cc,Pc,fm;class Ux extends Nx{constructor(t){var i;super();w(this,J);b(this,"id");b(this,"server");w(this,Wn);w(this,We,new Map);w(this,Bn);w(this,ze);w(this,dt);w(this,on);w(this,an,null);w(this,hs,t=>{if(this.disposed)return;const r=t.event;switch(r.type){case"screen-updated":r.screen.id===this.id&&m(this,J,um).call(this,r.screen);break;case"artifact-created":break;case"artifact-attached":r.screenID===this.id&&m(this,J,hm).call(this,r.cardID,r.artifact);break;case"artifact-updated":m(this,J,dm).call(this,r.artifact);break;case"artifact-removed":r.screenID===this.id&&m(this,J,pm).call(this,r.artifactID);break;case"artifact-content-changed":l(this,We).has(r.artifactID)&&this.dispatchEvent(new Ex("artifact-content-changed",{artifactID:r.artifactID}));break}});this.id=t.screen.id,this.server=t.server,x(this,Wn,t.localStore),x(this,Bn,t.screen.name),x(this,ze,structuredClone(t.screen.layout)),x(this,dt,t.screen.starred);const r=((i=l(this,Wn).get().screens[this.id])==null?void 0:i.scrollPosition)??0;x(this,on,Math.max(0,r)),this.server.addEventListener("server-event",l(this,hs)),m(this,J,cm).call(this)}get name(){return l(this,Bn)}get layout(){return l(this,ze)}get starred(){return l(this,dt)}get scrollPosition(){return l(this,on)}get artifacts(){return l(this,We)}setScrollPosition(t){m(this,J,Pn).call(this);const r=Math.max(0,t);r!==l(this,on)&&(x(this,on,r),m(this,J,fm).call(this),this.dispatchEvent(new K("change")))}setLayout(t){m(this,J,Pn).call(this);const r=jg(t);if(!Yg(r).valid)return;const s=m(this,J,Cc).call(this);x(this,ze,r),x(this,an,{layout:r,snapshot:s}),this.dispatchEvent(new K("change")),this.server.client.screens.update({screenID:this.id,layout:r.map(o=>structuredClone(o))}).catch(()=>{var o;this.disposed||((o=l(this,an))==null?void 0:o.layout)===r&&(x(this,an,null),m(this,J,Pc).call(this,s),this.dispatchEvent(new K("change")))})}rename(t){m(this,J,Pn).call(this),x(this,Bn,t),this.dispatchEvent(new K("change")),this.server.client.screens.update({screenID:this.id,name:t}).catch(()=>{})}setStarred(t){if(m(this,J,Pn).call(this),l(this,dt)===t)return;const r=l(this,dt);x(this,dt,t),this.dispatchEvent(new K("change")),this.server.client.screens.update({screenID:this.id,starred:t}).catch(()=>{this.disposed||l(this,dt)===t&&(x(this,dt,r),this.dispatchEvent(new K("change")))})}async remove(){m(this,J,Pn).call(this),await this.server.client.screens.remove({screenID:this.id})}removeArtifact(t){if(m(this,J,Pn).call(this),!l(this,We).has(t))return;const r=m(this,J,Cc).call(this);m(this,J,Ic).call(this,t),this.dispatchEvent(new K("change")),this.server.client.artifacts.detach({artifactID:t,screenID:this.id}).catch(()=>{this.disposed||(m(this,J,Pc).call(this,r),this.dispatchEvent(new K("change")))})}dispose(){this.server.removeEventListener("server-event",l(this,hs))}}Wn=new WeakMap,We=new WeakMap,Bn=new WeakMap,ze=new WeakMap,dt=new WeakMap,on=new WeakMap,an=new WeakMap,J=new WeakSet,Pn=function(){if(this.disposed)throw new Error("ScreenModel is disposed")},cm=async function(){try{const t=await this.server.client.screens.get({screenID:this.id});if(this.disposed)return;for(const r of t.artifacts)l(this,We).set(r.id,r);this.dispatchEvent(new K("change"))}catch{}},hs=new WeakMap,um=function(t){l(this,an)&&x(this,an,null),x(this,Bn,t.name),x(this,ze,structuredClone(t.layout)),x(this,dt,t.starred),this.dispatchEvent(new K("change"))},hm=function(t,r){im(l(this,ze),r.id)||x(this,ze,[...l(this,ze),rm(r.id,{id:t})]),l(this,We).set(r.id,r),this.dispatchEvent(new K("change"))},dm=function(t){const r=l(this,We).get(t.id);r&&(l(this,We).set(t.id,{...r,...t}),this.dispatchEvent(new K("change")))},pm=function(t){m(this,J,Ic).call(this,t)&&this.dispatchEvent(new K("change"))},Ic=function(t){const r=l(this,We).delete(t),i=Ap({layout:l(this,ze)}).length,s=qg(l(this,ze),t),o=Ap({layout:s}).length;return x(this,ze,s),r||i!==o},Cc=function(){return{layout:structuredClone(l(this,ze)),artifacts:new Map([...l(this,We).entries()].map(([t,r])=>[t,structuredClone(r)]))}},Pc=function(t){x(this,ze,structuredClone(t.layout)),l(this,We).clear();for(const[r,i]of t.artifacts)l(this,We).set(r,structuredClone(i))},fm=function(){const t=l(this,Wn).get();l(this,Wn).set({...t,screens:{...t.screens,[this.id]:{scrollPosition:l(this,on)}}})};const Fx=ki(wt);var nt,It,pt,ds,ps,fs,Vr,qo;class Zx extends Fx{constructor(t){super();w(this,Vr);w(this,nt);w(this,It);w(this,pt,null);w(this,ds,()=>{this.disposed||m(this,Vr,qo).call(this)});w(this,ps,()=>{this.disposed||m(this,Vr,qo).call(this)});w(this,fs,t=>{var i;if(this.disposed)return;const r=t.event;if(r.type==="screen-removed"&&((i=l(this,pt))==null?void 0:i.id)===r.screenID&&this.clearActive(),r.type==="viewer-active-screen-changed"){const s=l(this,It).servers.get(t.serverURL);s&&s.screens.has(r.screenID)&&this.setActive(t.serverURL,r.screenID)}});x(this,nt,t.localStore),x(this,It,t.serverManager),l(this,nt).addEventListener("change",l(this,ds)),l(this,It).addEventListener("change",l(this,ps)),l(this,It).addEventListener("server-event",l(this,fs)),m(this,Vr,qo).call(this)}get activeScreen(){return l(this,pt)}setActive(t,r){const i=l(this,nt).get();i.activeServerURL===t&&i.activeScreenID===r||l(this,nt).set({...i,activeServerURL:t,activeScreenID:r})}clearActive(){const t=l(this,nt).get();t.activeScreenID!==null&&l(this,nt).set({...t,activeScreenID:null})}dispose(){var t;l(this,nt).removeEventListener("change",l(this,ds)),l(this,It).removeEventListener("change",l(this,ps)),l(this,It).removeEventListener("server-event",l(this,fs)),(t=l(this,pt))==null||t.dispose(),x(this,pt,null)}}nt=new WeakMap,It=new WeakMap,pt=new WeakMap,ds=new WeakMap,ps=new WeakMap,fs=new WeakMap,Vr=new WeakSet,qo=function(){var c,u,h;const{activeServerURL:t,activeScreenID:r}=l(this,nt).get(),i=t?l(this,It).servers.get(t)??null:null,s=i&&r?i.screens.get(r)??null:null,o=((c=l(this,pt))==null?void 0:c.id)??null,a=(s==null?void 0:s.id)??null;o===a&&((u=l(this,pt))==null?void 0:u.server)===i||((h=l(this,pt))==null||h.dispose(),x(this,pt,i&&s?new Ux({screen:s,server:i,localStore:l(this,nt)}):null),this.dispatchEvent(new nx("active-screen-changed")))};const Hx="Local",Wx="store-";function ht(n){return new URL(n).origin}function Bx(n){return{servers:[{url:ht(n),name:Hx}],activeServerURL:null,activeScreenID:null,screens:{}}}var Vn,Gn,jn;class Vx extends wt{constructor(t,r,i={}){super();w(this,Vn);w(this,Gn);w(this,jn);x(this,Vn,`${Wx}${t}`),x(this,Gn,i.storage??Gx());const s=l(this,Gn).getItem(l(this,Vn));s===null?(x(this,jn,r),l(this,Gn).setItem(l(this,Vn),JSON.stringify(r))):x(this,jn,JSON.parse(s))}get(){return l(this,jn)}set(t){x(this,jn,t),l(this,Gn).setItem(l(this,Vn),JSON.stringify(t)),this.dispatchEvent(new K("change"))}}Vn=new WeakMap,Gn=new WeakMap,jn=new WeakMap;function Gx(){const n=globalThis.localStorage;if(!n)throw new Error("LocalStore: no storage adapter supplied and window.localStorage is unavailable");return n}function A(n,e,t){function r(a,c){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:c,constr:o,traits:new Set},enumerable:!1}),a._zod.traits.has(n))return;a._zod.traits.add(n),e(a,c);const u=o.prototype,h=Object.keys(u);for(let p=0;p<h.length;p++){const v=h[p];v in a||(a[v]=u[v].bind(a))}}const i=(t==null?void 0:t.Parent)??Object;class s extends i{}Object.defineProperty(s,"name",{value:n});function o(a){var c;const u=t!=null&&t.Parent?new s:this;r(u,a),(c=u._zod).deferred??(c.deferred=[]);for(const h of u._zod.deferred)h();return u}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:a=>{var c,u;return t!=null&&t.Parent&&a instanceof t.Parent?!0:(u=(c=a==null?void 0:a._zod)==null?void 0:c.traits)==null?void 0:u.has(n)}}),Object.defineProperty(o,"name",{value:n}),o}class Br extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class gm extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}}const mm={};function vn(n){return mm}function vm(n){const e=Object.values(n).filter(r=>typeof r=="number");return Object.entries(n).filter(([r,i])=>e.indexOf(+r)===-1).map(([r,i])=>i)}function Rc(n,e){return typeof e=="bigint"?e.toString():e}function Xu(n){return{get value(){{const e=n();return Object.defineProperty(this,"value",{value:e}),e}}}}function Ku(n){return n==null}function Ju(n){const e=n.startsWith("^")?1:0,t=n.endsWith("$")?n.length-1:n.length;return n.slice(e,t)}function jx(n,e){const t=(n.toString().split(".")[1]||"").length,r=e.toString();let i=(r.split(".")[1]||"").length;if(i===0&&/\d?e-\d?/.test(r)){const c=r.match(/\d?e-(\d?)/);c!=null&&c[1]&&(i=Number.parseInt(c[1]))}const s=t>i?t:i,o=Number.parseInt(n.toFixed(s).replace(".","")),a=Number.parseInt(e.toFixed(s).replace(".",""));return o%a/10**s}const $p=Symbol("evaluating");function ee(n,e,t){let r;Object.defineProperty(n,e,{get(){if(r!==$p)return r===void 0&&(r=$p,r=t()),r},set(i){Object.defineProperty(n,e,{value:i})},configurable:!0})}function br(n,e,t){Object.defineProperty(n,e,{value:t,writable:!0,enumerable:!0,configurable:!0})}function En(...n){const e={};for(const t of n){const r=Object.getOwnPropertyDescriptors(t);Object.assign(e,r)}return Object.defineProperties({},e)}function Tp(n){return JSON.stringify(n)}function qx(n){return n.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const ym="captureStackTrace"in Error?Error.captureStackTrace:(...n)=>{};function ha(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}const Yx=Xu(()=>{var n;if(typeof navigator<"u"&&((n=navigator==null?void 0:navigator.userAgent)!=null&&n.includes("Cloudflare")))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function hi(n){if(ha(n)===!1)return!1;const e=n.constructor;if(e===void 0||typeof e!="function")return!0;const t=e.prototype;return!(ha(t)===!1||Object.prototype.hasOwnProperty.call(t,"isPrototypeOf")===!1)}function bm(n){return hi(n)?{...n}:Array.isArray(n)?[...n]:n}const Xx=new Set(["string","number","symbol"]);function di(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function xn(n,e,t){const r=new n._zod.constr(e??n._zod.def);return(!e||t!=null&&t.parent)&&(r._zod.parent=n),r}function O(n){const e=n;if(!e)return{};if(typeof e=="string")return{error:()=>e};if((e==null?void 0:e.message)!==void 0){if((e==null?void 0:e.error)!==void 0)throw new Error("Cannot specify both `message` and `error` params");e.error=e.message}return delete e.message,typeof e.error=="string"?{...e,error:()=>e.error}:e}function Kx(n){return Object.keys(n).filter(e=>n[e]._zod.optin==="optional"&&n[e]._zod.optout==="optional")}const Jx={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 Qx(n,e){const t=n._zod.def,r=t.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const s=En(n._zod.def,{get shape(){const o={};for(const a in e){if(!(a in t.shape))throw new Error(`Unrecognized key: "${a}"`);e[a]&&(o[a]=t.shape[a])}return br(this,"shape",o),o},checks:[]});return xn(n,s)}function e1(n,e){const t=n._zod.def,r=t.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const s=En(n._zod.def,{get shape(){const o={...n._zod.def.shape};for(const a in e){if(!(a in t.shape))throw new Error(`Unrecognized key: "${a}"`);e[a]&&delete o[a]}return br(this,"shape",o),o},checks:[]});return xn(n,s)}function t1(n,e){if(!hi(e))throw new Error("Invalid input to extend: expected a plain object");const t=n._zod.def.checks;if(t&&t.length>0){const s=n._zod.def.shape;for(const o in e)if(Object.getOwnPropertyDescriptor(s,o)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const i=En(n._zod.def,{get shape(){const s={...n._zod.def.shape,...e};return br(this,"shape",s),s}});return xn(n,i)}function n1(n,e){if(!hi(e))throw new Error("Invalid input to safeExtend: expected a plain object");const t=En(n._zod.def,{get shape(){const r={...n._zod.def.shape,...e};return br(this,"shape",r),r}});return xn(n,t)}function r1(n,e){const t=En(n._zod.def,{get shape(){const r={...n._zod.def.shape,...e._zod.def.shape};return br(this,"shape",r),r},get catchall(){return e._zod.def.catchall},checks:[]});return xn(n,t)}function i1(n,e,t){const i=e._zod.def.checks;if(i&&i.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const o=En(e._zod.def,{get shape(){const a=e._zod.def.shape,c={...a};if(t)for(const u in t){if(!(u in a))throw new Error(`Unrecognized key: "${u}"`);t[u]&&(c[u]=n?new n({type:"optional",innerType:a[u]}):a[u])}else for(const u in a)c[u]=n?new n({type:"optional",innerType:a[u]}):a[u];return br(this,"shape",c),c},checks:[]});return xn(e,o)}function s1(n,e,t){const r=En(e._zod.def,{get shape(){const i=e._zod.def.shape,s={...i};if(t)for(const o in t){if(!(o in s))throw new Error(`Unrecognized key: "${o}"`);t[o]&&(s[o]=new n({type:"nonoptional",innerType:i[o]}))}else for(const o in i)s[o]=new n({type:"nonoptional",innerType:i[o]});return br(this,"shape",s),s}});return xn(e,r)}function Zr(n,e=0){var t;if(n.aborted===!0)return!0;for(let r=e;r<n.issues.length;r++)if(((t=n.issues[r])==null?void 0:t.continue)!==!0)return!0;return!1}function Hr(n,e){return e.map(t=>{var r;return(r=t).path??(r.path=[]),t.path.unshift(n),t})}function $o(n){return typeof n=="string"?n:n==null?void 0:n.message}function yn(n,e,t){var i,s,o,a,c,u;const r={...n,path:n.path??[]};if(!n.message){const h=$o((o=(s=(i=n.inst)==null?void 0:i._zod.def)==null?void 0:s.error)==null?void 0:o.call(s,n))??$o((a=e==null?void 0:e.error)==null?void 0:a.call(e,n))??$o((c=t.customError)==null?void 0:c.call(t,n))??$o((u=t.localeError)==null?void 0:u.call(t,n))??"Invalid input";r.message=h}return delete r.inst,delete r.continue,e!=null&&e.reportInput||delete r.input,r}function Qu(n){return Array.isArray(n)?"array":typeof n=="string"?"string":"unknown"}function ss(...n){const[e,t,r]=n;return typeof e=="string"?{message:e,code:"custom",input:t,inst:r}:{...e}}const wm=(n,e)=>{n.name="$ZodError",Object.defineProperty(n,"_zod",{value:n._zod,enumerable:!1}),Object.defineProperty(n,"issues",{value:e,enumerable:!1}),n.message=JSON.stringify(e,Rc,2),Object.defineProperty(n,"toString",{value:()=>n.message,enumerable:!1})},Sm=A("$ZodError",wm),_m=A("$ZodError",wm,{Parent:Error});function o1(n,e=t=>t.message){const t={},r=[];for(const i of n.issues)i.path.length>0?(t[i.path[0]]=t[i.path[0]]||[],t[i.path[0]].push(e(i))):r.push(e(i));return{formErrors:r,fieldErrors:t}}function a1(n,e=t=>t.message){const t={_errors:[]},r=i=>{for(const s of i.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(o=>r({issues:o}));else if(s.code==="invalid_key")r({issues:s.issues});else if(s.code==="invalid_element")r({issues:s.issues});else if(s.path.length===0)t._errors.push(e(s));else{let o=t,a=0;for(;a<s.path.length;){const c=s.path[a];a===s.path.length-1?(o[c]=o[c]||{_errors:[]},o[c]._errors.push(e(s))):o[c]=o[c]||{_errors:[]},o=o[c],a++}}};return r(n),t}const eh=n=>(e,t,r,i)=>{const s=r?Object.assign(r,{async:!1}):{async:!1},o=e._zod.run({value:t,issues:[]},s);if(o instanceof Promise)throw new Br;if(o.issues.length){const a=new((i==null?void 0:i.Err)??n)(o.issues.map(c=>yn(c,s,vn())));throw ym(a,i==null?void 0:i.callee),a}return o.value},th=n=>async(e,t,r,i)=>{const s=r?Object.assign(r,{async:!0}):{async:!0};let o=e._zod.run({value:t,issues:[]},s);if(o instanceof Promise&&(o=await o),o.issues.length){const a=new((i==null?void 0:i.Err)??n)(o.issues.map(c=>yn(c,s,vn())));throw ym(a,i==null?void 0:i.callee),a}return o.value},Xa=n=>(e,t,r)=>{const i=r?{...r,async:!1}:{async:!1},s=e._zod.run({value:t,issues:[]},i);if(s instanceof Promise)throw new Br;return s.issues.length?{success:!1,error:new(n??Sm)(s.issues.map(o=>yn(o,i,vn())))}:{success:!0,data:s.value}},l1=Xa(_m),Ka=n=>async(e,t,r)=>{const i=r?Object.assign(r,{async:!0}):{async:!0};let s=e._zod.run({value:t,issues:[]},i);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new n(s.issues.map(o=>yn(o,i,vn())))}:{success:!0,data:s.value}},c1=Ka(_m),u1=n=>(e,t,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return eh(n)(e,t,i)},h1=n=>(e,t,r)=>eh(n)(e,t,r),d1=n=>async(e,t,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return th(n)(e,t,i)},p1=n=>async(e,t,r)=>th(n)(e,t,r),f1=n=>(e,t,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Xa(n)(e,t,i)},g1=n=>(e,t,r)=>Xa(n)(e,t,r),m1=n=>async(e,t,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Ka(n)(e,t,i)},v1=n=>async(e,t,r)=>Ka(n)(e,t,r),y1=/^[cC][^\s-]{8,}$/,b1=/^[0-9a-z]+$/,w1=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,S1=/^[0-9a-vA-V]{20}$/,_1=/^[A-Za-z0-9]{27}$/,k1=/^[a-zA-Z0-9_-]{21}$/,E1=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,x1=/^([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})$/,Ip=n=>n?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${n}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,A1=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,$1="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function T1(){return new RegExp($1,"u")}const I1=/^(?:(?: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])$/,C1=/^(([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}|:))$/,P1=/^((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])$/,R1=/^(([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])$/,D1=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,km=/^[A-Za-z0-9_-]*$/,L1=/^\+[1-9]\d{6,14}$/,Em="(?:(?:\\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])))",O1=new RegExp(`^${Em}$`);function xm(n){const e="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof n.precision=="number"?n.precision===-1?`${e}`:n.precision===0?`${e}:[0-5]\\d`:`${e}:[0-5]\\d\\.\\d{${n.precision}}`:`${e}(?::[0-5]\\d(?:\\.\\d+)?)?`}function M1(n){return new RegExp(`^${xm(n)}$`)}function z1(n){const e=xm({precision:n.precision}),t=["Z"];n.local&&t.push(""),n.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${e}(?:${t.join("|")})`;return new RegExp(`^${Em}T(?:${r})$`)}const N1=n=>{const e=n?`[\\s\\S]{${(n==null?void 0:n.minimum)??0},${(n==null?void 0:n.maximum)??""}}`:"[\\s\\S]*";return new RegExp(`^${e}$`)},U1=/^-?\d+$/,Am=/^-?\d+(?:\.\d+)?$/,F1=/^(?:true|false)$/i,Z1=/^[^A-Z]*$/,H1=/^[^a-z]*$/,Ye=A("$ZodCheck",(n,e)=>{var t;n._zod??(n._zod={}),n._zod.def=e,(t=n._zod).onattach??(t.onattach=[])}),$m={number:"number",bigint:"bigint",object:"date"},Tm=A("$ZodCheckLessThan",(n,e)=>{Ye.init(n,e);const t=$m[typeof e.value];n._zod.onattach.push(r=>{const i=r._zod.bag,s=(e.inclusive?i.maximum:i.exclusiveMaximum)??Number.POSITIVE_INFINITY;e.value<s&&(e.inclusive?i.maximum=e.value:i.exclusiveMaximum=e.value)}),n._zod.check=r=>{(e.inclusive?r.value<=e.value:r.value<e.value)||r.issues.push({origin:t,code:"too_big",maximum:typeof e.value=="object"?e.value.getTime():e.value,input:r.value,inclusive:e.inclusive,inst:n,continue:!e.abort})}}),Im=A("$ZodCheckGreaterThan",(n,e)=>{Ye.init(n,e);const t=$m[typeof e.value];n._zod.onattach.push(r=>{const i=r._zod.bag,s=(e.inclusive?i.minimum:i.exclusiveMinimum)??Number.NEGATIVE_INFINITY;e.value>s&&(e.inclusive?i.minimum=e.value:i.exclusiveMinimum=e.value)}),n._zod.check=r=>{(e.inclusive?r.value>=e.value:r.value>e.value)||r.issues.push({origin:t,code:"too_small",minimum:typeof e.value=="object"?e.value.getTime():e.value,input:r.value,inclusive:e.inclusive,inst:n,continue:!e.abort})}}),W1=A("$ZodCheckMultipleOf",(n,e)=>{Ye.init(n,e),n._zod.onattach.push(t=>{var r;(r=t._zod.bag).multipleOf??(r.multipleOf=e.value)}),n._zod.check=t=>{if(typeof t.value!=typeof e.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof t.value=="bigint"?t.value%e.value===BigInt(0):jx(t.value,e.value)===0)||t.issues.push({origin:typeof t.value,code:"not_multiple_of",divisor:e.value,input:t.value,inst:n,continue:!e.abort})}}),B1=A("$ZodCheckNumberFormat",(n,e)=>{var o;Ye.init(n,e),e.format=e.format||"float64";const t=(o=e.format)==null?void 0:o.includes("int"),r=t?"int":"number",[i,s]=Jx[e.format];n._zod.onattach.push(a=>{const c=a._zod.bag;c.format=e.format,c.minimum=i,c.maximum=s,t&&(c.pattern=U1)}),n._zod.check=a=>{const c=a.value;if(t){if(!Number.isInteger(c)){a.issues.push({expected:r,format:e.format,code:"invalid_type",continue:!1,input:c,inst:n});return}if(!Number.isSafeInteger(c)){c>0?a.issues.push({input:c,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:n,origin:r,inclusive:!0,continue:!e.abort}):a.issues.push({input:c,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:n,origin:r,inclusive:!0,continue:!e.abort});return}}c<i&&a.issues.push({origin:"number",input:c,code:"too_small",minimum:i,inclusive:!0,inst:n,continue:!e.abort}),c>s&&a.issues.push({origin:"number",input:c,code:"too_big",maximum:s,inclusive:!0,inst:n,continue:!e.abort})}}),V1=A("$ZodCheckMaxLength",(n,e)=>{var t;Ye.init(n,e),(t=n._zod.def).when??(t.when=r=>{const i=r.value;return!Ku(i)&&i.length!==void 0}),n._zod.onattach.push(r=>{const i=r._zod.bag.maximum??Number.POSITIVE_INFINITY;e.maximum<i&&(r._zod.bag.maximum=e.maximum)}),n._zod.check=r=>{const i=r.value;if(i.length<=e.maximum)return;const o=Qu(i);r.issues.push({origin:o,code:"too_big",maximum:e.maximum,inclusive:!0,input:i,inst:n,continue:!e.abort})}}),G1=A("$ZodCheckMinLength",(n,e)=>{var t;Ye.init(n,e),(t=n._zod.def).when??(t.when=r=>{const i=r.value;return!Ku(i)&&i.length!==void 0}),n._zod.onattach.push(r=>{const i=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;e.minimum>i&&(r._zod.bag.minimum=e.minimum)}),n._zod.check=r=>{const i=r.value;if(i.length>=e.minimum)return;const o=Qu(i);r.issues.push({origin:o,code:"too_small",minimum:e.minimum,inclusive:!0,input:i,inst:n,continue:!e.abort})}}),j1=A("$ZodCheckLengthEquals",(n,e)=>{var t;Ye.init(n,e),(t=n._zod.def).when??(t.when=r=>{const i=r.value;return!Ku(i)&&i.length!==void 0}),n._zod.onattach.push(r=>{const i=r._zod.bag;i.minimum=e.length,i.maximum=e.length,i.length=e.length}),n._zod.check=r=>{const i=r.value,s=i.length;if(s===e.length)return;const o=Qu(i),a=s>e.length;r.issues.push({origin:o,...a?{code:"too_big",maximum:e.length}:{code:"too_small",minimum:e.length},inclusive:!0,exact:!0,input:r.value,inst:n,continue:!e.abort})}}),Ja=A("$ZodCheckStringFormat",(n,e)=>{var t,r;Ye.init(n,e),n._zod.onattach.push(i=>{const s=i._zod.bag;s.format=e.format,e.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(e.pattern))}),e.pattern?(t=n._zod).check??(t.check=i=>{e.pattern.lastIndex=0,!e.pattern.test(i.value)&&i.issues.push({origin:"string",code:"invalid_format",format:e.format,input:i.value,...e.pattern?{pattern:e.pattern.toString()}:{},inst:n,continue:!e.abort})}):(r=n._zod).check??(r.check=()=>{})}),q1=A("$ZodCheckRegex",(n,e)=>{Ja.init(n,e),n._zod.check=t=>{e.pattern.lastIndex=0,!e.pattern.test(t.value)&&t.issues.push({origin:"string",code:"invalid_format",format:"regex",input:t.value,pattern:e.pattern.toString(),inst:n,continue:!e.abort})}}),Y1=A("$ZodCheckLowerCase",(n,e)=>{e.pattern??(e.pattern=Z1),Ja.init(n,e)}),X1=A("$ZodCheckUpperCase",(n,e)=>{e.pattern??(e.pattern=H1),Ja.init(n,e)}),K1=A("$ZodCheckIncludes",(n,e)=>{Ye.init(n,e);const t=di(e.includes),r=new RegExp(typeof e.position=="number"?`^.{${e.position}}${t}`:t);e.pattern=r,n._zod.onattach.push(i=>{const s=i._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(r)}),n._zod.check=i=>{i.value.includes(e.includes,e.position)||i.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:e.includes,input:i.value,inst:n,continue:!e.abort})}}),J1=A("$ZodCheckStartsWith",(n,e)=>{Ye.init(n,e);const t=new RegExp(`^${di(e.prefix)}.*`);e.pattern??(e.pattern=t),n._zod.onattach.push(r=>{const i=r._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(t)}),n._zod.check=r=>{r.value.startsWith(e.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:e.prefix,input:r.value,inst:n,continue:!e.abort})}}),Q1=A("$ZodCheckEndsWith",(n,e)=>{Ye.init(n,e);const t=new RegExp(`.*${di(e.suffix)}$`);e.pattern??(e.pattern=t),n._zod.onattach.push(r=>{const i=r._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(t)}),n._zod.check=r=>{r.value.endsWith(e.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:e.suffix,input:r.value,inst:n,continue:!e.abort})}}),eA=A("$ZodCheckOverwrite",(n,e)=>{Ye.init(n,e),n._zod.check=t=>{t.value=e.tx(t.value)}});class tA{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 _o(n,e){var t=$c(n),r=[];if(t){r.length=n.length;for(var i=0;i<n.length;i++)r[i]=Ht(n,i)?e(n[i],n):""}var s=typeof Zl=="function"?Zl(n):[],o;if(ui){o={};for(var a=0;a<s.length;a++)o["$"+s[a]]=s[a]}for(var c in n)Ht(n,c)&&(t&&String(Number(c))===c&&c<n.length||ui&&o["$"+c]instanceof Symbol||(_g.call(/[^\w$]/,c)?r.push(e(c,n)+": "+e(n[c],n)):r.push(c+": "+e(n[c],n))));if(typeof Zl=="function")for(var u=0;u<s.length;u++)kg.call(n,s[u])&&r.push("["+e(s[u])+"]: "+e(n[s[u]],n));return r}var D_=wi,L_=j,Ba=function(n,e,t){for(var r=n,i;(i=r.next)!=null;r=i)if(i.key===e)return r.next=i.next,t||(i.next=n.next,n.next=i),i},O_=function(n,e){if(n){var t=Ba(n,e);return t&&t.value}},M_=function(n,e,t){var r=Ba(n,e);r?r.value=t:n.next={key:e,next:n.next,value:t}},z_=function(n,e){return n?!!Ba(n,e):!1},N_=function(n,e){if(n)return Ba(n,e,!0)},U_=function(){var e,t={assert:function(r){if(!t.has(r))throw new L_("Side channel does not contain "+D_(r))},delete:function(r){var i=e&&e.next,s=N_(e,r);return s&&i&&i===s&&(e=void 0),!!s},get:function(r){return O_(e,r)},has:function(r){return z_(e,r)},set:function(r,i){e||(e={next:void 0}),M_(e,r,i)}};return t},F_=ct,no=_n,Z_=wi,H_=j,qd=F_("%Map%",!0),W_=no("Map.prototype.get",!0),G_=no("Map.prototype.set",!0),V_=no("Map.prototype.has",!0),B_=no("Map.prototype.delete",!0),j_=no("Map.prototype.size",!0),Ig=!!qd&&function(){var e,t={assert:function(r){if(!t.has(r))throw new H_("Side channel does not contain "+Z_(r))},delete:function(r){if(e){var i=B_(e,r);return j_(e)===0&&(e=void 0),i}return!1},get:function(r){if(e)return W_(e,r)},has:function(r){return e?V_(e,r):!1},set:function(r,i){e||(e=new qd),G_(e,r,i)}};return t},q_=ct,ja=_n,Y_=wi,ko=Ig,X_=j,Ir=q_("%WeakMap%",!0),K_=ja("WeakMap.prototype.get",!0),J_=ja("WeakMap.prototype.set",!0),Q_=ja("WeakMap.prototype.has",!0),ek=ja("WeakMap.prototype.delete",!0),tk=Ir?function(){var e,t,r={assert:function(i){if(!r.has(i))throw new X_("Side channel does not contain "+Y_(i))},delete:function(i){if(Ir&&i&&(typeof i=="object"||typeof i=="function")){if(e)return ek(e,i)}else if(ko&&t)return t.delete(i);return!1},get:function(i){return Ir&&i&&(typeof i=="object"||typeof i=="function")&&e?K_(e,i):t&&t.get(i)},has:function(i){return Ir&&i&&(typeof i=="object"||typeof i=="function")&&e?Q_(e,i):!!t&&t.has(i)},set:function(i,s){Ir&&i&&(typeof i=="object"||typeof i=="function")?(e||(e=new Ir),J_(e,i,s)):ko&&(t||(t=ko()),t.set(i,s))}};return r}:ko,nk=j,rk=wi,ik=U_,sk=Ig,ok=tk,ak=ok||sk||ik,lk=function(){var e,t={assert:function(r){if(!t.has(r))throw new nk("Side channel does not contain "+rk(r))},delete:function(r){return!!e&&e.delete(r)},get:function(r){return e&&e.get(r)},has:function(r){return!!e&&e.has(r)},set:function(r,i){e||(e=ak()),e.set(r,i)}};return t},ck=tn,Li=lk(),Ut=j,Uu={assert:function(n,e){if(!n||typeof n!="object"&&typeof n!="function")throw new Ut("`O` is not an object");if(typeof e!="string")throw new Ut("`slot` must be a string");if(Li.assert(n),!Uu.has(n,e))throw new Ut("`"+e+"` is not present on `O`")},get:function(n,e){if(!n||typeof n!="object"&&typeof n!="function")throw new Ut("`O` is not an object");if(typeof e!="string")throw new Ut("`slot` must be a string");var t=Li.get(n);return t&&t["$"+e]},has:function(n,e){if(!n||typeof n!="object"&&typeof n!="function")throw new Ut("`O` is not an object");if(typeof e!="string")throw new Ut("`slot` must be a string");var t=Li.get(n);return!!t&&ck(t,"$"+e)},set:function(n,e,t){if(!n||typeof n!="object"&&typeof n!="function")throw new Ut("`O` is not an object");if(typeof e!="string")throw new Ut("`slot` must be a string");var r=Li.get(n);r||(r={},Li.set(n,r)),r["$"+e]=t}};Object.freeze&&Object.freeze(Uu);var Fu=Uu,Cg=Qt,gn=Fu,ro=function n(e,t){if(!(this instanceof n))return new n(e,t);if(e!=="normal"&&e!=="break"&&e!=="continue"&&e!=="return"&&e!=="throw")throw new Cg('Assertion failed: `type` must be one of "normal", "break", "continue", "return", or "throw"');gn.set(this,"[[Type]]",e),gn.set(this,"[[Value]]",t)};ro.prototype.type=function(){return gn.get(this,"[[Type]]")};ro.prototype.value=function(){return gn.get(this,"[[Value]]")};ro.prototype["?"]=function(){var e=gn.get(this,"[[Type]]"),t=gn.get(this,"[[Value]]");if(e==="throw")throw t;return t};ro.prototype["!"]=function(){var e=gn.get(this,"[[Type]]");if(e!=="normal")throw new Cg('Assertion failed: Completion Record is not of type "normal"');return gn.get(this,"[[Value]]")};var Zu=ro,uk=Zu,Hu=function(e){return new uk("normal",e)},Wl,Yd;function hk(){if(Yd)return Wl;Yd=1;var n=mi;return Wl=function(){return n()&&!!Symbol.toStringTag},Wl}var dk=ct,Xd=dk("%Object.defineProperty%",!0),pk=hk()(),fk=tn,gk=j,Eo=pk?Symbol.toStringTag:null,Pg=function(e,t){var r=arguments.length>2&&!!arguments[2]&&arguments[2].force,i=arguments.length>2&&!!arguments[2]&&arguments[2].nonConfigurable;if(typeof r<"u"&&typeof r!="boolean"||typeof i<"u"&&typeof i!="boolean")throw new gk("if provided, the `overrideIfSet` and `nonConfigurable` options must be booleans");Eo&&(r||!fk(e,Eo))&&(Xd?Xd(e,Eo,{configurable:!i,enumerable:!1,value:t,writable:!1}):e[Eo]=t)},Rg={exports:{}},mk=ct,Kd=Yf,vk=Wa(),Jd=gi,Qd=j,yk=mk("%Math.floor%"),bk=function(e,t){if(typeof e!="function")throw new Qd("`fn` is not a function");if(typeof t!="number"||t<0||t>4294967295||yk(t)!==t)throw new Qd("`length` must be a positive 32-bit integer");var r=arguments.length>2&&!!arguments[2],i=!0,s=!0;if("length"in e&&Jd){var o=Jd(e,"length");o&&!o.configurable&&(i=!1),o&&!o.writable&&(s=!1)}return(i||s||!r)&&(vk?Kd(e,"length",t,!0,!0):Kd(e,"length",t)),e},wk=Ks,Sk=Iu(),_k=og,kk=function(){return _k(wk,Sk,arguments)};(function(n){var e=bk,t=Xs,r=Ga,i=kk;n.exports=function(o){var a=r(arguments),c=1+o.length-(arguments.length-1);return e(a,c>0?c:0,!0)},t?t(n.exports,"apply",{value:i}):n.exports.apply=i})(Rg);var Wu=Rg.exports,Ek=function(e,t){for(var r=0;r<e.length;r+=1)if(!t(e[r],r,e))return!1;return!0},xk=Object,Ak=function(e){return e&&typeof e=="object"&&(typeof e["[[ResourceValue]]"]>"u"||xk(e["[[ResourceValue]]"])===e["[[ResourceValue]]"])&&(e["[[Hint]]"]==="SYNC-DISPOSE"||e["[[Hint]]"]==="ASYNC-DISPOSE")&&(typeof e["[[DisposeMethod]]"]=="function"||typeof e["[[DisposeMethod]]"]>"u")},$k=tn,Tk=Cu(),Ik=Ek,Ck=Ak,Pk=function(e){return e&&typeof e=="object"&&$k(e,"[[DisposableResourceStack]]")&&Tk(e["[[DisposableResourceStack]]"])&&(e["[[DisposableResourceStack]]"].length===0||Ik(e["[[DisposableResourceStack]]"],Ck))},Rk=en,Dk=function(e){if(e===null)return"Null";if(typeof e>"u")return"Undefined";if(Rk(e))return"Object";if(typeof e=="number")return"Number";if(typeof e=="boolean")return"Boolean";if(typeof e=="string")return"String"},Lk=Dk,Gu=function(e){return typeof e=="symbol"?"Symbol":typeof e=="bigint"?"BigInt":Lk(e)},Ok=j,Mk=wi,zk=yi,Nk=function(e,t){if(!zk(t))throw new Ok("Assertion failed: P is not a Property Key, got "+Mk(t));return e[t]},ep=j,Uk=Nk,Fk=bi,Zk=yi,tp=wi,Hk=function(e,t){if(!Zk(t))throw new ep("Assertion failed: P is not a Property Key");var r=Uk(e,t);if(r!=null){if(!Fk(r))throw new ep(tp(t)+" is not a function: "+tp(r));return r}},Ic={exports:{}},Wk=ct,Gk=Wk,np=Gk("%Reflect.construct%",!0),la=to;try{la({},"",{"[[Get]]":function(){}})}catch{la=null}if(la&&np){var rp={},ip={};la(ip,"length",{"[[Get]]":function(){throw rp},"[[Enumerable]]":!0}),Ic.exports=function(e){try{np(e,ip)}catch(t){return t===rp}}}else Ic.exports=function(e){return typeof e=="function"&&!!e.prototype};var Vk=Ic.exports,Gl=j,sp=bi,Bk=Vk,jk=function(e){if(!Bk(e))throw new Gl("C must be a constructor");var t={"[[Resolve]]":void 0,"[[Reject]]":void 0},r=new e(function(i,s){if(typeof t["[[Resolve]]"]<"u"||typeof t["[[Reject]]"]<"u")throw new Gl("executor has already been called");t["[[Resolve]]"]=i,t["[[Reject]]"]=s});if(!sp(t["[[Resolve]]"])||!sp(t["[[Reject]]"]))throw new Gl("executor must provide valid resolve and reject functions");return{"[[Promise]]":r,"[[Resolve]]":t["[[Resolve]]"],"[[Reject]]":t["[[Reject]]"]}},op=Qt,qk=j,Vl=Va,ap=Hk,Yk=jk,Xk=Gu,lp=Lu(),cp=Ou(),Kk=function(e,t){if(Xk(e)!=="Object")throw new qk("`V` must be an Object");if(t!=="SYNC-DISPOSE"&&t!=="ASYNC-DISPOSE")throw new op("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");var r;if(t==="ASYNC-DISPOSE"&&cp&&(r=ap(e,cp)),!r){if(!lp)throw new op("`Symbol.dispose` is not supported");if(r=ap(e,lp),typeof r<"u")return function(){var i=this;if(t==="ASYNC-DISPOSE"){var s=Yk(Promise);try{Vl(r,i),Vl(s["[[Resolve]]"],void 0,[void 0])}catch(o){s["[[Reject]]"](o)}return s["[[Promise]]"]}Vl(r,i)}}return r},Jk=Qt,Bl=j,Qk=bi,eE=Gu,tE=Kk,nE=function(e,t){if(t!=="SYNC-DISPOSE"&&t!=="ASYNC-DISPOSE")throw new Jk("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"&&eE(e)!=="Object")throw new Bl("`V` must be an Object, or `null` or `undefined`");if(r=tE(e,t),typeof r>"u")throw new Bl("dispose method must not be `undefined` on `V` when an object `V` is provided")}else if(r=arguments[2],!Qk(r))throw new Bl("`method`, when provided, must be a function");return{"[[ResourceValue]]":e,"[[Hint]]":t,"[[DisposeMethod]]":r}},rE=Qt,xo=j,iE=Pk,up=nE,sE=_n,oE=sE("Array.prototype.push"),Dg=function(e,t,r){if(!iE(e))throw new xo("Assertion failed: `disposeCapability` must be a DisposeCapability Record");if(r!=="SYNC-DISPOSE"&&r!=="ASYNC-DISPOSE")throw new rE("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");var i=arguments.length>3?arguments[3]:void 0;if(arguments.length>3&&typeof i!="function")throw new xo("Assertion failed: `method`, when present, must be a function");if(!e["[[DisposableResourceStack]]"])throw new xo("Assertion failed: `disposeCapability.[[DisposableResourceStack]]` must not be ~EMPTY~");var s;if(arguments.length<4){if(t==null&&r==="SYNC_DISPOSE")return"UNUSED";s=up(t,r)}else{if(typeof t<"u")throw new xo("Assertion failed: `V` must be undefined when `method` is present");s=up(void 0,r,i)}return oE(e["[[DisposableResourceStack]]"],s),"UNUSED"},jl,hp;function Vu(){if(hp)return jl;hp=1;var n=ct,e=Wu,t=Qt,r=n("%Promise.resolve%",!0),i=r&&e(r);return jl=function(o,a){if(!i)throw new t("This environment does not support Promises.");return i(o,a)},jl}var ql,dp;function aE(){if(dp)return ql;dp=1;var n=ct,e=Qt,t=n("%Promise%",!0),r=Va,i=Vu(),s=Gu;return ql=function(a,c,u){if(typeof a<"u"&&s(a)!=="Object")throw new e("Assertion failed: `V` must be `undefined` or an Object");if(c!=="SYNC-DISPOSE"&&c!=="ASYNC-DISPOSE")throw new e("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");if(typeof u<"u"&&typeof u!="function")throw new e("Assertion failed: `method` must be `undefined` or a function");var h=typeof u>"u"?u:r(u,a);if(c==="ASYNC-DISPOSE")return i(t,h)},ql}var Yl,pp;function lE(){if(pp)return Yl;pp=1;var n=Zu;return Yl=function(t){return new n("throw",t)},Yl}var cE=ct,Xl=Qt,fp=j,uE=cE("%Promise%",!0),hE=_n,gp=hE("Promise.prototype.then",!0),dE=Zu,mp=aE(),pE=Hu,fE=Vu(),vp=lE(),gE=Sg(),Lg=function(e,t){if(!(t instanceof dE))throw new fp("`completion` must be a Completion Record");var r=e["[[DisposableResourceStack]]"];if(!r)throw new fp("Assertion failed: `disposeCapability.[[DisposableResourceStack]]` must not be ~EMPTY~");for(var i,s=r.length-1;s>=0;s-=1)if(!i)i=r[s]["[[Hint]]"];else if(i!==r[s]["[[Hint]]"])throw new Xl("mixed hint stacks are not supported");for(var o=i==="ASYNC-DISPOSE"&&fE(uE,t),a=function(v){if(t.type()==="throw"){var g=t.value(),E=new gE(v,g);t=vp(E)}else t=vp(v)},c=i==="ASYNC-DISPOSE"&&function(g){return gp(o,function(){var E=mp(g["[[ResourceValue]]"],g["[[Hint]]"],g["[[DisposeMethod]]"]);if(!E)throw new Xl("Assertion failed: non-`~ASYNC-DISPOSE~` resource returned a promise from Dispose");return gp(E,pE)},a)},u=r.length-1;u>=0;u-=1)if(i==="ASYNC-DISPOSE")o=c(r[u]);else{var h=r[u];try{var p=mp(h["[[ResourceValue]]"],h["[[Hint]]"],h["[[DisposeMethod]]"]);if(p)throw new Xl("Assertion failed: `~SYNC-DISPOSE~` resource returned something from Dispose")}catch(v){a(v)}}return e["[[DisposableResourceStack]]"]=null,i==="ASYNC-DISPOSE"?o:t},Og=function(){var e=[];return{"[[DisposableResourceStack]]":e}},qa=xu,Bu=j,mE=Va,Si=Ru,vE=to,Mg=bi,yE=Hu,Be=Fu,bE=Pg,zg=vr.supportsDescriptors,wE=Wu,ju=Dg,SE=Lg,Ng=Og,yp=Lu(),ot=function n(){if(!(this instanceof n)||Be.has(this,"[[DisposableState]]")||Be.has(this,"[[DisposeCapability]]"))throw new Bu("can only be used with new");Be.set(this,"[[DisposableState]]","PENDING"),Be.set(this,"[[DisposeCapability]]",Ng())},Ug=function(){var e=this;return Be.assert(e,"[[DisposableState]]"),Be.get(e,"[[DisposableState]]")==="DISPOSED"},io=wE(Ug);zg?vE(ot.prototype,"disposed",{"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Get]]":Ug}):ot.prototype.disposed=!1;var Fg=function(e){Be.set(e,"[[DisposableState]]","DISPOSED"),zg||(e.disposed=!0)};Si(ot.prototype,"dispose",function(){var e=this;if(!io(e))return Fg(e),SE(Be.get(e,"[[DisposeCapability]]"),yE())["?"]()});Si(ot.prototype,"use",function(e){var t=this;if(io(t))throw new qa("a disposed stack can not use anything new");return ju(Be.get(t,"[[DisposeCapability]]"),e,"SYNC-DISPOSE"),e});Si(ot.prototype,"adopt",function(e,t){var r=this;if(io(r))throw new qa("a disposed stack can not use anything new");if(!Mg(t))throw new Bu("`onDispose` must be a function");var i=function(){return mE(t,void 0,[e])};return ju(Be.get(r,"[[DisposeCapability]]"),void 0,"SYNC-DISPOSE",i),e});Si(ot.prototype,"defer",function(e){var t=this;if(io(t))throw new qa("a disposed stack can not defer anything new");if(!Mg(e))throw new Bu("`onDispose` must be a function");ju(Be.get(t,"[[DisposeCapability]]"),void 0,"SYNC-DISPOSE",e)});Si(ot.prototype,"move",function(){var e=this;if(io(e))throw new qa("a disposed stack can not use anything new");var t=new ot;return Be.set(t,"[[DisposeCapability]]",Be.get(e,"[[DisposeCapability]]")),Be.set(e,"[[DisposeCapability]]",Ng()),Fg(e),t});yp&&Si(ot.prototype,yp,ot.prototype.dispose);bE(ot.prototype,"DisposableStack");var _E=ot,kE=_E,EE=function(){return typeof DisposableStack=="function"?DisposableStack:kE},xE=vr,AE=ku(),$E=EE,TE=function(){var e=$E();return xE(AE,{DisposableStack:e},{DisposableStack:!0}),e},IE=ct,Ya=xu,qu=j,bp=IE("%Promise%",!0),Yu=Dg,CE=Va,_i=Ru,PE=to,RE=Lg,Zg=bi,Hg=Og,DE=Hu,wp=Vu(),je=Fu,LE=Pg,Wg=vr.supportsDescriptors,OE=Wu,ME=_n,zE=ME("Promise.prototype.then",!0),Sp=Ou(),at=function n(){if(!(this instanceof n)||je.has(this,"[[AsyncDisposableState]]")||je.has(this,"[[DisposeCapability]]"))throw new qu("can only be used with new");je.set(this,"[[AsyncDisposableState]]","pending"),je.set(this,"[[DisposeCapability]]",Hg())},Gg=function(){var e=this;return je.assert(e,"[[AsyncDisposableState]]"),je.get(e,"[[AsyncDisposableState]]")==="disposed"},so=OE(Gg);Wg?PE(at.prototype,"disposed",{"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Get]]":Gg}):at.prototype.disposed=!1;var Vg=function(e){je.set(e,"[[AsyncDisposableState]]","disposed"),Wg||(e.disposed=!0)};_i(at.prototype,"disposeAsync",function(){var e=this;return so(e)?wp(bp):(Vg(e),zE(wp(bp,RE(je.get(e,"[[DisposeCapability]]"),DE())),function(t){return t["?"]()}))});_i(at.prototype,"use",function(e){var t=this;if(so(t))throw new Ya("a disposed stack can not use anything new");return Yu(je.get(t,"[[DisposeCapability]]"),e,"ASYNC-DISPOSE"),e});_i(at.prototype,"adopt",function(e,t){var r=this;if(so(r))throw new Ya("a disposed stack can not use anything new");if(!Zg(t))throw new qu("`onDisposeAsync` must be a function");var i=function(){return CE(t,void 0,[e])};return i.value=e,Yu(je.get(r,"[[DisposeCapability]]"),void 0,"ASYNC-DISPOSE",i),e});_i(at.prototype,"defer",function(e){var t=this;if(so(t))throw new Ya("a disposed stack can not defer anything new");if(!Zg(e))throw new qu("`onDispose` must be a function");Yu(je.get(t,"[[DisposeCapability]]"),void 0,"ASYNC-DISPOSE",e)});_i(at.prototype,"move",function(){var e=this;if(so(e))throw new Ya("a disposed stack can not use anything new");var t=new at;return je.set(t,"[[DisposeCapability]]",je.get(e,"[[DisposeCapability]]")),je.set(e,"[[DisposeCapability]]",Hg()),Vg(e),t});Sp&&_i(at.prototype,Sp,at.prototype.disposeAsync);LE(at.prototype,"AsyncDisposableStack");var NE=at,UE=NE,FE=function(){return typeof AsyncDisposableStack=="function"?AsyncDisposableStack:UE},ZE=vr,HE=ku(),WE=FE,GE=function(){var e=WE();return ZE(HE,{AsyncDisposableStack:e},{AsyncDisposableStack:!0}),e},VE=ZS,BE=YS,jE=TE,qE=GE,YE=function(){VE(),BE(),jE(),qE()};YE();const _p=new WeakMap;function XE(n){return(typeof n=="object"||typeof n=="function")&&n!==null&&"then"in n&&typeof n.then=="function"}function Cr(n){return typeof n=="string"?n:typeof n=="symbol"?n.description??n.toString():n.name||"(anonymous class)"}function kp(){return new Error("register(Key, factory) requires a factory function. Wrap existing instances as () => instance.")}function KE(){return new Error("register(Key, factory) does not accept async factories. Await setup before registering.")}class JE{constructor(){b(this,"entries",new Map);b(this,"constructionStack",[])}register(e,t){if(t===void 0){if(typeof e!="function")throw kp();this.validateClassRegistration(e),this.storeFactory(e,()=>this.instantiateClass(e));return}if(typeof t!="function")throw kp();if(t.constructor.name==="AsyncFunction")throw KE();this.storeFactory(e,t)}has(e){var t;return((t=this.entries.get(e))==null?void 0:t.factory)!==void 0}resolve(e){return this.resolveAny(e)}storeFactory(e,t){const r=this.getOrCreateEntry(e);r.factory=t,r.instance=void 0,r.error=void 0}validateClassRegistration(e){const t=_p.get(e);if(t){if(e.length!==t.length)throw new Error(`${Cr(e)} cannot be registered with register(Class). @injectable(...) declared ${t.length} dependencies but constructor arity is ${e.length}. Use register(Key, () => value) instead.`);return}if(e.length!==0)throw new Error(`${Cr(e)} cannot be registered with register(Class). Undecorated classes must have zero required constructor parameters. Use register(Key, () => value) instead.`)}instantiateClass(e){const t=_p.get(e);if(!t)return new e;const r=t.map(i=>this.resolveAny(i));return new e(...r)}resolveAny(e){return this.getOrCreateEntry(e).proxy}getOrCreateEntry(e){let t=this.entries.get(e);return t||(t={key:e},t.proxy=this.createProxy(t),this.entries.set(e,t),t)}createProxy(e){return new Proxy({},{get:(t,r)=>{if(r==="then")return;const i=this.getInstance(e),s=Reflect.get(i,r,i);return typeof s=="function"?s.bind(i):s},set:(t,r,i)=>{const s=this.getInstance(e);return Reflect.set(s,r,i,s)},has:(t,r)=>{const i=this.getInstance(e);return r in i}})}getInstance(e){if(e.instance)return e.instance;if(e.error)throw e.error;if(!e.factory)throw new Error(`${Cr(e.key)} was resolved but never registered`);const t=this.constructionStack.indexOf(e.key);if(t!==-1){const r=[...this.constructionStack.slice(t),e.key].map(i=>Cr(i)).join(" -> ");throw new Error(`Circular dependency detected: ${r}`)}this.constructionStack.push(e.key);try{const r=e.factory();if(XE(r))throw new Error(`Factory for ${Cr(e.key)} returned a Promise. Await setup before registering.`);if(typeof r!="object"||r===null)throw new Error(`Factory for ${Cr(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 qe=new JE,QE=new Set(["target","currentTarget","eventPhase","defaultPrevented","isTrusted","timeStamp","srcElement","returnValue","cancelBubble","NONE","CAPTURING_PHASE","AT_TARGET","BUBBLING_PHASE","composedPath","stopPropagation","stopImmediatePropagation","preventDefault","initEvent"]);function ex(n){for(const e of Object.keys(n))if(QE.has(e))throw new Error(`Event payload key "${e}" is reserved; choose a different property name`)}function tx(n,e){ex(e);for(const t of Object.keys(e))Object.defineProperty(n,t,{value:e[t],writable:!0,enumerable:!0,configurable:!0})}function tt(){class n extends Event{constructor(t,r){const{type:i,bubbles:s,cancelable:o,composed:a,...c}=r??{};if(i!==void 0)throw new Error('Do not pass "type" in init; use the constructor argument instead');super(t,{bubbles:s,cancelable:o,composed:a}),tx(this,c)}}return n}class wt extends globalThis.EventTarget{}function nx(n,e,t){const r=n.dispose.bind(n);n.dispose=()=>{if(!e())return t(),r()}}function ki(n){var t;class e extends n{constructor(...s){super(...s);w(this,t,!1);nx(this,()=>l(this,t),()=>{x(this,t,!0)})}[Symbol.dispose](){this.dispose()}get disposed(){return l(this,t)}}return t=new WeakMap,e}const rx=tt(),ix=tt(),jo=tt(),Bg="0123456789ABCDEFGHJKMNPQRSTVWXYZ",ca=32,sx=16,jg=10,Ep=0xffffffffffff;var Un;(function(n){n.Base32IncorrectEncoding="B32_ENC_INVALID",n.DecodeTimeInvalidCharacter="DEC_TIME_CHAR",n.DecodeTimeValueMalformed="DEC_TIME_MALFORMED",n.EncodeTimeNegative="ENC_TIME_NEG",n.EncodeTimeSizeExceeded="ENC_TIME_SIZE_EXCEED",n.EncodeTimeValueMalformed="ENC_TIME_MALFORMED",n.PRNGDetectFailure="PRNG_DETECT",n.ULIDInvalid="ULID_INVALID",n.Unexpected="UNEXPECTED",n.UUIDInvalid="UUID_INVALID"})(Un||(Un={}));class Wi extends Error{constructor(e,t){super(`${t} (${e})`),this.name="ULIDError",this.code=e}}function ox(n){const e=Math.floor(n()*ca)%ca;return Bg.charAt(e)}function ax(n){const e=lx(),t=e&&(e.crypto||e.msCrypto)||null;if(typeof(t==null?void 0:t.getRandomValues)=="function")return()=>{const r=new Uint8Array(1);return t.getRandomValues(r),r[0]/256};if(typeof(t==null?void 0:t.randomBytes)=="function")return()=>t.randomBytes(1).readUInt8()/256;throw new Wi(Un.PRNGDetectFailure,"Failed to find a reliable PRNG")}function lx(){return hx()?self:typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:null}function cx(n,e){let t="";for(;n>0;n--)t=ox(e)+t;return t}function ux(n,e=jg){if(isNaN(n))throw new Wi(Un.EncodeTimeValueMalformed,`Time must be a number: ${n}`);if(n>Ep)throw new Wi(Un.EncodeTimeSizeExceeded,`Cannot encode a time larger than ${Ep}: ${n}`);if(n<0)throw new Wi(Un.EncodeTimeNegative,`Time must be positive: ${n}`);if(Number.isInteger(n)===!1)throw new Wi(Un.EncodeTimeValueMalformed,`Time must be an integer: ${n}`);let t,r="";for(let i=e;i>0;i--)t=n%ca,r=Bg.charAt(t)+r,n=(n-t)/ca;return r}function hx(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}function Xu(n,e){const t=ax(),r=Date.now();return ux(r,jg)+cx(sx,t)}const Lt=4,et=6,qg=2,Cc=2,dx=Lt,px=et,Ku="auto",mn="auto",On=120,xp=50,he=16,hr=On*Lt+he*(Lt-1),ua=On*et+he*(et-1),fx=hr+he*2,gx=200,mx=4,Ao=150,vx=10,Ap=2,$p=8,yx=300,bx=4;function Yg(n){return Jg(n)}function Xg(n,e){return Jg(n.flatMap(t=>em(t,e)))}function Kg(n){const e=[],t=new Set;for(const r of n){if(r.type==="row"){e.push(`Top-level rows are invalid: ${r.id}`);continue}tm(r,"strip",e,t)}return{valid:e.length===0,errors:e}}function Fr(n){const e=Yg(n),t=Kg(e);if(!t.valid)throw new Error(`Invalid layout: ${t.errors.join("; ")}`);return{totalNodes:e.length,nodes:e.filter(r=>r.type!=="row").map(kx)}}function Jg(n){const e=[];for(const t of n){const r=Qg(t);for(const i of r){if(i.type==="row"){e.push(...i.children.map(Kt));continue}e.push(i)}}return e}function Qg(n){switch(n.type){case"card":return[Kt(n)];case"row":{const e=n.children.map(Kt);return e.length===0?[]:e.length===1?[e[0]]:[{...n,children:e}]}case"stack":{const e=[];for(const t of n.children){const r=Qg(t);for(const i of r){if(i.type==="stack"){e.push(...i.children.map(Pc));continue}if(i.type==="row"){e.push({...i,children:i.children.map(Kt)});continue}e.push(Kt(i))}}return e.length===0?[]:e.length===1?[Pc(e[0])]:[{...n,children:e}]}}}function em(n,e){switch(n.type){case"card":return n.artifactID===e?[]:[Kt(n)];case"row":{const t=n.children.filter(r=>r.artifactID!==e).map(Kt);return t.length===0?[]:t.length===1?[t[0]]:[{...n,children:t}]}case"stack":{const t=n.children.flatMap(r=>em(r,e).filter(s=>s.type!=="stack"));return t.length===0?[]:t.length===1?[Pc(t[0])]:[{...n,children:t}]}}}function tm(n,e,t,r){switch(n.type){case"card":nm(n,e,t,r);return;case"row":wx(n,e,t,r);return;case"stack":Sx(n,e,t,r);return}}function nm(n,e,t,r){Ju(n.id,t),typeof n.artifactID!="string"||n.artifactID.length===0?t.push(`Card ${n.id} is missing artifactID`):r.has(n.artifactID)?t.push(`Duplicate artifactID in layout: ${n.artifactID}`):r.add(n.artifactID),_x(n.width)||t.push(`Card ${n.id} width must be an integer in the range 2-4`),rm(n.height)||t.push(`Card ${n.id} height must be an integer in the range 2-6 or "auto"`);const i=Mn(n.width);e==="row"&&i<qg&&t.push(`Row child ${n.id} must be at least 2 columns wide`)}function wx(n,e,t,r){if(Ju(n.id,t),e!=="stack"&&t.push(`Row ${n.id} may only appear inside a stack`),rm(n.height,bx)||t.push(`Row ${n.id} height must be an integer in the range 2-4 or "auto"`),!Array.isArray(n.children)||n.children.length===0){t.push(`Row ${n.id} must contain card nodes`);return}let i=0;for(const s of n.children){if(s.type!=="card"){t.push(`Row ${n.id} must contain only card nodes`);continue}nm(s,"row",t,r),i+=Mn(s.width)}i!==Lt&&t.push(`Row ${n.id} children must sum to 4 columns`)}function Sx(n,e,t,r){if(Ju(n.id,t),e!=="strip"&&t.push(`Invalid nested stack at ${n.id}; stack children cannot contain another nested stack`),!Array.isArray(n.children)||n.children.length===0){t.push(`Stack ${n.id} must contain at least one child`);return}let i=0,s=0;for(const a of n.children){if(a.type==="stack"){t.push(`Stack ${n.id} cannot contain another nested stack`);continue}if(tm(a,"stack",t,r),a.height===mn){s+=1;continue}i+=a.height}if(i>et&&t.push(`Stack ${n.id} exceeds the 6-row budget`),s===0)return;const o=et-i;if(o<s*Cc||o%s!==0){t.push(`Stack ${n.id} has auto-height children that cannot resolve to whole height >= 2`);return}o/s<Cc&&t.push(`Stack ${n.id} has auto-height children below the minimum row size`)}function Ju(n,e){(typeof n!="string"||n.length===0)&&e.push(`Node id must be a non-empty string: ${String(n)}`)}function _x(n){return n===Ku||Number.isInteger(n)&&n>=qg&&n<=dx}function rm(n,e=px){return n===mn||Number.isInteger(n)&&n>=Cc&&n<=e}function Mn(n){return n===Ku?Lt:n}function kx(n){if(n.type==="card")return{id:n.id,type:"card",width:Mn(n.width),cards:[{id:n.id,artifactID:n.artifactID,col:1,row:1,width:Mn(n.width),height:im(n.height,et)}]};const e=Ex(n.children),t=[];let r=1;for(let i=0;i<n.children.length;i+=1){const s=n.children[i],o=e[i];if(s.type==="card")t.push({id:s.id,artifactID:s.artifactID,col:1,row:r,width:Mn(s.width),height:o});else{let a=1;for(const c of s.children)t.push({id:c.id,artifactID:c.artifactID,col:a,row:r,width:Mn(c.width),height:o}),a+=Mn(c.width)}r+=o}return{id:n.id,type:"stack",width:t.reduce((i,s)=>Math.max(i,s.col+s.width-1),1),cards:t}}function Ex(n){let e=0,t=0;for(const i of n)i.height===mn?t+=1:e+=i.height;const r=t>0?(et-e)/t:0;return n.map(i=>im(i.height,r))}function im(n,e){return n===mn?e:n}function Kt(n){return{...n}}function Pc(n){return n.type==="card"?Kt(n):{...n,children:n.children.map(Kt)}}function sm(n,e={}){return{id:e.id??Xu(),type:"card",artifactID:n,width:e.width??Ku,height:e.height??mn}}function om(n,e){return n.some(t=>am(t,e))}function am(n,e){switch(n.type){case"card":return n.artifactID===e;case"row":return n.children.some(t=>t.artifactID===e);case"stack":return n.children.some(t=>am(t,e))}}function Tp(n){return n.layout.flatMap(lm)}function lm(n){switch(n.type){case"card":return[n.artifactID];case"row":return n.children.map(e=>e.artifactID);case"stack":return n.children.flatMap(lm)}}const K=tt(),cm=tt(),Pr=tt(),xx=tt();function Ax(n){class e extends Error{constructor(r,i){super(r),this.name=n,i&&Object.assign(this,i)}}return e}const $x=Ax("RequestError"),Tx=200,Ix=300;class Cx{constructor(e,t){b(this,"serverURL");b(this,"token");this.serverURL=e.replace(/\/$/,""),this.token=t.token}async requestJSON(e,t,r){const i=await this.request(e,t,r!==void 0?JSON.stringify(r):void 0,r!==void 0?{"content-type":"application/json"}:void 0),s=await Px(i);if(!i.ok||i.status<Tx||i.status>=Ix)throw this.createError(typeof s.error=="string"?s.error:i.statusText,i.status);return s}async requestVoid(e,t){const r=await this.request(e,t);if(!r.ok)throw this.createError(await Kl(r,r.statusText),r.status)}async requestText(e,t){const r=await this.request(e,t);if(!r.ok)throw this.createError(await Kl(r,r.statusText),r.status);return r.text()}async requestRawVoid(e,t,r){const i=await this.request(e,t,r,{"content-type":"text/plain"});if(!i.ok)throw this.createError(await Kl(i,i.statusText),i.status)}createError(e,t){const r={serverURL:this.serverURL};return t!==void 0&&(r.status=t),new $x(e,r)}async request(e,t,r,i){const s=`${this.serverURL}${t}`;try{return await fetch(s,{method:e,headers:this.buildHeaders(i),body:r})}catch(o){throw this.createError(o instanceof Error?o.message:"Failed to reach server")}}buildHeaders(e){const t={...e??{}};return this.token&&(t.Authorization=`Bearer ${this.token}`),Object.keys(t).length>0?t:void 0}}async function Px(n){try{return await n.json()}catch{const e=await n.text().catch(()=>"");return e?{message:e}:{}}}async function Kl(n,e){try{const t=await n.json();if(typeof t.error=="string")return t.error;if(typeof t.message=="string")return t.message}catch{}return e}function Rx(n){return n.map(e=>`${e.name} (${e.id})`).join(", ")}var Tt,_a,um;class Dx{constructor(e){w(this,_a);w(this,Tt);x(this,Tt,e)}list(){return l(this,Tt).requestJSON("GET","/screens")}async get(e={}){const t=await m(this,_a,um).call(this,e.screenID);return l(this,Tt).requestJSON("GET",`/screens/${encodeURIComponent(t)}`)}create(e){const t={name:e.name};return e.id!==void 0&&(t.id=e.id),l(this,Tt).requestJSON("POST","/screens",t)}update(e){const{screenID:t,...r}=e;return l(this,Tt).requestJSON("PATCH",`/screens/${encodeURIComponent(t)}`,r)}remove(e){return l(this,Tt).requestJSON("DELETE",`/screens/${encodeURIComponent(e.screenID)}`)}}Tt=new WeakMap,_a=new WeakSet,um=async function(e){if(e!==void 0)return e;const{screens:t}=await this.list();if(t.length===1)return t[0].id;throw l(this,Tt).createError(`screenID is required when multiple screens exist. Available screens: ${Rx(t)}`)};var Le;class Lx{constructor(e){w(this,Le);x(this,Le,e)}create(e){const t={type:e.type,title:e.title};return e.externalFilePath!==void 0&&(t.externalFilePath=e.externalFilePath),e.externalURL!==void 0&&(t.externalURL=e.externalURL),e.screenID!==void 0&&(t.screenID=e.screenID),l(this,Le).requestJSON("POST","/artifacts",t)}list(e={}){const t=new URLSearchParams;e.screenID!==void 0&&t.set("screenID",e.screenID),e.unplaced&&t.set("unplaced","true");const r=t.toString();return l(this,Le).requestJSON("GET",r?`/artifacts?${r}`:"/artifacts")}get(e){return l(this,Le).requestJSON("GET",`/artifacts/${encodeURIComponent(e.artifactID)}`)}update(e){const t={};return e.title!==void 0&&(t.title=e.title),l(this,Le).requestJSON("PATCH",`/artifacts/${encodeURIComponent(e.artifactID)}`,t)}edit(e){return l(this,Le).requestJSON("POST",`/artifacts/${encodeURIComponent(e.artifactID)}/edit`)}commitPending(e){return l(this,Le).requestJSON("POST",`/artifacts/${encodeURIComponent(e.artifactID)}/commit`)}abandonPending(e){return l(this,Le).requestVoid("POST",`/artifacts/${encodeURIComponent(e.artifactID)}/abandon`)}attach(e){return l(this,Le).requestJSON("POST",`/screens/${encodeURIComponent(e.screenID)}/artifacts/${encodeURIComponent(e.artifactID)}`)}detach(e){return l(this,Le).requestJSON("DELETE",`/screens/${encodeURIComponent(e.screenID)}/artifacts/${encodeURIComponent(e.artifactID)}`)}delete(e){return l(this,Le).requestJSON("DELETE",`/artifacts/${encodeURIComponent(e.artifactID)}`)}getContent(e){return l(this,Le).requestText("GET",`/artifacts/${encodeURIComponent(e.artifactID)}/content`)}putContent(e){return l(this,Le).requestRawVoid("PUT",`/artifacts/${encodeURIComponent(e.artifactID)}/content`,e.content)}}Le=new WeakMap;var Hn;class Ox{constructor(e){w(this,Hn);x(this,Hn,e)}state(){return l(this,Hn).requestJSON("GET","/viewer/state")}setActive(e){return l(this,Hn).requestJSON("PUT","/viewer/active-screen",{screenID:e.screenID})}focus(e){const t={artifactID:e.artifactID};return e.screenID!==void 0&&(t.screenID=e.screenID),l(this,Hn).requestJSON("POST","/viewer/focus",t)}}Hn=new WeakMap;var us;class Mx{constructor(e){w(this,us);x(this,us,e)}async list(){const{views:e}=await l(this,us).requestJSON("GET","/views");return e}}us=new WeakMap;var Wt;class zx{constructor(e,t={}){b(this,"screens");b(this,"artifacts");b(this,"viewer");b(this,"views");w(this,Wt);x(this,Wt,new Cx(e,t)),this.screens=new Dx(l(this,Wt)),this.artifacts=new Lx(l(this,Wt)),this.viewer=new Ox(l(this,Wt)),this.views=new Mx(l(this,Wt))}health(){return l(this,Wt).requestJSON("GET","/health")}}Wt=new WeakMap;const Nx={focusCommandInput:{label:"Focus Command Input",trigger:{key:"k",meta:!0}}},Ux=ki(wt);var Wn,We,Gn,ze,dt,on,an,J,Pn,hm,hs,dm,pm,fm,gm,Rc,Dc,Lc,mm;class Fx extends Ux{constructor(t){var i;super();w(this,J);b(this,"id");b(this,"server");w(this,Wn);w(this,We,new Map);w(this,Gn);w(this,ze);w(this,dt);w(this,on);w(this,an,null);w(this,hs,t=>{if(this.disposed)return;const r=t.event;switch(r.type){case"screen-updated":r.screen.id===this.id&&m(this,J,dm).call(this,r.screen);break;case"artifact-created":break;case"artifact-attached":r.screenID===this.id&&m(this,J,pm).call(this,r.cardID,r.artifact);break;case"artifact-updated":m(this,J,fm).call(this,r.artifact);break;case"artifact-removed":r.screenID===this.id&&m(this,J,gm).call(this,r.artifactID);break;case"artifact-content-changed":l(this,We).has(r.artifactID)&&this.dispatchEvent(new xx("artifact-content-changed",{artifactID:r.artifactID}));break}});this.id=t.screen.id,this.server=t.server,x(this,Wn,t.localStore),x(this,Gn,t.screen.name),x(this,ze,structuredClone(t.screen.layout)),x(this,dt,t.screen.starred);const r=((i=l(this,Wn).get().screens[this.id])==null?void 0:i.scrollPosition)??0;x(this,on,Math.max(0,r)),this.server.addEventListener("server-event",l(this,hs)),m(this,J,hm).call(this)}get name(){return l(this,Gn)}get layout(){return l(this,ze)}get starred(){return l(this,dt)}get scrollPosition(){return l(this,on)}get artifacts(){return l(this,We)}setScrollPosition(t){m(this,J,Pn).call(this);const r=Math.max(0,t);r!==l(this,on)&&(x(this,on,r),m(this,J,mm).call(this),this.dispatchEvent(new K("change")))}setLayout(t){m(this,J,Pn).call(this);const r=Yg(t);if(!Kg(r).valid)return;const s=m(this,J,Dc).call(this);x(this,ze,r),x(this,an,{layout:r,snapshot:s}),this.dispatchEvent(new K("change")),this.server.client.screens.update({screenID:this.id,layout:r.map(o=>structuredClone(o))}).catch(()=>{var o;this.disposed||((o=l(this,an))==null?void 0:o.layout)===r&&(x(this,an,null),m(this,J,Lc).call(this,s),this.dispatchEvent(new K("change")))})}rename(t){m(this,J,Pn).call(this),x(this,Gn,t),this.dispatchEvent(new K("change")),this.server.client.screens.update({screenID:this.id,name:t}).catch(()=>{})}setStarred(t){if(m(this,J,Pn).call(this),l(this,dt)===t)return;const r=l(this,dt);x(this,dt,t),this.dispatchEvent(new K("change")),this.server.client.screens.update({screenID:this.id,starred:t}).catch(()=>{this.disposed||l(this,dt)===t&&(x(this,dt,r),this.dispatchEvent(new K("change")))})}async remove(){m(this,J,Pn).call(this),await this.server.client.screens.remove({screenID:this.id})}removeArtifact(t){if(m(this,J,Pn).call(this),!l(this,We).has(t))return;const r=m(this,J,Dc).call(this);m(this,J,Rc).call(this,t),this.dispatchEvent(new K("change")),this.server.client.artifacts.detach({artifactID:t,screenID:this.id}).catch(()=>{this.disposed||(m(this,J,Lc).call(this,r),this.dispatchEvent(new K("change")))})}dispose(){this.server.removeEventListener("server-event",l(this,hs))}}Wn=new WeakMap,We=new WeakMap,Gn=new WeakMap,ze=new WeakMap,dt=new WeakMap,on=new WeakMap,an=new WeakMap,J=new WeakSet,Pn=function(){if(this.disposed)throw new Error("ScreenModel is disposed")},hm=async function(){try{const t=await this.server.client.screens.get({screenID:this.id});if(this.disposed)return;for(const r of t.artifacts)l(this,We).set(r.id,r);this.dispatchEvent(new K("change"))}catch{}},hs=new WeakMap,dm=function(t){l(this,an)&&x(this,an,null),x(this,Gn,t.name),x(this,ze,structuredClone(t.layout)),x(this,dt,t.starred),this.dispatchEvent(new K("change"))},pm=function(t,r){om(l(this,ze),r.id)||x(this,ze,[...l(this,ze),sm(r.id,{id:t})]),l(this,We).set(r.id,r),this.dispatchEvent(new K("change"))},fm=function(t){const r=l(this,We).get(t.id);r&&(l(this,We).set(t.id,{...r,...t}),this.dispatchEvent(new K("change")))},gm=function(t){m(this,J,Rc).call(this,t)&&this.dispatchEvent(new K("change"))},Rc=function(t){const r=l(this,We).delete(t),i=Tp({layout:l(this,ze)}).length,s=Xg(l(this,ze),t),o=Tp({layout:s}).length;return x(this,ze,s),r||i!==o},Dc=function(){return{layout:structuredClone(l(this,ze)),artifacts:new Map([...l(this,We).entries()].map(([t,r])=>[t,structuredClone(r)]))}},Lc=function(t){x(this,ze,structuredClone(t.layout)),l(this,We).clear();for(const[r,i]of t.artifacts)l(this,We).set(r,structuredClone(i))},mm=function(){const t=l(this,Wn).get();l(this,Wn).set({...t,screens:{...t.screens,[this.id]:{scrollPosition:l(this,on)}}})};const Zx=ki(wt);var nt,It,pt,ds,ps,fs,Vr,qo;class Hx extends Zx{constructor(t){super();w(this,Vr);w(this,nt);w(this,It);w(this,pt,null);w(this,ds,()=>{this.disposed||m(this,Vr,qo).call(this)});w(this,ps,()=>{this.disposed||m(this,Vr,qo).call(this)});w(this,fs,t=>{var i;if(this.disposed)return;const r=t.event;if(r.type==="screen-removed"&&((i=l(this,pt))==null?void 0:i.id)===r.screenID&&this.clearActive(),r.type==="viewer-active-screen-changed"){const s=l(this,It).servers.get(t.serverURL);s&&s.screens.has(r.screenID)&&this.setActive(t.serverURL,r.screenID)}});x(this,nt,t.localStore),x(this,It,t.serverManager),l(this,nt).addEventListener("change",l(this,ds)),l(this,It).addEventListener("change",l(this,ps)),l(this,It).addEventListener("server-event",l(this,fs)),m(this,Vr,qo).call(this)}get activeScreen(){return l(this,pt)}setActive(t,r){const i=l(this,nt).get();i.activeServerURL===t&&i.activeScreenID===r||l(this,nt).set({...i,activeServerURL:t,activeScreenID:r})}clearActive(){const t=l(this,nt).get();t.activeScreenID!==null&&l(this,nt).set({...t,activeScreenID:null})}dispose(){var t;l(this,nt).removeEventListener("change",l(this,ds)),l(this,It).removeEventListener("change",l(this,ps)),l(this,It).removeEventListener("server-event",l(this,fs)),(t=l(this,pt))==null||t.dispose(),x(this,pt,null)}}nt=new WeakMap,It=new WeakMap,pt=new WeakMap,ds=new WeakMap,ps=new WeakMap,fs=new WeakMap,Vr=new WeakSet,qo=function(){var c,u,h;const{activeServerURL:t,activeScreenID:r}=l(this,nt).get(),i=t?l(this,It).servers.get(t)??null:null,s=i&&r?i.screens.get(r)??null:null,o=((c=l(this,pt))==null?void 0:c.id)??null,a=(s==null?void 0:s.id)??null;o===a&&((u=l(this,pt))==null?void 0:u.server)===i||((h=l(this,pt))==null||h.dispose(),x(this,pt,i&&s?new Fx({screen:s,server:i,localStore:l(this,nt)}):null),this.dispatchEvent(new rx("active-screen-changed")))};const Wx="Local",Gx="store-";function ht(n){return new URL(n).origin}function Vx(n){return{servers:[{url:ht(n),name:Wx}],activeServerURL:null,activeScreenID:null,screens:{}}}var Vn,Bn,jn;class Bx extends wt{constructor(t,r,i={}){super();w(this,Vn);w(this,Bn);w(this,jn);x(this,Vn,`${Gx}${t}`),x(this,Bn,i.storage??jx());const s=l(this,Bn).getItem(l(this,Vn));s===null?(x(this,jn,r),l(this,Bn).setItem(l(this,Vn),JSON.stringify(r))):x(this,jn,JSON.parse(s))}get(){return l(this,jn)}set(t){x(this,jn,t),l(this,Bn).setItem(l(this,Vn),JSON.stringify(t)),this.dispatchEvent(new K("change"))}}Vn=new WeakMap,Bn=new WeakMap,jn=new WeakMap;function jx(){const n=globalThis.localStorage;if(!n)throw new Error("LocalStore: no storage adapter supplied and window.localStorage is unavailable");return n}function A(n,e,t){function r(a,c){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:c,constr:o,traits:new Set},enumerable:!1}),a._zod.traits.has(n))return;a._zod.traits.add(n),e(a,c);const u=o.prototype,h=Object.keys(u);for(let p=0;p<h.length;p++){const v=h[p];v in a||(a[v]=u[v].bind(a))}}const i=(t==null?void 0:t.Parent)??Object;class s extends i{}Object.defineProperty(s,"name",{value:n});function o(a){var c;const u=t!=null&&t.Parent?new s:this;r(u,a),(c=u._zod).deferred??(c.deferred=[]);for(const h of u._zod.deferred)h();return u}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:a=>{var c,u;return t!=null&&t.Parent&&a instanceof t.Parent?!0:(u=(c=a==null?void 0:a._zod)==null?void 0:c.traits)==null?void 0:u.has(n)}}),Object.defineProperty(o,"name",{value:n}),o}class Gr extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class vm extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}}const ym={};function vn(n){return ym}function bm(n){const e=Object.values(n).filter(r=>typeof r=="number");return Object.entries(n).filter(([r,i])=>e.indexOf(+r)===-1).map(([r,i])=>i)}function Oc(n,e){return typeof e=="bigint"?e.toString():e}function Qu(n){return{get value(){{const e=n();return Object.defineProperty(this,"value",{value:e}),e}}}}function eh(n){return n==null}function th(n){const e=n.startsWith("^")?1:0,t=n.endsWith("$")?n.length-1:n.length;return n.slice(e,t)}function qx(n,e){const t=(n.toString().split(".")[1]||"").length,r=e.toString();let i=(r.split(".")[1]||"").length;if(i===0&&/\d?e-\d?/.test(r)){const c=r.match(/\d?e-(\d?)/);c!=null&&c[1]&&(i=Number.parseInt(c[1]))}const s=t>i?t:i,o=Number.parseInt(n.toFixed(s).replace(".","")),a=Number.parseInt(e.toFixed(s).replace(".",""));return o%a/10**s}const Ip=Symbol("evaluating");function ee(n,e,t){let r;Object.defineProperty(n,e,{get(){if(r!==Ip)return r===void 0&&(r=Ip,r=t()),r},set(i){Object.defineProperty(n,e,{value:i})},configurable:!0})}function br(n,e,t){Object.defineProperty(n,e,{value:t,writable:!0,enumerable:!0,configurable:!0})}function En(...n){const e={};for(const t of n){const r=Object.getOwnPropertyDescriptors(t);Object.assign(e,r)}return Object.defineProperties({},e)}function Cp(n){return JSON.stringify(n)}function Yx(n){return n.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const wm="captureStackTrace"in Error?Error.captureStackTrace:(...n)=>{};function ha(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}const Xx=Qu(()=>{var n;if(typeof navigator<"u"&&((n=navigator==null?void 0:navigator.userAgent)!=null&&n.includes("Cloudflare")))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function hi(n){if(ha(n)===!1)return!1;const e=n.constructor;if(e===void 0||typeof e!="function")return!0;const t=e.prototype;return!(ha(t)===!1||Object.prototype.hasOwnProperty.call(t,"isPrototypeOf")===!1)}function Sm(n){return hi(n)?{...n}:Array.isArray(n)?[...n]:n}const Kx=new Set(["string","number","symbol"]);function di(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function xn(n,e,t){const r=new n._zod.constr(e??n._zod.def);return(!e||t!=null&&t.parent)&&(r._zod.parent=n),r}function O(n){const e=n;if(!e)return{};if(typeof e=="string")return{error:()=>e};if((e==null?void 0:e.message)!==void 0){if((e==null?void 0:e.error)!==void 0)throw new Error("Cannot specify both `message` and `error` params");e.error=e.message}return delete e.message,typeof e.error=="string"?{...e,error:()=>e.error}:e}function Jx(n){return Object.keys(n).filter(e=>n[e]._zod.optin==="optional"&&n[e]._zod.optout==="optional")}const Qx={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 e1(n,e){const t=n._zod.def,r=t.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const s=En(n._zod.def,{get shape(){const o={};for(const a in e){if(!(a in t.shape))throw new Error(`Unrecognized key: "${a}"`);e[a]&&(o[a]=t.shape[a])}return br(this,"shape",o),o},checks:[]});return xn(n,s)}function t1(n,e){const t=n._zod.def,r=t.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const s=En(n._zod.def,{get shape(){const o={...n._zod.def.shape};for(const a in e){if(!(a in t.shape))throw new Error(`Unrecognized key: "${a}"`);e[a]&&delete o[a]}return br(this,"shape",o),o},checks:[]});return xn(n,s)}function n1(n,e){if(!hi(e))throw new Error("Invalid input to extend: expected a plain object");const t=n._zod.def.checks;if(t&&t.length>0){const s=n._zod.def.shape;for(const o in e)if(Object.getOwnPropertyDescriptor(s,o)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const i=En(n._zod.def,{get shape(){const s={...n._zod.def.shape,...e};return br(this,"shape",s),s}});return xn(n,i)}function r1(n,e){if(!hi(e))throw new Error("Invalid input to safeExtend: expected a plain object");const t=En(n._zod.def,{get shape(){const r={...n._zod.def.shape,...e};return br(this,"shape",r),r}});return xn(n,t)}function i1(n,e){const t=En(n._zod.def,{get shape(){const r={...n._zod.def.shape,...e._zod.def.shape};return br(this,"shape",r),r},get catchall(){return e._zod.def.catchall},checks:[]});return xn(n,t)}function s1(n,e,t){const i=e._zod.def.checks;if(i&&i.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const o=En(e._zod.def,{get shape(){const a=e._zod.def.shape,c={...a};if(t)for(const u in t){if(!(u in a))throw new Error(`Unrecognized key: "${u}"`);t[u]&&(c[u]=n?new n({type:"optional",innerType:a[u]}):a[u])}else for(const u in a)c[u]=n?new n({type:"optional",innerType:a[u]}):a[u];return br(this,"shape",c),c},checks:[]});return xn(e,o)}function o1(n,e,t){const r=En(e._zod.def,{get shape(){const i=e._zod.def.shape,s={...i};if(t)for(const o in t){if(!(o in s))throw new Error(`Unrecognized key: "${o}"`);t[o]&&(s[o]=new n({type:"nonoptional",innerType:i[o]}))}else for(const o in i)s[o]=new n({type:"nonoptional",innerType:i[o]});return br(this,"shape",s),s}});return xn(e,r)}function Zr(n,e=0){var t;if(n.aborted===!0)return!0;for(let r=e;r<n.issues.length;r++)if(((t=n.issues[r])==null?void 0:t.continue)!==!0)return!0;return!1}function Hr(n,e){return e.map(t=>{var r;return(r=t).path??(r.path=[]),t.path.unshift(n),t})}function $o(n){return typeof n=="string"?n:n==null?void 0:n.message}function yn(n,e,t){var i,s,o,a,c,u;const r={...n,path:n.path??[]};if(!n.message){const h=$o((o=(s=(i=n.inst)==null?void 0:i._zod.def)==null?void 0:s.error)==null?void 0:o.call(s,n))??$o((a=e==null?void 0:e.error)==null?void 0:a.call(e,n))??$o((c=t.customError)==null?void 0:c.call(t,n))??$o((u=t.localeError)==null?void 0:u.call(t,n))??"Invalid input";r.message=h}return delete r.inst,delete r.continue,e!=null&&e.reportInput||delete r.input,r}function nh(n){return Array.isArray(n)?"array":typeof n=="string"?"string":"unknown"}function ss(...n){const[e,t,r]=n;return typeof e=="string"?{message:e,code:"custom",input:t,inst:r}:{...e}}const _m=(n,e)=>{n.name="$ZodError",Object.defineProperty(n,"_zod",{value:n._zod,enumerable:!1}),Object.defineProperty(n,"issues",{value:e,enumerable:!1}),n.message=JSON.stringify(e,Oc,2),Object.defineProperty(n,"toString",{value:()=>n.message,enumerable:!1})},km=A("$ZodError",_m),Em=A("$ZodError",_m,{Parent:Error});function a1(n,e=t=>t.message){const t={},r=[];for(const i of n.issues)i.path.length>0?(t[i.path[0]]=t[i.path[0]]||[],t[i.path[0]].push(e(i))):r.push(e(i));return{formErrors:r,fieldErrors:t}}function l1(n,e=t=>t.message){const t={_errors:[]},r=i=>{for(const s of i.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(o=>r({issues:o}));else if(s.code==="invalid_key")r({issues:s.issues});else if(s.code==="invalid_element")r({issues:s.issues});else if(s.path.length===0)t._errors.push(e(s));else{let o=t,a=0;for(;a<s.path.length;){const c=s.path[a];a===s.path.length-1?(o[c]=o[c]||{_errors:[]},o[c]._errors.push(e(s))):o[c]=o[c]||{_errors:[]},o=o[c],a++}}};return r(n),t}const rh=n=>(e,t,r,i)=>{const s=r?Object.assign(r,{async:!1}):{async:!1},o=e._zod.run({value:t,issues:[]},s);if(o instanceof Promise)throw new Gr;if(o.issues.length){const a=new((i==null?void 0:i.Err)??n)(o.issues.map(c=>yn(c,s,vn())));throw wm(a,i==null?void 0:i.callee),a}return o.value},ih=n=>async(e,t,r,i)=>{const s=r?Object.assign(r,{async:!0}):{async:!0};let o=e._zod.run({value:t,issues:[]},s);if(o instanceof Promise&&(o=await o),o.issues.length){const a=new((i==null?void 0:i.Err)??n)(o.issues.map(c=>yn(c,s,vn())));throw wm(a,i==null?void 0:i.callee),a}return o.value},Xa=n=>(e,t,r)=>{const i=r?{...r,async:!1}:{async:!1},s=e._zod.run({value:t,issues:[]},i);if(s instanceof Promise)throw new Gr;return s.issues.length?{success:!1,error:new(n??km)(s.issues.map(o=>yn(o,i,vn())))}:{success:!0,data:s.value}},c1=Xa(Em),Ka=n=>async(e,t,r)=>{const i=r?Object.assign(r,{async:!0}):{async:!0};let s=e._zod.run({value:t,issues:[]},i);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new n(s.issues.map(o=>yn(o,i,vn())))}:{success:!0,data:s.value}},u1=Ka(Em),h1=n=>(e,t,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return rh(n)(e,t,i)},d1=n=>(e,t,r)=>rh(n)(e,t,r),p1=n=>async(e,t,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return ih(n)(e,t,i)},f1=n=>async(e,t,r)=>ih(n)(e,t,r),g1=n=>(e,t,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Xa(n)(e,t,i)},m1=n=>(e,t,r)=>Xa(n)(e,t,r),v1=n=>async(e,t,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Ka(n)(e,t,i)},y1=n=>async(e,t,r)=>Ka(n)(e,t,r),b1=/^[cC][^\s-]{8,}$/,w1=/^[0-9a-z]+$/,S1=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,_1=/^[0-9a-vA-V]{20}$/,k1=/^[A-Za-z0-9]{27}$/,E1=/^[a-zA-Z0-9_-]{21}$/,x1=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,A1=/^([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})$/,Pp=n=>n?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${n}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,$1=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,T1="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function I1(){return new RegExp(T1,"u")}const C1=/^(?:(?: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])$/,P1=/^(([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}|:))$/,R1=/^((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])$/,D1=/^(([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])$/,L1=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,xm=/^[A-Za-z0-9_-]*$/,O1=/^\+[1-9]\d{6,14}$/,Am="(?:(?:\\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])))",M1=new RegExp(`^${Am}$`);function $m(n){const e="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof n.precision=="number"?n.precision===-1?`${e}`:n.precision===0?`${e}:[0-5]\\d`:`${e}:[0-5]\\d\\.\\d{${n.precision}}`:`${e}(?::[0-5]\\d(?:\\.\\d+)?)?`}function z1(n){return new RegExp(`^${$m(n)}$`)}function N1(n){const e=$m({precision:n.precision}),t=["Z"];n.local&&t.push(""),n.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${e}(?:${t.join("|")})`;return new RegExp(`^${Am}T(?:${r})$`)}const U1=n=>{const e=n?`[\\s\\S]{${(n==null?void 0:n.minimum)??0},${(n==null?void 0:n.maximum)??""}}`:"[\\s\\S]*";return new RegExp(`^${e}$`)},F1=/^-?\d+$/,Tm=/^-?\d+(?:\.\d+)?$/,Z1=/^(?:true|false)$/i,H1=/^[^A-Z]*$/,W1=/^[^a-z]*$/,Ye=A("$ZodCheck",(n,e)=>{var t;n._zod??(n._zod={}),n._zod.def=e,(t=n._zod).onattach??(t.onattach=[])}),Im={number:"number",bigint:"bigint",object:"date"},Cm=A("$ZodCheckLessThan",(n,e)=>{Ye.init(n,e);const t=Im[typeof e.value];n._zod.onattach.push(r=>{const i=r._zod.bag,s=(e.inclusive?i.maximum:i.exclusiveMaximum)??Number.POSITIVE_INFINITY;e.value<s&&(e.inclusive?i.maximum=e.value:i.exclusiveMaximum=e.value)}),n._zod.check=r=>{(e.inclusive?r.value<=e.value:r.value<e.value)||r.issues.push({origin:t,code:"too_big",maximum:typeof e.value=="object"?e.value.getTime():e.value,input:r.value,inclusive:e.inclusive,inst:n,continue:!e.abort})}}),Pm=A("$ZodCheckGreaterThan",(n,e)=>{Ye.init(n,e);const t=Im[typeof e.value];n._zod.onattach.push(r=>{const i=r._zod.bag,s=(e.inclusive?i.minimum:i.exclusiveMinimum)??Number.NEGATIVE_INFINITY;e.value>s&&(e.inclusive?i.minimum=e.value:i.exclusiveMinimum=e.value)}),n._zod.check=r=>{(e.inclusive?r.value>=e.value:r.value>e.value)||r.issues.push({origin:t,code:"too_small",minimum:typeof e.value=="object"?e.value.getTime():e.value,input:r.value,inclusive:e.inclusive,inst:n,continue:!e.abort})}}),G1=A("$ZodCheckMultipleOf",(n,e)=>{Ye.init(n,e),n._zod.onattach.push(t=>{var r;(r=t._zod.bag).multipleOf??(r.multipleOf=e.value)}),n._zod.check=t=>{if(typeof t.value!=typeof e.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof t.value=="bigint"?t.value%e.value===BigInt(0):qx(t.value,e.value)===0)||t.issues.push({origin:typeof t.value,code:"not_multiple_of",divisor:e.value,input:t.value,inst:n,continue:!e.abort})}}),V1=A("$ZodCheckNumberFormat",(n,e)=>{var o;Ye.init(n,e),e.format=e.format||"float64";const t=(o=e.format)==null?void 0:o.includes("int"),r=t?"int":"number",[i,s]=Qx[e.format];n._zod.onattach.push(a=>{const c=a._zod.bag;c.format=e.format,c.minimum=i,c.maximum=s,t&&(c.pattern=F1)}),n._zod.check=a=>{const c=a.value;if(t){if(!Number.isInteger(c)){a.issues.push({expected:r,format:e.format,code:"invalid_type",continue:!1,input:c,inst:n});return}if(!Number.isSafeInteger(c)){c>0?a.issues.push({input:c,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:n,origin:r,inclusive:!0,continue:!e.abort}):a.issues.push({input:c,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:n,origin:r,inclusive:!0,continue:!e.abort});return}}c<i&&a.issues.push({origin:"number",input:c,code:"too_small",minimum:i,inclusive:!0,inst:n,continue:!e.abort}),c>s&&a.issues.push({origin:"number",input:c,code:"too_big",maximum:s,inclusive:!0,inst:n,continue:!e.abort})}}),B1=A("$ZodCheckMaxLength",(n,e)=>{var t;Ye.init(n,e),(t=n._zod.def).when??(t.when=r=>{const i=r.value;return!eh(i)&&i.length!==void 0}),n._zod.onattach.push(r=>{const i=r._zod.bag.maximum??Number.POSITIVE_INFINITY;e.maximum<i&&(r._zod.bag.maximum=e.maximum)}),n._zod.check=r=>{const i=r.value;if(i.length<=e.maximum)return;const o=nh(i);r.issues.push({origin:o,code:"too_big",maximum:e.maximum,inclusive:!0,input:i,inst:n,continue:!e.abort})}}),j1=A("$ZodCheckMinLength",(n,e)=>{var t;Ye.init(n,e),(t=n._zod.def).when??(t.when=r=>{const i=r.value;return!eh(i)&&i.length!==void 0}),n._zod.onattach.push(r=>{const i=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;e.minimum>i&&(r._zod.bag.minimum=e.minimum)}),n._zod.check=r=>{const i=r.value;if(i.length>=e.minimum)return;const o=nh(i);r.issues.push({origin:o,code:"too_small",minimum:e.minimum,inclusive:!0,input:i,inst:n,continue:!e.abort})}}),q1=A("$ZodCheckLengthEquals",(n,e)=>{var t;Ye.init(n,e),(t=n._zod.def).when??(t.when=r=>{const i=r.value;return!eh(i)&&i.length!==void 0}),n._zod.onattach.push(r=>{const i=r._zod.bag;i.minimum=e.length,i.maximum=e.length,i.length=e.length}),n._zod.check=r=>{const i=r.value,s=i.length;if(s===e.length)return;const o=nh(i),a=s>e.length;r.issues.push({origin:o,...a?{code:"too_big",maximum:e.length}:{code:"too_small",minimum:e.length},inclusive:!0,exact:!0,input:r.value,inst:n,continue:!e.abort})}}),Ja=A("$ZodCheckStringFormat",(n,e)=>{var t,r;Ye.init(n,e),n._zod.onattach.push(i=>{const s=i._zod.bag;s.format=e.format,e.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(e.pattern))}),e.pattern?(t=n._zod).check??(t.check=i=>{e.pattern.lastIndex=0,!e.pattern.test(i.value)&&i.issues.push({origin:"string",code:"invalid_format",format:e.format,input:i.value,...e.pattern?{pattern:e.pattern.toString()}:{},inst:n,continue:!e.abort})}):(r=n._zod).check??(r.check=()=>{})}),Y1=A("$ZodCheckRegex",(n,e)=>{Ja.init(n,e),n._zod.check=t=>{e.pattern.lastIndex=0,!e.pattern.test(t.value)&&t.issues.push({origin:"string",code:"invalid_format",format:"regex",input:t.value,pattern:e.pattern.toString(),inst:n,continue:!e.abort})}}),X1=A("$ZodCheckLowerCase",(n,e)=>{e.pattern??(e.pattern=H1),Ja.init(n,e)}),K1=A("$ZodCheckUpperCase",(n,e)=>{e.pattern??(e.pattern=W1),Ja.init(n,e)}),J1=A("$ZodCheckIncludes",(n,e)=>{Ye.init(n,e);const t=di(e.includes),r=new RegExp(typeof e.position=="number"?`^.{${e.position}}${t}`:t);e.pattern=r,n._zod.onattach.push(i=>{const s=i._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(r)}),n._zod.check=i=>{i.value.includes(e.includes,e.position)||i.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:e.includes,input:i.value,inst:n,continue:!e.abort})}}),Q1=A("$ZodCheckStartsWith",(n,e)=>{Ye.init(n,e);const t=new RegExp(`^${di(e.prefix)}.*`);e.pattern??(e.pattern=t),n._zod.onattach.push(r=>{const i=r._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(t)}),n._zod.check=r=>{r.value.startsWith(e.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:e.prefix,input:r.value,inst:n,continue:!e.abort})}}),eA=A("$ZodCheckEndsWith",(n,e)=>{Ye.init(n,e);const t=new RegExp(`.*${di(e.suffix)}$`);e.pattern??(e.pattern=t),n._zod.onattach.push(r=>{const i=r._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(t)}),n._zod.check=r=>{r.value.endsWith(e.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:e.suffix,input:r.value,inst:n,continue:!e.abort})}}),tA=A("$ZodCheckOverwrite",(n,e)=>{Ye.init(n,e),n._zod.check=t=>{t.value=e.tx(t.value)}});class nA{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),i=Math.min(...r.map(o=>o.length-o.trimStart().length)),s=r.map(o=>o.slice(i)).map(o=>" ".repeat(this.indent*2)+o);for(const o of s)this.content.push(o)}compile(){const e=Function,t=this==null?void 0:this.args,i=[...((this==null?void 0:this.content)??[""]).map(s=>` ${s}`)];return new e(...t,i.join(`
6
- `))}}const nA={major:4,minor:3,patch:6},pe=A("$ZodType",(n,e)=>{var i;var t;n??(n={}),n._zod.def=e,n._zod.bag=n._zod.bag||{},n._zod.version=nA;const r=[...n._zod.def.checks??[]];n._zod.traits.has("$ZodCheck")&&r.unshift(n);for(const s of r)for(const o of s._zod.onattach)o(n);if(r.length===0)(t=n._zod).deferred??(t.deferred=[]),(i=n._zod.deferred)==null||i.push(()=>{n._zod.run=n._zod.parse});else{const s=(a,c,u)=>{let h=Zr(a),p;for(const v of c){if(v._zod.def.when){if(!v._zod.def.when(a))continue}else if(h)continue;const g=a.issues.length,E=v._zod.check(a);if(E instanceof Promise&&(u==null?void 0:u.async)===!1)throw new Br;if(p||E instanceof Promise)p=(p??Promise.resolve()).then(async()=>{await E,a.issues.length!==g&&(h||(h=Zr(a,g)))});else{if(a.issues.length===g)continue;h||(h=Zr(a,g))}}return p?p.then(()=>a):a},o=(a,c,u)=>{if(Zr(a))return a.aborted=!0,a;const h=s(c,r,u);if(h instanceof Promise){if(u.async===!1)throw new Br;return h.then(p=>n._zod.parse(p,u))}return n._zod.parse(h,u)};n._zod.run=(a,c)=>{if(c.skipChecks)return n._zod.parse(a,c);if(c.direction==="backward"){const h=n._zod.parse({value:a.value,issues:[]},{...c,skipChecks:!0});return h instanceof Promise?h.then(p=>o(p,a,c)):o(h,a,c)}const u=n._zod.parse(a,c);if(u instanceof Promise){if(c.async===!1)throw new Br;return u.then(h=>s(h,r,c))}return s(u,r,c)}}ee(n,"~standard",()=>({validate:s=>{var o;try{const a=l1(n,s);return a.success?{value:a.data}:{issues:(o=a.error)==null?void 0:o.issues}}catch{return c1(n,s).then(c=>{var u;return c.success?{value:c.data}:{issues:(u=c.error)==null?void 0:u.issues}})}},vendor:"zod",version:1}))}),nh=A("$ZodString",(n,e)=>{var t;pe.init(n,e),n._zod.pattern=[...((t=n==null?void 0:n._zod.bag)==null?void 0:t.patterns)??[]].pop()??N1(n._zod.bag),n._zod.parse=(r,i)=>{if(e.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:n}),r}}),le=A("$ZodStringFormat",(n,e)=>{Ja.init(n,e),nh.init(n,e)}),rA=A("$ZodGUID",(n,e)=>{e.pattern??(e.pattern=x1),le.init(n,e)}),iA=A("$ZodUUID",(n,e)=>{if(e.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[e.version];if(r===void 0)throw new Error(`Invalid UUID version: "${e.version}"`);e.pattern??(e.pattern=Ip(r))}else e.pattern??(e.pattern=Ip());le.init(n,e)}),sA=A("$ZodEmail",(n,e)=>{e.pattern??(e.pattern=A1),le.init(n,e)}),oA=A("$ZodURL",(n,e)=>{le.init(n,e),n._zod.check=t=>{try{const r=t.value.trim(),i=new URL(r);e.hostname&&(e.hostname.lastIndex=0,e.hostname.test(i.hostname)||t.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:e.hostname.source,input:t.value,inst:n,continue:!e.abort})),e.protocol&&(e.protocol.lastIndex=0,e.protocol.test(i.protocol.endsWith(":")?i.protocol.slice(0,-1):i.protocol)||t.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:e.protocol.source,input:t.value,inst:n,continue:!e.abort})),e.normalize?t.value=i.href:t.value=r;return}catch{t.issues.push({code:"invalid_format",format:"url",input:t.value,inst:n,continue:!e.abort})}}}),aA=A("$ZodEmoji",(n,e)=>{e.pattern??(e.pattern=T1()),le.init(n,e)}),lA=A("$ZodNanoID",(n,e)=>{e.pattern??(e.pattern=k1),le.init(n,e)}),cA=A("$ZodCUID",(n,e)=>{e.pattern??(e.pattern=y1),le.init(n,e)}),uA=A("$ZodCUID2",(n,e)=>{e.pattern??(e.pattern=b1),le.init(n,e)}),hA=A("$ZodULID",(n,e)=>{e.pattern??(e.pattern=w1),le.init(n,e)}),dA=A("$ZodXID",(n,e)=>{e.pattern??(e.pattern=S1),le.init(n,e)}),pA=A("$ZodKSUID",(n,e)=>{e.pattern??(e.pattern=_1),le.init(n,e)}),fA=A("$ZodISODateTime",(n,e)=>{e.pattern??(e.pattern=z1(e)),le.init(n,e)}),gA=A("$ZodISODate",(n,e)=>{e.pattern??(e.pattern=O1),le.init(n,e)}),mA=A("$ZodISOTime",(n,e)=>{e.pattern??(e.pattern=M1(e)),le.init(n,e)}),vA=A("$ZodISODuration",(n,e)=>{e.pattern??(e.pattern=E1),le.init(n,e)}),yA=A("$ZodIPv4",(n,e)=>{e.pattern??(e.pattern=I1),le.init(n,e),n._zod.bag.format="ipv4"}),bA=A("$ZodIPv6",(n,e)=>{e.pattern??(e.pattern=C1),le.init(n,e),n._zod.bag.format="ipv6",n._zod.check=t=>{try{new URL(`http://[${t.value}]`)}catch{t.issues.push({code:"invalid_format",format:"ipv6",input:t.value,inst:n,continue:!e.abort})}}}),wA=A("$ZodCIDRv4",(n,e)=>{e.pattern??(e.pattern=P1),le.init(n,e)}),SA=A("$ZodCIDRv6",(n,e)=>{e.pattern??(e.pattern=R1),le.init(n,e),n._zod.check=t=>{const r=t.value.split("/");try{if(r.length!==2)throw new Error;const[i,s]=r;if(!s)throw new Error;const o=Number(s);if(`${o}`!==s)throw new Error;if(o<0||o>128)throw new Error;new URL(`http://[${i}]`)}catch{t.issues.push({code:"invalid_format",format:"cidrv6",input:t.value,inst:n,continue:!e.abort})}}});function Cm(n){if(n==="")return!0;if(n.length%4!==0)return!1;try{return atob(n),!0}catch{return!1}}const _A=A("$ZodBase64",(n,e)=>{e.pattern??(e.pattern=D1),le.init(n,e),n._zod.bag.contentEncoding="base64",n._zod.check=t=>{Cm(t.value)||t.issues.push({code:"invalid_format",format:"base64",input:t.value,inst:n,continue:!e.abort})}});function kA(n){if(!km.test(n))return!1;const e=n.replace(/[-_]/g,r=>r==="-"?"+":"/"),t=e.padEnd(Math.ceil(e.length/4)*4,"=");return Cm(t)}const EA=A("$ZodBase64URL",(n,e)=>{e.pattern??(e.pattern=km),le.init(n,e),n._zod.bag.contentEncoding="base64url",n._zod.check=t=>{kA(t.value)||t.issues.push({code:"invalid_format",format:"base64url",input:t.value,inst:n,continue:!e.abort})}}),xA=A("$ZodE164",(n,e)=>{e.pattern??(e.pattern=L1),le.init(n,e)});function AA(n,e=null){try{const t=n.split(".");if(t.length!==3)return!1;const[r]=t;if(!r)return!1;const i=JSON.parse(atob(r));return!("typ"in i&&(i==null?void 0:i.typ)!=="JWT"||!i.alg||e&&(!("alg"in i)||i.alg!==e))}catch{return!1}}const $A=A("$ZodJWT",(n,e)=>{le.init(n,e),n._zod.check=t=>{AA(t.value,e.alg)||t.issues.push({code:"invalid_format",format:"jwt",input:t.value,inst:n,continue:!e.abort})}}),Pm=A("$ZodNumber",(n,e)=>{pe.init(n,e),n._zod.pattern=n._zod.bag.pattern??Am,n._zod.parse=(t,r)=>{if(e.coerce)try{t.value=Number(t.value)}catch{}const i=t.value;if(typeof i=="number"&&!Number.isNaN(i)&&Number.isFinite(i))return t;const s=typeof i=="number"?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:"Infinity":void 0;return t.issues.push({expected:"number",code:"invalid_type",input:i,inst:n,...s?{received:s}:{}}),t}}),TA=A("$ZodNumberFormat",(n,e)=>{B1.init(n,e),Pm.init(n,e)}),IA=A("$ZodBoolean",(n,e)=>{pe.init(n,e),n._zod.pattern=F1,n._zod.parse=(t,r)=>{if(e.coerce)try{t.value=!!t.value}catch{}const i=t.value;return typeof i=="boolean"||t.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:n}),t}}),CA=A("$ZodUnknown",(n,e)=>{pe.init(n,e),n._zod.parse=t=>t}),PA=A("$ZodNever",(n,e)=>{pe.init(n,e),n._zod.parse=(t,r)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:n}),t)});function Cp(n,e,t){n.issues.length&&e.issues.push(...Hr(t,n.issues)),e.value[t]=n.value}const RA=A("$ZodArray",(n,e)=>{pe.init(n,e),n._zod.parse=(t,r)=>{const i=t.value;if(!Array.isArray(i))return t.issues.push({expected:"array",code:"invalid_type",input:i,inst:n}),t;t.value=Array(i.length);const s=[];for(let o=0;o<i.length;o++){const a=i[o],c=e.element._zod.run({value:a,issues:[]},r);c instanceof Promise?s.push(c.then(u=>Cp(u,t,o))):Cp(c,t,o)}return s.length?Promise.all(s).then(()=>t):t}});function da(n,e,t,r,i){if(n.issues.length){if(i&&!(t in r))return;e.issues.push(...Hr(t,n.issues))}n.value===void 0?t in r&&(e.value[t]=void 0):e.value[t]=n.value}function Rm(n){var r,i,s,o;const e=Object.keys(n.shape);for(const a of e)if(!((o=(s=(i=(r=n.shape)==null?void 0:r[a])==null?void 0:i._zod)==null?void 0:s.traits)!=null&&o.has("$ZodType")))throw new Error(`Invalid element at key "${a}": expected a Zod schema`);const t=Kx(n.shape);return{...n,keys:e,keySet:new Set(e),numKeys:e.length,optionalKeys:new Set(t)}}function Dm(n,e,t,r,i,s){const o=[],a=i.keySet,c=i.catchall._zod,u=c.def.type,h=c.optout==="optional";for(const p in e){if(a.has(p))continue;if(u==="never"){o.push(p);continue}const v=c.run({value:e[p],issues:[]},r);v instanceof Promise?n.push(v.then(g=>da(g,t,p,e,h))):da(v,t,p,e,h)}return o.length&&t.issues.push({code:"unrecognized_keys",keys:o,input:e,inst:s}),n.length?Promise.all(n).then(()=>t):t}const DA=A("$ZodObject",(n,e)=>{pe.init(n,e);const t=Object.getOwnPropertyDescriptor(e,"shape");if(!(t!=null&&t.get)){const a=e.shape;Object.defineProperty(e,"shape",{get:()=>{const c={...a};return Object.defineProperty(e,"shape",{value:c}),c}})}const r=Xu(()=>Rm(e));ee(n._zod,"propValues",()=>{const a=e.shape,c={};for(const u in a){const h=a[u]._zod;if(h.values){c[u]??(c[u]=new Set);for(const p of h.values)c[u].add(p)}}return c});const i=ha,s=e.catchall;let o;n._zod.parse=(a,c)=>{o??(o=r.value);const u=a.value;if(!i(u))return a.issues.push({expected:"object",code:"invalid_type",input:u,inst:n}),a;a.value={};const h=[],p=o.shape;for(const v of o.keys){const g=p[v],E=g._zod.optout==="optional",_=g._zod.run({value:u[v],issues:[]},c);_ instanceof Promise?h.push(_.then(C=>da(C,a,v,u,E))):da(_,a,v,u,E)}return s?Dm(h,u,a,c,r.value,n):h.length?Promise.all(h).then(()=>a):a}}),LA=A("$ZodObjectJIT",(n,e)=>{DA.init(n,e);const t=n._zod.parse,r=Xu(()=>Rm(e)),i=v=>{var W;const g=new tA(["shape","payload","ctx"]),E=r.value,_=L=>{const H=Tp(L);return`shape[${H}]._zod.run({ value: input[${H}], issues: [] }, ctx)`};g.write("const input = payload.value;");const C=Object.create(null);let N=0;for(const L of E.keys)C[L]=`key_${N++}`;g.write("const newResult = {};");for(const L of E.keys){const H=C[L],F=Tp(L),ce=v[L],ue=((W=ce==null?void 0:ce._zod)==null?void 0:W.optout)==="optional";g.write(`const ${H} = ${_(L)};`),ue?g.write(`
6
+ `))}}const rA={major:4,minor:3,patch:6},pe=A("$ZodType",(n,e)=>{var i;var t;n??(n={}),n._zod.def=e,n._zod.bag=n._zod.bag||{},n._zod.version=rA;const r=[...n._zod.def.checks??[]];n._zod.traits.has("$ZodCheck")&&r.unshift(n);for(const s of r)for(const o of s._zod.onattach)o(n);if(r.length===0)(t=n._zod).deferred??(t.deferred=[]),(i=n._zod.deferred)==null||i.push(()=>{n._zod.run=n._zod.parse});else{const s=(a,c,u)=>{let h=Zr(a),p;for(const v of c){if(v._zod.def.when){if(!v._zod.def.when(a))continue}else if(h)continue;const g=a.issues.length,E=v._zod.check(a);if(E instanceof Promise&&(u==null?void 0:u.async)===!1)throw new Gr;if(p||E instanceof Promise)p=(p??Promise.resolve()).then(async()=>{await E,a.issues.length!==g&&(h||(h=Zr(a,g)))});else{if(a.issues.length===g)continue;h||(h=Zr(a,g))}}return p?p.then(()=>a):a},o=(a,c,u)=>{if(Zr(a))return a.aborted=!0,a;const h=s(c,r,u);if(h instanceof Promise){if(u.async===!1)throw new Gr;return h.then(p=>n._zod.parse(p,u))}return n._zod.parse(h,u)};n._zod.run=(a,c)=>{if(c.skipChecks)return n._zod.parse(a,c);if(c.direction==="backward"){const h=n._zod.parse({value:a.value,issues:[]},{...c,skipChecks:!0});return h instanceof Promise?h.then(p=>o(p,a,c)):o(h,a,c)}const u=n._zod.parse(a,c);if(u instanceof Promise){if(c.async===!1)throw new Gr;return u.then(h=>s(h,r,c))}return s(u,r,c)}}ee(n,"~standard",()=>({validate:s=>{var o;try{const a=c1(n,s);return a.success?{value:a.data}:{issues:(o=a.error)==null?void 0:o.issues}}catch{return u1(n,s).then(c=>{var u;return c.success?{value:c.data}:{issues:(u=c.error)==null?void 0:u.issues}})}},vendor:"zod",version:1}))}),sh=A("$ZodString",(n,e)=>{var t;pe.init(n,e),n._zod.pattern=[...((t=n==null?void 0:n._zod.bag)==null?void 0:t.patterns)??[]].pop()??U1(n._zod.bag),n._zod.parse=(r,i)=>{if(e.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:n}),r}}),le=A("$ZodStringFormat",(n,e)=>{Ja.init(n,e),sh.init(n,e)}),iA=A("$ZodGUID",(n,e)=>{e.pattern??(e.pattern=A1),le.init(n,e)}),sA=A("$ZodUUID",(n,e)=>{if(e.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[e.version];if(r===void 0)throw new Error(`Invalid UUID version: "${e.version}"`);e.pattern??(e.pattern=Pp(r))}else e.pattern??(e.pattern=Pp());le.init(n,e)}),oA=A("$ZodEmail",(n,e)=>{e.pattern??(e.pattern=$1),le.init(n,e)}),aA=A("$ZodURL",(n,e)=>{le.init(n,e),n._zod.check=t=>{try{const r=t.value.trim(),i=new URL(r);e.hostname&&(e.hostname.lastIndex=0,e.hostname.test(i.hostname)||t.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:e.hostname.source,input:t.value,inst:n,continue:!e.abort})),e.protocol&&(e.protocol.lastIndex=0,e.protocol.test(i.protocol.endsWith(":")?i.protocol.slice(0,-1):i.protocol)||t.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:e.protocol.source,input:t.value,inst:n,continue:!e.abort})),e.normalize?t.value=i.href:t.value=r;return}catch{t.issues.push({code:"invalid_format",format:"url",input:t.value,inst:n,continue:!e.abort})}}}),lA=A("$ZodEmoji",(n,e)=>{e.pattern??(e.pattern=I1()),le.init(n,e)}),cA=A("$ZodNanoID",(n,e)=>{e.pattern??(e.pattern=E1),le.init(n,e)}),uA=A("$ZodCUID",(n,e)=>{e.pattern??(e.pattern=b1),le.init(n,e)}),hA=A("$ZodCUID2",(n,e)=>{e.pattern??(e.pattern=w1),le.init(n,e)}),dA=A("$ZodULID",(n,e)=>{e.pattern??(e.pattern=S1),le.init(n,e)}),pA=A("$ZodXID",(n,e)=>{e.pattern??(e.pattern=_1),le.init(n,e)}),fA=A("$ZodKSUID",(n,e)=>{e.pattern??(e.pattern=k1),le.init(n,e)}),gA=A("$ZodISODateTime",(n,e)=>{e.pattern??(e.pattern=N1(e)),le.init(n,e)}),mA=A("$ZodISODate",(n,e)=>{e.pattern??(e.pattern=M1),le.init(n,e)}),vA=A("$ZodISOTime",(n,e)=>{e.pattern??(e.pattern=z1(e)),le.init(n,e)}),yA=A("$ZodISODuration",(n,e)=>{e.pattern??(e.pattern=x1),le.init(n,e)}),bA=A("$ZodIPv4",(n,e)=>{e.pattern??(e.pattern=C1),le.init(n,e),n._zod.bag.format="ipv4"}),wA=A("$ZodIPv6",(n,e)=>{e.pattern??(e.pattern=P1),le.init(n,e),n._zod.bag.format="ipv6",n._zod.check=t=>{try{new URL(`http://[${t.value}]`)}catch{t.issues.push({code:"invalid_format",format:"ipv6",input:t.value,inst:n,continue:!e.abort})}}}),SA=A("$ZodCIDRv4",(n,e)=>{e.pattern??(e.pattern=R1),le.init(n,e)}),_A=A("$ZodCIDRv6",(n,e)=>{e.pattern??(e.pattern=D1),le.init(n,e),n._zod.check=t=>{const r=t.value.split("/");try{if(r.length!==2)throw new Error;const[i,s]=r;if(!s)throw new Error;const o=Number(s);if(`${o}`!==s)throw new Error;if(o<0||o>128)throw new Error;new URL(`http://[${i}]`)}catch{t.issues.push({code:"invalid_format",format:"cidrv6",input:t.value,inst:n,continue:!e.abort})}}});function Rm(n){if(n==="")return!0;if(n.length%4!==0)return!1;try{return atob(n),!0}catch{return!1}}const kA=A("$ZodBase64",(n,e)=>{e.pattern??(e.pattern=L1),le.init(n,e),n._zod.bag.contentEncoding="base64",n._zod.check=t=>{Rm(t.value)||t.issues.push({code:"invalid_format",format:"base64",input:t.value,inst:n,continue:!e.abort})}});function EA(n){if(!xm.test(n))return!1;const e=n.replace(/[-_]/g,r=>r==="-"?"+":"/"),t=e.padEnd(Math.ceil(e.length/4)*4,"=");return Rm(t)}const xA=A("$ZodBase64URL",(n,e)=>{e.pattern??(e.pattern=xm),le.init(n,e),n._zod.bag.contentEncoding="base64url",n._zod.check=t=>{EA(t.value)||t.issues.push({code:"invalid_format",format:"base64url",input:t.value,inst:n,continue:!e.abort})}}),AA=A("$ZodE164",(n,e)=>{e.pattern??(e.pattern=O1),le.init(n,e)});function $A(n,e=null){try{const t=n.split(".");if(t.length!==3)return!1;const[r]=t;if(!r)return!1;const i=JSON.parse(atob(r));return!("typ"in i&&(i==null?void 0:i.typ)!=="JWT"||!i.alg||e&&(!("alg"in i)||i.alg!==e))}catch{return!1}}const TA=A("$ZodJWT",(n,e)=>{le.init(n,e),n._zod.check=t=>{$A(t.value,e.alg)||t.issues.push({code:"invalid_format",format:"jwt",input:t.value,inst:n,continue:!e.abort})}}),Dm=A("$ZodNumber",(n,e)=>{pe.init(n,e),n._zod.pattern=n._zod.bag.pattern??Tm,n._zod.parse=(t,r)=>{if(e.coerce)try{t.value=Number(t.value)}catch{}const i=t.value;if(typeof i=="number"&&!Number.isNaN(i)&&Number.isFinite(i))return t;const s=typeof i=="number"?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:"Infinity":void 0;return t.issues.push({expected:"number",code:"invalid_type",input:i,inst:n,...s?{received:s}:{}}),t}}),IA=A("$ZodNumberFormat",(n,e)=>{V1.init(n,e),Dm.init(n,e)}),CA=A("$ZodBoolean",(n,e)=>{pe.init(n,e),n._zod.pattern=Z1,n._zod.parse=(t,r)=>{if(e.coerce)try{t.value=!!t.value}catch{}const i=t.value;return typeof i=="boolean"||t.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:n}),t}}),PA=A("$ZodUnknown",(n,e)=>{pe.init(n,e),n._zod.parse=t=>t}),RA=A("$ZodNever",(n,e)=>{pe.init(n,e),n._zod.parse=(t,r)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:n}),t)});function Rp(n,e,t){n.issues.length&&e.issues.push(...Hr(t,n.issues)),e.value[t]=n.value}const DA=A("$ZodArray",(n,e)=>{pe.init(n,e),n._zod.parse=(t,r)=>{const i=t.value;if(!Array.isArray(i))return t.issues.push({expected:"array",code:"invalid_type",input:i,inst:n}),t;t.value=Array(i.length);const s=[];for(let o=0;o<i.length;o++){const a=i[o],c=e.element._zod.run({value:a,issues:[]},r);c instanceof Promise?s.push(c.then(u=>Rp(u,t,o))):Rp(c,t,o)}return s.length?Promise.all(s).then(()=>t):t}});function da(n,e,t,r,i){if(n.issues.length){if(i&&!(t in r))return;e.issues.push(...Hr(t,n.issues))}n.value===void 0?t in r&&(e.value[t]=void 0):e.value[t]=n.value}function Lm(n){var r,i,s,o;const e=Object.keys(n.shape);for(const a of e)if(!((o=(s=(i=(r=n.shape)==null?void 0:r[a])==null?void 0:i._zod)==null?void 0:s.traits)!=null&&o.has("$ZodType")))throw new Error(`Invalid element at key "${a}": expected a Zod schema`);const t=Jx(n.shape);return{...n,keys:e,keySet:new Set(e),numKeys:e.length,optionalKeys:new Set(t)}}function Om(n,e,t,r,i,s){const o=[],a=i.keySet,c=i.catchall._zod,u=c.def.type,h=c.optout==="optional";for(const p in e){if(a.has(p))continue;if(u==="never"){o.push(p);continue}const v=c.run({value:e[p],issues:[]},r);v instanceof Promise?n.push(v.then(g=>da(g,t,p,e,h))):da(v,t,p,e,h)}return o.length&&t.issues.push({code:"unrecognized_keys",keys:o,input:e,inst:s}),n.length?Promise.all(n).then(()=>t):t}const LA=A("$ZodObject",(n,e)=>{pe.init(n,e);const t=Object.getOwnPropertyDescriptor(e,"shape");if(!(t!=null&&t.get)){const a=e.shape;Object.defineProperty(e,"shape",{get:()=>{const c={...a};return Object.defineProperty(e,"shape",{value:c}),c}})}const r=Qu(()=>Lm(e));ee(n._zod,"propValues",()=>{const a=e.shape,c={};for(const u in a){const h=a[u]._zod;if(h.values){c[u]??(c[u]=new Set);for(const p of h.values)c[u].add(p)}}return c});const i=ha,s=e.catchall;let o;n._zod.parse=(a,c)=>{o??(o=r.value);const u=a.value;if(!i(u))return a.issues.push({expected:"object",code:"invalid_type",input:u,inst:n}),a;a.value={};const h=[],p=o.shape;for(const v of o.keys){const g=p[v],E=g._zod.optout==="optional",_=g._zod.run({value:u[v],issues:[]},c);_ instanceof Promise?h.push(_.then(C=>da(C,a,v,u,E))):da(_,a,v,u,E)}return s?Om(h,u,a,c,r.value,n):h.length?Promise.all(h).then(()=>a):a}}),OA=A("$ZodObjectJIT",(n,e)=>{LA.init(n,e);const t=n._zod.parse,r=Qu(()=>Lm(e)),i=v=>{var W;const g=new nA(["shape","payload","ctx"]),E=r.value,_=L=>{const H=Cp(L);return`shape[${H}]._zod.run({ value: input[${H}], issues: [] }, ctx)`};g.write("const input = payload.value;");const C=Object.create(null);let N=0;for(const L of E.keys)C[L]=`key_${N++}`;g.write("const newResult = {};");for(const L of E.keys){const H=C[L],F=Cp(L),ce=v[L],ue=((W=ce==null?void 0:ce._zod)==null?void 0:W.optout)==="optional";g.write(`const ${H} = ${_(L)};`),ue?g.write(`
7
7
  if (${H}.issues.length) {
8
8
  if (${F} in input) {
9
9
  payload.issues = payload.issues.concat(${H}.issues.map(iss => ({
@@ -37,35 +37,35 @@ var xb=Object.defineProperty;var Yh=n=>{throw TypeError(n)};var Ab=(n,e,t)=>e in
37
37
  newResult[${F}] = ${H}.value;
38
38
  }
39
39
 
40
- `)}g.write("payload.value = newResult;"),g.write("return payload;");const P=g.compile();return(L,H)=>P(v,L,H)};let s;const o=ha,a=!mm.jitless,u=a&&Yx.value,h=e.catchall;let p;n._zod.parse=(v,g)=>{p??(p=r.value);const E=v.value;return o(E)?a&&u&&(g==null?void 0:g.async)===!1&&g.jitless!==!0?(s||(s=i(e.shape)),v=s(v,g),h?Dm([],E,v,g,p,n):v):t(v,g):(v.issues.push({expected:"object",code:"invalid_type",input:E,inst:n}),v)}});function Pp(n,e,t,r){for(const s of n)if(s.issues.length===0)return e.value=s.value,e;const i=n.filter(s=>!Zr(s));return i.length===1?(e.value=i[0].value,i[0]):(e.issues.push({code:"invalid_union",input:e.value,inst:t,errors:n.map(s=>s.issues.map(o=>yn(o,r,vn())))}),e)}const OA=A("$ZodUnion",(n,e)=>{pe.init(n,e),ee(n._zod,"optin",()=>e.options.some(i=>i._zod.optin==="optional")?"optional":void 0),ee(n._zod,"optout",()=>e.options.some(i=>i._zod.optout==="optional")?"optional":void 0),ee(n._zod,"values",()=>{if(e.options.every(i=>i._zod.values))return new Set(e.options.flatMap(i=>Array.from(i._zod.values)))}),ee(n._zod,"pattern",()=>{if(e.options.every(i=>i._zod.pattern)){const i=e.options.map(s=>s._zod.pattern);return new RegExp(`^(${i.map(s=>Ju(s.source)).join("|")})$`)}});const t=e.options.length===1,r=e.options[0]._zod.run;n._zod.parse=(i,s)=>{if(t)return r(i,s);let o=!1;const a=[];for(const c of e.options){const u=c._zod.run({value:i.value,issues:[]},s);if(u instanceof Promise)a.push(u),o=!0;else{if(u.issues.length===0)return u;a.push(u)}}return o?Promise.all(a).then(c=>Pp(c,i,n,s)):Pp(a,i,n,s)}}),MA=A("$ZodIntersection",(n,e)=>{pe.init(n,e),n._zod.parse=(t,r)=>{const i=t.value,s=e.left._zod.run({value:i,issues:[]},r),o=e.right._zod.run({value:i,issues:[]},r);return s instanceof Promise||o instanceof Promise?Promise.all([s,o]).then(([c,u])=>Rp(t,c,u)):Rp(t,s,o)}});function Dc(n,e){if(n===e)return{valid:!0,data:n};if(n instanceof Date&&e instanceof Date&&+n==+e)return{valid:!0,data:n};if(hi(n)&&hi(e)){const t=Object.keys(e),r=Object.keys(n).filter(s=>t.indexOf(s)!==-1),i={...n,...e};for(const s of r){const o=Dc(n[s],e[s]);if(!o.valid)return{valid:!1,mergeErrorPath:[s,...o.mergeErrorPath]};i[s]=o.data}return{valid:!0,data:i}}if(Array.isArray(n)&&Array.isArray(e)){if(n.length!==e.length)return{valid:!1,mergeErrorPath:[]};const t=[];for(let r=0;r<n.length;r++){const i=n[r],s=e[r],o=Dc(i,s);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};t.push(o.data)}return{valid:!0,data:t}}return{valid:!1,mergeErrorPath:[]}}function Rp(n,e,t){const r=new Map;let i;for(const a of e.issues)if(a.code==="unrecognized_keys"){i??(i=a);for(const c of a.keys)r.has(c)||r.set(c,{}),r.get(c).l=!0}else n.issues.push(a);for(const a of t.issues)if(a.code==="unrecognized_keys")for(const c of a.keys)r.has(c)||r.set(c,{}),r.get(c).r=!0;else n.issues.push(a);const s=[...r].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(s.length&&i&&n.issues.push({...i,keys:s}),Zr(n))return n;const o=Dc(e.value,t.value);if(!o.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return n.value=o.data,n}const zA=A("$ZodRecord",(n,e)=>{pe.init(n,e),n._zod.parse=(t,r)=>{const i=t.value;if(!hi(i))return t.issues.push({expected:"record",code:"invalid_type",input:i,inst:n}),t;const s=[],o=e.keyType._zod.values;if(o){t.value={};const a=new Set;for(const u of o)if(typeof u=="string"||typeof u=="number"||typeof u=="symbol"){a.add(typeof u=="number"?u.toString():u);const h=e.valueType._zod.run({value:i[u],issues:[]},r);h instanceof Promise?s.push(h.then(p=>{p.issues.length&&t.issues.push(...Hr(u,p.issues)),t.value[u]=p.value})):(h.issues.length&&t.issues.push(...Hr(u,h.issues)),t.value[u]=h.value)}let c;for(const u in i)a.has(u)||(c=c??[],c.push(u));c&&c.length>0&&t.issues.push({code:"unrecognized_keys",input:i,inst:n,keys:c})}else{t.value={};for(const a of Reflect.ownKeys(i)){if(a==="__proto__")continue;let c=e.keyType._zod.run({value:a,issues:[]},r);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof a=="string"&&Am.test(a)&&c.issues.length){const p=e.keyType._zod.run({value:Number(a),issues:[]},r);if(p instanceof Promise)throw new Error("Async schemas not supported in object keys currently");p.issues.length===0&&(c=p)}if(c.issues.length){e.mode==="loose"?t.value[a]=i[a]:t.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(p=>yn(p,r,vn())),input:a,path:[a],inst:n});continue}const h=e.valueType._zod.run({value:i[a],issues:[]},r);h instanceof Promise?s.push(h.then(p=>{p.issues.length&&t.issues.push(...Hr(a,p.issues)),t.value[c.value]=p.value})):(h.issues.length&&t.issues.push(...Hr(a,h.issues)),t.value[c.value]=h.value)}}return s.length?Promise.all(s).then(()=>t):t}}),NA=A("$ZodEnum",(n,e)=>{pe.init(n,e);const t=vm(e.entries),r=new Set(t);n._zod.values=r,n._zod.pattern=new RegExp(`^(${t.filter(i=>Xx.has(typeof i)).map(i=>typeof i=="string"?di(i):i.toString()).join("|")})$`),n._zod.parse=(i,s)=>{const o=i.value;return r.has(o)||i.issues.push({code:"invalid_value",values:t,input:o,inst:n}),i}}),UA=A("$ZodLiteral",(n,e)=>{if(pe.init(n,e),e.values.length===0)throw new Error("Cannot create literal schema with no valid values");const t=new Set(e.values);n._zod.values=t,n._zod.pattern=new RegExp(`^(${e.values.map(r=>typeof r=="string"?di(r):r?di(r.toString()):String(r)).join("|")})$`),n._zod.parse=(r,i)=>{const s=r.value;return t.has(s)||r.issues.push({code:"invalid_value",values:e.values,input:s,inst:n}),r}}),FA=A("$ZodTransform",(n,e)=>{pe.init(n,e),n._zod.parse=(t,r)=>{if(r.direction==="backward")throw new gm(n.constructor.name);const i=e.transform(t.value,t);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(o=>(t.value=o,t));if(i instanceof Promise)throw new Br;return t.value=i,t}});function Dp(n,e){return n.issues.length&&e===void 0?{issues:[],value:void 0}:n}const Lm=A("$ZodOptional",(n,e)=>{pe.init(n,e),n._zod.optin="optional",n._zod.optout="optional",ee(n._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,void 0]):void 0),ee(n._zod,"pattern",()=>{const t=e.innerType._zod.pattern;return t?new RegExp(`^(${Ju(t.source)})?$`):void 0}),n._zod.parse=(t,r)=>{if(e.innerType._zod.optin==="optional"){const i=e.innerType._zod.run(t,r);return i instanceof Promise?i.then(s=>Dp(s,t.value)):Dp(i,t.value)}return t.value===void 0?t:e.innerType._zod.run(t,r)}}),ZA=A("$ZodExactOptional",(n,e)=>{Lm.init(n,e),ee(n._zod,"values",()=>e.innerType._zod.values),ee(n._zod,"pattern",()=>e.innerType._zod.pattern),n._zod.parse=(t,r)=>e.innerType._zod.run(t,r)}),HA=A("$ZodNullable",(n,e)=>{pe.init(n,e),ee(n._zod,"optin",()=>e.innerType._zod.optin),ee(n._zod,"optout",()=>e.innerType._zod.optout),ee(n._zod,"pattern",()=>{const t=e.innerType._zod.pattern;return t?new RegExp(`^(${Ju(t.source)}|null)$`):void 0}),ee(n._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,null]):void 0),n._zod.parse=(t,r)=>t.value===null?t:e.innerType._zod.run(t,r)}),WA=A("$ZodDefault",(n,e)=>{pe.init(n,e),n._zod.optin="optional",ee(n._zod,"values",()=>e.innerType._zod.values),n._zod.parse=(t,r)=>{if(r.direction==="backward")return e.innerType._zod.run(t,r);if(t.value===void 0)return t.value=e.defaultValue,t;const i=e.innerType._zod.run(t,r);return i instanceof Promise?i.then(s=>Lp(s,e)):Lp(i,e)}});function Lp(n,e){return n.value===void 0&&(n.value=e.defaultValue),n}const BA=A("$ZodPrefault",(n,e)=>{pe.init(n,e),n._zod.optin="optional",ee(n._zod,"values",()=>e.innerType._zod.values),n._zod.parse=(t,r)=>(r.direction==="backward"||t.value===void 0&&(t.value=e.defaultValue),e.innerType._zod.run(t,r))}),VA=A("$ZodNonOptional",(n,e)=>{pe.init(n,e),ee(n._zod,"values",()=>{const t=e.innerType._zod.values;return t?new Set([...t].filter(r=>r!==void 0)):void 0}),n._zod.parse=(t,r)=>{const i=e.innerType._zod.run(t,r);return i instanceof Promise?i.then(s=>Op(s,n)):Op(i,n)}});function Op(n,e){return!n.issues.length&&n.value===void 0&&n.issues.push({code:"invalid_type",expected:"nonoptional",input:n.value,inst:e}),n}const GA=A("$ZodCatch",(n,e)=>{pe.init(n,e),ee(n._zod,"optin",()=>e.innerType._zod.optin),ee(n._zod,"optout",()=>e.innerType._zod.optout),ee(n._zod,"values",()=>e.innerType._zod.values),n._zod.parse=(t,r)=>{if(r.direction==="backward")return e.innerType._zod.run(t,r);const i=e.innerType._zod.run(t,r);return i instanceof Promise?i.then(s=>(t.value=s.value,s.issues.length&&(t.value=e.catchValue({...t,error:{issues:s.issues.map(o=>yn(o,r,vn()))},input:t.value}),t.issues=[]),t)):(t.value=i.value,i.issues.length&&(t.value=e.catchValue({...t,error:{issues:i.issues.map(s=>yn(s,r,vn()))},input:t.value}),t.issues=[]),t)}}),jA=A("$ZodPipe",(n,e)=>{pe.init(n,e),ee(n._zod,"values",()=>e.in._zod.values),ee(n._zod,"optin",()=>e.in._zod.optin),ee(n._zod,"optout",()=>e.out._zod.optout),ee(n._zod,"propValues",()=>e.in._zod.propValues),n._zod.parse=(t,r)=>{if(r.direction==="backward"){const s=e.out._zod.run(t,r);return s instanceof Promise?s.then(o=>To(o,e.in,r)):To(s,e.in,r)}const i=e.in._zod.run(t,r);return i instanceof Promise?i.then(s=>To(s,e.out,r)):To(i,e.out,r)}});function To(n,e,t){return n.issues.length?(n.aborted=!0,n):e._zod.run({value:n.value,issues:n.issues},t)}const qA=A("$ZodReadonly",(n,e)=>{pe.init(n,e),ee(n._zod,"propValues",()=>e.innerType._zod.propValues),ee(n._zod,"values",()=>e.innerType._zod.values),ee(n._zod,"optin",()=>{var t,r;return(r=(t=e.innerType)==null?void 0:t._zod)==null?void 0:r.optin}),ee(n._zod,"optout",()=>{var t,r;return(r=(t=e.innerType)==null?void 0:t._zod)==null?void 0:r.optout}),n._zod.parse=(t,r)=>{if(r.direction==="backward")return e.innerType._zod.run(t,r);const i=e.innerType._zod.run(t,r);return i instanceof Promise?i.then(Mp):Mp(i)}});function Mp(n){return n.value=Object.freeze(n.value),n}const YA=A("$ZodCustom",(n,e)=>{Ye.init(n,e),pe.init(n,e),n._zod.parse=(t,r)=>t,n._zod.check=t=>{const r=t.value,i=e.fn(r);if(i instanceof Promise)return i.then(s=>zp(s,t,r,n));zp(i,t,r,n)}});function zp(n,e,t,r){if(!n){const i={code:"custom",input:t,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(i.params=r._zod.def.params),e.issues.push(ss(i))}}var Np;class XA{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){const r=t[0];return this._map.set(e,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){const t=this._map.get(e);return t&&typeof t=="object"&&"id"in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){const t=e._zod.parent;if(t){const r={...this.get(t)??{}};delete r.id;const i={...r,...this._map.get(e)};return Object.keys(i).length?i:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function KA(){return new XA}(Np=globalThis).__zod_globalRegistry??(Np.__zod_globalRegistry=KA());const Bi=globalThis.__zod_globalRegistry;function JA(n,e){return new n({type:"string",...O(e)})}function QA(n,e){return new n({type:"string",format:"email",check:"string_format",abort:!1,...O(e)})}function Up(n,e){return new n({type:"string",format:"guid",check:"string_format",abort:!1,...O(e)})}function e$(n,e){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,...O(e)})}function t$(n,e){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...O(e)})}function n$(n,e){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...O(e)})}function r$(n,e){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...O(e)})}function i$(n,e){return new n({type:"string",format:"url",check:"string_format",abort:!1,...O(e)})}function s$(n,e){return new n({type:"string",format:"emoji",check:"string_format",abort:!1,...O(e)})}function o$(n,e){return new n({type:"string",format:"nanoid",check:"string_format",abort:!1,...O(e)})}function a$(n,e){return new n({type:"string",format:"cuid",check:"string_format",abort:!1,...O(e)})}function l$(n,e){return new n({type:"string",format:"cuid2",check:"string_format",abort:!1,...O(e)})}function c$(n,e){return new n({type:"string",format:"ulid",check:"string_format",abort:!1,...O(e)})}function u$(n,e){return new n({type:"string",format:"xid",check:"string_format",abort:!1,...O(e)})}function h$(n,e){return new n({type:"string",format:"ksuid",check:"string_format",abort:!1,...O(e)})}function d$(n,e){return new n({type:"string",format:"ipv4",check:"string_format",abort:!1,...O(e)})}function p$(n,e){return new n({type:"string",format:"ipv6",check:"string_format",abort:!1,...O(e)})}function f$(n,e){return new n({type:"string",format:"cidrv4",check:"string_format",abort:!1,...O(e)})}function g$(n,e){return new n({type:"string",format:"cidrv6",check:"string_format",abort:!1,...O(e)})}function m$(n,e){return new n({type:"string",format:"base64",check:"string_format",abort:!1,...O(e)})}function v$(n,e){return new n({type:"string",format:"base64url",check:"string_format",abort:!1,...O(e)})}function y$(n,e){return new n({type:"string",format:"e164",check:"string_format",abort:!1,...O(e)})}function b$(n,e){return new n({type:"string",format:"jwt",check:"string_format",abort:!1,...O(e)})}function w$(n,e){return new n({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...O(e)})}function S$(n,e){return new n({type:"string",format:"date",check:"string_format",...O(e)})}function _$(n,e){return new n({type:"string",format:"time",check:"string_format",precision:null,...O(e)})}function k$(n,e){return new n({type:"string",format:"duration",check:"string_format",...O(e)})}function E$(n,e){return new n({type:"number",checks:[],...O(e)})}function x$(n,e){return new n({type:"number",check:"number_format",abort:!1,format:"safeint",...O(e)})}function A$(n,e){return new n({type:"boolean",...O(e)})}function $$(n){return new n({type:"unknown"})}function T$(n,e){return new n({type:"never",...O(e)})}function Fp(n,e){return new Tm({check:"less_than",...O(e),value:n,inclusive:!1})}function Yl(n,e){return new Tm({check:"less_than",...O(e),value:n,inclusive:!0})}function Zp(n,e){return new Im({check:"greater_than",...O(e),value:n,inclusive:!1})}function Xl(n,e){return new Im({check:"greater_than",...O(e),value:n,inclusive:!0})}function Hp(n,e){return new W1({check:"multiple_of",...O(e),value:n})}function Om(n,e){return new V1({check:"max_length",...O(e),maximum:n})}function pa(n,e){return new G1({check:"min_length",...O(e),minimum:n})}function Mm(n,e){return new j1({check:"length_equals",...O(e),length:n})}function I$(n,e){return new q1({check:"string_format",format:"regex",...O(e),pattern:n})}function C$(n){return new Y1({check:"string_format",format:"lowercase",...O(n)})}function P$(n){return new X1({check:"string_format",format:"uppercase",...O(n)})}function R$(n,e){return new K1({check:"string_format",format:"includes",...O(e),includes:n})}function D$(n,e){return new J1({check:"string_format",format:"starts_with",...O(e),prefix:n})}function L$(n,e){return new Q1({check:"string_format",format:"ends_with",...O(e),suffix:n})}function Ei(n){return new eA({check:"overwrite",tx:n})}function O$(n){return Ei(e=>e.normalize(n))}function M$(){return Ei(n=>n.trim())}function z$(){return Ei(n=>n.toLowerCase())}function N$(){return Ei(n=>n.toUpperCase())}function U$(){return Ei(n=>qx(n))}function F$(n,e,t){return new n({type:"array",element:e,...O(t)})}function Z$(n,e,t){return new n({type:"custom",check:"custom",fn:e,...O(t)})}function H$(n){const e=W$(t=>(t.addIssue=r=>{if(typeof r=="string")t.issues.push(ss(r,t.value,e._zod.def));else{const i=r;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=t.value),i.inst??(i.inst=e),i.continue??(i.continue=!e._zod.def.abort),t.issues.push(ss(i))}},n(t.value,t)));return e}function W$(n,e){const t=new Ye({check:"custom",...O(e)});return t._zod.check=n,t}function zm(n){let e=(n==null?void 0:n.target)??"draft-2020-12";return e==="draft-4"&&(e="draft-04"),e==="draft-7"&&(e="draft-07"),{processors:n.processors??{},metadataRegistry:(n==null?void 0:n.metadata)??Bi,target:e,unrepresentable:(n==null?void 0:n.unrepresentable)??"throw",override:(n==null?void 0:n.override)??(()=>{}),io:(n==null?void 0:n.io)??"output",counter:0,seen:new Map,cycles:(n==null?void 0:n.cycles)??"ref",reused:(n==null?void 0:n.reused)??"inline",external:(n==null?void 0:n.external)??void 0}}function ye(n,e,t={path:[],schemaPath:[]}){var h,p;var r;const i=n._zod.def,s=e.seen.get(n);if(s)return s.count++,t.schemaPath.includes(n)&&(s.cycle=t.path),s.schema;const o={schema:{},count:1,cycle:void 0,path:t.path};e.seen.set(n,o);const a=(p=(h=n._zod).toJSONSchema)==null?void 0:p.call(h);if(a)o.schema=a;else{const v={...t,schemaPath:[...t.schemaPath,n],path:t.path};if(n._zod.processJSONSchema)n._zod.processJSONSchema(e,o.schema,v);else{const E=o.schema,_=e.processors[i.type];if(!_)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);_(n,e,E,v)}const g=n._zod.parent;g&&(o.ref||(o.ref=g),ye(g,e,v),e.seen.get(g).isParent=!0)}const c=e.metadataRegistry.get(n);return c&&Object.assign(o.schema,c),e.io==="input"&&Me(n)&&(delete o.schema.examples,delete o.schema.default),e.io==="input"&&o.schema._prefault&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,e.seen.get(n).schema}function Nm(n,e){var o,a,c,u;const t=n.seen.get(e);if(!t)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=new Map;for(const h of n.seen.entries()){const p=(o=n.metadataRegistry.get(h[0]))==null?void 0:o.id;if(p){const v=r.get(p);if(v&&v!==h[0])throw new Error(`Duplicate schema id "${p}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(p,h[0])}}const i=h=>{var _;const p=n.target==="draft-2020-12"?"$defs":"definitions";if(n.external){const C=(_=n.external.registry.get(h[0]))==null?void 0:_.id,N=n.external.uri??(W=>W);if(C)return{ref:N(C)};const P=h[1].defId??h[1].schema.id??`schema${n.counter++}`;return h[1].defId=P,{defId:P,ref:`${N("__shared")}#/${p}/${P}`}}if(h[1]===t)return{ref:"#"};const g=`#/${p}/`,E=h[1].schema.id??`__schema${n.counter++}`;return{defId:E,ref:g+E}},s=h=>{if(h[1].schema.$ref)return;const p=h[1],{ref:v,defId:g}=i(h);p.def={...p.schema},g&&(p.defId=g);const E=p.schema;for(const _ in E)delete E[_];E.$ref=v};if(n.cycles==="throw")for(const h of n.seen.entries()){const p=h[1];if(p.cycle)throw new Error(`Cycle detected: #/${(a=p.cycle)==null?void 0:a.join("/")}/<root>
40
+ `)}g.write("payload.value = newResult;"),g.write("return payload;");const P=g.compile();return(L,H)=>P(v,L,H)};let s;const o=ha,a=!ym.jitless,u=a&&Xx.value,h=e.catchall;let p;n._zod.parse=(v,g)=>{p??(p=r.value);const E=v.value;return o(E)?a&&u&&(g==null?void 0:g.async)===!1&&g.jitless!==!0?(s||(s=i(e.shape)),v=s(v,g),h?Om([],E,v,g,p,n):v):t(v,g):(v.issues.push({expected:"object",code:"invalid_type",input:E,inst:n}),v)}});function Dp(n,e,t,r){for(const s of n)if(s.issues.length===0)return e.value=s.value,e;const i=n.filter(s=>!Zr(s));return i.length===1?(e.value=i[0].value,i[0]):(e.issues.push({code:"invalid_union",input:e.value,inst:t,errors:n.map(s=>s.issues.map(o=>yn(o,r,vn())))}),e)}const MA=A("$ZodUnion",(n,e)=>{pe.init(n,e),ee(n._zod,"optin",()=>e.options.some(i=>i._zod.optin==="optional")?"optional":void 0),ee(n._zod,"optout",()=>e.options.some(i=>i._zod.optout==="optional")?"optional":void 0),ee(n._zod,"values",()=>{if(e.options.every(i=>i._zod.values))return new Set(e.options.flatMap(i=>Array.from(i._zod.values)))}),ee(n._zod,"pattern",()=>{if(e.options.every(i=>i._zod.pattern)){const i=e.options.map(s=>s._zod.pattern);return new RegExp(`^(${i.map(s=>th(s.source)).join("|")})$`)}});const t=e.options.length===1,r=e.options[0]._zod.run;n._zod.parse=(i,s)=>{if(t)return r(i,s);let o=!1;const a=[];for(const c of e.options){const u=c._zod.run({value:i.value,issues:[]},s);if(u instanceof Promise)a.push(u),o=!0;else{if(u.issues.length===0)return u;a.push(u)}}return o?Promise.all(a).then(c=>Dp(c,i,n,s)):Dp(a,i,n,s)}}),zA=A("$ZodIntersection",(n,e)=>{pe.init(n,e),n._zod.parse=(t,r)=>{const i=t.value,s=e.left._zod.run({value:i,issues:[]},r),o=e.right._zod.run({value:i,issues:[]},r);return s instanceof Promise||o instanceof Promise?Promise.all([s,o]).then(([c,u])=>Lp(t,c,u)):Lp(t,s,o)}});function Mc(n,e){if(n===e)return{valid:!0,data:n};if(n instanceof Date&&e instanceof Date&&+n==+e)return{valid:!0,data:n};if(hi(n)&&hi(e)){const t=Object.keys(e),r=Object.keys(n).filter(s=>t.indexOf(s)!==-1),i={...n,...e};for(const s of r){const o=Mc(n[s],e[s]);if(!o.valid)return{valid:!1,mergeErrorPath:[s,...o.mergeErrorPath]};i[s]=o.data}return{valid:!0,data:i}}if(Array.isArray(n)&&Array.isArray(e)){if(n.length!==e.length)return{valid:!1,mergeErrorPath:[]};const t=[];for(let r=0;r<n.length;r++){const i=n[r],s=e[r],o=Mc(i,s);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};t.push(o.data)}return{valid:!0,data:t}}return{valid:!1,mergeErrorPath:[]}}function Lp(n,e,t){const r=new Map;let i;for(const a of e.issues)if(a.code==="unrecognized_keys"){i??(i=a);for(const c of a.keys)r.has(c)||r.set(c,{}),r.get(c).l=!0}else n.issues.push(a);for(const a of t.issues)if(a.code==="unrecognized_keys")for(const c of a.keys)r.has(c)||r.set(c,{}),r.get(c).r=!0;else n.issues.push(a);const s=[...r].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(s.length&&i&&n.issues.push({...i,keys:s}),Zr(n))return n;const o=Mc(e.value,t.value);if(!o.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return n.value=o.data,n}const NA=A("$ZodRecord",(n,e)=>{pe.init(n,e),n._zod.parse=(t,r)=>{const i=t.value;if(!hi(i))return t.issues.push({expected:"record",code:"invalid_type",input:i,inst:n}),t;const s=[],o=e.keyType._zod.values;if(o){t.value={};const a=new Set;for(const u of o)if(typeof u=="string"||typeof u=="number"||typeof u=="symbol"){a.add(typeof u=="number"?u.toString():u);const h=e.valueType._zod.run({value:i[u],issues:[]},r);h instanceof Promise?s.push(h.then(p=>{p.issues.length&&t.issues.push(...Hr(u,p.issues)),t.value[u]=p.value})):(h.issues.length&&t.issues.push(...Hr(u,h.issues)),t.value[u]=h.value)}let c;for(const u in i)a.has(u)||(c=c??[],c.push(u));c&&c.length>0&&t.issues.push({code:"unrecognized_keys",input:i,inst:n,keys:c})}else{t.value={};for(const a of Reflect.ownKeys(i)){if(a==="__proto__")continue;let c=e.keyType._zod.run({value:a,issues:[]},r);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof a=="string"&&Tm.test(a)&&c.issues.length){const p=e.keyType._zod.run({value:Number(a),issues:[]},r);if(p instanceof Promise)throw new Error("Async schemas not supported in object keys currently");p.issues.length===0&&(c=p)}if(c.issues.length){e.mode==="loose"?t.value[a]=i[a]:t.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(p=>yn(p,r,vn())),input:a,path:[a],inst:n});continue}const h=e.valueType._zod.run({value:i[a],issues:[]},r);h instanceof Promise?s.push(h.then(p=>{p.issues.length&&t.issues.push(...Hr(a,p.issues)),t.value[c.value]=p.value})):(h.issues.length&&t.issues.push(...Hr(a,h.issues)),t.value[c.value]=h.value)}}return s.length?Promise.all(s).then(()=>t):t}}),UA=A("$ZodEnum",(n,e)=>{pe.init(n,e);const t=bm(e.entries),r=new Set(t);n._zod.values=r,n._zod.pattern=new RegExp(`^(${t.filter(i=>Kx.has(typeof i)).map(i=>typeof i=="string"?di(i):i.toString()).join("|")})$`),n._zod.parse=(i,s)=>{const o=i.value;return r.has(o)||i.issues.push({code:"invalid_value",values:t,input:o,inst:n}),i}}),FA=A("$ZodLiteral",(n,e)=>{if(pe.init(n,e),e.values.length===0)throw new Error("Cannot create literal schema with no valid values");const t=new Set(e.values);n._zod.values=t,n._zod.pattern=new RegExp(`^(${e.values.map(r=>typeof r=="string"?di(r):r?di(r.toString()):String(r)).join("|")})$`),n._zod.parse=(r,i)=>{const s=r.value;return t.has(s)||r.issues.push({code:"invalid_value",values:e.values,input:s,inst:n}),r}}),ZA=A("$ZodTransform",(n,e)=>{pe.init(n,e),n._zod.parse=(t,r)=>{if(r.direction==="backward")throw new vm(n.constructor.name);const i=e.transform(t.value,t);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(o=>(t.value=o,t));if(i instanceof Promise)throw new Gr;return t.value=i,t}});function Op(n,e){return n.issues.length&&e===void 0?{issues:[],value:void 0}:n}const Mm=A("$ZodOptional",(n,e)=>{pe.init(n,e),n._zod.optin="optional",n._zod.optout="optional",ee(n._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,void 0]):void 0),ee(n._zod,"pattern",()=>{const t=e.innerType._zod.pattern;return t?new RegExp(`^(${th(t.source)})?$`):void 0}),n._zod.parse=(t,r)=>{if(e.innerType._zod.optin==="optional"){const i=e.innerType._zod.run(t,r);return i instanceof Promise?i.then(s=>Op(s,t.value)):Op(i,t.value)}return t.value===void 0?t:e.innerType._zod.run(t,r)}}),HA=A("$ZodExactOptional",(n,e)=>{Mm.init(n,e),ee(n._zod,"values",()=>e.innerType._zod.values),ee(n._zod,"pattern",()=>e.innerType._zod.pattern),n._zod.parse=(t,r)=>e.innerType._zod.run(t,r)}),WA=A("$ZodNullable",(n,e)=>{pe.init(n,e),ee(n._zod,"optin",()=>e.innerType._zod.optin),ee(n._zod,"optout",()=>e.innerType._zod.optout),ee(n._zod,"pattern",()=>{const t=e.innerType._zod.pattern;return t?new RegExp(`^(${th(t.source)}|null)$`):void 0}),ee(n._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,null]):void 0),n._zod.parse=(t,r)=>t.value===null?t:e.innerType._zod.run(t,r)}),GA=A("$ZodDefault",(n,e)=>{pe.init(n,e),n._zod.optin="optional",ee(n._zod,"values",()=>e.innerType._zod.values),n._zod.parse=(t,r)=>{if(r.direction==="backward")return e.innerType._zod.run(t,r);if(t.value===void 0)return t.value=e.defaultValue,t;const i=e.innerType._zod.run(t,r);return i instanceof Promise?i.then(s=>Mp(s,e)):Mp(i,e)}});function Mp(n,e){return n.value===void 0&&(n.value=e.defaultValue),n}const VA=A("$ZodPrefault",(n,e)=>{pe.init(n,e),n._zod.optin="optional",ee(n._zod,"values",()=>e.innerType._zod.values),n._zod.parse=(t,r)=>(r.direction==="backward"||t.value===void 0&&(t.value=e.defaultValue),e.innerType._zod.run(t,r))}),BA=A("$ZodNonOptional",(n,e)=>{pe.init(n,e),ee(n._zod,"values",()=>{const t=e.innerType._zod.values;return t?new Set([...t].filter(r=>r!==void 0)):void 0}),n._zod.parse=(t,r)=>{const i=e.innerType._zod.run(t,r);return i instanceof Promise?i.then(s=>zp(s,n)):zp(i,n)}});function zp(n,e){return!n.issues.length&&n.value===void 0&&n.issues.push({code:"invalid_type",expected:"nonoptional",input:n.value,inst:e}),n}const jA=A("$ZodCatch",(n,e)=>{pe.init(n,e),ee(n._zod,"optin",()=>e.innerType._zod.optin),ee(n._zod,"optout",()=>e.innerType._zod.optout),ee(n._zod,"values",()=>e.innerType._zod.values),n._zod.parse=(t,r)=>{if(r.direction==="backward")return e.innerType._zod.run(t,r);const i=e.innerType._zod.run(t,r);return i instanceof Promise?i.then(s=>(t.value=s.value,s.issues.length&&(t.value=e.catchValue({...t,error:{issues:s.issues.map(o=>yn(o,r,vn()))},input:t.value}),t.issues=[]),t)):(t.value=i.value,i.issues.length&&(t.value=e.catchValue({...t,error:{issues:i.issues.map(s=>yn(s,r,vn()))},input:t.value}),t.issues=[]),t)}}),qA=A("$ZodPipe",(n,e)=>{pe.init(n,e),ee(n._zod,"values",()=>e.in._zod.values),ee(n._zod,"optin",()=>e.in._zod.optin),ee(n._zod,"optout",()=>e.out._zod.optout),ee(n._zod,"propValues",()=>e.in._zod.propValues),n._zod.parse=(t,r)=>{if(r.direction==="backward"){const s=e.out._zod.run(t,r);return s instanceof Promise?s.then(o=>To(o,e.in,r)):To(s,e.in,r)}const i=e.in._zod.run(t,r);return i instanceof Promise?i.then(s=>To(s,e.out,r)):To(i,e.out,r)}});function To(n,e,t){return n.issues.length?(n.aborted=!0,n):e._zod.run({value:n.value,issues:n.issues},t)}const YA=A("$ZodReadonly",(n,e)=>{pe.init(n,e),ee(n._zod,"propValues",()=>e.innerType._zod.propValues),ee(n._zod,"values",()=>e.innerType._zod.values),ee(n._zod,"optin",()=>{var t,r;return(r=(t=e.innerType)==null?void 0:t._zod)==null?void 0:r.optin}),ee(n._zod,"optout",()=>{var t,r;return(r=(t=e.innerType)==null?void 0:t._zod)==null?void 0:r.optout}),n._zod.parse=(t,r)=>{if(r.direction==="backward")return e.innerType._zod.run(t,r);const i=e.innerType._zod.run(t,r);return i instanceof Promise?i.then(Np):Np(i)}});function Np(n){return n.value=Object.freeze(n.value),n}const XA=A("$ZodCustom",(n,e)=>{Ye.init(n,e),pe.init(n,e),n._zod.parse=(t,r)=>t,n._zod.check=t=>{const r=t.value,i=e.fn(r);if(i instanceof Promise)return i.then(s=>Up(s,t,r,n));Up(i,t,r,n)}});function Up(n,e,t,r){if(!n){const i={code:"custom",input:t,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(i.params=r._zod.def.params),e.issues.push(ss(i))}}var Fp;class KA{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){const r=t[0];return this._map.set(e,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){const t=this._map.get(e);return t&&typeof t=="object"&&"id"in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){const t=e._zod.parent;if(t){const r={...this.get(t)??{}};delete r.id;const i={...r,...this._map.get(e)};return Object.keys(i).length?i:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function JA(){return new KA}(Fp=globalThis).__zod_globalRegistry??(Fp.__zod_globalRegistry=JA());const Gi=globalThis.__zod_globalRegistry;function QA(n,e){return new n({type:"string",...O(e)})}function e$(n,e){return new n({type:"string",format:"email",check:"string_format",abort:!1,...O(e)})}function Zp(n,e){return new n({type:"string",format:"guid",check:"string_format",abort:!1,...O(e)})}function t$(n,e){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,...O(e)})}function n$(n,e){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...O(e)})}function r$(n,e){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...O(e)})}function i$(n,e){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...O(e)})}function s$(n,e){return new n({type:"string",format:"url",check:"string_format",abort:!1,...O(e)})}function o$(n,e){return new n({type:"string",format:"emoji",check:"string_format",abort:!1,...O(e)})}function a$(n,e){return new n({type:"string",format:"nanoid",check:"string_format",abort:!1,...O(e)})}function l$(n,e){return new n({type:"string",format:"cuid",check:"string_format",abort:!1,...O(e)})}function c$(n,e){return new n({type:"string",format:"cuid2",check:"string_format",abort:!1,...O(e)})}function u$(n,e){return new n({type:"string",format:"ulid",check:"string_format",abort:!1,...O(e)})}function h$(n,e){return new n({type:"string",format:"xid",check:"string_format",abort:!1,...O(e)})}function d$(n,e){return new n({type:"string",format:"ksuid",check:"string_format",abort:!1,...O(e)})}function p$(n,e){return new n({type:"string",format:"ipv4",check:"string_format",abort:!1,...O(e)})}function f$(n,e){return new n({type:"string",format:"ipv6",check:"string_format",abort:!1,...O(e)})}function g$(n,e){return new n({type:"string",format:"cidrv4",check:"string_format",abort:!1,...O(e)})}function m$(n,e){return new n({type:"string",format:"cidrv6",check:"string_format",abort:!1,...O(e)})}function v$(n,e){return new n({type:"string",format:"base64",check:"string_format",abort:!1,...O(e)})}function y$(n,e){return new n({type:"string",format:"base64url",check:"string_format",abort:!1,...O(e)})}function b$(n,e){return new n({type:"string",format:"e164",check:"string_format",abort:!1,...O(e)})}function w$(n,e){return new n({type:"string",format:"jwt",check:"string_format",abort:!1,...O(e)})}function S$(n,e){return new n({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...O(e)})}function _$(n,e){return new n({type:"string",format:"date",check:"string_format",...O(e)})}function k$(n,e){return new n({type:"string",format:"time",check:"string_format",precision:null,...O(e)})}function E$(n,e){return new n({type:"string",format:"duration",check:"string_format",...O(e)})}function x$(n,e){return new n({type:"number",checks:[],...O(e)})}function A$(n,e){return new n({type:"number",check:"number_format",abort:!1,format:"safeint",...O(e)})}function $$(n,e){return new n({type:"boolean",...O(e)})}function T$(n){return new n({type:"unknown"})}function I$(n,e){return new n({type:"never",...O(e)})}function Hp(n,e){return new Cm({check:"less_than",...O(e),value:n,inclusive:!1})}function Jl(n,e){return new Cm({check:"less_than",...O(e),value:n,inclusive:!0})}function Wp(n,e){return new Pm({check:"greater_than",...O(e),value:n,inclusive:!1})}function Ql(n,e){return new Pm({check:"greater_than",...O(e),value:n,inclusive:!0})}function Gp(n,e){return new G1({check:"multiple_of",...O(e),value:n})}function zm(n,e){return new B1({check:"max_length",...O(e),maximum:n})}function pa(n,e){return new j1({check:"min_length",...O(e),minimum:n})}function Nm(n,e){return new q1({check:"length_equals",...O(e),length:n})}function C$(n,e){return new Y1({check:"string_format",format:"regex",...O(e),pattern:n})}function P$(n){return new X1({check:"string_format",format:"lowercase",...O(n)})}function R$(n){return new K1({check:"string_format",format:"uppercase",...O(n)})}function D$(n,e){return new J1({check:"string_format",format:"includes",...O(e),includes:n})}function L$(n,e){return new Q1({check:"string_format",format:"starts_with",...O(e),prefix:n})}function O$(n,e){return new eA({check:"string_format",format:"ends_with",...O(e),suffix:n})}function Ei(n){return new tA({check:"overwrite",tx:n})}function M$(n){return Ei(e=>e.normalize(n))}function z$(){return Ei(n=>n.trim())}function N$(){return Ei(n=>n.toLowerCase())}function U$(){return Ei(n=>n.toUpperCase())}function F$(){return Ei(n=>Yx(n))}function Z$(n,e,t){return new n({type:"array",element:e,...O(t)})}function H$(n,e,t){return new n({type:"custom",check:"custom",fn:e,...O(t)})}function W$(n){const e=G$(t=>(t.addIssue=r=>{if(typeof r=="string")t.issues.push(ss(r,t.value,e._zod.def));else{const i=r;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=t.value),i.inst??(i.inst=e),i.continue??(i.continue=!e._zod.def.abort),t.issues.push(ss(i))}},n(t.value,t)));return e}function G$(n,e){const t=new Ye({check:"custom",...O(e)});return t._zod.check=n,t}function Um(n){let e=(n==null?void 0:n.target)??"draft-2020-12";return e==="draft-4"&&(e="draft-04"),e==="draft-7"&&(e="draft-07"),{processors:n.processors??{},metadataRegistry:(n==null?void 0:n.metadata)??Gi,target:e,unrepresentable:(n==null?void 0:n.unrepresentable)??"throw",override:(n==null?void 0:n.override)??(()=>{}),io:(n==null?void 0:n.io)??"output",counter:0,seen:new Map,cycles:(n==null?void 0:n.cycles)??"ref",reused:(n==null?void 0:n.reused)??"inline",external:(n==null?void 0:n.external)??void 0}}function ye(n,e,t={path:[],schemaPath:[]}){var h,p;var r;const i=n._zod.def,s=e.seen.get(n);if(s)return s.count++,t.schemaPath.includes(n)&&(s.cycle=t.path),s.schema;const o={schema:{},count:1,cycle:void 0,path:t.path};e.seen.set(n,o);const a=(p=(h=n._zod).toJSONSchema)==null?void 0:p.call(h);if(a)o.schema=a;else{const v={...t,schemaPath:[...t.schemaPath,n],path:t.path};if(n._zod.processJSONSchema)n._zod.processJSONSchema(e,o.schema,v);else{const E=o.schema,_=e.processors[i.type];if(!_)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);_(n,e,E,v)}const g=n._zod.parent;g&&(o.ref||(o.ref=g),ye(g,e,v),e.seen.get(g).isParent=!0)}const c=e.metadataRegistry.get(n);return c&&Object.assign(o.schema,c),e.io==="input"&&Me(n)&&(delete o.schema.examples,delete o.schema.default),e.io==="input"&&o.schema._prefault&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,e.seen.get(n).schema}function Fm(n,e){var o,a,c,u;const t=n.seen.get(e);if(!t)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=new Map;for(const h of n.seen.entries()){const p=(o=n.metadataRegistry.get(h[0]))==null?void 0:o.id;if(p){const v=r.get(p);if(v&&v!==h[0])throw new Error(`Duplicate schema id "${p}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(p,h[0])}}const i=h=>{var _;const p=n.target==="draft-2020-12"?"$defs":"definitions";if(n.external){const C=(_=n.external.registry.get(h[0]))==null?void 0:_.id,N=n.external.uri??(W=>W);if(C)return{ref:N(C)};const P=h[1].defId??h[1].schema.id??`schema${n.counter++}`;return h[1].defId=P,{defId:P,ref:`${N("__shared")}#/${p}/${P}`}}if(h[1]===t)return{ref:"#"};const g=`#/${p}/`,E=h[1].schema.id??`__schema${n.counter++}`;return{defId:E,ref:g+E}},s=h=>{if(h[1].schema.$ref)return;const p=h[1],{ref:v,defId:g}=i(h);p.def={...p.schema},g&&(p.defId=g);const E=p.schema;for(const _ in E)delete E[_];E.$ref=v};if(n.cycles==="throw")for(const h of n.seen.entries()){const p=h[1];if(p.cycle)throw new Error(`Cycle detected: #/${(a=p.cycle)==null?void 0:a.join("/")}/<root>
41
41
 
42
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const h of n.seen.entries()){const p=h[1];if(e===h[0]){s(h);continue}if(n.external){const g=(c=n.external.registry.get(h[0]))==null?void 0:c.id;if(e!==h[0]&&g){s(h);continue}}if((u=n.metadataRegistry.get(h[0]))==null?void 0:u.id){s(h);continue}if(p.cycle){s(h);continue}if(p.count>1&&n.reused==="ref"){s(h);continue}}}function Um(n,e){var o,a,c;const t=n.seen.get(e);if(!t)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=u=>{const h=n.seen.get(u);if(h.ref===null)return;const p=h.def??h.schema,v={...p},g=h.ref;if(h.ref=null,g){r(g);const _=n.seen.get(g),C=_.schema;if(C.$ref&&(n.target==="draft-07"||n.target==="draft-04"||n.target==="openapi-3.0")?(p.allOf=p.allOf??[],p.allOf.push(C)):Object.assign(p,C),Object.assign(p,v),u._zod.parent===g)for(const P in p)P==="$ref"||P==="allOf"||P in v||delete p[P];if(C.$ref&&_.def)for(const P in p)P==="$ref"||P==="allOf"||P in _.def&&JSON.stringify(p[P])===JSON.stringify(_.def[P])&&delete p[P]}const E=u._zod.parent;if(E&&E!==g){r(E);const _=n.seen.get(E);if(_!=null&&_.schema.$ref&&(p.$ref=_.schema.$ref,_.def))for(const C in p)C==="$ref"||C==="allOf"||C in _.def&&JSON.stringify(p[C])===JSON.stringify(_.def[C])&&delete p[C]}n.override({zodSchema:u,jsonSchema:p,path:h.path??[]})};for(const u of[...n.seen.entries()].reverse())r(u[0]);const i={};if(n.target==="draft-2020-12"?i.$schema="https://json-schema.org/draft/2020-12/schema":n.target==="draft-07"?i.$schema="http://json-schema.org/draft-07/schema#":n.target==="draft-04"?i.$schema="http://json-schema.org/draft-04/schema#":n.target,(o=n.external)!=null&&o.uri){const u=(a=n.external.registry.get(e))==null?void 0:a.id;if(!u)throw new Error("Schema is missing an `id` property");i.$id=n.external.uri(u)}Object.assign(i,t.def??t.schema);const s=((c=n.external)==null?void 0:c.defs)??{};for(const u of n.seen.entries()){const h=u[1];h.def&&h.defId&&(s[h.defId]=h.def)}n.external||Object.keys(s).length>0&&(n.target==="draft-2020-12"?i.$defs=s:i.definitions=s);try{const u=JSON.parse(JSON.stringify(i));return Object.defineProperty(u,"~standard",{value:{...e["~standard"],jsonSchema:{input:fa(e,"input",n.processors),output:fa(e,"output",n.processors)}},enumerable:!1,writable:!1}),u}catch{throw new Error("Error converting schema to JSON.")}}function Me(n,e){const t=e??{seen:new Set};if(t.seen.has(n))return!1;t.seen.add(n);const r=n._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return Me(r.element,t);if(r.type==="set")return Me(r.valueType,t);if(r.type==="lazy")return Me(r.getter(),t);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault")return Me(r.innerType,t);if(r.type==="intersection")return Me(r.left,t)||Me(r.right,t);if(r.type==="record"||r.type==="map")return Me(r.keyType,t)||Me(r.valueType,t);if(r.type==="pipe")return Me(r.in,t)||Me(r.out,t);if(r.type==="object"){for(const i in r.shape)if(Me(r.shape[i],t))return!0;return!1}if(r.type==="union"){for(const i of r.options)if(Me(i,t))return!0;return!1}if(r.type==="tuple"){for(const i of r.items)if(Me(i,t))return!0;return!!(r.rest&&Me(r.rest,t))}return!1}const B$=(n,e={})=>t=>{const r=zm({...t,processors:e});return ye(n,r),Nm(r,n),Um(r,n)},fa=(n,e,t={})=>r=>{const{libraryOptions:i,target:s}=r??{},o=zm({...i??{},target:s,io:e,processors:t});return ye(n,o),Nm(o,n),Um(o,n)},V$={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},G$=(n,e,t,r)=>{const i=t;i.type="string";const{minimum:s,maximum:o,format:a,patterns:c,contentEncoding:u}=n._zod.bag;if(typeof s=="number"&&(i.minLength=s),typeof o=="number"&&(i.maxLength=o),a&&(i.format=V$[a]??a,i.format===""&&delete i.format,a==="time"&&delete i.format),u&&(i.contentEncoding=u),c&&c.size>0){const h=[...c];h.length===1?i.pattern=h[0].source:h.length>1&&(i.allOf=[...h.map(p=>({...e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"?{type:"string"}:{},pattern:p.source}))])}},j$=(n,e,t,r)=>{const i=t,{minimum:s,maximum:o,format:a,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:h}=n._zod.bag;typeof a=="string"&&a.includes("int")?i.type="integer":i.type="number",typeof h=="number"&&(e.target==="draft-04"||e.target==="openapi-3.0"?(i.minimum=h,i.exclusiveMinimum=!0):i.exclusiveMinimum=h),typeof s=="number"&&(i.minimum=s,typeof h=="number"&&e.target!=="draft-04"&&(h>=s?delete i.minimum:delete i.exclusiveMinimum)),typeof u=="number"&&(e.target==="draft-04"||e.target==="openapi-3.0"?(i.maximum=u,i.exclusiveMaximum=!0):i.exclusiveMaximum=u),typeof o=="number"&&(i.maximum=o,typeof u=="number"&&e.target!=="draft-04"&&(u<=o?delete i.maximum:delete i.exclusiveMaximum)),typeof c=="number"&&(i.multipleOf=c)},q$=(n,e,t,r)=>{t.type="boolean"},Y$=(n,e,t,r)=>{t.not={}},X$=(n,e,t,r)=>{},K$=(n,e,t,r)=>{const i=n._zod.def,s=vm(i.entries);s.every(o=>typeof o=="number")&&(t.type="number"),s.every(o=>typeof o=="string")&&(t.type="string"),t.enum=s},J$=(n,e,t,r)=>{const i=n._zod.def,s=[];for(const o of i.values)if(o===void 0){if(e.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof o=="bigint"){if(e.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");s.push(Number(o))}else s.push(o);if(s.length!==0)if(s.length===1){const o=s[0];t.type=o===null?"null":typeof o,e.target==="draft-04"||e.target==="openapi-3.0"?t.enum=[o]:t.const=o}else s.every(o=>typeof o=="number")&&(t.type="number"),s.every(o=>typeof o=="string")&&(t.type="string"),s.every(o=>typeof o=="boolean")&&(t.type="boolean"),s.every(o=>o===null)&&(t.type="null"),t.enum=s},Q$=(n,e,t,r)=>{if(e.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},eT=(n,e,t,r)=>{if(e.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},tT=(n,e,t,r)=>{const i=t,s=n._zod.def,{minimum:o,maximum:a}=n._zod.bag;typeof o=="number"&&(i.minItems=o),typeof a=="number"&&(i.maxItems=a),i.type="array",i.items=ye(s.element,e,{...r,path:[...r.path,"items"]})},nT=(n,e,t,r)=>{var u;const i=t,s=n._zod.def;i.type="object",i.properties={};const o=s.shape;for(const h in o)i.properties[h]=ye(o[h],e,{...r,path:[...r.path,"properties",h]});const a=new Set(Object.keys(o)),c=new Set([...a].filter(h=>{const p=s.shape[h]._zod;return e.io==="input"?p.optin===void 0:p.optout===void 0}));c.size>0&&(i.required=Array.from(c)),((u=s.catchall)==null?void 0:u._zod.def.type)==="never"?i.additionalProperties=!1:s.catchall?s.catchall&&(i.additionalProperties=ye(s.catchall,e,{...r,path:[...r.path,"additionalProperties"]})):e.io==="output"&&(i.additionalProperties=!1)},rT=(n,e,t,r)=>{const i=n._zod.def,s=i.inclusive===!1,o=i.options.map((a,c)=>ye(a,e,{...r,path:[...r.path,s?"oneOf":"anyOf",c]}));s?t.oneOf=o:t.anyOf=o},iT=(n,e,t,r)=>{const i=n._zod.def,s=ye(i.left,e,{...r,path:[...r.path,"allOf",0]}),o=ye(i.right,e,{...r,path:[...r.path,"allOf",1]}),a=u=>"allOf"in u&&Object.keys(u).length===1,c=[...a(s)?s.allOf:[s],...a(o)?o.allOf:[o]];t.allOf=c},sT=(n,e,t,r)=>{const i=t,s=n._zod.def;i.type="object";const o=s.keyType,a=o._zod.bag,c=a==null?void 0:a.patterns;if(s.mode==="loose"&&c&&c.size>0){const h=ye(s.valueType,e,{...r,path:[...r.path,"patternProperties","*"]});i.patternProperties={};for(const p of c)i.patternProperties[p.source]=h}else(e.target==="draft-07"||e.target==="draft-2020-12")&&(i.propertyNames=ye(s.keyType,e,{...r,path:[...r.path,"propertyNames"]})),i.additionalProperties=ye(s.valueType,e,{...r,path:[...r.path,"additionalProperties"]});const u=o._zod.values;if(u){const h=[...u].filter(p=>typeof p=="string"||typeof p=="number");h.length>0&&(i.required=h)}},oT=(n,e,t,r)=>{const i=n._zod.def,s=ye(i.innerType,e,r),o=e.seen.get(n);e.target==="openapi-3.0"?(o.ref=i.innerType,t.nullable=!0):t.anyOf=[s,{type:"null"}]},aT=(n,e,t,r)=>{const i=n._zod.def;ye(i.innerType,e,r);const s=e.seen.get(n);s.ref=i.innerType},lT=(n,e,t,r)=>{const i=n._zod.def;ye(i.innerType,e,r);const s=e.seen.get(n);s.ref=i.innerType,t.default=JSON.parse(JSON.stringify(i.defaultValue))},cT=(n,e,t,r)=>{const i=n._zod.def;ye(i.innerType,e,r);const s=e.seen.get(n);s.ref=i.innerType,e.io==="input"&&(t._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},uT=(n,e,t,r)=>{const i=n._zod.def;ye(i.innerType,e,r);const s=e.seen.get(n);s.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}t.default=o},hT=(n,e,t,r)=>{const i=n._zod.def,s=e.io==="input"?i.in._zod.def.type==="transform"?i.out:i.in:i.out;ye(s,e,r);const o=e.seen.get(n);o.ref=s},dT=(n,e,t,r)=>{const i=n._zod.def;ye(i.innerType,e,r);const s=e.seen.get(n);s.ref=i.innerType,t.readOnly=!0},Fm=(n,e,t,r)=>{const i=n._zod.def;ye(i.innerType,e,r);const s=e.seen.get(n);s.ref=i.innerType},pT=A("ZodISODateTime",(n,e)=>{fA.init(n,e),ge.init(n,e)});function fT(n){return w$(pT,n)}const gT=A("ZodISODate",(n,e)=>{gA.init(n,e),ge.init(n,e)});function mT(n){return S$(gT,n)}const vT=A("ZodISOTime",(n,e)=>{mA.init(n,e),ge.init(n,e)});function yT(n){return _$(vT,n)}const bT=A("ZodISODuration",(n,e)=>{vA.init(n,e),ge.init(n,e)});function wT(n){return k$(bT,n)}const Zm=(n,e)=>{Sm.init(n,e),n.name="ZodError",Object.defineProperties(n,{format:{value:t=>a1(n,t)},flatten:{value:t=>o1(n,t)},addIssue:{value:t=>{n.issues.push(t),n.message=JSON.stringify(n.issues,Rc,2)}},addIssues:{value:t=>{n.issues.push(...t),n.message=JSON.stringify(n.issues,Rc,2)}},isEmpty:{get(){return n.issues.length===0}}})},Wp=A("ZodError",Zm),ut=A("ZodError",Zm,{Parent:Error}),ST=eh(ut),_T=th(ut),kT=Xa(ut),ET=Ka(ut),xT=u1(ut),AT=h1(ut),$T=d1(ut),TT=p1(ut),IT=f1(ut),CT=g1(ut),PT=m1(ut),RT=v1(ut),fe=A("ZodType",(n,e)=>(pe.init(n,e),Object.assign(n["~standard"],{jsonSchema:{input:fa(n,"input"),output:fa(n,"output")}}),n.toJSONSchema=B$(n,{}),n.def=e,n.type=e.type,Object.defineProperty(n,"_def",{value:e}),n.check=(...t)=>n.clone(En(e,{checks:[...e.checks??[],...t.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0}),n.with=n.check,n.clone=(t,r)=>xn(n,t,r),n.brand=()=>n,n.register=(t,r)=>(t.add(n,r),n),n.parse=(t,r)=>ST(n,t,r,{callee:n.parse}),n.safeParse=(t,r)=>kT(n,t,r),n.parseAsync=async(t,r)=>_T(n,t,r,{callee:n.parseAsync}),n.safeParseAsync=async(t,r)=>ET(n,t,r),n.spa=n.safeParseAsync,n.encode=(t,r)=>xT(n,t,r),n.decode=(t,r)=>AT(n,t,r),n.encodeAsync=async(t,r)=>$T(n,t,r),n.decodeAsync=async(t,r)=>TT(n,t,r),n.safeEncode=(t,r)=>IT(n,t,r),n.safeDecode=(t,r)=>CT(n,t,r),n.safeEncodeAsync=async(t,r)=>PT(n,t,r),n.safeDecodeAsync=async(t,r)=>RT(n,t,r),n.refine=(t,r)=>n.check(kI(t,r)),n.superRefine=t=>n.check(EI(t)),n.overwrite=t=>n.check(Ei(t)),n.optional=()=>Gp(n),n.exactOptional=()=>uI(n),n.nullable=()=>jp(n),n.nullish=()=>Gp(jp(n)),n.nonoptional=t=>mI(n,t),n.array=()=>D(n),n.or=t=>B([n,t]),n.and=t=>Qa(n,t),n.transform=t=>qp(n,lI(t)),n.default=t=>pI(n,t),n.prefault=t=>gI(n,t),n.catch=t=>yI(n,t),n.pipe=t=>qp(n,t),n.readonly=()=>SI(n),n.describe=t=>{const r=n.clone();return Bi.add(r,{description:t}),r},Object.defineProperty(n,"description",{get(){var t;return(t=Bi.get(n))==null?void 0:t.description},configurable:!0}),n.meta=(...t)=>{if(t.length===0)return Bi.get(n);const r=n.clone();return Bi.add(r,t[0]),r},n.isOptional=()=>n.safeParse(void 0).success,n.isNullable=()=>n.safeParse(null).success,n.apply=t=>t(n),n)),Hm=A("_ZodString",(n,e)=>{nh.init(n,e),fe.init(n,e),n._zod.processJSONSchema=(r,i,s)=>G$(n,r,i);const t=n._zod.bag;n.format=t.format??null,n.minLength=t.minimum??null,n.maxLength=t.maximum??null,n.regex=(...r)=>n.check(I$(...r)),n.includes=(...r)=>n.check(R$(...r)),n.startsWith=(...r)=>n.check(D$(...r)),n.endsWith=(...r)=>n.check(L$(...r)),n.min=(...r)=>n.check(pa(...r)),n.max=(...r)=>n.check(Om(...r)),n.length=(...r)=>n.check(Mm(...r)),n.nonempty=(...r)=>n.check(pa(1,...r)),n.lowercase=r=>n.check(C$(r)),n.uppercase=r=>n.check(P$(r)),n.trim=()=>n.check(M$()),n.normalize=(...r)=>n.check(O$(...r)),n.toLowerCase=()=>n.check(z$()),n.toUpperCase=()=>n.check(N$()),n.slugify=()=>n.check(U$())}),DT=A("ZodString",(n,e)=>{nh.init(n,e),Hm.init(n,e),n.email=t=>n.check(QA(LT,t)),n.url=t=>n.check(i$(OT,t)),n.jwt=t=>n.check(b$(XT,t)),n.emoji=t=>n.check(s$(MT,t)),n.guid=t=>n.check(Up(Bp,t)),n.uuid=t=>n.check(e$(Io,t)),n.uuidv4=t=>n.check(t$(Io,t)),n.uuidv6=t=>n.check(n$(Io,t)),n.uuidv7=t=>n.check(r$(Io,t)),n.nanoid=t=>n.check(o$(zT,t)),n.guid=t=>n.check(Up(Bp,t)),n.cuid=t=>n.check(a$(NT,t)),n.cuid2=t=>n.check(l$(UT,t)),n.ulid=t=>n.check(c$(FT,t)),n.base64=t=>n.check(m$(jT,t)),n.base64url=t=>n.check(v$(qT,t)),n.xid=t=>n.check(u$(ZT,t)),n.ksuid=t=>n.check(h$(HT,t)),n.ipv4=t=>n.check(d$(WT,t)),n.ipv6=t=>n.check(p$(BT,t)),n.cidrv4=t=>n.check(f$(VT,t)),n.cidrv6=t=>n.check(g$(GT,t)),n.e164=t=>n.check(y$(YT,t)),n.datetime=t=>n.check(fT(t)),n.date=t=>n.check(mT(t)),n.time=t=>n.check(yT(t)),n.duration=t=>n.check(wT(t))});function d(n){return JA(DT,n)}const ge=A("ZodStringFormat",(n,e)=>{le.init(n,e),Hm.init(n,e)}),LT=A("ZodEmail",(n,e)=>{sA.init(n,e),ge.init(n,e)}),Bp=A("ZodGUID",(n,e)=>{rA.init(n,e),ge.init(n,e)}),Io=A("ZodUUID",(n,e)=>{iA.init(n,e),ge.init(n,e)}),OT=A("ZodURL",(n,e)=>{oA.init(n,e),ge.init(n,e)}),MT=A("ZodEmoji",(n,e)=>{aA.init(n,e),ge.init(n,e)}),zT=A("ZodNanoID",(n,e)=>{lA.init(n,e),ge.init(n,e)}),NT=A("ZodCUID",(n,e)=>{cA.init(n,e),ge.init(n,e)}),UT=A("ZodCUID2",(n,e)=>{uA.init(n,e),ge.init(n,e)}),FT=A("ZodULID",(n,e)=>{hA.init(n,e),ge.init(n,e)}),ZT=A("ZodXID",(n,e)=>{dA.init(n,e),ge.init(n,e)}),HT=A("ZodKSUID",(n,e)=>{pA.init(n,e),ge.init(n,e)}),WT=A("ZodIPv4",(n,e)=>{yA.init(n,e),ge.init(n,e)}),BT=A("ZodIPv6",(n,e)=>{bA.init(n,e),ge.init(n,e)}),VT=A("ZodCIDRv4",(n,e)=>{wA.init(n,e),ge.init(n,e)}),GT=A("ZodCIDRv6",(n,e)=>{SA.init(n,e),ge.init(n,e)}),jT=A("ZodBase64",(n,e)=>{_A.init(n,e),ge.init(n,e)}),qT=A("ZodBase64URL",(n,e)=>{EA.init(n,e),ge.init(n,e)}),YT=A("ZodE164",(n,e)=>{xA.init(n,e),ge.init(n,e)}),XT=A("ZodJWT",(n,e)=>{$A.init(n,e),ge.init(n,e)}),Wm=A("ZodNumber",(n,e)=>{Pm.init(n,e),fe.init(n,e),n._zod.processJSONSchema=(r,i,s)=>j$(n,r,i),n.gt=(r,i)=>n.check(Zp(r,i)),n.gte=(r,i)=>n.check(Xl(r,i)),n.min=(r,i)=>n.check(Xl(r,i)),n.lt=(r,i)=>n.check(Fp(r,i)),n.lte=(r,i)=>n.check(Yl(r,i)),n.max=(r,i)=>n.check(Yl(r,i)),n.int=r=>n.check(Vp(r)),n.safe=r=>n.check(Vp(r)),n.positive=r=>n.check(Zp(0,r)),n.nonnegative=r=>n.check(Xl(0,r)),n.negative=r=>n.check(Fp(0,r)),n.nonpositive=r=>n.check(Yl(0,r)),n.multipleOf=(r,i)=>n.check(Hp(r,i)),n.step=(r,i)=>n.check(Hp(r,i)),n.finite=()=>n;const t=n._zod.bag;n.minValue=Math.max(t.minimum??Number.NEGATIVE_INFINITY,t.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,n.maxValue=Math.min(t.maximum??Number.POSITIVE_INFINITY,t.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,n.isInt=(t.format??"").includes("int")||Number.isSafeInteger(t.multipleOf??.5),n.isFinite=!0,n.format=t.format??null});function Z(n){return E$(Wm,n)}const KT=A("ZodNumberFormat",(n,e)=>{TA.init(n,e),Wm.init(n,e)});function Vp(n){return x$(KT,n)}const JT=A("ZodBoolean",(n,e)=>{IA.init(n,e),fe.init(n,e),n._zod.processJSONSchema=(t,r,i)=>q$(n,t,r)});function Ee(n){return A$(JT,n)}const QT=A("ZodUnknown",(n,e)=>{CA.init(n,e),fe.init(n,e),n._zod.processJSONSchema=(t,r,i)=>X$()});function S(){return $$(QT)}const eI=A("ZodNever",(n,e)=>{PA.init(n,e),fe.init(n,e),n._zod.processJSONSchema=(t,r,i)=>Y$(n,t,r)});function tI(n){return T$(eI,n)}const nI=A("ZodArray",(n,e)=>{RA.init(n,e),fe.init(n,e),n._zod.processJSONSchema=(t,r,i)=>tT(n,t,r,i),n.element=e.element,n.min=(t,r)=>n.check(pa(t,r)),n.nonempty=t=>n.check(pa(1,t)),n.max=(t,r)=>n.check(Om(t,r)),n.length=(t,r)=>n.check(Mm(t,r)),n.unwrap=()=>n.element});function D(n,e){return F$(nI,n,e)}const Bm=A("ZodObject",(n,e)=>{LA.init(n,e),fe.init(n,e),n._zod.processJSONSchema=(t,r,i)=>nT(n,t,r,i),ee(n,"shape",()=>e.shape),n.keyof=()=>ga(Object.keys(n._zod.def.shape)),n.catchall=t=>n.clone({...n._zod.def,catchall:t}),n.passthrough=()=>n.clone({...n._zod.def,catchall:S()}),n.loose=()=>n.clone({...n._zod.def,catchall:S()}),n.strict=()=>n.clone({...n._zod.def,catchall:tI()}),n.strip=()=>n.clone({...n._zod.def,catchall:void 0}),n.extend=t=>t1(n,t),n.safeExtend=t=>n1(n,t),n.merge=t=>r1(n,t),n.pick=t=>Qx(n,t),n.omit=t=>e1(n,t),n.partial=(...t)=>i1(Gm,n,t[0]),n.required=(...t)=>s1(jm,n,t[0])});function Vm(n,e){const t={type:"object",shape:n??{},...O(e)};return new Bm(t)}function f(n,e){return new Bm({type:"object",shape:n,catchall:S(),...O(e)})}const rI=A("ZodUnion",(n,e)=>{OA.init(n,e),fe.init(n,e),n._zod.processJSONSchema=(t,r,i)=>rT(n,t,r,i),n.options=e.options});function B(n,e){return new rI({type:"union",options:n,...O(e)})}const iI=A("ZodIntersection",(n,e)=>{MA.init(n,e),fe.init(n,e),n._zod.processJSONSchema=(t,r,i)=>iT(n,t,r,i)});function Qa(n,e){return new iI({type:"intersection",left:n,right:e})}const sI=A("ZodRecord",(n,e)=>{zA.init(n,e),fe.init(n,e),n._zod.processJSONSchema=(t,r,i)=>sT(n,t,r,i),n.keyType=e.keyType,n.valueType=e.valueType});function k(n,e,t){return new sI({type:"record",keyType:n,valueType:e,...O(t)})}const Lc=A("ZodEnum",(n,e)=>{NA.init(n,e),fe.init(n,e),n._zod.processJSONSchema=(r,i,s)=>K$(n,r,i),n.enum=e.entries,n.options=Object.values(e.entries);const t=new Set(Object.keys(e.entries));n.extract=(r,i)=>{const s={};for(const o of r)if(t.has(o))s[o]=e.entries[o];else throw new Error(`Key ${o} not found in enum`);return new Lc({...e,checks:[],...O(i),entries:s})},n.exclude=(r,i)=>{const s={...e.entries};for(const o of r)if(t.has(o))delete s[o];else throw new Error(`Key ${o} not found in enum`);return new Lc({...e,checks:[],...O(i),entries:s})}});function ga(n,e){const t=Array.isArray(n)?Object.fromEntries(n.map(r=>[r,r])):n;return new Lc({type:"enum",entries:t,...O(e)})}const oI=A("ZodLiteral",(n,e)=>{UA.init(n,e),fe.init(n,e),n._zod.processJSONSchema=(t,r,i)=>J$(n,t,r),n.values=new Set(e.values),Object.defineProperty(n,"value",{get(){if(e.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return e.values[0]}})});function $(n,e){return new oI({type:"literal",values:Array.isArray(n)?n:[n],...O(e)})}const aI=A("ZodTransform",(n,e)=>{FA.init(n,e),fe.init(n,e),n._zod.processJSONSchema=(t,r,i)=>eT(n,t),n._zod.parse=(t,r)=>{if(r.direction==="backward")throw new gm(n.constructor.name);t.addIssue=s=>{if(typeof s=="string")t.issues.push(ss(s,t.value,e));else{const o=s;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=t.value),o.inst??(o.inst=n),t.issues.push(ss(o))}};const i=e.transform(t.value,t);return i instanceof Promise?i.then(s=>(t.value=s,t)):(t.value=i,t)}});function lI(n){return new aI({type:"transform",transform:n})}const Gm=A("ZodOptional",(n,e)=>{Lm.init(n,e),fe.init(n,e),n._zod.processJSONSchema=(t,r,i)=>Fm(n,t,r,i),n.unwrap=()=>n._zod.def.innerType});function Gp(n){return new Gm({type:"optional",innerType:n})}const cI=A("ZodExactOptional",(n,e)=>{ZA.init(n,e),fe.init(n,e),n._zod.processJSONSchema=(t,r,i)=>Fm(n,t,r,i),n.unwrap=()=>n._zod.def.innerType});function uI(n){return new cI({type:"optional",innerType:n})}const hI=A("ZodNullable",(n,e)=>{HA.init(n,e),fe.init(n,e),n._zod.processJSONSchema=(t,r,i)=>oT(n,t,r,i),n.unwrap=()=>n._zod.def.innerType});function jp(n){return new hI({type:"nullable",innerType:n})}const dI=A("ZodDefault",(n,e)=>{WA.init(n,e),fe.init(n,e),n._zod.processJSONSchema=(t,r,i)=>lT(n,t,r,i),n.unwrap=()=>n._zod.def.innerType,n.removeDefault=n.unwrap});function pI(n,e){return new dI({type:"default",innerType:n,get defaultValue(){return typeof e=="function"?e():bm(e)}})}const fI=A("ZodPrefault",(n,e)=>{BA.init(n,e),fe.init(n,e),n._zod.processJSONSchema=(t,r,i)=>cT(n,t,r,i),n.unwrap=()=>n._zod.def.innerType});function gI(n,e){return new fI({type:"prefault",innerType:n,get defaultValue(){return typeof e=="function"?e():bm(e)}})}const jm=A("ZodNonOptional",(n,e)=>{VA.init(n,e),fe.init(n,e),n._zod.processJSONSchema=(t,r,i)=>aT(n,t,r,i),n.unwrap=()=>n._zod.def.innerType});function mI(n,e){return new jm({type:"nonoptional",innerType:n,...O(e)})}const vI=A("ZodCatch",(n,e)=>{GA.init(n,e),fe.init(n,e),n._zod.processJSONSchema=(t,r,i)=>uT(n,t,r,i),n.unwrap=()=>n._zod.def.innerType,n.removeCatch=n.unwrap});function yI(n,e){return new vI({type:"catch",innerType:n,catchValue:typeof e=="function"?e:()=>e})}const bI=A("ZodPipe",(n,e)=>{jA.init(n,e),fe.init(n,e),n._zod.processJSONSchema=(t,r,i)=>hT(n,t,r,i),n.in=e.in,n.out=e.out});function qp(n,e){return new bI({type:"pipe",in:n,out:e})}const wI=A("ZodReadonly",(n,e)=>{qA.init(n,e),fe.init(n,e),n._zod.processJSONSchema=(t,r,i)=>dT(n,t,r,i),n.unwrap=()=>n._zod.def.innerType});function SI(n){return new wI({type:"readonly",innerType:n})}const _I=A("ZodCustom",(n,e)=>{YA.init(n,e),fe.init(n,e),n._zod.processJSONSchema=(t,r,i)=>Q$(n,t)});function kI(n,e={}){return Z$(_I,n,e)}function EI(n){return H$(n)}const Kl={custom:"custom"},xI=["text/markdown","text/html"],AI=["committed","pending"];function $I(n){let e;try{e=new URL(n)}catch{return!1}return e.protocol==="http:"||e.protocol==="https:"}Vm({id:d().min(1),type:ga(xI),title:d(),status:ga(AI),externalFilePath:d().optional(),externalURL:d().optional()}).superRefine((n,e)=>{n.externalFilePath!==void 0&&n.externalURL!==void 0&&e.addIssue({code:Kl.custom,message:"externalFilePath and externalURL are mutually exclusive",path:["externalURL"]}),n.externalURL!==void 0&&($I(n.externalURL)||e.addIssue({code:Kl.custom,message:"externalURL must be an http(s) URL",path:["externalURL"]}),n.status!=="committed"&&e.addIssue({code:Kl.custom,message:"URL-backed artifacts must have status committed",path:["status"]}))});Vm({name:d().min(1),description:d(),accepts:D(d().min(1)).min(1)});function qm(n){return typeof n=="object"&&n!==null}function TI(n){return!qm(n)||n.type!=="ready"?!1:!("id"in n)}function II(n){return!(!qm(n)||n.type!=="update-content"||typeof n.id!="string"||typeof n.content!="string")}function CI(n,e){if(n===e)return 2;if(n==="*/*")return 0;const t=n.indexOf("/");if(t>0&&n.slice(t+1)==="*"){const r=n.slice(0,t),i=e.indexOf("/");if(i>0&&e.slice(0,i)===r)return 1}return null}function PI(n,e){let t=null;for(const r of n.accepts){const i=CI(r,e);i!==null&&(t===null||i>t)&&(t=i)}return t}function RI(n,e){let t=-1,r=null;for(const i of e){const s=PI(i,n);s!==null&&(s>t||s===t&&r!==null&&i.id<r.id)&&(t=s,r=i)}return r}const DI=4401;class Oc extends Error{constructor(e="Authentication required"){super(e),this.name="AuthError"}}class Mc extends wt{constructor(t){super();b(this,"url");b(this,"name");b(this,"token");b(this,"status","disconnected");b(this,"screens",new Map);b(this,"views",[]);b(this,"client");b(this,"createSocket");b(this,"createClient");b(this,"socket",null);b(this,"connectAttempt",0);this.url=ht(t.url),this.name=t.name,this.token=t.token??null,this.createSocket=t.createSocket??(r=>new WebSocket(r)),this.createClient=t.createClient??((r,i)=>new Mx(r,{token:i??void 0})),this.client=this.createClient(this.url,this.token)}async connect(){var i;this.connectAttempt+=1;const t=this.connectAttempt;(i=this.socket)==null||i.close(),this.client=this.createClient(this.url,this.token),this.status="connecting",this.dispatchEvent(new K("change"));const r=this.createSocket(LI(this.url,this.token));return this.socket=r,await new Promise((s,o)=>{let a=!1;const c=()=>{a||this.connectAttempt!==t||(a=!0,this.status="connected",this.dispatchEvent(new K("change")),s())},u=p=>{a||this.connectAttempt!==t||(a=!0,this.status="disconnected",this.dispatchEvent(new K("change")),o(p))},h=async()=>{try{const[{screens:p},v]=await Promise.all([this.client.screens.list(),this.client.views.list()]);this.screens=new Map(p.map(g=>[g.id,structuredClone(g)])),this.views=v,this.dispatchEvent(new K("change")),c()}catch(p){u(p instanceof Error?p:new Error(String(p)))}};r.addEventListener("open",()=>{h()}),r.addEventListener("message",p=>{const v=MI(p);v&&(this.applyServerEvent(v),this.dispatchEvent(new am("server-event",{serverURL:this.url,event:v})))}),r.addEventListener("close",p=>{if(this.connectAttempt===t){if(this.socket=null,OI(p)===DI){u(new Oc);return}if(!a){u(new Error("Connection closed before initialization"));return}this.status="disconnected",this.dispatchEvent(new K("change"))}}),r.addEventListener("error",()=>{u(new Error("WebSocket connection failed"))})})}disconnect(){var t;this.connectAttempt+=1,(t=this.socket)==null||t.close(),this.socket=null,this.status="disconnected",this.dispatchEvent(new K("change"))}getViewURL(t){const r=RI(t.type,this.views);if(!r)return null;const i=`${this.url}/views/${encodeURIComponent(r.id)}/`;return this.token===null?i:`${i}?token=${encodeURIComponent(this.token)}`}getContentURL(t){const r=`${this.url}/artifacts/${encodeURIComponent(t)}/content`;return this.token===null?r:`${r}?token=${encodeURIComponent(this.token)}`}async createScreen(t){const{screen:r}=await this.client.screens.create({name:t});return this.screens.set(r.id,structuredClone(r)),r}applyServerEvent(t){switch(t.type){case"screen-created":this.screens.set(t.screen.id,structuredClone(t.screen)),this.dispatchEvent(new jo("screens-changed"));break;case"screen-updated":this.screens.set(t.screen.id,structuredClone(t.screen)),this.dispatchEvent(new jo("screens-changed"));break;case"screen-removed":this.screens.delete(t.screenID),this.dispatchEvent(new jo("screens-changed"));break;case"artifact-created":break;case"artifact-attached":{const r=this.screens.get(t.screenID);r&&!im(r.layout,t.artifact.id)&&(r.layout=[...r.layout,rm(t.artifact.id,{id:t.cardID})]);break}case"artifact-removed":{const r=this.screens.get(t.screenID);r&&(r.layout=qg(r.layout,t.artifactID));break}}}}function LI(n,e){const t=new URL(n);return t.protocol=t.protocol==="https:"?"wss:":"ws:",t.pathname="/events",t.search="",e&&t.searchParams.set("token",e),t.hash="",t.toString()}function OI(n){return typeof n=="object"&&n!==null&&"code"in n&&typeof n.code=="number"?n.code:null}function MI(n){const e=typeof n=="string"?n:typeof n=="object"&&n!==null&&"data"in n&&typeof n.data=="string"?n.data:"";if(!e)return null;try{return JSON.parse(e)}catch{return null}}const zI="Local";class NI extends wt{constructor(t){super();b(this,"servers",new Map);b(this,"localServerURL");b(this,"localStore");b(this,"createSocket");b(this,"lastActiveServerURL");b(this,"serverListeners",new Map);b(this,"handleLocalStoreChange",()=>{const t=this.localStore.get().activeServerURL;t!==this.lastActiveServerURL&&(this.lastActiveServerURL=t,this.dispatchEvent(new K("change")))});this.localStore=t.localStore,this.localServerURL=t.localServerURL?ht(t.localServerURL):null,this.createSocket=t.createSocket??(r=>new WebSocket(r)),this.lastActiveServerURL=this.localStore.get().activeServerURL,this.localStore.addEventListener("change",this.handleLocalStoreChange)}get activeServer(){const t=this.localStore.get().activeServerURL;return t===null?null:this.servers.get(t)??null}add(t){const r=ht(t.url);this.servers.get(r)&&this.remove(r),this.servers.set(r,t);const s=()=>{this.dispatchEvent(new K("change"))},o=c=>{this.dispatchEvent(new am("server-event",{serverURL:c.serverURL,event:c.event}))},a=()=>{this.dispatchEvent(new jo("screens-changed"))};t.addEventListener("change",s),t.addEventListener("server-event",o),t.addEventListener("screens-changed",a),this.serverListeners.set(r,{onServerChange:s,onServerEvent:o,onScreensChanged:a}),this.dispatchEvent(new K("change"))}remove(t){const r=ht(t);if(this.localServerURL&&r===this.localServerURL)return;const i=this.servers.get(r);if(!i)return;const s=this.serverListeners.get(r);s&&(i.removeEventListener("change",s.onServerChange),i.removeEventListener("server-event",s.onServerEvent),i.removeEventListener("screens-changed",s.onScreensChanged),this.serverListeners.delete(r)),i.disconnect(),this.servers.delete(r);const o=this.localStore.get(),a=o.activeServerURL===r;this.localStore.set({...o,servers:o.servers.filter(c=>c.url!==r),activeServerURL:a?null:o.activeServerURL}),this.dispatchEvent(new K("change"))}setActive(t){const r=this.localStore.get(),i=t?ht(t.url):null;r.activeServerURL!==i&&this.localStore.set({...r,activeServerURL:i})}connectConfiguredServers(t,r){const i=t?ht(t):null;if(i){const a=this.localStore.get();a.servers.some(u=>ht(u.url)===i)||this.localStore.set({...a,servers:[...a.servers,{url:i,name:zI}]})}const s=this.localStore.get().servers;for(const a of s){const c=ht(a.url),u=i!==null&&c===i,h=new Mc({url:a.url,name:a.name,token:u?r??null:null,createSocket:this.createSocket});this.add(h),h.connect().catch(()=>{})}const o=i?this.servers.get(i)??null:null;this.setActive(o??this.servers.values().next().value??null)}addServer(t,r){const i=ht(t);this.remove(i);const s=this.localStore.get();this.localStore.set({...s,servers:[...s.servers.filter(a=>ht(a.url)!==i),{url:i,name:r}]});const o=new Mc({url:i,name:r,createSocket:this.createSocket});this.add(o),this.setActive(o),o.connect().catch(()=>{})}removeServer(t){this.remove(t)}}const ae={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"},Ft={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"},UI=1,FI=f({_meta:k(d(),S()).nullish(),terminal:Ee().optional().default(!1)}),ZI=f({_meta:k(d(),S()).nullish(),label:d().nullish(),name:d(),optional:Ee().optional().default(!1),secret:Ee().optional().default(!0)}),HI=f({_meta:k(d(),S()).nullish(),description:d().nullish(),id:d(),name:d()}),WI=f({_meta:k(d(),S()).nullish(),description:d().nullish(),id:d(),link:d().nullish(),name:d(),vars:D(ZI)}),BI=f({_meta:k(d(),S()).nullish(),args:D(d()).optional(),description:d().nullish(),env:k(d(),d()).optional(),id:d(),name:d()}),VI=B([WI.and(f({type:$("env_var")})),BI.and(f({type:$("terminal")})),HI]),GI=f({_meta:k(d(),S()).nullish(),methodId:d()}),jI=f({_meta:k(d(),S()).nullish()}),qI=f({_meta:k(d(),S()).nullish(),blob:d(),mimeType:d().nullish(),uri:d()}),YI=f({default:Ee().nullish(),description:d().nullish(),title:d().nullish()}),XI=f({_meta:k(d(),S()).nullish()}),KI=f({_meta:k(d(),S()).nullish()}),JI=f({amount:Z(),currency:d()}),QI=f({_meta:k(d(),S()).nullish(),terminalId:d()}),eC=f({_meta:k(d(),S()).nullish(),newText:d(),oldText:d().nullish(),path:d()}),tC=B([d(),Z(),Z(),Ee(),D(d())]),nC=f({content:k(d(),tC).nullish()}),rC=B([nC.and(f({action:$("accept")})),f({action:$("decline")}),f({action:$("cancel")})]),iC=f({_meta:k(d(),S()).nullish()}),Ym=d(),sC=f({_meta:k(d(),S()).nullish(),elicitationId:Ym}),oC=f({_meta:k(d(),S()).nullish(),action:rC}),aC=$("object"),lC=$("string"),cC=f({_meta:k(d(),S()).nullish()}),uC=f({_meta:k(d(),S()).nullish(),form:iC.nullish(),url:cC.nullish()}),hC=f({elicitationId:Ym,url:d().url()}),Xm=f({const:d(),title:d()}),Km=f({_meta:k(d(),S()).nullish(),name:d(),value:d()}),dC=B([$(-32700),$(-32600),$(-32601),$(-32602),$(-32603),$(-32800),$(-32e3),$(-32002),$(-32042),Z().int().min(-2147483648,{message:"Invalid value: Expected int32 to be >= -2147483648"}).max(2147483647,{message:"Invalid value: Expected int32 to be <= 2147483647"})]),Jm=f({code:dC,data:S().optional(),message:d()}),Qm=S(),ev=S(),tv=S(),pC=f({_meta:k(d(),S()).nullish(),readTextFile:Ee().optional().default(!1),writeTextFile:Ee().optional().default(!1)}),nv=f({_meta:k(d(),S()).nullish(),name:d(),value:d()}),rv=f({_meta:k(d(),S()).nullish(),name:d(),title:d().nullish(),version:d()}),fC=f({default:Z().nullish(),description:d().nullish(),maximum:Z().nullish(),minimum:Z().nullish(),title:d().nullish()}),gC=f({_meta:k(d(),S()).nullish()}),mC=f({_meta:k(d(),S()).nullish(),additionalDirectories:D(d()).optional(),cursor:d().nullish(),cwd:d().nullish()}),vC=f({_meta:k(d(),S()).nullish()}),yC=f({_meta:k(d(),S()).nullish(),logout:vC.nullish()}),bC=f({_meta:k(d(),S()).nullish()}),wC=f({_meta:k(d(),S()).nullish()}),SC=f({_meta:k(d(),S()).nullish(),http:Ee().optional().default(!1),sse:Ee().optional().default(!1)}),_C=f({_meta:k(d(),S()).nullish(),headers:D(nv),name:d(),url:d()}),kC=f({_meta:k(d(),S()).nullish(),headers:D(nv),name:d(),url:d()}),EC=f({_meta:k(d(),S()).nullish(),args:D(d()),command:d(),env:D(Km),name:d()}),el=B([_C.and(f({type:$("http")})),kC.and(f({type:$("sse")})),EC]),rh=d(),xC=f({_meta:k(d(),S()).nullish(),description:d().nullish(),modelId:rh,name:d()}),AC=B([$("error"),$("warning"),$("information"),$("hint")]),$C=f({_meta:k(d(),S()).nullish()}),TC=f({_meta:k(d(),S()).nullish()}),IC=f({_meta:k(d(),S()).nullish()}),CC=f({_meta:k(d(),S()).nullish()}),PC=f({_meta:k(d(),S()).nullish()}),RC=f({_meta:k(d(),S()).nullish(),maxCount:Z().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),DC=f({diff:d(),uri:d()}),LC=f({endLine:Z().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),startLine:Z().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),text:d()}),OC=f({_meta:k(d(),S()).nullish()}),MC=f({_meta:k(d(),S()).nullish()}),zC=f({languageId:d(),text:d(),uri:d()}),NC=f({_meta:k(d(),S()).nullish(),maxCount:Z().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),UC=B([$("rejected"),$("ignored"),$("replaced"),$("cancelled")]),FC=f({excerpts:D(LC),uri:d()}),ZC=f({_meta:k(d(),S()).nullish()}),HC=f({_meta:k(d(),S()).nullish()}),WC=f({name:d(),owner:d(),remoteUrl:d()}),BC=f({_meta:k(d(),S()).nullish()}),VC=f({_meta:k(d(),S()).nullish(),jump:OC.nullish(),rename:HC.nullish(),searchAndReplace:BC.nullish()}),GC=f({id:d(),isRegex:Ee().nullish(),replace:d(),search:d(),uri:d()}),jC=B([$("automatic"),$("diagnostic"),$("manual")]),qC=f({_meta:k(d(),S()).nullish(),maxCount:Z().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),YC=f({_meta:k(d(),S()).nullish(),diagnostics:$C.nullish(),editHistory:RC.nullish(),openFiles:MC.nullish(),recentFiles:NC.nullish(),relatedSnippets:ZC.nullish(),userActions:qC.nullish()}),XC=f({_meta:k(d(),S()).nullish(),additionalDirectories:D(d()).optional(),cwd:d(),mcpServers:D(el)}),KC=f({default:Z().nullish(),description:d().nullish(),maximum:Z().nullish(),minimum:Z().nullish(),title:d().nullish()}),iv=d(),JC=B([$("allow_once"),$("allow_always"),$("reject_once"),$("reject_always")]),QC=f({_meta:k(d(),S()).nullish(),kind:JC,name:d(),optionId:iv}),eP=B([$("high"),$("medium"),$("low")]),tP=B([$("pending"),$("in_progress"),$("completed")]),nP=f({_meta:k(d(),S()).nullish(),content:d(),priority:eP,status:tP}),rP=f({_meta:k(d(),S()).nullish(),entries:D(nP)}),bn=f({character:Z().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),line:Z().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"})}),iP=f({id:d(),position:bn,uri:d()}),sP=f({id:d(),newName:d(),position:bn,uri:d()}),oP=f({action:d(),position:bn,timestampMs:Z(),uri:d()}),sv=B([$("utf-16"),$("utf-32"),$("utf-8")]),aP=f({_meta:k(d(),S()).nullish(),auth:FI.optional().default({terminal:!1}),elicitation:uC.nullish(),fs:pC.optional().default({readTextFile:!1,writeTextFile:!1}),nes:VC.nullish(),positionEncodings:D(sv).optional(),terminal:Ee().optional().default(!1)}),lP=f({_meta:k(d(),S()).nullish(),audio:Ee().optional().default(!1),embeddedContext:Ee().optional().default(!1),image:Ee().optional().default(!1)}),ov=Z().int().gte(0).lte(65535),cP=f({_meta:k(d(),S()).nullish(),clientCapabilities:aP.optional().default({auth:{terminal:!1},fs:{readTextFile:!1,writeTextFile:!1},terminal:!1}),clientInfo:rv.nullish(),protocolVersion:ov}),xi=f({end:bn,start:bn}),uP=f({message:d(),range:xi,severity:AC,uri:d()}),hP=f({languageId:d(),lastFocusedMs:Z().nullish(),uri:d(),visibleRange:xi.nullish()}),dP=f({_meta:k(d(),S()).nullish(),diagnostics:D(uP).nullish(),editHistory:D(DC).nullish(),openFiles:D(hP).nullish(),recentFiles:D(zC).nullish(),relatedSnippets:D(FC).nullish(),userActions:D(oP).nullish()}),pP=f({newText:d(),range:xi}),fP=f({cursorPosition:bn.nullish(),edits:D(pP),id:d(),uri:d()}),gP=B([fP.and(f({kind:$("edit")})),iP.and(f({kind:$("jump")})),sP.and(f({kind:$("rename")})),GC.and(f({kind:$("searchAndReplace")}))]),mP=f({_meta:k(d(),S()).nullish(),content:d()}),vP=f({_meta:k(d(),S()).nullish()}),dr=B([Z(),d()]).nullable();f({_meta:k(d(),S()).nullish(),requestId:dr});const yP=ga(["assistant","user"]),oo=f({_meta:k(d(),S()).nullish(),audience:D(yP).nullish(),lastModified:d().nullish(),priority:Z().nullish()}),bP=f({_meta:k(d(),S()).nullish(),annotations:oo.nullish(),data:d(),mimeType:d()}),wP=f({_meta:k(d(),S()).nullish(),annotations:oo.nullish(),data:d(),mimeType:d(),uri:d().nullish()}),SP=f({_meta:k(d(),S()).nullish(),annotations:oo.nullish(),description:d().nullish(),mimeType:d().nullish(),name:d(),size:Z().nullish(),title:d().nullish(),uri:d()}),_P=f({_meta:k(d(),S()).nullish(),optionId:iv}),kP=B([f({outcome:$("cancelled")}),_P.and(f({outcome:$("selected")}))]),EP=f({_meta:k(d(),S()).nullish(),outcome:kP}),xP=f({_meta:k(d(),S()).nullish()}),AP=f({_meta:k(d(),S()).nullish()}),$P=f({currentValue:Ee()}),TP=d(),av=d(),IP=B([$("mode"),$("model"),$("thought_level"),d()]),ih=d(),lv=f({_meta:k(d(),S()).nullish(),description:d().nullish(),name:d(),value:ih}),CP=f({_meta:k(d(),S()).nullish(),group:TP,name:d(),options:D(lv)}),PP=B([D(lv),D(CP)]),RP=f({currentValue:ih,options:PP}),Ai=Qa(B([RP.and(f({type:$("select")})),$P.and(f({type:$("boolean")}))]),f({_meta:k(d(),S()).nullish(),category:IP.nullish(),description:d().nullish(),id:av,name:d()})),DP=f({_meta:k(d(),S()).nullish(),configOptions:D(Ai)}),LP=f({_meta:k(d(),S()).nullish()}),X=d(),OP=f({_meta:k(d(),S()).nullish(),id:d(),sessionId:X}),MP=f({_meta:k(d(),S()).nullish(),sessionId:X}),zP=f({_meta:k(d(),S()).nullish(),sessionId:X}),NP=f({_meta:k(d(),S()).nullish(),sessionId:X}),cv=f({_meta:k(d(),S()).nullish(),args:D(d()).optional(),command:d(),cwd:d().nullish(),env:D(Km).optional(),outputByteLimit:Z().nullish(),sessionId:X}),UP=f({_meta:k(d(),S()).nullish(),sessionId:X,uri:d()}),FP=f({_meta:k(d(),S()).nullish(),position:bn,sessionId:X,uri:d(),version:Z(),visibleRange:xi}),ZP=f({_meta:k(d(),S()).nullish(),languageId:d(),sessionId:X,text:d(),uri:d(),version:Z()}),HP=f({_meta:k(d(),S()).nullish(),sessionId:X,uri:d()}),WP=f({_meta:k(d(),S()).nullish(),additionalDirectories:D(d()).optional(),cwd:d(),mcpServers:D(el).optional(),sessionId:X}),uv=f({_meta:k(d(),S()).nullish(),sessionId:X,terminalId:d()}),BP=f({_meta:k(d(),S()).nullish(),additionalDirectories:D(d()).optional(),cwd:d(),mcpServers:D(el),sessionId:X}),hv=f({_meta:k(d(),S()).nullish(),limit:Z().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),line:Z().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:d(),sessionId:X}),VP=f({_meta:k(d(),S()).nullish(),id:d(),reason:UC.nullish(),sessionId:X}),dv=f({_meta:k(d(),S()).nullish(),sessionId:X,terminalId:d()}),GP=f({_meta:k(d(),S()).nullish(),additionalDirectories:D(d()).optional(),cwd:d(),mcpServers:D(el).optional(),sessionId:X}),jP=f({_meta:k(d(),S()).nullish(),additionalDirectories:D(d()).optional(),cwd:d(),sessionId:X,title:d().nullish(),updatedAt:d().nullish()}),qP=f({_meta:k(d(),S()).nullish(),nextCursor:d().nullish(),sessions:D(jP)}),YP=f({_meta:k(d(),S()).nullish(),title:d().nullish(),updatedAt:d().nullish()}),XP=f({_meta:k(d(),S()).nullish()}),tl=d(),KP=f({_meta:k(d(),S()).nullish(),currentModeId:tl}),JP=f({_meta:k(d(),S()).nullish(),description:d().nullish(),id:tl,name:d()}),nl=f({_meta:k(d(),S()).nullish(),availableModes:D(JP),currentModeId:tl}),rl=f({_meta:k(d(),S()).nullish(),availableModels:D(xC),currentModelId:rh}),QP=f({_meta:k(d(),S()).nullish(),configOptions:D(Ai).nullish(),models:rl.nullish(),modes:nl.nullish(),sessionId:X}),eR=f({_meta:k(d(),S()).nullish(),configOptions:D(Ai).nullish(),models:rl.nullish(),modes:nl.nullish()}),tR=f({_meta:k(d(),S()).nullish(),configOptions:D(Ai).nullish(),models:rl.nullish(),modes:nl.nullish(),sessionId:X}),nR=f({_meta:k(d(),S()).nullish(),configOptions:D(Ai).nullish(),models:rl.nullish(),modes:nl.nullish()}),rR=f({_meta:k(d(),S()).nullish()}),iR=f({_meta:k(d(),S()).nullish(),additionalDirectories:xP.nullish(),close:AP.nullish(),fork:LP.nullish(),list:XP.nullish(),resume:rR.nullish()}),sR=Qa(B([f({type:$("boolean"),value:Ee()}),f({value:ih})]),f({_meta:k(d(),S()).nullish(),configId:av,sessionId:X})),oR=f({_meta:k(d(),S()).nullish(),configOptions:D(Ai)}),aR=f({_meta:k(d(),S()).nullish(),modeId:tl,sessionId:X}),lR=f({_meta:k(d(),S()).nullish()}),cR=f({_meta:k(d(),S()).nullish(),modelId:rh,sessionId:X}),uR=f({_meta:k(d(),S()).nullish()}),hR=f({_meta:k(d(),S()).nullish(),sessionId:X}),dR=B([$("end_turn"),$("max_tokens"),$("max_turn_requests"),$("refusal"),$("cancelled")]),pR=B([$("email"),$("uri"),$("date"),$("date-time")]),fR=f({default:d().nullish(),description:d().nullish(),enum:D(d()).nullish(),format:pR.nullish(),maxLength:Z().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),minLength:Z().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),oneOf:D(Xm).nullish(),pattern:d().nullish(),title:d().nullish()}),gR=f({_meta:k(d(),S()).nullish(),context:dP.nullish(),position:bn,selection:xi.nullish(),sessionId:X,triggerKind:jC,uri:d(),version:Z()}),mR=f({_meta:k(d(),S()).nullish(),suggestions:D(gP)}),vR=f({_meta:k(d(),S()).nullish(),terminalId:d()}),yR=f({_meta:k(d(),S()).nullish(),exitCode:Z().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:d().nullish()}),pv=f({_meta:k(d(),S()).nullish(),sessionId:X,terminalId:d()}),bR=f({_meta:k(d(),S()).nullish(),exitStatus:yR.nullish(),output:d(),truncated:Ee()}),wR=f({_meta:k(d(),S()).nullish(),annotations:oo.nullish(),text:d()}),SR=f({range:xi.nullish(),text:d()}),_R=f({_meta:k(d(),S()).nullish(),contentChanges:D(SR),sessionId:X,uri:d(),version:Z()});f({method:d(),params:B([MP,ZP,_R,UP,HP,FP,OP,VP,Qm]).nullish()});const kR=B([$("full"),$("incremental")]),ER=f({_meta:k(d(),S()).nullish(),syncKind:kR}),xR=f({_meta:k(d(),S()).nullish(),didChange:ER.nullish(),didClose:TC.nullish(),didFocus:IC.nullish(),didOpen:CC.nullish(),didSave:PC.nullish()}),AR=f({_meta:k(d(),S()).nullish(),document:xR.nullish()}),$R=f({_meta:k(d(),S()).nullish(),context:YC.nullish(),events:AR.nullish()}),TR=f({_meta:k(d(),S()).nullish(),auth:yC.optional().default({}),loadSession:Ee().optional().default(!1),mcpCapabilities:SC.optional().default({http:!1,sse:!1}),nes:$R.nullish(),positionEncoding:sv.nullish(),promptCapabilities:lP.optional().default({audio:!1,embeddedContext:!1,image:!1}),sessionCapabilities:iR.optional().default({})}),IR=f({_meta:k(d(),S()).nullish(),agentCapabilities:TR.optional().default({auth:{},loadSession:!1,mcpCapabilities:{http:!1,sse:!1},promptCapabilities:{audio:!1,embeddedContext:!1,image:!1},sessionCapabilities:{}}),agentInfo:rv.nullish(),authMethods:D(VI).optional().default([]),protocolVersion:ov}),CR=f({_meta:k(d(),S()).nullish(),mimeType:d().nullish(),text:d(),uri:d()}),PR=B([CR,qI]),RR=f({_meta:k(d(),S()).nullish(),annotations:oo.nullish(),resource:PR}),sh=B([wR.and(f({type:$("text")})),wP.and(f({type:$("image")})),bP.and(f({type:$("audio")})),SP.and(f({type:$("resource_link")})),RR.and(f({type:$("resource")}))]),DR=f({_meta:k(d(),S()).nullish(),content:sh}),Jl=f({_meta:k(d(),S()).nullish(),content:sh,messageId:d().nullish()}),LR=f({_meta:k(d(),S()).nullish(),messageId:d().nullish(),prompt:D(sh),sessionId:X}),OR=f({anyOf:D(Xm)}),fv=B([DR.and(f({type:$("content")})),eC.and(f({type:$("diff")})),vR.and(f({type:$("terminal")}))]),gv=d(),mv=f({_meta:k(d(),S()).nullish(),line:Z().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:d()}),vv=B([$("pending"),$("in_progress"),$("completed"),$("failed")]),yv=B([$("read"),$("edit"),$("delete"),$("move"),$("search"),$("execute"),$("think"),$("fetch"),$("switch_mode"),$("other")]),MR=f({_meta:k(d(),S()).nullish(),content:D(fv).optional(),kind:yv.optional(),locations:D(mv).optional(),rawInput:S().optional(),rawOutput:S().optional(),status:vv.optional(),title:d(),toolCallId:gv}),bv=f({_meta:k(d(),S()).nullish(),content:D(fv).nullish(),kind:yv.nullish(),locations:D(mv).nullish(),rawInput:S().optional(),rawOutput:S().optional(),status:vv.nullish(),title:d().nullish(),toolCallId:gv}),wv=f({_meta:k(d(),S()).nullish(),options:D(QC),sessionId:X,toolCall:bv}),zR=f({_meta:k(d(),S()).nullish(),hint:d()}),NR=zR,UR=f({_meta:k(d(),S()).nullish(),description:d(),input:NR.nullish(),name:d()}),FR=f({_meta:k(d(),S()).nullish(),availableCommands:D(UR)}),ZR=f({enum:D(d()),type:lC}),HR=B([ZR,OR]),WR=f({default:D(d()).nullish(),description:d().nullish(),items:HR,maxItems:Z().nullish(),minItems:Z().nullish(),title:d().nullish()}),BR=B([fR.and(f({type:$("string")})),KC.and(f({type:$("number")})),fC.and(f({type:$("integer")})),YI.and(f({type:$("boolean")})),WR.and(f({type:$("array")}))]),VR=f({description:d().nullish(),properties:k(d(),BR).optional().default({}),required:D(d()).nullish(),title:d().nullish(),type:aC.optional().default("object")}),GR=f({requestedSchema:VR}),jR=Qa(B([GR.and(f({mode:$("form")})),hC.and(f({mode:$("url")}))]),f({_meta:k(d(),S()).nullish(),message:d(),sessionId:X})),qR=f({cachedReadTokens:Z().nullish(),cachedWriteTokens:Z().nullish(),inputTokens:Z(),outputTokens:Z(),thoughtTokens:Z().nullish(),totalTokens:Z()}),YR=f({_meta:k(d(),S()).nullish(),stopReason:dR,usage:qR.nullish(),userMessageId:d().nullish()});B([f({id:dr,result:B([IR,jI,wC,tR,eR,qP,QP,nR,KI,lR,oR,YR,uR,hR,mR,XI,tv])}),f({error:Jm,id:dr})]);const XR=f({_meta:k(d(),S()).nullish(),cost:JI.nullish(),size:Z(),used:Z()}),KR=B([Jl.and(f({sessionUpdate:$("user_message_chunk")})),Jl.and(f({sessionUpdate:$("agent_message_chunk")})),Jl.and(f({sessionUpdate:$("agent_thought_chunk")})),MR.and(f({sessionUpdate:$("tool_call")})),bv.and(f({sessionUpdate:$("tool_call_update")})),rP.and(f({sessionUpdate:$("plan")})),FR.and(f({sessionUpdate:$("available_commands_update")})),KP.and(f({sessionUpdate:$("current_mode_update")})),DP.and(f({sessionUpdate:$("config_option_update")})),YP.and(f({sessionUpdate:$("session_info_update")})),XR.and(f({sessionUpdate:$("usage_update")}))]),Sv=f({_meta:k(d(),S()).nullish(),sessionId:X,update:KR});f({method:d(),params:B([Sv,sC,Qm]).nullish()});const _v=f({_meta:k(d(),S()).nullish(),sessionId:X,terminalId:d()}),JR=f({_meta:k(d(),S()).nullish(),exitCode:Z().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:d().nullish()}),QR=f({name:d(),uri:d()}),eD=f({_meta:k(d(),S()).nullish(),repository:WC.nullish(),workspaceFolders:D(QR).nullish(),workspaceUri:d().nullish()});f({id:dr,method:d(),params:B([cP,GI,bC,XC,BP,mC,WP,GP,NP,aR,sR,LR,cR,eD,gR,zP,ev]).nullish()});const kv=f({_meta:k(d(),S()).nullish(),content:d(),path:d(),sessionId:X});f({id:dr,method:d(),params:B([kv,hv,wv,cv,pv,dv,_v,uv,jR,ev]).nullish()});const tD=f({_meta:k(d(),S()).nullish()});B([f({id:dr,result:B([tD,mP,EP,QI,bR,vP,JR,gC,oC,tv])}),f({error:Jm,id:dr})]);var Y;class nD{constructor(e,t){w(this,Y);const r=e(this),i=async(o,a)=>{var c,u,h,p,v,g,E;switch(o){case Ft.fs_write_text_file:{const _=kv.parse(a);return(c=r.writeTextFile)==null?void 0:c.call(r,_)}case Ft.fs_read_text_file:{const _=hv.parse(a);return(u=r.readTextFile)==null?void 0:u.call(r,_)}case Ft.session_request_permission:{const _=wv.parse(a);return r.requestPermission(_)}case Ft.terminal_create:{const _=cv.parse(a);return(h=r.createTerminal)==null?void 0:h.call(r,_)}case Ft.terminal_output:{const _=pv.parse(a);return(p=r.terminalOutput)==null?void 0:p.call(r,_)}case Ft.terminal_release:{const _=dv.parse(a);return await((v=r.releaseTerminal)==null?void 0:v.call(r,_))??{}}case Ft.terminal_wait_for_exit:{const _=_v.parse(a);return(g=r.waitForTerminalExit)==null?void 0:g.call(r,_)}case Ft.terminal_kill:{const _=uv.parse(a);return await((E=r.killTerminal)==null?void 0:E.call(r,_))??{}}default:if(r.extMethod)return r.extMethod(o,a);throw Se.methodNotFound(o)}},s=async(o,a)=>{switch(o){case Ft.session_update:{const c=Sv.parse(a);return r.sessionUpdate(c)}default:if(r.extNotification)return r.extNotification(o,a);throw Se.methodNotFound(o)}};x(this,Y,new rD(i,s,t))}async initialize(e){return await l(this,Y).sendRequest(ae.initialize,e)}async newSession(e){return await l(this,Y).sendRequest(ae.session_new,e)}async loadSession(e){return await l(this,Y).sendRequest(ae.session_load,e)??{}}async unstable_forkSession(e){return await l(this,Y).sendRequest(ae.session_fork,e)}async listSessions(e){return await l(this,Y).sendRequest(ae.session_list,e)}async unstable_resumeSession(e){return await l(this,Y).sendRequest(ae.session_resume,e)}async unstable_closeSession(e){return await l(this,Y).sendRequest(ae.session_close,e)}async setSessionMode(e){return await l(this,Y).sendRequest(ae.session_set_mode,e)??{}}async unstable_setSessionModel(e){return await l(this,Y).sendRequest(ae.session_set_model,e)??{}}async setSessionConfigOption(e){return await l(this,Y).sendRequest(ae.session_set_config_option,e)}async authenticate(e){return await l(this,Y).sendRequest(ae.authenticate,e)??{}}async unstable_logout(e){return await l(this,Y).sendRequest(ae.logout,e)??{}}async prompt(e){return await l(this,Y).sendRequest(ae.session_prompt,e)}async cancel(e){return await l(this,Y).sendNotification(ae.session_cancel,e)}async unstable_startNes(e){return await l(this,Y).sendRequest(ae.nes_start,e)}async unstable_suggestNes(e){return await l(this,Y).sendRequest(ae.nes_suggest,e)}async unstable_closeNes(e){return await l(this,Y).sendRequest(ae.nes_close,e)??{}}async unstable_didOpenDocument(e){return await l(this,Y).sendNotification(ae.document_did_open,e)}async unstable_didChangeDocument(e){return await l(this,Y).sendNotification(ae.document_did_change,e)}async unstable_didCloseDocument(e){return await l(this,Y).sendNotification(ae.document_did_close,e)}async unstable_didSaveDocument(e){return await l(this,Y).sendNotification(ae.document_did_save,e)}async unstable_didFocusDocument(e){return await l(this,Y).sendNotification(ae.document_did_focus,e)}async unstable_acceptNes(e){return await l(this,Y).sendNotification(ae.nes_accept,e)}async unstable_rejectNes(e){return await l(this,Y).sendNotification(ae.nes_reject,e)}async extMethod(e,t){return await l(this,Y).sendRequest(e,t)}async extNotification(e,t){return await l(this,Y).sendNotification(e,t)}get signal(){return l(this,Y).signal}get closed(){return l(this,Y).closed}}Y=new WeakMap;var ln,ka,gs,ms,Gr,jr,Ct,vs,de,Ev,zc,xv,Av,$v,Tv,Nc,Vi;class rD{constructor(e,t,r){w(this,de);w(this,ln,new Map);w(this,ka,0);w(this,gs);w(this,ms);w(this,Gr);w(this,jr,Promise.resolve());w(this,Ct,new AbortController);w(this,vs);x(this,gs,e),x(this,ms,t),x(this,Gr,r),x(this,vs,new Promise(i=>{l(this,Ct).signal.addEventListener("abort",()=>i())})),m(this,de,Ev).call(this)}get signal(){return l(this,Ct).signal}get closed(){return l(this,vs)}async sendRequest(e,t){m(this,de,Nc).call(this);const r=Xh(this,ka)._++,i=new Promise((s,o)=>{l(this,ln).set(r,{resolve:s,reject:o})});return await m(this,de,Vi).call(this,{jsonrpc:"2.0",id:r,method:e,params:t}),i}async sendNotification(e,t){m(this,de,Nc).call(this),await m(this,de,Vi).call(this,{jsonrpc:"2.0",method:e,params:t})}}ln=new WeakMap,ka=new WeakMap,gs=new WeakMap,ms=new WeakMap,Gr=new WeakMap,jr=new WeakMap,Ct=new WeakMap,vs=new WeakMap,de=new WeakSet,Ev=async function(){let e;try{const t=l(this,Gr).readable.getReader();try{for(;!l(this,Ct).signal.aborted;){const{value:r,done:i}=await t.read();if(i)break;if(r)try{m(this,de,xv).call(this,r)}catch(s){console.error("Unexpected error during message processing:",r,s),"id"in r&&r.id!==void 0&&m(this,de,Vi).call(this,{jsonrpc:"2.0",id:r.id,error:{code:-32700,message:"Parse error"}})}}}finally{t.releaseLock()}}catch(t){e=t}finally{m(this,de,zc).call(this,e)}},zc=function(e){if(l(this,Ct).signal.aborted)return;const t=e??new Error("ACP connection closed");for(const r of l(this,ln).values())r.reject(t);l(this,ln).clear(),l(this,Ct).abort(t)},xv=async function(e){if("method"in e&&"id"in e){const t=await m(this,de,Av).call(this,e.method,e.params);"error"in t&&console.error("Error handling request",e,t.error),await m(this,de,Vi).call(this,{jsonrpc:"2.0",id:e.id,...t})}else if("method"in e){const t=await m(this,de,$v).call(this,e.method,e.params);"error"in t&&console.error("Error handling notification",e,t.error)}else"id"in e?m(this,de,Tv).call(this,e):console.error("Invalid message",{message:e})},Av=async function(e,t){try{return{result:await l(this,gs).call(this,e,t)??null}}catch(r){if(r instanceof Se)return r.toResult();if(r instanceof Wp)return Se.invalidParams(r.format()).toResult();let i;(r instanceof Error||typeof r=="object"&&r!=null&&"message"in r&&typeof r.message=="string")&&(i=r.message);try{return Se.internalError(i?JSON.parse(i):{}).toResult()}catch{return Se.internalError({details:i}).toResult()}}},$v=async function(e,t){try{return await l(this,ms).call(this,e,t),{result:null}}catch(r){if(r instanceof Se)return r.toResult();if(r instanceof Wp)return Se.invalidParams(r.format()).toResult();let i;(r instanceof Error||typeof r=="object"&&r!=null&&"message"in r&&typeof r.message=="string")&&(i=r.message);try{return Se.internalError(i?JSON.parse(i):{}).toResult()}catch{return Se.internalError({details:i}).toResult()}}},Tv=function(e){const t=l(this,ln).get(e.id);if(t){if("result"in e)t.resolve(e.result);else if("error"in e){const{code:r,message:i,data:s}=e.error;t.reject(new Se(r,i,s))}l(this,ln).delete(e.id)}else console.error("Got response to unknown request",e.id)},Nc=function(){if(l(this,Ct).signal.aborted)throw l(this,Ct).signal.reason??new Error("ACP connection closed")},Vi=async function(e){return x(this,jr,l(this,jr).then(async()=>{const t=l(this,Gr).writable.getWriter();try{await t.write(e)}finally{t.releaseLock()}}).catch(t=>{m(this,de,zc).call(this,t)})),l(this,jr)};class Se extends Error{constructor(t,r,i){super(r);b(this,"code");b(this,"data");this.code=t,this.name="RequestError",this.data=i}static parseError(t,r){return new Se(-32700,`Parse error${r?`: ${r}`:""}`,t)}static invalidRequest(t,r){return new Se(-32600,`Invalid request${r?`: ${r}`:""}`,t)}static methodNotFound(t){return new Se(-32601,`"Method not found": ${t}`,{method:t})}static invalidParams(t,r){return new Se(-32602,`Invalid params${r?`: ${r}`:""}`,t)}static internalError(t,r){return new Se(-32603,`Internal error${r?`: ${r}`:""}`,t)}static authRequired(t,r){return new Se(-32e3,`Authentication required${r?`: ${r}`:""}`,t)}static resourceNotFound(t){return new Se(-32002,`Resource not found${t?`: ${t}`:""}`,t&&{uri:t})}toResult(){return{error:{code:this.code,message:this.message,data:this.data}}}toErrorResponse(){return{code:this.code,message:this.message,data:this.data}}}const iD=/^Sender \(untrusted metadata\):\n```json\n[\s\S]*?\n```\n\n?/,sD=/^\[[^\n]*Working directory:[^\n]*\]\n\n?/,oD=/\[Television screen context\][\s\S]*?\[\/Television screen context\]\n*/,aD=/\[\[\s*(?:reply_to_current|reply_to\s*:\s*[^\]\n]+|audio_as_voice)\s*\]\]\s*/gi,lD="single_session",cD={name:"television-acp-client",version:"0.0.0"},Iv="agent:main:television",uD=ki(wt);var te,Bt,qr,Vt,qn,Yn,Xn,Kn,cn,Yr,Pt,ft,un,Jn,Gt,hn,ys,jt,gt,Ea,qt,T,Cv,Pv,Rv,Uc,Dv,Lv,Ov,Mv,zv,Nv,Uv,Rn,Lr,Or,He,Fv,Mr,Fc,Zc,Yo,Zv,Hv,bs,ws,Hc,zr,Wv,Bv;class hD extends uD{constructor(t){super();w(this,T);w(this,te,pD());w(this,Bt,null);w(this,qr,null);w(this,Vt,null);w(this,qn,null);w(this,Yn,null);w(this,Xn,null);w(this,Kn);w(this,cn,null);w(this,Yr,1);w(this,Pt,null);w(this,ft,null);w(this,un,!1);w(this,Jn,!1);w(this,Gt,null);w(this,hn,new Set);w(this,ys);w(this,jt);w(this,gt);w(this,Ea,t=>{m(this,T,Pv).call(this,t)});w(this,qt,null);w(this,bs,()=>{m(this,T,zr).call(this,"ACP bridge websocket closed")});w(this,ws,()=>{m(this,T,zr).call(this,"ACP bridge websocket error")});x(this,jt,t),x(this,gt,t.sessionMode??lD),x(this,Kn,t.mappedSessionStore??dD()),x(this,ys,t.createSocket??(r=>new WebSocket(r)))}getState(){return l(this,te)}get messages(){return l(this,te).messageOrder.map(t=>l(this,te).messagesById[t]).filter(t=>t!==void 0)}async connect(){if(this.disposed)throw new Error("ACPClient has been disposed");if(l(this,te).lifecycle.status!=="ready"){m(this,T,He).call(this,{lifecycle:{status:"connecting"}}),l(this,qr)??x(this,qr,m(this,T,Cv).call(this));try{await l(this,qr),await m(this,T,Uc).call(this)}catch(t){throw m(this,T,zr).call(this,Co(t)),t}}}dispose(){m(this,T,Hc).call(this),m(this,T,He).call(this,{lifecycle:{status:"disposed"},run:{status:"idle",stopReason:null,canCancel:!1,error:null},bridge:null})}async sendMessage(t){if(await this.connect(),l(this,te).lifecycle.status!=="ready"||l(this,te).run.status==="running"||l(this,te).run.status==="cancelling")throw new Error("ACPClient is not ready to send a new message");const r=t.text.trim();if(!r)throw new Error("Cannot send an empty message");m(this,T,Lr).call(this,{id:m(this,T,Mr).call(this,"user"),kind:"user",text:r,status:"final"}),m(this,T,He).call(this,{run:{status:"running",stopReason:null,canCancel:!0,error:null}});try{const i=await m(this,T,Yo).call(this).prompt({sessionId:m(this,T,Zc).call(this),prompt:[{type:"text",text:m(this,T,Fv).call(this,r)}]});m(this,T,Rn).call(this,i.stopReason==="cancelled"?"cancelled":"final"),m(this,T,He).call(this,{run:{status:i.stopReason==="cancelled"?"cancelled":"completed",stopReason:i.stopReason,canCancel:!1,error:null}})}catch(i){throw m(this,T,Bv).call(this)||(m(this,T,Rn).call(this,"error"),m(this,T,He).call(this,{run:{status:"error",stopReason:null,canCancel:!1,error:Co(i)}})),i}}async cancel(){if(await this.connect(),!l(this,te).run.canCancel||l(this,te).run.status!=="running")throw new Error("No active cancellable run");m(this,T,He).call(this,{run:{...l(this,te).run,status:"cancelling"}}),await m(this,T,Yo).call(this).cancel({sessionId:m(this,T,Zc).call(this)})}setScreenContext(t){var s,o,a;const r={screenID:t.screenID,screenName:t.screenName};if(((s=l(this,ft))==null?void 0:s.screenID)===r.screenID&&((o=l(this,ft))==null?void 0:o.screenName)===r.screenName)return;const i=((a=l(this,ft))==null?void 0:a.screenID)??null;if(x(this,ft,r),l(this,gt)==="single_session"){(!l(this,cn)||i!==r.screenID)&&x(this,un,!0);return}l(this,cn)!==Yp(l(this,gt),r.screenID,l(this,jt).clientGUID??"default-client")&&(x(this,Vt,null),x(this,qn,null),l(this,Bt)&&l(this,te).run.status==="idle"&&m(this,T,Uc).call(this).catch(c=>{m(this,T,zr).call(this,Co(c))}))}}te=new WeakMap,Bt=new WeakMap,qr=new WeakMap,Vt=new WeakMap,qn=new WeakMap,Yn=new WeakMap,Xn=new WeakMap,Kn=new WeakMap,cn=new WeakMap,Yr=new WeakMap,Pt=new WeakMap,ft=new WeakMap,un=new WeakMap,Jn=new WeakMap,Gt=new WeakMap,hn=new WeakMap,ys=new WeakMap,jt=new WeakMap,gt=new WeakMap,Ea=new WeakMap,qt=new WeakMap,T=new WeakSet,Cv=async function(){try{m(this,T,He).call(this,{lifecycle:{status:"connecting"}});const{stream:t,socket:r,metadata:i}=await mD({serverURL:l(this,jt).serverURL,token:l(this,jt).token,createSocket:l(this,ys),onDisconnect:l(this,Ea)});x(this,Xn,i),m(this,T,He).call(this,{bridge:i}),x(this,qt,r),r.addEventListener("close",l(this,bs)),r.addEventListener("error",l(this,ws)),x(this,Bt,new nD(s=>({connection:s,sessionUpdate:async o=>{await m(this,T,Lv).call(this,o)},requestPermission:async o=>m(this,T,Ov).call(this,o)}),t)),await l(this,Bt).initialize({protocolVersion:UI,clientCapabilities:{},clientInfo:cD})}catch(t){throw t}},Pv=function(t){m(this,T,zr).call(this,Co(t))},Rv=function(t){const r=t==null?void 0:t.models;if(!(r!=null&&r.currentModelId))return;const i=r.availableModels.find(s=>s.modelId===r.currentModelId);console.info("[ACPClient] Current model:",(i==null?void 0:i.name)??r.currentModelId,`(${r.currentModelId})`)},Uc=async function(){const t=m(this,T,Hv).call(this);if(l(this,Vt)&&l(this,qn)===t){await l(this,Vt);return}x(this,qn,t),x(this,Vt,m(this,T,Dv).call(this,t)),await l(this,Vt)},Dv=async function(t){var c;const r=m(this,T,Yo).call(this);m(this,T,Wv).call(this);let i,s=!1,o=null;const a={cwd:m(this,T,Zv).call(this),mcpServers:[],_meta:{sessionKey:t}};try{if(x(this,Jn,!0),x(this,Gt,null),((c=l(this,Xn))==null?void 0:c.sessionIdStrategy)==="mapped"){const u=l(this,Kn).getActualSessionId(t);if(u)try{const h=await r.loadSession({...a,sessionId:u});if(fD(h))throw new Error("Mapped ACP session was not found");o=h,i=u,s=!0}catch{const h=await r.newSession(a);o=h,i=h.sessionId,l(this,Kn).setActualSessionId(t,i),s=!1}else{const h=await r.newSession(a);o=h,i=h.sessionId,l(this,Kn).setActualSessionId(t,i),s=!1}}else try{o=await r.loadSession({...a,sessionId:t}),i=t,s=l(this,te).messageOrder.length>0}catch{const u=await r.newSession(a);o=u,i=u.sessionId,s=!1}}finally{x(this,Jn,!1),x(this,Gt,null),m(this,T,Rn).call(this,"final")}m(this,T,Rv).call(this,o),await r.setSessionConfigOption({sessionId:i,configId:"verbose_level",value:"full"}),x(this,Yn,i),x(this,cn,t),s?(l(this,hn).add(t),l(this,gt)==="single_session"&&x(this,un,!1)):(l(this,hn).delete(t),x(this,un,l(this,gt)==="single_session")),m(this,T,He).call(this,{lifecycle:{status:"ready"}})},Lv=async function(t){const r=t.update;switch(r.sessionUpdate){case"user_message_chunk":r.content.type==="text"&&m(this,T,Uv).call(this,r.content.text);return;case"agent_message_chunk":r.content.type==="text"&&m(this,T,Mv).call(this,r.content.text);return;case"tool_call":m(this,T,zv).call(this,r);return;case"tool_call_update":m(this,T,Nv).call(this,r);return;case"agent_thought_chunk":return;default:return}},Ov=async function(t){return{outcome:{outcome:"cancelled"}}},Mv=function(t){x(this,Gt,null);const r=gD(t);if(!r)return;if(!l(this,Pt)){const s={id:m(this,T,Mr).call(this,"assistant"),kind:"assistant",text:r,status:"streaming"};x(this,Pt,s.id),m(this,T,Lr).call(this,s);return}const i=l(this,te).messagesById[l(this,Pt)];if(!i||i.kind!=="assistant")throw new Error("Open assistant message invariant violated");m(this,T,Or).call(this,{...i,text:`${i.text}${r}`,status:"streaming"})},zv=function(t){m(this,T,Rn).call(this,"final");const r=m(this,T,Fc).call(this,t.toolCallId),i=Kp("content"in t?t.content:void 0),s={id:(r==null?void 0:r.id)??m(this,T,Mr).call(this,"tool"),kind:"tool_call",toolCallId:t.toolCallId,title:t.title,toolKind:t.kind??"other",status:t.status==="failed"?"failed":t.status==="completed"?"completed":"in_progress",text:(r==null?void 0:r.text)??i,locations:t.locations??(r==null?void 0:r.locations)};if(r){m(this,T,Or).call(this,s);return}m(this,T,Lr).call(this,s)},Nv=function(t){const r=m(this,T,Fc).call(this,t.toolCallId),i=(r==null?void 0:r.text)??"",s=Kp(t.content),o=s?`${i}${s}`:i,a={id:(r==null?void 0:r.id)??m(this,T,Mr).call(this,"tool"),kind:"tool_call",toolCallId:t.toolCallId,title:(r==null?void 0:r.title)??t.toolCallId,toolKind:(r==null?void 0:r.toolKind)??"other",status:t.status==="failed"?"failed":t.status==="completed"?"completed":"in_progress",text:o,locations:t.locations??(r==null?void 0:r.locations)};if(r){m(this,T,Or).call(this,a);return}m(this,T,Lr).call(this,a)},Uv=function(t){if(m(this,T,Rn).call(this,"final"),!t)return;const r=l(this,Jn)?l(this,Gt):null;if(!r){const s=Xp(t);if(!s)return;const o={id:m(this,T,Mr).call(this,"user"),kind:"user",text:s,status:"final"};m(this,T,Lr).call(this,o),l(this,Jn)&&x(this,Gt,o.id);return}const i=l(this,te).messagesById[r];if(!i||i.kind!=="user")throw new Error("Replay user message invariant violated");m(this,T,Or).call(this,{...i,text:Xp(`${i.text}${t}`)})},Rn=function(t){if(!l(this,Pt))return;const r=l(this,te).messagesById[l(this,Pt)];(r==null?void 0:r.kind)==="assistant"&&m(this,T,Or).call(this,{...r,status:t}),x(this,Pt,null)},Lr=function(t){m(this,T,He).call(this,{messagesById:{...l(this,te).messagesById,[t.id]:t},messageOrder:[...l(this,te).messageOrder,t.id]})},Or=function(t){m(this,T,He).call(this,{messagesById:{...l(this,te).messagesById,[t.id]:t}})},He=function(t){const r={...l(this,te),...t};x(this,te,{...r,sendDisabled:r.lifecycle.status!=="ready"||r.run.status==="running"||r.run.status==="cancelling",cancelDisabled:!(r.run.status==="running"||r.run.status==="cancelling")||!r.run.canCancel}),this.dispatchEvent(new K("change"))},Fv=function(t){const r=l(this,cn);return!l(this,ft)||!r||!(l(this,gt)==="single_session"?l(this,un)||!l(this,hn).has(r):!l(this,hn).has(r))?t:(x(this,un,!1),l(this,hn).add(r),["[Television screen context]","This chat session is coming from a Television client in the screen below.",`screen_id: ${l(this,ft).screenID}`,`screen_name: ${l(this,ft).screenName??""}`,"When the user asks to inspect or change Television state with the tv CLI, use this screen ID with the --screen argument.","[/Television screen context]","",t].join(`
43
- `))},Mr=function(t){const r=`${t}-${l(this,Yr)}`;return x(this,Yr,l(this,Yr)+1),r},Fc=function(t){for(const r of l(this,te).messageOrder){const i=l(this,te).messagesById[r];if((i==null?void 0:i.kind)==="tool_call"&&i.toolCallId===t)return i}return null},Zc=function(){if(!l(this,Yn))throw new Error("ACP session is not ready");return l(this,Yn)},Yo=function(){if(!l(this,Bt))throw new Error("ACP connection is not ready");return l(this,Bt)},Zv=function(){var r;const t=(r=l(this,Xn))==null?void 0:r.sessionCwd;if(!t)throw new Error("ACP bridge session cwd is not ready");return t},Hv=function(){var r;if(l(this,gt)==="single_session")return`${Iv}-${(l(this,jt).clientGUID??"default-client").toLowerCase()}`;const t=(r=l(this,ft))==null?void 0:r.screenID;if(!t)throw new Error("Screen context is required for per-screen session mode");return Yp(l(this,gt),t,l(this,jt).clientGUID??"default-client")},bs=new WeakMap,ws=new WeakMap,Hc=function(){x(this,Bt,null),x(this,qr,null),x(this,Vt,null),x(this,qn,null),x(this,Yn,null),x(this,cn,null),x(this,Xn,null),l(this,qt)&&(l(this,qt).removeEventListener("close",l(this,bs)),l(this,qt).removeEventListener("error",l(this,ws)),l(this,qt).close(),x(this,qt,null))},zr=function(t){this.disposed||l(this,te).lifecycle.status==="disconnected"||(m(this,T,Rn).call(this,"error"),m(this,T,Hc).call(this),m(this,T,He).call(this,{lifecycle:{status:"disconnected",...t?{error:t}:{}},run:{status:"idle",stopReason:null,canCancel:!1,error:null},bridge:null}))},Wv=function(){x(this,Pt,null),x(this,Gt,null),x(this,Yr,1),m(this,T,He).call(this,{run:{status:"idle",stopReason:null,canCancel:!1,error:null},messagesById:{},messageOrder:[]})},Bv=function(){return l(this,te).lifecycle.status==="disconnected"};function dD(){const n=new Map;return{getActualSessionId(e){return n.get(e)??null},setActualSessionId(e,t){n.set(e,t)},clearActualSessionId(e){n.delete(e)}}}function pD(){return{lifecycle:{status:"connecting"},run:{status:"idle",stopReason:null,canCancel:!1,error:null},bridge:null,messagesById:{},messageOrder:[],sendDisabled:!0,cancelDisabled:!0}}function fD(n){return n==null?!0:typeof n=="object"&&Object.keys(n).length===0}function Yp(n,e,t){return n==="single_session"?`${Iv}-${t.toLowerCase()}`:`agent:main:television-${t.toLowerCase()}-${e.toLowerCase()}`}function Vv(n){return n.replace(/^(?:\s*\n)+/,"")}function Xp(n){let e=n;return e=e.replace(iD,""),e=e.replace(sD,""),e=e.replace(oD,""),e=Vv(e),e}function gD(n){let e=n;return e=e.replace(aD,""),e=Vv(e),e}function Kp(n){return!n||n.length===0?"":n.flatMap(e=>e.type==="content"&&e.content.type==="text"?[e.content.text]:[]).join("")}async function mD(n){const e=n.createSocket(bD(n.serverURL,n.token));let t=!1,r,i;const s=new Promise((u,h)=>{r=u,i=h}),o=new ReadableStream({start(u){let h=!1;const p=()=>{e.send(JSON.stringify({type:"acp-bridge-connect"}))},v=_=>{const C=yD(_);if(!C)return;let N;try{N=JSON.parse(C)}catch(P){const W=P instanceof Error?P:new Error(String(P));i(W),u.error(W);return}switch(N.type){case"acp-bridge-status":if(N.status==="ready"){let P;try{P=vD(N)}catch(W){const L=W instanceof Error?W:new Error(String(W));t||i(L),u.error(L);return}t||(t=!0,r(P));return}if(N.status==="error"||N.status==="exited"){const P=new Error(N.error??`ACP bridge ${N.status}`);t||i(P),u.error(P)}return;case"acp-bridge-message":u.enqueue(N.message);return}},g=()=>{var C;if(h)return;h=!0;const _=new Error("ACP bridge websocket closed");t||i(_),(C=n.onDisconnect)==null||C.call(n,_),u.close()},E=()=>{var C;if(h)return;h=!0;const _=new Error("ACP bridge websocket error");t||i(_),(C=n.onDisconnect)==null||C.call(n,_),u.error(_)};e.addEventListener("open",p),e.addEventListener("message",v),e.addEventListener("close",g),e.addEventListener("error",E)}}),a=new WritableStream({async write(u){await s,e.send(JSON.stringify({type:"acp-bridge-message",message:u}))},close(){e.close()},abort(){e.close()}}),c=await s;return{stream:{readable:o,writable:a},socket:e,metadata:c}}function vD(n){const{agent:e,sessionIdStrategy:t,sessionCwd:r}=n;if((e==="openclaw"||e==="hermes")&&(t==="deterministic"||t==="mapped")&&typeof r=="string"&&r.length>0)return{agent:e,sessionIdStrategy:t,sessionCwd:r};throw new Error("ACP bridge ready status missing bootstrap metadata")}function yD(n){if(typeof n=="string")return n;if(n instanceof Uint8Array)return new TextDecoder().decode(n);if(typeof Buffer<"u"&&n instanceof Buffer)return n.toString("utf8");if(typeof n=="object"&&n!==null&&"data"in n){const e=n.data;if(typeof e=="string")return e;if(e instanceof Uint8Array)return new TextDecoder().decode(e);if(Array.isArray(e))return Buffer.concat(e).toString("utf8")}return null}function bD(n,e){const t=new URL(n);return t.protocol=t.protocol==="https:"?"wss:":"ws:",t.pathname="/acp",t.search="",t.searchParams.set("token",e),t.hash="",t.toString()}function Co(n){return n instanceof Error?n.message:String(n)}const Jp="television.acpClientGUID",Qp="television.acpMappedSessions",wD=ki(wt);class SD extends wD{constructor(t){super();b(this,"screenManager");b(this,"clients",new Map);b(this,"options");b(this,"sessionMode");b(this,"clientGUID");b(this,"mappedSessionStore");b(this,"activeClient",null);b(this,"handleActiveScreenChanged",()=>{this.syncActiveClient()});this.screenManager=t.screenManager,this.sessionMode=t.sessionMode??"single_session";const r=t.storage??ED();this.options={serverURL:t.serverURL,token:t.token,...t.createSocket?{createSocket:t.createSocket}:{},...t.sessionMode?{sessionMode:t.sessionMode}:{}},this.clientGUID=t.clientGUID??AD(xD(r)),this.mappedSessionStore=t.mappedSessionStore??(r?new kD(r,t.serverURL):new _D),this.screenManager.addEventListener("active-screen-changed",this.handleActiveScreenChanged),this.syncActiveClient()}getActiveClient(){return this.activeClient}dispose(){this.screenManager.removeEventListener("active-screen-changed",this.handleActiveScreenChanged);for(const t of this.clients.values())t.dispose();this.clients.clear(),this.activeClient=null}syncActiveClient(){const t=this.screenManager.activeScreen,r=t?this.getClientForScreen(t):null;this.activeClient!==r&&(this.activeClient=r,this.dispatchEvent(new K("change")))}getClientForScreen(t){const r=this.sessionMode==="single_session"?"single_session":t.id;let i=this.clients.get(r);return i||(i=new hD({...this.options,sessionMode:this.sessionMode,clientGUID:this.clientGUID,mappedSessionStore:this.mappedSessionStore}),this.clients.set(r,i)),i.setScreenContext({screenID:t.id,screenName:t.name}),i}}var Xr;class _D{constructor(){w(this,Xr,new Map)}getActualSessionId(e){return l(this,Xr).get(e)??null}setActualSessionId(e,t){l(this,Xr).set(e,t)}clearActualSessionId(e){l(this,Xr).delete(e)}}Xr=new WeakMap;const ef=1;var Kr,Ss,Qe,Xo,Ko,Wc;class kD{constructor(e,t){w(this,Qe);w(this,Kr);w(this,Ss);x(this,Kr,e),x(this,Ss,t)}getActualSessionId(e){const t=m(this,Qe,Ko).call(this)[m(this,Qe,Xo).call(this,e)];return typeof t=="string"&&t.length>0?t:null}setActualSessionId(e,t){const r=m(this,Qe,Ko).call(this);r[m(this,Qe,Xo).call(this,e)]=t,m(this,Qe,Wc).call(this,r)}clearActualSessionId(e){const t=m(this,Qe,Ko).call(this);delete t[m(this,Qe,Xo).call(this,e)],m(this,Qe,Wc).call(this,t)}}Kr=new WeakMap,Ss=new WeakMap,Qe=new WeakSet,Xo=function(e){return JSON.stringify([l(this,Ss),e])},Ko=function(){const e=l(this,Kr).getItem(Qp);if(!e)return{};let t;try{t=JSON.parse(e)}catch{return{}}if(typeof t!="object"||t===null||Array.isArray(t))return{};const r=t;return r.version!==ef?{}:typeof r.entries!="object"||r.entries===null||Array.isArray(r.entries)?{}:Object.fromEntries(Object.entries(r.entries).filter(i=>typeof i[1]=="string"))},Wc=function(e){const t={version:ef,entries:e};l(this,Kr).setItem(Qp,JSON.stringify(t))};function ED(){return typeof window>"u"?null:window.localStorage}function xD(n){if(!n)throw new Error("ACPClientManager requires storage when clientGUID is not provided");return n}function AD(n){const e=n.getItem(Jp);if(e)return e;const t=ju().toLowerCase();return n.setItem(Jp,t),t}var _s;class $D extends wt{constructor(){super();w(this,_s,t=>{const r=TD(t);r!==null&&(t.preventDefault(),this.dispatchEvent(new rx("shortcut-triggered",{shortcut:r})))});document.addEventListener("keydown",l(this,_s))}dispose(){document.removeEventListener("keydown",l(this,_s))}}_s=new WeakMap;function TD(n){for(const[e,t]of Object.entries(zx))if(ID(n,t.trigger))return e;return null}function ID(n,e){return!(n.key.toLowerCase()!==e.key.toLowerCase()||n.metaKey!==!!e.meta||n.ctrlKey!==!!e.ctrl||n.shiftKey!==!!e.shift||n.altKey!==!!e.alt)}const CD="serverURL",PD="token",RD="mode",DD="electron";function Gv(n=window.location.search,e=window.location.origin){const r=new URLSearchParams(n).get(CD);return r?new URL(r).origin:new URL(e).origin}function Bc(n=window.location.search){return new URLSearchParams(n).get(PD)}function oh(n=window.location.search){return new URLSearchParams(n).get(RD)===DD}/**
42
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const h of n.seen.entries()){const p=h[1];if(e===h[0]){s(h);continue}if(n.external){const g=(c=n.external.registry.get(h[0]))==null?void 0:c.id;if(e!==h[0]&&g){s(h);continue}}if((u=n.metadataRegistry.get(h[0]))==null?void 0:u.id){s(h);continue}if(p.cycle){s(h);continue}if(p.count>1&&n.reused==="ref"){s(h);continue}}}function Zm(n,e){var o,a,c;const t=n.seen.get(e);if(!t)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=u=>{const h=n.seen.get(u);if(h.ref===null)return;const p=h.def??h.schema,v={...p},g=h.ref;if(h.ref=null,g){r(g);const _=n.seen.get(g),C=_.schema;if(C.$ref&&(n.target==="draft-07"||n.target==="draft-04"||n.target==="openapi-3.0")?(p.allOf=p.allOf??[],p.allOf.push(C)):Object.assign(p,C),Object.assign(p,v),u._zod.parent===g)for(const P in p)P==="$ref"||P==="allOf"||P in v||delete p[P];if(C.$ref&&_.def)for(const P in p)P==="$ref"||P==="allOf"||P in _.def&&JSON.stringify(p[P])===JSON.stringify(_.def[P])&&delete p[P]}const E=u._zod.parent;if(E&&E!==g){r(E);const _=n.seen.get(E);if(_!=null&&_.schema.$ref&&(p.$ref=_.schema.$ref,_.def))for(const C in p)C==="$ref"||C==="allOf"||C in _.def&&JSON.stringify(p[C])===JSON.stringify(_.def[C])&&delete p[C]}n.override({zodSchema:u,jsonSchema:p,path:h.path??[]})};for(const u of[...n.seen.entries()].reverse())r(u[0]);const i={};if(n.target==="draft-2020-12"?i.$schema="https://json-schema.org/draft/2020-12/schema":n.target==="draft-07"?i.$schema="http://json-schema.org/draft-07/schema#":n.target==="draft-04"?i.$schema="http://json-schema.org/draft-04/schema#":n.target,(o=n.external)!=null&&o.uri){const u=(a=n.external.registry.get(e))==null?void 0:a.id;if(!u)throw new Error("Schema is missing an `id` property");i.$id=n.external.uri(u)}Object.assign(i,t.def??t.schema);const s=((c=n.external)==null?void 0:c.defs)??{};for(const u of n.seen.entries()){const h=u[1];h.def&&h.defId&&(s[h.defId]=h.def)}n.external||Object.keys(s).length>0&&(n.target==="draft-2020-12"?i.$defs=s:i.definitions=s);try{const u=JSON.parse(JSON.stringify(i));return Object.defineProperty(u,"~standard",{value:{...e["~standard"],jsonSchema:{input:fa(e,"input",n.processors),output:fa(e,"output",n.processors)}},enumerable:!1,writable:!1}),u}catch{throw new Error("Error converting schema to JSON.")}}function Me(n,e){const t=e??{seen:new Set};if(t.seen.has(n))return!1;t.seen.add(n);const r=n._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return Me(r.element,t);if(r.type==="set")return Me(r.valueType,t);if(r.type==="lazy")return Me(r.getter(),t);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault")return Me(r.innerType,t);if(r.type==="intersection")return Me(r.left,t)||Me(r.right,t);if(r.type==="record"||r.type==="map")return Me(r.keyType,t)||Me(r.valueType,t);if(r.type==="pipe")return Me(r.in,t)||Me(r.out,t);if(r.type==="object"){for(const i in r.shape)if(Me(r.shape[i],t))return!0;return!1}if(r.type==="union"){for(const i of r.options)if(Me(i,t))return!0;return!1}if(r.type==="tuple"){for(const i of r.items)if(Me(i,t))return!0;return!!(r.rest&&Me(r.rest,t))}return!1}const V$=(n,e={})=>t=>{const r=Um({...t,processors:e});return ye(n,r),Fm(r,n),Zm(r,n)},fa=(n,e,t={})=>r=>{const{libraryOptions:i,target:s}=r??{},o=Um({...i??{},target:s,io:e,processors:t});return ye(n,o),Fm(o,n),Zm(o,n)},B$={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},j$=(n,e,t,r)=>{const i=t;i.type="string";const{minimum:s,maximum:o,format:a,patterns:c,contentEncoding:u}=n._zod.bag;if(typeof s=="number"&&(i.minLength=s),typeof o=="number"&&(i.maxLength=o),a&&(i.format=B$[a]??a,i.format===""&&delete i.format,a==="time"&&delete i.format),u&&(i.contentEncoding=u),c&&c.size>0){const h=[...c];h.length===1?i.pattern=h[0].source:h.length>1&&(i.allOf=[...h.map(p=>({...e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"?{type:"string"}:{},pattern:p.source}))])}},q$=(n,e,t,r)=>{const i=t,{minimum:s,maximum:o,format:a,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:h}=n._zod.bag;typeof a=="string"&&a.includes("int")?i.type="integer":i.type="number",typeof h=="number"&&(e.target==="draft-04"||e.target==="openapi-3.0"?(i.minimum=h,i.exclusiveMinimum=!0):i.exclusiveMinimum=h),typeof s=="number"&&(i.minimum=s,typeof h=="number"&&e.target!=="draft-04"&&(h>=s?delete i.minimum:delete i.exclusiveMinimum)),typeof u=="number"&&(e.target==="draft-04"||e.target==="openapi-3.0"?(i.maximum=u,i.exclusiveMaximum=!0):i.exclusiveMaximum=u),typeof o=="number"&&(i.maximum=o,typeof u=="number"&&e.target!=="draft-04"&&(u<=o?delete i.maximum:delete i.exclusiveMaximum)),typeof c=="number"&&(i.multipleOf=c)},Y$=(n,e,t,r)=>{t.type="boolean"},X$=(n,e,t,r)=>{t.not={}},K$=(n,e,t,r)=>{},J$=(n,e,t,r)=>{const i=n._zod.def,s=bm(i.entries);s.every(o=>typeof o=="number")&&(t.type="number"),s.every(o=>typeof o=="string")&&(t.type="string"),t.enum=s},Q$=(n,e,t,r)=>{const i=n._zod.def,s=[];for(const o of i.values)if(o===void 0){if(e.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof o=="bigint"){if(e.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");s.push(Number(o))}else s.push(o);if(s.length!==0)if(s.length===1){const o=s[0];t.type=o===null?"null":typeof o,e.target==="draft-04"||e.target==="openapi-3.0"?t.enum=[o]:t.const=o}else s.every(o=>typeof o=="number")&&(t.type="number"),s.every(o=>typeof o=="string")&&(t.type="string"),s.every(o=>typeof o=="boolean")&&(t.type="boolean"),s.every(o=>o===null)&&(t.type="null"),t.enum=s},eT=(n,e,t,r)=>{if(e.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},tT=(n,e,t,r)=>{if(e.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},nT=(n,e,t,r)=>{const i=t,s=n._zod.def,{minimum:o,maximum:a}=n._zod.bag;typeof o=="number"&&(i.minItems=o),typeof a=="number"&&(i.maxItems=a),i.type="array",i.items=ye(s.element,e,{...r,path:[...r.path,"items"]})},rT=(n,e,t,r)=>{var u;const i=t,s=n._zod.def;i.type="object",i.properties={};const o=s.shape;for(const h in o)i.properties[h]=ye(o[h],e,{...r,path:[...r.path,"properties",h]});const a=new Set(Object.keys(o)),c=new Set([...a].filter(h=>{const p=s.shape[h]._zod;return e.io==="input"?p.optin===void 0:p.optout===void 0}));c.size>0&&(i.required=Array.from(c)),((u=s.catchall)==null?void 0:u._zod.def.type)==="never"?i.additionalProperties=!1:s.catchall?s.catchall&&(i.additionalProperties=ye(s.catchall,e,{...r,path:[...r.path,"additionalProperties"]})):e.io==="output"&&(i.additionalProperties=!1)},iT=(n,e,t,r)=>{const i=n._zod.def,s=i.inclusive===!1,o=i.options.map((a,c)=>ye(a,e,{...r,path:[...r.path,s?"oneOf":"anyOf",c]}));s?t.oneOf=o:t.anyOf=o},sT=(n,e,t,r)=>{const i=n._zod.def,s=ye(i.left,e,{...r,path:[...r.path,"allOf",0]}),o=ye(i.right,e,{...r,path:[...r.path,"allOf",1]}),a=u=>"allOf"in u&&Object.keys(u).length===1,c=[...a(s)?s.allOf:[s],...a(o)?o.allOf:[o]];t.allOf=c},oT=(n,e,t,r)=>{const i=t,s=n._zod.def;i.type="object";const o=s.keyType,a=o._zod.bag,c=a==null?void 0:a.patterns;if(s.mode==="loose"&&c&&c.size>0){const h=ye(s.valueType,e,{...r,path:[...r.path,"patternProperties","*"]});i.patternProperties={};for(const p of c)i.patternProperties[p.source]=h}else(e.target==="draft-07"||e.target==="draft-2020-12")&&(i.propertyNames=ye(s.keyType,e,{...r,path:[...r.path,"propertyNames"]})),i.additionalProperties=ye(s.valueType,e,{...r,path:[...r.path,"additionalProperties"]});const u=o._zod.values;if(u){const h=[...u].filter(p=>typeof p=="string"||typeof p=="number");h.length>0&&(i.required=h)}},aT=(n,e,t,r)=>{const i=n._zod.def,s=ye(i.innerType,e,r),o=e.seen.get(n);e.target==="openapi-3.0"?(o.ref=i.innerType,t.nullable=!0):t.anyOf=[s,{type:"null"}]},lT=(n,e,t,r)=>{const i=n._zod.def;ye(i.innerType,e,r);const s=e.seen.get(n);s.ref=i.innerType},cT=(n,e,t,r)=>{const i=n._zod.def;ye(i.innerType,e,r);const s=e.seen.get(n);s.ref=i.innerType,t.default=JSON.parse(JSON.stringify(i.defaultValue))},uT=(n,e,t,r)=>{const i=n._zod.def;ye(i.innerType,e,r);const s=e.seen.get(n);s.ref=i.innerType,e.io==="input"&&(t._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},hT=(n,e,t,r)=>{const i=n._zod.def;ye(i.innerType,e,r);const s=e.seen.get(n);s.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}t.default=o},dT=(n,e,t,r)=>{const i=n._zod.def,s=e.io==="input"?i.in._zod.def.type==="transform"?i.out:i.in:i.out;ye(s,e,r);const o=e.seen.get(n);o.ref=s},pT=(n,e,t,r)=>{const i=n._zod.def;ye(i.innerType,e,r);const s=e.seen.get(n);s.ref=i.innerType,t.readOnly=!0},Hm=(n,e,t,r)=>{const i=n._zod.def;ye(i.innerType,e,r);const s=e.seen.get(n);s.ref=i.innerType},fT=A("ZodISODateTime",(n,e)=>{gA.init(n,e),ge.init(n,e)});function gT(n){return S$(fT,n)}const mT=A("ZodISODate",(n,e)=>{mA.init(n,e),ge.init(n,e)});function vT(n){return _$(mT,n)}const yT=A("ZodISOTime",(n,e)=>{vA.init(n,e),ge.init(n,e)});function bT(n){return k$(yT,n)}const wT=A("ZodISODuration",(n,e)=>{yA.init(n,e),ge.init(n,e)});function ST(n){return E$(wT,n)}const Wm=(n,e)=>{km.init(n,e),n.name="ZodError",Object.defineProperties(n,{format:{value:t=>l1(n,t)},flatten:{value:t=>a1(n,t)},addIssue:{value:t=>{n.issues.push(t),n.message=JSON.stringify(n.issues,Oc,2)}},addIssues:{value:t=>{n.issues.push(...t),n.message=JSON.stringify(n.issues,Oc,2)}},isEmpty:{get(){return n.issues.length===0}}})},Vp=A("ZodError",Wm),ut=A("ZodError",Wm,{Parent:Error}),_T=rh(ut),kT=ih(ut),ET=Xa(ut),xT=Ka(ut),AT=h1(ut),$T=d1(ut),TT=p1(ut),IT=f1(ut),CT=g1(ut),PT=m1(ut),RT=v1(ut),DT=y1(ut),fe=A("ZodType",(n,e)=>(pe.init(n,e),Object.assign(n["~standard"],{jsonSchema:{input:fa(n,"input"),output:fa(n,"output")}}),n.toJSONSchema=V$(n,{}),n.def=e,n.type=e.type,Object.defineProperty(n,"_def",{value:e}),n.check=(...t)=>n.clone(En(e,{checks:[...e.checks??[],...t.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0}),n.with=n.check,n.clone=(t,r)=>xn(n,t,r),n.brand=()=>n,n.register=(t,r)=>(t.add(n,r),n),n.parse=(t,r)=>_T(n,t,r,{callee:n.parse}),n.safeParse=(t,r)=>ET(n,t,r),n.parseAsync=async(t,r)=>kT(n,t,r,{callee:n.parseAsync}),n.safeParseAsync=async(t,r)=>xT(n,t,r),n.spa=n.safeParseAsync,n.encode=(t,r)=>AT(n,t,r),n.decode=(t,r)=>$T(n,t,r),n.encodeAsync=async(t,r)=>TT(n,t,r),n.decodeAsync=async(t,r)=>IT(n,t,r),n.safeEncode=(t,r)=>CT(n,t,r),n.safeDecode=(t,r)=>PT(n,t,r),n.safeEncodeAsync=async(t,r)=>RT(n,t,r),n.safeDecodeAsync=async(t,r)=>DT(n,t,r),n.refine=(t,r)=>n.check(EI(t,r)),n.superRefine=t=>n.check(xI(t)),n.overwrite=t=>n.check(Ei(t)),n.optional=()=>qp(n),n.exactOptional=()=>hI(n),n.nullable=()=>Yp(n),n.nullish=()=>qp(Yp(n)),n.nonoptional=t=>vI(n,t),n.array=()=>D(n),n.or=t=>G([n,t]),n.and=t=>Qa(n,t),n.transform=t=>Xp(n,cI(t)),n.default=t=>fI(n,t),n.prefault=t=>mI(n,t),n.catch=t=>bI(n,t),n.pipe=t=>Xp(n,t),n.readonly=()=>_I(n),n.describe=t=>{const r=n.clone();return Gi.add(r,{description:t}),r},Object.defineProperty(n,"description",{get(){var t;return(t=Gi.get(n))==null?void 0:t.description},configurable:!0}),n.meta=(...t)=>{if(t.length===0)return Gi.get(n);const r=n.clone();return Gi.add(r,t[0]),r},n.isOptional=()=>n.safeParse(void 0).success,n.isNullable=()=>n.safeParse(null).success,n.apply=t=>t(n),n)),Gm=A("_ZodString",(n,e)=>{sh.init(n,e),fe.init(n,e),n._zod.processJSONSchema=(r,i,s)=>j$(n,r,i);const t=n._zod.bag;n.format=t.format??null,n.minLength=t.minimum??null,n.maxLength=t.maximum??null,n.regex=(...r)=>n.check(C$(...r)),n.includes=(...r)=>n.check(D$(...r)),n.startsWith=(...r)=>n.check(L$(...r)),n.endsWith=(...r)=>n.check(O$(...r)),n.min=(...r)=>n.check(pa(...r)),n.max=(...r)=>n.check(zm(...r)),n.length=(...r)=>n.check(Nm(...r)),n.nonempty=(...r)=>n.check(pa(1,...r)),n.lowercase=r=>n.check(P$(r)),n.uppercase=r=>n.check(R$(r)),n.trim=()=>n.check(z$()),n.normalize=(...r)=>n.check(M$(...r)),n.toLowerCase=()=>n.check(N$()),n.toUpperCase=()=>n.check(U$()),n.slugify=()=>n.check(F$())}),LT=A("ZodString",(n,e)=>{sh.init(n,e),Gm.init(n,e),n.email=t=>n.check(e$(OT,t)),n.url=t=>n.check(s$(MT,t)),n.jwt=t=>n.check(w$(KT,t)),n.emoji=t=>n.check(o$(zT,t)),n.guid=t=>n.check(Zp(Bp,t)),n.uuid=t=>n.check(t$(Io,t)),n.uuidv4=t=>n.check(n$(Io,t)),n.uuidv6=t=>n.check(r$(Io,t)),n.uuidv7=t=>n.check(i$(Io,t)),n.nanoid=t=>n.check(a$(NT,t)),n.guid=t=>n.check(Zp(Bp,t)),n.cuid=t=>n.check(l$(UT,t)),n.cuid2=t=>n.check(c$(FT,t)),n.ulid=t=>n.check(u$(ZT,t)),n.base64=t=>n.check(v$(qT,t)),n.base64url=t=>n.check(y$(YT,t)),n.xid=t=>n.check(h$(HT,t)),n.ksuid=t=>n.check(d$(WT,t)),n.ipv4=t=>n.check(p$(GT,t)),n.ipv6=t=>n.check(f$(VT,t)),n.cidrv4=t=>n.check(g$(BT,t)),n.cidrv6=t=>n.check(m$(jT,t)),n.e164=t=>n.check(b$(XT,t)),n.datetime=t=>n.check(gT(t)),n.date=t=>n.check(vT(t)),n.time=t=>n.check(bT(t)),n.duration=t=>n.check(ST(t))});function d(n){return QA(LT,n)}const ge=A("ZodStringFormat",(n,e)=>{le.init(n,e),Gm.init(n,e)}),OT=A("ZodEmail",(n,e)=>{oA.init(n,e),ge.init(n,e)}),Bp=A("ZodGUID",(n,e)=>{iA.init(n,e),ge.init(n,e)}),Io=A("ZodUUID",(n,e)=>{sA.init(n,e),ge.init(n,e)}),MT=A("ZodURL",(n,e)=>{aA.init(n,e),ge.init(n,e)}),zT=A("ZodEmoji",(n,e)=>{lA.init(n,e),ge.init(n,e)}),NT=A("ZodNanoID",(n,e)=>{cA.init(n,e),ge.init(n,e)}),UT=A("ZodCUID",(n,e)=>{uA.init(n,e),ge.init(n,e)}),FT=A("ZodCUID2",(n,e)=>{hA.init(n,e),ge.init(n,e)}),ZT=A("ZodULID",(n,e)=>{dA.init(n,e),ge.init(n,e)}),HT=A("ZodXID",(n,e)=>{pA.init(n,e),ge.init(n,e)}),WT=A("ZodKSUID",(n,e)=>{fA.init(n,e),ge.init(n,e)}),GT=A("ZodIPv4",(n,e)=>{bA.init(n,e),ge.init(n,e)}),VT=A("ZodIPv6",(n,e)=>{wA.init(n,e),ge.init(n,e)}),BT=A("ZodCIDRv4",(n,e)=>{SA.init(n,e),ge.init(n,e)}),jT=A("ZodCIDRv6",(n,e)=>{_A.init(n,e),ge.init(n,e)}),qT=A("ZodBase64",(n,e)=>{kA.init(n,e),ge.init(n,e)}),YT=A("ZodBase64URL",(n,e)=>{xA.init(n,e),ge.init(n,e)}),XT=A("ZodE164",(n,e)=>{AA.init(n,e),ge.init(n,e)}),KT=A("ZodJWT",(n,e)=>{TA.init(n,e),ge.init(n,e)}),Vm=A("ZodNumber",(n,e)=>{Dm.init(n,e),fe.init(n,e),n._zod.processJSONSchema=(r,i,s)=>q$(n,r,i),n.gt=(r,i)=>n.check(Wp(r,i)),n.gte=(r,i)=>n.check(Ql(r,i)),n.min=(r,i)=>n.check(Ql(r,i)),n.lt=(r,i)=>n.check(Hp(r,i)),n.lte=(r,i)=>n.check(Jl(r,i)),n.max=(r,i)=>n.check(Jl(r,i)),n.int=r=>n.check(jp(r)),n.safe=r=>n.check(jp(r)),n.positive=r=>n.check(Wp(0,r)),n.nonnegative=r=>n.check(Ql(0,r)),n.negative=r=>n.check(Hp(0,r)),n.nonpositive=r=>n.check(Jl(0,r)),n.multipleOf=(r,i)=>n.check(Gp(r,i)),n.step=(r,i)=>n.check(Gp(r,i)),n.finite=()=>n;const t=n._zod.bag;n.minValue=Math.max(t.minimum??Number.NEGATIVE_INFINITY,t.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,n.maxValue=Math.min(t.maximum??Number.POSITIVE_INFINITY,t.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,n.isInt=(t.format??"").includes("int")||Number.isSafeInteger(t.multipleOf??.5),n.isFinite=!0,n.format=t.format??null});function Z(n){return x$(Vm,n)}const JT=A("ZodNumberFormat",(n,e)=>{IA.init(n,e),Vm.init(n,e)});function jp(n){return A$(JT,n)}const QT=A("ZodBoolean",(n,e)=>{CA.init(n,e),fe.init(n,e),n._zod.processJSONSchema=(t,r,i)=>Y$(n,t,r)});function Ee(n){return $$(QT,n)}const eI=A("ZodUnknown",(n,e)=>{PA.init(n,e),fe.init(n,e),n._zod.processJSONSchema=(t,r,i)=>K$()});function S(){return T$(eI)}const tI=A("ZodNever",(n,e)=>{RA.init(n,e),fe.init(n,e),n._zod.processJSONSchema=(t,r,i)=>X$(n,t,r)});function nI(n){return I$(tI,n)}const rI=A("ZodArray",(n,e)=>{DA.init(n,e),fe.init(n,e),n._zod.processJSONSchema=(t,r,i)=>nT(n,t,r,i),n.element=e.element,n.min=(t,r)=>n.check(pa(t,r)),n.nonempty=t=>n.check(pa(1,t)),n.max=(t,r)=>n.check(zm(t,r)),n.length=(t,r)=>n.check(Nm(t,r)),n.unwrap=()=>n.element});function D(n,e){return Z$(rI,n,e)}const Bm=A("ZodObject",(n,e)=>{OA.init(n,e),fe.init(n,e),n._zod.processJSONSchema=(t,r,i)=>rT(n,t,r,i),ee(n,"shape",()=>e.shape),n.keyof=()=>ga(Object.keys(n._zod.def.shape)),n.catchall=t=>n.clone({...n._zod.def,catchall:t}),n.passthrough=()=>n.clone({...n._zod.def,catchall:S()}),n.loose=()=>n.clone({...n._zod.def,catchall:S()}),n.strict=()=>n.clone({...n._zod.def,catchall:nI()}),n.strip=()=>n.clone({...n._zod.def,catchall:void 0}),n.extend=t=>n1(n,t),n.safeExtend=t=>r1(n,t),n.merge=t=>i1(n,t),n.pick=t=>e1(n,t),n.omit=t=>t1(n,t),n.partial=(...t)=>s1(qm,n,t[0]),n.required=(...t)=>o1(Ym,n,t[0])});function jm(n,e){const t={type:"object",shape:n??{},...O(e)};return new Bm(t)}function f(n,e){return new Bm({type:"object",shape:n,catchall:S(),...O(e)})}const iI=A("ZodUnion",(n,e)=>{MA.init(n,e),fe.init(n,e),n._zod.processJSONSchema=(t,r,i)=>iT(n,t,r,i),n.options=e.options});function G(n,e){return new iI({type:"union",options:n,...O(e)})}const sI=A("ZodIntersection",(n,e)=>{zA.init(n,e),fe.init(n,e),n._zod.processJSONSchema=(t,r,i)=>sT(n,t,r,i)});function Qa(n,e){return new sI({type:"intersection",left:n,right:e})}const oI=A("ZodRecord",(n,e)=>{NA.init(n,e),fe.init(n,e),n._zod.processJSONSchema=(t,r,i)=>oT(n,t,r,i),n.keyType=e.keyType,n.valueType=e.valueType});function k(n,e,t){return new oI({type:"record",keyType:n,valueType:e,...O(t)})}const zc=A("ZodEnum",(n,e)=>{UA.init(n,e),fe.init(n,e),n._zod.processJSONSchema=(r,i,s)=>J$(n,r,i),n.enum=e.entries,n.options=Object.values(e.entries);const t=new Set(Object.keys(e.entries));n.extract=(r,i)=>{const s={};for(const o of r)if(t.has(o))s[o]=e.entries[o];else throw new Error(`Key ${o} not found in enum`);return new zc({...e,checks:[],...O(i),entries:s})},n.exclude=(r,i)=>{const s={...e.entries};for(const o of r)if(t.has(o))delete s[o];else throw new Error(`Key ${o} not found in enum`);return new zc({...e,checks:[],...O(i),entries:s})}});function ga(n,e){const t=Array.isArray(n)?Object.fromEntries(n.map(r=>[r,r])):n;return new zc({type:"enum",entries:t,...O(e)})}const aI=A("ZodLiteral",(n,e)=>{FA.init(n,e),fe.init(n,e),n._zod.processJSONSchema=(t,r,i)=>Q$(n,t,r),n.values=new Set(e.values),Object.defineProperty(n,"value",{get(){if(e.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return e.values[0]}})});function $(n,e){return new aI({type:"literal",values:Array.isArray(n)?n:[n],...O(e)})}const lI=A("ZodTransform",(n,e)=>{ZA.init(n,e),fe.init(n,e),n._zod.processJSONSchema=(t,r,i)=>tT(n,t),n._zod.parse=(t,r)=>{if(r.direction==="backward")throw new vm(n.constructor.name);t.addIssue=s=>{if(typeof s=="string")t.issues.push(ss(s,t.value,e));else{const o=s;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=t.value),o.inst??(o.inst=n),t.issues.push(ss(o))}};const i=e.transform(t.value,t);return i instanceof Promise?i.then(s=>(t.value=s,t)):(t.value=i,t)}});function cI(n){return new lI({type:"transform",transform:n})}const qm=A("ZodOptional",(n,e)=>{Mm.init(n,e),fe.init(n,e),n._zod.processJSONSchema=(t,r,i)=>Hm(n,t,r,i),n.unwrap=()=>n._zod.def.innerType});function qp(n){return new qm({type:"optional",innerType:n})}const uI=A("ZodExactOptional",(n,e)=>{HA.init(n,e),fe.init(n,e),n._zod.processJSONSchema=(t,r,i)=>Hm(n,t,r,i),n.unwrap=()=>n._zod.def.innerType});function hI(n){return new uI({type:"optional",innerType:n})}const dI=A("ZodNullable",(n,e)=>{WA.init(n,e),fe.init(n,e),n._zod.processJSONSchema=(t,r,i)=>aT(n,t,r,i),n.unwrap=()=>n._zod.def.innerType});function Yp(n){return new dI({type:"nullable",innerType:n})}const pI=A("ZodDefault",(n,e)=>{GA.init(n,e),fe.init(n,e),n._zod.processJSONSchema=(t,r,i)=>cT(n,t,r,i),n.unwrap=()=>n._zod.def.innerType,n.removeDefault=n.unwrap});function fI(n,e){return new pI({type:"default",innerType:n,get defaultValue(){return typeof e=="function"?e():Sm(e)}})}const gI=A("ZodPrefault",(n,e)=>{VA.init(n,e),fe.init(n,e),n._zod.processJSONSchema=(t,r,i)=>uT(n,t,r,i),n.unwrap=()=>n._zod.def.innerType});function mI(n,e){return new gI({type:"prefault",innerType:n,get defaultValue(){return typeof e=="function"?e():Sm(e)}})}const Ym=A("ZodNonOptional",(n,e)=>{BA.init(n,e),fe.init(n,e),n._zod.processJSONSchema=(t,r,i)=>lT(n,t,r,i),n.unwrap=()=>n._zod.def.innerType});function vI(n,e){return new Ym({type:"nonoptional",innerType:n,...O(e)})}const yI=A("ZodCatch",(n,e)=>{jA.init(n,e),fe.init(n,e),n._zod.processJSONSchema=(t,r,i)=>hT(n,t,r,i),n.unwrap=()=>n._zod.def.innerType,n.removeCatch=n.unwrap});function bI(n,e){return new yI({type:"catch",innerType:n,catchValue:typeof e=="function"?e:()=>e})}const wI=A("ZodPipe",(n,e)=>{qA.init(n,e),fe.init(n,e),n._zod.processJSONSchema=(t,r,i)=>dT(n,t,r,i),n.in=e.in,n.out=e.out});function Xp(n,e){return new wI({type:"pipe",in:n,out:e})}const SI=A("ZodReadonly",(n,e)=>{YA.init(n,e),fe.init(n,e),n._zod.processJSONSchema=(t,r,i)=>pT(n,t,r,i),n.unwrap=()=>n._zod.def.innerType});function _I(n){return new SI({type:"readonly",innerType:n})}const kI=A("ZodCustom",(n,e)=>{XA.init(n,e),fe.init(n,e),n._zod.processJSONSchema=(t,r,i)=>eT(n,t)});function EI(n,e={}){return H$(kI,n,e)}function xI(n){return W$(n)}const ec={custom:"custom"},AI=["text/markdown","text/html"],$I=["committed","pending"];function TI(n){let e;try{e=new URL(n)}catch{return!1}return e.protocol==="http:"||e.protocol==="https:"}jm({id:d().min(1),type:ga(AI),title:d(),status:ga($I),externalFilePath:d().optional(),externalURL:d().optional()}).superRefine((n,e)=>{n.externalFilePath!==void 0&&n.externalURL!==void 0&&e.addIssue({code:ec.custom,message:"externalFilePath and externalURL are mutually exclusive",path:["externalURL"]}),n.externalURL!==void 0&&(TI(n.externalURL)||e.addIssue({code:ec.custom,message:"externalURL must be an http(s) URL",path:["externalURL"]}),n.status!=="committed"&&e.addIssue({code:ec.custom,message:"URL-backed artifacts must have status committed",path:["status"]}))});jm({name:d().min(1),description:d(),accepts:D(d().min(1)).min(1)});function Xm(n){return typeof n=="object"&&n!==null}function II(n){return!Xm(n)||n.type!=="ready"?!1:!("id"in n)}function CI(n){return!(!Xm(n)||n.type!=="update-content"||typeof n.id!="string"||typeof n.content!="string")}function PI(n,e){if(n===e)return 2;if(n==="*/*")return 0;const t=n.indexOf("/");if(t>0&&n.slice(t+1)==="*"){const r=n.slice(0,t),i=e.indexOf("/");if(i>0&&e.slice(0,i)===r)return 1}return null}function RI(n,e){let t=null;for(const r of n.accepts){const i=PI(r,e);i!==null&&(t===null||i>t)&&(t=i)}return t}function DI(n,e){let t=-1,r=null;for(const i of e){const s=RI(i,n);s!==null&&(s>t||s===t&&r!==null&&i.id<r.id)&&(t=s,r=i)}return r}const LI=4401;class Nc extends Error{constructor(e="Authentication required"){super(e),this.name="AuthError"}}class Uc extends wt{constructor(t){super();b(this,"url");b(this,"name");b(this,"token");b(this,"status","disconnected");b(this,"screens",new Map);b(this,"views",[]);b(this,"client");b(this,"createSocket");b(this,"createClient");b(this,"socket",null);b(this,"connectAttempt",0);this.url=ht(t.url),this.name=t.name,this.token=t.token??null,this.createSocket=t.createSocket??(r=>new WebSocket(r)),this.createClient=t.createClient??((r,i)=>new zx(r,{token:i??void 0})),this.client=this.createClient(this.url,this.token)}async connect(){var i;this.connectAttempt+=1;const t=this.connectAttempt;(i=this.socket)==null||i.close(),this.client=this.createClient(this.url,this.token),this.status="connecting",this.dispatchEvent(new K("change"));const r=this.createSocket(OI(this.url,this.token));return this.socket=r,await new Promise((s,o)=>{let a=!1;const c=()=>{a||this.connectAttempt!==t||(a=!0,this.status="connected",this.dispatchEvent(new K("change")),s())},u=p=>{a||this.connectAttempt!==t||(a=!0,this.status="disconnected",this.dispatchEvent(new K("change")),o(p))},h=async()=>{try{const[{screens:p},v]=await Promise.all([this.client.screens.list(),this.client.views.list()]);this.screens=new Map(p.map(g=>[g.id,structuredClone(g)])),this.views=v,this.dispatchEvent(new K("change")),c()}catch(p){u(p instanceof Error?p:new Error(String(p)))}};r.addEventListener("open",()=>{h()}),r.addEventListener("message",p=>{const v=zI(p);v&&(this.applyServerEvent(v),this.dispatchEvent(new cm("server-event",{serverURL:this.url,event:v})))}),r.addEventListener("close",p=>{if(this.connectAttempt===t){if(this.socket=null,MI(p)===LI){u(new Nc);return}if(!a){u(new Error("Connection closed before initialization"));return}this.status="disconnected",this.dispatchEvent(new K("change"))}}),r.addEventListener("error",()=>{u(new Error("WebSocket connection failed"))})})}disconnect(){var t;this.connectAttempt+=1,(t=this.socket)==null||t.close(),this.socket=null,this.status="disconnected",this.dispatchEvent(new K("change"))}getViewURL(t){const r=DI(t.type,this.views);if(!r)return null;const i=`${this.url}/views/${encodeURIComponent(r.id)}/`;return this.token===null?i:`${i}?token=${encodeURIComponent(this.token)}`}getContentURL(t){const r=`${this.url}/artifacts/${encodeURIComponent(t)}/content`;return this.token===null?r:`${r}?token=${encodeURIComponent(this.token)}`}async createScreen(t){const{screen:r}=await this.client.screens.create({name:t});return this.screens.set(r.id,structuredClone(r)),r}applyServerEvent(t){switch(t.type){case"screen-created":this.screens.set(t.screen.id,structuredClone(t.screen)),this.dispatchEvent(new jo("screens-changed"));break;case"screen-updated":this.screens.set(t.screen.id,structuredClone(t.screen)),this.dispatchEvent(new jo("screens-changed"));break;case"screen-removed":this.screens.delete(t.screenID),this.dispatchEvent(new jo("screens-changed"));break;case"artifact-created":break;case"artifact-attached":{const r=this.screens.get(t.screenID);r&&!om(r.layout,t.artifact.id)&&(r.layout=[...r.layout,sm(t.artifact.id,{id:t.cardID})]);break}case"artifact-removed":{const r=this.screens.get(t.screenID);r&&(r.layout=Xg(r.layout,t.artifactID));break}}}}function OI(n,e){const t=new URL(n);return t.protocol=t.protocol==="https:"?"wss:":"ws:",t.pathname="/events",t.search="",e&&t.searchParams.set("token",e),t.hash="",t.toString()}function MI(n){return typeof n=="object"&&n!==null&&"code"in n&&typeof n.code=="number"?n.code:null}function zI(n){const e=typeof n=="string"?n:typeof n=="object"&&n!==null&&"data"in n&&typeof n.data=="string"?n.data:"";if(!e)return null;try{return JSON.parse(e)}catch{return null}}const NI="Local";class UI extends wt{constructor(t){super();b(this,"servers",new Map);b(this,"localServerURL");b(this,"localStore");b(this,"createSocket");b(this,"lastActiveServerURL");b(this,"serverListeners",new Map);b(this,"handleLocalStoreChange",()=>{const t=this.localStore.get().activeServerURL;t!==this.lastActiveServerURL&&(this.lastActiveServerURL=t,this.dispatchEvent(new K("change")))});this.localStore=t.localStore,this.localServerURL=t.localServerURL?ht(t.localServerURL):null,this.createSocket=t.createSocket??(r=>new WebSocket(r)),this.lastActiveServerURL=this.localStore.get().activeServerURL,this.localStore.addEventListener("change",this.handleLocalStoreChange)}get activeServer(){const t=this.localStore.get().activeServerURL;return t===null?null:this.servers.get(t)??null}add(t){const r=ht(t.url);this.servers.get(r)&&this.remove(r),this.servers.set(r,t);const s=()=>{this.dispatchEvent(new K("change"))},o=c=>{this.dispatchEvent(new cm("server-event",{serverURL:c.serverURL,event:c.event}))},a=()=>{this.dispatchEvent(new jo("screens-changed"))};t.addEventListener("change",s),t.addEventListener("server-event",o),t.addEventListener("screens-changed",a),this.serverListeners.set(r,{onServerChange:s,onServerEvent:o,onScreensChanged:a}),this.dispatchEvent(new K("change"))}remove(t){const r=ht(t);if(this.localServerURL&&r===this.localServerURL)return;const i=this.servers.get(r);if(!i)return;const s=this.serverListeners.get(r);s&&(i.removeEventListener("change",s.onServerChange),i.removeEventListener("server-event",s.onServerEvent),i.removeEventListener("screens-changed",s.onScreensChanged),this.serverListeners.delete(r)),i.disconnect(),this.servers.delete(r);const o=this.localStore.get(),a=o.activeServerURL===r;this.localStore.set({...o,servers:o.servers.filter(c=>c.url!==r),activeServerURL:a?null:o.activeServerURL}),this.dispatchEvent(new K("change"))}setActive(t){const r=this.localStore.get(),i=t?ht(t.url):null;r.activeServerURL!==i&&this.localStore.set({...r,activeServerURL:i})}connectConfiguredServers(t,r){const i=t?ht(t):null;if(i){const a=this.localStore.get();a.servers.some(u=>ht(u.url)===i)||this.localStore.set({...a,servers:[...a.servers,{url:i,name:NI}]})}const s=this.localStore.get().servers;for(const a of s){const c=ht(a.url),u=i!==null&&c===i,h=new Uc({url:a.url,name:a.name,token:u?r??null:null,createSocket:this.createSocket});this.add(h),h.connect().catch(()=>{})}const o=i?this.servers.get(i)??null:null;this.setActive(o??this.servers.values().next().value??null)}addServer(t,r){const i=ht(t);this.remove(i);const s=this.localStore.get();this.localStore.set({...s,servers:[...s.servers.filter(a=>ht(a.url)!==i),{url:i,name:r}]});const o=new Uc({url:i,name:r,createSocket:this.createSocket});this.add(o),this.setActive(o),o.connect().catch(()=>{})}removeServer(t){this.remove(t)}}const ae={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"},Ft={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"},FI=1,ZI=f({_meta:k(d(),S()).nullish(),terminal:Ee().optional().default(!1)}),HI=f({_meta:k(d(),S()).nullish(),label:d().nullish(),name:d(),optional:Ee().optional().default(!1),secret:Ee().optional().default(!0)}),WI=f({_meta:k(d(),S()).nullish(),description:d().nullish(),id:d(),name:d()}),GI=f({_meta:k(d(),S()).nullish(),description:d().nullish(),id:d(),link:d().nullish(),name:d(),vars:D(HI)}),VI=f({_meta:k(d(),S()).nullish(),args:D(d()).optional(),description:d().nullish(),env:k(d(),d()).optional(),id:d(),name:d()}),BI=G([GI.and(f({type:$("env_var")})),VI.and(f({type:$("terminal")})),WI]),jI=f({_meta:k(d(),S()).nullish(),methodId:d()}),qI=f({_meta:k(d(),S()).nullish()}),YI=f({_meta:k(d(),S()).nullish(),blob:d(),mimeType:d().nullish(),uri:d()}),XI=f({default:Ee().nullish(),description:d().nullish(),title:d().nullish()}),KI=f({_meta:k(d(),S()).nullish()}),JI=f({_meta:k(d(),S()).nullish()}),QI=f({amount:Z(),currency:d()}),eC=f({_meta:k(d(),S()).nullish(),terminalId:d()}),tC=f({_meta:k(d(),S()).nullish(),newText:d(),oldText:d().nullish(),path:d()}),nC=G([d(),Z(),Z(),Ee(),D(d())]),rC=f({content:k(d(),nC).nullish()}),iC=G([rC.and(f({action:$("accept")})),f({action:$("decline")}),f({action:$("cancel")})]),sC=f({_meta:k(d(),S()).nullish()}),Km=d(),oC=f({_meta:k(d(),S()).nullish(),elicitationId:Km}),aC=f({_meta:k(d(),S()).nullish(),action:iC}),lC=$("object"),cC=$("string"),uC=f({_meta:k(d(),S()).nullish()}),hC=f({_meta:k(d(),S()).nullish(),form:sC.nullish(),url:uC.nullish()}),dC=f({elicitationId:Km,url:d().url()}),Jm=f({const:d(),title:d()}),Qm=f({_meta:k(d(),S()).nullish(),name:d(),value:d()}),pC=G([$(-32700),$(-32600),$(-32601),$(-32602),$(-32603),$(-32800),$(-32e3),$(-32002),$(-32042),Z().int().min(-2147483648,{message:"Invalid value: Expected int32 to be >= -2147483648"}).max(2147483647,{message:"Invalid value: Expected int32 to be <= 2147483647"})]),ev=f({code:pC,data:S().optional(),message:d()}),tv=S(),nv=S(),rv=S(),fC=f({_meta:k(d(),S()).nullish(),readTextFile:Ee().optional().default(!1),writeTextFile:Ee().optional().default(!1)}),iv=f({_meta:k(d(),S()).nullish(),name:d(),value:d()}),sv=f({_meta:k(d(),S()).nullish(),name:d(),title:d().nullish(),version:d()}),gC=f({default:Z().nullish(),description:d().nullish(),maximum:Z().nullish(),minimum:Z().nullish(),title:d().nullish()}),mC=f({_meta:k(d(),S()).nullish()}),vC=f({_meta:k(d(),S()).nullish(),additionalDirectories:D(d()).optional(),cursor:d().nullish(),cwd:d().nullish()}),yC=f({_meta:k(d(),S()).nullish()}),bC=f({_meta:k(d(),S()).nullish(),logout:yC.nullish()}),wC=f({_meta:k(d(),S()).nullish()}),SC=f({_meta:k(d(),S()).nullish()}),_C=f({_meta:k(d(),S()).nullish(),http:Ee().optional().default(!1),sse:Ee().optional().default(!1)}),kC=f({_meta:k(d(),S()).nullish(),headers:D(iv),name:d(),url:d()}),EC=f({_meta:k(d(),S()).nullish(),headers:D(iv),name:d(),url:d()}),xC=f({_meta:k(d(),S()).nullish(),args:D(d()),command:d(),env:D(Qm),name:d()}),el=G([kC.and(f({type:$("http")})),EC.and(f({type:$("sse")})),xC]),oh=d(),AC=f({_meta:k(d(),S()).nullish(),description:d().nullish(),modelId:oh,name:d()}),$C=G([$("error"),$("warning"),$("information"),$("hint")]),TC=f({_meta:k(d(),S()).nullish()}),IC=f({_meta:k(d(),S()).nullish()}),CC=f({_meta:k(d(),S()).nullish()}),PC=f({_meta:k(d(),S()).nullish()}),RC=f({_meta:k(d(),S()).nullish()}),DC=f({_meta:k(d(),S()).nullish(),maxCount:Z().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),LC=f({diff:d(),uri:d()}),OC=f({endLine:Z().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),startLine:Z().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),text:d()}),MC=f({_meta:k(d(),S()).nullish()}),zC=f({_meta:k(d(),S()).nullish()}),NC=f({languageId:d(),text:d(),uri:d()}),UC=f({_meta:k(d(),S()).nullish(),maxCount:Z().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),FC=G([$("rejected"),$("ignored"),$("replaced"),$("cancelled")]),ZC=f({excerpts:D(OC),uri:d()}),HC=f({_meta:k(d(),S()).nullish()}),WC=f({_meta:k(d(),S()).nullish()}),GC=f({name:d(),owner:d(),remoteUrl:d()}),VC=f({_meta:k(d(),S()).nullish()}),BC=f({_meta:k(d(),S()).nullish(),jump:MC.nullish(),rename:WC.nullish(),searchAndReplace:VC.nullish()}),jC=f({id:d(),isRegex:Ee().nullish(),replace:d(),search:d(),uri:d()}),qC=G([$("automatic"),$("diagnostic"),$("manual")]),YC=f({_meta:k(d(),S()).nullish(),maxCount:Z().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),XC=f({_meta:k(d(),S()).nullish(),diagnostics:TC.nullish(),editHistory:DC.nullish(),openFiles:zC.nullish(),recentFiles:UC.nullish(),relatedSnippets:HC.nullish(),userActions:YC.nullish()}),KC=f({_meta:k(d(),S()).nullish(),additionalDirectories:D(d()).optional(),cwd:d(),mcpServers:D(el)}),JC=f({default:Z().nullish(),description:d().nullish(),maximum:Z().nullish(),minimum:Z().nullish(),title:d().nullish()}),ov=d(),QC=G([$("allow_once"),$("allow_always"),$("reject_once"),$("reject_always")]),eP=f({_meta:k(d(),S()).nullish(),kind:QC,name:d(),optionId:ov}),tP=G([$("high"),$("medium"),$("low")]),nP=G([$("pending"),$("in_progress"),$("completed")]),rP=f({_meta:k(d(),S()).nullish(),content:d(),priority:tP,status:nP}),iP=f({_meta:k(d(),S()).nullish(),entries:D(rP)}),bn=f({character:Z().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),line:Z().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"})}),sP=f({id:d(),position:bn,uri:d()}),oP=f({id:d(),newName:d(),position:bn,uri:d()}),aP=f({action:d(),position:bn,timestampMs:Z(),uri:d()}),av=G([$("utf-16"),$("utf-32"),$("utf-8")]),lP=f({_meta:k(d(),S()).nullish(),auth:ZI.optional().default({terminal:!1}),elicitation:hC.nullish(),fs:fC.optional().default({readTextFile:!1,writeTextFile:!1}),nes:BC.nullish(),positionEncodings:D(av).optional(),terminal:Ee().optional().default(!1)}),cP=f({_meta:k(d(),S()).nullish(),audio:Ee().optional().default(!1),embeddedContext:Ee().optional().default(!1),image:Ee().optional().default(!1)}),lv=Z().int().gte(0).lte(65535),uP=f({_meta:k(d(),S()).nullish(),clientCapabilities:lP.optional().default({auth:{terminal:!1},fs:{readTextFile:!1,writeTextFile:!1},terminal:!1}),clientInfo:sv.nullish(),protocolVersion:lv}),xi=f({end:bn,start:bn}),hP=f({message:d(),range:xi,severity:$C,uri:d()}),dP=f({languageId:d(),lastFocusedMs:Z().nullish(),uri:d(),visibleRange:xi.nullish()}),pP=f({_meta:k(d(),S()).nullish(),diagnostics:D(hP).nullish(),editHistory:D(LC).nullish(),openFiles:D(dP).nullish(),recentFiles:D(NC).nullish(),relatedSnippets:D(ZC).nullish(),userActions:D(aP).nullish()}),fP=f({newText:d(),range:xi}),gP=f({cursorPosition:bn.nullish(),edits:D(fP),id:d(),uri:d()}),mP=G([gP.and(f({kind:$("edit")})),sP.and(f({kind:$("jump")})),oP.and(f({kind:$("rename")})),jC.and(f({kind:$("searchAndReplace")}))]),vP=f({_meta:k(d(),S()).nullish(),content:d()}),yP=f({_meta:k(d(),S()).nullish()}),dr=G([Z(),d()]).nullable();f({_meta:k(d(),S()).nullish(),requestId:dr});const bP=ga(["assistant","user"]),oo=f({_meta:k(d(),S()).nullish(),audience:D(bP).nullish(),lastModified:d().nullish(),priority:Z().nullish()}),wP=f({_meta:k(d(),S()).nullish(),annotations:oo.nullish(),data:d(),mimeType:d()}),SP=f({_meta:k(d(),S()).nullish(),annotations:oo.nullish(),data:d(),mimeType:d(),uri:d().nullish()}),_P=f({_meta:k(d(),S()).nullish(),annotations:oo.nullish(),description:d().nullish(),mimeType:d().nullish(),name:d(),size:Z().nullish(),title:d().nullish(),uri:d()}),kP=f({_meta:k(d(),S()).nullish(),optionId:ov}),EP=G([f({outcome:$("cancelled")}),kP.and(f({outcome:$("selected")}))]),xP=f({_meta:k(d(),S()).nullish(),outcome:EP}),AP=f({_meta:k(d(),S()).nullish()}),$P=f({_meta:k(d(),S()).nullish()}),TP=f({currentValue:Ee()}),IP=d(),cv=d(),CP=G([$("mode"),$("model"),$("thought_level"),d()]),ah=d(),uv=f({_meta:k(d(),S()).nullish(),description:d().nullish(),name:d(),value:ah}),PP=f({_meta:k(d(),S()).nullish(),group:IP,name:d(),options:D(uv)}),RP=G([D(uv),D(PP)]),DP=f({currentValue:ah,options:RP}),Ai=Qa(G([DP.and(f({type:$("select")})),TP.and(f({type:$("boolean")}))]),f({_meta:k(d(),S()).nullish(),category:CP.nullish(),description:d().nullish(),id:cv,name:d()})),LP=f({_meta:k(d(),S()).nullish(),configOptions:D(Ai)}),OP=f({_meta:k(d(),S()).nullish()}),X=d(),MP=f({_meta:k(d(),S()).nullish(),id:d(),sessionId:X}),zP=f({_meta:k(d(),S()).nullish(),sessionId:X}),NP=f({_meta:k(d(),S()).nullish(),sessionId:X}),UP=f({_meta:k(d(),S()).nullish(),sessionId:X}),hv=f({_meta:k(d(),S()).nullish(),args:D(d()).optional(),command:d(),cwd:d().nullish(),env:D(Qm).optional(),outputByteLimit:Z().nullish(),sessionId:X}),FP=f({_meta:k(d(),S()).nullish(),sessionId:X,uri:d()}),ZP=f({_meta:k(d(),S()).nullish(),position:bn,sessionId:X,uri:d(),version:Z(),visibleRange:xi}),HP=f({_meta:k(d(),S()).nullish(),languageId:d(),sessionId:X,text:d(),uri:d(),version:Z()}),WP=f({_meta:k(d(),S()).nullish(),sessionId:X,uri:d()}),GP=f({_meta:k(d(),S()).nullish(),additionalDirectories:D(d()).optional(),cwd:d(),mcpServers:D(el).optional(),sessionId:X}),dv=f({_meta:k(d(),S()).nullish(),sessionId:X,terminalId:d()}),VP=f({_meta:k(d(),S()).nullish(),additionalDirectories:D(d()).optional(),cwd:d(),mcpServers:D(el),sessionId:X}),pv=f({_meta:k(d(),S()).nullish(),limit:Z().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),line:Z().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:d(),sessionId:X}),BP=f({_meta:k(d(),S()).nullish(),id:d(),reason:FC.nullish(),sessionId:X}),fv=f({_meta:k(d(),S()).nullish(),sessionId:X,terminalId:d()}),jP=f({_meta:k(d(),S()).nullish(),additionalDirectories:D(d()).optional(),cwd:d(),mcpServers:D(el).optional(),sessionId:X}),qP=f({_meta:k(d(),S()).nullish(),additionalDirectories:D(d()).optional(),cwd:d(),sessionId:X,title:d().nullish(),updatedAt:d().nullish()}),YP=f({_meta:k(d(),S()).nullish(),nextCursor:d().nullish(),sessions:D(qP)}),XP=f({_meta:k(d(),S()).nullish(),title:d().nullish(),updatedAt:d().nullish()}),KP=f({_meta:k(d(),S()).nullish()}),tl=d(),JP=f({_meta:k(d(),S()).nullish(),currentModeId:tl}),QP=f({_meta:k(d(),S()).nullish(),description:d().nullish(),id:tl,name:d()}),nl=f({_meta:k(d(),S()).nullish(),availableModes:D(QP),currentModeId:tl}),rl=f({_meta:k(d(),S()).nullish(),availableModels:D(AC),currentModelId:oh}),eR=f({_meta:k(d(),S()).nullish(),configOptions:D(Ai).nullish(),models:rl.nullish(),modes:nl.nullish(),sessionId:X}),tR=f({_meta:k(d(),S()).nullish(),configOptions:D(Ai).nullish(),models:rl.nullish(),modes:nl.nullish()}),nR=f({_meta:k(d(),S()).nullish(),configOptions:D(Ai).nullish(),models:rl.nullish(),modes:nl.nullish(),sessionId:X}),rR=f({_meta:k(d(),S()).nullish(),configOptions:D(Ai).nullish(),models:rl.nullish(),modes:nl.nullish()}),iR=f({_meta:k(d(),S()).nullish()}),sR=f({_meta:k(d(),S()).nullish(),additionalDirectories:AP.nullish(),close:$P.nullish(),fork:OP.nullish(),list:KP.nullish(),resume:iR.nullish()}),oR=Qa(G([f({type:$("boolean"),value:Ee()}),f({value:ah})]),f({_meta:k(d(),S()).nullish(),configId:cv,sessionId:X})),aR=f({_meta:k(d(),S()).nullish(),configOptions:D(Ai)}),lR=f({_meta:k(d(),S()).nullish(),modeId:tl,sessionId:X}),cR=f({_meta:k(d(),S()).nullish()}),uR=f({_meta:k(d(),S()).nullish(),modelId:oh,sessionId:X}),hR=f({_meta:k(d(),S()).nullish()}),dR=f({_meta:k(d(),S()).nullish(),sessionId:X}),pR=G([$("end_turn"),$("max_tokens"),$("max_turn_requests"),$("refusal"),$("cancelled")]),fR=G([$("email"),$("uri"),$("date"),$("date-time")]),gR=f({default:d().nullish(),description:d().nullish(),enum:D(d()).nullish(),format:fR.nullish(),maxLength:Z().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),minLength:Z().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),oneOf:D(Jm).nullish(),pattern:d().nullish(),title:d().nullish()}),mR=f({_meta:k(d(),S()).nullish(),context:pP.nullish(),position:bn,selection:xi.nullish(),sessionId:X,triggerKind:qC,uri:d(),version:Z()}),vR=f({_meta:k(d(),S()).nullish(),suggestions:D(mP)}),yR=f({_meta:k(d(),S()).nullish(),terminalId:d()}),bR=f({_meta:k(d(),S()).nullish(),exitCode:Z().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:d().nullish()}),gv=f({_meta:k(d(),S()).nullish(),sessionId:X,terminalId:d()}),wR=f({_meta:k(d(),S()).nullish(),exitStatus:bR.nullish(),output:d(),truncated:Ee()}),SR=f({_meta:k(d(),S()).nullish(),annotations:oo.nullish(),text:d()}),_R=f({range:xi.nullish(),text:d()}),kR=f({_meta:k(d(),S()).nullish(),contentChanges:D(_R),sessionId:X,uri:d(),version:Z()});f({method:d(),params:G([zP,HP,kR,FP,WP,ZP,MP,BP,tv]).nullish()});const ER=G([$("full"),$("incremental")]),xR=f({_meta:k(d(),S()).nullish(),syncKind:ER}),AR=f({_meta:k(d(),S()).nullish(),didChange:xR.nullish(),didClose:IC.nullish(),didFocus:CC.nullish(),didOpen:PC.nullish(),didSave:RC.nullish()}),$R=f({_meta:k(d(),S()).nullish(),document:AR.nullish()}),TR=f({_meta:k(d(),S()).nullish(),context:XC.nullish(),events:$R.nullish()}),IR=f({_meta:k(d(),S()).nullish(),auth:bC.optional().default({}),loadSession:Ee().optional().default(!1),mcpCapabilities:_C.optional().default({http:!1,sse:!1}),nes:TR.nullish(),positionEncoding:av.nullish(),promptCapabilities:cP.optional().default({audio:!1,embeddedContext:!1,image:!1}),sessionCapabilities:sR.optional().default({})}),CR=f({_meta:k(d(),S()).nullish(),agentCapabilities:IR.optional().default({auth:{},loadSession:!1,mcpCapabilities:{http:!1,sse:!1},promptCapabilities:{audio:!1,embeddedContext:!1,image:!1},sessionCapabilities:{}}),agentInfo:sv.nullish(),authMethods:D(BI).optional().default([]),protocolVersion:lv}),PR=f({_meta:k(d(),S()).nullish(),mimeType:d().nullish(),text:d(),uri:d()}),RR=G([PR,YI]),DR=f({_meta:k(d(),S()).nullish(),annotations:oo.nullish(),resource:RR}),lh=G([SR.and(f({type:$("text")})),SP.and(f({type:$("image")})),wP.and(f({type:$("audio")})),_P.and(f({type:$("resource_link")})),DR.and(f({type:$("resource")}))]),LR=f({_meta:k(d(),S()).nullish(),content:lh}),tc=f({_meta:k(d(),S()).nullish(),content:lh,messageId:d().nullish()}),OR=f({_meta:k(d(),S()).nullish(),messageId:d().nullish(),prompt:D(lh),sessionId:X}),MR=f({anyOf:D(Jm)}),mv=G([LR.and(f({type:$("content")})),tC.and(f({type:$("diff")})),yR.and(f({type:$("terminal")}))]),vv=d(),yv=f({_meta:k(d(),S()).nullish(),line:Z().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:d()}),bv=G([$("pending"),$("in_progress"),$("completed"),$("failed")]),wv=G([$("read"),$("edit"),$("delete"),$("move"),$("search"),$("execute"),$("think"),$("fetch"),$("switch_mode"),$("other")]),zR=f({_meta:k(d(),S()).nullish(),content:D(mv).optional(),kind:wv.optional(),locations:D(yv).optional(),rawInput:S().optional(),rawOutput:S().optional(),status:bv.optional(),title:d(),toolCallId:vv}),Sv=f({_meta:k(d(),S()).nullish(),content:D(mv).nullish(),kind:wv.nullish(),locations:D(yv).nullish(),rawInput:S().optional(),rawOutput:S().optional(),status:bv.nullish(),title:d().nullish(),toolCallId:vv}),_v=f({_meta:k(d(),S()).nullish(),options:D(eP),sessionId:X,toolCall:Sv}),NR=f({_meta:k(d(),S()).nullish(),hint:d()}),UR=NR,FR=f({_meta:k(d(),S()).nullish(),description:d(),input:UR.nullish(),name:d()}),ZR=f({_meta:k(d(),S()).nullish(),availableCommands:D(FR)}),HR=f({enum:D(d()),type:cC}),WR=G([HR,MR]),GR=f({default:D(d()).nullish(),description:d().nullish(),items:WR,maxItems:Z().nullish(),minItems:Z().nullish(),title:d().nullish()}),VR=G([gR.and(f({type:$("string")})),JC.and(f({type:$("number")})),gC.and(f({type:$("integer")})),XI.and(f({type:$("boolean")})),GR.and(f({type:$("array")}))]),BR=f({description:d().nullish(),properties:k(d(),VR).optional().default({}),required:D(d()).nullish(),title:d().nullish(),type:lC.optional().default("object")}),jR=f({requestedSchema:BR}),qR=Qa(G([jR.and(f({mode:$("form")})),dC.and(f({mode:$("url")}))]),f({_meta:k(d(),S()).nullish(),message:d(),sessionId:X})),YR=f({cachedReadTokens:Z().nullish(),cachedWriteTokens:Z().nullish(),inputTokens:Z(),outputTokens:Z(),thoughtTokens:Z().nullish(),totalTokens:Z()}),XR=f({_meta:k(d(),S()).nullish(),stopReason:pR,usage:YR.nullish(),userMessageId:d().nullish()});G([f({id:dr,result:G([CR,qI,SC,nR,tR,YP,eR,rR,JI,cR,aR,XR,hR,dR,vR,KI,rv])}),f({error:ev,id:dr})]);const KR=f({_meta:k(d(),S()).nullish(),cost:QI.nullish(),size:Z(),used:Z()}),JR=G([tc.and(f({sessionUpdate:$("user_message_chunk")})),tc.and(f({sessionUpdate:$("agent_message_chunk")})),tc.and(f({sessionUpdate:$("agent_thought_chunk")})),zR.and(f({sessionUpdate:$("tool_call")})),Sv.and(f({sessionUpdate:$("tool_call_update")})),iP.and(f({sessionUpdate:$("plan")})),ZR.and(f({sessionUpdate:$("available_commands_update")})),JP.and(f({sessionUpdate:$("current_mode_update")})),LP.and(f({sessionUpdate:$("config_option_update")})),XP.and(f({sessionUpdate:$("session_info_update")})),KR.and(f({sessionUpdate:$("usage_update")}))]),kv=f({_meta:k(d(),S()).nullish(),sessionId:X,update:JR});f({method:d(),params:G([kv,oC,tv]).nullish()});const Ev=f({_meta:k(d(),S()).nullish(),sessionId:X,terminalId:d()}),QR=f({_meta:k(d(),S()).nullish(),exitCode:Z().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:d().nullish()}),eD=f({name:d(),uri:d()}),tD=f({_meta:k(d(),S()).nullish(),repository:GC.nullish(),workspaceFolders:D(eD).nullish(),workspaceUri:d().nullish()});f({id:dr,method:d(),params:G([uP,jI,wC,KC,VP,vC,GP,jP,UP,lR,oR,OR,uR,tD,mR,NP,nv]).nullish()});const xv=f({_meta:k(d(),S()).nullish(),content:d(),path:d(),sessionId:X});f({id:dr,method:d(),params:G([xv,pv,_v,hv,gv,fv,Ev,dv,qR,nv]).nullish()});const nD=f({_meta:k(d(),S()).nullish()});G([f({id:dr,result:G([nD,vP,xP,eC,wR,yP,QR,mC,aC,rv])}),f({error:ev,id:dr})]);var Y;class rD{constructor(e,t){w(this,Y);const r=e(this),i=async(o,a)=>{var c,u,h,p,v,g,E;switch(o){case Ft.fs_write_text_file:{const _=xv.parse(a);return(c=r.writeTextFile)==null?void 0:c.call(r,_)}case Ft.fs_read_text_file:{const _=pv.parse(a);return(u=r.readTextFile)==null?void 0:u.call(r,_)}case Ft.session_request_permission:{const _=_v.parse(a);return r.requestPermission(_)}case Ft.terminal_create:{const _=hv.parse(a);return(h=r.createTerminal)==null?void 0:h.call(r,_)}case Ft.terminal_output:{const _=gv.parse(a);return(p=r.terminalOutput)==null?void 0:p.call(r,_)}case Ft.terminal_release:{const _=fv.parse(a);return await((v=r.releaseTerminal)==null?void 0:v.call(r,_))??{}}case Ft.terminal_wait_for_exit:{const _=Ev.parse(a);return(g=r.waitForTerminalExit)==null?void 0:g.call(r,_)}case Ft.terminal_kill:{const _=dv.parse(a);return await((E=r.killTerminal)==null?void 0:E.call(r,_))??{}}default:if(r.extMethod)return r.extMethod(o,a);throw Se.methodNotFound(o)}},s=async(o,a)=>{switch(o){case Ft.session_update:{const c=kv.parse(a);return r.sessionUpdate(c)}default:if(r.extNotification)return r.extNotification(o,a);throw Se.methodNotFound(o)}};x(this,Y,new iD(i,s,t))}async initialize(e){return await l(this,Y).sendRequest(ae.initialize,e)}async newSession(e){return await l(this,Y).sendRequest(ae.session_new,e)}async loadSession(e){return await l(this,Y).sendRequest(ae.session_load,e)??{}}async unstable_forkSession(e){return await l(this,Y).sendRequest(ae.session_fork,e)}async listSessions(e){return await l(this,Y).sendRequest(ae.session_list,e)}async unstable_resumeSession(e){return await l(this,Y).sendRequest(ae.session_resume,e)}async unstable_closeSession(e){return await l(this,Y).sendRequest(ae.session_close,e)}async setSessionMode(e){return await l(this,Y).sendRequest(ae.session_set_mode,e)??{}}async unstable_setSessionModel(e){return await l(this,Y).sendRequest(ae.session_set_model,e)??{}}async setSessionConfigOption(e){return await l(this,Y).sendRequest(ae.session_set_config_option,e)}async authenticate(e){return await l(this,Y).sendRequest(ae.authenticate,e)??{}}async unstable_logout(e){return await l(this,Y).sendRequest(ae.logout,e)??{}}async prompt(e){return await l(this,Y).sendRequest(ae.session_prompt,e)}async cancel(e){return await l(this,Y).sendNotification(ae.session_cancel,e)}async unstable_startNes(e){return await l(this,Y).sendRequest(ae.nes_start,e)}async unstable_suggestNes(e){return await l(this,Y).sendRequest(ae.nes_suggest,e)}async unstable_closeNes(e){return await l(this,Y).sendRequest(ae.nes_close,e)??{}}async unstable_didOpenDocument(e){return await l(this,Y).sendNotification(ae.document_did_open,e)}async unstable_didChangeDocument(e){return await l(this,Y).sendNotification(ae.document_did_change,e)}async unstable_didCloseDocument(e){return await l(this,Y).sendNotification(ae.document_did_close,e)}async unstable_didSaveDocument(e){return await l(this,Y).sendNotification(ae.document_did_save,e)}async unstable_didFocusDocument(e){return await l(this,Y).sendNotification(ae.document_did_focus,e)}async unstable_acceptNes(e){return await l(this,Y).sendNotification(ae.nes_accept,e)}async unstable_rejectNes(e){return await l(this,Y).sendNotification(ae.nes_reject,e)}async extMethod(e,t){return await l(this,Y).sendRequest(e,t)}async extNotification(e,t){return await l(this,Y).sendNotification(e,t)}get signal(){return l(this,Y).signal}get closed(){return l(this,Y).closed}}Y=new WeakMap;var ln,ka,gs,ms,Br,jr,Ct,vs,de,Av,Fc,$v,Tv,Iv,Cv,Zc,Vi;class iD{constructor(e,t,r){w(this,de);w(this,ln,new Map);w(this,ka,0);w(this,gs);w(this,ms);w(this,Br);w(this,jr,Promise.resolve());w(this,Ct,new AbortController);w(this,vs);x(this,gs,e),x(this,ms,t),x(this,Br,r),x(this,vs,new Promise(i=>{l(this,Ct).signal.addEventListener("abort",()=>i())})),m(this,de,Av).call(this)}get signal(){return l(this,Ct).signal}get closed(){return l(this,vs)}async sendRequest(e,t){m(this,de,Zc).call(this);const r=Qh(this,ka)._++,i=new Promise((s,o)=>{l(this,ln).set(r,{resolve:s,reject:o})});return await m(this,de,Vi).call(this,{jsonrpc:"2.0",id:r,method:e,params:t}),i}async sendNotification(e,t){m(this,de,Zc).call(this),await m(this,de,Vi).call(this,{jsonrpc:"2.0",method:e,params:t})}}ln=new WeakMap,ka=new WeakMap,gs=new WeakMap,ms=new WeakMap,Br=new WeakMap,jr=new WeakMap,Ct=new WeakMap,vs=new WeakMap,de=new WeakSet,Av=async function(){let e;try{const t=l(this,Br).readable.getReader();try{for(;!l(this,Ct).signal.aborted;){const{value:r,done:i}=await t.read();if(i)break;if(r)try{m(this,de,$v).call(this,r)}catch(s){console.error("Unexpected error during message processing:",r,s),"id"in r&&r.id!==void 0&&m(this,de,Vi).call(this,{jsonrpc:"2.0",id:r.id,error:{code:-32700,message:"Parse error"}})}}}finally{t.releaseLock()}}catch(t){e=t}finally{m(this,de,Fc).call(this,e)}},Fc=function(e){if(l(this,Ct).signal.aborted)return;const t=e??new Error("ACP connection closed");for(const r of l(this,ln).values())r.reject(t);l(this,ln).clear(),l(this,Ct).abort(t)},$v=async function(e){if("method"in e&&"id"in e){const t=await m(this,de,Tv).call(this,e.method,e.params);"error"in t&&console.error("Error handling request",e,t.error),await m(this,de,Vi).call(this,{jsonrpc:"2.0",id:e.id,...t})}else if("method"in e){const t=await m(this,de,Iv).call(this,e.method,e.params);"error"in t&&console.error("Error handling notification",e,t.error)}else"id"in e?m(this,de,Cv).call(this,e):console.error("Invalid message",{message:e})},Tv=async function(e,t){try{return{result:await l(this,gs).call(this,e,t)??null}}catch(r){if(r instanceof Se)return r.toResult();if(r instanceof Vp)return Se.invalidParams(r.format()).toResult();let i;(r instanceof Error||typeof r=="object"&&r!=null&&"message"in r&&typeof r.message=="string")&&(i=r.message);try{return Se.internalError(i?JSON.parse(i):{}).toResult()}catch{return Se.internalError({details:i}).toResult()}}},Iv=async function(e,t){try{return await l(this,ms).call(this,e,t),{result:null}}catch(r){if(r instanceof Se)return r.toResult();if(r instanceof Vp)return Se.invalidParams(r.format()).toResult();let i;(r instanceof Error||typeof r=="object"&&r!=null&&"message"in r&&typeof r.message=="string")&&(i=r.message);try{return Se.internalError(i?JSON.parse(i):{}).toResult()}catch{return Se.internalError({details:i}).toResult()}}},Cv=function(e){const t=l(this,ln).get(e.id);if(t){if("result"in e)t.resolve(e.result);else if("error"in e){const{code:r,message:i,data:s}=e.error;t.reject(new Se(r,i,s))}l(this,ln).delete(e.id)}else console.error("Got response to unknown request",e.id)},Zc=function(){if(l(this,Ct).signal.aborted)throw l(this,Ct).signal.reason??new Error("ACP connection closed")},Vi=async function(e){return x(this,jr,l(this,jr).then(async()=>{const t=l(this,Br).writable.getWriter();try{await t.write(e)}finally{t.releaseLock()}}).catch(t=>{m(this,de,Fc).call(this,t)})),l(this,jr)};class Se extends Error{constructor(t,r,i){super(r);b(this,"code");b(this,"data");this.code=t,this.name="RequestError",this.data=i}static parseError(t,r){return new Se(-32700,`Parse error${r?`: ${r}`:""}`,t)}static invalidRequest(t,r){return new Se(-32600,`Invalid request${r?`: ${r}`:""}`,t)}static methodNotFound(t){return new Se(-32601,`"Method not found": ${t}`,{method:t})}static invalidParams(t,r){return new Se(-32602,`Invalid params${r?`: ${r}`:""}`,t)}static internalError(t,r){return new Se(-32603,`Internal error${r?`: ${r}`:""}`,t)}static authRequired(t,r){return new Se(-32e3,`Authentication required${r?`: ${r}`:""}`,t)}static resourceNotFound(t){return new Se(-32002,`Resource not found${t?`: ${t}`:""}`,t&&{uri:t})}toResult(){return{error:{code:this.code,message:this.message,data:this.data}}}toErrorResponse(){return{code:this.code,message:this.message,data:this.data}}}const sD=/^Sender \(untrusted metadata\):\n```json\n[\s\S]*?\n```\n\n?/,oD=/^\[[^\n]*Working directory:[^\n]*\]\n\n?/,aD=/\[Television screen context\][\s\S]*?\[\/Television screen context\]\n*/,lD=/\[\[\s*(?:reply_to_current|reply_to\s*:\s*[^\]\n]+|audio_as_voice)\s*\]\]\s*/gi,cD="single_session",uD={name:"television-acp-client",version:"0.0.0"},Pv="agent:main:television",hD=ki(wt);var te,Gt,qr,Vt,qn,Yn,Xn,Kn,cn,Yr,Pt,ft,un,Jn,Bt,hn,ys,jt,gt,Ea,qt,T,Rv,Dv,Lv,Hc,Ov,Mv,zv,Nv,Uv,Fv,Zv,Rn,Lr,Or,He,Hv,Mr,Wc,Gc,Yo,Wv,Gv,bs,ws,Vc,zr,Vv,Bv;class dD extends hD{constructor(t){super();w(this,T);w(this,te,fD());w(this,Gt,null);w(this,qr,null);w(this,Vt,null);w(this,qn,null);w(this,Yn,null);w(this,Xn,null);w(this,Kn);w(this,cn,null);w(this,Yr,1);w(this,Pt,null);w(this,ft,null);w(this,un,!1);w(this,Jn,!1);w(this,Bt,null);w(this,hn,new Set);w(this,ys);w(this,jt);w(this,gt);w(this,Ea,t=>{m(this,T,Dv).call(this,t)});w(this,qt,null);w(this,bs,()=>{m(this,T,zr).call(this,"ACP bridge websocket closed")});w(this,ws,()=>{m(this,T,zr).call(this,"ACP bridge websocket error")});x(this,jt,t),x(this,gt,t.sessionMode??cD),x(this,Kn,t.mappedSessionStore??pD()),x(this,ys,t.createSocket??(r=>new WebSocket(r)))}getState(){return l(this,te)}get messages(){return l(this,te).messageOrder.map(t=>l(this,te).messagesById[t]).filter(t=>t!==void 0)}async connect(){if(this.disposed)throw new Error("ACPClient has been disposed");if(l(this,te).lifecycle.status!=="ready"){m(this,T,He).call(this,{lifecycle:{status:"connecting"}}),l(this,qr)??x(this,qr,m(this,T,Rv).call(this));try{await l(this,qr),await m(this,T,Hc).call(this)}catch(t){throw m(this,T,zr).call(this,Co(t)),t}}}dispose(){m(this,T,Vc).call(this),m(this,T,He).call(this,{lifecycle:{status:"disposed"},run:{status:"idle",stopReason:null,canCancel:!1,error:null},bridge:null})}async sendMessage(t){if(await this.connect(),l(this,te).lifecycle.status!=="ready"||l(this,te).run.status==="running"||l(this,te).run.status==="cancelling")throw new Error("ACPClient is not ready to send a new message");const r=t.text.trim();if(!r)throw new Error("Cannot send an empty message");m(this,T,Lr).call(this,{id:m(this,T,Mr).call(this,"user"),kind:"user",text:r,status:"final"}),m(this,T,He).call(this,{run:{status:"running",stopReason:null,canCancel:!0,error:null}});try{const i=await m(this,T,Yo).call(this).prompt({sessionId:m(this,T,Gc).call(this),prompt:[{type:"text",text:m(this,T,Hv).call(this,r)}]});m(this,T,Rn).call(this,i.stopReason==="cancelled"?"cancelled":"final"),m(this,T,He).call(this,{run:{status:i.stopReason==="cancelled"?"cancelled":"completed",stopReason:i.stopReason,canCancel:!1,error:null}})}catch(i){throw m(this,T,Bv).call(this)||(m(this,T,Rn).call(this,"error"),m(this,T,He).call(this,{run:{status:"error",stopReason:null,canCancel:!1,error:Co(i)}})),i}}async cancel(){if(await this.connect(),!l(this,te).run.canCancel||l(this,te).run.status!=="running")throw new Error("No active cancellable run");m(this,T,He).call(this,{run:{...l(this,te).run,status:"cancelling"}}),await m(this,T,Yo).call(this).cancel({sessionId:m(this,T,Gc).call(this)})}setScreenContext(t){var s,o,a;const r={screenID:t.screenID,screenName:t.screenName};if(((s=l(this,ft))==null?void 0:s.screenID)===r.screenID&&((o=l(this,ft))==null?void 0:o.screenName)===r.screenName)return;const i=((a=l(this,ft))==null?void 0:a.screenID)??null;if(x(this,ft,r),l(this,gt)==="single_session"){(!l(this,cn)||i!==r.screenID)&&x(this,un,!0);return}l(this,cn)!==Kp(l(this,gt),r.screenID,l(this,jt).clientGUID??"default-client")&&(x(this,Vt,null),x(this,qn,null),l(this,Gt)&&l(this,te).run.status==="idle"&&m(this,T,Hc).call(this).catch(c=>{m(this,T,zr).call(this,Co(c))}))}}te=new WeakMap,Gt=new WeakMap,qr=new WeakMap,Vt=new WeakMap,qn=new WeakMap,Yn=new WeakMap,Xn=new WeakMap,Kn=new WeakMap,cn=new WeakMap,Yr=new WeakMap,Pt=new WeakMap,ft=new WeakMap,un=new WeakMap,Jn=new WeakMap,Bt=new WeakMap,hn=new WeakMap,ys=new WeakMap,jt=new WeakMap,gt=new WeakMap,Ea=new WeakMap,qt=new WeakMap,T=new WeakSet,Rv=async function(){try{m(this,T,He).call(this,{lifecycle:{status:"connecting"}});const{stream:t,socket:r,metadata:i}=await vD({serverURL:l(this,jt).serverURL,token:l(this,jt).token,createSocket:l(this,ys),onDisconnect:l(this,Ea)});x(this,Xn,i),m(this,T,He).call(this,{bridge:i}),x(this,qt,r),r.addEventListener("close",l(this,bs)),r.addEventListener("error",l(this,ws)),x(this,Gt,new rD(s=>({connection:s,sessionUpdate:async o=>{await m(this,T,Mv).call(this,o)},requestPermission:async o=>m(this,T,zv).call(this,o)}),t)),await l(this,Gt).initialize({protocolVersion:FI,clientCapabilities:{},clientInfo:uD})}catch(t){throw t}},Dv=function(t){m(this,T,zr).call(this,Co(t))},Lv=function(t){const r=t==null?void 0:t.models;if(!(r!=null&&r.currentModelId))return;const i=r.availableModels.find(s=>s.modelId===r.currentModelId);console.info("[ACPClient] Current model:",(i==null?void 0:i.name)??r.currentModelId,`(${r.currentModelId})`)},Hc=async function(){const t=m(this,T,Gv).call(this);if(l(this,Vt)&&l(this,qn)===t){await l(this,Vt);return}x(this,qn,t),x(this,Vt,m(this,T,Ov).call(this,t)),await l(this,Vt)},Ov=async function(t){var c;const r=m(this,T,Yo).call(this);m(this,T,Vv).call(this);let i,s=!1,o=null;const a={cwd:m(this,T,Wv).call(this),mcpServers:[],_meta:{sessionKey:t}};try{if(x(this,Jn,!0),x(this,Bt,null),((c=l(this,Xn))==null?void 0:c.sessionIdStrategy)==="mapped"){const u=l(this,Kn).getActualSessionId(t);if(u)try{const h=await r.loadSession({...a,sessionId:u});if(gD(h))throw new Error("Mapped ACP session was not found");o=h,i=u,s=!0}catch{const h=await r.newSession(a);o=h,i=h.sessionId,l(this,Kn).setActualSessionId(t,i),s=!1}else{const h=await r.newSession(a);o=h,i=h.sessionId,l(this,Kn).setActualSessionId(t,i),s=!1}}else try{o=await r.loadSession({...a,sessionId:t}),i=t,s=l(this,te).messageOrder.length>0}catch{const u=await r.newSession(a);o=u,i=u.sessionId,s=!1}}finally{x(this,Jn,!1),x(this,Bt,null),m(this,T,Rn).call(this,"final")}m(this,T,Lv).call(this,o),await r.setSessionConfigOption({sessionId:i,configId:"verbose_level",value:"full"}),x(this,Yn,i),x(this,cn,t),s?(l(this,hn).add(t),l(this,gt)==="single_session"&&x(this,un,!1)):(l(this,hn).delete(t),x(this,un,l(this,gt)==="single_session")),m(this,T,He).call(this,{lifecycle:{status:"ready"}})},Mv=async function(t){const r=t.update;switch(r.sessionUpdate){case"user_message_chunk":r.content.type==="text"&&m(this,T,Zv).call(this,r.content.text);return;case"agent_message_chunk":r.content.type==="text"&&m(this,T,Nv).call(this,r.content.text);return;case"tool_call":m(this,T,Uv).call(this,r);return;case"tool_call_update":m(this,T,Fv).call(this,r);return;case"agent_thought_chunk":return;default:return}},zv=async function(t){return{outcome:{outcome:"cancelled"}}},Nv=function(t){x(this,Bt,null);const r=mD(t);if(!r)return;if(!l(this,Pt)){const s={id:m(this,T,Mr).call(this,"assistant"),kind:"assistant",text:r,status:"streaming"};x(this,Pt,s.id),m(this,T,Lr).call(this,s);return}const i=l(this,te).messagesById[l(this,Pt)];if(!i||i.kind!=="assistant")throw new Error("Open assistant message invariant violated");m(this,T,Or).call(this,{...i,text:`${i.text}${r}`,status:"streaming"})},Uv=function(t){m(this,T,Rn).call(this,"final");const r=m(this,T,Wc).call(this,t.toolCallId),i=Qp("content"in t?t.content:void 0),s={id:(r==null?void 0:r.id)??m(this,T,Mr).call(this,"tool"),kind:"tool_call",toolCallId:t.toolCallId,title:t.title,toolKind:t.kind??"other",status:t.status==="failed"?"failed":t.status==="completed"?"completed":"in_progress",text:(r==null?void 0:r.text)??i,locations:t.locations??(r==null?void 0:r.locations)};if(r){m(this,T,Or).call(this,s);return}m(this,T,Lr).call(this,s)},Fv=function(t){const r=m(this,T,Wc).call(this,t.toolCallId),i=(r==null?void 0:r.text)??"",s=Qp(t.content),o=s?`${i}${s}`:i,a={id:(r==null?void 0:r.id)??m(this,T,Mr).call(this,"tool"),kind:"tool_call",toolCallId:t.toolCallId,title:(r==null?void 0:r.title)??t.toolCallId,toolKind:(r==null?void 0:r.toolKind)??"other",status:t.status==="failed"?"failed":t.status==="completed"?"completed":"in_progress",text:o,locations:t.locations??(r==null?void 0:r.locations)};if(r){m(this,T,Or).call(this,a);return}m(this,T,Lr).call(this,a)},Zv=function(t){if(m(this,T,Rn).call(this,"final"),!t)return;const r=l(this,Jn)?l(this,Bt):null;if(!r){const s=Jp(t);if(!s)return;const o={id:m(this,T,Mr).call(this,"user"),kind:"user",text:s,status:"final"};m(this,T,Lr).call(this,o),l(this,Jn)&&x(this,Bt,o.id);return}const i=l(this,te).messagesById[r];if(!i||i.kind!=="user")throw new Error("Replay user message invariant violated");m(this,T,Or).call(this,{...i,text:Jp(`${i.text}${t}`)})},Rn=function(t){if(!l(this,Pt))return;const r=l(this,te).messagesById[l(this,Pt)];(r==null?void 0:r.kind)==="assistant"&&m(this,T,Or).call(this,{...r,status:t}),x(this,Pt,null)},Lr=function(t){m(this,T,He).call(this,{messagesById:{...l(this,te).messagesById,[t.id]:t},messageOrder:[...l(this,te).messageOrder,t.id]})},Or=function(t){m(this,T,He).call(this,{messagesById:{...l(this,te).messagesById,[t.id]:t}})},He=function(t){const r={...l(this,te),...t};x(this,te,{...r,sendDisabled:r.lifecycle.status!=="ready"||r.run.status==="running"||r.run.status==="cancelling",cancelDisabled:!(r.run.status==="running"||r.run.status==="cancelling")||!r.run.canCancel}),this.dispatchEvent(new K("change"))},Hv=function(t){const r=l(this,cn);return!l(this,ft)||!r||!(l(this,gt)==="single_session"?l(this,un)||!l(this,hn).has(r):!l(this,hn).has(r))?t:(x(this,un,!1),l(this,hn).add(r),["[Television screen context]","This chat session is coming from a Television client in the screen below.",`screen_id: ${l(this,ft).screenID}`,`screen_name: ${l(this,ft).screenName??""}`,"When the user asks to inspect or change Television state with the tv CLI, use this screen ID with the --screen argument.","[/Television screen context]","",t].join(`
43
+ `))},Mr=function(t){const r=`${t}-${l(this,Yr)}`;return x(this,Yr,l(this,Yr)+1),r},Wc=function(t){for(const r of l(this,te).messageOrder){const i=l(this,te).messagesById[r];if((i==null?void 0:i.kind)==="tool_call"&&i.toolCallId===t)return i}return null},Gc=function(){if(!l(this,Yn))throw new Error("ACP session is not ready");return l(this,Yn)},Yo=function(){if(!l(this,Gt))throw new Error("ACP connection is not ready");return l(this,Gt)},Wv=function(){var r;const t=(r=l(this,Xn))==null?void 0:r.sessionCwd;if(!t)throw new Error("ACP bridge session cwd is not ready");return t},Gv=function(){var r;if(l(this,gt)==="single_session")return`${Pv}-${(l(this,jt).clientGUID??"default-client").toLowerCase()}`;const t=(r=l(this,ft))==null?void 0:r.screenID;if(!t)throw new Error("Screen context is required for per-screen session mode");return Kp(l(this,gt),t,l(this,jt).clientGUID??"default-client")},bs=new WeakMap,ws=new WeakMap,Vc=function(){x(this,Gt,null),x(this,qr,null),x(this,Vt,null),x(this,qn,null),x(this,Yn,null),x(this,cn,null),x(this,Xn,null),l(this,qt)&&(l(this,qt).removeEventListener("close",l(this,bs)),l(this,qt).removeEventListener("error",l(this,ws)),l(this,qt).close(),x(this,qt,null))},zr=function(t){this.disposed||l(this,te).lifecycle.status==="disconnected"||(m(this,T,Rn).call(this,"error"),m(this,T,Vc).call(this),m(this,T,He).call(this,{lifecycle:{status:"disconnected",...t?{error:t}:{}},run:{status:"idle",stopReason:null,canCancel:!1,error:null},bridge:null}))},Vv=function(){x(this,Pt,null),x(this,Bt,null),x(this,Yr,1),m(this,T,He).call(this,{run:{status:"idle",stopReason:null,canCancel:!1,error:null},messagesById:{},messageOrder:[]})},Bv=function(){return l(this,te).lifecycle.status==="disconnected"};function pD(){const n=new Map;return{getActualSessionId(e){return n.get(e)??null},setActualSessionId(e,t){n.set(e,t)},clearActualSessionId(e){n.delete(e)}}}function fD(){return{lifecycle:{status:"connecting"},run:{status:"idle",stopReason:null,canCancel:!1,error:null},bridge:null,messagesById:{},messageOrder:[],sendDisabled:!0,cancelDisabled:!0}}function gD(n){return n==null?!0:typeof n=="object"&&Object.keys(n).length===0}function Kp(n,e,t){return n==="single_session"?`${Pv}-${t.toLowerCase()}`:`agent:main:television-${t.toLowerCase()}-${e.toLowerCase()}`}function jv(n){return n.replace(/^(?:\s*\n)+/,"")}function Jp(n){let e=n;return e=e.replace(sD,""),e=e.replace(oD,""),e=e.replace(aD,""),e=jv(e),e}function mD(n){let e=n;return e=e.replace(lD,""),e=jv(e),e}function Qp(n){return!n||n.length===0?"":n.flatMap(e=>e.type==="content"&&e.content.type==="text"?[e.content.text]:[]).join("")}async function vD(n){const e=n.createSocket(wD(n.serverURL,n.token));let t=!1,r,i;const s=new Promise((u,h)=>{r=u,i=h}),o=new ReadableStream({start(u){let h=!1;const p=()=>{e.send(JSON.stringify({type:"acp-bridge-connect"}))},v=_=>{const C=bD(_);if(!C)return;let N;try{N=JSON.parse(C)}catch(P){const W=P instanceof Error?P:new Error(String(P));i(W),u.error(W);return}switch(N.type){case"acp-bridge-status":if(N.status==="ready"){let P;try{P=yD(N)}catch(W){const L=W instanceof Error?W:new Error(String(W));t||i(L),u.error(L);return}t||(t=!0,r(P));return}if(N.status==="error"||N.status==="exited"){const P=new Error(N.error??`ACP bridge ${N.status}`);t||i(P),u.error(P)}return;case"acp-bridge-message":u.enqueue(N.message);return}},g=()=>{var C;if(h)return;h=!0;const _=new Error("ACP bridge websocket closed");t||i(_),(C=n.onDisconnect)==null||C.call(n,_),u.close()},E=()=>{var C;if(h)return;h=!0;const _=new Error("ACP bridge websocket error");t||i(_),(C=n.onDisconnect)==null||C.call(n,_),u.error(_)};e.addEventListener("open",p),e.addEventListener("message",v),e.addEventListener("close",g),e.addEventListener("error",E)}}),a=new WritableStream({async write(u){await s,e.send(JSON.stringify({type:"acp-bridge-message",message:u}))},close(){e.close()},abort(){e.close()}}),c=await s;return{stream:{readable:o,writable:a},socket:e,metadata:c}}function yD(n){const{agent:e,sessionIdStrategy:t,sessionCwd:r}=n;if((e==="openclaw"||e==="hermes")&&(t==="deterministic"||t==="mapped")&&typeof r=="string"&&r.length>0)return{agent:e,sessionIdStrategy:t,sessionCwd:r};throw new Error("ACP bridge ready status missing bootstrap metadata")}function bD(n){if(typeof n=="string")return n;if(n instanceof Uint8Array)return new TextDecoder().decode(n);if(typeof Buffer<"u"&&n instanceof Buffer)return n.toString("utf8");if(typeof n=="object"&&n!==null&&"data"in n){const e=n.data;if(typeof e=="string")return e;if(e instanceof Uint8Array)return new TextDecoder().decode(e);if(Array.isArray(e))return Buffer.concat(e).toString("utf8")}return null}function wD(n,e){const t=new URL(n);return t.protocol=t.protocol==="https:"?"wss:":"ws:",t.pathname="/acp",t.search="",t.searchParams.set("token",e),t.hash="",t.toString()}function Co(n){return n instanceof Error?n.message:String(n)}const ef="television.acpClientGUID",tf="television.acpMappedSessions",SD=ki(wt);class _D extends SD{constructor(t){super();b(this,"screenManager");b(this,"clients",new Map);b(this,"options");b(this,"sessionMode");b(this,"clientGUID");b(this,"mappedSessionStore");b(this,"activeClient",null);b(this,"handleActiveScreenChanged",()=>{this.syncActiveClient()});this.screenManager=t.screenManager,this.sessionMode=t.sessionMode??"single_session";const r=t.storage??xD();this.options={serverURL:t.serverURL,token:t.token,...t.createSocket?{createSocket:t.createSocket}:{},...t.sessionMode?{sessionMode:t.sessionMode}:{}},this.clientGUID=t.clientGUID??$D(AD(r)),this.mappedSessionStore=t.mappedSessionStore??(r?new ED(r,t.serverURL):new kD),this.screenManager.addEventListener("active-screen-changed",this.handleActiveScreenChanged),this.syncActiveClient()}getActiveClient(){return this.activeClient}dispose(){this.screenManager.removeEventListener("active-screen-changed",this.handleActiveScreenChanged);for(const t of this.clients.values())t.dispose();this.clients.clear(),this.activeClient=null}syncActiveClient(){const t=this.screenManager.activeScreen,r=t?this.getClientForScreen(t):null;this.activeClient!==r&&(this.activeClient=r,this.dispatchEvent(new K("change")))}getClientForScreen(t){const r=this.sessionMode==="single_session"?"single_session":t.id;let i=this.clients.get(r);return i||(i=new dD({...this.options,sessionMode:this.sessionMode,clientGUID:this.clientGUID,mappedSessionStore:this.mappedSessionStore}),this.clients.set(r,i)),i.setScreenContext({screenID:t.id,screenName:t.name}),i}}var Xr;class kD{constructor(){w(this,Xr,new Map)}getActualSessionId(e){return l(this,Xr).get(e)??null}setActualSessionId(e,t){l(this,Xr).set(e,t)}clearActualSessionId(e){l(this,Xr).delete(e)}}Xr=new WeakMap;const nf=1;var Kr,Ss,Qe,Xo,Ko,Bc;class ED{constructor(e,t){w(this,Qe);w(this,Kr);w(this,Ss);x(this,Kr,e),x(this,Ss,t)}getActualSessionId(e){const t=m(this,Qe,Ko).call(this)[m(this,Qe,Xo).call(this,e)];return typeof t=="string"&&t.length>0?t:null}setActualSessionId(e,t){const r=m(this,Qe,Ko).call(this);r[m(this,Qe,Xo).call(this,e)]=t,m(this,Qe,Bc).call(this,r)}clearActualSessionId(e){const t=m(this,Qe,Ko).call(this);delete t[m(this,Qe,Xo).call(this,e)],m(this,Qe,Bc).call(this,t)}}Kr=new WeakMap,Ss=new WeakMap,Qe=new WeakSet,Xo=function(e){return JSON.stringify([l(this,Ss),e])},Ko=function(){const e=l(this,Kr).getItem(tf);if(!e)return{};let t;try{t=JSON.parse(e)}catch{return{}}if(typeof t!="object"||t===null||Array.isArray(t))return{};const r=t;return r.version!==nf?{}:typeof r.entries!="object"||r.entries===null||Array.isArray(r.entries)?{}:Object.fromEntries(Object.entries(r.entries).filter(i=>typeof i[1]=="string"))},Bc=function(e){const t={version:nf,entries:e};l(this,Kr).setItem(tf,JSON.stringify(t))};function xD(){return typeof window>"u"?null:window.localStorage}function AD(n){if(!n)throw new Error("ACPClientManager requires storage when clientGUID is not provided");return n}function $D(n){const e=n.getItem(ef);if(e)return e;const t=Xu().toLowerCase();return n.setItem(ef,t),t}var _s;class TD extends wt{constructor(){super();w(this,_s,t=>{const r=ID(t);r!==null&&(t.preventDefault(),this.dispatchEvent(new ix("shortcut-triggered",{shortcut:r})))});document.addEventListener("keydown",l(this,_s))}dispose(){document.removeEventListener("keydown",l(this,_s))}}_s=new WeakMap;function ID(n){for(const[e,t]of Object.entries(Nx))if(CD(n,t.trigger))return e;return null}function CD(n,e){return!(n.key.toLowerCase()!==e.key.toLowerCase()||n.metaKey!==!!e.meta||n.ctrlKey!==!!e.ctrl||n.shiftKey!==!!e.shift||n.altKey!==!!e.alt)}const PD="serverURL",RD="token",DD="mode",LD="electron";function qv(n=window.location.search,e=window.location.origin){const r=new URLSearchParams(n).get(PD);return r?new URL(r).origin:new URL(e).origin}function jc(n=window.location.search){return new URLSearchParams(n).get(RD)}function ch(n=window.location.search){return new URLSearchParams(n).get(DD)===LD}/**
44
44
  * @license
45
45
  * Copyright 2017 Google LLC
46
46
  * SPDX-License-Identifier: BSD-3-Clause
47
- */const ns=globalThis,tf=n=>n,ma=ns.trustedTypes,nf=ma?ma.createPolicy("lit-html",{createHTML:n=>n}):void 0,jv="$lit$",sn=`lit$${Math.random().toFixed(9).slice(2)}$`,qv="?"+sn,LD=`<${qv}>`,pr=document,os=()=>pr.createComment(""),as=n=>n===null||typeof n!="object"&&typeof n!="function",ah=Array.isArray,OD=n=>ah(n)||typeof(n==null?void 0:n[Symbol.iterator])=="function",Ql=`[
48
- \f\r]`,Oi=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,rf=/-->/g,sf=/>/g,In=RegExp(`>|${Ql}(?:([^\\s"'>=/]+)(${Ql}*=${Ql}*(?:[^
49
- \f\r"'\`<>=]|("|')|))|$)`,"g"),of=/'/g,af=/"/g,Yv=/^(?:script|style|textarea|title)$/i,MD=n=>(e,...t)=>({_$litType$:n,strings:e,values:t}),U=MD(1),pi=Symbol.for("lit-noChange"),se=Symbol.for("lit-nothing"),lf=new WeakMap,Fn=pr.createTreeWalker(pr,129);function Xv(n,e){if(!ah(n)||!n.hasOwnProperty("raw"))throw Error("invalid template strings array");return nf!==void 0?nf.createHTML(e):e}const zD=(n,e)=>{const t=n.length-1,r=[];let i,s=e===2?"<svg>":e===3?"<math>":"",o=Oi;for(let a=0;a<t;a++){const c=n[a];let u,h,p=-1,v=0;for(;v<c.length&&(o.lastIndex=v,h=o.exec(c),h!==null);)v=o.lastIndex,o===Oi?h[1]==="!--"?o=rf:h[1]!==void 0?o=sf:h[2]!==void 0?(Yv.test(h[2])&&(i=RegExp("</"+h[2],"g")),o=In):h[3]!==void 0&&(o=In):o===In?h[0]===">"?(o=i??Oi,p=-1):h[1]===void 0?p=-2:(p=o.lastIndex-h[2].length,u=h[1],o=h[3]===void 0?In:h[3]==='"'?af:of):o===af||o===of?o=In:o===rf||o===sf?o=Oi:(o=In,i=void 0);const g=o===In&&n[a+1].startsWith("/>")?" ":"";s+=o===Oi?c+LD:p>=0?(r.push(u),c.slice(0,p)+jv+c.slice(p)+sn+g):c+sn+(p===-2?a:g)}return[Xv(n,s+(n[t]||"<?>")+(e===2?"</svg>":e===3?"</math>":"")),r]};class ls{constructor({strings:e,_$litType$:t},r){let i;this.parts=[];let s=0,o=0;const a=e.length-1,c=this.parts,[u,h]=zD(e,t);if(this.el=ls.createElement(u,r),Fn.currentNode=this.el.content,t===2||t===3){const p=this.el.content.firstChild;p.replaceWith(...p.childNodes)}for(;(i=Fn.nextNode())!==null&&c.length<a;){if(i.nodeType===1){if(i.hasAttributes())for(const p of i.getAttributeNames())if(p.endsWith(jv)){const v=h[o++],g=i.getAttribute(p).split(sn),E=/([.?@])?(.*)/.exec(v);c.push({type:1,index:s,name:E[2],strings:g,ctor:E[1]==="."?UD:E[1]==="?"?FD:E[1]==="@"?ZD:il}),i.removeAttribute(p)}else p.startsWith(sn)&&(c.push({type:6,index:s}),i.removeAttribute(p));if(Yv.test(i.tagName)){const p=i.textContent.split(sn),v=p.length-1;if(v>0){i.textContent=ma?ma.emptyScript:"";for(let g=0;g<v;g++)i.append(p[g],os()),Fn.nextNode(),c.push({type:2,index:++s});i.append(p[v],os())}}}else if(i.nodeType===8)if(i.data===qv)c.push({type:2,index:s});else{let p=-1;for(;(p=i.data.indexOf(sn,p+1))!==-1;)c.push({type:7,index:s}),p+=sn.length-1}s++}}static createElement(e,t){const r=pr.createElement("template");return r.innerHTML=e,r}}function fi(n,e,t=n,r){var o,a;if(e===pi)return e;let i=r!==void 0?(o=t._$Co)==null?void 0:o[r]:t._$Cl;const s=as(e)?void 0:e._$litDirective$;return(i==null?void 0:i.constructor)!==s&&((a=i==null?void 0:i._$AO)==null||a.call(i,!1),s===void 0?i=void 0:(i=new s(n),i._$AT(n,t,r)),r!==void 0?(t._$Co??(t._$Co=[]))[r]=i:t._$Cl=i),i!==void 0&&(e=fi(n,i._$AS(n,e.values),i,r)),e}class ND{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){const{el:{content:t},parts:r}=this._$AD,i=((e==null?void 0:e.creationScope)??pr).importNode(t,!0);Fn.currentNode=i;let s=Fn.nextNode(),o=0,a=0,c=r[0];for(;c!==void 0;){if(o===c.index){let u;c.type===2?u=new lh(s,s.nextSibling,this,e):c.type===1?u=new c.ctor(s,c.name,c.strings,this,e):c.type===6&&(u=new HD(s,this,e)),this._$AV.push(u),c=r[++a]}o!==(c==null?void 0:c.index)&&(s=Fn.nextNode(),o++)}return Fn.currentNode=pr,i}p(e){let t=0;for(const r of this._$AV)r!==void 0&&(r.strings!==void 0?(r._$AI(e,r,t),t+=r.strings.length-2):r._$AI(e[t])),t++}}let lh=class Kv{get _$AU(){var e;return((e=this._$AM)==null?void 0:e._$AU)??this._$Cv}constructor(e,t,r,i){this.type=2,this._$AH=se,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=r,this.options=i,this._$Cv=(i==null?void 0:i.isConnected)??!0}get parentNode(){let e=this._$AA.parentNode;const t=this._$AM;return t!==void 0&&(e==null?void 0:e.nodeType)===11&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=fi(this,e,t),as(e)?e===se||e==null||e===""?(this._$AH!==se&&this._$AR(),this._$AH=se):e!==this._$AH&&e!==pi&&this._(e):e._$litType$!==void 0?this.$(e):e.nodeType!==void 0?this.T(e):OD(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!==se&&as(this._$AH)?this._$AA.nextSibling.data=e:this.T(pr.createTextNode(e)),this._$AH=e}$(e){var s;const{values:t,_$litType$:r}=e,i=typeof r=="number"?this._$AC(e):(r.el===void 0&&(r.el=ls.createElement(Xv(r.h,r.h[0]),this.options)),r);if(((s=this._$AH)==null?void 0:s._$AD)===i)this._$AH.p(t);else{const o=new ND(i,this),a=o.u(this.options);o.p(t),this.T(a),this._$AH=o}}_$AC(e){let t=lf.get(e.strings);return t===void 0&&lf.set(e.strings,t=new ls(e)),t}k(e){ah(this._$AH)||(this._$AH=[],this._$AR());const t=this._$AH;let r,i=0;for(const s of e)i===t.length?t.push(r=new Kv(this.O(os()),this.O(os()),this,this.options)):r=t[i],r._$AI(s),i++;i<t.length&&(this._$AR(r&&r._$AB.nextSibling,i),t.length=i)}_$AR(e=this._$AA.nextSibling,t){var r;for((r=this._$AP)==null?void 0:r.call(this,!1,!0,t);e!==this._$AB;){const i=tf(e).nextSibling;tf(e).remove(),e=i}}setConnected(e){var t;this._$AM===void 0&&(this._$Cv=e,(t=this._$AP)==null||t.call(this,e))}},il=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,r,i,s){this.type=1,this._$AH=se,this._$AN=void 0,this.element=e,this.name=t,this._$AM=i,this.options=s,r.length>2||r[0]!==""||r[1]!==""?(this._$AH=Array(r.length-1).fill(new String),this.strings=r):this._$AH=se}_$AI(e,t=this,r,i){const s=this.strings;let o=!1;if(s===void 0)e=fi(this,e,t,0),o=!as(e)||e!==this._$AH&&e!==pi,o&&(this._$AH=e);else{const a=e;let c,u;for(e=s[0],c=0;c<s.length-1;c++)u=fi(this,a[r+c],t,c),u===pi&&(u=this._$AH[c]),o||(o=!as(u)||u!==this._$AH[c]),u===se?e=se:e!==se&&(e+=(u??"")+s[c+1]),this._$AH[c]=u}o&&!i&&this.j(e)}j(e){e===se?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}},UD=class extends il{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===se?void 0:e}},FD=class extends il{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==se)}},ZD=class extends il{constructor(e,t,r,i,s){super(e,t,r,i,s),this.type=5}_$AI(e,t=this){if((e=fi(this,e,t,0)??se)===pi)return;const r=this._$AH,i=e===se&&r!==se||e.capture!==r.capture||e.once!==r.once||e.passive!==r.passive,s=e!==se&&(r===se||i);i&&this.element.removeEventListener(this.name,this,r),s&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){var t;typeof this._$AH=="function"?this._$AH.call(((t=this.options)==null?void 0:t.host)??this.element,e):this._$AH.handleEvent(e)}};class HD{constructor(e,t,r){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=r}get _$AU(){return this._$AM._$AU}_$AI(e){fi(this,e)}}const ec=ns.litHtmlPolyfillSupport;ec==null||ec(ls,lh),(ns.litHtmlVersions??(ns.litHtmlVersions=[])).push("3.3.2");const Re=(n,e,t)=>{const r=e;let i=r._$litPart$;return i===void 0&&(r._$litPart$=i=new lh(e.insertBefore(os(),null),null,void 0,{})),i._$AI(n),i},WD=.5,cf=.1,uf=8,BD=4,Jv=3,Qv=3,VD=4,Zn=255,ey=.2126,ty=.7152,ny=.0722;async function ch(n){const e=GD(n);if(!e)return"light";try{return await YD(n,e)>=WD?"light":"dark"}catch{return"light"}}function GD(n){if(typeof document.elementsFromPoint!="function")return null;const e=n.getBoundingClientRect(),t=e.left+e.width/2,r=e.top+e.height/2,i=document.elementsFromPoint(t,r);for(const s of i){if(!(s instanceof HTMLElement)||s===n||n.contains(s))continue;const o=window.getComputedStyle(s);if(jD(o))return s}return null}function jD(n){return n.backgroundImage&&n.backgroundImage!=="none"?!0:qD(n.backgroundColor)>0}function qD(n){if(!n)return 0;const e=n.match(/rgba?\(([^)]+)\)/);if(!e)return 0;const t=e[1].split(/[\s,/]+/).filter(Boolean);return t.length===VD?parseFloat(t[Jv]):t.length===Qv?1:0}async function YD(n,e){const t=n.getBoundingClientRect(),r=e.getBoundingClientRect(),i={x:Po((t.left-r.left)/r.width),y:Po((t.top-r.top)/r.height),width:Po(t.width/r.width),height:Po(t.height/r.height)},s=window.getComputedStyle(e),o=XD(s.backgroundImage);return o?JD({url:o,surfaceWidth:r.width,surfaceHeight:r.height,region:i}):QD(s.backgroundColor)}function XD(n){const e=n.match(/url\(\s*["']?([^"')]+)["']?\s*\)/);return e?e[1]:null}const hf=new Map;function KD(n){let e=hf.get(n);return e||(e=new Promise((t,r)=>{const i=new Image;i.crossOrigin="anonymous",i.onload=()=>t(i),i.onerror=()=>r(new Error(`Failed to load ${n}`)),i.src=n}),hf.set(n,e),e)}async function JD(n){const e=await KD(n.url),t=Math.max(uf,Math.ceil(n.surfaceWidth*cf)),r=Math.max(uf,Math.ceil(n.surfaceHeight*cf)),i=document.createElement("canvas");i.width=t,i.height=r;const s=i.getContext("2d",{willReadFrequently:!0});if(!s)return 1;const o=n.surfaceWidth/n.surfaceHeight,a=e.naturalWidth/e.naturalHeight;let c,u;a>o?(u=r,c=r*a):(c=t,u=t/a);const h=(t-c)/2,p=(r-u)/2;s.drawImage(e,h,p,c,u);const v=Math.max(0,Math.floor(n.region.x*t)),g=Math.max(0,Math.floor(n.region.y*r)),E=Math.max(1,Math.min(t-v,Math.floor(n.region.width*t))),_=Math.max(1,Math.min(r-g,Math.floor(n.region.height*r))),C=s.getImageData(v,g,E,_).data;let N=0,P=0;for(let W=0;W<C.length;W+=BD){const L=C[W]/Zn,H=C[W+1]/Zn,F=C[W+2]/Zn,ce=C[W+Jv]/Zn;N+=ce*(ey*L+ty*H+ny*F),P+=1}return P>0?N/P:1}function QD(n){const e=n.match(/rgba?\(([^)]+)\)/);if(!e)return 1;const t=e[1].split(/[\s,/]+/).filter(Boolean).map(parseFloat);if(t.length<Qv)return 1;const r=t[0]/Zn,i=t[1]/Zn,s=t[2]/Zn;return ey*r+ty*i+ny*s}function Po(n){return n<0?0:n>1?1:n}const tc=new WeakSet,df=new WeakSet;function ry(n){if(df.has(n))return;df.add(n);for(const t of n.querySelectorAll('button[variant="ghost"]'))nc(t);if(typeof MutationObserver!="function")return;new MutationObserver(t=>{for(const r of t)if(r.type==="childList")for(const i of r.addedNodes)e2(i,nc);else r.type==="attributes"&&r.target instanceof HTMLButtonElement&&r.target.getAttribute("variant")==="ghost"&&nc(r.target)}).observe(n,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["variant"]})}function e2(n,e){if(n instanceof Element){n instanceof HTMLButtonElement&&n.getAttribute("variant")==="ghost"&&e(n);for(const t of n.querySelectorAll('button[variant="ghost"]'))e(t)}}async function nc(n){if(tc.has(n))return;tc.add(n);const e=await ch(n);if(n.getAttribute("variant")!=="ghost"){tc.delete(n);return}n.setAttribute("tone",e)}const t2="*,*:before,*:after{box-sizing:border-box}html,body{margin:0;padding:0;width:100%;height:100%}h1,h2,h3,h4,h5,h6,p,ul,ol,blockquote,pre,hr{margin:0}button,input,textarea,select{font:inherit;color:inherit}@font-face{font-family:Hind;src:url("+new URL("Hind-Variable-C47b_dt9.woff2",import.meta.url).href+') format("woff2-variations");font-weight:300 700;font-style:normal;font-display:swap}:root{--font-sans: "Hind", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;--font-brand: var(--font-sans);--font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, monospace;--font-weight-body: 500;--text-base: 13.5px;--text-scale: 1.125;--text-sm: round(calc(var(--text-base) / var(--text-scale)), 1px);--text-lg: round(calc(var(--text-base) * var(--text-scale)), 1px);--text-xl: round(calc(var(--text-lg) * var(--text-scale)), 1px);--leading-base: 1.5;--space-2: 2px;--space-4: 4px;--space-6: 6px;--space-8: 8px;--space-12: 12px;--space-16: 16px;--space-20: 20px;--space-24: 24px;--space-32: 32px;--space-48: 48px;--space-64: 64px;--radius-4: 4px;--radius-8: 8px;--radius-12: 12px;--radius-16: 16px;--radius-24: 24px;--radius-full: 9999px;--shadow-hairline: 0 0 0 .5px var(--color-border);--shadow-control: 0 1px 1px rgb(0 0 0 / .04), 0 2px 6px rgb(0 0 0 / .06);--alpha-50: 4%;--alpha-100: 8%;--alpha-200: 15%;--alpha-300: 22%;--alpha-400: 30%;--alpha-500: 40%;--alpha-600: 50%;--alpha-700: 65%;--alpha-800: 80%;--alpha-900: 90%;--alpha-950: 95%;--tint-50: color-mix(in srgb, currentColor var(--alpha-50), transparent);--tint-100: color-mix(in srgb, currentColor var(--alpha-100), transparent);--tint-200: color-mix(in srgb, currentColor var(--alpha-200), transparent);--tint-300: color-mix(in srgb, currentColor var(--alpha-300), transparent);--tint-400: color-mix(in srgb, currentColor var(--alpha-400), transparent);--tint-500: color-mix(in srgb, currentColor var(--alpha-500), transparent);--tint-600: color-mix(in srgb, currentColor var(--alpha-600), transparent);--tint-700: color-mix(in srgb, currentColor var(--alpha-700), transparent);--tint-800: color-mix(in srgb, currentColor var(--alpha-800), transparent);--tint-900: color-mix(in srgb, currentColor var(--alpha-900), transparent);--tint-950: color-mix(in srgb, currentColor var(--alpha-950), transparent);--color-overlay-hover: color-mix(in srgb, var(--black) var(--alpha-100), transparent);--color-overlay-active: color-mix(in srgb, var(--black) var(--alpha-300), transparent);--backdrop-blur-glass: blur(20px) saturate(1.4);--black: #000000;--white: #ffffff;--neutral-50: oklch(.985 0 0);--neutral-100: oklch(.97 0 0);--neutral-200: oklch(.923 0 0);--neutral-300: oklch(.869 0 0);--neutral-350: oklch(.79 0 0);--neutral-400: oklch(.709 0 0);--neutral-500: oklch(.553 0 0);--neutral-600: oklch(.444 0 0);--neutral-700: oklch(.374 0 0);--neutral-800: oklch(.268 0 0);--neutral-900: oklch(.216 0 0);--neutral-950: oklch(.147 0 0);--red-50: oklch(.969 .015 12.422);--red-100: oklch(.941 .03 12.58);--red-200: oklch(.892 .058 10.001);--red-300: oklch(.81 .117 11.638);--red-400: oklch(.712 .194 13.428);--red-500: oklch(.645 .246 16.439);--red-600: oklch(.586 .253 17.585);--red-700: oklch(.514 .222 16.935);--red-800: oklch(.455 .188 13.697);--red-900: oklch(.41 .159 10.272);--red-950: oklch(.271 .105 12.094);--orange-50: oklch(.98 .016 73.684);--orange-100: oklch(.954 .038 75.164);--orange-200: oklch(.901 .076 70.697);--orange-300: oklch(.837 .128 66.29);--orange-400: oklch(.75 .183 55.934);--orange-500: oklch(.705 .213 47.604);--orange-600: oklch(.646 .222 41.116);--orange-700: oklch(.553 .195 38.402);--orange-800: oklch(.47 .157 37.304);--orange-900: oklch(.408 .123 38.172);--orange-950: oklch(.266 .079 36.259);--yellow-50: oklch(.987 .026 102.212);--yellow-100: oklch(.973 .071 103.193);--yellow-200: oklch(.945 .129 101.54);--yellow-300: oklch(.905 .182 98.111);--yellow-400: oklch(.852 .199 91.936);--yellow-500: oklch(.795 .184 86.047);--yellow-600: oklch(.681 .162 75.834);--yellow-700: oklch(.554 .135 66.442);--yellow-800: oklch(.476 .114 61.907);--yellow-900: oklch(.421 .095 57.708);--yellow-950: oklch(.286 .066 53.813);--green-50: oklch(.979 .021 166.113);--green-100: oklch(.95 .052 163.051);--green-200: oklch(.905 .093 164.15);--green-300: oklch(.845 .143 164.978);--green-400: oklch(.765 .177 163.223);--green-500: oklch(.696 .17 162.48);--green-600: oklch(.596 .145 163.225);--green-700: oklch(.508 .118 165.612);--green-800: oklch(.432 .095 166.913);--green-900: oklch(.378 .077 168.94);--green-950: oklch(.262 .051 172.552);--blue-50: oklch(.97 .014 254.604);--blue-100: oklch(.932 .032 255.585);--blue-200: oklch(.882 .059 254.128);--blue-300: oklch(.809 .105 251.813);--blue-400: oklch(.707 .165 254.624);--blue-500: oklch(.623 .214 259.815);--blue-600: oklch(.546 .245 262.881);--blue-700: oklch(.488 .243 264.376);--blue-800: oklch(.424 .199 265.638);--blue-900: oklch(.379 .146 265.522);--blue-950: oklch(.282 .091 267.935);--purple-50: oklch(.969 .016 293.756);--purple-100: oklch(.943 .029 294.588);--purple-200: oklch(.894 .057 293.283);--purple-300: oklch(.811 .111 293.571);--purple-400: oklch(.702 .183 293.541);--purple-500: oklch(.606 .25 292.717);--purple-600: oklch(.541 .281 293.009);--purple-700: oklch(.491 .27 292.581);--purple-800: oklch(.432 .232 292.759);--purple-900: oklch(.38 .189 293.745);--purple-950: oklch(.283 .141 291.089)}@supports (corner-shape: squircle){:root{--radius-8: 10px;--radius-12: 15px;--radius-16: 20px;--radius-24: 30px}}:root[data-font=system]{--font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif}:root{--color-bg: var(--neutral-50);--color-bg-muted: var(--neutral-100);--color-surface: var(--white);--color-surface-muted: var(--neutral-100);--color-interactive: var(--neutral-200);--color-interactive-hover: var(--neutral-300);--color-border: rgba(0, 0, 0, .1);--color-border-muted: rgba(0, 0, 0, .06);--color-text: var(--neutral-900);--color-text-muted: var(--neutral-500);--color-link: inherit;--color-focus-ring: var(--neutral-500);--color-overlay-backdrop: rgb(0 0 0 / .5);--color-highlight: rgb(255 255 255 / .5);--color-primary: var(--blue-500);--color-danger: var(--red-600);color-scheme:light}body{font-family:var(--font-sans);font-size:var(--text-base);font-weight:var(--font-weight-body);line-height:var(--leading-base);letter-spacing:.015em;color:var(--color-text);background:var(--color-bg);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}a{color:var(--color-link);text-underline-offset:.15em;text-decoration-thickness:.08em}h1,h2,h3,h4,h5,h6{font-weight:600;color:inherit}code{font-family:var(--font-mono);font-size:.9em;background:var(--color-bg-muted);padding:var(--space-2) var(--space-4);border-radius:var(--radius-4)}pre{font-family:var(--font-mono);background:var(--color-bg-muted);padding:var(--space-12);border-radius:var(--radius-8);overflow-x:auto}pre code{background:none;padding:0}blockquote{padding-left:var(--space-16);border-left:3px solid var(--color-border);color:var(--color-text-muted)}hr{border:none;border-top:1px solid var(--color-border)}table{border-collapse:collapse}th,td{padding:var(--space-8) var(--space-12);border:1px solid var(--color-border);text-align:left}th{background:var(--color-bg-muted);font-weight:600}input,textarea{padding:6px 10px;border:.5px solid var(--tint-300);border-radius:var(--radius-12);background:var(--tint-100);color:inherit;font:inherit;transition:background .12s ease,border-color .12s ease,box-shadow .12s ease}textarea{resize:none}input::placeholder,textarea::placeholder{color:var(--tint-500)}input:focus,textarea:focus{background:color-mix(in srgb,var(--white) var(--alpha-300),transparent);border-color:var(--color-primary);outline:none;box-shadow:0 0 0 1.5px var(--color-primary)}label.field{display:grid;gap:4px;font-size:13px}label.field>span{font-size:11.5px;font-weight:450;color:var(--tint-800)}@supports (corner-shape: squircle){*{corner-shape:squircle}}button{display:inline-flex;align-items:center;justify-content:center;gap:var(--space-6);padding:4px 14px;border:.5px solid var(--tint-200);border-radius:var(--radius-12);background:var(--color-surface);color:inherit;font:inherit;cursor:default;box-shadow:var(--shadow-control)}button:hover:not(:disabled){background:color-mix(in srgb,var(--color-surface) 96%,black)}button:active:not(:disabled){background:color-mix(in srgb,var(--color-surface) 88%,black);box-shadow:inset 0 1px 2px #00000014}button:focus-visible{outline:2px solid var(--color-focus-ring);outline-offset:2px}button[variant=primary]{background:var(--color-primary);border-color:#0000002e;color:var(--white)}button[variant=primary]:hover:not(:disabled){background:color-mix(in srgb,var(--color-primary) 92%,black)}button[variant=primary]:active:not(:disabled){background:color-mix(in srgb,var(--color-primary) 82%,black);box-shadow:inset 0 1px 2px #0000002e}button[variant=danger]{background:var(--color-danger);border-color:#0000002e;color:var(--white)}button[variant=danger]:hover:not(:disabled){background:color-mix(in srgb,var(--color-danger) 92%,black)}button[variant=danger]:active:not(:disabled){background:color-mix(in srgb,var(--color-danger) 82%,black);box-shadow:inset 0 1px 2px #0000002e}button[variant=ghost]{background:transparent;border-color:transparent;color:inherit;box-shadow:none}button[variant=ghost]:hover:not(:disabled){background:var(--color-overlay-hover)}button[variant=ghost]:active:not(:disabled){background:var(--color-overlay-active);box-shadow:none}button[variant=ghost][data-active]:not(:disabled),button[variant=ghost][data-active]:hover:not(:disabled),button[variant=ghost][aria-expanded=true]:not(:disabled),button[variant=ghost][aria-expanded=true]:hover:not(:disabled){background:var(--color-overlay-active);box-shadow:none}button:disabled{background:var(--tint-300);border-color:transparent;color:var(--tint-700);box-shadow:none}[tone=dark] button:not([variant]):not(:disabled){background:var(--tint-200);border-color:var(--tint-300);box-shadow:inset 0 .5px 0 var(--tint-300)}[tone=dark] button:not([variant]):hover:not(:disabled){background:var(--tint-300)}[tone=dark] button:not([variant]):active:not(:disabled){background:var(--tint-400);box-shadow:inset 0 1px 2px #0003}[tone=light] button:not([variant]):not(:disabled){background:var(--color-surface);border-color:var(--tint-200);box-shadow:var(--shadow-control)}[tone=light] button:not([variant]):hover:not(:disabled){background:color-mix(in srgb,var(--color-surface) 96%,black)}[tone=light] button:not([variant]):active:not(:disabled){background:color-mix(in srgb,var(--color-surface) 88%,black);box-shadow:inset 0 1px 2px #00000014}button[size=sm]{min-height:24px;padding:var(--space-2) var(--space-8)}button[size=md]{min-height:32px;padding:var(--space-6) var(--space-12)}button[icon-only]{width:24px;height:24px;min-height:0;padding:0}[data-ui-icon]{display:inline-block;vertical-align:middle}.prose{line-height:var(--leading-base)}.prose h1{font-size:var(--text-xl);margin-bottom:var(--space-8)}.prose h2{font-size:var(--text-lg);margin-top:var(--space-24);margin-bottom:var(--space-8)}.prose h3,.prose h4,.prose h5,.prose h6{font-size:var(--text-base);margin-top:var(--space-24);margin-bottom:var(--space-8)}.prose p{margin:var(--space-12) 0}.prose ul,.prose ol{padding-left:var(--space-24);margin:var(--space-12) 0}.prose blockquote,.prose pre{margin:var(--space-12) 0}.prose hr{margin:var(--space-24) 0}.prose table{width:100%;margin:var(--space-12) 0}.prose img{max-width:100%;height:auto}.prose>:first-child{margin-top:0}.prose>:last-child{margin-bottom:0}[material=paper]{background:var(--white);border:.5px solid color-mix(in srgb,var(--black) var(--alpha-100),transparent);color:var(--color-text)}[material=glass]{background:color-mix(in srgb,var(--white) var(--alpha-700),transparent);border:.5px solid color-mix(in srgb,var(--black) var(--alpha-100),transparent);color:var(--color-text);backdrop-filter:var(--backdrop-blur-glass);-webkit-backdrop-filter:var(--backdrop-blur-glass)}[tone=dark]{color:color-mix(in srgb,var(--white) var(--alpha-950),transparent);border-color:color-mix(in srgb,var(--white) var(--alpha-200),transparent);--color-overlay-hover: color-mix(in srgb, var(--white) var(--alpha-200), transparent);--color-overlay-active: color-mix(in srgb, var(--black) var(--alpha-500), transparent)}[tone=dark][material=paper]{background:#000}[tone=dark][material=glass]{background:color-mix(in srgb,var(--black) var(--alpha-600),transparent)}[tone=light]{color:var(--color-text);border-color:color-mix(in srgb,var(--black) var(--alpha-100),transparent);--color-overlay-hover: color-mix(in srgb, var(--black) var(--alpha-100), transparent);--color-overlay-active: color-mix(in srgb, var(--black) var(--alpha-300), transparent)}[level="1"]{box-shadow:0 12px 32px #00000024}[level="2"]{box-shadow:0 4px 6px -2px #0000001f,0 40px 60px -16px #00000038}dropdown-menu{position:relative;display:inline-block;color:inherit}dropdown-group{display:grid;gap:var(--space-4)}dropdown-label{display:block;padding:var(--space-4) var(--space-8);color:var(--color-text-muted);font:inherit;font-size:var(--text-sm);font-weight:600;letter-spacing:.04em;text-transform:uppercase}dropdown-divider{display:block;height:1px;margin:2px 0;background:var(--color-border)}[data-dropdown-trigger][aria-expanded=true],[data-dropdown-trigger][aria-expanded=true]:hover,dropdown-menu[open]::part(trigger),dropdown-menu[open]::part(trigger):hover{background:color-mix(in srgb,var(--color-surface) 88%,black);box-shadow:inset 0 1px 2px #00000014}[data-dropdown-trigger-label],dropdown-menu::part(trigger-label){min-width:0}[data-dropdown-trigger-icon],dropdown-menu::part(trigger-icon){display:inline-flex;align-items:center;justify-content:center;flex:none;color:var(--color-text-muted);transform:translateY(1px)}dropdown-item:focus-visible{outline:2px solid var(--color-focus-ring);outline-offset:2px}dropdown-menu::part(panel){position:absolute;left:0;min-width:192px;padding:var(--space-4);border-radius:var(--radius-8);display:flex;flex-direction:column;gap:2px;z-index:2000}dropdown-menu::part(panel-bottom){top:calc(100% + var(--space-4))}dropdown-menu::part(panel-top){bottom:calc(100% + var(--space-4))}dropdown-item{display:flex;align-items:center;gap:var(--space-8);margin:0;padding:6px 12px;border-radius:var(--radius-8);font:inherit;line-height:1.2;color:inherit;font-weight:var(--font-weight-body);-webkit-user-select:none;user-select:none}dropdown-item>[data-ui-icon]{flex:none}dropdown-item[selected]{background:var(--color-overlay-active)}dropdown-item:hover{background:var(--color-primary);color:var(--white)}dropdown-item[action]{color:inherit}dropdown-item[danger]{color:var(--color-danger)}dropdown-item[danger]:hover{background:var(--color-danger);color:var(--white)}modal-overlay{color:inherit}modal-overlay::part(backdrop){position:fixed;top:0;right:0;bottom:0;left:0;z-index:var(--layer-overlay);display:flex;align-items:center;justify-content:center;padding:var(--space-16);background:var(--color-overlay-backdrop)}panel-view{display:block}panel-view::part(panel){display:flex;flex-direction:column;gap:var(--space-16);color:var(--color-text)}panel-view::part(header){display:flex;align-items:center;justify-content:space-between;gap:var(--space-12)}panel-view::part(title){margin:0;font:inherit;font-size:var(--text-lg);font-weight:600;color:var(--color-text)}panel-view::part(button){display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;margin:0;border:1px solid var(--color-border);border-radius:var(--radius-4);background:var(--color-surface);color:var(--color-text);box-shadow:none}panel-view::part(button):hover{background:var(--color-interactive-hover)}panel-view::part(button):focus-visible{outline:2px solid var(--color-focus-ring);outline-offset:2px}panel-view::part(icon){display:inline-flex;align-items:center;justify-content:center;flex:none}ui-popover{display:contents}ui-popover::part(panel){position:fixed;min-width:192px;max-width:384px;padding:var(--space-16) var(--space-20);border-radius:var(--radius-16);outline:none;z-index:2000}ui-pill{display:inline-block;vertical-align:baseline;margin:2px 0;padding:0 var(--space-8);font-size:var(--text-sm);font-weight:500;line-height:1.7;border-radius:var(--radius-full);border:1px solid var(--neutral-300);background:var(--neutral-200);color:var(--neutral-900);white-space:nowrap}ui-pill[color=gray]{border-color:var(--neutral-300);background:var(--neutral-200);color:var(--neutral-900)}ui-pill[color=red]{border-color:var(--red-200);background:var(--red-100);color:var(--red-950)}ui-pill[color=orange]{border-color:var(--orange-200);background:var(--orange-100);color:var(--orange-950)}ui-pill[color=yellow]{border-color:var(--yellow-200);background:var(--yellow-100);color:var(--yellow-950)}ui-pill[color=green]{border-color:var(--green-200);background:var(--green-100);color:var(--green-950)}ui-pill[color=blue]{border-color:var(--blue-200);background:var(--blue-100);color:var(--blue-950)}ui-pill[color=purple]{border-color:var(--purple-200);background:var(--purple-100);color:var(--purple-950)}',uh=new CSSStyleSheet;uh.replaceSync(t2);try{document.adoptedStyleSheets=[...document.adoptedStyleSheets,uh]}catch{}ry(document);function iy(n){try{n.adoptedStyleSheets=[...n.adoptedStyleSheets,uh]}catch{}ry(n)}/**
47
+ */const ns=globalThis,rf=n=>n,ma=ns.trustedTypes,sf=ma?ma.createPolicy("lit-html",{createHTML:n=>n}):void 0,Yv="$lit$",sn=`lit$${Math.random().toFixed(9).slice(2)}$`,Xv="?"+sn,OD=`<${Xv}>`,pr=document,os=()=>pr.createComment(""),as=n=>n===null||typeof n!="object"&&typeof n!="function",uh=Array.isArray,MD=n=>uh(n)||typeof(n==null?void 0:n[Symbol.iterator])=="function",nc=`[
48
+ \f\r]`,Oi=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,of=/-->/g,af=/>/g,In=RegExp(`>|${nc}(?:([^\\s"'>=/]+)(${nc}*=${nc}*(?:[^
49
+ \f\r"'\`<>=]|("|')|))|$)`,"g"),lf=/'/g,cf=/"/g,Kv=/^(?:script|style|textarea|title)$/i,zD=n=>(e,...t)=>({_$litType$:n,strings:e,values:t}),U=zD(1),pi=Symbol.for("lit-noChange"),se=Symbol.for("lit-nothing"),uf=new WeakMap,Fn=pr.createTreeWalker(pr,129);function Jv(n,e){if(!uh(n)||!n.hasOwnProperty("raw"))throw Error("invalid template strings array");return sf!==void 0?sf.createHTML(e):e}const ND=(n,e)=>{const t=n.length-1,r=[];let i,s=e===2?"<svg>":e===3?"<math>":"",o=Oi;for(let a=0;a<t;a++){const c=n[a];let u,h,p=-1,v=0;for(;v<c.length&&(o.lastIndex=v,h=o.exec(c),h!==null);)v=o.lastIndex,o===Oi?h[1]==="!--"?o=of:h[1]!==void 0?o=af:h[2]!==void 0?(Kv.test(h[2])&&(i=RegExp("</"+h[2],"g")),o=In):h[3]!==void 0&&(o=In):o===In?h[0]===">"?(o=i??Oi,p=-1):h[1]===void 0?p=-2:(p=o.lastIndex-h[2].length,u=h[1],o=h[3]===void 0?In:h[3]==='"'?cf:lf):o===cf||o===lf?o=In:o===of||o===af?o=Oi:(o=In,i=void 0);const g=o===In&&n[a+1].startsWith("/>")?" ":"";s+=o===Oi?c+OD:p>=0?(r.push(u),c.slice(0,p)+Yv+c.slice(p)+sn+g):c+sn+(p===-2?a:g)}return[Jv(n,s+(n[t]||"<?>")+(e===2?"</svg>":e===3?"</math>":"")),r]};class ls{constructor({strings:e,_$litType$:t},r){let i;this.parts=[];let s=0,o=0;const a=e.length-1,c=this.parts,[u,h]=ND(e,t);if(this.el=ls.createElement(u,r),Fn.currentNode=this.el.content,t===2||t===3){const p=this.el.content.firstChild;p.replaceWith(...p.childNodes)}for(;(i=Fn.nextNode())!==null&&c.length<a;){if(i.nodeType===1){if(i.hasAttributes())for(const p of i.getAttributeNames())if(p.endsWith(Yv)){const v=h[o++],g=i.getAttribute(p).split(sn),E=/([.?@])?(.*)/.exec(v);c.push({type:1,index:s,name:E[2],strings:g,ctor:E[1]==="."?FD:E[1]==="?"?ZD:E[1]==="@"?HD:il}),i.removeAttribute(p)}else p.startsWith(sn)&&(c.push({type:6,index:s}),i.removeAttribute(p));if(Kv.test(i.tagName)){const p=i.textContent.split(sn),v=p.length-1;if(v>0){i.textContent=ma?ma.emptyScript:"";for(let g=0;g<v;g++)i.append(p[g],os()),Fn.nextNode(),c.push({type:2,index:++s});i.append(p[v],os())}}}else if(i.nodeType===8)if(i.data===Xv)c.push({type:2,index:s});else{let p=-1;for(;(p=i.data.indexOf(sn,p+1))!==-1;)c.push({type:7,index:s}),p+=sn.length-1}s++}}static createElement(e,t){const r=pr.createElement("template");return r.innerHTML=e,r}}function fi(n,e,t=n,r){var o,a;if(e===pi)return e;let i=r!==void 0?(o=t._$Co)==null?void 0:o[r]:t._$Cl;const s=as(e)?void 0:e._$litDirective$;return(i==null?void 0:i.constructor)!==s&&((a=i==null?void 0:i._$AO)==null||a.call(i,!1),s===void 0?i=void 0:(i=new s(n),i._$AT(n,t,r)),r!==void 0?(t._$Co??(t._$Co=[]))[r]=i:t._$Cl=i),i!==void 0&&(e=fi(n,i._$AS(n,e.values),i,r)),e}class UD{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){const{el:{content:t},parts:r}=this._$AD,i=((e==null?void 0:e.creationScope)??pr).importNode(t,!0);Fn.currentNode=i;let s=Fn.nextNode(),o=0,a=0,c=r[0];for(;c!==void 0;){if(o===c.index){let u;c.type===2?u=new hh(s,s.nextSibling,this,e):c.type===1?u=new c.ctor(s,c.name,c.strings,this,e):c.type===6&&(u=new WD(s,this,e)),this._$AV.push(u),c=r[++a]}o!==(c==null?void 0:c.index)&&(s=Fn.nextNode(),o++)}return Fn.currentNode=pr,i}p(e){let t=0;for(const r of this._$AV)r!==void 0&&(r.strings!==void 0?(r._$AI(e,r,t),t+=r.strings.length-2):r._$AI(e[t])),t++}}let hh=class Qv{get _$AU(){var e;return((e=this._$AM)==null?void 0:e._$AU)??this._$Cv}constructor(e,t,r,i){this.type=2,this._$AH=se,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=r,this.options=i,this._$Cv=(i==null?void 0:i.isConnected)??!0}get parentNode(){let e=this._$AA.parentNode;const t=this._$AM;return t!==void 0&&(e==null?void 0:e.nodeType)===11&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=fi(this,e,t),as(e)?e===se||e==null||e===""?(this._$AH!==se&&this._$AR(),this._$AH=se):e!==this._$AH&&e!==pi&&this._(e):e._$litType$!==void 0?this.$(e):e.nodeType!==void 0?this.T(e):MD(e)?this.k(e):this._(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==se&&as(this._$AH)?this._$AA.nextSibling.data=e:this.T(pr.createTextNode(e)),this._$AH=e}$(e){var s;const{values:t,_$litType$:r}=e,i=typeof r=="number"?this._$AC(e):(r.el===void 0&&(r.el=ls.createElement(Jv(r.h,r.h[0]),this.options)),r);if(((s=this._$AH)==null?void 0:s._$AD)===i)this._$AH.p(t);else{const o=new UD(i,this),a=o.u(this.options);o.p(t),this.T(a),this._$AH=o}}_$AC(e){let t=uf.get(e.strings);return t===void 0&&uf.set(e.strings,t=new ls(e)),t}k(e){uh(this._$AH)||(this._$AH=[],this._$AR());const t=this._$AH;let r,i=0;for(const s of e)i===t.length?t.push(r=new Qv(this.O(os()),this.O(os()),this,this.options)):r=t[i],r._$AI(s),i++;i<t.length&&(this._$AR(r&&r._$AB.nextSibling,i),t.length=i)}_$AR(e=this._$AA.nextSibling,t){var r;for((r=this._$AP)==null?void 0:r.call(this,!1,!0,t);e!==this._$AB;){const i=rf(e).nextSibling;rf(e).remove(),e=i}}setConnected(e){var t;this._$AM===void 0&&(this._$Cv=e,(t=this._$AP)==null||t.call(this,e))}},il=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,r,i,s){this.type=1,this._$AH=se,this._$AN=void 0,this.element=e,this.name=t,this._$AM=i,this.options=s,r.length>2||r[0]!==""||r[1]!==""?(this._$AH=Array(r.length-1).fill(new String),this.strings=r):this._$AH=se}_$AI(e,t=this,r,i){const s=this.strings;let o=!1;if(s===void 0)e=fi(this,e,t,0),o=!as(e)||e!==this._$AH&&e!==pi,o&&(this._$AH=e);else{const a=e;let c,u;for(e=s[0],c=0;c<s.length-1;c++)u=fi(this,a[r+c],t,c),u===pi&&(u=this._$AH[c]),o||(o=!as(u)||u!==this._$AH[c]),u===se?e=se:e!==se&&(e+=(u??"")+s[c+1]),this._$AH[c]=u}o&&!i&&this.j(e)}j(e){e===se?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}},FD=class extends il{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===se?void 0:e}},ZD=class extends il{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==se)}},HD=class extends il{constructor(e,t,r,i,s){super(e,t,r,i,s),this.type=5}_$AI(e,t=this){if((e=fi(this,e,t,0)??se)===pi)return;const r=this._$AH,i=e===se&&r!==se||e.capture!==r.capture||e.once!==r.once||e.passive!==r.passive,s=e!==se&&(r===se||i);i&&this.element.removeEventListener(this.name,this,r),s&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){var t;typeof this._$AH=="function"?this._$AH.call(((t=this.options)==null?void 0:t.host)??this.element,e):this._$AH.handleEvent(e)}};class WD{constructor(e,t,r){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=r}get _$AU(){return this._$AM._$AU}_$AI(e){fi(this,e)}}const rc=ns.litHtmlPolyfillSupport;rc==null||rc(ls,hh),(ns.litHtmlVersions??(ns.litHtmlVersions=[])).push("3.3.2");const Re=(n,e,t)=>{const r=e;let i=r._$litPart$;return i===void 0&&(r._$litPart$=i=new hh(e.insertBefore(os(),null),null,void 0,{})),i._$AI(n),i},GD=.5,hf=.1,df=8,VD=4,ey=3,ty=3,BD=4,Zn=255,ny=.2126,ry=.7152,iy=.0722;async function dh(n){const e=jD(n);if(!e)return"light";try{return await XD(n,e)>=GD?"light":"dark"}catch{return"light"}}function jD(n){if(typeof document.elementsFromPoint!="function")return null;const e=n.getBoundingClientRect(),t=e.left+e.width/2,r=e.top+e.height/2,i=document.elementsFromPoint(t,r);for(const s of i){if(!(s instanceof HTMLElement)||s===n||n.contains(s))continue;const o=window.getComputedStyle(s);if(qD(o))return s}return null}function qD(n){return n.backgroundImage&&n.backgroundImage!=="none"?!0:YD(n.backgroundColor)>0}function YD(n){if(!n)return 0;const e=n.match(/rgba?\(([^)]+)\)/);if(!e)return 0;const t=e[1].split(/[\s,/]+/).filter(Boolean);return t.length===BD?parseFloat(t[ey]):t.length===ty?1:0}async function XD(n,e){const t=n.getBoundingClientRect(),r=e.getBoundingClientRect(),i={x:Po((t.left-r.left)/r.width),y:Po((t.top-r.top)/r.height),width:Po(t.width/r.width),height:Po(t.height/r.height)},s=window.getComputedStyle(e),o=KD(s.backgroundImage);return o?QD({url:o,surfaceWidth:r.width,surfaceHeight:r.height,region:i}):e2(s.backgroundColor)}function KD(n){const e=n.match(/url\(\s*["']?([^"')]+)["']?\s*\)/);return e?e[1]:null}const pf=new Map;function JD(n){let e=pf.get(n);return e||(e=new Promise((t,r)=>{const i=new Image;i.crossOrigin="anonymous",i.onload=()=>t(i),i.onerror=()=>r(new Error(`Failed to load ${n}`)),i.src=n}),pf.set(n,e),e)}async function QD(n){const e=await JD(n.url),t=Math.max(df,Math.ceil(n.surfaceWidth*hf)),r=Math.max(df,Math.ceil(n.surfaceHeight*hf)),i=document.createElement("canvas");i.width=t,i.height=r;const s=i.getContext("2d",{willReadFrequently:!0});if(!s)return 1;const o=n.surfaceWidth/n.surfaceHeight,a=e.naturalWidth/e.naturalHeight;let c,u;a>o?(u=r,c=r*a):(c=t,u=t/a);const h=(t-c)/2,p=(r-u)/2;s.drawImage(e,h,p,c,u);const v=Math.max(0,Math.floor(n.region.x*t)),g=Math.max(0,Math.floor(n.region.y*r)),E=Math.max(1,Math.min(t-v,Math.floor(n.region.width*t))),_=Math.max(1,Math.min(r-g,Math.floor(n.region.height*r))),C=s.getImageData(v,g,E,_).data;let N=0,P=0;for(let W=0;W<C.length;W+=VD){const L=C[W]/Zn,H=C[W+1]/Zn,F=C[W+2]/Zn,ce=C[W+ey]/Zn;N+=ce*(ny*L+ry*H+iy*F),P+=1}return P>0?N/P:1}function e2(n){const e=n.match(/rgba?\(([^)]+)\)/);if(!e)return 1;const t=e[1].split(/[\s,/]+/).filter(Boolean).map(parseFloat);if(t.length<ty)return 1;const r=t[0]/Zn,i=t[1]/Zn,s=t[2]/Zn;return ny*r+ry*i+iy*s}function Po(n){return n<0?0:n>1?1:n}const ic=new WeakSet,ff=new WeakSet;function sy(n){if(ff.has(n))return;ff.add(n);for(const t of n.querySelectorAll('button[variant="ghost"]'))sc(t);if(typeof MutationObserver!="function")return;new MutationObserver(t=>{for(const r of t)if(r.type==="childList")for(const i of r.addedNodes)t2(i,sc);else r.type==="attributes"&&r.target instanceof HTMLButtonElement&&r.target.getAttribute("variant")==="ghost"&&sc(r.target)}).observe(n,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["variant"]})}function t2(n,e){if(n instanceof Element){n instanceof HTMLButtonElement&&n.getAttribute("variant")==="ghost"&&e(n);for(const t of n.querySelectorAll('button[variant="ghost"]'))e(t)}}async function sc(n){if(ic.has(n))return;ic.add(n);const e=await dh(n);if(n.getAttribute("variant")!=="ghost"){ic.delete(n);return}n.setAttribute("tone",e)}const n2="*,*:before,*:after{box-sizing:border-box}html,body{margin:0;padding:0;width:100%;height:100%}h1,h2,h3,h4,h5,h6,p,ul,ol,blockquote,pre,hr{margin:0}button,input,textarea,select{font:inherit;color:inherit}@font-face{font-family:Hind;src:url("+new URL("Hind-Variable-C47b_dt9.woff2",import.meta.url).href+') format("woff2-variations");font-weight:300 700;font-style:normal;font-display:swap}:root{--font-sans: "Hind", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;--font-brand: var(--font-sans);--font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, monospace;--font-weight-body: 500;--text-base: 13.5px;--text-scale: 1.125;--text-sm: round(calc(var(--text-base) / var(--text-scale)), 1px);--text-lg: round(calc(var(--text-base) * var(--text-scale)), 1px);--text-xl: round(calc(var(--text-lg) * var(--text-scale)), 1px);--leading-base: 1.5;--space-2: 2px;--space-4: 4px;--space-6: 6px;--space-8: 8px;--space-12: 12px;--space-16: 16px;--space-20: 20px;--space-24: 24px;--space-32: 32px;--space-48: 48px;--space-64: 64px;--radius-4: 4px;--radius-8: 8px;--radius-12: 12px;--radius-16: 16px;--radius-24: 24px;--radius-full: 9999px;--shadow-hairline: 0 0 0 .5px var(--color-border);--shadow-control: 0 1px 1px rgb(0 0 0 / .04), 0 2px 6px rgb(0 0 0 / .06);--alpha-50: 4%;--alpha-100: 8%;--alpha-200: 15%;--alpha-300: 22%;--alpha-400: 30%;--alpha-500: 40%;--alpha-600: 50%;--alpha-700: 65%;--alpha-800: 80%;--alpha-900: 90%;--alpha-950: 95%;--tint-50: color-mix(in srgb, currentColor var(--alpha-50), transparent);--tint-100: color-mix(in srgb, currentColor var(--alpha-100), transparent);--tint-200: color-mix(in srgb, currentColor var(--alpha-200), transparent);--tint-300: color-mix(in srgb, currentColor var(--alpha-300), transparent);--tint-400: color-mix(in srgb, currentColor var(--alpha-400), transparent);--tint-500: color-mix(in srgb, currentColor var(--alpha-500), transparent);--tint-600: color-mix(in srgb, currentColor var(--alpha-600), transparent);--tint-700: color-mix(in srgb, currentColor var(--alpha-700), transparent);--tint-800: color-mix(in srgb, currentColor var(--alpha-800), transparent);--tint-900: color-mix(in srgb, currentColor var(--alpha-900), transparent);--tint-950: color-mix(in srgb, currentColor var(--alpha-950), transparent);--color-overlay-hover: color-mix(in srgb, var(--black) var(--alpha-100), transparent);--color-overlay-active: color-mix(in srgb, var(--black) var(--alpha-300), transparent);--backdrop-blur-glass: blur(20px) saturate(1.4);--black: #000000;--white: #ffffff;--neutral-50: oklch(.985 0 0);--neutral-100: oklch(.97 0 0);--neutral-200: oklch(.923 0 0);--neutral-300: oklch(.869 0 0);--neutral-350: oklch(.79 0 0);--neutral-400: oklch(.709 0 0);--neutral-500: oklch(.553 0 0);--neutral-600: oklch(.444 0 0);--neutral-700: oklch(.374 0 0);--neutral-800: oklch(.268 0 0);--neutral-900: oklch(.216 0 0);--neutral-950: oklch(.147 0 0);--red-50: oklch(.969 .015 12.422);--red-100: oklch(.941 .03 12.58);--red-200: oklch(.892 .058 10.001);--red-300: oklch(.81 .117 11.638);--red-400: oklch(.712 .194 13.428);--red-500: oklch(.645 .246 16.439);--red-600: oklch(.586 .253 17.585);--red-700: oklch(.514 .222 16.935);--red-800: oklch(.455 .188 13.697);--red-900: oklch(.41 .159 10.272);--red-950: oklch(.271 .105 12.094);--orange-50: oklch(.98 .016 73.684);--orange-100: oklch(.954 .038 75.164);--orange-200: oklch(.901 .076 70.697);--orange-300: oklch(.837 .128 66.29);--orange-400: oklch(.75 .183 55.934);--orange-500: oklch(.705 .213 47.604);--orange-600: oklch(.646 .222 41.116);--orange-700: oklch(.553 .195 38.402);--orange-800: oklch(.47 .157 37.304);--orange-900: oklch(.408 .123 38.172);--orange-950: oklch(.266 .079 36.259);--yellow-50: oklch(.987 .026 102.212);--yellow-100: oklch(.973 .071 103.193);--yellow-200: oklch(.945 .129 101.54);--yellow-300: oklch(.905 .182 98.111);--yellow-400: oklch(.852 .199 91.936);--yellow-500: oklch(.795 .184 86.047);--yellow-600: oklch(.681 .162 75.834);--yellow-700: oklch(.554 .135 66.442);--yellow-800: oklch(.476 .114 61.907);--yellow-900: oklch(.421 .095 57.708);--yellow-950: oklch(.286 .066 53.813);--green-50: oklch(.979 .021 166.113);--green-100: oklch(.95 .052 163.051);--green-200: oklch(.905 .093 164.15);--green-300: oklch(.845 .143 164.978);--green-400: oklch(.765 .177 163.223);--green-500: oklch(.696 .17 162.48);--green-600: oklch(.596 .145 163.225);--green-700: oklch(.508 .118 165.612);--green-800: oklch(.432 .095 166.913);--green-900: oklch(.378 .077 168.94);--green-950: oklch(.262 .051 172.552);--blue-50: oklch(.97 .014 254.604);--blue-100: oklch(.932 .032 255.585);--blue-200: oklch(.882 .059 254.128);--blue-300: oklch(.809 .105 251.813);--blue-400: oklch(.707 .165 254.624);--blue-500: oklch(.623 .214 259.815);--blue-600: oklch(.546 .245 262.881);--blue-700: oklch(.488 .243 264.376);--blue-800: oklch(.424 .199 265.638);--blue-900: oklch(.379 .146 265.522);--blue-950: oklch(.282 .091 267.935);--purple-50: oklch(.969 .016 293.756);--purple-100: oklch(.943 .029 294.588);--purple-200: oklch(.894 .057 293.283);--purple-300: oklch(.811 .111 293.571);--purple-400: oklch(.702 .183 293.541);--purple-500: oklch(.606 .25 292.717);--purple-600: oklch(.541 .281 293.009);--purple-700: oklch(.491 .27 292.581);--purple-800: oklch(.432 .232 292.759);--purple-900: oklch(.38 .189 293.745);--purple-950: oklch(.283 .141 291.089)}@supports (corner-shape: squircle){:root{--radius-8: 10px;--radius-12: 15px;--radius-16: 20px;--radius-24: 30px}}:root[data-font=system]{--font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif}:root{--color-bg: var(--neutral-50);--color-bg-muted: var(--neutral-100);--color-surface: var(--white);--color-surface-muted: var(--neutral-100);--color-interactive: var(--neutral-200);--color-interactive-hover: var(--neutral-300);--color-border: rgba(0, 0, 0, .1);--color-border-muted: rgba(0, 0, 0, .06);--color-text: var(--neutral-900);--color-text-muted: var(--neutral-500);--color-link: inherit;--color-focus-ring: var(--neutral-500);--color-overlay-backdrop: rgb(0 0 0 / .5);--color-highlight: rgb(255 255 255 / .5);--color-primary: var(--blue-500);--color-danger: var(--red-600);color-scheme:light}body{font-family:var(--font-sans);font-size:var(--text-base);font-weight:var(--font-weight-body);line-height:var(--leading-base);letter-spacing:.015em;color:var(--color-text);background:var(--color-bg);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}a{color:var(--color-link);text-underline-offset:.15em;text-decoration-thickness:.08em}h1,h2,h3,h4,h5,h6{font-weight:600;color:inherit}code{font-family:var(--font-mono);font-size:.9em;background:var(--color-bg-muted);padding:var(--space-2) var(--space-4);border-radius:var(--radius-4)}pre{font-family:var(--font-mono);background:var(--color-bg-muted);padding:var(--space-12);border-radius:var(--radius-8);overflow-x:auto}pre code{background:none;padding:0}blockquote{padding-left:var(--space-16);border-left:3px solid var(--color-border);color:var(--color-text-muted)}hr{border:none;border-top:1px solid var(--color-border)}table{border-collapse:collapse}th,td{padding:var(--space-8) var(--space-12);border:1px solid var(--color-border);text-align:left}th{background:var(--color-bg-muted);font-weight:600}input,textarea{padding:6px 10px;border:.5px solid var(--tint-300);border-radius:var(--radius-12);background:var(--tint-100);color:inherit;font:inherit;transition:background .12s ease,border-color .12s ease,box-shadow .12s ease}textarea{resize:none}input::placeholder,textarea::placeholder{color:var(--tint-500)}input:focus,textarea:focus{background:color-mix(in srgb,var(--white) var(--alpha-300),transparent);border-color:var(--color-primary);outline:none;box-shadow:0 0 0 1.5px var(--color-primary)}label.field{display:grid;gap:4px;font-size:13px}label.field>span{font-size:11.5px;font-weight:450;color:var(--tint-800)}@supports (corner-shape: squircle){*{corner-shape:squircle}}button{display:inline-flex;align-items:center;justify-content:center;gap:var(--space-6);padding:4px 14px;border:.5px solid var(--tint-200);border-radius:var(--radius-12);background:var(--color-surface);color:inherit;font:inherit;cursor:default;box-shadow:var(--shadow-control)}button:hover:not(:disabled){background:color-mix(in srgb,var(--color-surface) 96%,black)}button:active:not(:disabled){background:color-mix(in srgb,var(--color-surface) 88%,black);box-shadow:inset 0 1px 2px #00000014}button:focus-visible{outline:2px solid var(--color-focus-ring);outline-offset:2px}button[variant=primary]{background:var(--color-primary);border-color:#0000002e;color:var(--white)}button[variant=primary]:hover:not(:disabled){background:color-mix(in srgb,var(--color-primary) 92%,black)}button[variant=primary]:active:not(:disabled){background:color-mix(in srgb,var(--color-primary) 82%,black);box-shadow:inset 0 1px 2px #0000002e}button[variant=danger]{background:var(--color-danger);border-color:#0000002e;color:var(--white)}button[variant=danger]:hover:not(:disabled){background:color-mix(in srgb,var(--color-danger) 92%,black)}button[variant=danger]:active:not(:disabled){background:color-mix(in srgb,var(--color-danger) 82%,black);box-shadow:inset 0 1px 2px #0000002e}button[variant=ghost]{background:transparent;border-color:transparent;color:inherit;box-shadow:none}button[variant=ghost]:hover:not(:disabled){background:var(--color-overlay-hover)}button[variant=ghost]:active:not(:disabled){background:var(--color-overlay-active);box-shadow:none}button[variant=ghost][data-active]:not(:disabled),button[variant=ghost][data-active]:hover:not(:disabled),button[variant=ghost][aria-expanded=true]:not(:disabled),button[variant=ghost][aria-expanded=true]:hover:not(:disabled){background:var(--color-overlay-active);box-shadow:none}button:disabled{background:var(--tint-300);border-color:transparent;color:var(--tint-700);box-shadow:none}[tone=dark] button:not([variant]):not(:disabled){background:var(--tint-200);border-color:var(--tint-300);box-shadow:inset 0 .5px 0 var(--tint-300)}[tone=dark] button:not([variant]):hover:not(:disabled){background:var(--tint-300)}[tone=dark] button:not([variant]):active:not(:disabled){background:var(--tint-400);box-shadow:inset 0 1px 2px #0003}[tone=light] button:not([variant]):not(:disabled){background:var(--color-surface);border-color:var(--tint-200);box-shadow:var(--shadow-control)}[tone=light] button:not([variant]):hover:not(:disabled){background:color-mix(in srgb,var(--color-surface) 96%,black)}[tone=light] button:not([variant]):active:not(:disabled){background:color-mix(in srgb,var(--color-surface) 88%,black);box-shadow:inset 0 1px 2px #00000014}button[size=sm]{min-height:24px;padding:var(--space-2) var(--space-8)}button[size=md]{min-height:32px;padding:var(--space-6) var(--space-12)}button[icon-only]{width:24px;height:24px;min-height:0;padding:0}[data-ui-icon]{display:inline-block;vertical-align:middle}.prose{line-height:var(--leading-base)}.prose h1{font-size:var(--text-xl);margin-bottom:var(--space-8)}.prose h2{font-size:var(--text-lg);margin-top:var(--space-24);margin-bottom:var(--space-8)}.prose h3,.prose h4,.prose h5,.prose h6{font-size:var(--text-base);margin-top:var(--space-24);margin-bottom:var(--space-8)}.prose p{margin:var(--space-12) 0}.prose ul,.prose ol{padding-left:var(--space-24);margin:var(--space-12) 0}.prose blockquote,.prose pre{margin:var(--space-12) 0}.prose hr{margin:var(--space-24) 0}.prose table{width:100%;margin:var(--space-12) 0}.prose img{max-width:100%;height:auto}.prose>:first-child{margin-top:0}.prose>:last-child{margin-bottom:0}[material=paper]{background:var(--white);border:.5px solid color-mix(in srgb,var(--black) var(--alpha-100),transparent);color:var(--color-text)}[material=glass]{background:color-mix(in srgb,var(--white) var(--alpha-700),transparent);border:.5px solid color-mix(in srgb,var(--black) var(--alpha-100),transparent);color:var(--color-text);backdrop-filter:var(--backdrop-blur-glass);-webkit-backdrop-filter:var(--backdrop-blur-glass)}[tone=dark]{color:color-mix(in srgb,var(--white) var(--alpha-950),transparent);border-color:color-mix(in srgb,var(--white) var(--alpha-200),transparent);--color-overlay-hover: color-mix(in srgb, var(--white) var(--alpha-200), transparent);--color-overlay-active: color-mix(in srgb, var(--black) var(--alpha-500), transparent)}[tone=dark][material=paper]{background:#000}[tone=dark][material=glass]{background:color-mix(in srgb,var(--black) var(--alpha-600),transparent)}[tone=light]{color:var(--color-text);border-color:color-mix(in srgb,var(--black) var(--alpha-100),transparent);--color-overlay-hover: color-mix(in srgb, var(--black) var(--alpha-100), transparent);--color-overlay-active: color-mix(in srgb, var(--black) var(--alpha-300), transparent)}[level="1"]{box-shadow:0 12px 32px #00000024}[level="2"]{box-shadow:0 4px 6px -2px #0000001f,0 40px 60px -16px #00000038}dropdown-menu{position:relative;display:inline-block;color:inherit}dropdown-group{display:grid;gap:var(--space-4)}dropdown-label{display:block;padding:var(--space-4) var(--space-8);color:var(--color-text-muted);font:inherit;font-size:var(--text-sm);font-weight:600;letter-spacing:.04em;text-transform:uppercase}dropdown-divider{display:block;height:1px;margin:2px 0;background:var(--color-border)}[data-dropdown-trigger][aria-expanded=true],[data-dropdown-trigger][aria-expanded=true]:hover,dropdown-menu[open]::part(trigger),dropdown-menu[open]::part(trigger):hover{background:color-mix(in srgb,var(--color-surface) 88%,black);box-shadow:inset 0 1px 2px #00000014}[data-dropdown-trigger-label],dropdown-menu::part(trigger-label){min-width:0}[data-dropdown-trigger-icon],dropdown-menu::part(trigger-icon){display:inline-flex;align-items:center;justify-content:center;flex:none;color:var(--color-text-muted);transform:translateY(1px)}dropdown-item:focus-visible{outline:2px solid var(--color-focus-ring);outline-offset:2px}dropdown-menu::part(panel){position:absolute;left:0;min-width:192px;padding:var(--space-4);border-radius:var(--radius-8);display:flex;flex-direction:column;gap:2px;z-index:2000}dropdown-menu::part(panel-bottom){top:calc(100% + var(--space-4))}dropdown-menu::part(panel-top){bottom:calc(100% + var(--space-4))}dropdown-item{display:flex;align-items:center;gap:var(--space-8);margin:0;padding:6px 12px;border-radius:var(--radius-8);font:inherit;line-height:1.2;color:inherit;font-weight:var(--font-weight-body);-webkit-user-select:none;user-select:none}dropdown-item>[data-ui-icon]{flex:none}dropdown-item[selected]{background:var(--color-overlay-active)}dropdown-item:hover{background:var(--color-primary);color:var(--white)}dropdown-item[action]{color:inherit}dropdown-item[danger]{color:var(--color-danger)}dropdown-item[danger]:hover{background:var(--color-danger);color:var(--white)}modal-overlay{color:inherit}modal-overlay::part(backdrop){position:fixed;top:0;right:0;bottom:0;left:0;z-index:var(--layer-overlay);display:flex;align-items:center;justify-content:center;padding:var(--space-16);background:var(--color-overlay-backdrop)}panel-view{display:block}panel-view::part(panel){display:flex;flex-direction:column;gap:var(--space-16);color:var(--color-text)}panel-view::part(header){display:flex;align-items:center;justify-content:space-between;gap:var(--space-12)}panel-view::part(title){margin:0;font:inherit;font-size:var(--text-lg);font-weight:600;color:var(--color-text)}panel-view::part(button){display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;margin:0;border:1px solid var(--color-border);border-radius:var(--radius-4);background:var(--color-surface);color:var(--color-text);box-shadow:none}panel-view::part(button):hover{background:var(--color-interactive-hover)}panel-view::part(button):focus-visible{outline:2px solid var(--color-focus-ring);outline-offset:2px}panel-view::part(icon){display:inline-flex;align-items:center;justify-content:center;flex:none}ui-popover{display:contents}ui-popover::part(panel){position:fixed;min-width:192px;max-width:384px;padding:var(--space-16) var(--space-20);border-radius:var(--radius-16);outline:none;z-index:2000}ui-pill{display:inline-block;vertical-align:baseline;margin:2px 0;padding:0 var(--space-8);font-size:var(--text-sm);font-weight:500;line-height:1.7;border-radius:var(--radius-full);border:1px solid var(--neutral-300);background:var(--neutral-200);color:var(--neutral-900);white-space:nowrap}ui-pill[color=gray]{border-color:var(--neutral-300);background:var(--neutral-200);color:var(--neutral-900)}ui-pill[color=red]{border-color:var(--red-200);background:var(--red-100);color:var(--red-950)}ui-pill[color=orange]{border-color:var(--orange-200);background:var(--orange-100);color:var(--orange-950)}ui-pill[color=yellow]{border-color:var(--yellow-200);background:var(--yellow-100);color:var(--yellow-950)}ui-pill[color=green]{border-color:var(--green-200);background:var(--green-100);color:var(--green-950)}ui-pill[color=blue]{border-color:var(--blue-200);background:var(--blue-100);color:var(--blue-950)}ui-pill[color=purple]{border-color:var(--purple-200);background:var(--purple-100);color:var(--purple-950)}',ph=new CSSStyleSheet;ph.replaceSync(n2);try{document.adoptedStyleSheets=[...document.adoptedStyleSheets,ph]}catch{}sy(document);function oy(n){try{n.adoptedStyleSheets=[...n.adoptedStyleSheets,ph]}catch{}sy(n)}/**
50
50
  * @license
51
51
  * Copyright 2017 Google LLC
52
52
  * SPDX-License-Identifier: BSD-3-Clause
53
- */const sy={CHILD:2},hh=n=>(...e)=>({_$litDirective$:n,values:e});class oy{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,t,r){this._$Ct=e,this._$AM=t,this._$Ci=r}_$AS(e,t){return this.update(e,t)}update(e,t){return this.render(...t)}}/**
53
+ */const ay={CHILD:2},fh=n=>(...e)=>({_$litDirective$:n,values:e});class ly{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,t,r){this._$Ct=e,this._$AM=t,this._$Ci=r}_$AS(e,t){return this.update(e,t)}update(e,t){return this.render(...t)}}/**
54
54
  * @license
55
55
  * Copyright 2017 Google LLC
56
56
  * SPDX-License-Identifier: BSD-3-Clause
57
- */let va=class extends oy{constructor(e){if(super(e),this.it=se,e.type!==sy.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(e){if(e===se||e==null)return this._t=void 0,this.it=e;if(e===pi)return e;if(typeof e!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(e===this.it)return this._t;this.it=e;const t=[e];return t.raw=t,this._t={_$litType$:this.constructor.resultType,strings:t,values:[]}}};va.directiveName="unsafeHTML",va.resultType=1;const n2=hh(va);/**
57
+ */let va=class extends ly{constructor(e){if(super(e),this.it=se,e.type!==ay.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(e){if(e===se||e==null)return this._t=void 0,this.it=e;if(e===pi)return e;if(typeof e!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(e===this.it)return this._t;this.it=e;const t=[e];return t.raw=t,this._t={_$litType$:this.constructor.resultType,strings:t,values:[]}}};va.directiveName="unsafeHTML",va.resultType=1;const r2=fh(va);/**
58
58
  * @license
59
59
  * Copyright 2017 Google LLC
60
60
  * SPDX-License-Identifier: BSD-3-Clause
61
- */class Vc extends va{}Vc.directiveName="unsafeSVG",Vc.resultType=2;const r2=hh(Vc),i2={size:16,color:"currentColor",weight:"regular"};function s2(n){return typeof n=="string"?{regular:n}:n}function Ot(n,e="0 0 256 256"){const t=s2(n);return r=>{const{size:i,color:s,weight:o}={...i2,...r},a=t[o]??t.regular;return U`<svg
61
+ */class qc extends va{}qc.directiveName="unsafeSVG",qc.resultType=2;const i2=fh(qc),s2={size:16,color:"currentColor",weight:"regular"};function o2(n){return typeof n=="string"?{regular:n}:n}function Ot(n,e="0 0 256 256"){const t=o2(n);return r=>{const{size:i,color:s,weight:o}={...s2,...r},a=t[o]??t.regular;return U`<svg
62
62
  xmlns="http://www.w3.org/2000/svg"
63
63
  data-ui-icon=""
64
64
  width="${i}"
65
65
  height="${i}"
66
66
  viewBox="${e}"
67
67
  fill="${s}"
68
- >${r2(a)}</svg>`}}const o2=Ot('<path fill="none" stroke="currentColor" stroke-width="16" stroke-linecap="round" stroke-linejoin="round" d="M200 224H56C53.8783 224 51.8434 223.157 50.3431 221.657C48.8429 220.157 48 218.122 48 216V40C48 37.8783 48.8429 35.8434 50.3431 34.3431C51.8434 32.8429 53.8783 32 56 32H152L208 88V216C208 218.122 207.157 220.157 205.657 221.657C204.157 223.157 202.122 224 200 224Z"/><path fill="none" stroke="currentColor" stroke-width="16" stroke-linecap="round" stroke-linejoin="round" d="M152 32V88H208"/><path fill="none" stroke="currentColor" stroke-width="16" stroke-linecap="round" d="M80 88H124.5"/><path fill="none" stroke="currentColor" stroke-width="16" stroke-linecap="round" d="M80 128H175"/><path fill="none" stroke="currentColor" stroke-width="16" stroke-linecap="round" d="M80 169H175"/>'),ay=Ot('<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"/>'),a2=Ot('<path d="M181.66,133.66l-80,80a8,8,0,0,1-11.32-11.32L164.69,128,90.34,53.66a8,8,0,0,1,11.32-11.32l80,80A8,8,0,0,1,181.66,133.66Z"/>'),ly=Ot('<path d="M213.66,93.66l-80,80a8,8,0,0,1-11.32,0l-80-80A8,8,0,0,1,53.66,82.34L128,156.69l74.34-74.35a8,8,0,0,1,11.32,11.32Z"/>'),l2=Ot('<path d="M213.66,162.34l-80-80a8,8,0,0,0-11.32,0l-80,80A8,8,0,0,0,53.66,173.66L128,99.31l74.34,74.35a8,8,0,0,0,11.32-11.32Z"/>'),c2=Ot('<path d="M224,128a8,8,0,0,1-8,8H136v80a8,8,0,0,1-16,0V136H40a8,8,0,0,1,0-16h80V40a8,8,0,0,1,16,0v80h80A8,8,0,0,1,224,128Z"/>'),u2=Ot({regular:'<path d="M219.31,108.68l-80-80a16,16,0,0,0-22.62,0l-80,80A15.87,15.87,0,0,0,32,120v96a8,8,0,0,0,8,8h64a8,8,0,0,0,8-8V160h32v56a8,8,0,0,0,8,8h64a8,8,0,0,0,8-8V120A15.87,15.87,0,0,0,219.31,108.68ZM208,208H160V152a8,8,0,0,0-8-8H104a8,8,0,0,0-8,8v56H48V120l80-80,80,80Z"/>',bold:'<path d="M222.14,105.85l-80-80a20,20,0,0,0-28.28,0l-80,80A19.86,19.86,0,0,0,28,120v96a12,12,0,0,0,12,12h64a12,12,0,0,0,12-12V164h24v52a12,12,0,0,0,12,12h64a12,12,0,0,0,12-12V120A19.86,19.86,0,0,0,222.14,105.85ZM204,204H164V152a12,12,0,0,0-12-12H104a12,12,0,0,0-12,12v52H52V121.65l76-76,76,76Z"/>',fill:'<path d="M224,120v96a8,8,0,0,1-8,8H160a8,8,0,0,1-8-8V164a4,4,0,0,0-4-4H108a4,4,0,0,0-4,4v52a8,8,0,0,1-8,8H40a8,8,0,0,1-8-8V120a16,16,0,0,1,4.69-11.31l80-80a16,16,0,0,1,22.62,0l80,80A16,16,0,0,1,224,120Z"/>'}),h2=Ot({regular:'<path d="M227.31,73.37,182.63,28.68a16,16,0,0,0-22.63,0L36.69,152A15.86,15.86,0,0,0,32,163.31V208a16,16,0,0,0,16,16H92.69A15.86,15.86,0,0,0,104,219.31L227.31,96a16,16,0,0,0,0-22.63ZM51.31,160,136,75.31,152.69,92,68,176.68ZM48,179.31,76.69,208H48Zm48,25.38L79.31,188,164,103.31,180.69,120Zm96-96L147.31,64l24-24L216,84.68Z"/>',bold:'<path d="M230.14,70.54,185.46,25.85a20,20,0,0,0-28.29,0L33.86,149.17A19.85,19.85,0,0,0,28,163.31V208a20,20,0,0,0,20,20H92.69a19.86,19.86,0,0,0,14.14-5.86L230.14,98.82a20,20,0,0,0,0-28.28ZM93,180l71-71,11,11-71,71ZM76,163,65,152l71-71,11,11ZM52,173l15.51,15.51h0L83,204H52ZM192,103,153,64l18.34-18.34,39,39Z"/>'}),d2=Ot({regular:'<path d="M216,48H176V40a24,24,0,0,0-24-24H104A24,24,0,0,0,80,40v8H40a8,8,0,0,0,0,16h8V208a16,16,0,0,0,16,16H192a16,16,0,0,0,16-16V64h8a8,8,0,0,0,0-16ZM96,40a8,8,0,0,1,8-8h48a8,8,0,0,1,8,8v8H96Zm96,168H64V64H192ZM112,104v64a8,8,0,0,1-16,0V104a8,8,0,0,1,16,0Zm48,0v64a8,8,0,0,1-16,0V104a8,8,0,0,1,16,0Z"/>',bold:'<path d="M216,44H176V40a24,24,0,0,0-24-24H104A24,24,0,0,0,80,40v4H40a12,12,0,0,0,0,24h4V208a20,20,0,0,0,20,20H192a20,20,0,0,0,20-20V68h4a12,12,0,0,0,0-24ZM104,40h48v4H104Zm84,164H68V68H188Zm-84-48V120a12,12,0,0,1,24,0v36a12,12,0,0,1-24,0Zm40,0V120a12,12,0,0,1,24,0v36a12,12,0,0,1-24,0Z"/>'}),Gc=Ot({regular:'<path d="M239.18,97.26A16.38,16.38,0,0,0,224.92,86l-59-4.76L143.14,26.15a16.36,16.36,0,0,0-30.27,0L90.11,81.23,31.08,86a16.46,16.46,0,0,0-9.37,28.86l45,38.83L53,211.75a16.38,16.38,0,0,0,24.5,17.82L128,198.49l50.53,31.08A16.4,16.4,0,0,0,203,211.75l-13.76-58.07,45-38.83A16.43,16.43,0,0,0,239.18,97.26Zm-15.34,5.47-48.7,42a8,8,0,0,0-2.56,7.91l14.88,62.8a.37.37,0,0,1-.17.48c-.18.14-.23.11-.38,0l-54.72-33.65a8,8,0,0,0-8.38,0L69.09,215.94c-.15.09-.19.12-.38,0a.37.37,0,0,1-.17-.48l14.88-62.8a8,8,0,0,0-2.56-7.91l-48.7-42c-.12-.1-.23-.19-.13-.5s.18-.27.33-.29l63.92-5.16A8,8,0,0,0,103,91.86l24.62-59.61c.08-.17.11-.25.35-.25s.27.08.35.25L153,91.86a8,8,0,0,0,6.75,4.92l63.92,5.16c.15,0,.24,0,.33.29S224,102.63,223.84,102.73Z"/>',bold:'<path d="M243,96a20.33,20.33,0,0,0-17.74-14l-56.59-4.57L146.83,24.62a20.36,20.36,0,0,0-37.66,0L87.35,77.44,30.76,82A20.45,20.45,0,0,0,19.1,117.88l43.18,37.24-13.2,55.7A20.37,20.37,0,0,0,79.57,233L128,203.19,176.43,233a20.39,20.39,0,0,0,30.49-22.15l-13.2-55.7,43.18-37.24A20.43,20.43,0,0,0,243,96ZM172.53,141.7a12,12,0,0,0-3.84,11.86L181.58,208l-47.29-29.08a12,12,0,0,0-12.58,0L74.42,208l12.89-54.4a12,12,0,0,0-3.84-11.86L41.2,105.24l55.4-4.47a12,12,0,0,0,10.13-7.38L128,41.89l21.27,51.5a12,12,0,0,0,10.13,7.38l55.4,4.47Z"/>',fill:'<path d="M234.29,114.85l-45,38.83L203,211.75a16.4,16.4,0,0,1-24.5,17.82L128,198.49,77.47,229.57A16.4,16.4,0,0,1,53,211.75l13.76-58.07-45-38.83A16.46,16.46,0,0,1,31.08,86l59-4.76,22.76-55.08a16.36,16.36,0,0,1,30.27,0l22.75,55.08,59,4.76a16.46,16.46,0,0,1,9.37,28.86Z"/>'});class cy extends Event{constructor(t){super("dropdown-item-select",{bubbles:!0,composed:!0});b(this,"value");this.value=t}}class p2 extends Event{constructor(t){super("select",{bubbles:!0,composed:!0});b(this,"value");this.value=t}}var Ke,mt,dn,Qn,ne,ks,M,hy,Gi,dy,py,jc,fy,ji,Dn,er,Es,xs,As,xa,gy,my,qc,qi,vy,Yc,Zt;class uy extends HTMLElement{constructor(){super();w(this,M);w(this,Ke,!1);w(this,mt,null);w(this,dn,null);w(this,Qn);w(this,ne,null);w(this,ks,new MutationObserver(t=>m(this,M,gy).call(this,t)));w(this,er,()=>{m(this,M,ji).call(this,!l(this,Ke))});w(this,Es,t=>{t.key!=="Enter"&&t.key!==" "||(t.preventDefault(),l(this,er).call(this))});w(this,xs,t=>{l(this,Ke)&&(t.composedPath().includes(this)||m(this,M,ji).call(this,!1))});w(this,As,t=>{t instanceof cy&&(t.stopPropagation(),x(this,Ke,!1),m(this,M,Gi).call(this,t.value),m(this,M,Zt).call(this),this.dispatchEvent(new p2(t.value)))});w(this,xa,()=>{m(this,M,qc).call(this)});x(this,Qn,this.attachShadow({mode:"open"})),iy(l(this,Qn))}connectedCallback(){this.addEventListener("dropdown-item-select",l(this,As)),document.addEventListener("click",l(this,xs),!0),m(this,M,hy).call(this),l(this,ks).observe(this,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["selected","value","slot"]}),m(this,M,Zt).call(this)}disconnectedCallback(){this.removeEventListener("dropdown-item-select",l(this,As)),document.removeEventListener("click",l(this,xs),!0),l(this,ks).disconnect(),m(this,M,Yc).call(this)}attributeChangedCallback(t){if(t==="open"){m(this,M,ji).call(this,this.hasAttribute("open"));return}m(this,M,Zt).call(this)}get open(){return l(this,Ke)}set open(t){this.toggleAttribute("open",t)}get title(){return this.getAttribute("title")??""}get placement(){return this.getAttribute("placement")==="top"?"top":"bottom"}get value(){return l(this,mt)}set value(t){t===null?(m(this,M,Dn).call(this,null,null),m(this,M,dy).call(this)):m(this,M,Gi).call(this,t),m(this,M,Zt).call(this)}close(){m(this,M,ji).call(this,!1)}}Ke=new WeakMap,mt=new WeakMap,dn=new WeakMap,Qn=new WeakMap,ne=new WeakMap,ks=new WeakMap,M=new WeakSet,hy=function(){var r;const t=this.querySelector("dropdown-item[selected]");t&&m(this,M,Dn).call(this,t.value,((r=t.textContent)==null?void 0:r.trim())??null)},Gi=function(t){var r;for(const i of l(this,M,jc))i.value===t?(m(this,M,Dn).call(this,t,((r=i.textContent)==null?void 0:r.trim())??null),i.hasAttribute("selected")||i.setAttribute("selected","")):i.hasAttribute("selected")&&i.removeAttribute("selected")},dy=function(){const t=this.querySelectorAll("dropdown-item[selected]");for(const r of t)r.removeAttribute("selected")},py=function(t){for(const r of l(this,M,jc))if(r.value===t)return r;return null},jc=function(){return this.querySelectorAll("dropdown-item")},fy=function(){return l(this,dn)??this.title},ji=function(t){l(this,Ke)!==t&&(x(this,Ke,t),m(this,M,Zt).call(this))},Dn=function(t,r){x(this,mt,t),x(this,dn,r)},er=new WeakMap,Es=new WeakMap,xs=new WeakMap,As=new WeakMap,xa=new WeakMap,gy=function(t){t.every(i=>i.target instanceof Element?i.target.closest('[slot="trigger"]')!==null:!1)||m(this,M,my).call(this)},my=function(){var r,i;const t=this.querySelector("dropdown-item[selected]");if(t){const s=t.value,o=((r=t.textContent)==null?void 0:r.trim())??null,a=l(this,mt)!==s||l(this,dn)!==o;m(this,M,Dn).call(this,s,o),m(this,M,Gi).call(this,s),a?m(this,M,Zt).call(this):m(this,M,qi).call(this);return}if(l(this,mt)!==null){const s=m(this,M,py).call(this,l(this,mt));if(s){const o=((i=s.textContent)==null?void 0:i.trim())??null,a=l(this,dn)!==o;m(this,M,Dn).call(this,l(this,mt),o),m(this,M,Gi).call(this,l(this,mt)),a?m(this,M,Zt).call(this):m(this,M,qi).call(this);return}}if(l(this,mt)!==null||l(this,dn)!==null){m(this,M,Dn).call(this,null,null),m(this,M,Zt).call(this);return}m(this,M,qi).call(this)},qc=function(){const t=l(this,Qn).querySelector('slot[name="trigger"]'),r=t instanceof HTMLSlotElement?t.assignedElements()[0]??null:null;l(this,ne)!==r&&(m(this,M,Yc).call(this),x(this,ne,r),l(this,ne)&&(l(this,ne).addEventListener("click",l(this,er)),l(this,ne)instanceof HTMLButtonElement?l(this,ne).hasAttribute("type")||(l(this,ne).type="button"):(l(this,ne).hasAttribute("role")||l(this,ne).setAttribute("role","button"),l(this,ne).hasAttribute("tabindex")||(l(this,ne).tabIndex=0),l(this,ne).addEventListener("keydown",l(this,Es))))),m(this,M,qi).call(this)},qi=function(){l(this,ne)&&(l(this,ne).setAttribute("data-dropdown-trigger",""),l(this,ne).setAttribute("aria-haspopup","listbox"),l(this,ne).setAttribute("aria-expanded",l(this,Ke)?"true":"false"))},vy=function(){return this.placement==="top"?l2:ly},Yc=function(){l(this,ne)&&(l(this,ne).removeEventListener("click",l(this,er)),l(this,ne).removeEventListener("keydown",l(this,Es)),l(this,ne).removeAttribute("data-dropdown-trigger"),l(this,ne).removeAttribute("aria-haspopup"),l(this,ne).removeAttribute("aria-expanded"),x(this,ne,null))},Zt=function(){this.toggleAttribute("open",l(this,Ke)),Re(U`
68
+ >${i2(a)}</svg>`}}const a2=Ot('<path fill="none" stroke="currentColor" stroke-width="16" stroke-linecap="round" stroke-linejoin="round" d="M200 224H56C53.8783 224 51.8434 223.157 50.3431 221.657C48.8429 220.157 48 218.122 48 216V40C48 37.8783 48.8429 35.8434 50.3431 34.3431C51.8434 32.8429 53.8783 32 56 32H152L208 88V216C208 218.122 207.157 220.157 205.657 221.657C204.157 223.157 202.122 224 200 224Z"/><path fill="none" stroke="currentColor" stroke-width="16" stroke-linecap="round" stroke-linejoin="round" d="M152 32V88H208"/><path fill="none" stroke="currentColor" stroke-width="16" stroke-linecap="round" d="M80 88H124.5"/><path fill="none" stroke="currentColor" stroke-width="16" stroke-linecap="round" d="M80 128H175"/><path fill="none" stroke="currentColor" stroke-width="16" stroke-linecap="round" d="M80 169H175"/>'),cy=Ot('<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"/>'),l2=Ot('<path d="M181.66,133.66l-80,80a8,8,0,0,1-11.32-11.32L164.69,128,90.34,53.66a8,8,0,0,1,11.32-11.32l80,80A8,8,0,0,1,181.66,133.66Z"/>'),uy=Ot('<path d="M213.66,93.66l-80,80a8,8,0,0,1-11.32,0l-80-80A8,8,0,0,1,53.66,82.34L128,156.69l74.34-74.35a8,8,0,0,1,11.32,11.32Z"/>'),c2=Ot('<path d="M213.66,162.34l-80-80a8,8,0,0,0-11.32,0l-80,80A8,8,0,0,0,53.66,173.66L128,99.31l74.34,74.35a8,8,0,0,0,11.32-11.32Z"/>'),u2=Ot('<path d="M224,128a8,8,0,0,1-8,8H136v80a8,8,0,0,1-16,0V136H40a8,8,0,0,1,0-16h80V40a8,8,0,0,1,16,0v80h80A8,8,0,0,1,224,128Z"/>'),h2=Ot({regular:'<path d="M219.31,108.68l-80-80a16,16,0,0,0-22.62,0l-80,80A15.87,15.87,0,0,0,32,120v96a8,8,0,0,0,8,8h64a8,8,0,0,0,8-8V160h32v56a8,8,0,0,0,8,8h64a8,8,0,0,0,8-8V120A15.87,15.87,0,0,0,219.31,108.68ZM208,208H160V152a8,8,0,0,0-8-8H104a8,8,0,0,0-8,8v56H48V120l80-80,80,80Z"/>',bold:'<path d="M222.14,105.85l-80-80a20,20,0,0,0-28.28,0l-80,80A19.86,19.86,0,0,0,28,120v96a12,12,0,0,0,12,12h64a12,12,0,0,0,12-12V164h24v52a12,12,0,0,0,12,12h64a12,12,0,0,0,12-12V120A19.86,19.86,0,0,0,222.14,105.85ZM204,204H164V152a12,12,0,0,0-12-12H104a12,12,0,0,0-12,12v52H52V121.65l76-76,76,76Z"/>',fill:'<path d="M224,120v96a8,8,0,0,1-8,8H160a8,8,0,0,1-8-8V164a4,4,0,0,0-4-4H108a4,4,0,0,0-4,4v52a8,8,0,0,1-8,8H40a8,8,0,0,1-8-8V120a16,16,0,0,1,4.69-11.31l80-80a16,16,0,0,1,22.62,0l80,80A16,16,0,0,1,224,120Z"/>'}),d2=Ot({regular:'<path d="M227.31,73.37,182.63,28.68a16,16,0,0,0-22.63,0L36.69,152A15.86,15.86,0,0,0,32,163.31V208a16,16,0,0,0,16,16H92.69A15.86,15.86,0,0,0,104,219.31L227.31,96a16,16,0,0,0,0-22.63ZM51.31,160,136,75.31,152.69,92,68,176.68ZM48,179.31,76.69,208H48Zm48,25.38L79.31,188,164,103.31,180.69,120Zm96-96L147.31,64l24-24L216,84.68Z"/>',bold:'<path d="M230.14,70.54,185.46,25.85a20,20,0,0,0-28.29,0L33.86,149.17A19.85,19.85,0,0,0,28,163.31V208a20,20,0,0,0,20,20H92.69a19.86,19.86,0,0,0,14.14-5.86L230.14,98.82a20,20,0,0,0,0-28.28ZM93,180l71-71,11,11-71,71ZM76,163,65,152l71-71,11,11ZM52,173l15.51,15.51h0L83,204H52ZM192,103,153,64l18.34-18.34,39,39Z"/>'}),p2=Ot({regular:'<path d="M216,48H176V40a24,24,0,0,0-24-24H104A24,24,0,0,0,80,40v8H40a8,8,0,0,0,0,16h8V208a16,16,0,0,0,16,16H192a16,16,0,0,0,16-16V64h8a8,8,0,0,0,0-16ZM96,40a8,8,0,0,1,8-8h48a8,8,0,0,1,8,8v8H96Zm96,168H64V64H192ZM112,104v64a8,8,0,0,1-16,0V104a8,8,0,0,1,16,0Zm48,0v64a8,8,0,0,1-16,0V104a8,8,0,0,1,16,0Z"/>',bold:'<path d="M216,44H176V40a24,24,0,0,0-24-24H104A24,24,0,0,0,80,40v4H40a12,12,0,0,0,0,24h4V208a20,20,0,0,0,20,20H192a20,20,0,0,0,20-20V68h4a12,12,0,0,0,0-24ZM104,40h48v4H104Zm84,164H68V68H188Zm-84-48V120a12,12,0,0,1,24,0v36a12,12,0,0,1-24,0Zm40,0V120a12,12,0,0,1,24,0v36a12,12,0,0,1-24,0Z"/>'}),Yc=Ot({regular:'<path d="M239.18,97.26A16.38,16.38,0,0,0,224.92,86l-59-4.76L143.14,26.15a16.36,16.36,0,0,0-30.27,0L90.11,81.23,31.08,86a16.46,16.46,0,0,0-9.37,28.86l45,38.83L53,211.75a16.38,16.38,0,0,0,24.5,17.82L128,198.49l50.53,31.08A16.4,16.4,0,0,0,203,211.75l-13.76-58.07,45-38.83A16.43,16.43,0,0,0,239.18,97.26Zm-15.34,5.47-48.7,42a8,8,0,0,0-2.56,7.91l14.88,62.8a.37.37,0,0,1-.17.48c-.18.14-.23.11-.38,0l-54.72-33.65a8,8,0,0,0-8.38,0L69.09,215.94c-.15.09-.19.12-.38,0a.37.37,0,0,1-.17-.48l14.88-62.8a8,8,0,0,0-2.56-7.91l-48.7-42c-.12-.1-.23-.19-.13-.5s.18-.27.33-.29l63.92-5.16A8,8,0,0,0,103,91.86l24.62-59.61c.08-.17.11-.25.35-.25s.27.08.35.25L153,91.86a8,8,0,0,0,6.75,4.92l63.92,5.16c.15,0,.24,0,.33.29S224,102.63,223.84,102.73Z"/>',bold:'<path d="M243,96a20.33,20.33,0,0,0-17.74-14l-56.59-4.57L146.83,24.62a20.36,20.36,0,0,0-37.66,0L87.35,77.44,30.76,82A20.45,20.45,0,0,0,19.1,117.88l43.18,37.24-13.2,55.7A20.37,20.37,0,0,0,79.57,233L128,203.19,176.43,233a20.39,20.39,0,0,0,30.49-22.15l-13.2-55.7,43.18-37.24A20.43,20.43,0,0,0,243,96ZM172.53,141.7a12,12,0,0,0-3.84,11.86L181.58,208l-47.29-29.08a12,12,0,0,0-12.58,0L74.42,208l12.89-54.4a12,12,0,0,0-3.84-11.86L41.2,105.24l55.4-4.47a12,12,0,0,0,10.13-7.38L128,41.89l21.27,51.5a12,12,0,0,0,10.13,7.38l55.4,4.47Z"/>',fill:'<path d="M234.29,114.85l-45,38.83L203,211.75a16.4,16.4,0,0,1-24.5,17.82L128,198.49,77.47,229.57A16.4,16.4,0,0,1,53,211.75l13.76-58.07-45-38.83A16.46,16.46,0,0,1,31.08,86l59-4.76,22.76-55.08a16.36,16.36,0,0,1,30.27,0l22.75,55.08,59,4.76a16.46,16.46,0,0,1,9.37,28.86Z"/>'});class hy extends Event{constructor(t){super("dropdown-item-select",{bubbles:!0,composed:!0});b(this,"value");this.value=t}}class f2 extends Event{constructor(t){super("select",{bubbles:!0,composed:!0});b(this,"value");this.value=t}}var Ke,mt,dn,Qn,ne,ks,M,py,Bi,fy,gy,Xc,my,ji,Dn,er,Es,xs,As,xa,vy,yy,Kc,qi,by,Jc,Zt;class dy extends HTMLElement{constructor(){super();w(this,M);w(this,Ke,!1);w(this,mt,null);w(this,dn,null);w(this,Qn);w(this,ne,null);w(this,ks,new MutationObserver(t=>m(this,M,vy).call(this,t)));w(this,er,()=>{m(this,M,ji).call(this,!l(this,Ke))});w(this,Es,t=>{t.key!=="Enter"&&t.key!==" "||(t.preventDefault(),l(this,er).call(this))});w(this,xs,t=>{l(this,Ke)&&(t.composedPath().includes(this)||m(this,M,ji).call(this,!1))});w(this,As,t=>{t instanceof hy&&(t.stopPropagation(),x(this,Ke,!1),m(this,M,Bi).call(this,t.value),m(this,M,Zt).call(this),this.dispatchEvent(new f2(t.value)))});w(this,xa,()=>{m(this,M,Kc).call(this)});x(this,Qn,this.attachShadow({mode:"open"})),oy(l(this,Qn))}connectedCallback(){this.addEventListener("dropdown-item-select",l(this,As)),document.addEventListener("click",l(this,xs),!0),m(this,M,py).call(this),l(this,ks).observe(this,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["selected","value","slot"]}),m(this,M,Zt).call(this)}disconnectedCallback(){this.removeEventListener("dropdown-item-select",l(this,As)),document.removeEventListener("click",l(this,xs),!0),l(this,ks).disconnect(),m(this,M,Jc).call(this)}attributeChangedCallback(t){if(t==="open"){m(this,M,ji).call(this,this.hasAttribute("open"));return}m(this,M,Zt).call(this)}get open(){return l(this,Ke)}set open(t){this.toggleAttribute("open",t)}get title(){return this.getAttribute("title")??""}get placement(){return this.getAttribute("placement")==="top"?"top":"bottom"}get value(){return l(this,mt)}set value(t){t===null?(m(this,M,Dn).call(this,null,null),m(this,M,fy).call(this)):m(this,M,Bi).call(this,t),m(this,M,Zt).call(this)}close(){m(this,M,ji).call(this,!1)}}Ke=new WeakMap,mt=new WeakMap,dn=new WeakMap,Qn=new WeakMap,ne=new WeakMap,ks=new WeakMap,M=new WeakSet,py=function(){var r;const t=this.querySelector("dropdown-item[selected]");t&&m(this,M,Dn).call(this,t.value,((r=t.textContent)==null?void 0:r.trim())??null)},Bi=function(t){var r;for(const i of l(this,M,Xc))i.value===t?(m(this,M,Dn).call(this,t,((r=i.textContent)==null?void 0:r.trim())??null),i.hasAttribute("selected")||i.setAttribute("selected","")):i.hasAttribute("selected")&&i.removeAttribute("selected")},fy=function(){const t=this.querySelectorAll("dropdown-item[selected]");for(const r of t)r.removeAttribute("selected")},gy=function(t){for(const r of l(this,M,Xc))if(r.value===t)return r;return null},Xc=function(){return this.querySelectorAll("dropdown-item")},my=function(){return l(this,dn)??this.title},ji=function(t){l(this,Ke)!==t&&(x(this,Ke,t),m(this,M,Zt).call(this))},Dn=function(t,r){x(this,mt,t),x(this,dn,r)},er=new WeakMap,Es=new WeakMap,xs=new WeakMap,As=new WeakMap,xa=new WeakMap,vy=function(t){t.every(i=>i.target instanceof Element?i.target.closest('[slot="trigger"]')!==null:!1)||m(this,M,yy).call(this)},yy=function(){var r,i;const t=this.querySelector("dropdown-item[selected]");if(t){const s=t.value,o=((r=t.textContent)==null?void 0:r.trim())??null,a=l(this,mt)!==s||l(this,dn)!==o;m(this,M,Dn).call(this,s,o),m(this,M,Bi).call(this,s),a?m(this,M,Zt).call(this):m(this,M,qi).call(this);return}if(l(this,mt)!==null){const s=m(this,M,gy).call(this,l(this,mt));if(s){const o=((i=s.textContent)==null?void 0:i.trim())??null,a=l(this,dn)!==o;m(this,M,Dn).call(this,l(this,mt),o),m(this,M,Bi).call(this,l(this,mt)),a?m(this,M,Zt).call(this):m(this,M,qi).call(this);return}}if(l(this,mt)!==null||l(this,dn)!==null){m(this,M,Dn).call(this,null,null),m(this,M,Zt).call(this);return}m(this,M,qi).call(this)},Kc=function(){const t=l(this,Qn).querySelector('slot[name="trigger"]'),r=t instanceof HTMLSlotElement?t.assignedElements()[0]??null:null;l(this,ne)!==r&&(m(this,M,Jc).call(this),x(this,ne,r),l(this,ne)&&(l(this,ne).addEventListener("click",l(this,er)),l(this,ne)instanceof HTMLButtonElement?l(this,ne).hasAttribute("type")||(l(this,ne).type="button"):(l(this,ne).hasAttribute("role")||l(this,ne).setAttribute("role","button"),l(this,ne).hasAttribute("tabindex")||(l(this,ne).tabIndex=0),l(this,ne).addEventListener("keydown",l(this,Es))))),m(this,M,qi).call(this)},qi=function(){l(this,ne)&&(l(this,ne).setAttribute("data-dropdown-trigger",""),l(this,ne).setAttribute("aria-haspopup","listbox"),l(this,ne).setAttribute("aria-expanded",l(this,Ke)?"true":"false"))},by=function(){return this.placement==="top"?c2:uy},Jc=function(){l(this,ne)&&(l(this,ne).removeEventListener("click",l(this,er)),l(this,ne).removeEventListener("keydown",l(this,Es)),l(this,ne).removeAttribute("data-dropdown-trigger"),l(this,ne).removeAttribute("aria-haspopup"),l(this,ne).removeAttribute("aria-expanded"),x(this,ne,null))},Zt=function(){this.toggleAttribute("open",l(this,Ke)),Re(U`
69
69
  <slot name="trigger" @slotchange=${l(this,xa)}>
70
70
  <button
71
71
  class="fallback-trigger"
@@ -75,9 +75,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
75
75
  aria-expanded=${l(this,Ke)?"true":"false"}
76
76
  @click=${l(this,er)}
77
77
  >
78
- <span class="trigger-label" part="trigger-label">${l(this,M,fy)}</span>
78
+ <span class="trigger-label" part="trigger-label">${l(this,M,my)}</span>
79
79
  <span class="trigger-icon" part="trigger-icon" aria-hidden="true">
80
- ${l(this,M,vy).call(this,{size:16})}
80
+ ${l(this,M,by).call(this,{size:16})}
81
81
  </span>
82
82
  </button>
83
83
  </slot>
@@ -92,13 +92,13 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
92
92
  <slot></slot>
93
93
  </div>
94
94
  `:null}
95
- `,l(this,Qn)),queueMicrotask(()=>m(this,M,qc).call(this))},b(uy,"observedAttributes",["title","placement","open"]);class f2 extends HTMLElement{}class g2 extends HTMLElement{}class m2 extends HTMLElement{}var mr,Xc,by,$s,Ts;class yy extends HTMLElement{constructor(){super(...arguments);w(this,mr);w(this,$s,()=>{this.action||m(this,mr,by).call(this)});w(this,Ts,t=>{t.key!=="Enter"&&t.key!==" "||(t.preventDefault(),this.click())})}connectedCallback(){this.hasAttribute("role")||this.setAttribute("role","option"),this.hasAttribute("tabindex")||(this.tabIndex=0),this.addEventListener("click",l(this,$s)),this.addEventListener("keydown",l(this,Ts)),m(this,mr,Xc).call(this)}disconnectedCallback(){this.removeEventListener("click",l(this,$s)),this.removeEventListener("keydown",l(this,Ts))}attributeChangedCallback(){m(this,mr,Xc).call(this)}get value(){return this.getAttribute("value")??""}get selected(){return this.hasAttribute("selected")}get action(){return this.hasAttribute("action")}}mr=new WeakSet,Xc=function(){if(this.action){this.setAttribute("role","button"),this.removeAttribute("aria-selected");return}this.setAttribute("role","option"),this.setAttribute("aria-selected",this.selected?"true":"false")},by=function(){this.dispatchEvent(new cy(this.value))},$s=new WeakMap,Ts=new WeakMap,b(yy,"observedAttributes",["action","selected","value"]);customElements.get("dropdown-menu")||customElements.define("dropdown-menu",uy);customElements.get("dropdown-group")||customElements.define("dropdown-group",f2);customElements.get("dropdown-label")||customElements.define("dropdown-label",g2);customElements.get("dropdown-divider")||customElements.define("dropdown-divider",m2);customElements.get("dropdown-item")||customElements.define("dropdown-item",yy);class v2 extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}var Is,wn,Kc,Aa,Cs,Jc;class wy extends HTMLElement{constructor(){super();w(this,wn);w(this,Is);w(this,Aa,t=>{t.target===t.currentTarget&&m(this,wn,Kc).call(this)});w(this,Cs,t=>{this.open&&t.key==="Escape"&&m(this,wn,Kc).call(this)});x(this,Is,this.attachShadow({mode:"open"}))}connectedCallback(){document.addEventListener("keydown",l(this,Cs)),m(this,wn,Jc).call(this)}disconnectedCallback(){document.removeEventListener("keydown",l(this,Cs))}attributeChangedCallback(){m(this,wn,Jc).call(this)}get open(){return this.hasAttribute("open")}}Is=new WeakMap,wn=new WeakSet,Kc=function(){this.dispatchEvent(new v2)},Aa=new WeakMap,Cs=new WeakMap,Jc=function(){Re(U`
95
+ `,l(this,Qn)),queueMicrotask(()=>m(this,M,Kc).call(this))},b(dy,"observedAttributes",["title","placement","open"]);class g2 extends HTMLElement{}class m2 extends HTMLElement{}class v2 extends HTMLElement{}var mr,Qc,Sy,$s,Ts;class wy extends HTMLElement{constructor(){super(...arguments);w(this,mr);w(this,$s,()=>{this.action||m(this,mr,Sy).call(this)});w(this,Ts,t=>{t.key!=="Enter"&&t.key!==" "||(t.preventDefault(),this.click())})}connectedCallback(){this.hasAttribute("role")||this.setAttribute("role","option"),this.hasAttribute("tabindex")||(this.tabIndex=0),this.addEventListener("click",l(this,$s)),this.addEventListener("keydown",l(this,Ts)),m(this,mr,Qc).call(this)}disconnectedCallback(){this.removeEventListener("click",l(this,$s)),this.removeEventListener("keydown",l(this,Ts))}attributeChangedCallback(){m(this,mr,Qc).call(this)}get value(){return this.getAttribute("value")??""}get selected(){return this.hasAttribute("selected")}get action(){return this.hasAttribute("action")}}mr=new WeakSet,Qc=function(){if(this.action){this.setAttribute("role","button"),this.removeAttribute("aria-selected");return}this.setAttribute("role","option"),this.setAttribute("aria-selected",this.selected?"true":"false")},Sy=function(){this.dispatchEvent(new hy(this.value))},$s=new WeakMap,Ts=new WeakMap,b(wy,"observedAttributes",["action","selected","value"]);customElements.get("dropdown-menu")||customElements.define("dropdown-menu",dy);customElements.get("dropdown-group")||customElements.define("dropdown-group",g2);customElements.get("dropdown-label")||customElements.define("dropdown-label",m2);customElements.get("dropdown-divider")||customElements.define("dropdown-divider",v2);customElements.get("dropdown-item")||customElements.define("dropdown-item",wy);class y2 extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}var Is,wn,eu,Aa,Cs,tu;class _y extends HTMLElement{constructor(){super();w(this,wn);w(this,Is);w(this,Aa,t=>{t.target===t.currentTarget&&m(this,wn,eu).call(this)});w(this,Cs,t=>{this.open&&t.key==="Escape"&&m(this,wn,eu).call(this)});x(this,Is,this.attachShadow({mode:"open"}))}connectedCallback(){document.addEventListener("keydown",l(this,Cs)),m(this,wn,tu).call(this)}disconnectedCallback(){document.removeEventListener("keydown",l(this,Cs))}attributeChangedCallback(){m(this,wn,tu).call(this)}get open(){return this.hasAttribute("open")}}Is=new WeakMap,wn=new WeakSet,eu=function(){this.dispatchEvent(new y2)},Aa=new WeakMap,Cs=new WeakMap,tu=function(){Re(U`
96
96
  ${this.open?U`
97
97
  <div class="backdrop" part="backdrop" @click=${l(this,Aa)}>
98
98
  <slot></slot>
99
99
  </div>
100
100
  `:null}
101
- `,l(this,Is))},b(wy,"observedAttributes",["open"]);customElements.get("modal-overlay")||customElements.define("modal-overlay",wy);class y2 extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}class b2 extends HTMLElement{}var Ps,Rs,Qc;class Sy extends HTMLElement{constructor(){super();w(this,Rs);w(this,Ps);x(this,Ps,this.attachShadow({mode:"open"}))}connectedCallback(){m(this,Rs,Qc).call(this)}attributeChangedCallback(){m(this,Rs,Qc).call(this)}get closable(){return this.hasAttribute("closable")}}Ps=new WeakMap,Rs=new WeakSet,Qc=function(){const t=this.querySelector("panel-page");Re(U`
101
+ `,l(this,Is))},b(_y,"observedAttributes",["open"]);customElements.get("modal-overlay")||customElements.define("modal-overlay",_y);class b2 extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}class w2 extends HTMLElement{}var Ps,Rs,nu;class ky extends HTMLElement{constructor(){super();w(this,Rs);w(this,Ps);x(this,Ps,this.attachShadow({mode:"open"}))}connectedCallback(){m(this,Rs,nu).call(this)}attributeChangedCallback(){m(this,Rs,nu).call(this)}get closable(){return this.hasAttribute("closable")}}Ps=new WeakMap,Rs=new WeakSet,nu=function(){const t=this.querySelector("panel-page");Re(U`
102
102
  <section class="panel" part="panel">
103
103
  <header class="title-bar" part="header">
104
104
  <h2 class="title" part="title">${(t==null?void 0:t.getAttribute("title"))??""}</h2>
@@ -108,15 +108,15 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
108
108
  class="title-button"
109
109
  part="button close-button"
110
110
  aria-label="Close"
111
- @click=${()=>this.dispatchEvent(new y2)}
111
+ @click=${()=>this.dispatchEvent(new b2)}
112
112
  >
113
- <span class="close-icon" part="icon close-icon">${ay({size:16})}</span>
113
+ <span class="close-icon" part="icon close-icon">${cy({size:16})}</span>
114
114
  </button>
115
115
  `:null}
116
116
  </header>
117
117
  <slot></slot>
118
118
  </section>
119
- `,l(this,Ps))},b(Sy,"observedAttributes",["closable"]);customElements.get("panel-view")||customElements.define("panel-view",Sy);customElements.get("panel-page")||customElements.define("panel-page",b2);class w2 extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}const pf='a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])',rc=4;var Be,Yt,tr,rt,Ds,Jr,re,ky,Ey,eu,Ls,Os,nr,xy,tu,Ay,$y,Jo,Qo;class _y extends HTMLElement{constructor(){super();w(this,re);w(this,Be,!1);w(this,Yt,null);w(this,tr);w(this,rt,null);w(this,Ds,"bottom-start");w(this,Jr,!1);w(this,Ls,t=>{l(this,Be)&&(l(this,Jr)||t.composedPath().includes(this)||(this.open=!1))});w(this,Os,t=>{if(l(this,Be)){if(t.key==="Escape"){t.preventDefault(),this.open=!1;return}t.key==="Tab"&&m(this,re,xy).call(this,t)}});w(this,nr,()=>{l(this,Be)&&m(this,re,Jo).call(this)});x(this,tr,this.attachShadow({mode:"open"})),iy(l(this,tr))}connectedCallback(){this.hasAttribute("tone")||this.setAttribute("tone","light"),m(this,re,Qo).call(this)}disconnectedCallback(){m(this,re,eu).call(this)}attributeChangedCallback(t){t==="open"&&m(this,re,ky).call(this,this.hasAttribute("open"))}get open(){return l(this,Be)}set open(t){this.toggleAttribute("open",t)}get anchor(){return l(this,Yt)}set anchor(t){l(this,Yt)!==t&&(x(this,Yt,t),l(this,Be)&&m(this,re,Jo).call(this))}}Be=new WeakMap,Yt=new WeakMap,tr=new WeakMap,rt=new WeakMap,Ds=new WeakMap,Jr=new WeakMap,re=new WeakSet,ky=function(t){var r;l(this,Be)!==t&&(x(this,Be,t),t?(x(this,Jr,!0),setTimeout(()=>{x(this,Jr,!1)},0),m(this,re,Qo).call(this),m(this,re,Ey).call(this),queueMicrotask(()=>{l(this,Be)&&(m(this,re,Jo).call(this),m(this,re,$y).call(this))})):(m(this,re,eu).call(this),m(this,re,Qo).call(this),(r=l(this,Yt))==null||r.focus(),this.dispatchEvent(new w2)))},Ey=function(){document.addEventListener("click",l(this,Ls)),document.addEventListener("keydown",l(this,Os),!0),window.addEventListener("resize",l(this,nr)),window.addEventListener("scroll",l(this,nr),!0)},eu=function(){document.removeEventListener("click",l(this,Ls)),document.removeEventListener("keydown",l(this,Os),!0),window.removeEventListener("resize",l(this,nr)),window.removeEventListener("scroll",l(this,nr),!0)},Ls=new WeakMap,Os=new WeakMap,nr=new WeakMap,xy=function(t){const r=m(this,re,tu).call(this);if(r.length===0){t.preventDefault();return}const i=r[0],s=r[r.length-1],o=m(this,re,Ay).call(this),a=o instanceof HTMLElement&&r.includes(o);t.shiftKey?(!a||o===i)&&(t.preventDefault(),s.focus()):(!a||o===s)&&(t.preventDefault(),i.focus())},tu=function(){if(!l(this,rt))return[];const t=l(this,rt).querySelector("slot");if(!(t instanceof HTMLSlotElement))return[];const r=[];for(const i of t.assignedElements({flatten:!0}))if(i instanceof HTMLElement){i.matches(pf)&&r.push(i);for(const s of i.querySelectorAll(pf))r.push(s)}return r},Ay=function(){var r;let t=document.activeElement;for(;t&&((r=t.shadowRoot)!=null&&r.activeElement);)t=t.shadowRoot.activeElement;return t},$y=function(){var r;const t=m(this,re,tu).call(this);t.length>0?t[0].focus():(r=l(this,rt))==null||r.focus()},Jo=function(){if(!l(this,Be)||!l(this,Yt)||!l(this,rt))return;const t=l(this,Yt).getBoundingClientRect(),r=l(this,rt).getBoundingClientRect(),s=window.innerHeight-t.bottom,o=r.height+rc,a=s<o&&t.top>o?"top-start":"bottom-start";x(this,Ds,a);const c=a==="bottom-start"?t.bottom+rc:t.top-r.height-rc,u=t.left;l(this,rt).style.top=`${c}px`,l(this,rt).style.left=`${u}px`,l(this,rt).setAttribute("data-placement",a)},Qo=function(){this.toggleAttribute("open",l(this,Be)),Re(l(this,Be)?U`<div
119
+ `,l(this,Ps))},b(ky,"observedAttributes",["closable"]);customElements.get("panel-view")||customElements.define("panel-view",ky);customElements.get("panel-page")||customElements.define("panel-page",w2);class S2 extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}const gf='a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])',oc=4;var Ge,Yt,tr,rt,Ds,Jr,re,xy,Ay,ru,Ls,Os,nr,$y,iu,Ty,Iy,Jo,Qo;class Ey extends HTMLElement{constructor(){super();w(this,re);w(this,Ge,!1);w(this,Yt,null);w(this,tr);w(this,rt,null);w(this,Ds,"bottom-start");w(this,Jr,!1);w(this,Ls,t=>{l(this,Ge)&&(l(this,Jr)||t.composedPath().includes(this)||(this.open=!1))});w(this,Os,t=>{if(l(this,Ge)){if(t.key==="Escape"){t.preventDefault(),this.open=!1;return}t.key==="Tab"&&m(this,re,$y).call(this,t)}});w(this,nr,()=>{l(this,Ge)&&m(this,re,Jo).call(this)});x(this,tr,this.attachShadow({mode:"open"})),oy(l(this,tr))}connectedCallback(){this.hasAttribute("tone")||this.setAttribute("tone","light"),m(this,re,Qo).call(this)}disconnectedCallback(){m(this,re,ru).call(this)}attributeChangedCallback(t){t==="open"&&m(this,re,xy).call(this,this.hasAttribute("open"))}get open(){return l(this,Ge)}set open(t){this.toggleAttribute("open",t)}get anchor(){return l(this,Yt)}set anchor(t){l(this,Yt)!==t&&(x(this,Yt,t),l(this,Ge)&&m(this,re,Jo).call(this))}}Ge=new WeakMap,Yt=new WeakMap,tr=new WeakMap,rt=new WeakMap,Ds=new WeakMap,Jr=new WeakMap,re=new WeakSet,xy=function(t){var r;l(this,Ge)!==t&&(x(this,Ge,t),t?(x(this,Jr,!0),setTimeout(()=>{x(this,Jr,!1)},0),m(this,re,Qo).call(this),m(this,re,Ay).call(this),queueMicrotask(()=>{l(this,Ge)&&(m(this,re,Jo).call(this),m(this,re,Iy).call(this))})):(m(this,re,ru).call(this),m(this,re,Qo).call(this),(r=l(this,Yt))==null||r.focus(),this.dispatchEvent(new S2)))},Ay=function(){document.addEventListener("click",l(this,Ls)),document.addEventListener("keydown",l(this,Os),!0),window.addEventListener("resize",l(this,nr)),window.addEventListener("scroll",l(this,nr),!0)},ru=function(){document.removeEventListener("click",l(this,Ls)),document.removeEventListener("keydown",l(this,Os),!0),window.removeEventListener("resize",l(this,nr)),window.removeEventListener("scroll",l(this,nr),!0)},Ls=new WeakMap,Os=new WeakMap,nr=new WeakMap,$y=function(t){const r=m(this,re,iu).call(this);if(r.length===0){t.preventDefault();return}const i=r[0],s=r[r.length-1],o=m(this,re,Ty).call(this),a=o instanceof HTMLElement&&r.includes(o);t.shiftKey?(!a||o===i)&&(t.preventDefault(),s.focus()):(!a||o===s)&&(t.preventDefault(),i.focus())},iu=function(){if(!l(this,rt))return[];const t=l(this,rt).querySelector("slot");if(!(t instanceof HTMLSlotElement))return[];const r=[];for(const i of t.assignedElements({flatten:!0}))if(i instanceof HTMLElement){i.matches(gf)&&r.push(i);for(const s of i.querySelectorAll(gf))r.push(s)}return r},Ty=function(){var r;let t=document.activeElement;for(;t&&((r=t.shadowRoot)!=null&&r.activeElement);)t=t.shadowRoot.activeElement;return t},Iy=function(){var r;const t=m(this,re,iu).call(this);t.length>0?t[0].focus():(r=l(this,rt))==null||r.focus()},Jo=function(){if(!l(this,Ge)||!l(this,Yt)||!l(this,rt))return;const t=l(this,Yt).getBoundingClientRect(),r=l(this,rt).getBoundingClientRect(),s=window.innerHeight-t.bottom,o=r.height+oc,a=s<o&&t.top>o?"top-start":"bottom-start";x(this,Ds,a);const c=a==="bottom-start"?t.bottom+oc:t.top-r.height-oc,u=t.left;l(this,rt).style.top=`${c}px`,l(this,rt).style.left=`${u}px`,l(this,rt).setAttribute("data-placement",a)},Qo=function(){this.toggleAttribute("open",l(this,Ge)),Re(l(this,Ge)?U`<div
120
120
  class="panel"
121
121
  part="panel"
122
122
  data-placement=${l(this,Ds)}
@@ -126,8 +126,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
126
126
  level="1"
127
127
  >
128
128
  <slot></slot>
129
- </div>`:se,l(this,tr)),x(this,rt,l(this,tr).querySelector(".panel"))},b(_y,"observedAttributes",["open"]);customElements.get("ui-popover")||customElements.define("ui-popover",_y);function sl(n){return typeof n=="object"&&n!==null}function S2(n){return!sl(n)||n.type!=="wheel"||typeof n.deltaX!="number"||typeof n.deltaY!="number"||typeof n.shiftKey!="boolean"?!1:!("id"in n)}function _2(n){return!sl(n)||n.type!=="swipe-move"||typeof n.deltaX!="number"?!1:!("id"in n)}function k2(n){return!sl(n)||n.type!=="swipe-end"||typeof n.velocityX!="number"?!1:!("id"in n)}function Ty(n){return!sl(n)||n.type!=="open-artifact"||typeof n.artifactID!="string"?!1:!("id"in n)}function E2(n=window){if(n.parent===n)return;let e=0,t=0;n.document.documentElement&&(n.document.documentElement.style.touchAction="pan-y"),n.addEventListener("wheel",u=>{const h=u;e=h.clientX,t=h.clientY,n.parent.postMessage({type:"wheel",deltaX:h.deltaX,deltaY:h.deltaY,shiftKey:h.shiftKey},"*"),h.preventDefault()},{passive:!1});const r=8,i=100,s=1e3,o=new Map;n.addEventListener("pointerdown",u=>{const h=u;h.pointerType==="touch"&&o.set(h.pointerId,{startX:h.clientX,startY:h.clientY,lastX:h.clientX,offset:0,active:!1,discarded:!1,samples:[{time:h.timeStamp,offset:0}]})},{passive:!0}),n.addEventListener("pointermove",u=>{const h=u,p=o.get(h.pointerId);if(!p||p.discarded)return;if(!p.active){const _=h.clientX-p.startX,C=h.clientY-p.startY,N=Math.abs(_),P=Math.abs(C);if(N<r&&P<r)return;if(P>=N){p.discarded=!0;return}p.active=!0}const v=h.clientX-p.lastX;p.lastX=h.clientX,p.offset+=v,p.samples.push({time:h.timeStamp,offset:p.offset});const g=h.timeStamp-i;let E=0;for(let _=0;_<p.samples.length;_+=1){if(p.samples[_].time>=g){E=_;break}E=_+1}if(E>0){const _=Math.max(0,E-1);p.samples.splice(0,_)}n.parent.postMessage({type:"swipe-move",deltaX:v},"*"),h.preventDefault()},{passive:!1}),n.addEventListener("pointerup",u=>{const h=u,p=o.get(h.pointerId);if(!p||(o.delete(h.pointerId),!p.active))return;let v=0;if(p.samples.length>=2){const g=p.samples[0],E=p.samples[p.samples.length-1],_=E.time-g.time;_>0&&(v=(E.offset-g.offset)/_*s)}n.parent.postMessage({type:"swipe-end",velocityX:v},"*")}),n.addEventListener("pointercancel",u=>{const h=u,p=o.get(h.pointerId);p&&(o.delete(h.pointerId),p.active&&n.parent.postMessage({type:"swipe-end",velocityX:0},"*"))}),n.addEventListener("message",u=>{var _,C;const h=u.data;if(h===null||typeof h!="object"||h.type!=="scroll")return;const p=h,v=typeof p.deltaX=="number"?p.deltaX:0,g=typeof p.deltaY=="number"?p.deltaY:0;let E=((C=(_=n.document).elementFromPoint)==null?void 0:C.call(_,e,t))??null;for(;E!==null;){const N=n.getComputedStyle(E);if(g!==0){const P=(N.overflowY==="auto"||N.overflowY==="scroll")&&E.scrollHeight>E.clientHeight,W=g>0?E.scrollTop+E.clientHeight<E.scrollHeight:E.scrollTop>0;if(P&&W){E.scrollBy(v,g);return}}if(v!==0){const P=(N.overflowX==="auto"||N.overflowX==="scroll")&&E.scrollWidth>E.clientWidth,W=v>0?E.scrollLeft+E.clientWidth<E.scrollWidth:E.scrollLeft>0;if(P&&W){E.scrollBy(v,g);return}}E=E.parentElement}n.scrollBy(v,g)});function a(u){if(typeof u!="string")return!1;let h;try{h=new URL(u)}catch{return!1}if(h.protocol!=="artifact:")return!1;const p=h.hostname||h.pathname.replace(/^\/+/,"");return p===""?!1:(n.parent.postMessage({type:"open-artifact",artifactID:p},"*"),!0)}n.document.addEventListener("click",u=>{const h=u,p=typeof h.composedPath=="function"?h.composedPath():[];let v=null;for(const _ of p)if(_ instanceof HTMLAnchorElement||_&&_.tagName==="A"){v=_;break}if(v===null)return;const g=v.getAttribute("href");if(g===null)return;let E;try{E=new URL(g,n.document.baseURI).toString()}catch{return}a(E)&&u.preventDefault()},!0);const c=n.navigation;c&&c.addEventListener("navigate",u=>{var p;a((p=u.destination)==null?void 0:p.url)&&u.preventDefault()})}function x2(){return`(${E2.toString()})(window);`}const A2=tt(),$2=tt(),T2="No handler registered for update-content",I2="handleUpdateContent: handler already registered";function C2(n){return n instanceof Error&&typeof n.message=="string"?n.message:String(n)}const P2=ki(wt);var Qr,ei,ti,rr,ir,Ms,Ie,nu,Iy,Cy,Yi,ru,Vf;let R2=(Vf=class extends P2{constructor(t){super();w(this,Ie);w(this,Qr);w(this,ei);w(this,ti);w(this,rr,null);w(this,ir,null);w(this,Ms,!1);x(this,Qr,t);const r=t.ownerDocument.defaultView;if(!r)throw new Error("ArtifactView: iframe has no owner window");x(this,ei,r),x(this,ti,i=>m(this,Ie,Iy).call(this,i)),l(this,ei).addEventListener("message",l(this,ti))}get content(){return l(this,ir)}set content(t){m(this,Ie,ru).call(this),x(this,ir,t),l(this,Ms)&&m(this,Ie,nu).call(this,t)}handleUpdateContent(t){if(m(this,Ie,ru).call(this),l(this,rr)!==null)throw new Error(I2);x(this,rr,t)}dispose(){l(this,ei).removeEventListener("message",l(this,ti)),x(this,rr,null)}},Qr=new WeakMap,ei=new WeakMap,ti=new WeakMap,rr=new WeakMap,ir=new WeakMap,Ms=new WeakMap,Ie=new WeakSet,nu=function(t){const r={type:"content-updated",content:t};m(this,Ie,Yi).call(this,r)},Iy=function(t){if(this.disposed||t.source!==l(this,Qr).contentWindow)return;const r=t.data;if(TI(r)){x(this,Ms,!0),this.dispatchEvent(new A2("ready")),l(this,ir)!==null&&m(this,Ie,nu).call(this,l(this,ir));return}if(II(r)){m(this,Ie,Cy).call(this,r);return}if(Ty(r)){this.dispatchEvent(new $2("open-artifact",{artifactID:r.artifactID}));return}},Cy=async function(t){const r=l(this,rr);if(r===null){m(this,Ie,Yi).call(this,{type:"response",id:t.id,error:{message:T2}});return}try{await r(t.content)}catch(i){if(this.disposed)return;m(this,Ie,Yi).call(this,{type:"response",id:t.id,error:{message:C2(i)}});return}this.disposed||m(this,Ie,Yi).call(this,{type:"response",id:t.id,result:{}})},Yi=function(t){const r=l(this,Qr).contentWindow;r&&r.postMessage(t,"*")},ru=function(){if(this.disposed)throw new Error("ArtifactView is disposed")},Vf);async function D2(n){const e=await fetch(n);if(!e.ok)throw new Error(`Failed to fetch artifact content: ${e.status}`);const t=await e.text(),r=new DOMParser().parseFromString(t,"text/html"),i=r.createElement("base");i.href=new URL(n,window.location.href).href,r.head.insertBefore(i,r.head.firstChild);const s=r.createElement("script");s.textContent=x2(),r.head.appendChild(s);const o=new Blob([`<!DOCTYPE html>
130
- ${r.documentElement.outerHTML}`],{type:"text/html"});return URL.createObjectURL(o)}const ff="television-artifact-bridge",Py=tt(),L2=tt();class O2 extends HTMLElement{constructor(){super(...arguments);b(this,"_artifact",null);b(this,"_viewURL",null);b(this,"_contentURL",null);b(this,"_screen",null);b(this,"_subscribedScreen",null);b(this,"_activeView",null);b(this,"_contentState",{kind:"idle"});b(this,"_fetchSequence",0);b(this,"_blobSequence",0);b(this,"_mountedViewURL",null);b(this,"_directRender",!1);b(this,"_blobURL",null);b(this,"_subscribedWebview",null);b(this,"_directRenderMessageListener",null);b(this,"handleScreenContentChanged",t=>{!this._artifact||t.artifactID!==this._artifact.id||this._activeView!==null&&this.refetchContent()});b(this,"handleOpenArtifact",t=>{this.requestFocus(t.artifactID)});b(this,"handleIframeMessage",t=>{const r=this.querySelector("iframe.artifact-frame");!r||r.contentWindow!==t.source||S2(t.data)&&this.dispatchArtifactWheel({deltaX:t.data.deltaX,deltaY:t.data.deltaY,shiftKey:t.data.shiftKey},i=>{var o;const s={type:"scroll",deltaX:0,deltaY:i};(o=r.contentWindow)==null||o.postMessage(s,this.iframeTargetOrigin(r))})});b(this,"handleWebviewIpcMessage",t=>{var o;const r=t.detail??t;if(!r||r.channel!==ff)return;const i=(o=r.args)==null?void 0:o[0];if(!i||i.type!=="wheel")return;const s=this._subscribedWebview;s&&this.dispatchArtifactWheel({deltaX:i.deltaX??0,deltaY:i.deltaY??0,shiftKey:i.shiftKey??!1},a=>{var c;(c=s.send)==null||c.call(s,ff,{type:"scroll",deltaX:0,deltaY:a})})})}set artifact(t){const r=this._artifact;this._artifact=t,this.render(),r!==null&&r!==t&&this.syncView()}get artifact(){return this._artifact}set viewURL(t){this._viewURL!==t&&(this._viewURL=t,this.syncView())}get viewURL(){return this._viewURL}set contentURL(t){this._contentURL!==t&&(this._contentURL=t,this.syncView())}get contentURL(){return this._contentURL}set screen(t){this._screen!==t&&(this._screen=t,this.syncScreenSubscription())}get screen(){return this._screen}set dragging(t){t?this.setAttribute("dragging","true"):this.removeAttribute("dragging")}get dragging(){return this.getAttribute("dragging")==="true"}get activeView(){return this._activeView}connectedCallback(){this.setAttribute("level","2"),this.render(),this.syncView(),this.syncScreenSubscription(),window.addEventListener("message",this.handleIframeMessage)}disconnectedCallback(){this.teardownView(),this.unsubscribeFromScreen(),window.removeEventListener("message",this.handleIframeMessage),this.unsubscribeFromWebview()}handleClose(){this._artifact&&this.dispatchEvent(new Py("close-artifact",{artifactID:this._artifact.id,bubbles:!0,composed:!0}))}syncView(){var t,r;if(this.isConnected){if((t=this._artifact)!=null&&t.externalURL){this.teardownView(),this._contentState={kind:"ready"},this.render();return}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 i=this.querySelector("iframe.artifact-frame");if(!i){this._contentState={kind:"error"},this.render();return}this._activeView=new R2(i),this._activeView.handleUpdateContent(async s=>{await this.saveContent(s)}),this._activeView.addEventListener("open-artifact",this.handleOpenArtifact),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(),this.installDirectRenderMessageListener(),((r=this._artifact)==null?void 0:r.status)==="committed"&&this.loadBlobFrame(this._contentURL);return}this.teardownView(),this._contentState={kind:"idle"},this.render()}}async saveContent(t){const r=this._screen,i=this._artifact;if(!r||!i)throw new Error("artifact-view: cannot save without a screen and artifact");await r.server.client.artifacts.putContent({artifactID:i.id,content:t})}syncScreenSubscription(){if(!this.isConnected){this.unsubscribeFromScreen();return}this._subscribedScreen!==this._screen&&(this.unsubscribeFromScreen(),this._screen!==null&&(this._screen.addEventListener("artifact-content-changed",this.handleScreenContentChanged),this._subscribedScreen=this._screen))}unsubscribeFromScreen(){this._subscribedScreen!==null&&(this._subscribedScreen.removeEventListener("artifact-content-changed",this.handleScreenContentChanged),this._subscribedScreen=null)}startContentFetch(){this._fetchSequence+=1;const t=this._fetchSequence,r=this._contentURL,i=this._activeView;if(!i||r===null){this._contentState={kind:"error"},this.render();return}this._contentState={kind:"loading"},(async()=>{try{const s=await fetch(r);if(t!==this._fetchSequence)return;if(!s.ok){this._contentState={kind:"error"},this.teardownView(),this.render();return}const o=await s.text();if(t!==this._fetchSequence||this._activeView!==i)return;this._activeView.content=o,this._contentState={kind:"ready"}}catch{if(t!==this._fetchSequence)return;this._contentState={kind:"error"},this.teardownView(),this.render()}})()}refetchContent(){this._fetchSequence+=1;const t=this._fetchSequence,r=this._contentURL,i=this._activeView;!i||r===null||(async()=>{try{const s=await fetch(r);if(t!==this._fetchSequence||!s.ok)return;const o=await s.text();if(t!==this._fetchSequence||this._activeView!==i)return;this._activeView.content=o}catch{}})()}loadBlobFrame(t){this._blobSequence+=1;const r=this._blobSequence;(async()=>{try{const i=await D2(t);if(r!==this._blobSequence){URL.revokeObjectURL(i);return}this._blobURL=i,this.render();const s=this.querySelector("iframe.artifact-frame");s&&(s.src=i)}catch{if(r!==this._blobSequence)return;this._contentState={kind:"error"},this.teardownView(),this.render()}})()}teardownView(){this._activeView!==null&&(this._activeView.removeEventListener("open-artifact",this.handleOpenArtifact),this._activeView.dispose(),this._activeView=null),this.removeDirectRenderMessageListener(),this._blobURL!==null&&(URL.revokeObjectURL(this._blobURL),this._blobURL=null),this._mountedViewURL=null,this._directRender=!1,this._fetchSequence+=1,this._blobSequence+=1}installDirectRenderMessageListener(){if(this._directRenderMessageListener!==null)return;const t=r=>{const i=this.querySelector("iframe.artifact-frame");i&&r.source===i.contentWindow&&Ty(r.data)&&this.requestFocus(r.data.artifactID)};this._directRenderMessageListener=t,window.addEventListener("message",t)}removeDirectRenderMessageListener(){this._directRenderMessageListener!==null&&(window.removeEventListener("message",this._directRenderMessageListener),this._directRenderMessageListener=null)}requestFocus(t){const r=this._screen;r&&r.server.client.viewer.focus({artifactID:t}).catch(i=>{console.warn("artifact-view: viewer.focus failed",i)})}contentTemplate(){var t;if((t=this._artifact)!=null&&t.externalURL){const r=this._artifact.externalURL;return oh()?U`
129
+ </div>`:se,l(this,tr)),x(this,rt,l(this,tr).querySelector(".panel"))},b(Ey,"observedAttributes",["open"]);customElements.get("ui-popover")||customElements.define("ui-popover",Ey);function sl(n){return typeof n=="object"&&n!==null}function _2(n){return!sl(n)||n.type!=="wheel"||typeof n.deltaX!="number"||typeof n.deltaY!="number"||typeof n.shiftKey!="boolean"?!1:!("id"in n)}function k2(n){return!sl(n)||n.type!=="swipe-move"||typeof n.deltaX!="number"?!1:!("id"in n)}function E2(n){return!sl(n)||n.type!=="swipe-end"||typeof n.velocityX!="number"?!1:!("id"in n)}function Cy(n){return!sl(n)||n.type!=="open-artifact"||typeof n.artifactID!="string"?!1:!("id"in n)}function x2(n=window){if(n.parent===n)return;let e=0,t=0;n.document.documentElement&&(n.document.documentElement.style.touchAction="pan-y"),n.addEventListener("wheel",u=>{const h=u;e=h.clientX,t=h.clientY,n.parent.postMessage({type:"wheel",deltaX:h.deltaX,deltaY:h.deltaY,shiftKey:h.shiftKey},"*"),h.preventDefault()},{passive:!1});const r=8,i=100,s=1e3,o=new Map;n.addEventListener("pointerdown",u=>{const h=u;h.pointerType==="touch"&&o.set(h.pointerId,{startX:h.clientX,startY:h.clientY,lastX:h.clientX,offset:0,active:!1,discarded:!1,samples:[{time:h.timeStamp,offset:0}]})},{passive:!0}),n.addEventListener("pointermove",u=>{const h=u,p=o.get(h.pointerId);if(!p||p.discarded)return;if(!p.active){const _=h.clientX-p.startX,C=h.clientY-p.startY,N=Math.abs(_),P=Math.abs(C);if(N<r&&P<r)return;if(P>=N){p.discarded=!0;return}p.active=!0}const v=h.clientX-p.lastX;p.lastX=h.clientX,p.offset+=v,p.samples.push({time:h.timeStamp,offset:p.offset});const g=h.timeStamp-i;let E=0;for(let _=0;_<p.samples.length;_+=1){if(p.samples[_].time>=g){E=_;break}E=_+1}if(E>0){const _=Math.max(0,E-1);p.samples.splice(0,_)}n.parent.postMessage({type:"swipe-move",deltaX:v},"*"),h.preventDefault()},{passive:!1}),n.addEventListener("pointerup",u=>{const h=u,p=o.get(h.pointerId);if(!p||(o.delete(h.pointerId),!p.active))return;let v=0;if(p.samples.length>=2){const g=p.samples[0],E=p.samples[p.samples.length-1],_=E.time-g.time;_>0&&(v=(E.offset-g.offset)/_*s)}n.parent.postMessage({type:"swipe-end",velocityX:v},"*")}),n.addEventListener("pointercancel",u=>{const h=u,p=o.get(h.pointerId);p&&(o.delete(h.pointerId),p.active&&n.parent.postMessage({type:"swipe-end",velocityX:0},"*"))}),n.addEventListener("message",u=>{var _,C;const h=u.data;if(h===null||typeof h!="object"||h.type!=="scroll")return;const p=h,v=typeof p.deltaX=="number"?p.deltaX:0,g=typeof p.deltaY=="number"?p.deltaY:0;let E=((C=(_=n.document).elementFromPoint)==null?void 0:C.call(_,e,t))??null;for(;E!==null;){const N=n.getComputedStyle(E);if(g!==0){const P=(N.overflowY==="auto"||N.overflowY==="scroll")&&E.scrollHeight>E.clientHeight,W=g>0?E.scrollTop+E.clientHeight<E.scrollHeight:E.scrollTop>0;if(P&&W){E.scrollBy(v,g);return}}if(v!==0){const P=(N.overflowX==="auto"||N.overflowX==="scroll")&&E.scrollWidth>E.clientWidth,W=v>0?E.scrollLeft+E.clientWidth<E.scrollWidth:E.scrollLeft>0;if(P&&W){E.scrollBy(v,g);return}}E=E.parentElement}n.scrollBy(v,g)});function a(u){if(typeof u!="string")return!1;let h;try{h=new URL(u)}catch{return!1}if(h.protocol!=="artifact:")return!1;const p=h.hostname||h.pathname.replace(/^\/+/,"");return p===""?!1:(n.parent.postMessage({type:"open-artifact",artifactID:p},"*"),!0)}n.document.addEventListener("click",u=>{const h=u,p=typeof h.composedPath=="function"?h.composedPath():[];let v=null;for(const _ of p)if(_ instanceof HTMLAnchorElement||_&&_.tagName==="A"){v=_;break}if(v===null)return;const g=v.getAttribute("href");if(g===null)return;let E;try{E=new URL(g,n.document.baseURI).toString()}catch{return}a(E)&&u.preventDefault()},!0);const c=n.navigation;c&&c.addEventListener("navigate",u=>{var p;a((p=u.destination)==null?void 0:p.url)&&u.preventDefault()})}function A2(){return`(${x2.toString()})(window);`}const $2=tt(),T2=tt(),I2="No handler registered for update-content",C2="handleUpdateContent: handler already registered";function P2(n){return n instanceof Error&&typeof n.message=="string"?n.message:String(n)}const R2=ki(wt);var Qr,ei,ti,rr,ir,Ms,Ie,su,Py,Ry,Yi,ou,jf;let D2=(jf=class extends R2{constructor(t){super();w(this,Ie);w(this,Qr);w(this,ei);w(this,ti);w(this,rr,null);w(this,ir,null);w(this,Ms,!1);x(this,Qr,t);const r=t.ownerDocument.defaultView;if(!r)throw new Error("ArtifactView: iframe has no owner window");x(this,ei,r),x(this,ti,i=>m(this,Ie,Py).call(this,i)),l(this,ei).addEventListener("message",l(this,ti))}get content(){return l(this,ir)}set content(t){m(this,Ie,ou).call(this),x(this,ir,t),l(this,Ms)&&m(this,Ie,su).call(this,t)}handleUpdateContent(t){if(m(this,Ie,ou).call(this),l(this,rr)!==null)throw new Error(C2);x(this,rr,t)}dispose(){l(this,ei).removeEventListener("message",l(this,ti)),x(this,rr,null)}},Qr=new WeakMap,ei=new WeakMap,ti=new WeakMap,rr=new WeakMap,ir=new WeakMap,Ms=new WeakMap,Ie=new WeakSet,su=function(t){const r={type:"content-updated",content:t};m(this,Ie,Yi).call(this,r)},Py=function(t){if(this.disposed||t.source!==l(this,Qr).contentWindow)return;const r=t.data;if(II(r)){x(this,Ms,!0),this.dispatchEvent(new $2("ready")),l(this,ir)!==null&&m(this,Ie,su).call(this,l(this,ir));return}if(CI(r)){m(this,Ie,Ry).call(this,r);return}if(Cy(r)){this.dispatchEvent(new T2("open-artifact",{artifactID:r.artifactID}));return}},Ry=async function(t){const r=l(this,rr);if(r===null){m(this,Ie,Yi).call(this,{type:"response",id:t.id,error:{message:I2}});return}try{await r(t.content)}catch(i){if(this.disposed)return;m(this,Ie,Yi).call(this,{type:"response",id:t.id,error:{message:P2(i)}});return}this.disposed||m(this,Ie,Yi).call(this,{type:"response",id:t.id,result:{}})},Yi=function(t){const r=l(this,Qr).contentWindow;r&&r.postMessage(t,"*")},ou=function(){if(this.disposed)throw new Error("ArtifactView is disposed")},jf);async function L2(n){const e=await fetch(n);if(!e.ok)throw new Error(`Failed to fetch artifact content: ${e.status}`);const t=await e.text(),r=new DOMParser().parseFromString(t,"text/html"),i=r.createElement("base");i.href=new URL(n,window.location.href).href,r.head.insertBefore(i,r.head.firstChild);const s=r.createElement("script");s.textContent=A2(),r.head.appendChild(s);const o=new Blob([`<!DOCTYPE html>
130
+ ${r.documentElement.outerHTML}`],{type:"text/html"});return URL.createObjectURL(o)}const mf="television-artifact-bridge",Dy=tt(),O2=tt();class M2 extends HTMLElement{constructor(){super(...arguments);b(this,"_artifact",null);b(this,"_viewURL",null);b(this,"_contentURL",null);b(this,"_screen",null);b(this,"_subscribedScreen",null);b(this,"_activeView",null);b(this,"_contentState",{kind:"idle"});b(this,"_fetchSequence",0);b(this,"_blobSequence",0);b(this,"_mountedViewURL",null);b(this,"_directRender",!1);b(this,"_blobURL",null);b(this,"_subscribedWebview",null);b(this,"_directRenderMessageListener",null);b(this,"handleScreenContentChanged",t=>{!this._artifact||t.artifactID!==this._artifact.id||this._activeView!==null&&this.refetchContent()});b(this,"handleOpenArtifact",t=>{this.requestFocus(t.artifactID)});b(this,"handleIframeMessage",t=>{const r=this.querySelector("iframe.artifact-frame");!r||r.contentWindow!==t.source||_2(t.data)&&this.dispatchArtifactWheel({deltaX:t.data.deltaX,deltaY:t.data.deltaY,shiftKey:t.data.shiftKey},i=>{var o;const s={type:"scroll",deltaX:0,deltaY:i};(o=r.contentWindow)==null||o.postMessage(s,this.iframeTargetOrigin(r))})});b(this,"handleWebviewIpcMessage",t=>{var o;const r=t.detail??t;if(!r||r.channel!==mf)return;const i=(o=r.args)==null?void 0:o[0];if(!i||i.type!=="wheel")return;const s=this._subscribedWebview;s&&this.dispatchArtifactWheel({deltaX:i.deltaX??0,deltaY:i.deltaY??0,shiftKey:i.shiftKey??!1},a=>{var c;(c=s.send)==null||c.call(s,mf,{type:"scroll",deltaX:0,deltaY:a})})})}set artifact(t){const r=this._artifact;this._artifact=t,this.render(),r!==null&&r!==t&&this.syncView()}get artifact(){return this._artifact}set viewURL(t){this._viewURL!==t&&(this._viewURL=t,this.syncView())}get viewURL(){return this._viewURL}set contentURL(t){this._contentURL!==t&&(this._contentURL=t,this.syncView())}get contentURL(){return this._contentURL}set screen(t){this._screen!==t&&(this._screen=t,this.syncScreenSubscription())}get screen(){return this._screen}set dragging(t){t?this.setAttribute("dragging","true"):this.removeAttribute("dragging")}get dragging(){return this.getAttribute("dragging")==="true"}get activeView(){return this._activeView}connectedCallback(){this.setAttribute("level","2"),this.render(),this.syncView(),this.syncScreenSubscription(),window.addEventListener("message",this.handleIframeMessage)}disconnectedCallback(){this.teardownView(),this.unsubscribeFromScreen(),window.removeEventListener("message",this.handleIframeMessage),this.unsubscribeFromWebview()}handleClose(){this._artifact&&this.dispatchEvent(new Dy("close-artifact",{artifactID:this._artifact.id,bubbles:!0,composed:!0}))}syncView(){var t,r;if(this.isConnected){if((t=this._artifact)!=null&&t.externalURL){this.teardownView(),this._contentState={kind:"ready"},this.render();return}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 i=this.querySelector("iframe.artifact-frame");if(!i){this._contentState={kind:"error"},this.render();return}this._activeView=new D2(i),this._activeView.handleUpdateContent(async s=>{await this.saveContent(s)}),this._activeView.addEventListener("open-artifact",this.handleOpenArtifact),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(),this.installDirectRenderMessageListener(),((r=this._artifact)==null?void 0:r.status)==="committed"&&this.loadBlobFrame(this._contentURL);return}this.teardownView(),this._contentState={kind:"idle"},this.render()}}async saveContent(t){const r=this._screen,i=this._artifact;if(!r||!i)throw new Error("artifact-view: cannot save without a screen and artifact");await r.server.client.artifacts.putContent({artifactID:i.id,content:t})}syncScreenSubscription(){if(!this.isConnected){this.unsubscribeFromScreen();return}this._subscribedScreen!==this._screen&&(this.unsubscribeFromScreen(),this._screen!==null&&(this._screen.addEventListener("artifact-content-changed",this.handleScreenContentChanged),this._subscribedScreen=this._screen))}unsubscribeFromScreen(){this._subscribedScreen!==null&&(this._subscribedScreen.removeEventListener("artifact-content-changed",this.handleScreenContentChanged),this._subscribedScreen=null)}startContentFetch(){this._fetchSequence+=1;const t=this._fetchSequence,r=this._contentURL,i=this._activeView;if(!i||r===null){this._contentState={kind:"error"},this.render();return}this._contentState={kind:"loading"},(async()=>{try{const s=await fetch(r);if(t!==this._fetchSequence)return;if(!s.ok){this._contentState={kind:"error"},this.teardownView(),this.render();return}const o=await s.text();if(t!==this._fetchSequence||this._activeView!==i)return;this._activeView.content=o,this._contentState={kind:"ready"}}catch{if(t!==this._fetchSequence)return;this._contentState={kind:"error"},this.teardownView(),this.render()}})()}refetchContent(){this._fetchSequence+=1;const t=this._fetchSequence,r=this._contentURL,i=this._activeView;!i||r===null||(async()=>{try{const s=await fetch(r);if(t!==this._fetchSequence||!s.ok)return;const o=await s.text();if(t!==this._fetchSequence||this._activeView!==i)return;this._activeView.content=o}catch{}})()}loadBlobFrame(t){this._blobSequence+=1;const r=this._blobSequence;(async()=>{try{const i=await L2(t);if(r!==this._blobSequence){URL.revokeObjectURL(i);return}this._blobURL=i,this.render();const s=this.querySelector("iframe.artifact-frame");s&&(s.src=i)}catch{if(r!==this._blobSequence)return;this._contentState={kind:"error"},this.teardownView(),this.render()}})()}teardownView(){this._activeView!==null&&(this._activeView.removeEventListener("open-artifact",this.handleOpenArtifact),this._activeView.dispose(),this._activeView=null),this.removeDirectRenderMessageListener(),this._blobURL!==null&&(URL.revokeObjectURL(this._blobURL),this._blobURL=null),this._mountedViewURL=null,this._directRender=!1,this._fetchSequence+=1,this._blobSequence+=1}installDirectRenderMessageListener(){if(this._directRenderMessageListener!==null)return;const t=r=>{const i=this.querySelector("iframe.artifact-frame");i&&r.source===i.contentWindow&&Cy(r.data)&&this.requestFocus(r.data.artifactID)};this._directRenderMessageListener=t,window.addEventListener("message",t)}removeDirectRenderMessageListener(){this._directRenderMessageListener!==null&&(window.removeEventListener("message",this._directRenderMessageListener),this._directRenderMessageListener=null)}requestFocus(t){const r=this._screen;r&&r.server.client.viewer.focus({artifactID:t}).catch(i=>{console.warn("artifact-view: viewer.focus failed",i)})}contentTemplate(){var t;if((t=this._artifact)!=null&&t.externalURL){const r=this._artifact.externalURL;return ch()?U`
131
131
  <webview
132
132
  class="artifact-frame artifact-content"
133
133
  src=${r}
@@ -157,7 +157,7 @@ ${r.documentElement.outerHTML}`],{type:"text/html"});return URL.createObjectURL(
157
157
  ${this.contentTemplate()}
158
158
  <footer class="artifact-title-bar" drag-handle material="glass">
159
159
  <div class="artifact-title-group">
160
- <span class="artifact-title-icon">${o2({size:16})}</span>
160
+ <span class="artifact-title-icon">${a2({size:16})}</span>
161
161
  <span class="artifact-title">${t.title}</span>
162
162
  </div>
163
163
  <button
@@ -167,10 +167,10 @@ ${r.documentElement.outerHTML}`],{type:"text/html"});return URL.createObjectURL(
167
167
  @click=${()=>this.handleClose()}
168
168
  aria-label="Close"
169
169
  >
170
- ${ay({size:16})}
170
+ ${cy({size:16})}
171
171
  </button>
172
172
  </footer>
173
- `}render(){this._artifact&&(this.setAttribute("type",this._artifact.type),Re(this.template(),this),this.syncWebviewSubscription())}dispatchArtifactWheel(t,r){this.dispatchEvent(new L2("artifact-wheel",{bubbles:!0,composed:!0,deltaX:t.deltaX,deltaY:t.deltaY,shiftKey:t.shiftKey,scrollNative:r}))}syncWebviewSubscription(){const t=this.querySelector("webview");t!==this._subscribedWebview&&(this.unsubscribeFromWebview(),t&&(t.addEventListener("ipc-message",this.handleWebviewIpcMessage),this._subscribedWebview=t))}unsubscribeFromWebview(){this._subscribedWebview&&(this._subscribedWebview.removeEventListener("ipc-message",this.handleWebviewIpcMessage),this._subscribedWebview=null)}iframeTargetOrigin(t){const r=t.getAttribute("sandbox")??"";if(!new Set(r.split(/\s+/).filter(Boolean)).has("allow-same-origin"))return"*";const s=t.getAttribute("src")??t.src;if(!s)return"*";try{return new URL(s,window.location.href).origin}catch{return"*"}}}customElements.define("artifact-view",O2);const we=n=>({type:"px",...n}),Te=n=>({type:"unit",...n}),Ro=2;class M2{constructor(e){b(this,"basis");b(this,"min");b(this,"_gap");b(this,"_viewport");b(this,"_unit");this.basis=e.basis,this.min=e.min,this._viewport=e.viewport,this._gap=e.gap??we({x:he,y:he});const t=this._viewport.x??hr,r=this._viewport.y??ua,i=this._gap.x??he,s=this._gap.y??he,o=t<=px,a=o?t-i*Ro:Math.min(hr,t-i*Ro),c=o?r-s*Ro:Math.min(ua,r-s*Ro),u=(a-i*(Lt-1))/Lt,h=(c-s*(et-1))/et,p=this.basis.x??0,v=this.basis.y??0,g=this.min.x??0,E=this.min.y??0;this._unit=we(o?{x:Math.max(g,u),y:Math.max(E,h)}:{x:Math.max(g,Math.min(p,u)),y:Math.max(E,Math.min(v,h))})}get unit(){return this._unit}get viewport(){return this._viewport}get gap(){return this._gap}toUnits(e){return Te({x:e.x==null?void 0:e.x/(this._unit.x??1),y:e.y==null?void 0:e.y/(this._unit.y??1)})}toPixels(e){const t=this._unit.x??0,r=this._unit.y??0,i=this._gap.x??he,s=this._gap.y??he,o=e.x==null?void 0:e.x*t+Math.max(0,e.x-1)*i,a=e.y==null?void 0:e.y*r+Math.max(0,e.y-1)*s;return we({x:o,y:a})}}const fr=1e-4,Je=1e-6,z2=40,N2=24;function Ry(n,e){return Math.max(0,n-e*2)}function Dy(n){const e=[0];for(const t of n)e.push((e[e.length-1]??0)+t);return e}function Ly(n){const e=[0];for(let t=0;t<n.length;t+=1){const r=e[t]??0;e.push(r+n[t]+he)}return e}function Oy(n,e,t){if(e<0||e>=n.length)return 0;let r=0,i=0;for(let s=e;s<n.length;s+=1){const o=n[s],a=i===0?o:r+he+o;if(a>t+fr)break;r=a,i+=1}return Math.max(1,i)}function U2(n,e,t){if(e<0||e>=n.length)return 0;let r=0,i=0;for(let s=e;s>=0;s-=1){const o=n[s],a=i===0?o:r+he+o;if(a>t+fr)break;r=a,i+=1}return Math.max(1,i)}function F2(n,e){if(n.length===0)return 0;let t=0,r=0;for(let i=n.length-1;i>=0;i-=1){const s=n[i],o=r===0?s:t+he+s;if(o>e+fr)break;t=o,r+=1}return Math.max(1,r)}function dh(n,e){if(n.length===0)return 0;const t=F2(n,e);return Math.max(0,n.length-t)}function gf(n,e,t){if(n.length===0)return 0;const r=Oy(n,e,t),i=Math.min(n.length,e+r);if(i<=e)return 0;const s=n.slice(e,i);return s.reduce((o,a)=>o+a,0)+Math.max(0,s.length-1)*he}function iu(n,e,t){const r=n[e]??0;return t-r}function Nr(n,e,t,r,i){if(n.length===0)return 0;const s=dh(n,i),o=e[s]??0,a=Math.max(0,Math.min(o,t));let c=0;for(let H=0;H<s;H+=1){const F=e[H]??0,ce=e[H+1]??F;if(a>=F&&a<=ce+fr){c=H;break}c=H+1}const u=Math.min(c+1,s),h=e[c]??0,p=e[u]??h,v=Math.max(p-h,fr),g=u===c?0:(a-h)/v,E=Ly(n),_=gf(n,c,i),C=gf(n,u,i),N=(r-_)/2,P=(r-C)/2,W=iu(E,c,N),L=iu(E,u,P);return W+(L-W)*g}function mf(n,e,t,r,i){const s=dh(n,r),o=e[s]??0;let a=0,c=o;for(let u=0;u<z2;u+=1){const h=(a+c)/2;Nr(n,e,h,t,r)>i?a=h:c=h}return(a+c)/2}function vf(n,e,t){const r=Ly(n),[i,s]=e,o=n.slice(i,s+1),a=o.reduce((u,h)=>u+h,0)+Math.max(0,o.length-1)*he,c=(t-a)/2;return iu(r,i,c)}function Z2(n,e,t){const r=Oy(n,e,t);return[e,Math.min(n.length-1,e+r-1)]}function H2(n,e,t){const r=U2(n,e,t);return[Math.max(0,e-r+1),e]}function W2(n){const e=new Set,t=[];for(const r of n){const i=`${r.nodeRange[0]}:${r.nodeRange[1]}`;if(e.has(i))continue;const s=t[t.length-1];s&&Math.abs(s.anchor-r.anchor)<=Je||(e.add(i),t.push(r))}return t}function B2(n){const{nodeCols:e,nodeWidthsPx:t,viewportWidthPx:r}=n;if(e.length===0||t.length===0)return{viewspans:[],minScroll:0,maxScroll:0};const i=n.gapPx??he,s=Ry(r,i),o=Dy(e),a=dh(t,s),c=o[a]??0,u=[];for(let h=0;h<=a;h+=1){const p=Z2(t,h,s),v=vf(t,p,r),g=mf(t,o,r,s,v);u.push({nodeRange:p,anchor:Math.max(0,Math.min(c,g))})}for(let h=t.length-1;h>=0;h-=1){const p=H2(t,h,s),v=`${p[0]}:${p[1]}`;if(u.some(_=>`${_.nodeRange[0]}:${_.nodeRange[1]}`===v))continue;const g=vf(t,p,r),E=mf(t,o,r,s,g);u.push({nodeRange:p,anchor:Math.max(0,Math.min(c,E))})}return u.sort((h,p)=>Math.abs(h.anchor-p.anchor)>Je?h.anchor-p.anchor:h.nodeRange[0]!==p.nodeRange[0]?h.nodeRange[0]-p.nodeRange[0]:h.nodeRange[1]-p.nodeRange[1]),{viewspans:W2(u),minScroll:0,maxScroll:c}}function ic(n,e){var i;let t=0,r=Number.POSITIVE_INFINITY;for(let s=0;s<n.length;s+=1){const o=Math.abs((((i=n[s])==null?void 0:i.anchor)??0)-e);if(o+Je<r){r=o,t=s;continue}Math.abs(o-r)<=Je&&s<t&&(t=s)}return t}function V2(n,e,t){return t<=0?0:Math.max(0,Math.min(t-1,n+e))}function Rr(n,e,t){return Math.max(e,Math.min(t,n))}function G2(n,e){var t;for(let r=0;r<n.length;r+=1)if(Math.abs((((t=n[r])==null?void 0:t.anchor)??0)-e)<=Je)return r;return-1}function j2(n,e,t){var i,s,o,a;if(n.length===0)return e;const r=G2(n,e);if(r>=0){const c=n[r];if(!c)return e;if(t>0){const v=c.nodeRange[0]+1,g=n.filter(_=>_.nodeRange[0]===v);if(g.length===0)return((i=n[n.length-1])==null?void 0:i.anchor)??e;let E=g[0];for(const _ of g)_.nodeRange[1]>E.nodeRange[1]&&(E=_);return E.anchor}const u=c.nodeRange[1]-1,h=n.filter(v=>v.nodeRange[1]===u);if(h.length===0)return((s=n[0])==null?void 0:s.anchor)??e;let p=h[0];for(const v of h)v.nodeRange[0]<p.nodeRange[0]&&(p=v);return p.anchor}if(t>0){for(const c of n)if(c.anchor>e+Je)return c.anchor;return((o=n[n.length-1])==null?void 0:o.anchor)??e}for(let c=n.length-1;c>=0;c-=1){const u=n[c];if(u&&u.anchor<e-Je)return u.anchor}return((a=n[0])==null?void 0:a.anchor)??e}class q2 extends wt{constructor(t){super();b(this,"_scroll",0);b(this,"minScroll",0);b(this,"maxScroll",0);b(this,"viewspans",[]);b(this,"activeViewspanIndex",null);b(this,"nodeWidthsPx",[]);b(this,"boundaryCols",[0]);b(this,"viewportWidthPx",0);b(this,"framedViewportWidthPx",0);this._scroll=(t==null?void 0:t.x)??0}get scroll(){return Te({x:this._scroll})}get translate(){return we({x:Nr(this.nodeWidthsPx,this.boundaryCols,this._scroll,this.viewportWidthPx,this.framedViewportWidthPx)})}set scroll(t){const r=Rr(t.x??this._scroll,this.minScroll,this.maxScroll);Math.abs(r-this._scroll)<=Je||(this._scroll=r,this.activeViewspanIndex=null,this.dispatchEvent(new Pr("layout-scroll",{scroll:this.scroll})))}rebuild(t){const r=t.nodeWidths.map(u=>Math.max(0,u.x??0)),i=r.map(u=>t.grid.toPixels(Te({x:u})).x??0),s=t.grid.viewport.x??0,o=t.grid.gap.x??he,a=B2({nodeCols:r,nodeWidthsPx:i,viewportWidthPx:s,gapPx:o});this.nodeWidthsPx=i,this.boundaryCols=Dy(r),this.viewportWidthPx=s,this.framedViewportWidthPx=Ry(s,o),this.viewspans=a.viewspans,this.minScroll=a.minScroll,this.maxScroll=a.maxScroll,this.activeViewspanIndex=null;const c=Rr(this._scroll,this.minScroll,this.maxScroll);Math.abs(c-this._scroll)>Je&&(this._scroll=c,this.dispatchEvent(new Pr("layout-scroll",{scroll:this.scroll})))}step(t){var a;if(this.viewspans.length===0)return;const r=this.activeViewspanIndex??ic(this.viewspans,this._scroll),i=V2(r,t,this.viewspans.length),s=((a=this.viewspans[i])==null?void 0:a.anchor)??this._scroll,o=Rr(s,this.minScroll,this.maxScroll);this.activeViewspanIndex=i,!(Math.abs(o-this._scroll)<=Je)&&(this._scroll=o,this.dispatchEvent(new Pr("layout-scroll",{scroll:this.scroll})))}snap(t){var s;if(this.viewspans.length===0)return;const r=t===void 0?((s=this.viewspans[ic(this.viewspans,this._scroll)])==null?void 0:s.anchor)??this._scroll:j2(this.viewspans,this._scroll,t),i=Rr(r,this.minScroll,this.maxScroll);this.activeViewspanIndex=ic(this.viewspans,i),!(Math.abs(i-this._scroll)<=Je)&&(this._scroll=i,this.dispatchEvent(new Pr("layout-scroll",{scroll:this.scroll})))}wheel(t){const r=Rr(this._scroll+(t.x??0),this.minScroll,this.maxScroll);this.activeViewspanIndex=null,!(Math.abs(r-this._scroll)<=Je)&&(this._scroll=r,this.dispatchEvent(new Pr("layout-scroll",{scroll:this.scroll})))}wheelPixels(t){const r=t.x??0;if(Math.abs(r)<=fr)return;this.activeViewspanIndex=null;const i=Nr(this.nodeWidthsPx,this.boundaryCols,this._scroll,this.viewportWidthPx,this.framedViewportWidthPx),s=i-r,o=Nr(this.nodeWidthsPx,this.boundaryCols,this.maxScroll,this.viewportWidthPx,this.framedViewportWidthPx),a=Nr(this.nodeWidthsPx,this.boundaryCols,this.minScroll,this.viewportWidthPx,this.framedViewportWidthPx),c=Math.max(o,Math.min(a,s));if(Math.abs(c-i)<=fr)return;let u=this.minScroll,h=this.maxScroll;for(let v=0;v<N2;v+=1){const g=(u+h)/2;Nr(this.nodeWidthsPx,this.boundaryCols,g,this.viewportWidthPx,this.framedViewportWidthPx)>c?u=g:h=g}const p=Rr((u+h)/2,this.minScroll,this.maxScroll);Math.abs(p-this._scroll)<=Je||(this._scroll=p,this.dispatchEvent(new Pr("layout-scroll",{scroll:this.scroll})))}}const sc={"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}},Y2=["stack-above","stack-below","reorder-before","reorder-after"];function oc(n,e){return{left:n.left+n.width*e.left,top:n.top+n.height*e.top,width:n.width*e.width,height:n.height*e.height}}function Cn(n,e,t){return n>=t.left&&n<t.left+t.width&&e>=t.top&&e<t.top+t.height}function ph(n,e){for(const t of n){if(t.type==="card"&&t.id===e)return t;if(t.type==="stack")for(const r of t.children){if(r.type==="card"&&r.id===e)return r;if(r.type==="row"){for(const i of r.children)if(i.id===e)return i}}}return null}function su(n){return n.height===et||n.height===mn?{...n,height:mn}:n}function ou(n){return n.height===mn?{...n,height:et}:n}function X2(n,e,t,r){const i=n.findIndex(h=>h.type==="stack"&&h.id===e);if(i===-1)return n;const s=n[i];if(!s||s.type!=="stack")return n;const o=s.children.find(h=>h.type==="card"&&h.id===t);if(!o||o.type!=="card")return n;const a=s.children.filter(h=>h.id!==t);if(a.length===s.children.length||a.length<1)return n;const c=[...n];if(a.length===1){const[h]=a;c[i]=h.type==="card"?ou(h):h}else c[i]={...s,children:a};const u=Math.max(0,Math.min(r,c.length));return c.splice(u,0,ou(o)),c}const K2=tt(),J2=tt(),Q2=50;function eL(n,e){if(n.type!==e.type)return!1;switch(n.type){case"reorder":return e.index===n.index;case"stack":return e.targetCardId===n.targetCardId&&e.position===n.position;case"stack-child-noop":return!0;case"stack-child-extract":return e.toIndex===n.toIndex;case"stack-child-reorder":return e.position===n.position;default:return!1}}function ao(n){return{id:n.id,type:"drop-target",width:n.width,height:n.height}}function yf(n){return n.map(nL)}function tL(n){return n.type==="drop-target"?{id:n.id,type:"card",artifactID:n.id,width:n.width,height:n.height}:n}function nL(n){return n.type==="drop-target"?{id:n.id,type:"card",artifactID:n.id,width:n.width,height:n.height}:n.type==="stack"?{...n,children:n.children.map(tL)}:n}function My(n,e){return n.find(r=>r.type==="card"&&r.id===e)??null}function bf(n,e){return n.find(r=>r.type==="stack"&&r.id===e)??null}function rL(n,e){const t=[...e],r=t.findIndex(a=>a.type==="card"&&a.id===n.nodeId);if(r===-1)return null;const i=t[r];if(!i||i.type!=="card")return null;t.splice(r,1);const s=Math.max(0,Math.min(n.lastReorderIndex,t.length));t.splice(s,0,i);const o=t.findIndex(a=>a.type==="card"&&a.id===n.nodeId);return o===-1?null:{base:t,visualDraggedIndex:o}}function iL(n,e,t,r){const i=[...n.base];i.splice(n.visualDraggedIndex,1);const s=i.findIndex(v=>v.type==="card"&&v.id===t.targetCardId),o=s===-1?null:i[s];if(!o||o.type!=="card")return null;const a=My(r,e.nodeId);if(!a)return null;const c=su(a),u=su(o),h=ao(c),p=t.position==="above"?[h,u]:[u,h];return i[s]={id:o.id,type:"stack",children:p},i}function ac(n,e){return n.parentStackId?oL(n,e):sL(n,e)}function sL(n,e){const t=n.hitTarget;if(t.type==="reorder"){const r=e[n.sourceIndex];if(!r||r.type!=="card")return[...e];const i=[...e];return i.splice(n.sourceIndex,1),i.splice(t.index,0,ao(r)),i}if(t.type==="stack"){const r=rL(n,e);return r?iL(r,n,t,e)??[...e]:[...e]}return[...e]}function oL(n,e){const t=n.hitTarget;switch(t.type){case"stack-child-reorder":return aL(n,e,t.position);case"stack-child-extract":return lL(n,e,t.toIndex);case"stack-child-noop":return cL(n,e);default:return[...e]}}function aL(n,e,t){const r=e.findIndex(v=>v.type==="stack"&&v.id===n.parentStackId);if(r===-1)return[...e];const i=e[r];if(!i||i.type!=="stack")return[...e];if(!i.children.every(v=>v.type==="card"))return[...e];const s=i.children,o=s.findIndex(v=>v.id===n.nodeId);if(o===-1)return[...e];const a=s[o],c=s.filter(v=>v.id!==n.nodeId),u=ao(a),h=t==="above"?[u,...c]:[...c,u],p=[...e];return p[r]={...i,children:h},p}function lL(n,e,t){if(!n.parentStackId)return[...e];const r=X2(e,n.parentStackId,n.nodeId,t);if(r===e)return[...e];const i=r.findIndex(a=>a.type==="card"&&a.id===n.nodeId);if(i===-1)return[...e];const s=r[i];if(!s||s.type!=="card")return[...e];const o=[...r];return o[i]=ao(s),o}function cL(n,e){const t=e.findIndex(c=>c.type==="stack"&&c.id===n.parentStackId);if(t===-1)return[...e];const r=e[t];if(!r||r.type!=="stack")return[...e];const i=r.children.findIndex(c=>c.type==="card"&&c.id===n.nodeId);if(i===-1)return[...e];const s=r.children[i];if(!s||s.type!=="card")return[...e];const o=[...e],a=[...r.children];return a[i]=ao(s),o[t]={...r,children:a},o}function uL(n,e){return e.find(r=>r.type==="stack"&&r.id===n.id)?n.id:ju()}function hL(n,e,t){if(n.type==="drop-target"){const r=ph(e,t);if(!r)throw new Error(`finalize: missing dragged card ${t}`);return su(r)}return n}function dL(n,e,t){const r=n.children.map(s=>hL(s,e,t));return{id:uL(n,e),type:"stack",children:r}}function pL(n,e,t){if(n.type==="drop-target"){const r=ph(e,t);if(!r)throw new Error(`finalize: missing dragged card ${t}`);return My(e,t)!==null?r:ou(r)}return n.type==="card"||n.type==="row"?n:dL(n,e,t)}function fL(n,e,t){return n.map(r=>pL(r,e,t))}function gL(n,e){return JSON.stringify(n)===JSON.stringify(e)}const mL=ki(wt);class vL extends mL{constructor(t={}){super();b(this,"pending",null);b(this,"active",null)}start(t){if(this.pending||this.active)return;const r=t.pointer.x??0,i=t.pointer.y??0;this.pending={startX:r,startY:i,grabOffsetX:t.grabOffset.x??0,grabOffsetY:t.grabOffset.y??0,nodeId:t.nodeId,sourceIndex:t.source.index,parentStackId:t.source.parentId,width:t.size.x??0,height:t.size.y??0,baseLayout:t.layout}}update(t){const r=t.pointer.x??0,i=t.pointer.y??0,s=this.pending;if(s){const u=r-s.startX,h=i-s.startY;Math.hypot(u,h)>=gx&&(this.pending=null,this.active={...s,pointerX:r,pointerY:i,hitTarget:{type:"reorder",index:s.sourceIndex},lastReorderIndex:s.sourceIndex},this.emitDrag(),this.dispatchEvent(new K("change")));return}if(!this.active)return;const o=ac(this.active,this.active.baseLayout),a=this.getHitTargetForPointer(r,i,t,o),c=a.type==="reorder"?a.index:this.active.lastReorderIndex;this.active.pointerX===r&&this.active.pointerY===i&&eL(this.active.hitTarget,a)&&this.active.lastReorderIndex===c||(this.active={...this.active,pointerX:r,pointerY:i,hitTarget:a,lastReorderIndex:c},this.emitDrag(),this.dispatchEvent(new K("change")))}drop(){if(this.pending){this.cancel();return}if(!this.active)return;const t=this.active.baseLayout;let r=null;try{const i=ac(this.active,t),s=fL(i,t,this.active.nodeId);gL(s,t)||(r=s)}catch{r=null}this.reset(),r&&this.dispatchEvent(new J2("drop",{layout:r})),this.dispatchEvent(new K("change"))}cancel(){!this.pending&&!this.active||(this.reset(),this.dispatchEvent(new K("change")))}dispose(){this.reset()}get status(){return this.active?"active":this.pending?"pending":"idle"}reset(){this.pending=null,this.active=null}emitDrag(){if(!this.active)return;const t=ac(this.active,this.active.baseLayout);this.dispatchEvent(new K2("drag",{nodeId:this.active.nodeId,source:{index:this.active.sourceIndex,parentId:this.active.parentStackId},grabOffset:we({x:this.active.grabOffsetX,y:this.active.grabOffsetY}),pointer:we({x:this.active.pointerX,y:this.active.pointerY}),size:we({x:this.active.width,y:this.active.height}),projectedLayout:t}))}getHitTargetForPointer(t,r,i,s){return this.active?this.isPointerInsideDragBounds(t,r,i.viewport)?this.active.parentStackId?this.getStackChildHitTarget(t,r,i,s):this.getTopLevelCardHitTarget(t,r,i,s):{type:"reorder",index:this.active.sourceIndex}:{type:"reorder",index:0}}getStackChildHitTarget(t,r,i,s){var u;if(!((u=this.active)!=null&&u.parentStackId))return{type:"stack-child-noop"};const o=this.getSourceStackInteractionRect(i.geometry);if(o&&Cn(t,r,o)){const h=o.top+o.height/2;return{type:"stack-child-reorder",position:r<h?"above":"below"}}const a=this.getSourceRemainingSiblingRect(i.geometry);if(a&&Cn(t,r,a)){const h=a.top+a.height/2;return{type:"stack-child-reorder",position:r<h?"above":"below"}}return{type:"stack-child-extract",toIndex:this.getTopLevelReorderIndexForPointer(t,r,i,s)}}getSourceRemainingSiblingRect(t){var s,o;if(!((s=this.active)!=null&&s.parentStackId))return;const r=bf(this.active.baseLayout,this.active.parentStackId);if(!r)return;const i=r.children.find(a=>{var c;return a.type==="card"&&a.id!==((c=this.active)==null?void 0:c.nodeId)});if(i)return(o=t.find(a=>a.id===i.id))==null?void 0:o.rect}getSourceStackInteractionRect(t){var o;if(!((o=this.active)!=null&&o.parentStackId))return;const r=t.find(a=>{var c;return a.id===((c=this.active)==null?void 0:c.parentStackId)});if(r)return this.active.sourceStackRect=r.rect,r.rect;const i=bf(this.active.baseLayout,this.active.parentStackId);if(!i)return this.active.sourceStackRect;const s=i.children.find(a=>{var c;return a.type==="card"&&a.id!==((c=this.active)==null?void 0:c.nodeId)});if(s){const a=t.find(c=>c.id===s.id);if(a)return a.rect}return this.active.sourceStackRect}getTopLevelCardHitTarget(t,r,i,s){var g,E,_;const o=this.getTopLevelZoneNodes(i.geometry,s);if(o.length===0)return{type:"reorder",index:((g=this.active)==null?void 0:g.sourceIndex)??0};const c=(i.effectiveVelocity??0)<=Q2;for(const C of o){const N=C.rect;if(!Cn(t,r,N))continue;const P=this.resolveTopLevelTargetForCard(t,r,C,C.logicalIndex,c);if(P)return P;if(!c&&((E=this.active)!=null&&E.hitTarget))return this.active.hitTarget}const u=this.getNearestTargetableZone(t,o);if(!u)return{type:"reorder",index:((_=this.active)==null?void 0:_.sourceIndex)??0};const h=Math.max(u.rect.left,Math.min(u.rect.left+u.rect.width,t)),p=this.resolveTopLevelTargetForCard(h,r,u,u.logicalIndex,c);if(p)return p;const v=u.rect.left+u.rect.width/2;return{type:"reorder",index:t<v?u.logicalIndex:u.logicalIndex+1}}getTopLevelReorderIndexForPointer(t,r,i,s){var u,h;const o=this.getTopLevelZoneNodes(i.geometry,s);if(o.length===0)return((u=this.active)==null?void 0:u.sourceIndex)??0;for(const p of o){if(!Cn(t,r,p.rect))continue;const v=oc(p.rect,sc["reorder-before"]);if(Cn(t,r,v))return p.logicalIndex;const g=oc(p.rect,sc["reorder-after"]);if(Cn(t,r,g))return p.logicalIndex+1}const a=this.getNearestTargetableZone(t,o);if(!a)return((h=this.active)==null?void 0:h.sourceIndex)??0;const c=a.rect.left+a.rect.width/2;return t<c?a.logicalIndex:a.logicalIndex+1}getTopLevelZoneNodes(t,r){const i=new Map(r.map(a=>[a.id,a])),s=[];let o=0;for(const a of t){const c=i.get(a.id);c&&c.type!=="drop-target"&&(c.type==="card"||c.type==="stack")&&(s.push({id:c.id,rect:a.rect,logicalIndex:o}),o+=1)}return s}resolveTopLevelTargetForCard(t,r,i,s,o){const a=i.rect;for(const c of Y2){if(!o&&(c==="stack-above"||c==="stack-below"))continue;const u=sc[c],h=oc(a,u);if(Cn(t,r,h))return c==="stack-above"?{type:"stack",targetCardId:i.id,position:"above"}:c==="stack-below"?{type:"stack",targetCardId:i.id,position:"below"}:c==="reorder-before"?{type:"reorder",index:s}:{type:"reorder",index:s+1}}return null}getNearestTargetableZone(t,r){let i=null,s=Number.POSITIVE_INFINITY;for(const o of r){const a=o.rect.left,c=o.rect.left+o.rect.width,u=t<a?a-t:t>c?t-c:0;u<s&&(s=u,i=o)}return i}isPointerInsideDragBounds(t,r,i){return t>=i.left&&t<=i.left+i.width&&r>=i.top&&r<=i.top+i.height}}const wf=60,yL=80,Sf=.5,_f=10;class bL{constructor(){b(this,"awaitingFreshWheelGesture",!1);b(this,"lastWheelEventAt",Number.NEGATIVE_INFINITY);b(this,"lastWheelDeltaX",0);b(this,"activeGestureType","none");b(this,"lastWheelGestureAt",Number.NEGATIVE_INFINITY)}markKeyboardNavigation(e){this.awaitingFreshWheelGesture=!0,this.lastWheelEventAt=e,this.activeGestureType="none"}reset(){this.awaitingFreshWheelGesture=!1,this.lastWheelEventAt=Number.NEGATIVE_INFINITY,this.lastWheelDeltaX=0,this.activeGestureType="none",this.lastWheelGestureAt=Number.NEGATIVE_INFINITY}decide(e){const{now:t,shiftKey:r,deltaX:i,deltaY:s,overArtifactContent:o}=e;t-this.lastWheelGestureAt>=wf&&(this.activeGestureType="none");const c=r&&s!==0,u=c?s:i,h=Math.abs(u),p=Math.abs(s);return this.activeGestureType==="vertical-artifact"&&o?h>=Sf&&h>=p*_f?this.classifyHorizontal(t,u):(this.lastWheelGestureAt=t,{type:"scroll-native"}):this.activeGestureType==="horizontal-filmstrip"?!c&&o&&p>0&&p>=h*_f?(this.activeGestureType="vertical-artifact",this.lastWheelGestureAt=t,{type:"scroll-native"}):this.classifyHorizontal(t,u):h<Sf?(o&&(this.activeGestureType="vertical-artifact"),this.lastWheelGestureAt=t,{type:"scroll-native"}):c||h>p?this.classifyHorizontal(t,u):p>h?(o&&(this.activeGestureType="vertical-artifact"),this.lastWheelGestureAt=t,{type:"scroll-native"}):o?(this.activeGestureType="vertical-artifact",this.lastWheelGestureAt=t,{type:"scroll-native"}):this.classifyHorizontal(t,u)}classifyHorizontal(e,t){const r=e-this.lastWheelEventAt,i=Math.sign(this.lastWheelDeltaX),s=Math.sign(t),o=i!==0&&s!==0&&i!==s,a=i!==0&&Math.abs(t)>=Math.abs(this.lastWheelDeltaX)+yL;return this.awaitingFreshWheelGesture&&r<wf&&!o&&!a?{type:"ignore"}:(this.lastWheelEventAt=e,this.lastWheelDeltaX=t,this.lastWheelGestureAt=e,this.awaitingFreshWheelGesture=!1,this.activeGestureType="horizontal-filmstrip",{type:"scroll-horizontal",horizontalDelta:t})}}const wL=100,SL=1e3;class _L{constructor(e,t){b(this,"_status","idle");b(this,"cumulativeOffset",0);b(this,"samples",[]);b(this,"scroll");b(this,"setAnimating");this.scroll=e,this.setAnimating=t}get status(){return this._status}start(e){this._status="active",this.cumulativeOffset=0,this.samples=[{time:e,offset:0}]}move(e,t){this._status==="active"&&(this.cumulativeOffset+=t,this.samples.push({time:e,offset:this.cumulativeOffset}),this.pruneSamples(e),this.setAnimating(!1),this.scroll.wheelPixels(we({x:-t})))}end(){if(this._status!=="active")return;const e=this.computeVelocityPxPerSec();this.setAnimating(!0),Math.abs(e)<vx?this.scroll.snap():this.scroll.snap(e>0?-1:1),this.reset()}cancel(){this._status==="active"&&(this.setAnimating(!0),this.scroll.snap(),this.reset())}reset(){this._status="idle",this.cumulativeOffset=0,this.samples=[]}pruneSamples(e){const t=e-wL;let r=0;for(let i=0;i<this.samples.length;i+=1){if(this.samples[i].time>=t){r=i;break}r=i+1}if(r>0){const i=Math.max(0,r-1);this.samples=this.samples.slice(i)}}computeVelocityPxPerSec(){if(this.samples.length<2)return 0;const e=this.samples[0],t=this.samples[this.samples.length-1],r=t.time-e.time;return r<=0?0:(t.offset-e.offset)/r*SL}}const kL=2,kf=1e3,Do=1e-4;function EL(n){return n.replace(/["\\]/g,"\\$&")}function Ef(n,e,t){if(n===0)return 0;const r=e.toPixels(Te({y:et})).y??0;return(t-r)/kL}function lc(n){const e=n.clientWidth>0?n.clientWidth:hr,t=n.clientHeight>0?n.clientHeight:ua;let r=0,i=0;if(n.isConnected){const o=getComputedStyle(n);r=parseFloat(o.paddingTop)||0,i=parseFloat(o.paddingBottom)||0}const s=Math.max(1,t-r-i);return{width:e,height:s,offsetY:r}}class xL extends Event{constructor(t){super("scroll",{bubbles:!0,composed:!0});b(this,"scrollPosition");this.scrollPosition=t}}class zy extends Event{constructor(t){super("layout-change",{bubbles:!0,composed:!0});b(this,"layout");this.layout=t}}class AL extends HTMLElement{constructor(){super();b(this,"_layout",[]);b(this,"_scrollPosition",0);b(this,"layoutGrid",null);b(this,"layoutScroll",new q2(Te({x:0})));b(this,"scrollModelKey","");b(this,"resizeObserver",null);b(this,"renderPending",!1);b(this,"animateNextRender",!0);b(this,"wheelGesture",new bL);b(this,"swipeGesture",new _L(this.layoutScroll,t=>{this.animateNextRender=t}));b(this,"swipePointerId",null);b(this,"swipeStartX",0);b(this,"swipeStartY",0);b(this,"swipeLastX",0);b(this,"swipeActive",!1);b(this,"swipeShouldSuppressClick",!1);b(this,"swipeListenersAttached",!1);b(this,"dragController",new vL);b(this,"dragState",null);b(this,"activeDragPointerId",null);b(this,"dragListenersAttached",!1);b(this,"dragFrame",0);b(this,"lastDragFrameTime",0);b(this,"lastPointerX",0);b(this,"lastPointerY",0);b(this,"pointerVelocityPxPerSec",0);b(this,"scrollVelocityPxPerSec",0);b(this,"motionSampleTime",0);b(this,"motionSampleX",0);b(this,"motionSampleY",0);b(this,"dragTrackOffsetXPx",0);b(this,"previousProjectedLayoutForOffset",null);b(this,"renderContent",()=>U``);b(this,"onDragControllerChange",()=>{this.dragController.status==="idle"&&(this.dragState=null,this.dragTrackOffsetXPx=0,this.previousProjectedLayoutForOffset=null),this.scheduleRender()});b(this,"onDragControllerDrag",t=>{const r=yf(t.projectedLayout),i=this.shouldApplyTrackOffset(t.projectedLayout,t.source.parentId),s=t.source.parentId?this.getStackChildAnchorCardId(t.source.parentId,t.nodeId):null;this.dragTrackOffsetXPx=i?this.computeDragTrackOffset(this.previousProjectedLayoutForOffset,r,t.nodeId,t.source.parentId,s,this.dragTrackOffsetXPx):0,this.previousProjectedLayoutForOffset=r,this.dragState={nodeId:t.nodeId,source:t.source,grabOffset:t.grabOffset,pointer:t.pointer,size:t.size,projectedLayout:t.projectedLayout},this.scheduleRender()});b(this,"onDragControllerDrop",t=>{this.dragState=null,this.dragTrackOffsetXPx=0,this.previousProjectedLayoutForOffset=null,this.commitLayout(t.layout)});b(this,"onLayoutScrollInternal",t=>{const i=t.scroll.x??0;Math.abs(i-this._scrollPosition)<Do||(this._scrollPosition=i,this.emitScrollPositionChanged(i),this.scheduleRender())});b(this,"handleKeyDown",t=>{if(t.key==="Escape"&&this.dragController.status!=="idle"){t.preventDefault(),this.stopDragFrameLoop(),this.releaseActiveDragPointerCapture(),this.dragController.cancel(),this.detachDragListeners();return}this.dragController.status==="idle"&&(t.key==="ArrowRight"?(t.preventDefault(),this.wheelGesture.markKeyboardNavigation(Date.now()),this.shiftWindow(1)):t.key==="ArrowLeft"&&(t.preventDefault(),this.wheelGesture.markKeyboardNavigation(Date.now()),this.shiftWindow(-1)))});b(this,"handleWheel",t=>{if(this._layout.length===0)return;const r=this.wheelGesture.decide({now:Date.now(),shiftKey:t.shiftKey,deltaX:t.deltaX,deltaY:t.deltaY,overArtifactContent:!1});r.type==="scroll-horizontal"&&(t.preventDefault(),this.applyHorizontalWheel(r.horizontalDelta))});b(this,"handleWindowMessage",t=>{if(this._layout.length===0)return;const r=this.findManagedArtifactFrame(t.source);if(r&&this.isTrustedArtifactFrameMessage(t,r)){if(_2(t.data)){const i=typeof performance<"u"?performance.now():Date.now();this.swipeGesture.status==="idle"&&this.swipeGesture.start(i),this.swipeGesture.move(i,t.data.deltaX);return}if(k2(t.data)){this.swipeGesture.status==="active"&&this.swipeGesture.end();return}}});b(this,"handleArtifactWheel",t=>{if(this._layout.length===0)return;const r=this.wheelGesture.decide({now:Date.now(),shiftKey:t.shiftKey,deltaX:t.deltaX,deltaY:t.deltaY,overArtifactContent:!0});if(r.type==="scroll-horizontal"){this.applyHorizontalWheel(r.horizontalDelta);return}r.type==="scroll-native"&&t.scrollNative(t.deltaY)});b(this,"handlePointerDown",t=>{if(t.button!==0||this.dragController.status!=="idle")return;const r=t.target;if(!(r instanceof Element))return;const i=r.closest("[drag-handle]")!==null,s=r.closest("button, input, textarea, select, a, [role='button']")!==null;if(t.pointerType==="touch"&&!i&&!s&&this._layout.length>0){this.beginSwipeTracking(t);return}if(!i||s)return;const o=r.closest(".card-slot");if(!o)return;const a=o.getAttribute("data-layout-node-id");if(!a)return;const c=TL(this._layout,a);if(!c)return;const u=o.getBoundingClientRect();this.lastPointerX=t.clientX,this.lastPointerY=t.clientY,this.resetMotionTracking(t.clientX,t.clientY),this.focus(),this.dragController.start({nodeId:a,source:{index:c.topLevelIndex,parentId:c.sourceStackId},pointer:we({x:t.clientX,y:t.clientY}),grabOffset:we({x:t.clientX-u.left,y:t.clientY-u.top}),size:we({x:u.width,y:u.height}),layout:this._layout}),this.attachDragListeners(),this.activeDragPointerId=t.pointerId;try{this.setPointerCapture(t.pointerId)}catch{}t.preventDefault()});b(this,"handleSwipePointerMove",t=>{if(this.swipePointerId===null||t.pointerId!==this.swipePointerId)return;if(!this.swipeActive){const i=t.clientX-this.swipeStartX,s=t.clientY-this.swipeStartY,o=Math.abs(i),a=Math.abs(s);if(o<xp&&a<xp)return;if(a>=o){this.endSwipeTracking();return}this.swipeActive=!0,this.swipeShouldSuppressClick=!0;try{this.setPointerCapture(t.pointerId)}catch{}this.swipeGesture.start(t.timeStamp)}const r=t.clientX-this.swipeLastX;this.swipeLastX=t.clientX,this.swipeGesture.move(t.timeStamp,r),t.preventDefault()});b(this,"handleSwipePointerUp",t=>{this.swipePointerId===null||t.pointerId!==this.swipePointerId||(this.swipeActive&&this.swipeGesture.end(),this.releaseSwipePointerCapture(t.pointerId),this.endSwipeTracking())});b(this,"handleSwipePointerCancel",t=>{this.swipePointerId===null||t.pointerId!==this.swipePointerId||(this.swipeActive&&this.swipeGesture.cancel(),this.releaseSwipePointerCapture(t.pointerId),this.endSwipeTracking())});b(this,"handleSwipeWindowBlur",()=>{this.swipePointerId!==null&&this.swipeActive&&this.swipeGesture.cancel(),this.swipePointerId!==null&&this.releaseSwipePointerCapture(this.swipePointerId),this.endSwipeTracking()});b(this,"handleSwipeClick",t=>{this.swipeShouldSuppressClick&&(this.swipeShouldSuppressClick=!1,t.preventDefault(),t.stopPropagation(),typeof t.stopImmediatePropagation=="function"&&t.stopImmediatePropagation())});b(this,"handleWindowPointerMove",t=>{this.lastPointerX=t.clientX,this.lastPointerY=t.clientY,this.updatePointerVelocity(t.clientX,t.clientY),this.syncDragTargetForLatestPointer(),this.ensureDragFrameLoop()});b(this,"handleWindowPointerUp",t=>{this.stopDragFrameLoop(),this.releasePointerCaptureForEvent(t.pointerId),this.dragController.drop(),this.clearMotionTracking(),this.detachDragListeners()});b(this,"handleWindowPointerCancel",t=>{this.stopDragFrameLoop(),this.releasePointerCaptureForEvent(t.pointerId),this.dragController.cancel(),this.clearMotionTracking(),this.detachDragListeners()});b(this,"handleWindowBlur",()=>{this.releaseActiveDragPointerCapture(),this.stopDragFrameLoop(),this.dragController.cancel(),this.clearMotionTracking(),this.detachDragListeners()});b(this,"runDragFrame",t=>{if(this.dragController.status==="idle"){this.dragFrame=0;return}const r=Math.max(0,t-this.lastDragFrameTime)/kf;this.lastDragFrameTime=t,this.samplePointerVelocityAt(t,this.lastPointerX,this.lastPointerY);const i=this.getBoundingClientRect(),s=this.clampPointerToViewport(this.lastPointerX,this.lastPointerY,i),o=this.getDragEdgeScrollDeltaPixels(s.x,i,r);this.scrollVelocityPxPerSec=r>Do?Math.abs(o)/r:0,Math.abs(o)>Do&&(this.animateNextRender=!1,this.layoutScroll.wheelPixels(we({x:o}))),this.dragController.status==="active"&&this.syncDragTarget(s.x,s.y,i),this.dragFrame=requestAnimationFrame(this.runDragFrame)});this.dragController.addEventListener("change",this.onDragControllerChange),this.dragController.addEventListener("drag",this.onDragControllerDrag),this.dragController.addEventListener("drop",this.onDragControllerDrop),this.layoutScroll.addEventListener("layout-scroll",this.onLayoutScrollInternal)}set layout(t){this._layout=[...t],this.stopDragFrameLoop(),this.dragController.cancel(),this.scrollModelKey="",this.syncScrollModel(),this.layoutScroll.scroll=Te({x:this._scrollPosition}),this.scheduleRender()}get layout(){return this._layout}commitLayout(t){this.layout=t,this.emitLayoutChanged()}set scrollPosition(t){Math.abs(t-this._scrollPosition)<Do||(this.animateNextRender=!1,this.syncScrollModel(),this.layoutScroll.scroll=Te({x:t}))}get scrollPosition(){return this._scrollPosition}focusArtifact(t){const r=Fr(this._layout),i=r.nodes.findIndex(o=>o.cards.some(a=>a.artifactID===t));if(i<0)return;let s=0;for(let o=0;o<i;o+=1)s+=r.nodes[o].width;this.scrollPosition=s,queueMicrotask(()=>{const o=this.querySelector(`.card-slot[data-layout-card-id="${EL(t)}"]`);if(!o)return;o.classList.remove("card-focus-pulse"),o.offsetHeight,o.classList.add("card-focus-pulse");const a=()=>{o.classList.remove("card-focus-pulse"),o.removeEventListener("animationend",a)};o.addEventListener("animationend",a)})}connectedCallback(){this.hasAttribute("tabindex")||(this.tabIndex=0),this.focus(),this.addEventListener("keydown",this.handleKeyDown),this.addEventListener("wheel",this.handleWheel,{passive:!1}),this.addEventListener("pointerdown",this.handlePointerDown),this.addEventListener("artifact-wheel",this.handleArtifactWheel),window.addEventListener("message",this.handleWindowMessage),typeof ResizeObserver<"u"&&(this.resizeObserver=new ResizeObserver(()=>this.render()),this.resizeObserver.observe(this)),this.render()}disconnectedCallback(){var t;this.removeEventListener("keydown",this.handleKeyDown),this.removeEventListener("wheel",this.handleWheel),this.removeEventListener("pointerdown",this.handlePointerDown),this.removeEventListener("artifact-wheel",this.handleArtifactWheel),window.removeEventListener("message",this.handleWindowMessage),(t=this.resizeObserver)==null||t.disconnect(),this.resizeObserver=null,this.wheelGesture.reset(),this.detachDragListeners(),this.swipeGesture.status==="active"&&this.swipeGesture.cancel(),this.swipePointerId!==null&&this.releaseSwipePointerCapture(this.swipePointerId),this.endSwipeTracking(),this.dragController.removeEventListener("change",this.onDragControllerChange),this.dragController.removeEventListener("drag",this.onDragControllerDrag),this.dragController.removeEventListener("drop",this.onDragControllerDrop),this.layoutScroll.removeEventListener("layout-scroll",this.onLayoutScrollInternal),this.dragController.dispose(),this.stopDragFrameLoop()}scheduleRender(){this.renderPending||(this.renderPending=!0,queueMicrotask(()=>{this.renderPending=!1,this.render()}))}createGrid(t,r){return new M2({basis:we({x:On,y:On}),min:we({x:kp,y:kp}),viewport:we({x:t,y:r}),gap:we({x:he,y:he})})}syncScrollModel(){const t=lc(this),i=Fr(this._layout).nodes.map(o=>o.width),s=`${t.width}x${t.height}:${i.join(",")}`;s===this.scrollModelKey&&this.layoutGrid||(this.scrollModelKey=s,this.layoutGrid=this.createGrid(t.width,t.height),this.layoutScroll.rebuild({grid:this.layoutGrid,nodeWidths:i.map(o=>Te({x:o}))}))}emitScrollPositionChanged(t){this.dispatchEvent(new xL(t))}emitLayoutChanged(){this.dispatchEvent(new zy([...this._layout]))}shiftWindow(t){this.syncScrollModel(),this.animateNextRender=!0,this.layoutScroll.step(t)}applyHorizontalWheel(t){this.syncScrollModel();const r=this.layoutGrid;if(!r)return;this.animateNextRender=!1;const i=r.toUnits(we({x:t}));this.layoutScroll.wheel(Te({x:i.x??0}))}findManagedArtifactFrame(t){if(!t)return null;const r=this.querySelectorAll("iframe.artifact-frame");for(const i of r)if(i.contentWindow===t)return i;return null}isTrustedArtifactFrameMessage(t,r){if(t.origin==="null")return!0;const i=this.getArtifactFrameOrigin(r);return i===null||t.origin===i}getArtifactFrameOrigin(t){const r=t.getAttribute("src")??t.src;if(!r)return null;try{return new URL(r,window.location.href).origin}catch{return null}}beginSwipeTracking(t){this.swipePointerId=t.pointerId,this.swipeStartX=t.clientX,this.swipeStartY=t.clientY,this.swipeLastX=t.clientX,this.swipeActive=!1,this.swipeShouldSuppressClick=!1,this.attachSwipeListeners()}attachSwipeListeners(){this.swipeListenersAttached||(window.addEventListener("pointermove",this.handleSwipePointerMove),window.addEventListener("pointerup",this.handleSwipePointerUp),window.addEventListener("pointercancel",this.handleSwipePointerCancel),this.addEventListener("pointermove",this.handleSwipePointerMove),this.addEventListener("pointerup",this.handleSwipePointerUp),this.addEventListener("pointercancel",this.handleSwipePointerCancel),window.addEventListener("blur",this.handleSwipeWindowBlur),this.addEventListener("click",this.handleSwipeClick,{capture:!0}),this.swipeListenersAttached=!0)}detachSwipeListeners(){this.swipeListenersAttached&&(window.removeEventListener("pointermove",this.handleSwipePointerMove),window.removeEventListener("pointerup",this.handleSwipePointerUp),window.removeEventListener("pointercancel",this.handleSwipePointerCancel),this.removeEventListener("pointermove",this.handleSwipePointerMove),this.removeEventListener("pointerup",this.handleSwipePointerUp),this.removeEventListener("pointercancel",this.handleSwipePointerCancel),window.removeEventListener("blur",this.handleSwipeWindowBlur),this.removeEventListener("click",this.handleSwipeClick,{capture:!0}),this.swipeListenersAttached=!1)}endSwipeTracking(){this.swipePointerId=null,this.swipeActive=!1,this.detachSwipeListeners()}releaseSwipePointerCapture(t){try{this.hasPointerCapture(t)&&this.releasePointerCapture(t)}catch{}}releaseActiveDragPointerCapture(){this.activeDragPointerId!==null&&this.releasePointerCaptureForEvent(this.activeDragPointerId)}releasePointerCaptureForEvent(t){try{this.hasPointerCapture(t)&&this.releasePointerCapture(t)}catch{}}attachDragListeners(){this.dragListenersAttached||(window.addEventListener("pointermove",this.handleWindowPointerMove),window.addEventListener("pointerup",this.handleWindowPointerUp),window.addEventListener("pointercancel",this.handleWindowPointerCancel),this.addEventListener("pointermove",this.handleWindowPointerMove),this.addEventListener("pointerup",this.handleWindowPointerUp),this.addEventListener("pointercancel",this.handleWindowPointerCancel),window.addEventListener("blur",this.handleWindowBlur),this.dragListenersAttached=!0)}detachDragListeners(){this.dragListenersAttached&&(window.removeEventListener("pointermove",this.handleWindowPointerMove),window.removeEventListener("pointerup",this.handleWindowPointerUp),window.removeEventListener("pointercancel",this.handleWindowPointerCancel),this.removeEventListener("pointermove",this.handleWindowPointerMove),this.removeEventListener("pointerup",this.handleWindowPointerUp),this.removeEventListener("pointercancel",this.handleWindowPointerCancel),window.removeEventListener("blur",this.handleWindowBlur),this.dragListenersAttached=!1,this.activeDragPointerId=null)}getDisplayModel(){if(this.dragController.status!=="active"||!this.dragState)return{layout:this._layout,activePlaceholderId:null,placeholdersById:new Map};const t=new Map;return t.set(this.dragState.nodeId,{id:this.dragState.nodeId,sourceCardId:this.dragState.nodeId}),{layout:yf(this.dragState.projectedLayout),activePlaceholderId:this.dragState.nodeId,placeholdersById:t}}render(){const t=lc(this),r=this.createGrid(t.width,t.height);this.layoutGrid=r;const i=this.getDisplayModel(),s=i.layout,o=this.dragController.status==="active",a=Fr(s),c=a.nodes.map(L=>L.width),u=`${t.width}x${t.height}:${c.join(",")}`;!o&&u!==this.scrollModelKey&&(this.scrollModelKey=u,this.layoutScroll.rebuild({grid:r,nodeWidths:c.map(L=>Te({x:L}))}),this._scrollPosition=this.layoutScroll.scroll.x??this._scrollPosition);const h=$L(s),p=r.unit.x??On,v=r.unit.y??On,g=o?this.dragTrackOffsetXPx:0,E=(this.layoutScroll.translate.x??0)+g,_=Ef(a.nodes.length,r,t.height),C=this.animateNextRender&&!o,N=[`transform: translate(${E}px, ${_}px);`,`transition-duration: ${C?fx:0}ms;`,`pointer-events: ${o?"none":"auto"};`].join(" ");this.animateNextRender=!0,this.style.setProperty("--layout-unit-x",`${p}px`),this.style.setProperty("--layout-unit-y",`${v}px`),this.style.setProperty("--layout-gap",`${he}px`);const P=this.dragState,W={width:(P==null?void 0:P.size.x)??0,height:(P==null?void 0:P.size.y)??0};Re(U`
173
+ `}render(){this._artifact&&(this.setAttribute("type",this._artifact.type),Re(this.template(),this),this.syncWebviewSubscription())}dispatchArtifactWheel(t,r){this.dispatchEvent(new O2("artifact-wheel",{bubbles:!0,composed:!0,deltaX:t.deltaX,deltaY:t.deltaY,shiftKey:t.shiftKey,scrollNative:r}))}syncWebviewSubscription(){const t=this.querySelector("webview");t!==this._subscribedWebview&&(this.unsubscribeFromWebview(),t&&(t.addEventListener("ipc-message",this.handleWebviewIpcMessage),this._subscribedWebview=t))}unsubscribeFromWebview(){this._subscribedWebview&&(this._subscribedWebview.removeEventListener("ipc-message",this.handleWebviewIpcMessage),this._subscribedWebview=null)}iframeTargetOrigin(t){const r=t.getAttribute("sandbox")??"";if(!new Set(r.split(/\s+/).filter(Boolean)).has("allow-same-origin"))return"*";const s=t.getAttribute("src")??t.src;if(!s)return"*";try{return new URL(s,window.location.href).origin}catch{return"*"}}}customElements.define("artifact-view",M2);const we=n=>({type:"px",...n}),Te=n=>({type:"unit",...n}),Ro=2;class z2{constructor(e){b(this,"basis");b(this,"min");b(this,"_gap");b(this,"_viewport");b(this,"_unit");this.basis=e.basis,this.min=e.min,this._viewport=e.viewport,this._gap=e.gap??we({x:he,y:he});const t=this._viewport.x??hr,r=this._viewport.y??ua,i=this._gap.x??he,s=this._gap.y??he,o=t<=fx,a=o?t-i*Ro:Math.min(hr,t-i*Ro),c=o?r-s*Ro:Math.min(ua,r-s*Ro),u=(a-i*(Lt-1))/Lt,h=(c-s*(et-1))/et,p=this.basis.x??0,v=this.basis.y??0,g=this.min.x??0,E=this.min.y??0;this._unit=we(o?{x:Math.max(g,u),y:Math.max(E,h)}:{x:Math.max(g,Math.min(p,u)),y:Math.max(E,Math.min(v,h))})}get unit(){return this._unit}get viewport(){return this._viewport}get gap(){return this._gap}toUnits(e){return Te({x:e.x==null?void 0:e.x/(this._unit.x??1),y:e.y==null?void 0:e.y/(this._unit.y??1)})}toPixels(e){const t=this._unit.x??0,r=this._unit.y??0,i=this._gap.x??he,s=this._gap.y??he,o=e.x==null?void 0:e.x*t+Math.max(0,e.x-1)*i,a=e.y==null?void 0:e.y*r+Math.max(0,e.y-1)*s;return we({x:o,y:a})}}const fr=1e-4,Je=1e-6,N2=40,U2=24;function Ly(n,e){return Math.max(0,n-e*2)}function Oy(n){const e=[0];for(const t of n)e.push((e[e.length-1]??0)+t);return e}function My(n){const e=[0];for(let t=0;t<n.length;t+=1){const r=e[t]??0;e.push(r+n[t]+he)}return e}function zy(n,e,t){if(e<0||e>=n.length)return 0;let r=0,i=0;for(let s=e;s<n.length;s+=1){const o=n[s],a=i===0?o:r+he+o;if(a>t+fr)break;r=a,i+=1}return Math.max(1,i)}function F2(n,e,t){if(e<0||e>=n.length)return 0;let r=0,i=0;for(let s=e;s>=0;s-=1){const o=n[s],a=i===0?o:r+he+o;if(a>t+fr)break;r=a,i+=1}return Math.max(1,i)}function Z2(n,e){if(n.length===0)return 0;let t=0,r=0;for(let i=n.length-1;i>=0;i-=1){const s=n[i],o=r===0?s:t+he+s;if(o>e+fr)break;t=o,r+=1}return Math.max(1,r)}function gh(n,e){if(n.length===0)return 0;const t=Z2(n,e);return Math.max(0,n.length-t)}function vf(n,e,t){if(n.length===0)return 0;const r=zy(n,e,t),i=Math.min(n.length,e+r);if(i<=e)return 0;const s=n.slice(e,i);return s.reduce((o,a)=>o+a,0)+Math.max(0,s.length-1)*he}function au(n,e,t){const r=n[e]??0;return t-r}function Nr(n,e,t,r,i){if(n.length===0)return 0;const s=gh(n,i),o=e[s]??0,a=Math.max(0,Math.min(o,t));let c=0;for(let H=0;H<s;H+=1){const F=e[H]??0,ce=e[H+1]??F;if(a>=F&&a<=ce+fr){c=H;break}c=H+1}const u=Math.min(c+1,s),h=e[c]??0,p=e[u]??h,v=Math.max(p-h,fr),g=u===c?0:(a-h)/v,E=My(n),_=vf(n,c,i),C=vf(n,u,i),N=(r-_)/2,P=(r-C)/2,W=au(E,c,N),L=au(E,u,P);return W+(L-W)*g}function yf(n,e,t,r,i){const s=gh(n,r),o=e[s]??0;let a=0,c=o;for(let u=0;u<N2;u+=1){const h=(a+c)/2;Nr(n,e,h,t,r)>i?a=h:c=h}return(a+c)/2}function bf(n,e,t){const r=My(n),[i,s]=e,o=n.slice(i,s+1),a=o.reduce((u,h)=>u+h,0)+Math.max(0,o.length-1)*he,c=(t-a)/2;return au(r,i,c)}function H2(n,e,t){const r=zy(n,e,t);return[e,Math.min(n.length-1,e+r-1)]}function W2(n,e,t){const r=F2(n,e,t);return[Math.max(0,e-r+1),e]}function G2(n){const e=new Set,t=[];for(const r of n){const i=`${r.nodeRange[0]}:${r.nodeRange[1]}`;if(e.has(i))continue;const s=t[t.length-1];s&&Math.abs(s.anchor-r.anchor)<=Je||(e.add(i),t.push(r))}return t}function V2(n){const{nodeCols:e,nodeWidthsPx:t,viewportWidthPx:r}=n;if(e.length===0||t.length===0)return{viewspans:[],minScroll:0,maxScroll:0};const i=n.gapPx??he,s=Ly(r,i),o=Oy(e),a=gh(t,s),c=o[a]??0,u=[];for(let h=0;h<=a;h+=1){const p=H2(t,h,s),v=bf(t,p,r),g=yf(t,o,r,s,v);u.push({nodeRange:p,anchor:Math.max(0,Math.min(c,g))})}for(let h=t.length-1;h>=0;h-=1){const p=W2(t,h,s),v=`${p[0]}:${p[1]}`;if(u.some(_=>`${_.nodeRange[0]}:${_.nodeRange[1]}`===v))continue;const g=bf(t,p,r),E=yf(t,o,r,s,g);u.push({nodeRange:p,anchor:Math.max(0,Math.min(c,E))})}return u.sort((h,p)=>Math.abs(h.anchor-p.anchor)>Je?h.anchor-p.anchor:h.nodeRange[0]!==p.nodeRange[0]?h.nodeRange[0]-p.nodeRange[0]:h.nodeRange[1]-p.nodeRange[1]),{viewspans:G2(u),minScroll:0,maxScroll:c}}function ac(n,e){var i;let t=0,r=Number.POSITIVE_INFINITY;for(let s=0;s<n.length;s+=1){const o=Math.abs((((i=n[s])==null?void 0:i.anchor)??0)-e);if(o+Je<r){r=o,t=s;continue}Math.abs(o-r)<=Je&&s<t&&(t=s)}return t}function B2(n,e,t){return t<=0?0:Math.max(0,Math.min(t-1,n+e))}function Rr(n,e,t){return Math.max(e,Math.min(t,n))}function j2(n,e){var t;for(let r=0;r<n.length;r+=1)if(Math.abs((((t=n[r])==null?void 0:t.anchor)??0)-e)<=Je)return r;return-1}function q2(n,e,t){var i,s,o,a;if(n.length===0)return e;const r=j2(n,e);if(r>=0){const c=n[r];if(!c)return e;if(t>0){const v=c.nodeRange[0]+1,g=n.filter(_=>_.nodeRange[0]===v);if(g.length===0)return((i=n[n.length-1])==null?void 0:i.anchor)??e;let E=g[0];for(const _ of g)_.nodeRange[1]>E.nodeRange[1]&&(E=_);return E.anchor}const u=c.nodeRange[1]-1,h=n.filter(v=>v.nodeRange[1]===u);if(h.length===0)return((s=n[0])==null?void 0:s.anchor)??e;let p=h[0];for(const v of h)v.nodeRange[0]<p.nodeRange[0]&&(p=v);return p.anchor}if(t>0){for(const c of n)if(c.anchor>e+Je)return c.anchor;return((o=n[n.length-1])==null?void 0:o.anchor)??e}for(let c=n.length-1;c>=0;c-=1){const u=n[c];if(u&&u.anchor<e-Je)return u.anchor}return((a=n[0])==null?void 0:a.anchor)??e}class Y2 extends wt{constructor(t){super();b(this,"_scroll",0);b(this,"minScroll",0);b(this,"maxScroll",0);b(this,"viewspans",[]);b(this,"activeViewspanIndex",null);b(this,"nodeWidthsPx",[]);b(this,"boundaryCols",[0]);b(this,"viewportWidthPx",0);b(this,"framedViewportWidthPx",0);this._scroll=(t==null?void 0:t.x)??0}get scroll(){return Te({x:this._scroll})}get translate(){return we({x:Nr(this.nodeWidthsPx,this.boundaryCols,this._scroll,this.viewportWidthPx,this.framedViewportWidthPx)})}set scroll(t){const r=Rr(t.x??this._scroll,this.minScroll,this.maxScroll);Math.abs(r-this._scroll)<=Je||(this._scroll=r,this.activeViewspanIndex=null,this.dispatchEvent(new Pr("layout-scroll",{scroll:this.scroll})))}rebuild(t){const r=t.nodeWidths.map(u=>Math.max(0,u.x??0)),i=r.map(u=>t.grid.toPixels(Te({x:u})).x??0),s=t.grid.viewport.x??0,o=t.grid.gap.x??he,a=V2({nodeCols:r,nodeWidthsPx:i,viewportWidthPx:s,gapPx:o});this.nodeWidthsPx=i,this.boundaryCols=Oy(r),this.viewportWidthPx=s,this.framedViewportWidthPx=Ly(s,o),this.viewspans=a.viewspans,this.minScroll=a.minScroll,this.maxScroll=a.maxScroll,this.activeViewspanIndex=null;const c=Rr(this._scroll,this.minScroll,this.maxScroll);Math.abs(c-this._scroll)>Je&&(this._scroll=c,this.dispatchEvent(new Pr("layout-scroll",{scroll:this.scroll})))}step(t){var a;if(this.viewspans.length===0)return;const r=this.activeViewspanIndex??ac(this.viewspans,this._scroll),i=B2(r,t,this.viewspans.length),s=((a=this.viewspans[i])==null?void 0:a.anchor)??this._scroll,o=Rr(s,this.minScroll,this.maxScroll);this.activeViewspanIndex=i,!(Math.abs(o-this._scroll)<=Je)&&(this._scroll=o,this.dispatchEvent(new Pr("layout-scroll",{scroll:this.scroll})))}snap(t){var s;if(this.viewspans.length===0)return;const r=t===void 0?((s=this.viewspans[ac(this.viewspans,this._scroll)])==null?void 0:s.anchor)??this._scroll:q2(this.viewspans,this._scroll,t),i=Rr(r,this.minScroll,this.maxScroll);this.activeViewspanIndex=ac(this.viewspans,i),!(Math.abs(i-this._scroll)<=Je)&&(this._scroll=i,this.dispatchEvent(new Pr("layout-scroll",{scroll:this.scroll})))}wheel(t){const r=Rr(this._scroll+(t.x??0),this.minScroll,this.maxScroll);this.activeViewspanIndex=null,!(Math.abs(r-this._scroll)<=Je)&&(this._scroll=r,this.dispatchEvent(new Pr("layout-scroll",{scroll:this.scroll})))}wheelPixels(t){const r=t.x??0;if(Math.abs(r)<=fr)return;this.activeViewspanIndex=null;const i=Nr(this.nodeWidthsPx,this.boundaryCols,this._scroll,this.viewportWidthPx,this.framedViewportWidthPx),s=i-r,o=Nr(this.nodeWidthsPx,this.boundaryCols,this.maxScroll,this.viewportWidthPx,this.framedViewportWidthPx),a=Nr(this.nodeWidthsPx,this.boundaryCols,this.minScroll,this.viewportWidthPx,this.framedViewportWidthPx),c=Math.max(o,Math.min(a,s));if(Math.abs(c-i)<=fr)return;let u=this.minScroll,h=this.maxScroll;for(let v=0;v<U2;v+=1){const g=(u+h)/2;Nr(this.nodeWidthsPx,this.boundaryCols,g,this.viewportWidthPx,this.framedViewportWidthPx)>c?u=g:h=g}const p=Rr((u+h)/2,this.minScroll,this.maxScroll);Math.abs(p-this._scroll)<=Je||(this._scroll=p,this.dispatchEvent(new Pr("layout-scroll",{scroll:this.scroll})))}}const lc={"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}},X2=["stack-above","stack-below","reorder-before","reorder-after"];function cc(n,e){return{left:n.left+n.width*e.left,top:n.top+n.height*e.top,width:n.width*e.width,height:n.height*e.height}}function Cn(n,e,t){return n>=t.left&&n<t.left+t.width&&e>=t.top&&e<t.top+t.height}function mh(n,e){for(const t of n){if(t.type==="card"&&t.id===e)return t;if(t.type==="stack")for(const r of t.children){if(r.type==="card"&&r.id===e)return r;if(r.type==="row"){for(const i of r.children)if(i.id===e)return i}}}return null}function lu(n){return n.height===et||n.height===mn?{...n,height:mn}:n}function cu(n){return n.height===mn?{...n,height:et}:n}function K2(n,e,t,r){const i=n.findIndex(h=>h.type==="stack"&&h.id===e);if(i===-1)return n;const s=n[i];if(!s||s.type!=="stack")return n;const o=s.children.find(h=>h.type==="card"&&h.id===t);if(!o||o.type!=="card")return n;const a=s.children.filter(h=>h.id!==t);if(a.length===s.children.length||a.length<1)return n;const c=[...n];if(a.length===1){const[h]=a;c[i]=h.type==="card"?cu(h):h}else c[i]={...s,children:a};const u=Math.max(0,Math.min(r,c.length));return c.splice(u,0,cu(o)),c}const J2=tt(),Q2=tt(),eL=50;function tL(n,e){if(n.type!==e.type)return!1;switch(n.type){case"reorder":return e.index===n.index;case"stack":return e.targetCardId===n.targetCardId&&e.position===n.position;case"stack-child-noop":return!0;case"stack-child-extract":return e.toIndex===n.toIndex;case"stack-child-reorder":return e.position===n.position;default:return!1}}function ao(n){return{id:n.id,type:"drop-target",width:n.width,height:n.height}}function wf(n){return n.map(rL)}function nL(n){return n.type==="drop-target"?{id:n.id,type:"card",artifactID:n.id,width:n.width,height:n.height}:n}function rL(n){return n.type==="drop-target"?{id:n.id,type:"card",artifactID:n.id,width:n.width,height:n.height}:n.type==="stack"?{...n,children:n.children.map(nL)}:n}function Ny(n,e){return n.find(r=>r.type==="card"&&r.id===e)??null}function Sf(n,e){return n.find(r=>r.type==="stack"&&r.id===e)??null}function iL(n,e){const t=[...e],r=t.findIndex(a=>a.type==="card"&&a.id===n.nodeId);if(r===-1)return null;const i=t[r];if(!i||i.type!=="card")return null;t.splice(r,1);const s=Math.max(0,Math.min(n.lastReorderIndex,t.length));t.splice(s,0,i);const o=t.findIndex(a=>a.type==="card"&&a.id===n.nodeId);return o===-1?null:{base:t,visualDraggedIndex:o}}function sL(n,e,t,r){const i=[...n.base];i.splice(n.visualDraggedIndex,1);const s=i.findIndex(v=>v.type==="card"&&v.id===t.targetCardId),o=s===-1?null:i[s];if(!o||o.type!=="card")return null;const a=Ny(r,e.nodeId);if(!a)return null;const c=lu(a),u=lu(o),h=ao(c),p=t.position==="above"?[h,u]:[u,h];return i[s]={id:o.id,type:"stack",children:p},i}function uc(n,e){return n.parentStackId?aL(n,e):oL(n,e)}function oL(n,e){const t=n.hitTarget;if(t.type==="reorder"){const r=e[n.sourceIndex];if(!r||r.type!=="card")return[...e];const i=[...e];return i.splice(n.sourceIndex,1),i.splice(t.index,0,ao(r)),i}if(t.type==="stack"){const r=iL(n,e);return r?sL(r,n,t,e)??[...e]:[...e]}return[...e]}function aL(n,e){const t=n.hitTarget;switch(t.type){case"stack-child-reorder":return lL(n,e,t.position);case"stack-child-extract":return cL(n,e,t.toIndex);case"stack-child-noop":return uL(n,e);default:return[...e]}}function lL(n,e,t){const r=e.findIndex(v=>v.type==="stack"&&v.id===n.parentStackId);if(r===-1)return[...e];const i=e[r];if(!i||i.type!=="stack")return[...e];if(!i.children.every(v=>v.type==="card"))return[...e];const s=i.children,o=s.findIndex(v=>v.id===n.nodeId);if(o===-1)return[...e];const a=s[o],c=s.filter(v=>v.id!==n.nodeId),u=ao(a),h=t==="above"?[u,...c]:[...c,u],p=[...e];return p[r]={...i,children:h},p}function cL(n,e,t){if(!n.parentStackId)return[...e];const r=K2(e,n.parentStackId,n.nodeId,t);if(r===e)return[...e];const i=r.findIndex(a=>a.type==="card"&&a.id===n.nodeId);if(i===-1)return[...e];const s=r[i];if(!s||s.type!=="card")return[...e];const o=[...r];return o[i]=ao(s),o}function uL(n,e){const t=e.findIndex(c=>c.type==="stack"&&c.id===n.parentStackId);if(t===-1)return[...e];const r=e[t];if(!r||r.type!=="stack")return[...e];const i=r.children.findIndex(c=>c.type==="card"&&c.id===n.nodeId);if(i===-1)return[...e];const s=r.children[i];if(!s||s.type!=="card")return[...e];const o=[...e],a=[...r.children];return a[i]=ao(s),o[t]={...r,children:a},o}function hL(n,e){return e.find(r=>r.type==="stack"&&r.id===n.id)?n.id:Xu()}function dL(n,e,t){if(n.type==="drop-target"){const r=mh(e,t);if(!r)throw new Error(`finalize: missing dragged card ${t}`);return lu(r)}return n}function pL(n,e,t){const r=n.children.map(s=>dL(s,e,t));return{id:hL(n,e),type:"stack",children:r}}function fL(n,e,t){if(n.type==="drop-target"){const r=mh(e,t);if(!r)throw new Error(`finalize: missing dragged card ${t}`);return Ny(e,t)!==null?r:cu(r)}return n.type==="card"||n.type==="row"?n:pL(n,e,t)}function gL(n,e,t){return n.map(r=>fL(r,e,t))}function mL(n,e){return JSON.stringify(n)===JSON.stringify(e)}const vL=ki(wt);class yL extends vL{constructor(t={}){super();b(this,"pending",null);b(this,"active",null)}start(t){if(this.pending||this.active)return;const r=t.pointer.x??0,i=t.pointer.y??0;this.pending={startX:r,startY:i,grabOffsetX:t.grabOffset.x??0,grabOffsetY:t.grabOffset.y??0,nodeId:t.nodeId,sourceIndex:t.source.index,parentStackId:t.source.parentId,width:t.size.x??0,height:t.size.y??0,baseLayout:t.layout}}update(t){const r=t.pointer.x??0,i=t.pointer.y??0,s=this.pending;if(s){const u=r-s.startX,h=i-s.startY;Math.hypot(u,h)>=mx&&(this.pending=null,this.active={...s,pointerX:r,pointerY:i,hitTarget:{type:"reorder",index:s.sourceIndex},lastReorderIndex:s.sourceIndex},this.emitDrag(),this.dispatchEvent(new K("change")));return}if(!this.active)return;const o=uc(this.active,this.active.baseLayout),a=this.getHitTargetForPointer(r,i,t,o),c=a.type==="reorder"?a.index:this.active.lastReorderIndex;this.active.pointerX===r&&this.active.pointerY===i&&tL(this.active.hitTarget,a)&&this.active.lastReorderIndex===c||(this.active={...this.active,pointerX:r,pointerY:i,hitTarget:a,lastReorderIndex:c},this.emitDrag(),this.dispatchEvent(new K("change")))}drop(){if(this.pending){this.cancel();return}if(!this.active)return;const t=this.active.baseLayout;let r=null;try{const i=uc(this.active,t),s=gL(i,t,this.active.nodeId);mL(s,t)||(r=s)}catch{r=null}this.reset(),r&&this.dispatchEvent(new Q2("drop",{layout:r})),this.dispatchEvent(new K("change"))}cancel(){!this.pending&&!this.active||(this.reset(),this.dispatchEvent(new K("change")))}dispose(){this.reset()}get status(){return this.active?"active":this.pending?"pending":"idle"}reset(){this.pending=null,this.active=null}emitDrag(){if(!this.active)return;const t=uc(this.active,this.active.baseLayout);this.dispatchEvent(new J2("drag",{nodeId:this.active.nodeId,source:{index:this.active.sourceIndex,parentId:this.active.parentStackId},grabOffset:we({x:this.active.grabOffsetX,y:this.active.grabOffsetY}),pointer:we({x:this.active.pointerX,y:this.active.pointerY}),size:we({x:this.active.width,y:this.active.height}),projectedLayout:t}))}getHitTargetForPointer(t,r,i,s){return this.active?this.isPointerInsideDragBounds(t,r,i.viewport)?this.active.parentStackId?this.getStackChildHitTarget(t,r,i,s):this.getTopLevelCardHitTarget(t,r,i,s):{type:"reorder",index:this.active.sourceIndex}:{type:"reorder",index:0}}getStackChildHitTarget(t,r,i,s){var u;if(!((u=this.active)!=null&&u.parentStackId))return{type:"stack-child-noop"};const o=this.getSourceStackInteractionRect(i.geometry);if(o&&Cn(t,r,o)){const h=o.top+o.height/2;return{type:"stack-child-reorder",position:r<h?"above":"below"}}const a=this.getSourceRemainingSiblingRect(i.geometry);if(a&&Cn(t,r,a)){const h=a.top+a.height/2;return{type:"stack-child-reorder",position:r<h?"above":"below"}}return{type:"stack-child-extract",toIndex:this.getTopLevelReorderIndexForPointer(t,r,i,s)}}getSourceRemainingSiblingRect(t){var s,o;if(!((s=this.active)!=null&&s.parentStackId))return;const r=Sf(this.active.baseLayout,this.active.parentStackId);if(!r)return;const i=r.children.find(a=>{var c;return a.type==="card"&&a.id!==((c=this.active)==null?void 0:c.nodeId)});if(i)return(o=t.find(a=>a.id===i.id))==null?void 0:o.rect}getSourceStackInteractionRect(t){var o;if(!((o=this.active)!=null&&o.parentStackId))return;const r=t.find(a=>{var c;return a.id===((c=this.active)==null?void 0:c.parentStackId)});if(r)return this.active.sourceStackRect=r.rect,r.rect;const i=Sf(this.active.baseLayout,this.active.parentStackId);if(!i)return this.active.sourceStackRect;const s=i.children.find(a=>{var c;return a.type==="card"&&a.id!==((c=this.active)==null?void 0:c.nodeId)});if(s){const a=t.find(c=>c.id===s.id);if(a)return a.rect}return this.active.sourceStackRect}getTopLevelCardHitTarget(t,r,i,s){var g,E,_;const o=this.getTopLevelZoneNodes(i.geometry,s);if(o.length===0)return{type:"reorder",index:((g=this.active)==null?void 0:g.sourceIndex)??0};const c=(i.effectiveVelocity??0)<=eL;for(const C of o){const N=C.rect;if(!Cn(t,r,N))continue;const P=this.resolveTopLevelTargetForCard(t,r,C,C.logicalIndex,c);if(P)return P;if(!c&&((E=this.active)!=null&&E.hitTarget))return this.active.hitTarget}const u=this.getNearestTargetableZone(t,o);if(!u)return{type:"reorder",index:((_=this.active)==null?void 0:_.sourceIndex)??0};const h=Math.max(u.rect.left,Math.min(u.rect.left+u.rect.width,t)),p=this.resolveTopLevelTargetForCard(h,r,u,u.logicalIndex,c);if(p)return p;const v=u.rect.left+u.rect.width/2;return{type:"reorder",index:t<v?u.logicalIndex:u.logicalIndex+1}}getTopLevelReorderIndexForPointer(t,r,i,s){var u,h;const o=this.getTopLevelZoneNodes(i.geometry,s);if(o.length===0)return((u=this.active)==null?void 0:u.sourceIndex)??0;for(const p of o){if(!Cn(t,r,p.rect))continue;const v=cc(p.rect,lc["reorder-before"]);if(Cn(t,r,v))return p.logicalIndex;const g=cc(p.rect,lc["reorder-after"]);if(Cn(t,r,g))return p.logicalIndex+1}const a=this.getNearestTargetableZone(t,o);if(!a)return((h=this.active)==null?void 0:h.sourceIndex)??0;const c=a.rect.left+a.rect.width/2;return t<c?a.logicalIndex:a.logicalIndex+1}getTopLevelZoneNodes(t,r){const i=new Map(r.map(a=>[a.id,a])),s=[];let o=0;for(const a of t){const c=i.get(a.id);c&&c.type!=="drop-target"&&(c.type==="card"||c.type==="stack")&&(s.push({id:c.id,rect:a.rect,logicalIndex:o}),o+=1)}return s}resolveTopLevelTargetForCard(t,r,i,s,o){const a=i.rect;for(const c of X2){if(!o&&(c==="stack-above"||c==="stack-below"))continue;const u=lc[c],h=cc(a,u);if(Cn(t,r,h))return c==="stack-above"?{type:"stack",targetCardId:i.id,position:"above"}:c==="stack-below"?{type:"stack",targetCardId:i.id,position:"below"}:c==="reorder-before"?{type:"reorder",index:s}:{type:"reorder",index:s+1}}return null}getNearestTargetableZone(t,r){let i=null,s=Number.POSITIVE_INFINITY;for(const o of r){const a=o.rect.left,c=o.rect.left+o.rect.width,u=t<a?a-t:t>c?t-c:0;u<s&&(s=u,i=o)}return i}isPointerInsideDragBounds(t,r,i){return t>=i.left&&t<=i.left+i.width&&r>=i.top&&r<=i.top+i.height}}const _f=60,bL=80,kf=.5,Ef=10;class wL{constructor(){b(this,"awaitingFreshWheelGesture",!1);b(this,"lastWheelEventAt",Number.NEGATIVE_INFINITY);b(this,"lastWheelDeltaX",0);b(this,"activeGestureType","none");b(this,"lastWheelGestureAt",Number.NEGATIVE_INFINITY)}markKeyboardNavigation(e){this.awaitingFreshWheelGesture=!0,this.lastWheelEventAt=e,this.activeGestureType="none"}reset(){this.awaitingFreshWheelGesture=!1,this.lastWheelEventAt=Number.NEGATIVE_INFINITY,this.lastWheelDeltaX=0,this.activeGestureType="none",this.lastWheelGestureAt=Number.NEGATIVE_INFINITY}decide(e){const{now:t,shiftKey:r,deltaX:i,deltaY:s,overArtifactContent:o}=e;t-this.lastWheelGestureAt>=_f&&(this.activeGestureType="none");const c=r&&s!==0,u=c?s:i,h=Math.abs(u),p=Math.abs(s);return this.activeGestureType==="vertical-artifact"&&o?h>=kf&&h>=p*Ef?this.classifyHorizontal(t,u):(this.lastWheelGestureAt=t,{type:"scroll-native"}):this.activeGestureType==="horizontal-filmstrip"?!c&&o&&p>0&&p>=h*Ef?(this.activeGestureType="vertical-artifact",this.lastWheelGestureAt=t,{type:"scroll-native"}):this.classifyHorizontal(t,u):h<kf?(o&&(this.activeGestureType="vertical-artifact"),this.lastWheelGestureAt=t,{type:"scroll-native"}):c||h>p?this.classifyHorizontal(t,u):p>h?(o&&(this.activeGestureType="vertical-artifact"),this.lastWheelGestureAt=t,{type:"scroll-native"}):o?(this.activeGestureType="vertical-artifact",this.lastWheelGestureAt=t,{type:"scroll-native"}):this.classifyHorizontal(t,u)}classifyHorizontal(e,t){const r=e-this.lastWheelEventAt,i=Math.sign(this.lastWheelDeltaX),s=Math.sign(t),o=i!==0&&s!==0&&i!==s,a=i!==0&&Math.abs(t)>=Math.abs(this.lastWheelDeltaX)+bL;return this.awaitingFreshWheelGesture&&r<_f&&!o&&!a?{type:"ignore"}:(this.lastWheelEventAt=e,this.lastWheelDeltaX=t,this.lastWheelGestureAt=e,this.awaitingFreshWheelGesture=!1,this.activeGestureType="horizontal-filmstrip",{type:"scroll-horizontal",horizontalDelta:t})}}const SL=100,_L=1e3;class kL{constructor(e,t){b(this,"_status","idle");b(this,"cumulativeOffset",0);b(this,"samples",[]);b(this,"scroll");b(this,"setAnimating");this.scroll=e,this.setAnimating=t}get status(){return this._status}start(e){this._status="active",this.cumulativeOffset=0,this.samples=[{time:e,offset:0}]}move(e,t){this._status==="active"&&(this.cumulativeOffset+=t,this.samples.push({time:e,offset:this.cumulativeOffset}),this.pruneSamples(e),this.setAnimating(!1),this.scroll.wheelPixels(we({x:-t})))}end(){if(this._status!=="active")return;const e=this.computeVelocityPxPerSec();this.setAnimating(!0),Math.abs(e)<yx?this.scroll.snap():this.scroll.snap(e>0?-1:1),this.reset()}cancel(){this._status==="active"&&(this.setAnimating(!0),this.scroll.snap(),this.reset())}reset(){this._status="idle",this.cumulativeOffset=0,this.samples=[]}pruneSamples(e){const t=e-SL;let r=0;for(let i=0;i<this.samples.length;i+=1){if(this.samples[i].time>=t){r=i;break}r=i+1}if(r>0){const i=Math.max(0,r-1);this.samples=this.samples.slice(i)}}computeVelocityPxPerSec(){if(this.samples.length<2)return 0;const e=this.samples[0],t=this.samples[this.samples.length-1],r=t.time-e.time;return r<=0?0:(t.offset-e.offset)/r*_L}}const EL=2,xf=1e3,Do=1e-4;function xL(n){return n.replace(/["\\]/g,"\\$&")}function Af(n,e,t){if(n===0)return 0;const r=e.toPixels(Te({y:et})).y??0;return(t-r)/EL}function hc(n){const e=n.clientWidth>0?n.clientWidth:hr,t=n.clientHeight>0?n.clientHeight:ua;let r=0,i=0;if(n.isConnected){const o=getComputedStyle(n);r=parseFloat(o.paddingTop)||0,i=parseFloat(o.paddingBottom)||0}const s=Math.max(1,t-r-i);return{width:e,height:s,offsetY:r}}class AL extends Event{constructor(t){super("scroll",{bubbles:!0,composed:!0});b(this,"scrollPosition");this.scrollPosition=t}}class Uy extends Event{constructor(t){super("layout-change",{bubbles:!0,composed:!0});b(this,"layout");this.layout=t}}class $L extends HTMLElement{constructor(){super();b(this,"_layout",[]);b(this,"_scrollPosition",0);b(this,"layoutGrid",null);b(this,"layoutScroll",new Y2(Te({x:0})));b(this,"scrollModelKey","");b(this,"resizeObserver",null);b(this,"renderPending",!1);b(this,"animateNextRender",!0);b(this,"wheelGesture",new wL);b(this,"swipeGesture",new kL(this.layoutScroll,t=>{this.animateNextRender=t}));b(this,"swipePointerId",null);b(this,"swipeStartX",0);b(this,"swipeStartY",0);b(this,"swipeLastX",0);b(this,"swipeActive",!1);b(this,"swipeShouldSuppressClick",!1);b(this,"swipeListenersAttached",!1);b(this,"dragController",new yL);b(this,"dragState",null);b(this,"activeDragPointerId",null);b(this,"dragListenersAttached",!1);b(this,"dragFrame",0);b(this,"lastDragFrameTime",0);b(this,"lastPointerX",0);b(this,"lastPointerY",0);b(this,"pointerVelocityPxPerSec",0);b(this,"scrollVelocityPxPerSec",0);b(this,"motionSampleTime",0);b(this,"motionSampleX",0);b(this,"motionSampleY",0);b(this,"dragTrackOffsetXPx",0);b(this,"previousProjectedLayoutForOffset",null);b(this,"renderContent",()=>U``);b(this,"onDragControllerChange",()=>{this.dragController.status==="idle"&&(this.dragState=null,this.dragTrackOffsetXPx=0,this.previousProjectedLayoutForOffset=null),this.scheduleRender()});b(this,"onDragControllerDrag",t=>{const r=wf(t.projectedLayout),i=this.shouldApplyTrackOffset(t.projectedLayout,t.source.parentId),s=t.source.parentId?this.getStackChildAnchorCardId(t.source.parentId,t.nodeId):null;this.dragTrackOffsetXPx=i?this.computeDragTrackOffset(this.previousProjectedLayoutForOffset,r,t.nodeId,t.source.parentId,s,this.dragTrackOffsetXPx):0,this.previousProjectedLayoutForOffset=r,this.dragState={nodeId:t.nodeId,source:t.source,grabOffset:t.grabOffset,pointer:t.pointer,size:t.size,projectedLayout:t.projectedLayout},this.scheduleRender()});b(this,"onDragControllerDrop",t=>{this.dragState=null,this.dragTrackOffsetXPx=0,this.previousProjectedLayoutForOffset=null,this.commitLayout(t.layout)});b(this,"onLayoutScrollInternal",t=>{const i=t.scroll.x??0;Math.abs(i-this._scrollPosition)<Do||(this._scrollPosition=i,this.emitScrollPositionChanged(i),this.scheduleRender())});b(this,"handleKeyDown",t=>{if(t.key==="Escape"&&this.dragController.status!=="idle"){t.preventDefault(),this.stopDragFrameLoop(),this.releaseActiveDragPointerCapture(),this.dragController.cancel(),this.detachDragListeners();return}this.dragController.status==="idle"&&(t.key==="ArrowRight"?(t.preventDefault(),this.wheelGesture.markKeyboardNavigation(Date.now()),this.shiftWindow(1)):t.key==="ArrowLeft"&&(t.preventDefault(),this.wheelGesture.markKeyboardNavigation(Date.now()),this.shiftWindow(-1)))});b(this,"handleWheel",t=>{if(this._layout.length===0)return;const r=this.wheelGesture.decide({now:Date.now(),shiftKey:t.shiftKey,deltaX:t.deltaX,deltaY:t.deltaY,overArtifactContent:!1});r.type==="scroll-horizontal"&&(t.preventDefault(),this.applyHorizontalWheel(r.horizontalDelta))});b(this,"handleWindowMessage",t=>{if(this._layout.length===0)return;const r=this.findManagedArtifactFrame(t.source);if(r&&this.isTrustedArtifactFrameMessage(t,r)){if(k2(t.data)){const i=typeof performance<"u"?performance.now():Date.now();this.swipeGesture.status==="idle"&&this.swipeGesture.start(i),this.swipeGesture.move(i,t.data.deltaX);return}if(E2(t.data)){this.swipeGesture.status==="active"&&this.swipeGesture.end();return}}});b(this,"handleArtifactWheel",t=>{if(this._layout.length===0)return;const r=this.wheelGesture.decide({now:Date.now(),shiftKey:t.shiftKey,deltaX:t.deltaX,deltaY:t.deltaY,overArtifactContent:!0});if(r.type==="scroll-horizontal"){this.applyHorizontalWheel(r.horizontalDelta);return}r.type==="scroll-native"&&t.scrollNative(t.deltaY)});b(this,"handlePointerDown",t=>{if(t.button!==0||this.dragController.status!=="idle")return;const r=t.target;if(!(r instanceof Element))return;const i=r.closest("[drag-handle]")!==null,s=r.closest("button, input, textarea, select, a, [role='button']")!==null;if(t.pointerType==="touch"&&!i&&!s&&this._layout.length>0){this.beginSwipeTracking(t);return}if(!i||s)return;const o=r.closest(".card-slot");if(!o)return;const a=o.getAttribute("data-layout-node-id");if(!a)return;const c=IL(this._layout,a);if(!c)return;const u=o.getBoundingClientRect();this.lastPointerX=t.clientX,this.lastPointerY=t.clientY,this.resetMotionTracking(t.clientX,t.clientY),this.focus(),this.dragController.start({nodeId:a,source:{index:c.topLevelIndex,parentId:c.sourceStackId},pointer:we({x:t.clientX,y:t.clientY}),grabOffset:we({x:t.clientX-u.left,y:t.clientY-u.top}),size:we({x:u.width,y:u.height}),layout:this._layout}),this.attachDragListeners(),this.activeDragPointerId=t.pointerId;try{this.setPointerCapture(t.pointerId)}catch{}t.preventDefault()});b(this,"handleSwipePointerMove",t=>{if(this.swipePointerId===null||t.pointerId!==this.swipePointerId)return;if(!this.swipeActive){const i=t.clientX-this.swipeStartX,s=t.clientY-this.swipeStartY,o=Math.abs(i),a=Math.abs(s);if(o<$p&&a<$p)return;if(a>=o){this.endSwipeTracking();return}this.swipeActive=!0,this.swipeShouldSuppressClick=!0;try{this.setPointerCapture(t.pointerId)}catch{}this.swipeGesture.start(t.timeStamp)}const r=t.clientX-this.swipeLastX;this.swipeLastX=t.clientX,this.swipeGesture.move(t.timeStamp,r),t.preventDefault()});b(this,"handleSwipePointerUp",t=>{this.swipePointerId===null||t.pointerId!==this.swipePointerId||(this.swipeActive&&this.swipeGesture.end(),this.releaseSwipePointerCapture(t.pointerId),this.endSwipeTracking())});b(this,"handleSwipePointerCancel",t=>{this.swipePointerId===null||t.pointerId!==this.swipePointerId||(this.swipeActive&&this.swipeGesture.cancel(),this.releaseSwipePointerCapture(t.pointerId),this.endSwipeTracking())});b(this,"handleSwipeWindowBlur",()=>{this.swipePointerId!==null&&this.swipeActive&&this.swipeGesture.cancel(),this.swipePointerId!==null&&this.releaseSwipePointerCapture(this.swipePointerId),this.endSwipeTracking()});b(this,"handleSwipeClick",t=>{this.swipeShouldSuppressClick&&(this.swipeShouldSuppressClick=!1,t.preventDefault(),t.stopPropagation(),typeof t.stopImmediatePropagation=="function"&&t.stopImmediatePropagation())});b(this,"handleWindowPointerMove",t=>{this.lastPointerX=t.clientX,this.lastPointerY=t.clientY,this.updatePointerVelocity(t.clientX,t.clientY),this.syncDragTargetForLatestPointer(),this.ensureDragFrameLoop()});b(this,"handleWindowPointerUp",t=>{this.stopDragFrameLoop(),this.releasePointerCaptureForEvent(t.pointerId),this.dragController.drop(),this.clearMotionTracking(),this.detachDragListeners()});b(this,"handleWindowPointerCancel",t=>{this.stopDragFrameLoop(),this.releasePointerCaptureForEvent(t.pointerId),this.dragController.cancel(),this.clearMotionTracking(),this.detachDragListeners()});b(this,"handleWindowBlur",()=>{this.releaseActiveDragPointerCapture(),this.stopDragFrameLoop(),this.dragController.cancel(),this.clearMotionTracking(),this.detachDragListeners()});b(this,"runDragFrame",t=>{if(this.dragController.status==="idle"){this.dragFrame=0;return}const r=Math.max(0,t-this.lastDragFrameTime)/xf;this.lastDragFrameTime=t,this.samplePointerVelocityAt(t,this.lastPointerX,this.lastPointerY);const i=this.getBoundingClientRect(),s=this.clampPointerToViewport(this.lastPointerX,this.lastPointerY,i),o=this.getDragEdgeScrollDeltaPixels(s.x,i,r);this.scrollVelocityPxPerSec=r>Do?Math.abs(o)/r:0,Math.abs(o)>Do&&(this.animateNextRender=!1,this.layoutScroll.wheelPixels(we({x:o}))),this.dragController.status==="active"&&this.syncDragTarget(s.x,s.y,i),this.dragFrame=requestAnimationFrame(this.runDragFrame)});this.dragController.addEventListener("change",this.onDragControllerChange),this.dragController.addEventListener("drag",this.onDragControllerDrag),this.dragController.addEventListener("drop",this.onDragControllerDrop),this.layoutScroll.addEventListener("layout-scroll",this.onLayoutScrollInternal)}set layout(t){this._layout=[...t],this.stopDragFrameLoop(),this.dragController.cancel(),this.scrollModelKey="",this.syncScrollModel(),this.layoutScroll.scroll=Te({x:this._scrollPosition}),this.scheduleRender()}get layout(){return this._layout}commitLayout(t){this.layout=t,this.emitLayoutChanged()}set scrollPosition(t){Math.abs(t-this._scrollPosition)<Do||(this.animateNextRender=!1,this.syncScrollModel(),this.layoutScroll.scroll=Te({x:t}))}get scrollPosition(){return this._scrollPosition}focusArtifact(t){const r=Fr(this._layout),i=r.nodes.findIndex(o=>o.cards.some(a=>a.artifactID===t));if(i<0)return;let s=0;for(let o=0;o<i;o+=1)s+=r.nodes[o].width;this.scrollPosition=s,queueMicrotask(()=>{const o=this.querySelector(`.card-slot[data-layout-card-id="${xL(t)}"]`);if(!o)return;o.classList.remove("card-focus-pulse"),o.offsetHeight,o.classList.add("card-focus-pulse");const a=()=>{o.classList.remove("card-focus-pulse"),o.removeEventListener("animationend",a)};o.addEventListener("animationend",a)})}connectedCallback(){this.hasAttribute("tabindex")||(this.tabIndex=0),this.focus(),this.addEventListener("keydown",this.handleKeyDown),this.addEventListener("wheel",this.handleWheel,{passive:!1}),this.addEventListener("pointerdown",this.handlePointerDown),this.addEventListener("artifact-wheel",this.handleArtifactWheel),window.addEventListener("message",this.handleWindowMessage),typeof ResizeObserver<"u"&&(this.resizeObserver=new ResizeObserver(()=>this.render()),this.resizeObserver.observe(this)),this.render()}disconnectedCallback(){var t;this.removeEventListener("keydown",this.handleKeyDown),this.removeEventListener("wheel",this.handleWheel),this.removeEventListener("pointerdown",this.handlePointerDown),this.removeEventListener("artifact-wheel",this.handleArtifactWheel),window.removeEventListener("message",this.handleWindowMessage),(t=this.resizeObserver)==null||t.disconnect(),this.resizeObserver=null,this.wheelGesture.reset(),this.detachDragListeners(),this.swipeGesture.status==="active"&&this.swipeGesture.cancel(),this.swipePointerId!==null&&this.releaseSwipePointerCapture(this.swipePointerId),this.endSwipeTracking(),this.dragController.removeEventListener("change",this.onDragControllerChange),this.dragController.removeEventListener("drag",this.onDragControllerDrag),this.dragController.removeEventListener("drop",this.onDragControllerDrop),this.layoutScroll.removeEventListener("layout-scroll",this.onLayoutScrollInternal),this.dragController.dispose(),this.stopDragFrameLoop()}scheduleRender(){this.renderPending||(this.renderPending=!0,queueMicrotask(()=>{this.renderPending=!1,this.render()}))}createGrid(t,r){return new z2({basis:we({x:On,y:On}),min:we({x:xp,y:xp}),viewport:we({x:t,y:r}),gap:we({x:he,y:he})})}syncScrollModel(){const t=hc(this),i=Fr(this._layout).nodes.map(o=>o.width),s=`${t.width}x${t.height}:${i.join(",")}`;s===this.scrollModelKey&&this.layoutGrid||(this.scrollModelKey=s,this.layoutGrid=this.createGrid(t.width,t.height),this.layoutScroll.rebuild({grid:this.layoutGrid,nodeWidths:i.map(o=>Te({x:o}))}))}emitScrollPositionChanged(t){this.dispatchEvent(new AL(t))}emitLayoutChanged(){this.dispatchEvent(new Uy([...this._layout]))}shiftWindow(t){this.syncScrollModel(),this.animateNextRender=!0,this.layoutScroll.step(t)}applyHorizontalWheel(t){this.syncScrollModel();const r=this.layoutGrid;if(!r)return;this.animateNextRender=!1;const i=r.toUnits(we({x:t}));this.layoutScroll.wheel(Te({x:i.x??0}))}findManagedArtifactFrame(t){if(!t)return null;const r=this.querySelectorAll("iframe.artifact-frame");for(const i of r)if(i.contentWindow===t)return i;return null}isTrustedArtifactFrameMessage(t,r){if(t.origin==="null")return!0;const i=this.getArtifactFrameOrigin(r);return i===null||t.origin===i}getArtifactFrameOrigin(t){const r=t.getAttribute("src")??t.src;if(!r)return null;try{return new URL(r,window.location.href).origin}catch{return null}}beginSwipeTracking(t){this.swipePointerId=t.pointerId,this.swipeStartX=t.clientX,this.swipeStartY=t.clientY,this.swipeLastX=t.clientX,this.swipeActive=!1,this.swipeShouldSuppressClick=!1,this.attachSwipeListeners()}attachSwipeListeners(){this.swipeListenersAttached||(window.addEventListener("pointermove",this.handleSwipePointerMove),window.addEventListener("pointerup",this.handleSwipePointerUp),window.addEventListener("pointercancel",this.handleSwipePointerCancel),this.addEventListener("pointermove",this.handleSwipePointerMove),this.addEventListener("pointerup",this.handleSwipePointerUp),this.addEventListener("pointercancel",this.handleSwipePointerCancel),window.addEventListener("blur",this.handleSwipeWindowBlur),this.addEventListener("click",this.handleSwipeClick,{capture:!0}),this.swipeListenersAttached=!0)}detachSwipeListeners(){this.swipeListenersAttached&&(window.removeEventListener("pointermove",this.handleSwipePointerMove),window.removeEventListener("pointerup",this.handleSwipePointerUp),window.removeEventListener("pointercancel",this.handleSwipePointerCancel),this.removeEventListener("pointermove",this.handleSwipePointerMove),this.removeEventListener("pointerup",this.handleSwipePointerUp),this.removeEventListener("pointercancel",this.handleSwipePointerCancel),window.removeEventListener("blur",this.handleSwipeWindowBlur),this.removeEventListener("click",this.handleSwipeClick,{capture:!0}),this.swipeListenersAttached=!1)}endSwipeTracking(){this.swipePointerId=null,this.swipeActive=!1,this.detachSwipeListeners()}releaseSwipePointerCapture(t){try{this.hasPointerCapture(t)&&this.releasePointerCapture(t)}catch{}}releaseActiveDragPointerCapture(){this.activeDragPointerId!==null&&this.releasePointerCaptureForEvent(this.activeDragPointerId)}releasePointerCaptureForEvent(t){try{this.hasPointerCapture(t)&&this.releasePointerCapture(t)}catch{}}attachDragListeners(){this.dragListenersAttached||(window.addEventListener("pointermove",this.handleWindowPointerMove),window.addEventListener("pointerup",this.handleWindowPointerUp),window.addEventListener("pointercancel",this.handleWindowPointerCancel),this.addEventListener("pointermove",this.handleWindowPointerMove),this.addEventListener("pointerup",this.handleWindowPointerUp),this.addEventListener("pointercancel",this.handleWindowPointerCancel),window.addEventListener("blur",this.handleWindowBlur),this.dragListenersAttached=!0)}detachDragListeners(){this.dragListenersAttached&&(window.removeEventListener("pointermove",this.handleWindowPointerMove),window.removeEventListener("pointerup",this.handleWindowPointerUp),window.removeEventListener("pointercancel",this.handleWindowPointerCancel),this.removeEventListener("pointermove",this.handleWindowPointerMove),this.removeEventListener("pointerup",this.handleWindowPointerUp),this.removeEventListener("pointercancel",this.handleWindowPointerCancel),window.removeEventListener("blur",this.handleWindowBlur),this.dragListenersAttached=!1,this.activeDragPointerId=null)}getDisplayModel(){if(this.dragController.status!=="active"||!this.dragState)return{layout:this._layout,activePlaceholderId:null,placeholdersById:new Map};const t=new Map;return t.set(this.dragState.nodeId,{id:this.dragState.nodeId,sourceCardId:this.dragState.nodeId}),{layout:wf(this.dragState.projectedLayout),activePlaceholderId:this.dragState.nodeId,placeholdersById:t}}render(){const t=hc(this),r=this.createGrid(t.width,t.height);this.layoutGrid=r;const i=this.getDisplayModel(),s=i.layout,o=this.dragController.status==="active",a=Fr(s),c=a.nodes.map(L=>L.width),u=`${t.width}x${t.height}:${c.join(",")}`;!o&&u!==this.scrollModelKey&&(this.scrollModelKey=u,this.layoutScroll.rebuild({grid:r,nodeWidths:c.map(L=>Te({x:L}))}),this._scrollPosition=this.layoutScroll.scroll.x??this._scrollPosition);const h=TL(s),p=r.unit.x??On,v=r.unit.y??On,g=o?this.dragTrackOffsetXPx:0,E=(this.layoutScroll.translate.x??0)+g,_=Af(a.nodes.length,r,t.height),C=this.animateNextRender&&!o,N=[`transform: translate(${E}px, ${_}px);`,`transition-duration: ${C?gx:0}ms;`,`pointer-events: ${o?"none":"auto"};`].join(" ");this.animateNextRender=!0,this.style.setProperty("--layout-unit-x",`${p}px`),this.style.setProperty("--layout-unit-y",`${v}px`),this.style.setProperty("--layout-gap",`${he}px`);const P=this.dragState,W={width:(P==null?void 0:P.size.x)??0,height:(P==null?void 0:P.size.y)??0};Re(U`
174
174
  <div class="track" style=${N}>
175
175
  ${a.nodes.map((L,H)=>U`
176
176
  <div
@@ -213,7 +213,7 @@ ${r.documentElement.outerHTML}`],{type:"text/html"});return URL.createObjectURL(
213
213
  ${this.renderDraggedPreview(P.nodeId)}
214
214
  </div>
215
215
  `})():null}
216
- `,this)}ensureDragFrameLoop(){this.dragFrame!==0||this.dragController.status==="idle"||(this.lastDragFrameTime=performance.now(),this.dragFrame=requestAnimationFrame(this.runDragFrame))}stopDragFrameLoop(){this.dragFrame!==0&&(cancelAnimationFrame(this.dragFrame),this.dragFrame=0,this.scrollVelocityPxPerSec=0)}syncDragTargetForLatestPointer(){if(this.dragController.status==="idle")return;const t=this.getBoundingClientRect();if(this.dragController.status==="active"){const i=this.clampPointerToViewport(this.lastPointerX,this.lastPointerY,t);this.syncDragTarget(i.x,i.y,t);return}if(this.syncDragTarget(this.lastPointerX,this.lastPointerY,t),this.dragController.status==="pending")return;const r=this.clampPointerToViewport(this.lastPointerX,this.lastPointerY,t);(r.x!==this.lastPointerX||r.y!==this.lastPointerY)&&this.syncDragTarget(r.x,r.y,t)}syncDragTarget(t,r,i=this.getBoundingClientRect()){if(this.dragController.status==="idle")return;const s=this.getDisplayModel(),o=new Set(s.placeholdersById.keys()),a=this.dragController.status==="active"?this.dragTrackOffsetXPx:0,c=this.measureLayoutGeometry(s.layout,o,a);this.dragController.update({pointer:we({x:t,y:r}),viewport:{left:i.left,top:i.top,width:i.width,height:i.height},geometry:c,effectiveVelocity:Math.max(this.pointerVelocityPxPerSec,this.scrollVelocityPxPerSec)})}resetMotionTracking(t,r){this.pointerVelocityPxPerSec=0,this.scrollVelocityPxPerSec=0,this.motionSampleTime=performance.now(),this.motionSampleX=t,this.motionSampleY=r}clearMotionTracking(){this.pointerVelocityPxPerSec=0,this.scrollVelocityPxPerSec=0,this.motionSampleTime=0}updatePointerVelocity(t,r){this.samplePointerVelocityAt(performance.now(),t,r)}samplePointerVelocityAt(t,r,i){if(this.motionSampleTime===0){this.motionSampleTime=t,this.motionSampleX=r,this.motionSampleY=i,this.pointerVelocityPxPerSec=0;return}const s=t-this.motionSampleTime;if(s<100)return;const o=r-this.motionSampleX;this.pointerVelocityPxPerSec=Math.abs(o)/s*kf,this.motionSampleTime=t,this.motionSampleX=r,this.motionSampleY=i}clampPointerToViewport(t,r,i){return{x:Math.max(i.left,Math.min(i.left+i.width,t)),y:Math.max(i.top,Math.min(i.top+i.height,r))}}isPointerOutsideViewport(t,r,i){return t<i.left||t>i.left+i.width||r<i.top||r>i.top+i.height}getDragEdgeScrollDeltaPixels(t,r,i){var u;const s=r.left+Ao,o=r.left+r.width-Ao,a=((u=this.layoutGrid)==null?void 0:u.unit.x)??On,c=mx*a;if(t<s){const h=Math.max(0,Math.min(1,(s-t)/Ao));return-(c*h**Ep)*i}if(t>o){const h=Math.max(0,Math.min(1,(t-o)/Ao));return c*h**Ep*i}return 0}measureLayoutGeometry(t,r,i=0){const s=this.layoutGrid;if(!s)return[];const o=Fr(t),a=new Map(o.nodes.map(_=>[_.id,_.width])),c=s.toPixels(Te({y:et})).y??ua,u=lc(this),h=(this.layoutScroll.translate.x??0)+i,p=Ef(o.nodes.length,s,u.height),v=u.offsetY+p,g=[];let E=h;for(const _ of t){const C=a.get(_.id)??Lt,N=s.toPixels(Te({x:C})).x??hr,P={left:E,top:v,width:N,height:c};g.push({id:_.id,rect:P}),E+=N+he}return g}getPlaceholderPixelSize(t,r,i,s){if(!r)return s;for(const o of t.nodes)for(const a of o.cards)if(a.id===r)return{width:i.toPixels(Te({x:a.width})).x??s.width,height:i.toPixels(Te({y:a.height})).y??s.height};return s}renderDraggedPreview(t){const r=ph(this._layout,t);return r?this.renderContent(r,{isDragging:!0}):U``}shouldApplyTrackOffset(t,r){if(r)return!0;for(const i of t){if(i.type!=="stack")continue;if(i.children.some(o=>o.type==="drop-target")&&r!==i.id)return!0}return!1}computeDragTrackOffset(t,r,i,s,o,a){if(!t)return a;const c=s?o??this.getStableAnchorCardId(t,r,i):this.getStableAnchorNodeId(t,r,i);if(!c)return a;const u=s?Af(t,c,this.layoutGrid):$f(t,c,this.layoutGrid),h=s?Af(r,c,this.layoutGrid):$f(r,c,this.layoutGrid);return u===null||h===null?a:a+(u-h)}getStableAnchorCardId(t,r,i){const s=xf(t),o=new Set(xf(r));for(const a of s)if(a!==i&&o.has(a))return a;return null}getStableAnchorNodeId(t,r,i){const s=new Set(r.map(o=>o.id));for(const o of t)if(o.id!==i&&s.has(o.id))return o.id;return null}getStackChildAnchorCardId(t,r){const i=this._layout.find(o=>o.type==="stack"&&o.id===t);if(!i||i.type!=="stack")return null;const s=i.children.find(o=>o.type==="card"&&o.id!==r);return(s==null?void 0:s.id)??null}}function $L(n){const e=new Map;for(const t of n){if(t.type==="card"){e.set(t.id,t);continue}for(const r of t.children)if(r.type==="card")e.set(r.id,r);else for(const i of r.children)e.set(i.id,i)}return e}function TL(n,e){const t=n.findIndex(r=>r.type==="card"&&r.id===e);if(t!==-1)return{topLevelIndex:t};for(let r=0;r<n.length;r+=1){const i=n[r];if(!(!i||i.type!=="stack")&&i.children.some(s=>s.type==="card"&&s.id===e))return{topLevelIndex:r,sourceStackId:i.id}}return null}function xf(n){const e=[];for(const t of n){if(t.type==="card"){e.push(t.id);continue}if(t.type==="stack"){const r=t.children.find(i=>i.type==="card");r&&e.push(r.id)}}return e}function Af(n,e,t){if(!t)return null;const r=Fr(n),i=new Map(r.nodes.map(o=>[o.id,o.width]));let s=0;for(const o of n){if(o.type==="card"&&o.id===e||o.type==="stack"&&o.children.some(u=>u.type==="card"&&u.id===e))return s;const a=i.get(o.id)??Lt,c=t.toPixels(Te({x:a})).x??hr;s+=c+he}return null}function $f(n,e,t){if(!t)return null;const r=Fr(n),i=new Map(r.nodes.map(o=>[o.id,o.width]));let s=0;for(const o of n){if(o.id===e)return s;const a=i.get(o.id)??Lt,c=t.toPixels(Te({x:a})).x??hr;s+=c+he}return null}customElements.get("layout-view")||customElements.define("layout-view",AL);class IL extends HTMLElement{constructor(){super(...arguments);b(this,"screenManager",qe.resolve("ScreenManager"));b(this,"boundModel",null);b(this,"handleActiveScreenChanged",()=>{this.rebindModel(),this.render()});b(this,"handleModelChange",()=>{this.render()});b(this,"handleCloseArtifact",t=>{t instanceof Py&&this.screenManager.activeScreen&&this.screenManager.activeScreen.removeArtifact(t.artifactID)});b(this,"handleScrollPositionChanged",t=>{const r=t;typeof r.scrollPosition=="number"&&Number.isFinite(r.scrollPosition)&&this.screenManager.activeScreen&&this.screenManager.activeScreen.setScrollPosition(r.scrollPosition)});b(this,"handleLayoutChanged",t=>{t instanceof zy&&this.screenManager.activeScreen&&this.screenManager.activeScreen.setLayout(t.layout)});b(this,"handleServerEvent",t=>{const r=t.event;if(r.type!=="viewer-focus"||!this.boundModel||r.screenID!==this.boundModel.id)return;const i=this.querySelector("layout-view");i&&i.focusArtifact(r.artifactID)})}connectedCallback(){this.screenManager.addEventListener("active-screen-changed",this.handleActiveScreenChanged),this.rebindModel(),this.render()}disconnectedCallback(){this.screenManager.removeEventListener("active-screen-changed",this.handleActiveScreenChanged),this.unbindModel()}rebindModel(){const t=this.screenManager.activeScreen;this.boundModel!==t&&(this.unbindModel(),this.boundModel=t,t&&(t.addEventListener("change",this.handleModelChange),t.server.addEventListener("server-event",this.handleServerEvent)))}unbindModel(){this.boundModel&&(this.boundModel.removeEventListener("change",this.handleModelChange),this.boundModel.server.removeEventListener("server-event",this.handleServerEvent),this.boundModel=null)}buildArtifactMap(){const t=this.screenManager.activeScreen;return t?new Map(t.artifacts):new Map}render(){const t=this.screenManager.activeScreen,r=(t==null?void 0:t.layout)??[],i=this.buildArtifactMap();if(r.length===0){Re(U`<p data-testid="empty-screen" class="empty">
216
+ `,this)}ensureDragFrameLoop(){this.dragFrame!==0||this.dragController.status==="idle"||(this.lastDragFrameTime=performance.now(),this.dragFrame=requestAnimationFrame(this.runDragFrame))}stopDragFrameLoop(){this.dragFrame!==0&&(cancelAnimationFrame(this.dragFrame),this.dragFrame=0,this.scrollVelocityPxPerSec=0)}syncDragTargetForLatestPointer(){if(this.dragController.status==="idle")return;const t=this.getBoundingClientRect();if(this.dragController.status==="active"){const i=this.clampPointerToViewport(this.lastPointerX,this.lastPointerY,t);this.syncDragTarget(i.x,i.y,t);return}if(this.syncDragTarget(this.lastPointerX,this.lastPointerY,t),this.dragController.status==="pending")return;const r=this.clampPointerToViewport(this.lastPointerX,this.lastPointerY,t);(r.x!==this.lastPointerX||r.y!==this.lastPointerY)&&this.syncDragTarget(r.x,r.y,t)}syncDragTarget(t,r,i=this.getBoundingClientRect()){if(this.dragController.status==="idle")return;const s=this.getDisplayModel(),o=new Set(s.placeholdersById.keys()),a=this.dragController.status==="active"?this.dragTrackOffsetXPx:0,c=this.measureLayoutGeometry(s.layout,o,a);this.dragController.update({pointer:we({x:t,y:r}),viewport:{left:i.left,top:i.top,width:i.width,height:i.height},geometry:c,effectiveVelocity:Math.max(this.pointerVelocityPxPerSec,this.scrollVelocityPxPerSec)})}resetMotionTracking(t,r){this.pointerVelocityPxPerSec=0,this.scrollVelocityPxPerSec=0,this.motionSampleTime=performance.now(),this.motionSampleX=t,this.motionSampleY=r}clearMotionTracking(){this.pointerVelocityPxPerSec=0,this.scrollVelocityPxPerSec=0,this.motionSampleTime=0}updatePointerVelocity(t,r){this.samplePointerVelocityAt(performance.now(),t,r)}samplePointerVelocityAt(t,r,i){if(this.motionSampleTime===0){this.motionSampleTime=t,this.motionSampleX=r,this.motionSampleY=i,this.pointerVelocityPxPerSec=0;return}const s=t-this.motionSampleTime;if(s<100)return;const o=r-this.motionSampleX;this.pointerVelocityPxPerSec=Math.abs(o)/s*xf,this.motionSampleTime=t,this.motionSampleX=r,this.motionSampleY=i}clampPointerToViewport(t,r,i){return{x:Math.max(i.left,Math.min(i.left+i.width,t)),y:Math.max(i.top,Math.min(i.top+i.height,r))}}isPointerOutsideViewport(t,r,i){return t<i.left||t>i.left+i.width||r<i.top||r>i.top+i.height}getDragEdgeScrollDeltaPixels(t,r,i){var u;const s=r.left+Ao,o=r.left+r.width-Ao,a=((u=this.layoutGrid)==null?void 0:u.unit.x)??On,c=vx*a;if(t<s){const h=Math.max(0,Math.min(1,(s-t)/Ao));return-(c*h**Ap)*i}if(t>o){const h=Math.max(0,Math.min(1,(t-o)/Ao));return c*h**Ap*i}return 0}measureLayoutGeometry(t,r,i=0){const s=this.layoutGrid;if(!s)return[];const o=Fr(t),a=new Map(o.nodes.map(_=>[_.id,_.width])),c=s.toPixels(Te({y:et})).y??ua,u=hc(this),h=(this.layoutScroll.translate.x??0)+i,p=Af(o.nodes.length,s,u.height),v=u.offsetY+p,g=[];let E=h;for(const _ of t){const C=a.get(_.id)??Lt,N=s.toPixels(Te({x:C})).x??hr,P={left:E,top:v,width:N,height:c};g.push({id:_.id,rect:P}),E+=N+he}return g}getPlaceholderPixelSize(t,r,i,s){if(!r)return s;for(const o of t.nodes)for(const a of o.cards)if(a.id===r)return{width:i.toPixels(Te({x:a.width})).x??s.width,height:i.toPixels(Te({y:a.height})).y??s.height};return s}renderDraggedPreview(t){const r=mh(this._layout,t);return r?this.renderContent(r,{isDragging:!0}):U``}shouldApplyTrackOffset(t,r){if(r)return!0;for(const i of t){if(i.type!=="stack")continue;if(i.children.some(o=>o.type==="drop-target")&&r!==i.id)return!0}return!1}computeDragTrackOffset(t,r,i,s,o,a){if(!t)return a;const c=s?o??this.getStableAnchorCardId(t,r,i):this.getStableAnchorNodeId(t,r,i);if(!c)return a;const u=s?Tf(t,c,this.layoutGrid):If(t,c,this.layoutGrid),h=s?Tf(r,c,this.layoutGrid):If(r,c,this.layoutGrid);return u===null||h===null?a:a+(u-h)}getStableAnchorCardId(t,r,i){const s=$f(t),o=new Set($f(r));for(const a of s)if(a!==i&&o.has(a))return a;return null}getStableAnchorNodeId(t,r,i){const s=new Set(r.map(o=>o.id));for(const o of t)if(o.id!==i&&s.has(o.id))return o.id;return null}getStackChildAnchorCardId(t,r){const i=this._layout.find(o=>o.type==="stack"&&o.id===t);if(!i||i.type!=="stack")return null;const s=i.children.find(o=>o.type==="card"&&o.id!==r);return(s==null?void 0:s.id)??null}}function TL(n){const e=new Map;for(const t of n){if(t.type==="card"){e.set(t.id,t);continue}for(const r of t.children)if(r.type==="card")e.set(r.id,r);else for(const i of r.children)e.set(i.id,i)}return e}function IL(n,e){const t=n.findIndex(r=>r.type==="card"&&r.id===e);if(t!==-1)return{topLevelIndex:t};for(let r=0;r<n.length;r+=1){const i=n[r];if(!(!i||i.type!=="stack")&&i.children.some(s=>s.type==="card"&&s.id===e))return{topLevelIndex:r,sourceStackId:i.id}}return null}function $f(n){const e=[];for(const t of n){if(t.type==="card"){e.push(t.id);continue}if(t.type==="stack"){const r=t.children.find(i=>i.type==="card");r&&e.push(r.id)}}return e}function Tf(n,e,t){if(!t)return null;const r=Fr(n),i=new Map(r.nodes.map(o=>[o.id,o.width]));let s=0;for(const o of n){if(o.type==="card"&&o.id===e||o.type==="stack"&&o.children.some(u=>u.type==="card"&&u.id===e))return s;const a=i.get(o.id)??Lt,c=t.toPixels(Te({x:a})).x??hr;s+=c+he}return null}function If(n,e,t){if(!t)return null;const r=Fr(n),i=new Map(r.nodes.map(o=>[o.id,o.width]));let s=0;for(const o of n){if(o.id===e)return s;const a=i.get(o.id)??Lt,c=t.toPixels(Te({x:a})).x??hr;s+=c+he}return null}customElements.get("layout-view")||customElements.define("layout-view",$L);class CL extends HTMLElement{constructor(){super(...arguments);b(this,"screenManager",qe.resolve("ScreenManager"));b(this,"boundModel",null);b(this,"handleActiveScreenChanged",()=>{this.rebindModel(),this.render()});b(this,"handleModelChange",()=>{this.render()});b(this,"handleCloseArtifact",t=>{t instanceof Dy&&this.screenManager.activeScreen&&this.screenManager.activeScreen.removeArtifact(t.artifactID)});b(this,"handleScrollPositionChanged",t=>{const r=t;typeof r.scrollPosition=="number"&&Number.isFinite(r.scrollPosition)&&this.screenManager.activeScreen&&this.screenManager.activeScreen.setScrollPosition(r.scrollPosition)});b(this,"handleLayoutChanged",t=>{t instanceof Uy&&this.screenManager.activeScreen&&this.screenManager.activeScreen.setLayout(t.layout)});b(this,"handleServerEvent",t=>{const r=t.event;if(r.type!=="viewer-focus"||!this.boundModel||r.screenID!==this.boundModel.id)return;const i=this.querySelector("layout-view");i&&i.focusArtifact(r.artifactID)})}connectedCallback(){this.screenManager.addEventListener("active-screen-changed",this.handleActiveScreenChanged),this.rebindModel(),this.render()}disconnectedCallback(){this.screenManager.removeEventListener("active-screen-changed",this.handleActiveScreenChanged),this.unbindModel()}rebindModel(){const t=this.screenManager.activeScreen;this.boundModel!==t&&(this.unbindModel(),this.boundModel=t,t&&(t.addEventListener("change",this.handleModelChange),t.server.addEventListener("server-event",this.handleServerEvent)))}unbindModel(){this.boundModel&&(this.boundModel.removeEventListener("change",this.handleModelChange),this.boundModel.server.removeEventListener("server-event",this.handleServerEvent),this.boundModel=null)}buildArtifactMap(){const t=this.screenManager.activeScreen;return t?new Map(t.artifacts):new Map}render(){const t=this.screenManager.activeScreen,r=(t==null?void 0:t.layout)??[],i=this.buildArtifactMap();if(r.length===0){Re(U`<p data-testid="empty-screen" class="empty">
217
217
  No artifacts yet. Create one by asking for something.
218
218
  </p>`,this);return}Re(U`
219
219
  <layout-view
@@ -230,7 +230,7 @@ ${r.documentElement.outerHTML}`],{type:"text/html"});return URL.createObjectURL(
230
230
  @layout-change=${this.handleLayoutChanged}
231
231
  @close-artifact=${this.handleCloseArtifact}
232
232
  ></layout-view>
233
- `,this)}}customElements.define("screen-view",IL);var $a,ni,zs,Jt,Ny,Uy,au;class CL extends HTMLElement{constructor(){super(...arguments);w(this,Jt);w(this,$a,qe.resolve("ScreenManager"));w(this,ni,qe.resolve("ServerManager"));w(this,zs,()=>{m(this,Jt,au).call(this)})}connectedCallback(){l(this,ni).addEventListener("change",l(this,zs)),m(this,Jt,au).call(this)}disconnectedCallback(){l(this,ni).removeEventListener("change",l(this,zs))}}$a=new WeakMap,ni=new WeakMap,zs=new WeakMap,Jt=new WeakSet,Ny=function(t,r){l(this,$a).setActive(t,r)},Uy=function(){for(const t of l(this,ni).servers.values())return t;return null},au=function(){const t=m(this,Jt,Uy).call(this),i=(t?[...t.screens.values()]:[]).slice().sort((o,a)=>o.starred!==a.starred?o.starred?-1:1:o.name.localeCompare(a.name,void 0,{sensitivity:"base"})),s=i.length===0?U`<p class="empty">No screens yet. Hit + to create one.</p>`:U`
233
+ `,this)}}customElements.define("screen-view",CL);var $a,ni,zs,Jt,Fy,Zy,uu;class PL extends HTMLElement{constructor(){super(...arguments);w(this,Jt);w(this,$a,qe.resolve("ScreenManager"));w(this,ni,qe.resolve("ServerManager"));w(this,zs,()=>{m(this,Jt,uu).call(this)})}connectedCallback(){l(this,ni).addEventListener("change",l(this,zs)),m(this,Jt,uu).call(this)}disconnectedCallback(){l(this,ni).removeEventListener("change",l(this,zs))}}$a=new WeakMap,ni=new WeakMap,zs=new WeakMap,Jt=new WeakSet,Fy=function(t,r){l(this,$a).setActive(t,r)},Zy=function(){for(const t of l(this,ni).servers.values())return t;return null},uu=function(){const t=m(this,Jt,Zy).call(this),i=(t?[...t.screens.values()]:[]).slice().sort((o,a)=>o.starred!==a.starred?o.starred?-1:1:o.name.localeCompare(a.name,void 0,{sensitivity:"base"})),s=i.length===0?U`<p class="empty">No screens yet. Hit + to create one.</p>`:U`
234
234
  <ul class="tiles">
235
235
  ${i.map(o=>U`
236
236
  <li>
@@ -238,27 +238,27 @@ ${r.documentElement.outerHTML}`],{type:"text/html"});return URL.createObjectURL(
238
238
  class="tile"
239
239
  type="button"
240
240
  material="glass"
241
- @click=${()=>t&&m(this,Jt,Ny).call(this,t.url,o.id)}
241
+ @click=${()=>t&&m(this,Jt,Fy).call(this,t.url,o.id)}
242
242
  >
243
243
  <span class="tile-name">${o.name}</span>
244
- ${o.starred?U`<span class="tile-star" aria-hidden="true">${Gc({weight:"fill"})}</span>`:se}
244
+ ${o.starred?U`<span class="tile-star" aria-hidden="true">${Yc({weight:"fill"})}</span>`:se}
245
245
  </button>
246
246
  </li>
247
247
  `)}
248
248
  </ul>
249
- `;Re(s,this)};customElements.get("home-screen")||customElements.define("home-screen",CL);const cc=new WeakMap,Tf=Object.prototype.hasOwnProperty,PL=(()=>{const n=new Set;let e=HTMLElement.prototype;for(;e;){for(const t of Object.getOwnPropertyNames(e))n.add(t);if(e===Node.prototype)break;e=Object.getPrototypeOf(e)}return n})();function RL(n,e){if(n===Boolean)return e!==null;if(e!==null)return n===Number?Number(e):e}var Ns,lu,sr,it,Rt,ri,or,ii,Ce,Xi,Fy,Zy,Hy,ea;const Nn=class Nn extends HTMLElement{constructor(){var i;super();w(this,Ce);w(this,sr,new Map);w(this,it,new Map);w(this,Rt,new Map);w(this,ri,!1);w(this,or,!1);w(this,ii,!1);const t=m(i=Nn,Ns,lu).call(i,this.constructor),r=this;for(const s of t.properties)Tf.call(r,s)&&(l(this,Rt).set(s,r[s]),delete r[s])}static get observedAttributes(){var t;return m(t=Nn,Ns,lu).call(t,this).observedAttributes}connected(){}disconnected(){}changed(t){}connectedCallback(){if(m(this,Ce,Hy).call(this),!l(this,or))for(const t of m(this,Ce,Xi).call(this).properties)l(this,it).has(t)||l(this,it).set(t,void 0);this.dispatchEvent(new Event("reactive:connect")),this.connected(),m(this,Ce,ea).call(this)}disconnectedCallback(){this.dispatchEvent(new Event("reactive:disconnect")),this.disconnected()}attributeChangedCallback(t,r,i){if(r===i)return;const s=m(this,Ce,Xi).call(this).byAttr.get(t);s&&(l(this,Rt).has(s.property)||(this[s.property]=RL(s.type,i)))}};Ns=new WeakSet,lu=function(t){const r=cc.get(t);if(r)return r;const i=[...t.properties??[]],s=t.attributes??{},o=new Map,a=new Map;for(const u of i)if(PL.has(u))throw new Error(`Reactive property "${u}" collides with a built-in DOM property. Rename it to avoid shadowing the platform API.`);for(const[u,h]of Object.entries(s)){if(u.includes("-")&&h.property===void 0)throw new Error(`Attribute "${u}" must declare a "property" name because kebab-case cannot be a property.`);const p=h.property??u;if(!i.includes(p))throw new Error(`Attribute '${u}' references property '${p}', which isn't declared in \`static properties\`. Add it to \`properties\` to make it reactive.`);const v={attribute:u,property:p,type:h.type};o.set(u,v),a.set(p,v)}for(const u of i){const h=Object.getOwnPropertyDescriptor(t.prototype,u);if((h==null?void 0:h.get)!==void 0||(h==null?void 0:h.set)!==void 0)throw new Error(`Observed property "${u}" cannot define a custom getter/setter. Use changed() for side effects instead.`);h===void 0&&Object.defineProperty(t.prototype,u,{configurable:!0,enumerable:!0,get(){return l(this,sr).get(u)},set(p){m(this,Ce,Fy).call(this,u,p)}})}const c={properties:i,observedAttributes:Object.keys(s),byAttr:o,byProp:a};return cc.set(t,c),c},sr=new WeakMap,it=new WeakMap,Rt=new WeakMap,ri=new WeakMap,or=new WeakMap,ii=new WeakMap,Ce=new WeakSet,Xi=function(){return cc.get(this.constructor)},Fy=function(t,r){if(!l(this,ii)&&l(this,Rt).has(t))return;const i=l(this,sr).get(t);Object.is(i,r)||(l(this,it).has(t)||l(this,it).set(t,i),l(this,sr).set(t,r),l(this,Rt).delete(t),m(this,Ce,Zy).call(this,t,r),this.isConnected&&m(this,Ce,ea).call(this))},Zy=function(t,r){const i=m(this,Ce,Xi).call(this).byProp.get(t);if(!i)return;const{attribute:s,type:o}=i;if(o===Boolean){const c=this.hasAttribute(s);r&&!c?this.setAttribute(s,""):!r&&c&&this.removeAttribute(s);return}if(r==null){this.hasAttribute(s)&&this.removeAttribute(s);return}const a=String(r);this.getAttribute(s)!==a&&this.setAttribute(s,a)},Hy=function(){const t=this,r=m(this,Ce,Xi).call(this);for(const i of r.properties){if(!Tf.call(t,i))continue;const s=t[i];delete t[i],!(l(this,Rt).has(i)||l(this,sr).has(i))&&(t[i]=s)}x(this,ii,!0);try{for(const[i,s]of l(this,Rt))t[i]=s;l(this,Rt).clear()}finally{x(this,ii,!1)}},ea=function(){l(this,ri)||!this.isConnected||l(this,or)&&l(this,it).size===0||(x(this,ri,!0),queueMicrotask(()=>{if(x(this,ri,!1),!this.isConnected||l(this,or)&&l(this,it).size===0)return;const t=new Map(l(this,it));l(this,it).clear(),x(this,or,!0);try{this.changed(t)}catch(r){console.error(r)}this.isConnected&&l(this,it).size>0&&m(this,Ce,ea).call(this)}))},w(Nn,Ns),b(Nn,"properties"),b(Nn,"attributes");let cs=Nn;/**
249
+ `;Re(s,this)};customElements.get("home-screen")||customElements.define("home-screen",PL);const dc=new WeakMap,Cf=Object.prototype.hasOwnProperty,RL=(()=>{const n=new Set;let e=HTMLElement.prototype;for(;e;){for(const t of Object.getOwnPropertyNames(e))n.add(t);if(e===Node.prototype)break;e=Object.getPrototypeOf(e)}return n})();function DL(n,e){if(n===Boolean)return e!==null;if(e!==null)return n===Number?Number(e):e}var Ns,hu,sr,it,Rt,ri,or,ii,Ce,Xi,Hy,Wy,Gy,ea;const Nn=class Nn extends HTMLElement{constructor(){var i;super();w(this,Ce);w(this,sr,new Map);w(this,it,new Map);w(this,Rt,new Map);w(this,ri,!1);w(this,or,!1);w(this,ii,!1);const t=m(i=Nn,Ns,hu).call(i,this.constructor),r=this;for(const s of t.properties)Cf.call(r,s)&&(l(this,Rt).set(s,r[s]),delete r[s])}static get observedAttributes(){var t;return m(t=Nn,Ns,hu).call(t,this).observedAttributes}connected(){}disconnected(){}changed(t){}connectedCallback(){if(m(this,Ce,Gy).call(this),!l(this,or))for(const t of m(this,Ce,Xi).call(this).properties)l(this,it).has(t)||l(this,it).set(t,void 0);this.dispatchEvent(new Event("reactive:connect")),this.connected(),m(this,Ce,ea).call(this)}disconnectedCallback(){this.dispatchEvent(new Event("reactive:disconnect")),this.disconnected()}attributeChangedCallback(t,r,i){if(r===i)return;const s=m(this,Ce,Xi).call(this).byAttr.get(t);s&&(l(this,Rt).has(s.property)||(this[s.property]=DL(s.type,i)))}};Ns=new WeakSet,hu=function(t){const r=dc.get(t);if(r)return r;const i=[...t.properties??[]],s=t.attributes??{},o=new Map,a=new Map;for(const u of i)if(RL.has(u))throw new Error(`Reactive property "${u}" collides with a built-in DOM property. Rename it to avoid shadowing the platform API.`);for(const[u,h]of Object.entries(s)){if(u.includes("-")&&h.property===void 0)throw new Error(`Attribute "${u}" must declare a "property" name because kebab-case cannot be a property.`);const p=h.property??u;if(!i.includes(p))throw new Error(`Attribute '${u}' references property '${p}', which isn't declared in \`static properties\`. Add it to \`properties\` to make it reactive.`);const v={attribute:u,property:p,type:h.type};o.set(u,v),a.set(p,v)}for(const u of i){const h=Object.getOwnPropertyDescriptor(t.prototype,u);if((h==null?void 0:h.get)!==void 0||(h==null?void 0:h.set)!==void 0)throw new Error(`Observed property "${u}" cannot define a custom getter/setter. Use changed() for side effects instead.`);h===void 0&&Object.defineProperty(t.prototype,u,{configurable:!0,enumerable:!0,get(){return l(this,sr).get(u)},set(p){m(this,Ce,Hy).call(this,u,p)}})}const c={properties:i,observedAttributes:Object.keys(s),byAttr:o,byProp:a};return dc.set(t,c),c},sr=new WeakMap,it=new WeakMap,Rt=new WeakMap,ri=new WeakMap,or=new WeakMap,ii=new WeakMap,Ce=new WeakSet,Xi=function(){return dc.get(this.constructor)},Hy=function(t,r){if(!l(this,ii)&&l(this,Rt).has(t))return;const i=l(this,sr).get(t);Object.is(i,r)||(l(this,it).has(t)||l(this,it).set(t,i),l(this,sr).set(t,r),l(this,Rt).delete(t),m(this,Ce,Wy).call(this,t,r),this.isConnected&&m(this,Ce,ea).call(this))},Wy=function(t,r){const i=m(this,Ce,Xi).call(this).byProp.get(t);if(!i)return;const{attribute:s,type:o}=i;if(o===Boolean){const c=this.hasAttribute(s);r&&!c?this.setAttribute(s,""):!r&&c&&this.removeAttribute(s);return}if(r==null){this.hasAttribute(s)&&this.removeAttribute(s);return}const a=String(r);this.getAttribute(s)!==a&&this.setAttribute(s,a)},Gy=function(){const t=this,r=m(this,Ce,Xi).call(this);for(const i of r.properties){if(!Cf.call(t,i))continue;const s=t[i];delete t[i],!(l(this,Rt).has(i)||l(this,sr).has(i))&&(t[i]=s)}x(this,ii,!0);try{for(const[i,s]of l(this,Rt))t[i]=s;l(this,Rt).clear()}finally{x(this,ii,!1)}},ea=function(){l(this,ri)||!this.isConnected||l(this,or)&&l(this,it).size===0||(x(this,ri,!0),queueMicrotask(()=>{if(x(this,ri,!1),!this.isConnected||l(this,or)&&l(this,it).size===0)return;const t=new Map(l(this,it));l(this,it).clear(),x(this,or,!0);try{this.changed(t)}catch(r){console.error(r)}this.isConnected&&l(this,it).size>0&&m(this,Ce,ea).call(this)}))},w(Nn,Ns),b(Nn,"properties"),b(Nn,"attributes");let cs=Nn;/**
250
250
  * @license
251
251
  * Copyright 2020 Google LLC
252
252
  * SPDX-License-Identifier: BSD-3-Clause
253
- */const DL=n=>n.strings===void 0;/**
253
+ */const LL=n=>n.strings===void 0;/**
254
254
  * @license
255
255
  * Copyright 2017 Google LLC
256
256
  * SPDX-License-Identifier: BSD-3-Clause
257
- */const rs=(n,e)=>{var r;const t=n._$AN;if(t===void 0)return!1;for(const i of t)(r=i._$AO)==null||r.call(i,e,!1),rs(i,e);return!0},ya=n=>{let e,t;do{if((e=n._$AM)===void 0)break;t=e._$AN,t.delete(n),n=e}while((t==null?void 0:t.size)===0)},Wy=n=>{for(let e;e=n._$AM;n=e){let t=e._$AN;if(t===void 0)e._$AN=t=new Set;else if(t.has(n))break;t.add(n),ML(e)}};function LL(n){this._$AN!==void 0?(ya(this),this._$AM=n,Wy(this)):this._$AM=n}function OL(n,e=!1,t=0){const r=this._$AH,i=this._$AN;if(i!==void 0&&i.size!==0)if(e)if(Array.isArray(r))for(let s=t;s<r.length;s++)rs(r[s],!1),ya(r[s]);else r!=null&&(rs(r,!1),ya(r));else rs(this,n)}const ML=n=>{n.type==sy.CHILD&&(n._$AP??(n._$AP=OL),n._$AQ??(n._$AQ=LL))};class zL extends oy{constructor(){super(...arguments),this._$AN=void 0}_$AT(e,t,r){super._$AT(e,t,r),Wy(this),this.isConnected=e._$AU}_$AO(e,t=!0){var r,i;e!==this.isConnected&&(this.isConnected=e,e?(r=this.reconnected)==null||r.call(this):(i=this.disconnected)==null||i.call(this)),t&&(rs(this,e),ya(this))}setValue(e){if(DL(this._$Ct))this._$Ct._$AI(e,this);else{const t=[...this._$Ct._$AH];t[this._$Ci]=e,this._$Ct._$AI(t,this,0)}}disconnected(){}reconnected(){}}/**
257
+ */const rs=(n,e)=>{var r;const t=n._$AN;if(t===void 0)return!1;for(const i of t)(r=i._$AO)==null||r.call(i,e,!1),rs(i,e);return!0},ya=n=>{let e,t;do{if((e=n._$AM)===void 0)break;t=e._$AN,t.delete(n),n=e}while((t==null?void 0:t.size)===0)},Vy=n=>{for(let e;e=n._$AM;n=e){let t=e._$AN;if(t===void 0)e._$AN=t=new Set;else if(t.has(n))break;t.add(n),zL(e)}};function OL(n){this._$AN!==void 0?(ya(this),this._$AM=n,Vy(this)):this._$AM=n}function ML(n,e=!1,t=0){const r=this._$AH,i=this._$AN;if(i!==void 0&&i.size!==0)if(e)if(Array.isArray(r))for(let s=t;s<r.length;s++)rs(r[s],!1),ya(r[s]);else r!=null&&(rs(r,!1),ya(r));else rs(this,n)}const zL=n=>{n.type==ay.CHILD&&(n._$AP??(n._$AP=ML),n._$AQ??(n._$AQ=OL))};class NL extends ly{constructor(){super(...arguments),this._$AN=void 0}_$AT(e,t,r){super._$AT(e,t,r),Vy(this),this.isConnected=e._$AU}_$AO(e,t=!0){var r,i;e!==this.isConnected&&(this.isConnected=e,e?(r=this.reconnected)==null||r.call(this):(i=this.disconnected)==null||i.call(this)),t&&(rs(this,e),ya(this))}setValue(e){if(LL(this._$Ct))this._$Ct._$AI(e,this);else{const t=[...this._$Ct._$AH];t[this._$Ci]=e,this._$Ct._$AI(t,this,0)}}disconnected(){}reconnected(){}}/**
258
258
  * @license
259
259
  * Copyright 2020 Google LLC
260
260
  * SPDX-License-Identifier: BSD-3-Clause
261
- */const Lo=()=>new NL;class NL{}const uc=new WeakMap,Oo=hh(class extends zL{render(n){return se}update(n,[e]){var r;const t=e!==this.G;return t&&this.G!==void 0&&this.rt(void 0),(t||this.lt!==this.ct)&&(this.G=e,this.ht=(r=n.options)==null?void 0:r.host,this.rt(this.ct=n.element)),se}rt(n){if(this.isConnected||(n=void 0),typeof this.G=="function"){const e=this.ht??globalThis;let t=uc.get(e);t===void 0&&(t=new WeakMap,uc.set(e,t)),t.get(this.G)!==void 0&&this.G.call(this.ht,void 0),t.set(this.G,n),n!==void 0&&this.G.call(this.ht,n)}else this.G.value=n}get lt(){var n,e;return typeof this.G=="function"?(n=uc.get(this.ht??globalThis))==null?void 0:n.get(this.G):(e=this.G)==null?void 0:e.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}});var Ve,pn,si,oi,Us,ar,lr,ie,Pe,By,Fs,Zs,cu,uu,Ta,Ia,Ca,Pa,Ra,Da,La,Oa,Hs,Ws,Ki,Vy,vt;class UL extends cs{constructor(){super(...arguments);w(this,Pe);w(this,Ve,qe.resolve("ScreenManager"));w(this,pn,null);w(this,si,new DisposableStack);w(this,oi,Lo());w(this,Us,Lo());w(this,ar,Lo());w(this,lr,Lo());w(this,ie,{kind:"none"});w(this,Fs,()=>{m(this,Pe,cu).call(this),l(this,vt).call(this)});w(this,Zs,()=>{l(this,vt).call(this)});w(this,Ta,()=>{l(this,Ve).clearActive()});w(this,Ia,()=>{const t=l(this,Ve).activeScreen;t&&t.setStarred(!t.starred)});w(this,Ca,t=>{l(this,ie).kind!=="none"&&(t.stopImmediatePropagation(),m(this,Pe,Ki).call(this))});w(this,Pa,()=>{var r;const t=l(this,Ve).activeScreen;t&&((r=l(this,oi).value)==null||r.close(),x(this,ie,{kind:"rename",draft:t.name}),l(this,vt).call(this))});w(this,Ra,()=>{var t;l(this,Ve).activeScreen&&((t=l(this,oi).value)==null||t.close(),x(this,ie,{kind:"delete",error:null}),l(this,vt).call(this))});w(this,Da,t=>{if(l(this,ie).kind!=="rename")return;const r=t.target;r instanceof HTMLInputElement&&x(this,ie,{kind:"rename",draft:r.value})});w(this,La,t=>{if(t.preventDefault(),l(this,ie).kind!=="rename")return;const r=l(this,Ve).activeScreen;if(!r)return;const i=l(this,ie).draft.trim();i.length>0&&i!==r.name&&r.rename(i),m(this,Pe,Ki).call(this)});w(this,Oa,async()=>{if(l(this,ie).kind!=="delete")return;const t=l(this,Ve).activeScreen;if(t){x(this,ie,{kind:"delete",error:null});try{await t.remove(),l(this,Ve).clearActive(),m(this,Pe,Ki).call(this)}catch(r){x(this,ie,{kind:"delete",error:r instanceof Error?r.message:"Failed to delete screen."}),l(this,vt).call(this)}}});w(this,Hs,()=>{m(this,Pe,Ki).call(this)});w(this,Ws,()=>{l(this,ie).kind!=="none"&&(x(this,ie,{kind:"none"}),l(this,vt).call(this))});w(this,vt,()=>{const t=U`
261
+ */const Lo=()=>new UL;class UL{}const pc=new WeakMap,Oo=fh(class extends NL{render(n){return se}update(n,[e]){var r;const t=e!==this.G;return t&&this.G!==void 0&&this.rt(void 0),(t||this.lt!==this.ct)&&(this.G=e,this.ht=(r=n.options)==null?void 0:r.host,this.rt(this.ct=n.element)),se}rt(n){if(this.isConnected||(n=void 0),typeof this.G=="function"){const e=this.ht??globalThis;let t=pc.get(e);t===void 0&&(t=new WeakMap,pc.set(e,t)),t.get(this.G)!==void 0&&this.G.call(this.ht,void 0),t.set(this.G,n),n!==void 0&&this.G.call(this.ht,n)}else this.G.value=n}get lt(){var n,e;return typeof this.G=="function"?(n=pc.get(this.ht??globalThis))==null?void 0:n.get(this.G):(e=this.G)==null?void 0:e.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}});var Ve,pn,si,oi,Us,ar,lr,ie,Pe,By,Fs,Zs,du,pu,Ta,Ia,Ca,Pa,Ra,Da,La,Oa,Hs,Ws,Ki,jy,vt;class FL extends cs{constructor(){super(...arguments);w(this,Pe);w(this,Ve,qe.resolve("ScreenManager"));w(this,pn,null);w(this,si,new DisposableStack);w(this,oi,Lo());w(this,Us,Lo());w(this,ar,Lo());w(this,lr,Lo());w(this,ie,{kind:"none"});w(this,Fs,()=>{m(this,Pe,du).call(this),l(this,vt).call(this)});w(this,Zs,()=>{l(this,vt).call(this)});w(this,Ta,()=>{l(this,Ve).clearActive()});w(this,Ia,()=>{const t=l(this,Ve).activeScreen;t&&t.setStarred(!t.starred)});w(this,Ca,t=>{l(this,ie).kind!=="none"&&(t.stopImmediatePropagation(),m(this,Pe,Ki).call(this))});w(this,Pa,()=>{var r;const t=l(this,Ve).activeScreen;t&&((r=l(this,oi).value)==null||r.close(),x(this,ie,{kind:"rename",draft:t.name}),l(this,vt).call(this))});w(this,Ra,()=>{var t;l(this,Ve).activeScreen&&((t=l(this,oi).value)==null||t.close(),x(this,ie,{kind:"delete",error:null}),l(this,vt).call(this))});w(this,Da,t=>{if(l(this,ie).kind!=="rename")return;const r=t.target;r instanceof HTMLInputElement&&x(this,ie,{kind:"rename",draft:r.value})});w(this,La,t=>{if(t.preventDefault(),l(this,ie).kind!=="rename")return;const r=l(this,Ve).activeScreen;if(!r)return;const i=l(this,ie).draft.trim();i.length>0&&i!==r.name&&r.rename(i),m(this,Pe,Ki).call(this)});w(this,Oa,async()=>{if(l(this,ie).kind!=="delete")return;const t=l(this,Ve).activeScreen;if(t){x(this,ie,{kind:"delete",error:null});try{await t.remove(),l(this,Ve).clearActive(),m(this,Pe,Ki).call(this)}catch(r){x(this,ie,{kind:"delete",error:r instanceof Error?r.message:"Failed to delete screen."}),l(this,vt).call(this)}}});w(this,Hs,()=>{m(this,Pe,Ki).call(this)});w(this,Ws,()=>{l(this,ie).kind!=="none"&&(x(this,ie,{kind:"none"}),l(this,vt).call(this))});w(this,vt,()=>{const t=U`
262
262
  <button
263
263
  icon-only
264
264
  variant="ghost"
@@ -267,11 +267,11 @@ ${r.documentElement.outerHTML}`],{type:"text/html"});return URL.createObjectURL(
267
267
  aria-label="Home"
268
268
  @click=${l(this,Ta)}
269
269
  >
270
- ${u2({weight:"fill"})}
270
+ ${h2({weight:"fill"})}
271
271
  </button>
272
- `;Re(U`${t}${m(this,Pe,Vy).call(this)}`,this);const r=l(this,Us).value??null;l(this,ar).value&&(l(this,ar).value.anchor=r),l(this,lr).value&&(l(this,lr).value.anchor=r)})}connected(){l(this,Ve).addEventListener("active-screen-changed",l(this,Fs)),m(this,Pe,cu).call(this),l(this,vt).call(this),m(this,Pe,By).call(this),l(this,si).defer(()=>{l(this,Ve).removeEventListener("active-screen-changed",l(this,Fs)),m(this,Pe,uu).call(this)})}disconnected(){l(this,si).dispose(),x(this,si,new DisposableStack)}}Ve=new WeakMap,pn=new WeakMap,si=new WeakMap,oi=new WeakMap,Us=new WeakMap,ar=new WeakMap,lr=new WeakMap,ie=new WeakMap,Pe=new WeakSet,By=async function(){const t=await ch(this);this.setAttribute("tone",t)},Fs=new WeakMap,Zs=new WeakMap,cu=function(){var r;const t=l(this,Ve).activeScreen;l(this,pn)!==t&&(m(this,Pe,uu).call(this),x(this,pn,t),(r=l(this,pn))==null||r.addEventListener("change",l(this,Zs)))},uu=function(){var t;(t=l(this,pn))==null||t.removeEventListener("change",l(this,Zs)),x(this,pn,null)},Ta=new WeakMap,Ia=new WeakMap,Ca=new WeakMap,Pa=new WeakMap,Ra=new WeakMap,Da=new WeakMap,La=new WeakMap,Oa=new WeakMap,Hs=new WeakMap,Ws=new WeakMap,Ki=function(){const t=l(this,ie).kind==="rename"?l(this,ar).value:l(this,ie).kind==="delete"?l(this,lr).value:null;t&&(t.open=!1),x(this,ie,{kind:"none"}),l(this,vt).call(this)},Vy=function(){const t=l(this,Ve).activeScreen;if(!t)return null;const r=l(this,ie).kind==="rename"?l(this,ie).draft:"",i=l(this,ie).kind==="delete"?l(this,ie).error:null;return U`
272
+ `;Re(U`${t}${m(this,Pe,jy).call(this)}`,this);const r=l(this,Us).value??null;l(this,ar).value&&(l(this,ar).value.anchor=r),l(this,lr).value&&(l(this,lr).value.anchor=r)})}connected(){l(this,Ve).addEventListener("active-screen-changed",l(this,Fs)),m(this,Pe,du).call(this),l(this,vt).call(this),m(this,Pe,By).call(this),l(this,si).defer(()=>{l(this,Ve).removeEventListener("active-screen-changed",l(this,Fs)),m(this,Pe,pu).call(this)})}disconnected(){l(this,si).dispose(),x(this,si,new DisposableStack)}}Ve=new WeakMap,pn=new WeakMap,si=new WeakMap,oi=new WeakMap,Us=new WeakMap,ar=new WeakMap,lr=new WeakMap,ie=new WeakMap,Pe=new WeakSet,By=async function(){const t=await dh(this);this.setAttribute("tone",t)},Fs=new WeakMap,Zs=new WeakMap,du=function(){var r;const t=l(this,Ve).activeScreen;l(this,pn)!==t&&(m(this,Pe,pu).call(this),x(this,pn,t),(r=l(this,pn))==null||r.addEventListener("change",l(this,Zs)))},pu=function(){var t;(t=l(this,pn))==null||t.removeEventListener("change",l(this,Zs)),x(this,pn,null)},Ta=new WeakMap,Ia=new WeakMap,Ca=new WeakMap,Pa=new WeakMap,Ra=new WeakMap,Da=new WeakMap,La=new WeakMap,Oa=new WeakMap,Hs=new WeakMap,Ws=new WeakMap,Ki=function(){const t=l(this,ie).kind==="rename"?l(this,ar).value:l(this,ie).kind==="delete"?l(this,lr).value:null;t&&(t.open=!1),x(this,ie,{kind:"none"}),l(this,vt).call(this)},jy=function(){const t=l(this,Ve).activeScreen;if(!t)return null;const r=l(this,ie).kind==="rename"?l(this,ie).draft:"",i=l(this,ie).kind==="delete"?l(this,ie).error:null;return U`
273
273
  <span class="separator" aria-hidden="true">
274
- ${a2()}
274
+ ${l2()}
275
275
  </span>
276
276
  <dropdown-menu ${Oo(l(this,oi))}>
277
277
  <button
@@ -287,10 +287,10 @@ ${r.documentElement.outerHTML}`],{type:"text/html"});return URL.createObjectURL(
287
287
  </button>
288
288
  <dropdown-group>
289
289
  <dropdown-item action @click=${l(this,Pa)}>
290
- ${h2()} Rename
290
+ ${d2()} Rename
291
291
  </dropdown-item>
292
292
  <dropdown-item action danger @click=${l(this,Ra)}>
293
- ${d2()} Delete
293
+ ${p2()} Delete
294
294
  </dropdown-item>
295
295
  </dropdown-group>
296
296
  </dropdown-menu>
@@ -345,9 +345,9 @@ ${r.documentElement.outerHTML}`],{type:"text/html"});return URL.createObjectURL(
345
345
  ?data-starred=${t.starred}
346
346
  @click=${l(this,Ia)}
347
347
  >
348
- ${t.starred?Gc({weight:"fill"}):Gc()}
348
+ ${t.starred?Yc({weight:"fill"}):Yc()}
349
349
  </button>
350
- `},vt=new WeakMap;customElements.define("screen-breadcrumb",UL);var Ma,za,ai,Sn,Gy,jy,Na,qy;class FL extends HTMLElement{constructor(){super(...arguments);w(this,Sn);w(this,Ma,qe.resolve("ServerManager"));w(this,za,qe.resolve("ScreenManager"));w(this,ai,!1);w(this,Na,async()=>{if(l(this,ai))return;const t=m(this,Sn,jy).call(this);if(t){x(this,ai,!0);try{const r=await t.createScreen(ZL(new Date));l(this,za).setActive(t.url,r.id)}catch{}finally{x(this,ai,!1)}}})}connectedCallback(){m(this,Sn,qy).call(this),m(this,Sn,Gy).call(this)}}Ma=new WeakMap,za=new WeakMap,ai=new WeakMap,Sn=new WeakSet,Gy=async function(){const t=await ch(this);this.setAttribute("tone",t)},jy=function(){for(const t of l(this,Ma).servers.values())return t;return null},Na=new WeakMap,qy=function(){Re(U`
350
+ `},vt=new WeakMap;customElements.define("screen-breadcrumb",FL);var Ma,za,ai,Sn,qy,Yy,Na,Xy;class ZL extends HTMLElement{constructor(){super(...arguments);w(this,Sn);w(this,Ma,qe.resolve("ServerManager"));w(this,za,qe.resolve("ScreenManager"));w(this,ai,!1);w(this,Na,async()=>{if(l(this,ai))return;const t=m(this,Sn,Yy).call(this);if(t){x(this,ai,!0);try{const r=await t.createScreen(HL(new Date));l(this,za).setActive(t.url,r.id)}catch{}finally{x(this,ai,!1)}}})}connectedCallback(){m(this,Sn,Xy).call(this),m(this,Sn,qy).call(this)}}Ma=new WeakMap,za=new WeakMap,ai=new WeakMap,Sn=new WeakSet,qy=async function(){const t=await dh(this);this.setAttribute("tone",t)},Yy=function(){for(const t of l(this,Ma).servers.values())return t;return null},Na=new WeakMap,Xy=function(){Re(U`
351
351
  <button
352
352
  icon-only
353
353
  variant="ghost"
@@ -356,14 +356,14 @@ ${r.documentElement.outerHTML}`],{type:"text/html"});return URL.createObjectURL(
356
356
  aria-label="New screen"
357
357
  @click=${l(this,Na)}
358
358
  >
359
- ${c2({size:16,weight:"bold"})}
359
+ ${u2({size:16,weight:"bold"})}
360
360
  </button>
361
- `,this)};function ZL(n){const e=n.toLocaleDateString("en-US",{month:"long",day:"numeric",year:"numeric"}),t=12,r=n.getHours(),i=r%t===0?t:r%t,s=n.getMinutes().toString().padStart(2,"0"),o=r>=t?"pm":"am";return`${e} at ${i}:${s}${o}`}customElements.define("screen-create-button",FL);function HL(n,e){let t=null;const r=()=>e((t==null?void 0:t.messages)??[]),i=()=>{const o=n.getActiveClient();o!==t&&(t==null||t.removeEventListener("change",r),t=o,t&&(t.addEventListener("change",r),t.connect().catch(a=>{console.error("ACPClient.connect() failed",a)})),r())};n.addEventListener("change",i),i();const s=()=>{n.removeEventListener("change",i),t==null||t.removeEventListener("change",r),t=null};return{dispose:s,[Symbol.dispose](){s()}}}/*! @license DOMPurify 3.3.3 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.3.3/LICENSE */const{entries:Yy,setPrototypeOf:If,isFrozen:WL,getPrototypeOf:BL,getOwnPropertyDescriptor:VL}=Object;let{freeze:Ue,seal:lt,create:ta}=Object,{apply:hu,construct:du}=typeof Reflect<"u"&&Reflect;Ue||(Ue=function(e){return e});lt||(lt=function(e){return e});hu||(hu=function(e,t){for(var r=arguments.length,i=new Array(r>2?r-2:0),s=2;s<r;s++)i[s-2]=arguments[s];return e.apply(t,i)});du||(du=function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];return new e(...r)});const Mo=Fe(Array.prototype.forEach),GL=Fe(Array.prototype.lastIndexOf),Cf=Fe(Array.prototype.pop),Mi=Fe(Array.prototype.push),jL=Fe(Array.prototype.splice),na=Fe(String.prototype.toLowerCase),hc=Fe(String.prototype.toString),dc=Fe(String.prototype.match),zi=Fe(String.prototype.replace),qL=Fe(String.prototype.indexOf),YL=Fe(String.prototype.trim),Xe=Fe(Object.prototype.hasOwnProperty),Oe=Fe(RegExp.prototype.test),Ni=XL(TypeError);function Fe(n){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];return hu(n,e,r)}}function XL(n){return function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return du(n,t)}}function V(n,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:na;If&&If(n,null);let r=e.length;for(;r--;){let i=e[r];if(typeof i=="string"){const s=t(i);s!==i&&(WL(e)||(e[r]=s),i=s)}n[i]=!0}return n}function KL(n){for(let e=0;e<n.length;e++)Xe(n,e)||(n[e]=null);return n}function At(n){const e=ta(null);for(const[t,r]of Yy(n))Xe(n,t)&&(Array.isArray(r)?e[t]=KL(r):r&&typeof r=="object"&&r.constructor===Object?e[t]=At(r):e[t]=r);return e}function Ui(n,e){for(;n!==null;){const r=VL(n,e);if(r){if(r.get)return Fe(r.get);if(typeof r.value=="function")return Fe(r.value)}n=BL(n)}function t(){return null}return t}const Pf=Ue(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),pc=Ue(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),fc=Ue(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),JL=Ue(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),gc=Ue(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),QL=Ue(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Rf=Ue(["#text"]),Df=Ue(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),mc=Ue(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),Lf=Ue(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),zo=Ue(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),eO=lt(/\{\{[\w\W]*|[\w\W]*\}\}/gm),tO=lt(/<%[\w\W]*|[\w\W]*%>/gm),nO=lt(/\$\{[\w\W]*/gm),rO=lt(/^data-[\-\w.\u00B7-\uFFFF]+$/),iO=lt(/^aria-[\-\w]+$/),Xy=lt(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),sO=lt(/^(?:\w+script|data):/i),oO=lt(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Ky=lt(/^html$/i),aO=lt(/^[a-z][.\w]*(-[.\w]+)+$/i);var Of=Object.freeze({__proto__:null,ARIA_ATTR:iO,ATTR_WHITESPACE:oO,CUSTOM_ELEMENT:aO,DATA_ATTR:rO,DOCTYPE_NAME:Ky,ERB_EXPR:tO,IS_ALLOWED_URI:Xy,IS_SCRIPT_OR_DATA:sO,MUSTACHE_EXPR:eO,TMPLIT_EXPR:nO});const Fi={element:1,text:3,progressingInstruction:7,comment:8,document:9},lO=function(){return typeof window>"u"?null:window},cO=function(e,t){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let r=null;const i="data-tt-policy-suffix";t&&t.hasAttribute(i)&&(r=t.getAttribute(i));const s="dompurify"+(r?"#"+r:"");try{return e.createPolicy(s,{createHTML(o){return o},createScriptURL(o){return o}})}catch{return console.warn("TrustedTypes policy "+s+" could not be created."),null}},Mf=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Jy(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:lO();const e=z=>Jy(z);if(e.version="3.3.3",e.removed=[],!n||!n.document||n.document.nodeType!==Fi.document||!n.Element)return e.isSupported=!1,e;let{document:t}=n;const r=t,i=r.currentScript,{DocumentFragment:s,HTMLTemplateElement:o,Node:a,Element:c,NodeFilter:u,NamedNodeMap:h=n.NamedNodeMap||n.MozNamedAttrMap,HTMLFormElement:p,DOMParser:v,trustedTypes:g}=n,E=c.prototype,_=Ui(E,"cloneNode"),C=Ui(E,"remove"),N=Ui(E,"nextSibling"),P=Ui(E,"childNodes"),W=Ui(E,"parentNode");if(typeof o=="function"){const z=t.createElement("template");z.content&&z.content.ownerDocument&&(t=z.content.ownerDocument)}let L,H="";const{implementation:F,createNodeIterator:ce,createDocumentFragment:ue,getElementsByTagName:Ti}=t,{importNode:co}=r;let xe=Mf();e.isSupported=typeof Yy=="function"&&typeof W=="function"&&F&&F.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:An,ERB_EXPR:St,TMPLIT_EXPR:nn,DATA_ATTR:cl,ARIA_ATTR:uo,IS_SCRIPT_OR_DATA:gb,ATTR_WHITESPACE:xh,CUSTOM_ELEMENT:mb}=Of;let{IS_ALLOWED_URI:Ah}=Of,_e=null;const $h=V({},[...Pf,...pc,...fc,...gc,...Rf]);let Ae=null;const Th=V({},[...Df,...mc,...Lf,...zo]);let me=Object.seal(ta(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}})),Ii=null,ho=null;const rn=Object.seal(ta(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Ih=!0,ul=!0,Ch=!1,Ph=!0,Sr=!1,po=!0,$n=!1,hl=!1,dl=!1,_r=!1,fo=!1,go=!1,Rh=!0,Dh=!1;const vb="user-content-";let pl=!0,Ci=!1,kr={},_t=null;const fl=V({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let Lh=null;const Oh=V({},["audio","video","img","source","image","track"]);let gl=null;const Mh=V({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),mo="http://www.w3.org/1998/Math/MathML",vo="http://www.w3.org/2000/svg",Mt="http://www.w3.org/1999/xhtml";let Er=Mt,ml=!1,vl=null;const yb=V({},[mo,vo,Mt],hc);let yo=V({},["mi","mo","mn","ms","mtext"]),bo=V({},["annotation-xml"]);const bb=V({},["title","style","font","a","script"]);let Pi=null;const wb=["application/xhtml+xml","text/html"],Sb="text/html";let be=null,xr=null;const _b=t.createElement("form"),zh=function(y){return y instanceof RegExp||y instanceof Function},yl=function(){let y=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(xr&&xr===y)){if((!y||typeof y!="object")&&(y={}),y=At(y),Pi=wb.indexOf(y.PARSER_MEDIA_TYPE)===-1?Sb:y.PARSER_MEDIA_TYPE,be=Pi==="application/xhtml+xml"?hc:na,_e=Xe(y,"ALLOWED_TAGS")?V({},y.ALLOWED_TAGS,be):$h,Ae=Xe(y,"ALLOWED_ATTR")?V({},y.ALLOWED_ATTR,be):Th,vl=Xe(y,"ALLOWED_NAMESPACES")?V({},y.ALLOWED_NAMESPACES,hc):yb,gl=Xe(y,"ADD_URI_SAFE_ATTR")?V(At(Mh),y.ADD_URI_SAFE_ATTR,be):Mh,Lh=Xe(y,"ADD_DATA_URI_TAGS")?V(At(Oh),y.ADD_DATA_URI_TAGS,be):Oh,_t=Xe(y,"FORBID_CONTENTS")?V({},y.FORBID_CONTENTS,be):fl,Ii=Xe(y,"FORBID_TAGS")?V({},y.FORBID_TAGS,be):At({}),ho=Xe(y,"FORBID_ATTR")?V({},y.FORBID_ATTR,be):At({}),kr=Xe(y,"USE_PROFILES")?y.USE_PROFILES:!1,Ih=y.ALLOW_ARIA_ATTR!==!1,ul=y.ALLOW_DATA_ATTR!==!1,Ch=y.ALLOW_UNKNOWN_PROTOCOLS||!1,Ph=y.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Sr=y.SAFE_FOR_TEMPLATES||!1,po=y.SAFE_FOR_XML!==!1,$n=y.WHOLE_DOCUMENT||!1,_r=y.RETURN_DOM||!1,fo=y.RETURN_DOM_FRAGMENT||!1,go=y.RETURN_TRUSTED_TYPE||!1,dl=y.FORCE_BODY||!1,Rh=y.SANITIZE_DOM!==!1,Dh=y.SANITIZE_NAMED_PROPS||!1,pl=y.KEEP_CONTENT!==!1,Ci=y.IN_PLACE||!1,Ah=y.ALLOWED_URI_REGEXP||Xy,Er=y.NAMESPACE||Mt,yo=y.MATHML_TEXT_INTEGRATION_POINTS||yo,bo=y.HTML_INTEGRATION_POINTS||bo,me=y.CUSTOM_ELEMENT_HANDLING||{},y.CUSTOM_ELEMENT_HANDLING&&zh(y.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(me.tagNameCheck=y.CUSTOM_ELEMENT_HANDLING.tagNameCheck),y.CUSTOM_ELEMENT_HANDLING&&zh(y.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(me.attributeNameCheck=y.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),y.CUSTOM_ELEMENT_HANDLING&&typeof y.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(me.allowCustomizedBuiltInElements=y.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Sr&&(ul=!1),fo&&(_r=!0),kr&&(_e=V({},Rf),Ae=ta(null),kr.html===!0&&(V(_e,Pf),V(Ae,Df)),kr.svg===!0&&(V(_e,pc),V(Ae,mc),V(Ae,zo)),kr.svgFilters===!0&&(V(_e,fc),V(Ae,mc),V(Ae,zo)),kr.mathMl===!0&&(V(_e,gc),V(Ae,Lf),V(Ae,zo))),Xe(y,"ADD_TAGS")||(rn.tagCheck=null),Xe(y,"ADD_ATTR")||(rn.attributeCheck=null),y.ADD_TAGS&&(typeof y.ADD_TAGS=="function"?rn.tagCheck=y.ADD_TAGS:(_e===$h&&(_e=At(_e)),V(_e,y.ADD_TAGS,be))),y.ADD_ATTR&&(typeof y.ADD_ATTR=="function"?rn.attributeCheck=y.ADD_ATTR:(Ae===Th&&(Ae=At(Ae)),V(Ae,y.ADD_ATTR,be))),y.ADD_URI_SAFE_ATTR&&V(gl,y.ADD_URI_SAFE_ATTR,be),y.FORBID_CONTENTS&&(_t===fl&&(_t=At(_t)),V(_t,y.FORBID_CONTENTS,be)),y.ADD_FORBID_CONTENTS&&(_t===fl&&(_t=At(_t)),V(_t,y.ADD_FORBID_CONTENTS,be)),pl&&(_e["#text"]=!0),$n&&V(_e,["html","head","body"]),_e.table&&(V(_e,["tbody"]),delete Ii.tbody),y.TRUSTED_TYPES_POLICY){if(typeof y.TRUSTED_TYPES_POLICY.createHTML!="function")throw Ni('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof y.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Ni('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');L=y.TRUSTED_TYPES_POLICY,H=L.createHTML("")}else L===void 0&&(L=cO(g,i)),L!==null&&typeof H=="string"&&(H=L.createHTML(""));Ue&&Ue(y),xr=y}},Nh=V({},[...pc,...fc,...JL]),Uh=V({},[...gc,...QL]),kb=function(y){let I=W(y);(!I||!I.tagName)&&(I={namespaceURI:Er,tagName:"template"});const R=na(y.tagName),oe=na(I.tagName);return vl[y.namespaceURI]?y.namespaceURI===vo?I.namespaceURI===Mt?R==="svg":I.namespaceURI===mo?R==="svg"&&(oe==="annotation-xml"||yo[oe]):!!Nh[R]:y.namespaceURI===mo?I.namespaceURI===Mt?R==="math":I.namespaceURI===vo?R==="math"&&bo[oe]:!!Uh[R]:y.namespaceURI===Mt?I.namespaceURI===vo&&!bo[oe]||I.namespaceURI===mo&&!yo[oe]?!1:!Uh[R]&&(bb[R]||!Nh[R]):!!(Pi==="application/xhtml+xml"&&vl[y.namespaceURI]):!1},kt=function(y){Mi(e.removed,{element:y});try{W(y).removeChild(y)}catch{C(y)}},Tn=function(y,I){try{Mi(e.removed,{attribute:I.getAttributeNode(y),from:I})}catch{Mi(e.removed,{attribute:null,from:I})}if(I.removeAttribute(y),y==="is")if(_r||fo)try{kt(I)}catch{}else try{I.setAttribute(y,"")}catch{}},Fh=function(y){let I=null,R=null;if(dl)y="<remove></remove>"+y;else{const ve=dc(y,/^[\r\n\t ]+/);R=ve&&ve[0]}Pi==="application/xhtml+xml"&&Er===Mt&&(y='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+y+"</body></html>");const oe=L?L.createHTML(y):y;if(Er===Mt)try{I=new v().parseFromString(oe,Pi)}catch{}if(!I||!I.documentElement){I=F.createDocument(Er,"template",null);try{I.documentElement.innerHTML=ml?H:oe}catch{}}const De=I.body||I.documentElement;return y&&R&&De.insertBefore(t.createTextNode(R),De.childNodes[0]||null),Er===Mt?Ti.call(I,$n?"html":"body")[0]:$n?I.documentElement:De},Zh=function(y){return ce.call(y.ownerDocument||y,y,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},bl=function(y){return y instanceof p&&(typeof y.nodeName!="string"||typeof y.textContent!="string"||typeof y.removeChild!="function"||!(y.attributes instanceof h)||typeof y.removeAttribute!="function"||typeof y.setAttribute!="function"||typeof y.namespaceURI!="string"||typeof y.insertBefore!="function"||typeof y.hasChildNodes!="function")},Hh=function(y){return typeof a=="function"&&y instanceof a};function zt(z,y,I){Mo(z,R=>{R.call(e,y,I,xr)})}const Wh=function(y){let I=null;if(zt(xe.beforeSanitizeElements,y,null),bl(y))return kt(y),!0;const R=be(y.nodeName);if(zt(xe.uponSanitizeElement,y,{tagName:R,allowedTags:_e}),po&&y.hasChildNodes()&&!Hh(y.firstElementChild)&&Oe(/<[/\w!]/g,y.innerHTML)&&Oe(/<[/\w!]/g,y.textContent)||y.nodeType===Fi.progressingInstruction||po&&y.nodeType===Fi.comment&&Oe(/<[/\w]/g,y.data))return kt(y),!0;if(!(rn.tagCheck instanceof Function&&rn.tagCheck(R))&&(!_e[R]||Ii[R])){if(!Ii[R]&&Vh(R)&&(me.tagNameCheck instanceof RegExp&&Oe(me.tagNameCheck,R)||me.tagNameCheck instanceof Function&&me.tagNameCheck(R)))return!1;if(pl&&!_t[R]){const oe=W(y)||y.parentNode,De=P(y)||y.childNodes;if(De&&oe){const ve=De.length;for(let Ze=ve-1;Ze>=0;--Ze){const Nt=_(De[Ze],!0);Nt.__removalCount=(y.__removalCount||0)+1,oe.insertBefore(Nt,N(y))}}}return kt(y),!0}return y instanceof c&&!kb(y)||(R==="noscript"||R==="noembed"||R==="noframes")&&Oe(/<\/no(script|embed|frames)/i,y.innerHTML)?(kt(y),!0):(Sr&&y.nodeType===Fi.text&&(I=y.textContent,Mo([An,St,nn],oe=>{I=zi(I,oe," ")}),y.textContent!==I&&(Mi(e.removed,{element:y.cloneNode()}),y.textContent=I)),zt(xe.afterSanitizeElements,y,null),!1)},Bh=function(y,I,R){if(ho[I]||Rh&&(I==="id"||I==="name")&&(R in t||R in _b))return!1;if(!(ul&&!ho[I]&&Oe(cl,I))){if(!(Ih&&Oe(uo,I))){if(!(rn.attributeCheck instanceof Function&&rn.attributeCheck(I,y))){if(!Ae[I]||ho[I]){if(!(Vh(y)&&(me.tagNameCheck instanceof RegExp&&Oe(me.tagNameCheck,y)||me.tagNameCheck instanceof Function&&me.tagNameCheck(y))&&(me.attributeNameCheck instanceof RegExp&&Oe(me.attributeNameCheck,I)||me.attributeNameCheck instanceof Function&&me.attributeNameCheck(I,y))||I==="is"&&me.allowCustomizedBuiltInElements&&(me.tagNameCheck instanceof RegExp&&Oe(me.tagNameCheck,R)||me.tagNameCheck instanceof Function&&me.tagNameCheck(R))))return!1}else if(!gl[I]){if(!Oe(Ah,zi(R,xh,""))){if(!((I==="src"||I==="xlink:href"||I==="href")&&y!=="script"&&qL(R,"data:")===0&&Lh[y])){if(!(Ch&&!Oe(gb,zi(R,xh,"")))){if(R)return!1}}}}}}}return!0},Vh=function(y){return y!=="annotation-xml"&&dc(y,mb)},Gh=function(y){zt(xe.beforeSanitizeAttributes,y,null);const{attributes:I}=y;if(!I||bl(y))return;const R={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Ae,forceKeepAttr:void 0};let oe=I.length;for(;oe--;){const De=I[oe],{name:ve,namespaceURI:Ze,value:Nt}=De,Ar=be(ve),wl=Nt;let $e=ve==="value"?wl:YL(wl);if(R.attrName=Ar,R.attrValue=$e,R.keepAttr=!0,R.forceKeepAttr=void 0,zt(xe.uponSanitizeAttribute,y,R),$e=R.attrValue,Dh&&(Ar==="id"||Ar==="name")&&(Tn(ve,y),$e=vb+$e),po&&Oe(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,$e)){Tn(ve,y);continue}if(Ar==="attributename"&&dc($e,"href")){Tn(ve,y);continue}if(R.forceKeepAttr)continue;if(!R.keepAttr){Tn(ve,y);continue}if(!Ph&&Oe(/\/>/i,$e)){Tn(ve,y);continue}Sr&&Mo([An,St,nn],qh=>{$e=zi($e,qh," ")});const jh=be(y.nodeName);if(!Bh(jh,Ar,$e)){Tn(ve,y);continue}if(L&&typeof g=="object"&&typeof g.getAttributeType=="function"&&!Ze)switch(g.getAttributeType(jh,Ar)){case"TrustedHTML":{$e=L.createHTML($e);break}case"TrustedScriptURL":{$e=L.createScriptURL($e);break}}if($e!==wl)try{Ze?y.setAttributeNS(Ze,ve,$e):y.setAttribute(ve,$e),bl(y)?kt(y):Cf(e.removed)}catch{Tn(ve,y)}}zt(xe.afterSanitizeAttributes,y,null)},Eb=function z(y){let I=null;const R=Zh(y);for(zt(xe.beforeSanitizeShadowDOM,y,null);I=R.nextNode();)zt(xe.uponSanitizeShadowNode,I,null),Wh(I),Gh(I),I.content instanceof s&&z(I.content);zt(xe.afterSanitizeShadowDOM,y,null)};return e.sanitize=function(z){let y=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},I=null,R=null,oe=null,De=null;if(ml=!z,ml&&(z="<!-->"),typeof z!="string"&&!Hh(z))if(typeof z.toString=="function"){if(z=z.toString(),typeof z!="string")throw Ni("dirty is not a string, aborting")}else throw Ni("toString is not a function");if(!e.isSupported)return z;if(hl||yl(y),e.removed=[],typeof z=="string"&&(Ci=!1),Ci){if(z.nodeName){const Nt=be(z.nodeName);if(!_e[Nt]||Ii[Nt])throw Ni("root node is forbidden and cannot be sanitized in-place")}}else if(z instanceof a)I=Fh("<!---->"),R=I.ownerDocument.importNode(z,!0),R.nodeType===Fi.element&&R.nodeName==="BODY"||R.nodeName==="HTML"?I=R:I.appendChild(R);else{if(!_r&&!Sr&&!$n&&z.indexOf("<")===-1)return L&&go?L.createHTML(z):z;if(I=Fh(z),!I)return _r?null:go?H:""}I&&dl&&kt(I.firstChild);const ve=Zh(Ci?z:I);for(;oe=ve.nextNode();)Wh(oe),Gh(oe),oe.content instanceof s&&Eb(oe.content);if(Ci)return z;if(_r){if(fo)for(De=ue.call(I.ownerDocument);I.firstChild;)De.appendChild(I.firstChild);else De=I;return(Ae.shadowroot||Ae.shadowrootmode)&&(De=co.call(r,De,!0)),De}let Ze=$n?I.outerHTML:I.innerHTML;return $n&&_e["!doctype"]&&I.ownerDocument&&I.ownerDocument.doctype&&I.ownerDocument.doctype.name&&Oe(Ky,I.ownerDocument.doctype.name)&&(Ze="<!DOCTYPE "+I.ownerDocument.doctype.name+`>
362
- `+Ze),Sr&&Mo([An,St,nn],Nt=>{Ze=zi(Ze,Nt," ")}),L&&go?L.createHTML(Ze):Ze},e.setConfig=function(){let z=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};yl(z),hl=!0},e.clearConfig=function(){xr=null,hl=!1},e.isValidAttribute=function(z,y,I){xr||yl({});const R=be(z),oe=be(y);return Bh(R,oe,I)},e.addHook=function(z,y){typeof y=="function"&&Mi(xe[z],y)},e.removeHook=function(z,y){if(y!==void 0){const I=GL(xe[z],y);return I===-1?void 0:jL(xe[z],I,1)[0]}return Cf(xe[z])},e.removeHooks=function(z){xe[z]=[]},e.removeAllHooks=function(){xe=Mf()},e}var Qy=Jy();function fh(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var wr=fh();function eb(n){wr=n}var zn={exec:()=>null};function q(n,e=""){let t=typeof n=="string"?n:n.source,r={replace:(i,s)=>{let o=typeof s=="string"?s:s.source;return o=o.replace(Ne.caret,"$1"),t=t.replace(i,o),r},getRegex:()=>new RegExp(t,e)};return r}var uO=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),Ne={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:n=>new RegExp(`^( {0,3}${n})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}#`),htmlBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}<(?:[a-z].*>|!--)`,"i"),blockquoteBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}>`)},hO=/^(?:[ \t]*(?:\n|$))+/,dO=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,pO=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,lo=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,fO=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,gh=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,tb=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,nb=q(tb).replace(/bull/g,gh).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),gO=q(tb).replace(/bull/g,gh).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(),mh=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,mO=/^[^\n]+/,vh=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,vO=q(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",vh).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),yO=q(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,gh).getRegex(),ol="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",yh=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,bO=q("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",yh).replace("tag",ol).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),rb=q(mh).replace("hr",lo).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",ol).getRegex(),wO=q(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",rb).getRegex(),bh={blockquote:wO,code:dO,def:vO,fences:pO,heading:fO,hr:lo,html:bO,lheading:nb,list:yO,newline:hO,paragraph:rb,table:zn,text:mO},zf=q("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",lo).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",ol).getRegex(),SO={...bh,lheading:gO,table:zf,paragraph:q(mh).replace("hr",lo).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",zf).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",ol).getRegex()},_O={...bh,html:q(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",yh).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:zn,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:q(mh).replace("hr",lo).replace("heading",` *#{1,6} *[^
363
- ]`).replace("lheading",nb).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},kO=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,EO=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,ib=/^( {2,}|\\)\n(?!\s*$)/,xO=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,$i=/[\p{P}\p{S}]/u,al=/[\s\p{P}\p{S}]/u,wh=/[^\s\p{P}\p{S}]/u,AO=q(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,al).getRegex(),sb=/(?!~)[\p{P}\p{S}]/u,$O=/(?!~)[\s\p{P}\p{S}]/u,TO=/(?:[^\s\p{P}\p{S}]|~)/u,IO=q(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",uO?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),ob=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,CO=q(ob,"u").replace(/punct/g,$i).getRegex(),PO=q(ob,"u").replace(/punct/g,sb).getRegex(),ab="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",RO=q(ab,"gu").replace(/notPunctSpace/g,wh).replace(/punctSpace/g,al).replace(/punct/g,$i).getRegex(),DO=q(ab,"gu").replace(/notPunctSpace/g,TO).replace(/punctSpace/g,$O).replace(/punct/g,sb).getRegex(),LO=q("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,wh).replace(/punctSpace/g,al).replace(/punct/g,$i).getRegex(),OO=q(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,$i).getRegex(),MO="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",zO=q(MO,"gu").replace(/notPunctSpace/g,wh).replace(/punctSpace/g,al).replace(/punct/g,$i).getRegex(),NO=q(/\\(punct)/,"gu").replace(/punct/g,$i).getRegex(),UO=q(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),FO=q(yh).replace("(?:-->|$)","-->").getRegex(),ZO=q("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",FO).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),ba=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,HO=q(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",ba).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),lb=q(/^!?\[(label)\]\[(ref)\]/).replace("label",ba).replace("ref",vh).getRegex(),cb=q(/^!?\[(ref)\](?:\[\])?/).replace("ref",vh).getRegex(),WO=q("reflink|nolink(?!\\()","g").replace("reflink",lb).replace("nolink",cb).getRegex(),Nf=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Sh={_backpedal:zn,anyPunctuation:NO,autolink:UO,blockSkip:IO,br:ib,code:EO,del:zn,delLDelim:zn,delRDelim:zn,emStrongLDelim:CO,emStrongRDelimAst:RO,emStrongRDelimUnd:LO,escape:kO,link:HO,nolink:cb,punctuation:AO,reflink:lb,reflinkSearch:WO,tag:ZO,text:xO,url:zn},BO={...Sh,link:q(/^!?\[(label)\]\((.*?)\)/).replace("label",ba).getRegex(),reflink:q(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",ba).getRegex()},pu={...Sh,emStrongRDelimAst:DO,emStrongLDelim:PO,delLDelim:OO,delRDelim:zO,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()},VO={...pu,br:q(ib).replace("{2,}","*").getRegex(),text:q(pu.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},No={normal:bh,gfm:SO,pedantic:_O},Zi={normal:Sh,gfm:pu,breaks:VO,pedantic:BO},GO={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Uf=n=>GO[n];function $t(n,e){if(e){if(Ne.escapeTest.test(n))return n.replace(Ne.escapeReplace,Uf)}else if(Ne.escapeTestNoEncode.test(n))return n.replace(Ne.escapeReplaceNoEncode,Uf);return n}function Ff(n){try{n=encodeURI(n).replace(Ne.percentDecode,"%")}catch{return null}return n}function Zf(n,e){var s;let t=n.replace(Ne.findPipe,(o,a,c)=>{let u=!1,h=a;for(;--h>=0&&c[h]==="\\";)u=!u;return u?"|":" |"}),r=t.split(Ne.splitPipe),i=0;if(r[0].trim()||r.shift(),r.length>0&&!((s=r.at(-1))!=null&&s.trim())&&r.pop(),e)if(r.length>e)r.splice(e);else for(;r.length<e;)r.push("");for(;i<r.length;i++)r[i]=r[i].trim().replace(Ne.slashPipe,"|");return r}function Hi(n,e,t){let r=n.length;if(r===0)return"";let i=0;for(;i<r&&n.charAt(r-i-1)===e;)i++;return n.slice(0,r-i)}function jO(n,e){if(n.indexOf(e[1])===-1)return-1;let t=0;for(let r=0;r<n.length;r++)if(n[r]==="\\")r++;else if(n[r]===e[0])t++;else if(n[r]===e[1]&&(t--,t<0))return r;return t>0?-2:-1}function qO(n,e=0){let t=e,r="";for(let i of n)if(i===" "){let s=4-t%4;r+=" ".repeat(s),t+=s}else r+=i,t++;return r}function Hf(n,e,t,r,i){let s=e.href,o=e.title||null,a=n[1].replace(i.other.outputLinkReplace,"$1");r.state.inLink=!0;let c={type:n[0].charAt(0)==="!"?"image":"link",raw:t,href:s,title:o,text:a,tokens:r.inlineTokens(a)};return r.state.inLink=!1,c}function YO(n,e,t){let r=n.match(t.other.indentCodeCompensation);if(r===null)return e;let i=r[1];return e.split(`
361
+ `,this)};function HL(n){const e=n.toLocaleDateString("en-US",{month:"long",day:"numeric",year:"numeric"}),t=12,r=n.getHours(),i=r%t===0?t:r%t,s=n.getMinutes().toString().padStart(2,"0"),o=r>=t?"pm":"am";return`${e} at ${i}:${s}${o}`}customElements.define("screen-create-button",ZL);function WL(n,e){let t=null;const r=()=>e((t==null?void 0:t.messages)??[]),i=()=>{const o=n.getActiveClient();o!==t&&(t==null||t.removeEventListener("change",r),t=o,t&&(t.addEventListener("change",r),t.connect().catch(a=>{console.error("ACPClient.connect() failed",a)})),r())};n.addEventListener("change",i),i();const s=()=>{n.removeEventListener("change",i),t==null||t.removeEventListener("change",r),t=null};return{dispose:s,[Symbol.dispose](){s()}}}/*! @license DOMPurify 3.3.3 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.3.3/LICENSE */const{entries:Ky,setPrototypeOf:Pf,isFrozen:GL,getPrototypeOf:VL,getOwnPropertyDescriptor:BL}=Object;let{freeze:Ue,seal:lt,create:ta}=Object,{apply:fu,construct:gu}=typeof Reflect<"u"&&Reflect;Ue||(Ue=function(e){return e});lt||(lt=function(e){return e});fu||(fu=function(e,t){for(var r=arguments.length,i=new Array(r>2?r-2:0),s=2;s<r;s++)i[s-2]=arguments[s];return e.apply(t,i)});gu||(gu=function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];return new e(...r)});const Mo=Fe(Array.prototype.forEach),jL=Fe(Array.prototype.lastIndexOf),Rf=Fe(Array.prototype.pop),Mi=Fe(Array.prototype.push),qL=Fe(Array.prototype.splice),na=Fe(String.prototype.toLowerCase),fc=Fe(String.prototype.toString),gc=Fe(String.prototype.match),zi=Fe(String.prototype.replace),YL=Fe(String.prototype.indexOf),XL=Fe(String.prototype.trim),Xe=Fe(Object.prototype.hasOwnProperty),Oe=Fe(RegExp.prototype.test),Ni=KL(TypeError);function Fe(n){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];return fu(n,e,r)}}function KL(n){return function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return gu(n,t)}}function V(n,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:na;Pf&&Pf(n,null);let r=e.length;for(;r--;){let i=e[r];if(typeof i=="string"){const s=t(i);s!==i&&(GL(e)||(e[r]=s),i=s)}n[i]=!0}return n}function JL(n){for(let e=0;e<n.length;e++)Xe(n,e)||(n[e]=null);return n}function At(n){const e=ta(null);for(const[t,r]of Ky(n))Xe(n,t)&&(Array.isArray(r)?e[t]=JL(r):r&&typeof r=="object"&&r.constructor===Object?e[t]=At(r):e[t]=r);return e}function Ui(n,e){for(;n!==null;){const r=BL(n,e);if(r){if(r.get)return Fe(r.get);if(typeof r.value=="function")return Fe(r.value)}n=VL(n)}function t(){return null}return t}const Df=Ue(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),mc=Ue(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),vc=Ue(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),QL=Ue(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),yc=Ue(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),eO=Ue(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Lf=Ue(["#text"]),Of=Ue(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),bc=Ue(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),Mf=Ue(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),zo=Ue(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),tO=lt(/\{\{[\w\W]*|[\w\W]*\}\}/gm),nO=lt(/<%[\w\W]*|[\w\W]*%>/gm),rO=lt(/\$\{[\w\W]*/gm),iO=lt(/^data-[\-\w.\u00B7-\uFFFF]+$/),sO=lt(/^aria-[\-\w]+$/),Jy=lt(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),oO=lt(/^(?:\w+script|data):/i),aO=lt(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Qy=lt(/^html$/i),lO=lt(/^[a-z][.\w]*(-[.\w]+)+$/i);var zf=Object.freeze({__proto__:null,ARIA_ATTR:sO,ATTR_WHITESPACE:aO,CUSTOM_ELEMENT:lO,DATA_ATTR:iO,DOCTYPE_NAME:Qy,ERB_EXPR:nO,IS_ALLOWED_URI:Jy,IS_SCRIPT_OR_DATA:oO,MUSTACHE_EXPR:tO,TMPLIT_EXPR:rO});const Fi={element:1,text:3,progressingInstruction:7,comment:8,document:9},cO=function(){return typeof window>"u"?null:window},uO=function(e,t){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let r=null;const i="data-tt-policy-suffix";t&&t.hasAttribute(i)&&(r=t.getAttribute(i));const s="dompurify"+(r?"#"+r:"");try{return e.createPolicy(s,{createHTML(o){return o},createScriptURL(o){return o}})}catch{return console.warn("TrustedTypes policy "+s+" could not be created."),null}},Nf=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function eb(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:cO();const e=z=>eb(z);if(e.version="3.3.3",e.removed=[],!n||!n.document||n.document.nodeType!==Fi.document||!n.Element)return e.isSupported=!1,e;let{document:t}=n;const r=t,i=r.currentScript,{DocumentFragment:s,HTMLTemplateElement:o,Node:a,Element:c,NodeFilter:u,NamedNodeMap:h=n.NamedNodeMap||n.MozNamedAttrMap,HTMLFormElement:p,DOMParser:v,trustedTypes:g}=n,E=c.prototype,_=Ui(E,"cloneNode"),C=Ui(E,"remove"),N=Ui(E,"nextSibling"),P=Ui(E,"childNodes"),W=Ui(E,"parentNode");if(typeof o=="function"){const z=t.createElement("template");z.content&&z.content.ownerDocument&&(t=z.content.ownerDocument)}let L,H="";const{implementation:F,createNodeIterator:ce,createDocumentFragment:ue,getElementsByTagName:Ti}=t,{importNode:co}=r;let xe=Nf();e.isSupported=typeof Ky=="function"&&typeof W=="function"&&F&&F.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:An,ERB_EXPR:St,TMPLIT_EXPR:nn,DATA_ATTR:cl,ARIA_ATTR:uo,IS_SCRIPT_OR_DATA:vb,ATTR_WHITESPACE:Th,CUSTOM_ELEMENT:yb}=zf;let{IS_ALLOWED_URI:Ih}=zf,_e=null;const Ch=V({},[...Df,...mc,...vc,...yc,...Lf]);let Ae=null;const Ph=V({},[...Of,...bc,...Mf,...zo]);let me=Object.seal(ta(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}})),Ii=null,ho=null;const rn=Object.seal(ta(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Rh=!0,ul=!0,Dh=!1,Lh=!0,Sr=!1,po=!0,$n=!1,hl=!1,dl=!1,_r=!1,fo=!1,go=!1,Oh=!0,Mh=!1;const bb="user-content-";let pl=!0,Ci=!1,kr={},_t=null;const fl=V({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let zh=null;const Nh=V({},["audio","video","img","source","image","track"]);let gl=null;const Uh=V({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),mo="http://www.w3.org/1998/Math/MathML",vo="http://www.w3.org/2000/svg",Mt="http://www.w3.org/1999/xhtml";let Er=Mt,ml=!1,vl=null;const wb=V({},[mo,vo,Mt],fc);let yo=V({},["mi","mo","mn","ms","mtext"]),bo=V({},["annotation-xml"]);const Sb=V({},["title","style","font","a","script"]);let Pi=null;const _b=["application/xhtml+xml","text/html"],kb="text/html";let be=null,xr=null;const Eb=t.createElement("form"),Fh=function(y){return y instanceof RegExp||y instanceof Function},yl=function(){let y=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(xr&&xr===y)){if((!y||typeof y!="object")&&(y={}),y=At(y),Pi=_b.indexOf(y.PARSER_MEDIA_TYPE)===-1?kb:y.PARSER_MEDIA_TYPE,be=Pi==="application/xhtml+xml"?fc:na,_e=Xe(y,"ALLOWED_TAGS")?V({},y.ALLOWED_TAGS,be):Ch,Ae=Xe(y,"ALLOWED_ATTR")?V({},y.ALLOWED_ATTR,be):Ph,vl=Xe(y,"ALLOWED_NAMESPACES")?V({},y.ALLOWED_NAMESPACES,fc):wb,gl=Xe(y,"ADD_URI_SAFE_ATTR")?V(At(Uh),y.ADD_URI_SAFE_ATTR,be):Uh,zh=Xe(y,"ADD_DATA_URI_TAGS")?V(At(Nh),y.ADD_DATA_URI_TAGS,be):Nh,_t=Xe(y,"FORBID_CONTENTS")?V({},y.FORBID_CONTENTS,be):fl,Ii=Xe(y,"FORBID_TAGS")?V({},y.FORBID_TAGS,be):At({}),ho=Xe(y,"FORBID_ATTR")?V({},y.FORBID_ATTR,be):At({}),kr=Xe(y,"USE_PROFILES")?y.USE_PROFILES:!1,Rh=y.ALLOW_ARIA_ATTR!==!1,ul=y.ALLOW_DATA_ATTR!==!1,Dh=y.ALLOW_UNKNOWN_PROTOCOLS||!1,Lh=y.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Sr=y.SAFE_FOR_TEMPLATES||!1,po=y.SAFE_FOR_XML!==!1,$n=y.WHOLE_DOCUMENT||!1,_r=y.RETURN_DOM||!1,fo=y.RETURN_DOM_FRAGMENT||!1,go=y.RETURN_TRUSTED_TYPE||!1,dl=y.FORCE_BODY||!1,Oh=y.SANITIZE_DOM!==!1,Mh=y.SANITIZE_NAMED_PROPS||!1,pl=y.KEEP_CONTENT!==!1,Ci=y.IN_PLACE||!1,Ih=y.ALLOWED_URI_REGEXP||Jy,Er=y.NAMESPACE||Mt,yo=y.MATHML_TEXT_INTEGRATION_POINTS||yo,bo=y.HTML_INTEGRATION_POINTS||bo,me=y.CUSTOM_ELEMENT_HANDLING||{},y.CUSTOM_ELEMENT_HANDLING&&Fh(y.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(me.tagNameCheck=y.CUSTOM_ELEMENT_HANDLING.tagNameCheck),y.CUSTOM_ELEMENT_HANDLING&&Fh(y.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(me.attributeNameCheck=y.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),y.CUSTOM_ELEMENT_HANDLING&&typeof y.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(me.allowCustomizedBuiltInElements=y.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Sr&&(ul=!1),fo&&(_r=!0),kr&&(_e=V({},Lf),Ae=ta(null),kr.html===!0&&(V(_e,Df),V(Ae,Of)),kr.svg===!0&&(V(_e,mc),V(Ae,bc),V(Ae,zo)),kr.svgFilters===!0&&(V(_e,vc),V(Ae,bc),V(Ae,zo)),kr.mathMl===!0&&(V(_e,yc),V(Ae,Mf),V(Ae,zo))),Xe(y,"ADD_TAGS")||(rn.tagCheck=null),Xe(y,"ADD_ATTR")||(rn.attributeCheck=null),y.ADD_TAGS&&(typeof y.ADD_TAGS=="function"?rn.tagCheck=y.ADD_TAGS:(_e===Ch&&(_e=At(_e)),V(_e,y.ADD_TAGS,be))),y.ADD_ATTR&&(typeof y.ADD_ATTR=="function"?rn.attributeCheck=y.ADD_ATTR:(Ae===Ph&&(Ae=At(Ae)),V(Ae,y.ADD_ATTR,be))),y.ADD_URI_SAFE_ATTR&&V(gl,y.ADD_URI_SAFE_ATTR,be),y.FORBID_CONTENTS&&(_t===fl&&(_t=At(_t)),V(_t,y.FORBID_CONTENTS,be)),y.ADD_FORBID_CONTENTS&&(_t===fl&&(_t=At(_t)),V(_t,y.ADD_FORBID_CONTENTS,be)),pl&&(_e["#text"]=!0),$n&&V(_e,["html","head","body"]),_e.table&&(V(_e,["tbody"]),delete Ii.tbody),y.TRUSTED_TYPES_POLICY){if(typeof y.TRUSTED_TYPES_POLICY.createHTML!="function")throw Ni('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof y.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Ni('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');L=y.TRUSTED_TYPES_POLICY,H=L.createHTML("")}else L===void 0&&(L=uO(g,i)),L!==null&&typeof H=="string"&&(H=L.createHTML(""));Ue&&Ue(y),xr=y}},Zh=V({},[...mc,...vc,...QL]),Hh=V({},[...yc,...eO]),xb=function(y){let I=W(y);(!I||!I.tagName)&&(I={namespaceURI:Er,tagName:"template"});const R=na(y.tagName),oe=na(I.tagName);return vl[y.namespaceURI]?y.namespaceURI===vo?I.namespaceURI===Mt?R==="svg":I.namespaceURI===mo?R==="svg"&&(oe==="annotation-xml"||yo[oe]):!!Zh[R]:y.namespaceURI===mo?I.namespaceURI===Mt?R==="math":I.namespaceURI===vo?R==="math"&&bo[oe]:!!Hh[R]:y.namespaceURI===Mt?I.namespaceURI===vo&&!bo[oe]||I.namespaceURI===mo&&!yo[oe]?!1:!Hh[R]&&(Sb[R]||!Zh[R]):!!(Pi==="application/xhtml+xml"&&vl[y.namespaceURI]):!1},kt=function(y){Mi(e.removed,{element:y});try{W(y).removeChild(y)}catch{C(y)}},Tn=function(y,I){try{Mi(e.removed,{attribute:I.getAttributeNode(y),from:I})}catch{Mi(e.removed,{attribute:null,from:I})}if(I.removeAttribute(y),y==="is")if(_r||fo)try{kt(I)}catch{}else try{I.setAttribute(y,"")}catch{}},Wh=function(y){let I=null,R=null;if(dl)y="<remove></remove>"+y;else{const ve=gc(y,/^[\r\n\t ]+/);R=ve&&ve[0]}Pi==="application/xhtml+xml"&&Er===Mt&&(y='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+y+"</body></html>");const oe=L?L.createHTML(y):y;if(Er===Mt)try{I=new v().parseFromString(oe,Pi)}catch{}if(!I||!I.documentElement){I=F.createDocument(Er,"template",null);try{I.documentElement.innerHTML=ml?H:oe}catch{}}const De=I.body||I.documentElement;return y&&R&&De.insertBefore(t.createTextNode(R),De.childNodes[0]||null),Er===Mt?Ti.call(I,$n?"html":"body")[0]:$n?I.documentElement:De},Gh=function(y){return ce.call(y.ownerDocument||y,y,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},bl=function(y){return y instanceof p&&(typeof y.nodeName!="string"||typeof y.textContent!="string"||typeof y.removeChild!="function"||!(y.attributes instanceof h)||typeof y.removeAttribute!="function"||typeof y.setAttribute!="function"||typeof y.namespaceURI!="string"||typeof y.insertBefore!="function"||typeof y.hasChildNodes!="function")},Vh=function(y){return typeof a=="function"&&y instanceof a};function zt(z,y,I){Mo(z,R=>{R.call(e,y,I,xr)})}const Bh=function(y){let I=null;if(zt(xe.beforeSanitizeElements,y,null),bl(y))return kt(y),!0;const R=be(y.nodeName);if(zt(xe.uponSanitizeElement,y,{tagName:R,allowedTags:_e}),po&&y.hasChildNodes()&&!Vh(y.firstElementChild)&&Oe(/<[/\w!]/g,y.innerHTML)&&Oe(/<[/\w!]/g,y.textContent)||y.nodeType===Fi.progressingInstruction||po&&y.nodeType===Fi.comment&&Oe(/<[/\w]/g,y.data))return kt(y),!0;if(!(rn.tagCheck instanceof Function&&rn.tagCheck(R))&&(!_e[R]||Ii[R])){if(!Ii[R]&&qh(R)&&(me.tagNameCheck instanceof RegExp&&Oe(me.tagNameCheck,R)||me.tagNameCheck instanceof Function&&me.tagNameCheck(R)))return!1;if(pl&&!_t[R]){const oe=W(y)||y.parentNode,De=P(y)||y.childNodes;if(De&&oe){const ve=De.length;for(let Ze=ve-1;Ze>=0;--Ze){const Nt=_(De[Ze],!0);Nt.__removalCount=(y.__removalCount||0)+1,oe.insertBefore(Nt,N(y))}}}return kt(y),!0}return y instanceof c&&!xb(y)||(R==="noscript"||R==="noembed"||R==="noframes")&&Oe(/<\/no(script|embed|frames)/i,y.innerHTML)?(kt(y),!0):(Sr&&y.nodeType===Fi.text&&(I=y.textContent,Mo([An,St,nn],oe=>{I=zi(I,oe," ")}),y.textContent!==I&&(Mi(e.removed,{element:y.cloneNode()}),y.textContent=I)),zt(xe.afterSanitizeElements,y,null),!1)},jh=function(y,I,R){if(ho[I]||Oh&&(I==="id"||I==="name")&&(R in t||R in Eb))return!1;if(!(ul&&!ho[I]&&Oe(cl,I))){if(!(Rh&&Oe(uo,I))){if(!(rn.attributeCheck instanceof Function&&rn.attributeCheck(I,y))){if(!Ae[I]||ho[I]){if(!(qh(y)&&(me.tagNameCheck instanceof RegExp&&Oe(me.tagNameCheck,y)||me.tagNameCheck instanceof Function&&me.tagNameCheck(y))&&(me.attributeNameCheck instanceof RegExp&&Oe(me.attributeNameCheck,I)||me.attributeNameCheck instanceof Function&&me.attributeNameCheck(I,y))||I==="is"&&me.allowCustomizedBuiltInElements&&(me.tagNameCheck instanceof RegExp&&Oe(me.tagNameCheck,R)||me.tagNameCheck instanceof Function&&me.tagNameCheck(R))))return!1}else if(!gl[I]){if(!Oe(Ih,zi(R,Th,""))){if(!((I==="src"||I==="xlink:href"||I==="href")&&y!=="script"&&YL(R,"data:")===0&&zh[y])){if(!(Dh&&!Oe(vb,zi(R,Th,"")))){if(R)return!1}}}}}}}return!0},qh=function(y){return y!=="annotation-xml"&&gc(y,yb)},Yh=function(y){zt(xe.beforeSanitizeAttributes,y,null);const{attributes:I}=y;if(!I||bl(y))return;const R={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Ae,forceKeepAttr:void 0};let oe=I.length;for(;oe--;){const De=I[oe],{name:ve,namespaceURI:Ze,value:Nt}=De,Ar=be(ve),wl=Nt;let $e=ve==="value"?wl:XL(wl);if(R.attrName=Ar,R.attrValue=$e,R.keepAttr=!0,R.forceKeepAttr=void 0,zt(xe.uponSanitizeAttribute,y,R),$e=R.attrValue,Mh&&(Ar==="id"||Ar==="name")&&(Tn(ve,y),$e=bb+$e),po&&Oe(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,$e)){Tn(ve,y);continue}if(Ar==="attributename"&&gc($e,"href")){Tn(ve,y);continue}if(R.forceKeepAttr)continue;if(!R.keepAttr){Tn(ve,y);continue}if(!Lh&&Oe(/\/>/i,$e)){Tn(ve,y);continue}Sr&&Mo([An,St,nn],Kh=>{$e=zi($e,Kh," ")});const Xh=be(y.nodeName);if(!jh(Xh,Ar,$e)){Tn(ve,y);continue}if(L&&typeof g=="object"&&typeof g.getAttributeType=="function"&&!Ze)switch(g.getAttributeType(Xh,Ar)){case"TrustedHTML":{$e=L.createHTML($e);break}case"TrustedScriptURL":{$e=L.createScriptURL($e);break}}if($e!==wl)try{Ze?y.setAttributeNS(Ze,ve,$e):y.setAttribute(ve,$e),bl(y)?kt(y):Rf(e.removed)}catch{Tn(ve,y)}}zt(xe.afterSanitizeAttributes,y,null)},Ab=function z(y){let I=null;const R=Gh(y);for(zt(xe.beforeSanitizeShadowDOM,y,null);I=R.nextNode();)zt(xe.uponSanitizeShadowNode,I,null),Bh(I),Yh(I),I.content instanceof s&&z(I.content);zt(xe.afterSanitizeShadowDOM,y,null)};return e.sanitize=function(z){let y=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},I=null,R=null,oe=null,De=null;if(ml=!z,ml&&(z="<!-->"),typeof z!="string"&&!Vh(z))if(typeof z.toString=="function"){if(z=z.toString(),typeof z!="string")throw Ni("dirty is not a string, aborting")}else throw Ni("toString is not a function");if(!e.isSupported)return z;if(hl||yl(y),e.removed=[],typeof z=="string"&&(Ci=!1),Ci){if(z.nodeName){const Nt=be(z.nodeName);if(!_e[Nt]||Ii[Nt])throw Ni("root node is forbidden and cannot be sanitized in-place")}}else if(z instanceof a)I=Wh("<!---->"),R=I.ownerDocument.importNode(z,!0),R.nodeType===Fi.element&&R.nodeName==="BODY"||R.nodeName==="HTML"?I=R:I.appendChild(R);else{if(!_r&&!Sr&&!$n&&z.indexOf("<")===-1)return L&&go?L.createHTML(z):z;if(I=Wh(z),!I)return _r?null:go?H:""}I&&dl&&kt(I.firstChild);const ve=Gh(Ci?z:I);for(;oe=ve.nextNode();)Bh(oe),Yh(oe),oe.content instanceof s&&Ab(oe.content);if(Ci)return z;if(_r){if(fo)for(De=ue.call(I.ownerDocument);I.firstChild;)De.appendChild(I.firstChild);else De=I;return(Ae.shadowroot||Ae.shadowrootmode)&&(De=co.call(r,De,!0)),De}let Ze=$n?I.outerHTML:I.innerHTML;return $n&&_e["!doctype"]&&I.ownerDocument&&I.ownerDocument.doctype&&I.ownerDocument.doctype.name&&Oe(Qy,I.ownerDocument.doctype.name)&&(Ze="<!DOCTYPE "+I.ownerDocument.doctype.name+`>
362
+ `+Ze),Sr&&Mo([An,St,nn],Nt=>{Ze=zi(Ze,Nt," ")}),L&&go?L.createHTML(Ze):Ze},e.setConfig=function(){let z=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};yl(z),hl=!0},e.clearConfig=function(){xr=null,hl=!1},e.isValidAttribute=function(z,y,I){xr||yl({});const R=be(z),oe=be(y);return jh(R,oe,I)},e.addHook=function(z,y){typeof y=="function"&&Mi(xe[z],y)},e.removeHook=function(z,y){if(y!==void 0){const I=jL(xe[z],y);return I===-1?void 0:qL(xe[z],I,1)[0]}return Rf(xe[z])},e.removeHooks=function(z){xe[z]=[]},e.removeAllHooks=function(){xe=Nf()},e}var tb=eb();function vh(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var wr=vh();function nb(n){wr=n}var zn={exec:()=>null};function q(n,e=""){let t=typeof n=="string"?n:n.source,r={replace:(i,s)=>{let o=typeof s=="string"?s:s.source;return o=o.replace(Ne.caret,"$1"),t=t.replace(i,o),r},getRegex:()=>new RegExp(t,e)};return r}var hO=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),Ne={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:n=>new RegExp(`^( {0,3}${n})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}#`),htmlBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}<(?:[a-z].*>|!--)`,"i"),blockquoteBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}>`)},dO=/^(?:[ \t]*(?:\n|$))+/,pO=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,fO=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,lo=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,gO=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,yh=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,rb=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,ib=q(rb).replace(/bull/g,yh).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(),mO=q(rb).replace(/bull/g,yh).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(),bh=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,vO=/^[^\n]+/,wh=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,yO=q(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",wh).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),bO=q(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,yh).getRegex(),ol="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",Sh=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,wO=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",Sh).replace("tag",ol).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),sb=q(bh).replace("hr",lo).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",ol).getRegex(),SO=q(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",sb).getRegex(),_h={blockquote:SO,code:pO,def:yO,fences:fO,heading:gO,hr:lo,html:wO,lheading:ib,list:bO,newline:dO,paragraph:sb,table:zn,text:vO},Uf=q("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",lo).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",ol).getRegex(),_O={..._h,lheading:mO,table:Uf,paragraph:q(bh).replace("hr",lo).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Uf).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",ol).getRegex()},kO={..._h,html:q(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Sh).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:zn,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:q(bh).replace("hr",lo).replace("heading",` *#{1,6} *[^
363
+ ]`).replace("lheading",ib).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},EO=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,xO=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,ob=/^( {2,}|\\)\n(?!\s*$)/,AO=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,$i=/[\p{P}\p{S}]/u,al=/[\s\p{P}\p{S}]/u,kh=/[^\s\p{P}\p{S}]/u,$O=q(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,al).getRegex(),ab=/(?!~)[\p{P}\p{S}]/u,TO=/(?!~)[\s\p{P}\p{S}]/u,IO=/(?:[^\s\p{P}\p{S}]|~)/u,CO=q(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",hO?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),lb=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,PO=q(lb,"u").replace(/punct/g,$i).getRegex(),RO=q(lb,"u").replace(/punct/g,ab).getRegex(),cb="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",DO=q(cb,"gu").replace(/notPunctSpace/g,kh).replace(/punctSpace/g,al).replace(/punct/g,$i).getRegex(),LO=q(cb,"gu").replace(/notPunctSpace/g,IO).replace(/punctSpace/g,TO).replace(/punct/g,ab).getRegex(),OO=q("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,kh).replace(/punctSpace/g,al).replace(/punct/g,$i).getRegex(),MO=q(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,$i).getRegex(),zO="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",NO=q(zO,"gu").replace(/notPunctSpace/g,kh).replace(/punctSpace/g,al).replace(/punct/g,$i).getRegex(),UO=q(/\\(punct)/,"gu").replace(/punct/g,$i).getRegex(),FO=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(),ZO=q(Sh).replace("(?:-->|$)","-->").getRegex(),HO=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",ZO).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),ba=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,WO=q(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",ba).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),ub=q(/^!?\[(label)\]\[(ref)\]/).replace("label",ba).replace("ref",wh).getRegex(),hb=q(/^!?\[(ref)\](?:\[\])?/).replace("ref",wh).getRegex(),GO=q("reflink|nolink(?!\\()","g").replace("reflink",ub).replace("nolink",hb).getRegex(),Ff=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Eh={_backpedal:zn,anyPunctuation:UO,autolink:FO,blockSkip:CO,br:ob,code:xO,del:zn,delLDelim:zn,delRDelim:zn,emStrongLDelim:PO,emStrongRDelimAst:DO,emStrongRDelimUnd:OO,escape:EO,link:WO,nolink:hb,punctuation:$O,reflink:ub,reflinkSearch:GO,tag:HO,text:AO,url:zn},VO={...Eh,link:q(/^!?\[(label)\]\((.*?)\)/).replace("label",ba).getRegex(),reflink:q(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",ba).getRegex()},mu={...Eh,emStrongRDelimAst:LO,emStrongLDelim:RO,delLDelim:MO,delRDelim:NO,url:q(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Ff).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",Ff).getRegex()},BO={...mu,br:q(ob).replace("{2,}","*").getRegex(),text:q(mu.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},No={normal:_h,gfm:_O,pedantic:kO},Zi={normal:Eh,gfm:mu,breaks:BO,pedantic:VO},jO={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Zf=n=>jO[n];function $t(n,e){if(e){if(Ne.escapeTest.test(n))return n.replace(Ne.escapeReplace,Zf)}else if(Ne.escapeTestNoEncode.test(n))return n.replace(Ne.escapeReplaceNoEncode,Zf);return n}function Hf(n){try{n=encodeURI(n).replace(Ne.percentDecode,"%")}catch{return null}return n}function Wf(n,e){var s;let t=n.replace(Ne.findPipe,(o,a,c)=>{let u=!1,h=a;for(;--h>=0&&c[h]==="\\";)u=!u;return u?"|":" |"}),r=t.split(Ne.splitPipe),i=0;if(r[0].trim()||r.shift(),r.length>0&&!((s=r.at(-1))!=null&&s.trim())&&r.pop(),e)if(r.length>e)r.splice(e);else for(;r.length<e;)r.push("");for(;i<r.length;i++)r[i]=r[i].trim().replace(Ne.slashPipe,"|");return r}function Hi(n,e,t){let r=n.length;if(r===0)return"";let i=0;for(;i<r&&n.charAt(r-i-1)===e;)i++;return n.slice(0,r-i)}function qO(n,e){if(n.indexOf(e[1])===-1)return-1;let t=0;for(let r=0;r<n.length;r++)if(n[r]==="\\")r++;else if(n[r]===e[0])t++;else if(n[r]===e[1]&&(t--,t<0))return r;return t>0?-2:-1}function YO(n,e=0){let t=e,r="";for(let i of n)if(i===" "){let s=4-t%4;r+=" ".repeat(s),t+=s}else r+=i,t++;return r}function Gf(n,e,t,r,i){let s=e.href,o=e.title||null,a=n[1].replace(i.other.outputLinkReplace,"$1");r.state.inLink=!0;let c={type:n[0].charAt(0)==="!"?"image":"link",raw:t,href:s,title:o,text:a,tokens:r.inlineTokens(a)};return r.state.inLink=!1,c}function XO(n,e,t){let r=n.match(t.other.indentCodeCompensation);if(r===null)return e;let i=r[1];return e.split(`
364
364
  `).map(s=>{let o=s.match(t.other.beginningSpace);if(o===null)return s;let[a]=o;return a.length>=i.length?s.slice(i.length):s}).join(`
365
365
  `)}var wa=class{constructor(n){b(this,"options");b(this,"rules");b(this,"lexer");this.options=n||wr}space(n){let e=this.rules.block.newline.exec(n);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(n){let e=this.rules.block.code.exec(n);if(e){let t=e[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:e[0],codeBlockStyle:"indented",text:this.options.pedantic?t:Hi(t,`
366
- `)}}}fences(n){let e=this.rules.block.fences.exec(n);if(e){let t=e[0],r=YO(t,e[3]||"",this.rules);return{type:"code",raw:t,lang:e[2]?e[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):e[2],text:r}}}heading(n){let e=this.rules.block.heading.exec(n);if(e){let t=e[2].trim();if(this.rules.other.endingHash.test(t)){let r=Hi(t,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(t=r.trim())}return{type:"heading",raw:e[0],depth:e[1].length,text:t,tokens:this.lexer.inline(t)}}}hr(n){let e=this.rules.block.hr.exec(n);if(e)return{type:"hr",raw:Hi(e[0],`
366
+ `)}}}fences(n){let e=this.rules.block.fences.exec(n);if(e){let t=e[0],r=XO(t,e[3]||"",this.rules);return{type:"code",raw:t,lang:e[2]?e[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):e[2],text:r}}}heading(n){let e=this.rules.block.heading.exec(n);if(e){let t=e[2].trim();if(this.rules.other.endingHash.test(t)){let r=Hi(t,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(t=r.trim())}return{type:"heading",raw:e[0],depth:e[1].length,text:t,tokens:this.lexer.inline(t)}}}hr(n){let e=this.rules.block.hr.exec(n);if(e)return{type:"hr",raw:Hi(e[0],`
367
367
  `)}}blockquote(n){let e=this.rules.block.blockquote.exec(n);if(e){let t=Hi(e[0],`
368
368
  `).split(`
369
369
  `),r="",i="",s=[];for(;t.length>0;){let o=!1,a=[],c;for(c=0;c<t.length;c++)if(this.rules.other.blockquoteStart.test(t[c]))a.push(t[c]),o=!0;else if(!o)a.push(t[c]);else break;t=t.slice(c);let u=a.join(`
@@ -375,16 +375,16 @@ ${h}`:h;let p=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTo
375
375
  `),_=this.blockquote(E);s[s.length-1]=_,r=r.substring(0,r.length-g.raw.length)+_.raw,i=i.substring(0,i.length-g.text.length)+_.text;break}else if((v==null?void 0:v.type)==="list"){let g=v,E=g.raw+`
376
376
  `+t.join(`
377
377
  `),_=this.list(E);s[s.length-1]=_,r=r.substring(0,r.length-v.raw.length)+_.raw,i=i.substring(0,i.length-g.raw.length)+_.raw,t=E.substring(s.at(-1).raw.length).split(`
378
- `);continue}}return{type:"blockquote",raw:r,tokens:s,text:i}}}list(n){var t,r;let e=this.rules.block.list.exec(n);if(e){let i=e[1].trim(),s=i.length>1,o={type:"list",raw:"",ordered:s,start:s?+i.slice(0,-1):"",loose:!1,items:[]};i=s?`\\d{1,9}\\${i.slice(-1)}`:`\\${i}`,this.options.pedantic&&(i=s?i:"[*+-]");let a=this.rules.other.listItemRegex(i),c=!1;for(;n;){let h=!1,p="",v="";if(!(e=a.exec(n))||this.rules.block.hr.test(n))break;p=e[0],n=n.substring(p.length);let g=qO(e[2].split(`
378
+ `);continue}}return{type:"blockquote",raw:r,tokens:s,text:i}}}list(n){var t,r;let e=this.rules.block.list.exec(n);if(e){let i=e[1].trim(),s=i.length>1,o={type:"list",raw:"",ordered:s,start:s?+i.slice(0,-1):"",loose:!1,items:[]};i=s?`\\d{1,9}\\${i.slice(-1)}`:`\\${i}`,this.options.pedantic&&(i=s?i:"[*+-]");let a=this.rules.other.listItemRegex(i),c=!1;for(;n;){let h=!1,p="",v="";if(!(e=a.exec(n))||this.rules.block.hr.test(n))break;p=e[0],n=n.substring(p.length);let g=YO(e[2].split(`
379
379
  `,1)[0],e[1].length),E=n.split(`
380
380
  `,1)[0],_=!g.trim(),C=0;if(this.options.pedantic?(C=2,v=g.trimStart()):_?C=e[1].length+1:(C=g.search(this.rules.other.nonSpaceChar),C=C>4?1:C,v=g.slice(C),C+=e[1].length),_&&this.rules.other.blankLine.test(E)&&(p+=E+`
381
381
  `,n=n.substring(E.length+1),h=!0),!h){let N=this.rules.other.nextBulletRegex(C),P=this.rules.other.hrRegex(C),W=this.rules.other.fencesBeginRegex(C),L=this.rules.other.headingBeginRegex(C),H=this.rules.other.htmlBeginRegex(C),F=this.rules.other.blockquoteBeginRegex(C);for(;n;){let ce=n.split(`
382
382
  `,1)[0],ue;if(E=ce,this.options.pedantic?(E=E.replace(this.rules.other.listReplaceNesting," "),ue=E):ue=E.replace(this.rules.other.tabCharGlobal," "),W.test(E)||L.test(E)||H.test(E)||F.test(E)||N.test(E)||P.test(E))break;if(ue.search(this.rules.other.nonSpaceChar)>=C||!E.trim())v+=`
383
383
  `+ue.slice(C);else{if(_||g.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||W.test(g)||L.test(g)||P.test(g))break;v+=`
384
384
  `+E}_=!E.trim(),p+=ce+`
385
- `,n=n.substring(ce.length+1),g=ue.slice(C)}}o.loose||(c?o.loose=!0:this.rules.other.doubleBlankLine.test(p)&&(c=!0)),o.items.push({type:"list_item",raw:p,task:!!this.options.gfm&&this.rules.other.listIsTask.test(v),loose:!1,text:v,tokens:[]}),o.raw+=p}let u=o.items.at(-1);if(u)u.raw=u.raw.trimEnd(),u.text=u.text.trimEnd();else return;o.raw=o.raw.trimEnd();for(let h of o.items){if(this.lexer.state.top=!1,h.tokens=this.lexer.blockTokens(h.text,[]),h.task){if(h.text=h.text.replace(this.rules.other.listReplaceTask,""),((t=h.tokens[0])==null?void 0:t.type)==="text"||((r=h.tokens[0])==null?void 0:r.type)==="paragraph"){h.tokens[0].raw=h.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),h.tokens[0].text=h.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let v=this.lexer.inlineQueue.length-1;v>=0;v--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[v].src)){this.lexer.inlineQueue[v].src=this.lexer.inlineQueue[v].src.replace(this.rules.other.listReplaceTask,"");break}}let p=this.rules.other.listTaskCheckbox.exec(h.raw);if(p){let v={type:"checkbox",raw:p[0]+" ",checked:p[0]!=="[ ]"};h.checked=v.checked,o.loose?h.tokens[0]&&["paragraph","text"].includes(h.tokens[0].type)&&"tokens"in h.tokens[0]&&h.tokens[0].tokens?(h.tokens[0].raw=v.raw+h.tokens[0].raw,h.tokens[0].text=v.raw+h.tokens[0].text,h.tokens[0].tokens.unshift(v)):h.tokens.unshift({type:"paragraph",raw:v.raw,text:v.raw,tokens:[v]}):h.tokens.unshift(v)}}if(!o.loose){let p=h.tokens.filter(g=>g.type==="space"),v=p.length>0&&p.some(g=>this.rules.other.anyLine.test(g.raw));o.loose=v}}if(o.loose)for(let h of o.items){h.loose=!0;for(let p of h.tokens)p.type==="text"&&(p.type="paragraph")}return o}}html(n){let e=this.rules.block.html.exec(n);if(e)return{type:"html",block:!0,raw:e[0],pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:e[0]}}def(n){let e=this.rules.block.def.exec(n);if(e){let t=e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),r=e[2]?e[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",i=e[3]?e[3].substring(1,e[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):e[3];return{type:"def",tag:t,raw:e[0],href:r,title:i}}}table(n){var o;let e=this.rules.block.table.exec(n);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;let t=Zf(e[1]),r=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),i=(o=e[3])!=null&&o.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`
386
- `):[],s={type:"table",raw:e[0],header:[],align:[],rows:[]};if(t.length===r.length){for(let a of r)this.rules.other.tableAlignRight.test(a)?s.align.push("right"):this.rules.other.tableAlignCenter.test(a)?s.align.push("center"):this.rules.other.tableAlignLeft.test(a)?s.align.push("left"):s.align.push(null);for(let a=0;a<t.length;a++)s.header.push({text:t[a],tokens:this.lexer.inline(t[a]),header:!0,align:s.align[a]});for(let a of i)s.rows.push(Zf(a,s.header.length).map((c,u)=>({text:c,tokens:this.lexer.inline(c),header:!1,align:s.align[u]})));return s}}lheading(n){let e=this.rules.block.lheading.exec(n);if(e){let t=e[1].trim();return{type:"heading",raw:e[0],depth:e[2].charAt(0)==="="?1:2,text:t,tokens:this.lexer.inline(t)}}}paragraph(n){let e=this.rules.block.paragraph.exec(n);if(e){let t=e[1].charAt(e[1].length-1)===`
387
- `?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:t,tokens:this.lexer.inline(t)}}}text(n){let e=this.rules.block.text.exec(n);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(n){let e=this.rules.inline.escape.exec(n);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(n){let e=this.rules.inline.tag.exec(n);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(n){let e=this.rules.inline.link.exec(n);if(e){let t=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(t)){if(!this.rules.other.endAngleBracket.test(t))return;let s=Hi(t.slice(0,-1),"\\");if((t.length-s.length)%2===0)return}else{let s=jO(e[2],"()");if(s===-2)return;if(s>-1){let o=(e[0].indexOf("!")===0?5:4)+e[1].length+s;e[2]=e[2].substring(0,s),e[0]=e[0].substring(0,o).trim(),e[3]=""}}let r=e[2],i="";if(this.options.pedantic){let s=this.rules.other.pedanticHrefTitle.exec(r);s&&(r=s[1],i=s[3])}else i=e[3]?e[3].slice(1,-1):"";return r=r.trim(),this.rules.other.startAngleBracket.test(r)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(t)?r=r.slice(1):r=r.slice(1,-1)),Hf(e,{href:r&&r.replace(this.rules.inline.anyPunctuation,"$1"),title:i&&i.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer,this.rules)}}reflink(n,e){let t;if((t=this.rules.inline.reflink.exec(n))||(t=this.rules.inline.nolink.exec(n))){let r=(t[2]||t[1]).replace(this.rules.other.multipleSpaceGlobal," "),i=e[r.toLowerCase()];if(!i){let s=t[0].charAt(0);return{type:"text",raw:s,text:s}}return Hf(t,i,t[0],this.lexer,this.rules)}}emStrong(n,e,t=""){let r=this.rules.inline.emStrongLDelim.exec(n);if(!(!r||!r[1]&&!r[2]&&!r[3]&&!r[4]||r[4]&&t.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[3])||!t||this.rules.inline.punctuation.exec(t))){let i=[...r[0]].length-1,s,o,a=i,c=0,u=r[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(u.lastIndex=0,e=e.slice(-1*n.length+i);(r=u.exec(e))!=null;){if(s=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!s)continue;if(o=[...s].length,r[3]||r[4]){a+=o;continue}else if((r[5]||r[6])&&i%3&&!((i+o)%3)){c+=o;continue}if(a-=o,a>0)continue;o=Math.min(o,o+a+c);let h=[...r[0]][0].length,p=n.slice(0,i+r.index+h+o);if(Math.min(i,o)%2){let g=p.slice(1,-1);return{type:"em",raw:p,text:g,tokens:this.lexer.inlineTokens(g)}}let v=p.slice(2,-2);return{type:"strong",raw:p,text:v,tokens:this.lexer.inlineTokens(v)}}}}codespan(n){let e=this.rules.inline.code.exec(n);if(e){let t=e[2].replace(this.rules.other.newLineCharGlobal," "),r=this.rules.other.nonSpaceChar.test(t),i=this.rules.other.startingSpaceChar.test(t)&&this.rules.other.endingSpaceChar.test(t);return r&&i&&(t=t.substring(1,t.length-1)),{type:"codespan",raw:e[0],text:t}}}br(n){let e=this.rules.inline.br.exec(n);if(e)return{type:"br",raw:e[0]}}del(n,e,t=""){let r=this.rules.inline.delLDelim.exec(n);if(r&&(!r[1]||!t||this.rules.inline.punctuation.exec(t))){let i=[...r[0]].length-1,s,o,a=i,c=this.rules.inline.delRDelim;for(c.lastIndex=0,e=e.slice(-1*n.length+i);(r=c.exec(e))!=null;){if(s=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!s||(o=[...s].length,o!==i))continue;if(r[3]||r[4]){a+=o;continue}if(a-=o,a>0)continue;o=Math.min(o,o+a);let u=[...r[0]][0].length,h=n.slice(0,i+r.index+u+o),p=h.slice(i,-i);return{type:"del",raw:h,text:p,tokens:this.lexer.inlineTokens(p)}}}}autolink(n){let e=this.rules.inline.autolink.exec(n);if(e){let t,r;return e[2]==="@"?(t=e[1],r="mailto:"+t):(t=e[1],r=t),{type:"link",raw:e[0],text:t,href:r,tokens:[{type:"text",raw:t,text:t}]}}}url(n){var t;let e;if(e=this.rules.inline.url.exec(n)){let r,i;if(e[2]==="@")r=e[0],i="mailto:"+r;else{let s;do s=e[0],e[0]=((t=this.rules.inline._backpedal.exec(e[0]))==null?void 0:t[0])??"";while(s!==e[0]);r=e[0],e[1]==="www."?i="http://"+e[0]:i=e[0]}return{type:"link",raw:e[0],text:r,href:i,tokens:[{type:"text",raw:r,text:r}]}}}inlineText(n){let e=this.rules.inline.text.exec(n);if(e){let t=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:e[0],escaped:t}}}},yt=class fu{constructor(e){b(this,"tokens");b(this,"options");b(this,"state");b(this,"inlineQueue");b(this,"tokenizer");this.tokens=[],this.tokens.links=Object.create(null),this.options=e||wr,this.options.tokenizer=this.options.tokenizer||new wa,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let t={other:Ne,block:No.normal,inline:Zi.normal};this.options.pedantic?(t.block=No.pedantic,t.inline=Zi.pedantic):this.options.gfm&&(t.block=No.gfm,this.options.breaks?t.inline=Zi.breaks:t.inline=Zi.gfm),this.tokenizer.rules=t}static get rules(){return{block:No,inline:Zi}}static lex(e,t){return new fu(t).lex(e)}static lexInline(e,t){return new fu(t).inlineTokens(e)}lex(e){e=e.replace(Ne.carriageReturn,`
385
+ `,n=n.substring(ce.length+1),g=ue.slice(C)}}o.loose||(c?o.loose=!0:this.rules.other.doubleBlankLine.test(p)&&(c=!0)),o.items.push({type:"list_item",raw:p,task:!!this.options.gfm&&this.rules.other.listIsTask.test(v),loose:!1,text:v,tokens:[]}),o.raw+=p}let u=o.items.at(-1);if(u)u.raw=u.raw.trimEnd(),u.text=u.text.trimEnd();else return;o.raw=o.raw.trimEnd();for(let h of o.items){if(this.lexer.state.top=!1,h.tokens=this.lexer.blockTokens(h.text,[]),h.task){if(h.text=h.text.replace(this.rules.other.listReplaceTask,""),((t=h.tokens[0])==null?void 0:t.type)==="text"||((r=h.tokens[0])==null?void 0:r.type)==="paragraph"){h.tokens[0].raw=h.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),h.tokens[0].text=h.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let v=this.lexer.inlineQueue.length-1;v>=0;v--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[v].src)){this.lexer.inlineQueue[v].src=this.lexer.inlineQueue[v].src.replace(this.rules.other.listReplaceTask,"");break}}let p=this.rules.other.listTaskCheckbox.exec(h.raw);if(p){let v={type:"checkbox",raw:p[0]+" ",checked:p[0]!=="[ ]"};h.checked=v.checked,o.loose?h.tokens[0]&&["paragraph","text"].includes(h.tokens[0].type)&&"tokens"in h.tokens[0]&&h.tokens[0].tokens?(h.tokens[0].raw=v.raw+h.tokens[0].raw,h.tokens[0].text=v.raw+h.tokens[0].text,h.tokens[0].tokens.unshift(v)):h.tokens.unshift({type:"paragraph",raw:v.raw,text:v.raw,tokens:[v]}):h.tokens.unshift(v)}}if(!o.loose){let p=h.tokens.filter(g=>g.type==="space"),v=p.length>0&&p.some(g=>this.rules.other.anyLine.test(g.raw));o.loose=v}}if(o.loose)for(let h of o.items){h.loose=!0;for(let p of h.tokens)p.type==="text"&&(p.type="paragraph")}return o}}html(n){let e=this.rules.block.html.exec(n);if(e)return{type:"html",block:!0,raw:e[0],pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:e[0]}}def(n){let e=this.rules.block.def.exec(n);if(e){let t=e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),r=e[2]?e[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",i=e[3]?e[3].substring(1,e[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):e[3];return{type:"def",tag:t,raw:e[0],href:r,title:i}}}table(n){var o;let e=this.rules.block.table.exec(n);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;let t=Wf(e[1]),r=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),i=(o=e[3])!=null&&o.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`
386
+ `):[],s={type:"table",raw:e[0],header:[],align:[],rows:[]};if(t.length===r.length){for(let a of r)this.rules.other.tableAlignRight.test(a)?s.align.push("right"):this.rules.other.tableAlignCenter.test(a)?s.align.push("center"):this.rules.other.tableAlignLeft.test(a)?s.align.push("left"):s.align.push(null);for(let a=0;a<t.length;a++)s.header.push({text:t[a],tokens:this.lexer.inline(t[a]),header:!0,align:s.align[a]});for(let a of i)s.rows.push(Wf(a,s.header.length).map((c,u)=>({text:c,tokens:this.lexer.inline(c),header:!1,align:s.align[u]})));return s}}lheading(n){let e=this.rules.block.lheading.exec(n);if(e){let t=e[1].trim();return{type:"heading",raw:e[0],depth:e[2].charAt(0)==="="?1:2,text:t,tokens:this.lexer.inline(t)}}}paragraph(n){let e=this.rules.block.paragraph.exec(n);if(e){let t=e[1].charAt(e[1].length-1)===`
387
+ `?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:t,tokens:this.lexer.inline(t)}}}text(n){let e=this.rules.block.text.exec(n);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(n){let e=this.rules.inline.escape.exec(n);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(n){let e=this.rules.inline.tag.exec(n);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(n){let e=this.rules.inline.link.exec(n);if(e){let t=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(t)){if(!this.rules.other.endAngleBracket.test(t))return;let s=Hi(t.slice(0,-1),"\\");if((t.length-s.length)%2===0)return}else{let s=qO(e[2],"()");if(s===-2)return;if(s>-1){let o=(e[0].indexOf("!")===0?5:4)+e[1].length+s;e[2]=e[2].substring(0,s),e[0]=e[0].substring(0,o).trim(),e[3]=""}}let r=e[2],i="";if(this.options.pedantic){let s=this.rules.other.pedanticHrefTitle.exec(r);s&&(r=s[1],i=s[3])}else i=e[3]?e[3].slice(1,-1):"";return r=r.trim(),this.rules.other.startAngleBracket.test(r)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(t)?r=r.slice(1):r=r.slice(1,-1)),Gf(e,{href:r&&r.replace(this.rules.inline.anyPunctuation,"$1"),title:i&&i.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer,this.rules)}}reflink(n,e){let t;if((t=this.rules.inline.reflink.exec(n))||(t=this.rules.inline.nolink.exec(n))){let r=(t[2]||t[1]).replace(this.rules.other.multipleSpaceGlobal," "),i=e[r.toLowerCase()];if(!i){let s=t[0].charAt(0);return{type:"text",raw:s,text:s}}return Gf(t,i,t[0],this.lexer,this.rules)}}emStrong(n,e,t=""){let r=this.rules.inline.emStrongLDelim.exec(n);if(!(!r||!r[1]&&!r[2]&&!r[3]&&!r[4]||r[4]&&t.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[3])||!t||this.rules.inline.punctuation.exec(t))){let i=[...r[0]].length-1,s,o,a=i,c=0,u=r[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(u.lastIndex=0,e=e.slice(-1*n.length+i);(r=u.exec(e))!=null;){if(s=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!s)continue;if(o=[...s].length,r[3]||r[4]){a+=o;continue}else if((r[5]||r[6])&&i%3&&!((i+o)%3)){c+=o;continue}if(a-=o,a>0)continue;o=Math.min(o,o+a+c);let h=[...r[0]][0].length,p=n.slice(0,i+r.index+h+o);if(Math.min(i,o)%2){let g=p.slice(1,-1);return{type:"em",raw:p,text:g,tokens:this.lexer.inlineTokens(g)}}let v=p.slice(2,-2);return{type:"strong",raw:p,text:v,tokens:this.lexer.inlineTokens(v)}}}}codespan(n){let e=this.rules.inline.code.exec(n);if(e){let t=e[2].replace(this.rules.other.newLineCharGlobal," "),r=this.rules.other.nonSpaceChar.test(t),i=this.rules.other.startingSpaceChar.test(t)&&this.rules.other.endingSpaceChar.test(t);return r&&i&&(t=t.substring(1,t.length-1)),{type:"codespan",raw:e[0],text:t}}}br(n){let e=this.rules.inline.br.exec(n);if(e)return{type:"br",raw:e[0]}}del(n,e,t=""){let r=this.rules.inline.delLDelim.exec(n);if(r&&(!r[1]||!t||this.rules.inline.punctuation.exec(t))){let i=[...r[0]].length-1,s,o,a=i,c=this.rules.inline.delRDelim;for(c.lastIndex=0,e=e.slice(-1*n.length+i);(r=c.exec(e))!=null;){if(s=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!s||(o=[...s].length,o!==i))continue;if(r[3]||r[4]){a+=o;continue}if(a-=o,a>0)continue;o=Math.min(o,o+a);let u=[...r[0]][0].length,h=n.slice(0,i+r.index+u+o),p=h.slice(i,-i);return{type:"del",raw:h,text:p,tokens:this.lexer.inlineTokens(p)}}}}autolink(n){let e=this.rules.inline.autolink.exec(n);if(e){let t,r;return e[2]==="@"?(t=e[1],r="mailto:"+t):(t=e[1],r=t),{type:"link",raw:e[0],text:t,href:r,tokens:[{type:"text",raw:t,text:t}]}}}url(n){var t;let e;if(e=this.rules.inline.url.exec(n)){let r,i;if(e[2]==="@")r=e[0],i="mailto:"+r;else{let s;do s=e[0],e[0]=((t=this.rules.inline._backpedal.exec(e[0]))==null?void 0:t[0])??"";while(s!==e[0]);r=e[0],e[1]==="www."?i="http://"+e[0]:i=e[0]}return{type:"link",raw:e[0],text:r,href:i,tokens:[{type:"text",raw:r,text:r}]}}}inlineText(n){let e=this.rules.inline.text.exec(n);if(e){let t=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:e[0],escaped:t}}}},yt=class vu{constructor(e){b(this,"tokens");b(this,"options");b(this,"state");b(this,"inlineQueue");b(this,"tokenizer");this.tokens=[],this.tokens.links=Object.create(null),this.options=e||wr,this.options.tokenizer=this.options.tokenizer||new wa,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let t={other:Ne,block:No.normal,inline:Zi.normal};this.options.pedantic?(t.block=No.pedantic,t.inline=Zi.pedantic):this.options.gfm&&(t.block=No.gfm,this.options.breaks?t.inline=Zi.breaks:t.inline=Zi.gfm),this.tokenizer.rules=t}static get rules(){return{block:No,inline:Zi}}static lex(e,t){return new vu(t).lex(e)}static lexInline(e,t){return new vu(t).inlineTokens(e)}lex(e){e=e.replace(Ne.carriageReturn,`
388
388
  `),this.blockTokens(e,this.tokens);for(let t=0;t<this.inlineQueue.length;t++){let r=this.inlineQueue[t];this.inlineTokens(r.src,r.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],r=!1){var i,s,o;for(this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(Ne.tabCharGlobal," ").replace(Ne.spaceLine,""));e;){let a;if((s=(i=this.options.extensions)==null?void 0:i.block)!=null&&s.some(u=>(a=u.call({lexer:this},e,t))?(e=e.substring(a.raw.length),t.push(a),!0):!1))continue;if(a=this.tokenizer.space(e)){e=e.substring(a.raw.length);let u=t.at(-1);a.raw.length===1&&u!==void 0?u.raw+=`
389
389
  `:t.push(a);continue}if(a=this.tokenizer.code(e)){e=e.substring(a.raw.length);let u=t.at(-1);(u==null?void 0:u.type)==="paragraph"||(u==null?void 0:u.type)==="text"?(u.raw+=(u.raw.endsWith(`
390
390
  `)?"":`
@@ -416,16 +416,16 @@ ${this.parser.parse(n)}</blockquote>
416
416
  `}tablerow({text:n}){return`<tr>
417
417
  ${n}</tr>
418
418
  `}tablecell(n){let e=this.parser.parseInline(n.tokens),t=n.header?"th":"td";return(n.align?`<${t} align="${n.align}">`:`<${t}>`)+e+`</${t}>
419
- `}strong({tokens:n}){return`<strong>${this.parser.parseInline(n)}</strong>`}em({tokens:n}){return`<em>${this.parser.parseInline(n)}</em>`}codespan({text:n}){return`<code>${$t(n,!0)}</code>`}br(n){return"<br>"}del({tokens:n}){return`<del>${this.parser.parseInline(n)}</del>`}link({href:n,title:e,tokens:t}){let r=this.parser.parseInline(t),i=Ff(n);if(i===null)return r;n=i;let s='<a href="'+n+'"';return e&&(s+=' title="'+$t(e)+'"'),s+=">"+r+"</a>",s}image({href:n,title:e,text:t,tokens:r}){r&&(t=this.parser.parseInline(r,this.parser.textRenderer));let i=Ff(n);if(i===null)return $t(t);n=i;let s=`<img src="${n}" alt="${$t(t)}"`;return e&&(s+=` title="${$t(e)}"`),s+=">",s}text(n){return"tokens"in n&&n.tokens?this.parser.parseInline(n.tokens):"escaped"in n&&n.escaped?n.text:$t(n.text)}},_h=class{strong({text:n}){return n}em({text:n}){return n}codespan({text:n}){return n}del({text:n}){return n}html({text:n}){return n}text({text:n}){return n}link({text:n}){return""+n}image({text:n}){return""+n}br(){return""}checkbox({raw:n}){return n}},bt=class gu{constructor(e){b(this,"options");b(this,"renderer");b(this,"textRenderer");this.options=e||wr,this.options.renderer=this.options.renderer||new Sa,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new _h}static parse(e,t){return new gu(t).parse(e)}static parseInline(e,t){return new gu(t).parseInline(e)}parse(e){var r,i;this.renderer.parser=this;let t="";for(let s=0;s<e.length;s++){let o=e[s];if((i=(r=this.options.extensions)==null?void 0:r.renderers)!=null&&i[o.type]){let c=o,u=this.options.extensions.renderers[c.type].call({parser:this},c);if(u!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(c.type)){t+=u||"";continue}}let a=o;switch(a.type){case"space":{t+=this.renderer.space(a);break}case"hr":{t+=this.renderer.hr(a);break}case"heading":{t+=this.renderer.heading(a);break}case"code":{t+=this.renderer.code(a);break}case"table":{t+=this.renderer.table(a);break}case"blockquote":{t+=this.renderer.blockquote(a);break}case"list":{t+=this.renderer.list(a);break}case"checkbox":{t+=this.renderer.checkbox(a);break}case"html":{t+=this.renderer.html(a);break}case"def":{t+=this.renderer.def(a);break}case"paragraph":{t+=this.renderer.paragraph(a);break}case"text":{t+=this.renderer.text(a);break}default:{let c='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(c),"";throw new Error(c)}}}return t}parseInline(e,t=this.renderer){var i,s;this.renderer.parser=this;let r="";for(let o=0;o<e.length;o++){let a=e[o];if((s=(i=this.options.extensions)==null?void 0:i.renderers)!=null&&s[a.type]){let u=this.options.extensions.renderers[a.type].call({parser:this},a);if(u!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(a.type)){r+=u||"";continue}}let c=a;switch(c.type){case"escape":{r+=t.text(c);break}case"html":{r+=t.html(c);break}case"link":{r+=t.link(c);break}case"image":{r+=t.image(c);break}case"checkbox":{r+=t.checkbox(c);break}case"strong":{r+=t.strong(c);break}case"em":{r+=t.em(c);break}case"codespan":{r+=t.codespan(c);break}case"br":{r+=t.br(c);break}case"del":{r+=t.del(c);break}case"text":{r+=t.text(c);break}default:{let u='Token with "'+c.type+'" type was not found.';if(this.options.silent)return console.error(u),"";throw new Error(u)}}}return r}},Uo,Ji=(Uo=class{constructor(n){b(this,"options");b(this,"block");this.options=n||wr}preprocess(n){return n}postprocess(n){return n}processAllTokens(n){return n}emStrongMask(n){return n}provideLexer(){return this.block?yt.lex:yt.lexInline}provideParser(){return this.block?bt.parse:bt.parseInline}},b(Uo,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),b(Uo,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),Uo),XO=class{constructor(...n){b(this,"defaults",fh());b(this,"options",this.setOptions);b(this,"parse",this.parseMarkdown(!0));b(this,"parseInline",this.parseMarkdown(!1));b(this,"Parser",bt);b(this,"Renderer",Sa);b(this,"TextRenderer",_h);b(this,"Lexer",yt);b(this,"Tokenizer",wa);b(this,"Hooks",Ji);this.use(...n)}walkTokens(n,e){var r,i;let t=[];for(let s of n)switch(t=t.concat(e.call(this,s)),s.type){case"table":{let o=s;for(let a of o.header)t=t.concat(this.walkTokens(a.tokens,e));for(let a of o.rows)for(let c of a)t=t.concat(this.walkTokens(c.tokens,e));break}case"list":{let o=s;t=t.concat(this.walkTokens(o.items,e));break}default:{let o=s;(i=(r=this.defaults.extensions)==null?void 0:r.childTokens)!=null&&i[o.type]?this.defaults.extensions.childTokens[o.type].forEach(a=>{let c=o[a].flat(1/0);t=t.concat(this.walkTokens(c,e))}):o.tokens&&(t=t.concat(this.walkTokens(o.tokens,e)))}}return t}use(...n){let e=this.defaults.extensions||{renderers:{},childTokens:{}};return n.forEach(t=>{let r={...t};if(r.async=this.defaults.async||r.async||!1,t.extensions&&(t.extensions.forEach(i=>{if(!i.name)throw new Error("extension name required");if("renderer"in i){let s=e.renderers[i.name];s?e.renderers[i.name]=function(...o){let a=i.renderer.apply(this,o);return a===!1&&(a=s.apply(this,o)),a}:e.renderers[i.name]=i.renderer}if("tokenizer"in i){if(!i.level||i.level!=="block"&&i.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let s=e[i.level];s?s.unshift(i.tokenizer):e[i.level]=[i.tokenizer],i.start&&(i.level==="block"?e.startBlock?e.startBlock.push(i.start):e.startBlock=[i.start]:i.level==="inline"&&(e.startInline?e.startInline.push(i.start):e.startInline=[i.start]))}"childTokens"in i&&i.childTokens&&(e.childTokens[i.name]=i.childTokens)}),r.extensions=e),t.renderer){let i=this.defaults.renderer||new Sa(this.defaults);for(let s in t.renderer){if(!(s in i))throw new Error(`renderer '${s}' does not exist`);if(["options","parser"].includes(s))continue;let o=s,a=t.renderer[o],c=i[o];i[o]=(...u)=>{let h=a.apply(i,u);return h===!1&&(h=c.apply(i,u)),h||""}}r.renderer=i}if(t.tokenizer){let i=this.defaults.tokenizer||new wa(this.defaults);for(let s in t.tokenizer){if(!(s in i))throw new Error(`tokenizer '${s}' does not exist`);if(["options","rules","lexer"].includes(s))continue;let o=s,a=t.tokenizer[o],c=i[o];i[o]=(...u)=>{let h=a.apply(i,u);return h===!1&&(h=c.apply(i,u)),h}}r.tokenizer=i}if(t.hooks){let i=this.defaults.hooks||new Ji;for(let s in t.hooks){if(!(s in i))throw new Error(`hook '${s}' does not exist`);if(["options","block"].includes(s))continue;let o=s,a=t.hooks[o],c=i[o];Ji.passThroughHooks.has(s)?i[o]=u=>{if(this.defaults.async&&Ji.passThroughHooksRespectAsync.has(s))return(async()=>{let p=await a.call(i,u);return c.call(i,p)})();let h=a.call(i,u);return c.call(i,h)}:i[o]=(...u)=>{if(this.defaults.async)return(async()=>{let p=await a.apply(i,u);return p===!1&&(p=await c.apply(i,u)),p})();let h=a.apply(i,u);return h===!1&&(h=c.apply(i,u)),h}}r.hooks=i}if(t.walkTokens){let i=this.defaults.walkTokens,s=t.walkTokens;r.walkTokens=function(o){let a=[];return a.push(s.call(this,o)),i&&(a=a.concat(i.call(this,o))),a}}this.defaults={...this.defaults,...r}}),this}setOptions(n){return this.defaults={...this.defaults,...n},this}lexer(n,e){return yt.lex(n,e??this.defaults)}parser(n,e){return bt.parse(n,e??this.defaults)}parseMarkdown(n){return(e,t)=>{let r={...t},i={...this.defaults,...r},s=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return s(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof e>"u"||e===null)return s(new Error("marked(): input parameter is undefined or null"));if(typeof e!="string")return s(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected"));if(i.hooks&&(i.hooks.options=i,i.hooks.block=n),i.async)return(async()=>{let o=i.hooks?await i.hooks.preprocess(e):e,a=await(i.hooks?await i.hooks.provideLexer():n?yt.lex:yt.lexInline)(o,i),c=i.hooks?await i.hooks.processAllTokens(a):a;i.walkTokens&&await Promise.all(this.walkTokens(c,i.walkTokens));let u=await(i.hooks?await i.hooks.provideParser():n?bt.parse:bt.parseInline)(c,i);return i.hooks?await i.hooks.postprocess(u):u})().catch(s);try{i.hooks&&(e=i.hooks.preprocess(e));let o=(i.hooks?i.hooks.provideLexer():n?yt.lex:yt.lexInline)(e,i);i.hooks&&(o=i.hooks.processAllTokens(o)),i.walkTokens&&this.walkTokens(o,i.walkTokens);let a=(i.hooks?i.hooks.provideParser():n?bt.parse:bt.parseInline)(o,i);return i.hooks&&(a=i.hooks.postprocess(a)),a}catch(o){return s(o)}}}onError(n,e){return t=>{if(t.message+=`
420
- Please report this to https://github.com/markedjs/marked.`,n){let r="<p>An error occurred:</p><pre>"+$t(t.message+"",!0)+"</pre>";return e?Promise.resolve(r):r}if(e)return Promise.reject(t);throw t}}},gr=new XO;function Q(n,e){return gr.parse(n,e)}Q.options=Q.setOptions=function(n){return gr.setOptions(n),Q.defaults=gr.defaults,eb(Q.defaults),Q};Q.getDefaults=fh;Q.defaults=wr;Q.use=function(...n){return gr.use(...n),Q.defaults=gr.defaults,eb(Q.defaults),Q};Q.walkTokens=function(n,e){return gr.walkTokens(n,e)};Q.parseInline=gr.parseInline;Q.Parser=bt;Q.parser=bt.parse;Q.Renderer=Sa;Q.TextRenderer=_h;Q.Lexer=yt;Q.lexer=yt.lex;Q.Tokenizer=wa;Q.Hooks=Ji;Q.parse=Q;Q.options;Q.setOptions;Q.use;Q.walkTokens;Q.parseInline;bt.parse;yt.lex;Qy.addHook("afterSanitizeAttributes",n=>{n.tagName==="A"&&(n.setAttribute("target","_blank"),n.setAttribute("rel","noopener noreferrer"))});function KO(n){const e=Q.parse(n,{async:!1});return Qy.sanitize(e,{USE_PROFILES:{html:!0}})}const JO=8,Wf=new WeakMap;function QO(n){const e=Wf.get(n);if(e&&e.text===n.text)return e.html;const t=KO(n.text);return Wf.set(n,{text:n.text,html:t}),t}function eM(n){return n.replace(/_/g," ")}function tM(n){return U`
419
+ `}strong({tokens:n}){return`<strong>${this.parser.parseInline(n)}</strong>`}em({tokens:n}){return`<em>${this.parser.parseInline(n)}</em>`}codespan({text:n}){return`<code>${$t(n,!0)}</code>`}br(n){return"<br>"}del({tokens:n}){return`<del>${this.parser.parseInline(n)}</del>`}link({href:n,title:e,tokens:t}){let r=this.parser.parseInline(t),i=Hf(n);if(i===null)return r;n=i;let s='<a href="'+n+'"';return e&&(s+=' title="'+$t(e)+'"'),s+=">"+r+"</a>",s}image({href:n,title:e,text:t,tokens:r}){r&&(t=this.parser.parseInline(r,this.parser.textRenderer));let i=Hf(n);if(i===null)return $t(t);n=i;let s=`<img src="${n}" alt="${$t(t)}"`;return e&&(s+=` title="${$t(e)}"`),s+=">",s}text(n){return"tokens"in n&&n.tokens?this.parser.parseInline(n.tokens):"escaped"in n&&n.escaped?n.text:$t(n.text)}},xh=class{strong({text:n}){return n}em({text:n}){return n}codespan({text:n}){return n}del({text:n}){return n}html({text:n}){return n}text({text:n}){return n}link({text:n}){return""+n}image({text:n}){return""+n}br(){return""}checkbox({raw:n}){return n}},bt=class yu{constructor(e){b(this,"options");b(this,"renderer");b(this,"textRenderer");this.options=e||wr,this.options.renderer=this.options.renderer||new Sa,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new xh}static parse(e,t){return new yu(t).parse(e)}static parseInline(e,t){return new yu(t).parseInline(e)}parse(e){var r,i;this.renderer.parser=this;let t="";for(let s=0;s<e.length;s++){let o=e[s];if((i=(r=this.options.extensions)==null?void 0:r.renderers)!=null&&i[o.type]){let c=o,u=this.options.extensions.renderers[c.type].call({parser:this},c);if(u!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(c.type)){t+=u||"";continue}}let a=o;switch(a.type){case"space":{t+=this.renderer.space(a);break}case"hr":{t+=this.renderer.hr(a);break}case"heading":{t+=this.renderer.heading(a);break}case"code":{t+=this.renderer.code(a);break}case"table":{t+=this.renderer.table(a);break}case"blockquote":{t+=this.renderer.blockquote(a);break}case"list":{t+=this.renderer.list(a);break}case"checkbox":{t+=this.renderer.checkbox(a);break}case"html":{t+=this.renderer.html(a);break}case"def":{t+=this.renderer.def(a);break}case"paragraph":{t+=this.renderer.paragraph(a);break}case"text":{t+=this.renderer.text(a);break}default:{let c='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(c),"";throw new Error(c)}}}return t}parseInline(e,t=this.renderer){var i,s;this.renderer.parser=this;let r="";for(let o=0;o<e.length;o++){let a=e[o];if((s=(i=this.options.extensions)==null?void 0:i.renderers)!=null&&s[a.type]){let u=this.options.extensions.renderers[a.type].call({parser:this},a);if(u!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(a.type)){r+=u||"";continue}}let c=a;switch(c.type){case"escape":{r+=t.text(c);break}case"html":{r+=t.html(c);break}case"link":{r+=t.link(c);break}case"image":{r+=t.image(c);break}case"checkbox":{r+=t.checkbox(c);break}case"strong":{r+=t.strong(c);break}case"em":{r+=t.em(c);break}case"codespan":{r+=t.codespan(c);break}case"br":{r+=t.br(c);break}case"del":{r+=t.del(c);break}case"text":{r+=t.text(c);break}default:{let u='Token with "'+c.type+'" type was not found.';if(this.options.silent)return console.error(u),"";throw new Error(u)}}}return r}},Uo,Ji=(Uo=class{constructor(n){b(this,"options");b(this,"block");this.options=n||wr}preprocess(n){return n}postprocess(n){return n}processAllTokens(n){return n}emStrongMask(n){return n}provideLexer(){return this.block?yt.lex:yt.lexInline}provideParser(){return this.block?bt.parse:bt.parseInline}},b(Uo,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),b(Uo,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),Uo),KO=class{constructor(...n){b(this,"defaults",vh());b(this,"options",this.setOptions);b(this,"parse",this.parseMarkdown(!0));b(this,"parseInline",this.parseMarkdown(!1));b(this,"Parser",bt);b(this,"Renderer",Sa);b(this,"TextRenderer",xh);b(this,"Lexer",yt);b(this,"Tokenizer",wa);b(this,"Hooks",Ji);this.use(...n)}walkTokens(n,e){var r,i;let t=[];for(let s of n)switch(t=t.concat(e.call(this,s)),s.type){case"table":{let o=s;for(let a of o.header)t=t.concat(this.walkTokens(a.tokens,e));for(let a of o.rows)for(let c of a)t=t.concat(this.walkTokens(c.tokens,e));break}case"list":{let o=s;t=t.concat(this.walkTokens(o.items,e));break}default:{let o=s;(i=(r=this.defaults.extensions)==null?void 0:r.childTokens)!=null&&i[o.type]?this.defaults.extensions.childTokens[o.type].forEach(a=>{let c=o[a].flat(1/0);t=t.concat(this.walkTokens(c,e))}):o.tokens&&(t=t.concat(this.walkTokens(o.tokens,e)))}}return t}use(...n){let e=this.defaults.extensions||{renderers:{},childTokens:{}};return n.forEach(t=>{let r={...t};if(r.async=this.defaults.async||r.async||!1,t.extensions&&(t.extensions.forEach(i=>{if(!i.name)throw new Error("extension name required");if("renderer"in i){let s=e.renderers[i.name];s?e.renderers[i.name]=function(...o){let a=i.renderer.apply(this,o);return a===!1&&(a=s.apply(this,o)),a}:e.renderers[i.name]=i.renderer}if("tokenizer"in i){if(!i.level||i.level!=="block"&&i.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let s=e[i.level];s?s.unshift(i.tokenizer):e[i.level]=[i.tokenizer],i.start&&(i.level==="block"?e.startBlock?e.startBlock.push(i.start):e.startBlock=[i.start]:i.level==="inline"&&(e.startInline?e.startInline.push(i.start):e.startInline=[i.start]))}"childTokens"in i&&i.childTokens&&(e.childTokens[i.name]=i.childTokens)}),r.extensions=e),t.renderer){let i=this.defaults.renderer||new Sa(this.defaults);for(let s in t.renderer){if(!(s in i))throw new Error(`renderer '${s}' does not exist`);if(["options","parser"].includes(s))continue;let o=s,a=t.renderer[o],c=i[o];i[o]=(...u)=>{let h=a.apply(i,u);return h===!1&&(h=c.apply(i,u)),h||""}}r.renderer=i}if(t.tokenizer){let i=this.defaults.tokenizer||new wa(this.defaults);for(let s in t.tokenizer){if(!(s in i))throw new Error(`tokenizer '${s}' does not exist`);if(["options","rules","lexer"].includes(s))continue;let o=s,a=t.tokenizer[o],c=i[o];i[o]=(...u)=>{let h=a.apply(i,u);return h===!1&&(h=c.apply(i,u)),h}}r.tokenizer=i}if(t.hooks){let i=this.defaults.hooks||new Ji;for(let s in t.hooks){if(!(s in i))throw new Error(`hook '${s}' does not exist`);if(["options","block"].includes(s))continue;let o=s,a=t.hooks[o],c=i[o];Ji.passThroughHooks.has(s)?i[o]=u=>{if(this.defaults.async&&Ji.passThroughHooksRespectAsync.has(s))return(async()=>{let p=await a.call(i,u);return c.call(i,p)})();let h=a.call(i,u);return c.call(i,h)}:i[o]=(...u)=>{if(this.defaults.async)return(async()=>{let p=await a.apply(i,u);return p===!1&&(p=await c.apply(i,u)),p})();let h=a.apply(i,u);return h===!1&&(h=c.apply(i,u)),h}}r.hooks=i}if(t.walkTokens){let i=this.defaults.walkTokens,s=t.walkTokens;r.walkTokens=function(o){let a=[];return a.push(s.call(this,o)),i&&(a=a.concat(i.call(this,o))),a}}this.defaults={...this.defaults,...r}}),this}setOptions(n){return this.defaults={...this.defaults,...n},this}lexer(n,e){return yt.lex(n,e??this.defaults)}parser(n,e){return bt.parse(n,e??this.defaults)}parseMarkdown(n){return(e,t)=>{let r={...t},i={...this.defaults,...r},s=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return s(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof e>"u"||e===null)return s(new Error("marked(): input parameter is undefined or null"));if(typeof e!="string")return s(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected"));if(i.hooks&&(i.hooks.options=i,i.hooks.block=n),i.async)return(async()=>{let o=i.hooks?await i.hooks.preprocess(e):e,a=await(i.hooks?await i.hooks.provideLexer():n?yt.lex:yt.lexInline)(o,i),c=i.hooks?await i.hooks.processAllTokens(a):a;i.walkTokens&&await Promise.all(this.walkTokens(c,i.walkTokens));let u=await(i.hooks?await i.hooks.provideParser():n?bt.parse:bt.parseInline)(c,i);return i.hooks?await i.hooks.postprocess(u):u})().catch(s);try{i.hooks&&(e=i.hooks.preprocess(e));let o=(i.hooks?i.hooks.provideLexer():n?yt.lex:yt.lexInline)(e,i);i.hooks&&(o=i.hooks.processAllTokens(o)),i.walkTokens&&this.walkTokens(o,i.walkTokens);let a=(i.hooks?i.hooks.provideParser():n?bt.parse:bt.parseInline)(o,i);return i.hooks&&(a=i.hooks.postprocess(a)),a}catch(o){return s(o)}}}onError(n,e){return t=>{if(t.message+=`
420
+ Please report this to https://github.com/markedjs/marked.`,n){let r="<p>An error occurred:</p><pre>"+$t(t.message+"",!0)+"</pre>";return e?Promise.resolve(r):r}if(e)return Promise.reject(t);throw t}}},gr=new KO;function Q(n,e){return gr.parse(n,e)}Q.options=Q.setOptions=function(n){return gr.setOptions(n),Q.defaults=gr.defaults,nb(Q.defaults),Q};Q.getDefaults=vh;Q.defaults=wr;Q.use=function(...n){return gr.use(...n),Q.defaults=gr.defaults,nb(Q.defaults),Q};Q.walkTokens=function(n,e){return gr.walkTokens(n,e)};Q.parseInline=gr.parseInline;Q.Parser=bt;Q.parser=bt.parse;Q.Renderer=Sa;Q.TextRenderer=xh;Q.Lexer=yt;Q.lexer=yt.lex;Q.Tokenizer=wa;Q.Hooks=Ji;Q.parse=Q;Q.options;Q.setOptions;Q.use;Q.walkTokens;Q.parseInline;bt.parse;yt.lex;tb.addHook("afterSanitizeAttributes",n=>{n.tagName==="A"&&(n.setAttribute("target","_blank"),n.setAttribute("rel","noopener noreferrer"))});function JO(n){const e=Q.parse(n,{async:!1});return tb.sanitize(e,{USE_PROFILES:{html:!0}})}const QO=8,Vf=new WeakMap;function eM(n){const e=Vf.get(n);if(e&&e.text===n.text)return e.html;const t=JO(n.text);return Vf.set(n,{text:n.text,html:t}),t}function tM(n){return n.replace(/_/g," ")}function nM(n){return U`
421
421
  <div class="tool-call-header">
422
422
  <span class="tool-call-title">${n.title}</span>
423
- <span class="tool-call-meta">${n.toolKind} · ${eM(n.status)}</span>
423
+ <span class="tool-call-meta">${n.toolKind} · ${tM(n.status)}</span>
424
424
  </div>
425
425
  ${n.text?U`<pre class="tool-call-text">${n.text}</pre>`:null}
426
- `}function Bf(n){for(let e=n.length-1;e>=0;e-=1){const t=n[e];if(t&&t.kind==="user")return t.id}return null}var Xt,cr,Ua,Fa,Bs,mu;class ub extends cs{constructor(){super(...arguments);w(this,Bs);b(this,"messages",[]);w(this,Xt,!0);w(this,cr,null);w(this,Ua,()=>{const t=l(this,cr);if(!t)return;const i=t.scrollHeight-t.clientHeight-t.scrollTop<=JO;i!==l(this,Xt)&&(x(this,Xt,i),this.toggleAttribute("data-pinned",i))});w(this,Fa,()=>{x(this,Xt,!0),this.toggleAttribute("data-pinned",!0),m(this,Bs,mu).call(this,!0)})}changed(t){let r=!1;if(t.has("messages")){const i=t.get("messages")??[],s=Bf(this.messages);r=s!==null&&s!==Bf(i),r&&x(this,Xt,!0)}Re(this.template(),this),l(this,cr)||x(this,cr,this.querySelector(".history-scroll")),this.toggleAttribute("data-pinned",l(this,Xt)),m(this,Bs,mu).call(this,r)}template(){return U`
426
+ `}function Bf(n){for(let e=n.length-1;e>=0;e-=1){const t=n[e];if(t&&t.kind==="user")return t.id}return null}var Xt,cr,Ua,Fa,Gs,bu;class db extends cs{constructor(){super(...arguments);w(this,Gs);b(this,"messages",[]);w(this,Xt,!0);w(this,cr,null);w(this,Ua,()=>{const t=l(this,cr);if(!t)return;const i=t.scrollHeight-t.clientHeight-t.scrollTop<=QO;i!==l(this,Xt)&&(x(this,Xt,i),this.toggleAttribute("data-pinned",i))});w(this,Fa,()=>{x(this,Xt,!0),this.toggleAttribute("data-pinned",!0),m(this,Gs,bu).call(this,!0)})}changed(t){let r=!1;if(t.has("messages")){const i=t.get("messages")??[],s=Bf(this.messages);r=s!==null&&s!==Bf(i),r&&x(this,Xt,!0)}Re(this.template(),this),l(this,cr)||x(this,cr,this.querySelector(".history-scroll")),this.toggleAttribute("data-pinned",l(this,Xt)),m(this,Gs,bu).call(this,r)}template(){return U`
427
427
  <div class="history-scroll" @scroll=${l(this,Ua)}>
428
- ${this.messages.map(t=>{const r=t.kind==="assistant"?n2(QO(t)):t.kind==="tool_call"?tM(t):t.text;return U`<div
428
+ ${this.messages.map(t=>{const r=t.kind==="assistant"?r2(eM(t)):t.kind==="tool_call"?nM(t):t.text;return U`<div
429
429
  class="message message-${t.kind}"
430
430
  data-message-id=${t.id}
431
431
  >${r}</div>`})}
@@ -436,9 +436,9 @@ Please report this to https://github.com/markedjs/marked.`,n){let r="<p>An error
436
436
  aria-label="Jump to latest message"
437
437
  @click=${l(this,Fa)}
438
438
  >
439
- ${ly({size:16})}
439
+ ${uy({size:16})}
440
440
  </button>
441
- `}}Xt=new WeakMap,cr=new WeakMap,Ua=new WeakMap,Fa=new WeakMap,Bs=new WeakSet,mu=function(t){requestAnimationFrame(()=>{const r=l(this,cr);r&&(!l(this,Xt)&&!t||(r.scrollTop=r.scrollHeight-r.clientHeight))})},b(ub,"properties",["messages"]);customElements.define("message-history",ub);var Vs,Gs,li,Za,Ha,st,ra,js,yu,bu,qs,Ys;class vu extends cs{constructor(){super(...arguments);w(this,st);b(this,"placeholder","What do you want to do?");b(this,"open",!1);b(this,"messages",[]);w(this,Vs,qe.resolve("ACPClientManager"));w(this,Gs,qe.resolve("ShortcutService"));w(this,li,null);b(this,"handleTriggerActivate",()=>{this.open=!0});b(this,"handleKeydown",t=>{if(t.key!=="Enter"||t.shiftKey)return;const r=t.currentTarget,i=r.value.trim();if(t.preventDefault(),!i)return;r.value="",m(this,st,ra).call(this,r);const s=l(this,Vs).getActiveClient();s&&s.sendMessage({text:i}).catch(o=>{console.error("ACPClient.sendMessage() failed",o)})});w(this,Za,t=>{m(this,st,ra).call(this,t.currentTarget)});w(this,Ha,t=>{if(t.target instanceof HTMLTextAreaElement)return;const r=t.currentTarget.querySelector("textarea");r==null||r.focus()});w(this,js,t=>{if(t.shortcut!=="focusCommandInput")return;if(!this.open){this.open=!0;return}const r=this.querySelector("textarea");if(r){if(document.activeElement===r){this.open=!1;return}r.focus()}});w(this,qs,t=>{t.target instanceof Node&&(this.contains(t.target)||(this.open=!1))});w(this,Ys,t=>{t.key==="Escape"&&(this.open=!1)})}connected(){const t=new DisposableStack;x(this,li,t);const r=HL(l(this,Vs),i=>{this.messages=i});t.defer(()=>r.dispose()),l(this,Gs).addEventListener("shortcut-triggered",l(this,js)),t.defer(()=>l(this,Gs).removeEventListener("shortcut-triggered",l(this,js))),this.open&&m(this,st,yu).call(this)}disconnected(){var t;(t=l(this,li))==null||t.dispose(),x(this,li,null),m(this,st,bu).call(this)}changed(t){if(this.open?(this.removeAttribute("material"),this.removeAttribute("tone"),this.removeAttribute("level")):(this.setAttribute("material","paper"),this.setAttribute("tone","dark"),this.setAttribute("level","overlay")),Re(this.template(),this),t.has("open"))if(this.open){m(this,st,yu).call(this);const r=this.querySelector("textarea");r&&(m(this,st,ra).call(this,r),r.focus())}else m(this,st,bu).call(this)}template(){return this.open?U`
441
+ `}}Xt=new WeakMap,cr=new WeakMap,Ua=new WeakMap,Fa=new WeakMap,Gs=new WeakSet,bu=function(t){requestAnimationFrame(()=>{const r=l(this,cr);r&&(!l(this,Xt)&&!t||(r.scrollTop=r.scrollHeight-r.clientHeight))})},b(db,"properties",["messages"]);customElements.define("message-history",db);var Vs,Bs,li,Za,Ha,st,ra,js,Su,_u,qs,Ys;class wu extends cs{constructor(){super(...arguments);w(this,st);b(this,"placeholder","What do you want to do?");b(this,"open",!1);b(this,"messages",[]);w(this,Vs,qe.resolve("ACPClientManager"));w(this,Bs,qe.resolve("ShortcutService"));w(this,li,null);b(this,"handleTriggerActivate",()=>{this.open=!0});b(this,"handleKeydown",t=>{if(t.key!=="Enter"||t.shiftKey)return;const r=t.currentTarget,i=r.value.trim();if(t.preventDefault(),!i)return;r.value="",m(this,st,ra).call(this,r);const s=l(this,Vs).getActiveClient();s&&s.sendMessage({text:i}).catch(o=>{console.error("ACPClient.sendMessage() failed",o)})});w(this,Za,t=>{m(this,st,ra).call(this,t.currentTarget)});w(this,Ha,t=>{if(t.target instanceof HTMLTextAreaElement)return;const r=t.currentTarget.querySelector("textarea");r==null||r.focus()});w(this,js,t=>{if(t.shortcut!=="focusCommandInput")return;if(!this.open){this.open=!0;return}const r=this.querySelector("textarea");if(r){if(document.activeElement===r){this.open=!1;return}r.focus()}});w(this,qs,t=>{t.target instanceof Node&&(this.contains(t.target)||(this.open=!1))});w(this,Ys,t=>{t.key==="Escape"&&(this.open=!1)})}connected(){const t=new DisposableStack;x(this,li,t);const r=WL(l(this,Vs),i=>{this.messages=i});t.defer(()=>r.dispose()),l(this,Bs).addEventListener("shortcut-triggered",l(this,js)),t.defer(()=>l(this,Bs).removeEventListener("shortcut-triggered",l(this,js))),this.open&&m(this,st,Su).call(this)}disconnected(){var t;(t=l(this,li))==null||t.dispose(),x(this,li,null),m(this,st,_u).call(this)}changed(t){if(this.open?(this.removeAttribute("material"),this.removeAttribute("tone"),this.removeAttribute("level")):(this.setAttribute("material","paper"),this.setAttribute("tone","dark"),this.setAttribute("level","overlay")),Re(this.template(),this),t.has("open"))if(this.open){m(this,st,Su).call(this);const r=this.querySelector("textarea");r&&(m(this,st,ra).call(this,r),r.focus())}else m(this,st,_u).call(this)}template(){return this.open?U`
442
442
  ${this.messages.length>0?U`
443
443
  <div
444
444
  class="chat"
@@ -474,7 +474,7 @@ Please report this to https://github.com/markedjs/marked.`,n){let r="<p>An error
474
474
  <span class="label">${this.placeholder}</span>
475
475
  <span class="kbd" aria-hidden="true">⌘K</span>
476
476
  </div>
477
- `}}Vs=new WeakMap,Gs=new WeakMap,li=new WeakMap,Za=new WeakMap,Ha=new WeakMap,st=new WeakSet,ra=function(t){t.style.height="auto",t.style.height=`${t.scrollHeight}px`},js=new WeakMap,yu=function(){document.addEventListener("mousedown",l(this,qs)),document.addEventListener("keydown",l(this,Ys))},bu=function(){document.removeEventListener("mousedown",l(this,qs)),document.removeEventListener("keydown",l(this,Ys))},qs=new WeakMap,Ys=new WeakMap,b(vu,"properties",["placeholder","open","messages"]),b(vu,"attributes",{placeholder:{type:String},open:{type:Boolean}});customElements.define("command-panel",vu);class hb extends Event{constructor(t){super("auth-submit",{bubbles:!0,composed:!0});b(this,"token");this.token=t}}class nM extends HTMLElement{constructor(){super(...arguments);b(this,"_invalid",!1);b(this,"_tokenValue","")}set invalid(t){this._invalid=t,this.render()}get invalid(){return this._invalid}set tokenValue(t){this._tokenValue=t,this.render()}get tokenValue(){return this._tokenValue}connectedCallback(){this.render()}handleInput(t){const r=t.currentTarget;this._tokenValue=r.value}handleSubmit(t){t.preventDefault();const r=this._tokenValue.trim();r&&this.dispatchEvent(new hb(r))}render(){Re(U`
477
+ `}}Vs=new WeakMap,Bs=new WeakMap,li=new WeakMap,Za=new WeakMap,Ha=new WeakMap,st=new WeakSet,ra=function(t){t.style.height="auto",t.style.height=`${t.scrollHeight}px`},js=new WeakMap,Su=function(){document.addEventListener("mousedown",l(this,qs)),document.addEventListener("keydown",l(this,Ys))},_u=function(){document.removeEventListener("mousedown",l(this,qs)),document.removeEventListener("keydown",l(this,Ys))},qs=new WeakMap,Ys=new WeakMap,b(wu,"properties",["placeholder","open","messages"]),b(wu,"attributes",{placeholder:{type:String},open:{type:Boolean}});customElements.define("command-panel",wu);class pb extends Event{constructor(t){super("auth-submit",{bubbles:!0,composed:!0});b(this,"token");this.token=t}}class rM extends HTMLElement{constructor(){super(...arguments);b(this,"_invalid",!1);b(this,"_tokenValue","")}set invalid(t){this._invalid=t,this.render()}get invalid(){return this._invalid}set tokenValue(t){this._tokenValue=t,this.render()}get tokenValue(){return this._tokenValue}connectedCallback(){this.render()}handleInput(t){const r=t.currentTarget;this._tokenValue=r.value}handleSubmit(t){t.preventDefault();const r=this._tokenValue.trim();r&&this.dispatchEvent(new pb(r))}render(){Re(U`
478
478
  <modal-overlay open>
479
479
  <section class="auth-modal">
480
480
  <form class="auth-form" @submit=${t=>this.handleSubmit(t)}>
@@ -495,7 +495,7 @@ Please report this to https://github.com/markedjs/marked.`,n){let r="<p>An error
495
495
  </form>
496
496
  </section>
497
497
  </modal-overlay>
498
- `,this)}}customElements.get("auth-modal")||customElements.define("auth-modal",nM);class rM extends HTMLElement{constructor(){super(...arguments);b(this,"runtimeServerURL",Gv());b(this,"electronMode",oh());b(this,"serverManager",qe.resolve("ServerManager"));b(this,"screenManager",qe.resolve("ScreenManager"));b(this,"connectError",null);b(this,"handleServerManagerChange",()=>{this.render()});b(this,"handleActiveScreenChanged",()=>{this.render()})}connectedCallback(){this.serverManager.addEventListener("change",this.handleServerManagerChange),this.screenManager.addEventListener("active-screen-changed",this.handleActiveScreenChanged),this.addEventListener("auth-submit",t=>{var i;const r=t instanceof hb?t.token:t instanceof CustomEvent&&typeof((i=t.detail)==null?void 0:i.token)=="string"?t.detail.token:null;r&&this.handleAuthSubmit(r)}),this.initializeConnection(),this.render()}disconnectedCallback(){this.serverManager.removeEventListener("change",this.handleServerManagerChange),this.screenManager.removeEventListener("active-screen-changed",this.handleActiveScreenChanged)}async initializeConnection(){if(this.electronMode){this.serverManager.connectConfiguredServers(this.runtimeServerURL,Bc());return}if(this.serverManager.activeServer)return;const t=new Mc({url:this.runtimeServerURL,name:"Server",token:Bc()});this.serverManager.add(t),this.serverManager.setActive(t);try{await t.connect(),this.connectError=null}catch(r){this.connectError=r instanceof Error&&!(r instanceof Oc)?r.message:null}this.render()}async handleAuthSubmit(t){const r=this.serverManager.activeServer;if(r){this.connectError=null,r.token=t,this.updateTokenQueryParam(t);try{await r.connect()}catch(i){i instanceof Oc||(this.connectError=i instanceof Error?i.message:String(i))}this.render()}}updateTokenQueryParam(t){const r=new URL(window.location.href);r.searchParams.set("token",t),window.history.replaceState({},"",`${r.pathname}${r.search}${r.hash}`)}render(){const t=this.serverManager.activeServer,r=(t==null?void 0:t.status)??null;if(r==="connecting"){Re(U`
498
+ `,this)}}customElements.get("auth-modal")||customElements.define("auth-modal",rM);class iM extends HTMLElement{constructor(){super(...arguments);b(this,"runtimeServerURL",qv());b(this,"electronMode",ch());b(this,"serverManager",qe.resolve("ServerManager"));b(this,"screenManager",qe.resolve("ScreenManager"));b(this,"connectError",null);b(this,"handleServerManagerChange",()=>{this.render()});b(this,"handleActiveScreenChanged",()=>{this.render()})}connectedCallback(){this.serverManager.addEventListener("change",this.handleServerManagerChange),this.screenManager.addEventListener("active-screen-changed",this.handleActiveScreenChanged),this.addEventListener("auth-submit",t=>{var i;const r=t instanceof pb?t.token:t instanceof CustomEvent&&typeof((i=t.detail)==null?void 0:i.token)=="string"?t.detail.token:null;r&&this.handleAuthSubmit(r)}),this.initializeConnection(),this.render()}disconnectedCallback(){this.serverManager.removeEventListener("change",this.handleServerManagerChange),this.screenManager.removeEventListener("active-screen-changed",this.handleActiveScreenChanged)}async initializeConnection(){if(this.electronMode){this.serverManager.connectConfiguredServers(this.runtimeServerURL,jc());return}if(this.serverManager.activeServer)return;const t=new Uc({url:this.runtimeServerURL,name:"Server",token:jc()});this.serverManager.add(t),this.serverManager.setActive(t);try{await t.connect(),this.connectError=null}catch(r){this.connectError=r instanceof Error&&!(r instanceof Nc)?r.message:null}this.render()}async handleAuthSubmit(t){const r=this.serverManager.activeServer;if(r){this.connectError=null,r.token=t,this.updateTokenQueryParam(t);try{await r.connect()}catch(i){i instanceof Nc||(this.connectError=i instanceof Error?i.message:String(i))}this.render()}}updateTokenQueryParam(t){const r=new URL(window.location.href);r.searchParams.set("token",t),window.history.replaceState({},"",`${r.pathname}${r.search}${r.hash}`)}render(){const t=this.serverManager.activeServer,r=(t==null?void 0:t.status)??null;if(r==="connecting"){Re(U`
499
499
  <main class="auth-gate"><p>Connecting...</p></main>
500
500
  `,this);return}if(r==="disconnected"){const o=t;if(!o)return;Re(U`
501
501
  <main class="auth-gate">
@@ -519,4 +519,4 @@ Please report this to https://github.com/markedjs/marked.`,n){let r="<p>An error
519
519
  `:null}
520
520
  `}
521
521
  </main>
522
- `,this)}}customElements.get("television-app")||customElements.define("television-app",rM);const kh=oh(),ll=Gv(),db=new Vx(kh?"television-electron":"television-browser",Bx(ll)),pb=new NI({localStore:db,localServerURL:ll}),fb=new Zx({localStore:db,serverManager:pb}),iM=new SD({serverURL:ll,token:Bc()??"",screenManager:fb}),sM=new $D;qe.register("ServerManager",()=>pb);qe.register("ScreenManager",()=>fb);qe.register("ACPClientManager",()=>iM);qe.register("ShortcutService",()=>sM);const Eh=document.createElement("television-app");Eh.runtimeServerURL=ll;Eh.electronMode=kh;kh&&document.body.classList.add("electron");document.body.appendChild(Eh);
522
+ `,this)}}customElements.get("television-app")||customElements.define("television-app",iM);const Ah=ch(),ll=qv(),fb=new Bx(Ah?"television-electron":"television-browser",Vx(ll)),gb=new UI({localStore:fb,localServerURL:ll}),mb=new Hx({localStore:fb,serverManager:gb}),sM=new _D({serverURL:ll,token:jc()??"",screenManager:mb}),oM=new TD;qe.register("ServerManager",()=>gb);qe.register("ScreenManager",()=>mb);qe.register("ACPClientManager",()=>sM);qe.register("ShortcutService",()=>oM);const $h=document.createElement("television-app");$h.runtimeServerURL=ll;$h.electronMode=Ah;Ah&&document.body.classList.add("electron");document.body.appendChild($h);