@telepath-computer/television 0.1.89 → 0.1.91

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,522 +0,0 @@
1
- var Xb=Object.defineProperty;var vd=r=>{throw TypeError(r)};var Kb=(r,e,t)=>e in r?Xb(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var y=(r,e,t)=>Kb(r,typeof e!="symbol"?e+"":e,t),Ol=(r,e,t)=>e.has(r)||vd("Cannot "+t);var l=(r,e,t)=>(Ol(r,e,"read from private field"),t?t.call(r):e.get(r)),w=(r,e,t)=>e.has(r)?vd("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),_=(r,e,t,n)=>(Ol(r,e,"write to private field"),n?n.call(r,t):e.set(r,t),t),f=(r,e,t)=>(Ol(r,e,"access private method"),t);var yd=(r,e,t,n)=>({set _(i){_(r,e,i,t)},get _(){return l(r,e,n)}});(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))n(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"&&n(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 n(i){if(i.ep)return;i.ep=!0;const s=t(i);fetch(i.href,s)}})();var Zr=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Jb(r){if(r.__esModule)return r;var e=r.default;if(typeof e=="function"){var t=function n(){return this instanceof n?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(r).forEach(function(n){var i=Object.getOwnPropertyDescriptor(r,n);Object.defineProperty(t,n,i.get?i:{enumerable:!0,get:function(){return r[n]}})}),t}var bd=Object.prototype.toString,fg=function(e){var t=bd.call(e),n=t==="[object Arguments]";return n||(n=t!=="[object Array]"&&e!==null&&typeof e=="object"&&typeof e.length=="number"&&e.length>=0&&bd.call(e.callee)==="[object Function]"),n},Ml,wd;function Qb(){if(wd)return Ml;wd=1;var r;if(!Object.keys){var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,n=fg,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 m=v.constructor;return m&&m.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}};r=function(m){var E=m!==null&&typeof m=="object",x=t.call(m)==="[object Function]",T=n(m),O=E&&t.call(m)==="[object String]",P=[];if(!E&&!x&&!T)throw new TypeError("Object.keys called on a non-object");var Z=o&&x;if(O&&m.length>0&&!e.call(m,0))for(var F=0;F<m.length;++F)P.push(String(F));if(T&&m.length>0)for(var B=0;B<m.length;++B)P.push(String(B));else for(var N in m)!(Z&&N==="prototype")&&e.call(m,N)&&P.push(String(N));if(s)for(var J=p(m),j=0;j<a.length;++j)!(J&&a[j]==="constructor")&&e.call(m,a[j])&&P.push(a[j]);return P}}return Ml=r,Ml}var ew=Array.prototype.slice,tw=fg,Sd=Object.keys,ea=Sd?function(e){return Sd(e)}:Qb(),_d=Object.keys;ea.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(n){return tw(n)?_d(ew.call(n)):_d(n)})}else Object.keys=ea;return Object.keys||ea};var rw=ea,ta=Object.defineProperty||!1;if(ta)try{ta({},"a",{value:1})}catch{ta=!1}var ho=ta,ar=SyntaxError,X=TypeError,nw=Object.getOwnPropertyDescriptor,ra=nw;if(ra)try{ra([],"length")}catch{ra=null}var Ii=ra,kd=ho,iw=ar,zn=X,xd=Ii,gg=function(e,t,n){if(!e||typeof e!="object"&&typeof e!="function")throw new zn("`obj` must be an object or a function`");if(typeof t!="string"&&typeof t!="symbol")throw new zn("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new zn("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new zn("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new zn("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new zn("`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=!!xd&&xd(e,t);if(kd)kd(e,t,{configurable:o===null&&c?c.configurable:!o,enumerable:i===null&&c?c.enumerable:!i,value:n,writable:s===null&&c?c.writable:!s});else if(a||!i&&!s&&!o)e[t]=n;else throw new iw("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},Pc=ho,mg=function(){return!!Pc};mg.hasArrayLengthDefineBug=function(){if(!Pc)return null;try{return Pc([],"length",{value:1}).length!==1}catch{return!0}};var il=mg,sw=rw,ow=typeof Symbol=="function"&&typeof Symbol("foo")=="symbol",aw=Object.prototype.toString,lw=Array.prototype.concat,Ed=gg,cw=function(r){return typeof r=="function"&&aw.call(r)==="[object Function]"},vg=il(),uw=function(r,e,t,n){if(e in r){if(n===!0){if(r[e]===t)return}else if(!cw(n)||!n())return}vg?Ed(r,e,t,!0):Ed(r,e,t)},yg=function(r,e){var t=arguments.length>2?arguments[2]:{},n=sw(e);ow&&(n=lw.call(n,Object.getOwnPropertySymbols(e)));for(var i=0;i<n.length;i+=1)uw(r,n[i],e[n[i]],t[n[i]])};yg.supportsDescriptors=!!vg;var xn=yg,na={exports:{}};typeof self<"u"?na.exports=self:typeof window<"u"?na.exports=window:na.exports=Function("return this")();var bg=na.exports,hw=bg,wg=function(){return typeof Zr!="object"||!Zr||Zr.Math!==Math||Zr.Array!==Array?hw:Zr},dw=xn,pw=Ii,fw=wg,gw=function(){var e=fw();if(dw.supportsDescriptors){var t=pw(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},mw=xn,vw=bg,Sg=wg,yw=gw,bw=Sg(),_g=function(){return bw};mw(_g,{getPolyfill:Sg,implementation:vw,shim:yw});var Fu=_g,lr=function(e){return!!e&&(typeof e=="function"||typeof e=="object")},Wu=Object,kg=Error,ww=EvalError,Sw=RangeError,Hu=ReferenceError,_w=URIError,kw=Math.abs,xw=Math.floor,Ew=Math.max,Aw=Math.min,$w=Math.pow,Iw=Math.round,Zu=Number.isNaN||function(e){return e!==e},Tw=Zu,Cw=function(e){return Tw(e)||e===0?e:e<0?-1:1},Ti=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var e={},t=Symbol("test"),n=Object(t);if(typeof t=="string"||Object.prototype.toString.call(t)!=="[object Symbol]"||Object.prototype.toString.call(n)!=="[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,Pw=Ti,Vu=function(){return typeof Ad!="function"||typeof Symbol!="function"||typeof Ad("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:Pw()},xg=typeof Reflect<"u"&&Reflect.getPrototypeOf||null,Nl,$d;function Eg(){if($d)return Nl;$d=1;var r=Wu;return Nl=r.getPrototypeOf||null,Nl}var Rw="Function.prototype.bind called on incompatible ",Dw=Object.prototype.toString,Lw=Math.max,zw="[object Function]",Id=function(e,t){for(var n=[],i=0;i<e.length;i+=1)n[i]=e[i];for(var s=0;s<t.length;s+=1)n[s+e.length]=t[s];return n},Ow=function(e,t){for(var n=[],i=t,s=0;i<e.length;i+=1,s+=1)n[s]=e[i];return n},Mw=function(r,e){for(var t="",n=0;n<r.length;n+=1)t+=r[n],n+1<r.length&&(t+=e);return t},Nw=function(e){var t=this;if(typeof t!="function"||Dw.apply(t)!==zw)throw new TypeError(Rw+t);for(var n=Ow(arguments,1),i,s=function(){if(this instanceof i){var h=t.apply(this,Id(n,arguments));return Object(h)===h?h:this}return t.apply(e,Id(n,arguments))},o=Lw(0,t.length-n.length),a=[],c=0;c<o;c++)a[c]="$"+c;if(i=Function("binder","return function ("+Mw(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},Uw=Nw,po=Function.prototype.bind||Uw,Bu=Function.prototype.call,Gu=Function.prototype.apply,Fw=typeof Reflect<"u"&&Reflect&&Reflect.apply,Ww=po,Hw=Gu,Zw=Bu,Vw=Fw,Ag=Vw||Ww.call(Zw,Hw),Bw=po,Gw=X,jw=Bu,qw=Ag,sl=function(e){if(e.length<1||typeof e[0]!="function")throw new Gw("a function is required");return qw(Bw,jw,e)},Yw=sl,Td=Ii,$g;try{$g=[].__proto__===Array.prototype}catch(r){if(!r||typeof r!="object"||!("code"in r)||r.code!=="ERR_PROTO_ACCESS")throw r}var Ul=!!$g&&Td&&Td(Object.prototype,"__proto__"),Ig=Object,Cd=Ig.getPrototypeOf,Xw=Ul&&typeof Ul.get=="function"?Yw([Ul.get]):typeof Cd=="function"?function(e){return Cd(e==null?e:Ig(e))}:!1,Pd=xg,Rd=Eg(),Dd=Xw,Tg=Pd?function(e){return Pd(e)}:Rd?function(e){if(!e||typeof e!="object"&&typeof e!="function")throw new TypeError("getProto: not an object");return Rd(e)}:Dd?function(e){return Dd(e)}:null,Kw=Function.prototype.call,Jw=Object.prototype.hasOwnProperty,Qw=po,cr=Qw.call(Kw,Jw),Y,e0=Wu,t0=kg,r0=ww,n0=Sw,i0=Hu,_i=ar,ei=X,s0=_w,o0=kw,a0=xw,l0=Ew,c0=Aw,u0=$w,h0=Iw,d0=Cw,Cg=Function,Fl=function(r){try{return Cg('"use strict"; return ('+r+").constructor;")()}catch{}},fs=Ii,p0=ho,Wl=function(){throw new ei},f0=fs?function(){try{return arguments.callee,Wl}catch{try{return fs(arguments,"callee").get}catch{return Wl}}}():Wl,On=Vu(),Ie=Tg,g0=Eg(),m0=xg,Pg=Gu,fo=Bu,Wn={},v0=typeof Uint8Array>"u"||!Ie?Y:Ie(Uint8Array),vn={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?Y:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?Y:ArrayBuffer,"%ArrayIteratorPrototype%":On&&Ie?Ie([][Symbol.iterator]()):Y,"%AsyncFromSyncIteratorPrototype%":Y,"%AsyncFunction%":Wn,"%AsyncGenerator%":Wn,"%AsyncGeneratorFunction%":Wn,"%AsyncIteratorPrototype%":Wn,"%Atomics%":typeof Atomics>"u"?Y:Atomics,"%BigInt%":typeof BigInt>"u"?Y:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?Y:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?Y:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?Y:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":t0,"%eval%":eval,"%EvalError%":r0,"%Float16Array%":typeof Float16Array>"u"?Y:Float16Array,"%Float32Array%":typeof Float32Array>"u"?Y:Float32Array,"%Float64Array%":typeof Float64Array>"u"?Y:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?Y:FinalizationRegistry,"%Function%":Cg,"%GeneratorFunction%":Wn,"%Int8Array%":typeof Int8Array>"u"?Y:Int8Array,"%Int16Array%":typeof Int16Array>"u"?Y:Int16Array,"%Int32Array%":typeof Int32Array>"u"?Y:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":On&&Ie?Ie(Ie([][Symbol.iterator]())):Y,"%JSON%":typeof JSON=="object"?JSON:Y,"%Map%":typeof Map>"u"?Y:Map,"%MapIteratorPrototype%":typeof Map>"u"||!On||!Ie?Y:Ie(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":e0,"%Object.getOwnPropertyDescriptor%":fs,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?Y:Promise,"%Proxy%":typeof Proxy>"u"?Y:Proxy,"%RangeError%":n0,"%ReferenceError%":i0,"%Reflect%":typeof Reflect>"u"?Y:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?Y:Set,"%SetIteratorPrototype%":typeof Set>"u"||!On||!Ie?Y:Ie(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?Y:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":On&&Ie?Ie(""[Symbol.iterator]()):Y,"%Symbol%":On?Symbol:Y,"%SyntaxError%":_i,"%ThrowTypeError%":f0,"%TypedArray%":v0,"%TypeError%":ei,"%Uint8Array%":typeof Uint8Array>"u"?Y:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?Y:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?Y:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?Y:Uint32Array,"%URIError%":s0,"%WeakMap%":typeof WeakMap>"u"?Y:WeakMap,"%WeakRef%":typeof WeakRef>"u"?Y:WeakRef,"%WeakSet%":typeof WeakSet>"u"?Y:WeakSet,"%Function.prototype.call%":fo,"%Function.prototype.apply%":Pg,"%Object.defineProperty%":p0,"%Object.getPrototypeOf%":g0,"%Math.abs%":o0,"%Math.floor%":a0,"%Math.max%":l0,"%Math.min%":c0,"%Math.pow%":u0,"%Math.round%":h0,"%Math.sign%":d0,"%Reflect.getPrototypeOf%":m0};if(Ie)try{null.error}catch(r){var y0=Ie(Ie(r));vn["%Error.prototype%"]=y0}var b0=function r(e){var t;if(e==="%AsyncFunction%")t=Fl("async function () {}");else if(e==="%GeneratorFunction%")t=Fl("function* () {}");else if(e==="%AsyncGeneratorFunction%")t=Fl("async function* () {}");else if(e==="%AsyncGenerator%"){var n=r("%AsyncGeneratorFunction%");n&&(t=n.prototype)}else if(e==="%AsyncIteratorPrototype%"){var i=r("%AsyncGenerator%");i&&Ie&&(t=Ie(i.prototype))}return vn[e]=t,t},Ld={__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"]},go=po,ka=cr,w0=go.call(fo,Array.prototype.concat),S0=go.call(Pg,Array.prototype.splice),zd=go.call(fo,String.prototype.replace),xa=go.call(fo,String.prototype.slice),_0=go.call(fo,RegExp.prototype.exec),k0=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,x0=/\\(\\)?/g,E0=function(e){var t=xa(e,0,1),n=xa(e,-1);if(t==="%"&&n!=="%")throw new _i("invalid intrinsic syntax, expected closing `%`");if(n==="%"&&t!=="%")throw new _i("invalid intrinsic syntax, expected opening `%`");var i=[];return zd(e,k0,function(s,o,a,c){i[i.length]=a?zd(c,x0,"$1"):o||s}),i},A0=function(e,t){var n=e,i;if(ka(Ld,n)&&(i=Ld[n],n="%"+i[0]+"%"),ka(vn,n)){var s=vn[n];if(s===Wn&&(s=b0(n)),typeof s>"u"&&!t)throw new ei("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:i,name:n,value:s}}throw new _i("intrinsic "+e+" does not exist!")},pt=function(e,t){if(typeof e!="string"||e.length===0)throw new ei("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof t!="boolean")throw new ei('"allowMissing" argument must be a boolean');if(_0(/^%?[^%]*%?$/,e)===null)throw new _i("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var n=E0(e),i=n.length>0?n[0]:"",s=A0("%"+i+"%",t),o=s.name,a=s.value,c=!1,u=s.alias;u&&(i=u[0],S0(n,w0([0,1],u)));for(var h=1,p=!0;h<n.length;h+=1){var v=n[h],m=xa(v,0,1),E=xa(v,-1);if((m==='"'||m==="'"||m==="`"||E==='"'||E==="'"||E==="`")&&m!==E)throw new _i("property names with quotes must have matching quotes");if((v==="constructor"||!p)&&(c=!0),i+="."+v,o="%"+i+"%",ka(vn,o))a=vn[o];else if(a!=null){if(!(v in a)){if(!t)throw new ei("base intrinsic for "+e+" exists, but the property is not available.");return}if(fs&&h+1>=n.length){var x=fs(a,v);p=!!x,p&&"get"in x&&!("originalValue"in x.get)?a=x.get:a=a[v]}else p=ka(a,v),a=a[v];p&&!c&&(vn[o]=a)}}return a},Hl,Od;function Cr(){if(Od)return Hl;Od=1;var r=pt,e=sl,t=e([r("%String.prototype.indexOf%")]);return Hl=function(i,s){var o=r(i,!!s);return typeof o=="function"&&t(i,".prototype.")>-1?e([o]):o},Hl}var Zl,Md;function ju(){if(Md)return Zl;Md=1;var r=pt,e=r("%Array%"),t=!e.isArray&&Cr()("Object.prototype.toString");return Zl=e.isArray||function(i){return t(i)==="[object Array]"},Zl}var $0=il,Nd=ho,Rg=$0.hasArrayLengthDefineBug(),I0=Rg&&ju(),T0=Cr(),C0=T0("Object.prototype.propertyIsEnumerable"),qu=function(e,t,n,i,s,o){if(!Nd){if(!e(o)||!o["[[Configurable]]"]||!o["[[Writable]]"]||s in i&&C0(i,s)!==!!o["[[Enumerable]]"])return!1;var a=o["[[Value]]"];return i[s]=a,t(i[s],a)}return Rg&&s==="length"&&"[[Value]]"in o&&I0(i)&&i.length!==o["[[Value]]"]?(i.length=o["[[Value]]"],i.length===o["[[Value]]"]):(Nd(i,s,n(o)),!0)},P0=X,Zi=cr,R0={__proto__:null,"[[Configurable]]":!0,"[[Enumerable]]":!0,"[[Get]]":!0,"[[Set]]":!0,"[[Value]]":!0,"[[Writable]]":!0},Ci=function(e){if(!e||typeof e!="object")return!1;for(var t in e)if(Zi(e,t)&&!R0[t])return!1;var n=Zi(e,"[[Value]]")||Zi(e,"[[Writable]]"),i=Zi(e,"[[Get]]")||Zi(e,"[[Set]]");if(n&&i)throw new P0("Property Descriptors may not be both accessor and data descriptors");return!0},Dg=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},D0=X,L0=Ci,z0=Dg,Lg=function(e){if(typeof e<"u"&&!L0(e))throw new D0("Assertion failed: `Desc` must be a Property Descriptor");return z0(e)},O0=X,Ud=cr,M0=Ci,zg=function(e){if(typeof e>"u")return!1;if(!M0(e))throw new O0("Assertion failed: `Desc` must be a Property Descriptor");return!(!Ud(e,"[[Value]]")&&!Ud(e,"[[Writable]]"))},Pi=function(e){return typeof e=="string"||typeof e=="symbol"},Fd=Zu,Og=function(e,t){return e===t?e===0?1/e===1/t:!0:Fd(e)&&Fd(t)},Wd=X,N0=lr,U0=qu,F0=Lg,W0=zg,H0=Pi,Z0=Og,Yu=function(e,t,n){if(!N0(e))throw new Wd("Assertion failed: Type(O) is not Object");if(!H0(t))throw new Wd("Assertion failed: P is not a Property Key");var i={"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Value]]":n,"[[Writable]]":!0};return U0(W0,Z0,F0,e,t,i)},Mg=Function.prototype.toString,Xn=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,Rc,ia;if(typeof Xn=="function"&&typeof Object.defineProperty=="function")try{Rc=Object.defineProperty({},"length",{get:function(){throw ia}}),ia={},Xn(function(){throw 42},null,Rc)}catch(r){r!==ia&&(Xn=null)}else Xn=null;var V0=/^\s*class\b/,Dc=function(e){try{var t=Mg.call(e);return V0.test(t)}catch{return!1}},Vl=function(e){try{return Dc(e)?!1:(Mg.call(e),!0)}catch{return!1}},sa=Object.prototype.toString,B0="[object Object]",G0="[object Function]",j0="[object GeneratorFunction]",q0="[object HTMLAllCollection]",Y0="[object HTML document.all class]",X0="[object HTMLCollection]",K0=typeof Symbol=="function"&&!!Symbol.toStringTag,J0=!(0 in[,]),Lc=function(){return!1};if(typeof document=="object"){var Q0=document.all;sa.call(Q0)===sa.call(document.all)&&(Lc=function(e){if((J0||!e)&&(typeof e>"u"||typeof e=="object"))try{var t=sa.call(e);return(t===q0||t===Y0||t===X0||t===B0)&&e("")==null}catch{}return!1})}var Ng=Xn?function(e){if(Lc(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;try{Xn(e,null,Rc)}catch(t){if(t!==ia)return!1}return!Dc(e)&&Vl(e)}:function(e){if(Lc(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;if(K0)return Vl(e);if(Dc(e))return!1;var t=sa.call(e);return t!==G0&&t!==j0&&!/^\[object HTML/.test(t)?!1:Vl(e)},eS=Ng,tS=function(e){return!!e},Tt=cr,zo=X,rS=lr,Hd=eS,Bl=tS,nS=function(e){if(!rS(e))throw new zo("ToPropertyDescriptor requires an object");var t={};if(Tt(e,"enumerable")&&(t["[[Enumerable]]"]=Bl(e.enumerable)),Tt(e,"configurable")&&(t["[[Configurable]]"]=Bl(e.configurable)),Tt(e,"value")&&(t["[[Value]]"]=e.value),Tt(e,"writable")&&(t["[[Writable]]"]=Bl(e.writable)),Tt(e,"get")){var n=e.get;if(typeof n<"u"&&!Hd(n))throw new zo("getter must be a function");t["[[Get]]"]=n}if(Tt(e,"set")){var i=e.set;if(typeof i<"u"&&!Hd(i))throw new zo("setter must be a function");t["[[Set]]"]=i}if((Tt(t,"[[Get]]")||Tt(t,"[[Set]]"))&&(Tt(t,"[[Value]]")||Tt(t,"[[Writable]]")))throw new zo("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute");return t},Gl=X,iS=lr,Zd=Ci,sS=qu,oS=Lg,aS=zg,lS=Pi,cS=Og,uS=nS,hS=function(e,t,n){if(!iS(e))throw new Gl("Assertion failed: Type(O) is not Object");if(!lS(t))throw new Gl("Assertion failed: P is not a Property Key");var i=Zd(n)?n:uS(n);if(!Zd(i))throw new Gl("Assertion failed: Desc is not a valid Property Descriptor");return sS(aS,cS,oS,e,t,i)},Vd=X,dS=lr,pS=hS,fS=Pi,gS=function(e,t,n){if(!dS(e))throw new Vd("Assertion failed: Type(O) is not Object");if(!fS(t))throw new Vd("Assertion failed: P is not a Property Key");var i={"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Value]]":n,"[[Writable]]":!0};return pS(e,t,i)},mS=typeof Reflect<"u"&&Reflect.setPrototypeOf||null,vS=Wu,yS=vS.setPrototypeOf||null,bS=sl,Bd=Ii,wS=X,Ug={};try{Ug.__proto__=null}catch(r){if(!r||typeof r!="object"||!("code"in r)||r.code!=="ERR_PROTO_ACCESS")throw r}var SS=!("toString"in Ug),jl=Bd&&Bd(Object.prototype,"__proto__"),_S=SS&&(!!jl&&typeof jl.set=="function"&&bS([jl.set])||function(e,t){if(e==null)throw new wS("set Object.prototype.__proto__ called on null or undefined");return e.__proto__=t,t}),Gd=mS,kS=yS,jd=_S,xS=X,ES=Gd?function(e,t){if(Gd(e,t))return e;throw new xS("Reflect.setPrototypeOf: failed to set [[Prototype]]")}:kS||(jd?function(e,t){return jd(e,t),e}:null),qd=X,AS=lr,Yd=Tg,$S=function(e){if(!AS(e))throw new qd("Assertion failed: O must be an Object");if(!Yd)throw new qd("This environment does not support fetching prototypes.");return Yd(e)},IS=X,TS=ES,CS=lr,PS=$S,RS=function(e,t){if(t!==null&&!CS(t))throw new IS("Assertion failed: V must be Object or Null");try{TS(e,t)}catch{return!1}return PS(e)===t},ql=Yu,Xd=gS,Fg=RS,DS=il(),Xu=kg;function mo(r,e,t){var n=new Xu(t);return Fg(n,oa),delete n.constructor,Xd(n,"error",r),Xd(n,"suppressed",e),n}DS&&Object.defineProperty(mo,"prototype",{writable:!1});var oa=mo.prototype;if(!ql(oa,"constructor",mo)||!ql(oa,"message","")||!ql(oa,"name","SuppressedError"))throw new Xu("unable to install SuppressedError.prototype properties; please report this!");Fg(mo.prototype,Xu.prototype);var LS=mo,zS=LS,Wg=function(){return typeof SuppressedError=="function"?SuppressedError:zS},OS=xn,Kd=Fu(),MS=Wg,NS=function(){var e=MS();return OS(Kd,{SuppressedError:e},{SuppressedError:function(){return Kd.SuppressedError!==e}}),e};NS();var US=X,FS=Ci,WS=Dg,HS=function(e){if(typeof e<"u"&&!FS(e))throw new US("Assertion failed: `Desc` must be a Property Descriptor");return WS(e)},ZS=X,Jd=cr,VS=Ci,BS=function(e){if(typeof e>"u")return!1;if(!VS(e))throw new ZS("Assertion failed: `Desc` must be a Property Descriptor");return!(!Jd(e,"[[Value]]")&&!Jd(e,"[[Writable]]"))},Qd=Zu,GS=function(e,t){return e===t?e===0?1/e===1/t:!0:Qd(e)&&Qd(t)},Ri=Ng,jS=function(e){return!!e},Ct=cr,Oo=X,qS=lr,ep=Ri,Yl=jS,YS=function(e){if(!qS(e))throw new Oo("ToPropertyDescriptor requires an object");var t={};if(Ct(e,"enumerable")&&(t["[[Enumerable]]"]=Yl(e.enumerable)),Ct(e,"configurable")&&(t["[[Configurable]]"]=Yl(e.configurable)),Ct(e,"value")&&(t["[[Value]]"]=e.value),Ct(e,"writable")&&(t["[[Writable]]"]=Yl(e.writable)),Ct(e,"get")){var n=e.get;if(typeof n<"u"&&!ep(n))throw new Oo("getter must be a function");t["[[Get]]"]=n}if(Ct(e,"set")){var i=e.set;if(typeof i<"u"&&!ep(i))throw new Oo("setter must be a function");t["[[Set]]"]=i}if((Ct(t,"[[Get]]")||Ct(t,"[[Set]]"))&&(Ct(t,"[[Value]]")||Ct(t,"[[Writable]]")))throw new Oo("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute");return t},Xl=X,XS=lr,tp=Ci,KS=qu,JS=HS,QS=BS,e_=Pi,t_=GS,r_=YS,vo=function(e,t,n){if(!XS(e))throw new Xl("Assertion failed: Type(O) is not Object");if(!e_(t))throw new Xl("Assertion failed: P is not a Property Key");var i=tp(n)?n:r_(n);if(!tp(i))throw new Xl("Assertion failed: Desc is not a valid Property Descriptor");return KS(QS,t_,JS,e,t,i)},n_=Ti(),i_=n_?Symbol.dispose||Symbol("Symbol.dispose"):null,s_=Ti,o_=i_,Ku=function(){return s_()&&Symbol.dispose||o_},a_=Vu,l_=vo,c_=Ku,u_=function(){var e=c_();return a_()&&l_(Symbol,"dispose",{"[[Configurable]]":!1,"[[Enumerable]]":!1,"[[Writable]]":!1,"[[Value]]":e}),e},h_=Ti(),d_=h_?Symbol.asyncDispose||Symbol("Symbol.asyncDispose"):null,p_=Ti,f_=d_,Ju=function(){return p_()&&Symbol.asyncDispose||f_},g_=Vu,m_=vo,v_=Ju,y_=function(){var e=v_();return g_()&&m_(Symbol,"asyncDispose",{"[[Configurable]]":!1,"[[Enumerable]]":!1,"[[Writable]]":!1,"[[Value]]":e}),e},b_=ju(),w_=pt,S_=Cr(),__=X,k_=b_,x_=w_("%Reflect.apply%",!0)||S_("Function.prototype.apply"),ol=function(e,t){var n=arguments.length>2?arguments[2]:[];if(!k_(n))throw new __("Assertion failed: optional `argumentsList`, if provided, must be a List");return x_(e,t,n)};const E_={},A_=Object.freeze(Object.defineProperty({__proto__:null,default:E_},Symbol.toStringTag,{value:"Module"})),$_=Jb(A_);var Qu=typeof Map=="function"&&Map.prototype,Kl=Object.getOwnPropertyDescriptor&&Qu?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,Ea=Qu&&Kl&&typeof Kl.get=="function"?Kl.get:null,rp=Qu&&Map.prototype.forEach,eh=typeof Set=="function"&&Set.prototype,Jl=Object.getOwnPropertyDescriptor&&eh?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,Aa=eh&&Jl&&typeof Jl.get=="function"?Jl.get:null,np=eh&&Set.prototype.forEach,I_=typeof WeakMap=="function"&&WeakMap.prototype,cs=I_?WeakMap.prototype.has:null,T_=typeof WeakSet=="function"&&WeakSet.prototype,us=T_?WeakSet.prototype.has:null,C_=typeof WeakRef=="function"&&WeakRef.prototype,ip=C_?WeakRef.prototype.deref:null,P_=Boolean.prototype.valueOf,R_=Object.prototype.toString,D_=Function.prototype.toString,L_=String.prototype.match,th=String.prototype.slice,kr=String.prototype.replace,z_=String.prototype.toUpperCase,sp=String.prototype.toLowerCase,Hg=RegExp.prototype.test,op=Array.prototype.concat,Ft=Array.prototype.join,O_=Array.prototype.slice,ap=Math.floor,zc=typeof BigInt=="function"?BigInt.prototype.valueOf:null,Ql=Object.getOwnPropertySymbols,Oc=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,ki=typeof Symbol=="function"&&typeof Symbol.iterator=="object",hs=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===ki||!0)?Symbol.toStringTag:null,Zg=Object.prototype.propertyIsEnumerable,lp=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(r){return r.__proto__}:null);function cp(r,e){if(r===1/0||r===-1/0||r!==r||r&&r>-1e3&&r<1e3||Hg.call(/e/,e))return e;var t=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof r=="number"){var n=r<0?-ap(-r):ap(r);if(n!==r){var i=String(n),s=th.call(e,i.length+1);return kr.call(i,t,"$&_")+"."+kr.call(kr.call(s,/([0-9]{3})/g,"$&_"),/_$/,"")}}return kr.call(e,t,"$&_")}var Mc=$_,up=Mc.custom,hp=Gg(up)?up:null,Vg={__proto__:null,double:'"',single:"'"},M_={__proto__:null,double:/(["\\])/g,single:/(['\\])/g},Di=function r(e,t,n,i){var s=t||{};if(Xt(s,"quoteStyle")&&!Xt(Vg,s.quoteStyle))throw new TypeError('option "quoteStyle" must be "single" or "double"');if(Xt(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=Xt(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(Xt(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(Xt(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 qg(e,s);if(typeof e=="number"){if(e===0)return 1/0/e>0?"0":"-0";var c=String(e);return a?cp(e,c):c}if(typeof e=="bigint"){var u=String(e)+"n";return a?cp(e,u):u}var h=typeof s.depth>"u"?5:s.depth;if(typeof n>"u"&&(n=0),n>=h&&h>0&&typeof e=="object")return Nc(e)?"[Array]":"[Object]";var p=tk(s,n);if(typeof i>"u")i=[];else if(jg(i,e)>=0)return"[Circular]";function v(At,ur,xl){if(ur&&(i=O_.call(i),i.push(ur)),xl){var Ao={depth:s.depth};return Xt(s,"quoteStyle")&&(Ao.quoteStyle=s.quoteStyle),r(At,Ao,n+1,i)}return r(At,s,n+1,i)}if(typeof e=="function"&&!dp(e)){var m=G_(e),E=Mo(e,v);return"[Function"+(m?": "+m:" (anonymous)")+"]"+(E.length>0?" { "+Ft.call(E,", ")+" }":"")}if(Gg(e)){var x=ki?kr.call(String(e),/^(Symbol\(.*\))_[^)]*$/,"$1"):Oc.call(e);return typeof e=="object"&&!ki?Vi(x):x}if(J_(e)){for(var T="<"+sp.call(String(e.nodeName)),O=e.attributes||[],P=0;P<O.length;P++)T+=" "+O[P].name+"="+Bg(N_(O[P].value),"double",s);return T+=">",e.childNodes&&e.childNodes.length&&(T+="..."),T+="</"+sp.call(String(e.nodeName))+">",T}if(Nc(e)){if(e.length===0)return"[]";var Z=Mo(e,v);return p&&!ek(Z)?"["+Uc(Z,p)+"]":"[ "+Ft.call(Z,", ")+" ]"}if(F_(e)){var F=Mo(e,v);return!("cause"in Error.prototype)&&"cause"in e&&!Zg.call(e,"cause")?"{ ["+String(e)+"] "+Ft.call(op.call("[cause]: "+v(e.cause),F),", ")+" }":F.length===0?"["+String(e)+"]":"{ ["+String(e)+"] "+Ft.call(F,", ")+" }"}if(typeof e=="object"&&o){if(hp&&typeof e[hp]=="function"&&Mc)return Mc(e,{depth:h-n});if(o!=="symbol"&&typeof e.inspect=="function")return e.inspect()}if(j_(e)){var B=[];return rp&&rp.call(e,function(At,ur){B.push(v(ur,e,!0)+" => "+v(At,e))}),pp("Map",Ea.call(e),B,p)}if(X_(e)){var N=[];return np&&np.call(e,function(At){N.push(v(At,e))}),pp("Set",Aa.call(e),N,p)}if(q_(e))return ec("WeakMap");if(K_(e))return ec("WeakSet");if(Y_(e))return ec("WeakRef");if(H_(e))return Vi(v(Number(e)));if(V_(e))return Vi(v(zc.call(e)));if(Z_(e))return Vi(P_.call(e));if(W_(e))return Vi(v(String(e)));if(typeof window<"u"&&e===window)return"{ [object Window] }";if(typeof globalThis<"u"&&e===globalThis||typeof Zr<"u"&&e===Zr)return"{ [object globalThis] }";if(!U_(e)&&!dp(e)){var J=Mo(e,v),j=lp?lp(e)===Object.prototype:e instanceof Object||e.constructor===Object,st=e instanceof Object?"":"null prototype",Zt=!j&&hs&&Object(e)===e&&hs in e?th.call(Pr(e),8,-1):st?"Object":"",_e=j||typeof e.constructor!="function"?"":e.constructor.name?e.constructor.name+" ":"",Lr=_e+(Zt||st?"["+Ft.call(op.call([],Zt||[],st||[]),": ")+"] ":"");return J.length===0?Lr+"{}":p?Lr+"{"+Uc(J,p)+"}":Lr+"{ "+Ft.call(J,", ")+" }"}return String(e)};function Bg(r,e,t){var n=t.quoteStyle||e,i=Vg[n];return i+r+i}function N_(r){return kr.call(String(r),/"/g,"&quot;")}function En(r){return!hs||!(typeof r=="object"&&(hs in r||typeof r[hs]<"u"))}function Nc(r){return Pr(r)==="[object Array]"&&En(r)}function U_(r){return Pr(r)==="[object Date]"&&En(r)}function dp(r){return Pr(r)==="[object RegExp]"&&En(r)}function F_(r){return Pr(r)==="[object Error]"&&En(r)}function W_(r){return Pr(r)==="[object String]"&&En(r)}function H_(r){return Pr(r)==="[object Number]"&&En(r)}function Z_(r){return Pr(r)==="[object Boolean]"&&En(r)}function Gg(r){if(ki)return r&&typeof r=="object"&&r instanceof Symbol;if(typeof r=="symbol")return!0;if(!r||typeof r!="object"||!Oc)return!1;try{return Oc.call(r),!0}catch{}return!1}function V_(r){if(!r||typeof r!="object"||!zc)return!1;try{return zc.call(r),!0}catch{}return!1}var B_=Object.prototype.hasOwnProperty||function(r){return r in this};function Xt(r,e){return B_.call(r,e)}function Pr(r){return R_.call(r)}function G_(r){if(r.name)return r.name;var e=L_.call(D_.call(r),/^function\s*([\w$]+)/);return e?e[1]:null}function jg(r,e){if(r.indexOf)return r.indexOf(e);for(var t=0,n=r.length;t<n;t++)if(r[t]===e)return t;return-1}function j_(r){if(!Ea||!r||typeof r!="object")return!1;try{Ea.call(r);try{Aa.call(r)}catch{return!0}return r instanceof Map}catch{}return!1}function q_(r){if(!cs||!r||typeof r!="object")return!1;try{cs.call(r,cs);try{us.call(r,us)}catch{return!0}return r instanceof WeakMap}catch{}return!1}function Y_(r){if(!ip||!r||typeof r!="object")return!1;try{return ip.call(r),!0}catch{}return!1}function X_(r){if(!Aa||!r||typeof r!="object")return!1;try{Aa.call(r);try{Ea.call(r)}catch{return!0}return r instanceof Set}catch{}return!1}function K_(r){if(!us||!r||typeof r!="object")return!1;try{us.call(r,us);try{cs.call(r,cs)}catch{return!0}return r instanceof WeakSet}catch{}return!1}function J_(r){return!r||typeof r!="object"?!1:typeof HTMLElement<"u"&&r instanceof HTMLElement?!0:typeof r.nodeName=="string"&&typeof r.getAttribute=="function"}function qg(r,e){if(r.length>e.maxStringLength){var t=r.length-e.maxStringLength,n="... "+t+" more character"+(t>1?"s":"");return qg(th.call(r,0,e.maxStringLength),e)+n}var i=M_[e.quoteStyle||"single"];i.lastIndex=0;var s=kr.call(kr.call(r,i,"\\$1"),/[\x00-\x1f]/g,Q_);return Bg(s,"single",e)}function Q_(r){var e=r.charCodeAt(0),t={8:"b",9:"t",10:"n",12:"f",13:"r"}[e];return t?"\\"+t:"\\x"+(e<16?"0":"")+z_.call(e.toString(16))}function Vi(r){return"Object("+r+")"}function ec(r){return r+" { ? }"}function pp(r,e,t,n){var i=n?Uc(t,n):Ft.call(t,", ");return r+" ("+e+") {"+i+"}"}function ek(r){for(var e=0;e<r.length;e++)if(jg(r[e],`
2
- `)>=0)return!1;return!0}function tk(r,e){var t;if(r.indent===" ")t=" ";else if(typeof r.indent=="number"&&r.indent>0)t=Ft.call(Array(r.indent+1)," ");else return null;return{base:t,prev:Ft.call(Array(e+1),t)}}function Uc(r,e){if(r.length===0)return"";var t=`
3
- `+e.prev+e.base;return t+Ft.call(r,","+t)+`
4
- `+e.prev}function Mo(r,e){var t=Nc(r),n=[];if(t){n.length=r.length;for(var i=0;i<r.length;i++)n[i]=Xt(r,i)?e(r[i],r):""}var s=typeof Ql=="function"?Ql(r):[],o;if(ki){o={};for(var a=0;a<s.length;a++)o["$"+s[a]]=s[a]}for(var c in r)Xt(r,c)&&(t&&String(Number(c))===c&&c<r.length||ki&&o["$"+c]instanceof Symbol||(Hg.call(/[^\w$]/,c)?n.push(e(c,r)+": "+e(r[c],r)):n.push(c+": "+e(r[c],r))));if(typeof Ql=="function")for(var u=0;u<s.length;u++)Zg.call(r,s[u])&&n.push("["+e(s[u])+"]: "+e(r[s[u]],r));return n}var rk=Di,nk=X,al=function(r,e,t){for(var n=r,i;(i=n.next)!=null;n=i)if(i.key===e)return n.next=i.next,t||(i.next=r.next,r.next=i),i},ik=function(r,e){if(r){var t=al(r,e);return t&&t.value}},sk=function(r,e,t){var n=al(r,e);n?n.value=t:r.next={key:e,next:r.next,value:t}},ok=function(r,e){return r?!!al(r,e):!1},ak=function(r,e){if(r)return al(r,e,!0)},lk=function(){var e,t={assert:function(n){if(!t.has(n))throw new nk("Side channel does not contain "+rk(n))},delete:function(n){var i=e&&e.next,s=ak(e,n);return s&&i&&i===s&&(e=void 0),!!s},get:function(n){return ik(e,n)},has:function(n){return ok(e,n)},set:function(n,i){e||(e={next:void 0}),sk(e,n,i)}};return t},ck=pt,yo=Cr(),uk=Di,hk=X,fp=ck("%Map%",!0),dk=yo("Map.prototype.get",!0),pk=yo("Map.prototype.set",!0),fk=yo("Map.prototype.has",!0),gk=yo("Map.prototype.delete",!0),mk=yo("Map.prototype.size",!0),Yg=!!fp&&function(){var e,t={assert:function(n){if(!t.has(n))throw new hk("Side channel does not contain "+uk(n))},delete:function(n){if(e){var i=gk(e,n);return mk(e)===0&&(e=void 0),i}return!1},get:function(n){if(e)return dk(e,n)},has:function(n){return e?fk(e,n):!1},set:function(n,i){e||(e=new fp),pk(e,n,i)}};return t},vk=pt,ll=Cr(),yk=Di,No=Yg,bk=X,Mn=vk("%WeakMap%",!0),wk=ll("WeakMap.prototype.get",!0),Sk=ll("WeakMap.prototype.set",!0),_k=ll("WeakMap.prototype.has",!0),kk=ll("WeakMap.prototype.delete",!0),xk=Mn?function(){var e,t,n={assert:function(i){if(!n.has(i))throw new bk("Side channel does not contain "+yk(i))},delete:function(i){if(Mn&&i&&(typeof i=="object"||typeof i=="function")){if(e)return kk(e,i)}else if(No&&t)return t.delete(i);return!1},get:function(i){return Mn&&i&&(typeof i=="object"||typeof i=="function")&&e?wk(e,i):t&&t.get(i)},has:function(i){return Mn&&i&&(typeof i=="object"||typeof i=="function")&&e?_k(e,i):!!t&&t.has(i)},set:function(i,s){Mn&&i&&(typeof i=="object"||typeof i=="function")?(e||(e=new Mn),Sk(e,i,s)):No&&(t||(t=No()),t.set(i,s))}};return n}:No,Ek=X,Ak=Di,$k=lk,Ik=Yg,Tk=xk,Ck=Tk||Ik||$k,Pk=function(){var e,t={assert:function(n){if(!t.has(n))throw new Ek("Side channel does not contain "+Ak(n))},delete:function(n){return!!e&&e.delete(n)},get:function(n){return e&&e.get(n)},has:function(n){return!!e&&e.has(n)},set:function(n,i){e||(e=Ck()),e.set(n,i)}};return t},Rk=cr,Bi=Pk(),jt=X,rh={assert:function(r,e){if(!r||typeof r!="object"&&typeof r!="function")throw new jt("`O` is not an object");if(typeof e!="string")throw new jt("`slot` must be a string");if(Bi.assert(r),!rh.has(r,e))throw new jt("`"+e+"` is not present on `O`")},get:function(r,e){if(!r||typeof r!="object"&&typeof r!="function")throw new jt("`O` is not an object");if(typeof e!="string")throw new jt("`slot` must be a string");var t=Bi.get(r);return t&&t["$"+e]},has:function(r,e){if(!r||typeof r!="object"&&typeof r!="function")throw new jt("`O` is not an object");if(typeof e!="string")throw new jt("`slot` must be a string");var t=Bi.get(r);return!!t&&Rk(t,"$"+e)},set:function(r,e,t){if(!r||typeof r!="object"&&typeof r!="function")throw new jt("`O` is not an object");if(typeof e!="string")throw new jt("`slot` must be a string");var n=Bi.get(r);n||(n={},Bi.set(r,n)),n["$"+e]=t}};Object.freeze&&Object.freeze(rh);var nh=rh,Xg=ar,xr=nh,bo=function r(e,t){if(!(this instanceof r))return new r(e,t);if(e!=="normal"&&e!=="break"&&e!=="continue"&&e!=="return"&&e!=="throw")throw new Xg('Assertion failed: `type` must be one of "normal", "break", "continue", "return", or "throw"');xr.set(this,"[[Type]]",e),xr.set(this,"[[Value]]",t)};bo.prototype.type=function(){return xr.get(this,"[[Type]]")};bo.prototype.value=function(){return xr.get(this,"[[Value]]")};bo.prototype["?"]=function(){var e=xr.get(this,"[[Type]]"),t=xr.get(this,"[[Value]]");if(e==="throw")throw t;return t};bo.prototype["!"]=function(){var e=xr.get(this,"[[Type]]");if(e!=="normal")throw new Xg('Assertion failed: Completion Record is not of type "normal"');return xr.get(this,"[[Value]]")};var ih=bo,Dk=ih,sh=function(e){return new Dk("normal",e)},tc,gp;function Lk(){if(gp)return tc;gp=1;var r=Ti;return tc=function(){return r()&&!!Symbol.toStringTag},tc}var zk=pt,mp=zk("%Object.defineProperty%",!0),Ok=Lk()(),Mk=cr,Nk=X,Uo=Ok?Symbol.toStringTag:null,Kg=function(e,t){var n=arguments.length>2&&!!arguments[2]&&arguments[2].force,i=arguments.length>2&&!!arguments[2]&&arguments[2].nonConfigurable;if(typeof n<"u"&&typeof n!="boolean"||typeof i<"u"&&typeof i!="boolean")throw new Nk("if provided, the `overrideIfSet` and `nonConfigurable` options must be booleans");Uo&&(n||!Mk(e,Uo))&&(mp?mp(e,Uo,{configurable:!i,enumerable:!1,value:t,writable:!1}):e[Uo]=t)},Jg={exports:{}},Uk=pt,vp=gg,Fk=il(),yp=Ii,bp=X,Wk=Uk("%Math.floor%"),Hk=function(e,t){if(typeof e!="function")throw new bp("`fn` is not a function");if(typeof t!="number"||t<0||t>4294967295||Wk(t)!==t)throw new bp("`length` must be a positive 32-bit integer");var n=arguments.length>2&&!!arguments[2],i=!0,s=!0;if("length"in e&&yp){var o=yp(e,"length");o&&!o.configurable&&(i=!1),o&&!o.writable&&(s=!1)}return(i||s||!n)&&(Fk?vp(e,"length",t,!0,!0):vp(e,"length",t)),e},Zk=po,Vk=Gu,Bk=Ag,Gk=function(){return Bk(Zk,Vk,arguments)};(function(r){var e=Hk,t=ho,n=sl,i=Gk;r.exports=function(o){var a=n(arguments),c=1+o.length-(arguments.length-1);return e(a,c>0?c:0,!0)},t?t(r.exports,"apply",{value:i}):r.exports.apply=i})(Jg);var oh=Jg.exports,jk=function(e,t){for(var n=0;n<e.length;n+=1)if(!t(e[n],n,e))return!1;return!0},qk=Object,Yk=function(e){return e&&typeof e=="object"&&(typeof e["[[ResourceValue]]"]>"u"||qk(e["[[ResourceValue]]"])===e["[[ResourceValue]]"])&&(e["[[Hint]]"]==="SYNC-DISPOSE"||e["[[Hint]]"]==="ASYNC-DISPOSE")&&(typeof e["[[DisposeMethod]]"]=="function"||typeof e["[[DisposeMethod]]"]>"u")},Xk=cr,Kk=ju(),Jk=jk,Qk=Yk,ex=function(e){return e&&typeof e=="object"&&Xk(e,"[[DisposableResourceStack]]")&&Kk(e["[[DisposableResourceStack]]"])&&(e["[[DisposableResourceStack]]"].length===0||Jk(e["[[DisposableResourceStack]]"],Qk))},tx=lr,rx=function(e){if(e===null)return"Null";if(typeof e>"u")return"Undefined";if(tx(e))return"Object";if(typeof e=="number")return"Number";if(typeof e=="boolean")return"Boolean";if(typeof e=="string")return"String"},nx=rx,ah=function(e){return typeof e=="symbol"?"Symbol":typeof e=="bigint"?"BigInt":nx(e)},ix=X,sx=Di,ox=Pi,ax=function(e,t){if(!ox(t))throw new ix("Assertion failed: P is not a Property Key, got "+sx(t));return e[t]},wp=X,lx=ax,cx=Ri,ux=Pi,Sp=Di,hx=function(e,t){if(!ux(t))throw new wp("Assertion failed: P is not a Property Key");var n=lx(e,t);if(n!=null){if(!cx(n))throw new wp(Sp(t)+" is not a function: "+Sp(n));return n}},Fc={exports:{}},dx=pt,px=dx,_p=px("%Reflect.construct%",!0),$a=vo;try{$a({},"",{"[[Get]]":function(){}})}catch{$a=null}if($a&&_p){var kp={},xp={};$a(xp,"length",{"[[Get]]":function(){throw kp},"[[Enumerable]]":!0}),Fc.exports=function(e){try{_p(e,xp)}catch(t){return t===kp}}}else Fc.exports=function(e){return typeof e=="function"&&!!e.prototype};var fx=Fc.exports,rc=X,Ep=Ri,gx=fx,mx=function(e){if(!gx(e))throw new rc("C must be a constructor");var t={"[[Resolve]]":void 0,"[[Reject]]":void 0},n=new e(function(i,s){if(typeof t["[[Resolve]]"]<"u"||typeof t["[[Reject]]"]<"u")throw new rc("executor has already been called");t["[[Resolve]]"]=i,t["[[Reject]]"]=s});if(!Ep(t["[[Resolve]]"])||!Ep(t["[[Reject]]"]))throw new rc("executor must provide valid resolve and reject functions");return{"[[Promise]]":n,"[[Resolve]]":t["[[Resolve]]"],"[[Reject]]":t["[[Reject]]"]}},Ap=ar,vx=X,nc=ol,$p=hx,yx=mx,bx=ah,Ip=Ku(),Tp=Ju(),wx=function(e,t){if(bx(e)!=="Object")throw new vx("`V` must be an Object");if(t!=="SYNC-DISPOSE"&&t!=="ASYNC-DISPOSE")throw new Ap("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");var n;if(t==="ASYNC-DISPOSE"&&Tp&&(n=$p(e,Tp)),!n){if(!Ip)throw new Ap("`Symbol.dispose` is not supported");if(n=$p(e,Ip),typeof n<"u")return function(){var i=this;if(t==="ASYNC-DISPOSE"){var s=yx(Promise);try{nc(n,i),nc(s["[[Resolve]]"],void 0,[void 0])}catch(o){s["[[Reject]]"](o)}return s["[[Promise]]"]}nc(n,i)}}return n},Sx=ar,ic=X,_x=Ri,kx=ah,xx=wx,Ex=function(e,t){if(t!=="SYNC-DISPOSE"&&t!=="ASYNC-DISPOSE")throw new Sx("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");var n;if(arguments.length<3)if(e==null)e=void 0,n=void 0;else{if(typeof e<"u"&&kx(e)!=="Object")throw new ic("`V` must be an Object, or `null` or `undefined`");if(n=xx(e,t),typeof n>"u")throw new ic("dispose method must not be `undefined` on `V` when an object `V` is provided")}else if(n=arguments[2],!_x(n))throw new ic("`method`, when provided, must be a function");return{"[[ResourceValue]]":e,"[[Hint]]":t,"[[DisposeMethod]]":n}},Ax=ar,Fo=X,$x=ex,Cp=Ex,Ix=Cr(),Tx=Ix("Array.prototype.push"),Qg=function(e,t,n){if(!$x(e))throw new Fo("Assertion failed: `disposeCapability` must be a DisposeCapability Record");if(n!=="SYNC-DISPOSE"&&n!=="ASYNC-DISPOSE")throw new Ax("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 Fo("Assertion failed: `method`, when present, must be a function");if(!e["[[DisposableResourceStack]]"])throw new Fo("Assertion failed: `disposeCapability.[[DisposableResourceStack]]` must not be ~EMPTY~");var s;if(arguments.length<4){if(t==null&&n==="SYNC_DISPOSE")return"UNUSED";s=Cp(t,n)}else{if(typeof t<"u")throw new Fo("Assertion failed: `V` must be undefined when `method` is present");s=Cp(void 0,n,i)}return Tx(e["[[DisposableResourceStack]]"],s),"UNUSED"},sc,Pp;function lh(){if(Pp)return sc;Pp=1;var r=pt,e=oh,t=ar,n=r("%Promise.resolve%",!0),i=n&&e(n);return sc=function(o,a){if(!i)throw new t("This environment does not support Promises.");return i(o,a)},sc}var oc,Rp;function Cx(){if(Rp)return oc;Rp=1;var r=pt,e=ar,t=r("%Promise%",!0),n=ol,i=lh(),s=ah;return oc=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:n(u,a);if(c==="ASYNC-DISPOSE")return i(t,h)},oc}var ac,Dp;function Px(){if(Dp)return ac;Dp=1;var r=ih;return ac=function(t){return new r("throw",t)},ac}var Rx=pt,lc=ar,Lp=X,Dx=Rx("%Promise%",!0),Lx=Cr(),zp=Lx("Promise.prototype.then",!0),zx=ih,Op=Cx(),Ox=sh,Mx=lh(),Mp=Px(),Nx=Wg(),em=function(e,t){if(!(t instanceof zx))throw new Lp("`completion` must be a Completion Record");var n=e["[[DisposableResourceStack]]"];if(!n)throw new Lp("Assertion failed: `disposeCapability.[[DisposableResourceStack]]` must not be ~EMPTY~");for(var i,s=n.length-1;s>=0;s-=1)if(!i)i=n[s]["[[Hint]]"];else if(i!==n[s]["[[Hint]]"])throw new lc("mixed hint stacks are not supported");for(var o=i==="ASYNC-DISPOSE"&&Mx(Dx,t),a=function(v){if(t.type()==="throw"){var m=t.value(),E=new Nx(v,m);t=Mp(E)}else t=Mp(v)},c=i==="ASYNC-DISPOSE"&&function(m){return zp(o,function(){var E=Op(m["[[ResourceValue]]"],m["[[Hint]]"],m["[[DisposeMethod]]"]);if(!E)throw new lc("Assertion failed: non-`~ASYNC-DISPOSE~` resource returned a promise from Dispose");return zp(E,Ox)},a)},u=n.length-1;u>=0;u-=1)if(i==="ASYNC-DISPOSE")o=c(n[u]);else{var h=n[u];try{var p=Op(h["[[ResourceValue]]"],h["[[Hint]]"],h["[[DisposeMethod]]"]);if(p)throw new lc("Assertion failed: `~SYNC-DISPOSE~` resource returned something from Dispose")}catch(v){a(v)}}return e["[[DisposableResourceStack]]"]=null,i==="ASYNC-DISPOSE"?o:t},tm=function(){var e=[];return{"[[DisposableResourceStack]]":e}},cl=Hu,ch=X,Ux=ol,Li=Yu,Fx=vo,rm=Ri,Wx=sh,Je=nh,Hx=Kg,nm=xn.supportsDescriptors,Zx=oh,uh=Qg,Vx=em,im=tm,Np=Ku(),ut=function r(){if(!(this instanceof r)||Je.has(this,"[[DisposableState]]")||Je.has(this,"[[DisposeCapability]]"))throw new ch("can only be used with new");Je.set(this,"[[DisposableState]]","PENDING"),Je.set(this,"[[DisposeCapability]]",im())},sm=function(){var e=this;return Je.assert(e,"[[DisposableState]]"),Je.get(e,"[[DisposableState]]")==="DISPOSED"},wo=Zx(sm);nm?Fx(ut.prototype,"disposed",{"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Get]]":sm}):ut.prototype.disposed=!1;var om=function(e){Je.set(e,"[[DisposableState]]","DISPOSED"),nm||(e.disposed=!0)};Li(ut.prototype,"dispose",function(){var e=this;if(!wo(e))return om(e),Vx(Je.get(e,"[[DisposeCapability]]"),Wx())["?"]()});Li(ut.prototype,"use",function(e){var t=this;if(wo(t))throw new cl("a disposed stack can not use anything new");return uh(Je.get(t,"[[DisposeCapability]]"),e,"SYNC-DISPOSE"),e});Li(ut.prototype,"adopt",function(e,t){var n=this;if(wo(n))throw new cl("a disposed stack can not use anything new");if(!rm(t))throw new ch("`onDispose` must be a function");var i=function(){return Ux(t,void 0,[e])};return uh(Je.get(n,"[[DisposeCapability]]"),void 0,"SYNC-DISPOSE",i),e});Li(ut.prototype,"defer",function(e){var t=this;if(wo(t))throw new cl("a disposed stack can not defer anything new");if(!rm(e))throw new ch("`onDispose` must be a function");uh(Je.get(t,"[[DisposeCapability]]"),void 0,"SYNC-DISPOSE",e)});Li(ut.prototype,"move",function(){var e=this;if(wo(e))throw new cl("a disposed stack can not use anything new");var t=new ut;return Je.set(t,"[[DisposeCapability]]",Je.get(e,"[[DisposeCapability]]")),Je.set(e,"[[DisposeCapability]]",im()),om(e),t});Np&&Li(ut.prototype,Np,ut.prototype.dispose);Hx(ut.prototype,"DisposableStack");var Bx=ut,Gx=Bx,jx=function(){return typeof DisposableStack=="function"?DisposableStack:Gx},qx=xn,Yx=Fu(),Xx=jx,Kx=function(){var e=Xx();return qx(Yx,{DisposableStack:e},{DisposableStack:!0}),e},Jx=pt,ul=Hu,hh=X,Up=Jx("%Promise%",!0),dh=Qg,Qx=ol,zi=Yu,eE=vo,tE=em,am=Ri,lm=tm,rE=sh,Fp=lh(),Qe=nh,nE=Kg,cm=xn.supportsDescriptors,iE=oh,sE=Cr(),oE=sE("Promise.prototype.then",!0),Wp=Ju(),ht=function r(){if(!(this instanceof r)||Qe.has(this,"[[AsyncDisposableState]]")||Qe.has(this,"[[DisposeCapability]]"))throw new hh("can only be used with new");Qe.set(this,"[[AsyncDisposableState]]","pending"),Qe.set(this,"[[DisposeCapability]]",lm())},um=function(){var e=this;return Qe.assert(e,"[[AsyncDisposableState]]"),Qe.get(e,"[[AsyncDisposableState]]")==="disposed"},So=iE(um);cm?eE(ht.prototype,"disposed",{"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Get]]":um}):ht.prototype.disposed=!1;var hm=function(e){Qe.set(e,"[[AsyncDisposableState]]","disposed"),cm||(e.disposed=!0)};zi(ht.prototype,"disposeAsync",function(){var e=this;return So(e)?Fp(Up):(hm(e),oE(Fp(Up,tE(Qe.get(e,"[[DisposeCapability]]"),rE())),function(t){return t["?"]()}))});zi(ht.prototype,"use",function(e){var t=this;if(So(t))throw new ul("a disposed stack can not use anything new");return dh(Qe.get(t,"[[DisposeCapability]]"),e,"ASYNC-DISPOSE"),e});zi(ht.prototype,"adopt",function(e,t){var n=this;if(So(n))throw new ul("a disposed stack can not use anything new");if(!am(t))throw new hh("`onDisposeAsync` must be a function");var i=function(){return Qx(t,void 0,[e])};return i.value=e,dh(Qe.get(n,"[[DisposeCapability]]"),void 0,"ASYNC-DISPOSE",i),e});zi(ht.prototype,"defer",function(e){var t=this;if(So(t))throw new ul("a disposed stack can not defer anything new");if(!am(e))throw new hh("`onDispose` must be a function");dh(Qe.get(t,"[[DisposeCapability]]"),void 0,"ASYNC-DISPOSE",e)});zi(ht.prototype,"move",function(){var e=this;if(So(e))throw new ul("a disposed stack can not use anything new");var t=new ht;return Qe.set(t,"[[DisposeCapability]]",Qe.get(e,"[[DisposeCapability]]")),Qe.set(e,"[[DisposeCapability]]",lm()),hm(e),t});Wp&&zi(ht.prototype,Wp,ht.prototype.disposeAsync);nE(ht.prototype,"AsyncDisposableStack");var aE=ht,lE=aE,cE=function(){return typeof AsyncDisposableStack=="function"?AsyncDisposableStack:lE},uE=xn,hE=Fu(),dE=cE,pE=function(){var e=dE();return uE(hE,{AsyncDisposableStack:e},{AsyncDisposableStack:!0}),e},fE=u_,gE=y_,mE=Kx,vE=pE,yE=function(){fE(),gE(),mE(),vE()};yE();const Hp=new WeakMap;function bE(r){return(typeof r=="object"||typeof r=="function")&&r!==null&&"then"in r&&typeof r.then=="function"}function Nn(r){return typeof r=="string"?r:typeof r=="symbol"?r.description??r.toString():r.name||"(anonymous class)"}function Zp(){return new Error("register(Key, factory) requires a factory function. Wrap existing instances as () => instance.")}function wE(){return new Error("register(Key, factory) does not accept async factories. Await setup before registering.")}class SE{constructor(){y(this,"entries",new Map);y(this,"constructionStack",[])}register(e,t){if(t===void 0){if(typeof e!="function")throw Zp();this.validateClassRegistration(e),this.storeFactory(e,()=>this.instantiateClass(e));return}if(typeof t!="function")throw Zp();if(t.constructor.name==="AsyncFunction")throw wE();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 n=this.getOrCreateEntry(e);n.factory=t,n.instance=void 0,n.error=void 0}validateClassRegistration(e){const t=Hp.get(e);if(t){if(e.length!==t.length)throw new Error(`${Nn(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(`${Nn(e)} cannot be registered with register(Class). Undecorated classes must have zero required constructor parameters. Use register(Key, () => value) instead.`)}instantiateClass(e){const t=Hp.get(e);if(!t)return new e;const n=t.map(i=>this.resolveAny(i));return new e(...n)}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,n)=>{if(n==="then")return;const i=this.getInstance(e),s=Reflect.get(i,n,i);return typeof s=="function"?s.bind(i):s},set:(t,n,i)=>{const s=this.getInstance(e);return Reflect.set(s,n,i,s)},has:(t,n)=>{const i=this.getInstance(e);return n in i}})}getInstance(e){if(e.instance)return e.instance;if(e.error)throw e.error;if(!e.factory)throw new Error(`${Nn(e.key)} was resolved but never registered`);const t=this.constructionStack.indexOf(e.key);if(t!==-1){const n=[...this.constructionStack.slice(t),e.key].map(i=>Nn(i)).join(" -> ");throw new Error(`Circular dependency detected: ${n}`)}this.constructionStack.push(e.key);try{const n=e.factory();if(bE(n))throw new Error(`Factory for ${Nn(e.key)} returned a Promise. Await setup before registering.`);if(typeof n!="object"||n===null)throw new Error(`Factory for ${Nn(e.key)} returned a non-object value. Wrap primitives in an object.`);return e.instance=n,n}catch(n){throw e.error=n,n}finally{this.constructionStack.pop()}}}const Wt=new SE,_E=new Set(["target","currentTarget","eventPhase","defaultPrevented","isTrusted","timeStamp","srcElement","returnValue","cancelBubble","NONE","CAPTURING_PHASE","AT_TARGET","BUBBLING_PHASE","composedPath","stopPropagation","stopImmediatePropagation","preventDefault","initEvent"]);function kE(r){for(const e of Object.keys(r))if(_E.has(e))throw new Error(`Event payload key "${e}" is reserved; choose a different property name`)}function xE(r,e){kE(e);for(const t of Object.keys(e))Object.defineProperty(r,t,{value:e[t],writable:!0,enumerable:!0,configurable:!0})}function it(){class r extends Event{constructor(t,n){const{type:i,bubbles:s,cancelable:o,composed:a,...c}=n??{};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}),xE(this,c)}}return r}class Ht extends globalThis.EventTarget{}function EE(r,e,t){const n=r.dispose.bind(r);r.dispose=()=>{if(!e())return t(),n()}}function _o(r){var t;class e extends r{constructor(...s){super(...s);w(this,t,!1);EE(this,()=>l(this,t),()=>{_(this,t,!0)})}[Symbol.dispose](){this.dispose()}get disposed(){return l(this,t)}}return t=new WeakMap,e}const AE=it(),$E=it(),Hn=it(),dm="0123456789ABCDEFGHJKMNPQRSTVWXYZ",Ia=32,IE=16,pm=10,Vp=0xffffffffffff;var jr;(function(r){r.Base32IncorrectEncoding="B32_ENC_INVALID",r.DecodeTimeInvalidCharacter="DEC_TIME_CHAR",r.DecodeTimeValueMalformed="DEC_TIME_MALFORMED",r.EncodeTimeNegative="ENC_TIME_NEG",r.EncodeTimeSizeExceeded="ENC_TIME_SIZE_EXCEED",r.EncodeTimeValueMalformed="ENC_TIME_MALFORMED",r.PRNGDetectFailure="PRNG_DETECT",r.ULIDInvalid="ULID_INVALID",r.Unexpected="UNEXPECTED",r.UUIDInvalid="UUID_INVALID"})(jr||(jr={}));class es extends Error{constructor(e,t){super(`${t} (${e})`),this.name="ULIDError",this.code=e}}function TE(r){const e=Math.floor(r()*Ia)%Ia;return dm.charAt(e)}function CE(r){const e=PE(),t=e&&(e.crypto||e.msCrypto)||null;if(typeof(t==null?void 0:t.getRandomValues)=="function")return()=>{const n=new Uint8Array(1);return t.getRandomValues(n),n[0]/256};if(typeof(t==null?void 0:t.randomBytes)=="function")return()=>t.randomBytes(1).readUInt8()/256;throw new es(jr.PRNGDetectFailure,"Failed to find a reliable PRNG")}function PE(){return LE()?self:typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:null}function RE(r,e){let t="";for(;r>0;r--)t=TE(e)+t;return t}function DE(r,e=pm){if(isNaN(r))throw new es(jr.EncodeTimeValueMalformed,`Time must be a number: ${r}`);if(r>Vp)throw new es(jr.EncodeTimeSizeExceeded,`Cannot encode a time larger than ${Vp}: ${r}`);if(r<0)throw new es(jr.EncodeTimeNegative,`Time must be positive: ${r}`);if(Number.isInteger(r)===!1)throw new es(jr.EncodeTimeValueMalformed,`Time must be an integer: ${r}`);let t,n="";for(let i=e;i>0;i--)t=r%Ia,n=dm.charAt(t)+n,r=(r-t)/Ia;return n}function LE(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}function hl(r,e){const t=CE(),n=Date.now();return DE(n,pm)+RE(IE,t)}const Et=4,nt=6,gs=2,Wc=2,ph=8,zE=nt,fh="auto",Er="auto",dr=120,Bp=50,ce=16,yn=dr*Et+ce*(Et-1),Ta=dr*nt+ce*(nt-1),OE=yn+ce*2,ME=200,NE=4,Wo=150,UE=10,Gp=2,jp=8,FE=300,WE=4;function fm(r){return vm(r)}function gm(r,e){return vm(r.flatMap(t=>bm(t,e)))}function mm(r){const e=[],t=new Set;for(const n of r){if(n.type==="row"){e.push(`Top-level rows are invalid: ${n.id}`);continue}wm(n,"strip",e,t)}return{valid:e.length===0,errors:e}}function Kn(r){const e=fm(r),t=mm(e);if(!t.valid)throw new Error(`Invalid layout: ${t.errors.join("; ")}`);return{totalNodes:e.length,nodes:e.filter(n=>n.type!=="row").map(BE)}}function vm(r){const e=[];for(const t of r){const n=ym(t);for(const i of n){if(i.type==="row"){e.push(...i.children.map(or));continue}e.push(i)}}return e}function ym(r){switch(r.type){case"card":return[or(r)];case"row":{const e=r.children.map(or);return e.length===0?[]:e.length===1?[e[0]]:[{...r,children:e}]}case"stack":{const e=[];for(const t of r.children){const n=ym(t);for(const i of n){if(i.type==="stack"){e.push(...i.children.map(Hc));continue}if(i.type==="row"){e.push({...i,children:i.children.map(or)});continue}e.push(or(i))}}return e.length===0?[]:e.length===1?[Hc(e[0])]:[{...r,children:e}]}}}function bm(r,e){switch(r.type){case"card":return r.artifactID===e?[]:[or(r)];case"row":{const t=r.children.filter(n=>n.artifactID!==e).map(or);return t.length===0?[]:t.length===1?[t[0]]:[{...r,children:t}]}case"stack":{const t=r.children.flatMap(n=>bm(n,e).filter(s=>s.type!=="stack"));return t.length===0?[]:t.length===1?[Hc(t[0])]:[{...r,children:t}]}}}function wm(r,e,t,n){switch(r.type){case"card":Sm(r,e,t,n);return;case"row":HE(r,e,t,n);return;case"stack":ZE(r,e,t,n);return}}function Sm(r,e,t,n){gh(r.id,t),typeof r.artifactID!="string"||r.artifactID.length===0?t.push(`Card ${r.id} is missing artifactID`):n.has(r.artifactID)?t.push(`Duplicate artifactID in layout: ${r.artifactID}`):n.add(r.artifactID),VE(r.width)||t.push(`Card ${r.id} width must be an integer in the range ${gs}-${ph}`),_m(r.height)||t.push(`Card ${r.id} height must be an integer in the range 2-6 or "auto"`);const i=Vr(r.width);e==="row"&&i<gs&&t.push(`Row child ${r.id} must be at least 2 columns wide`)}function HE(r,e,t,n){if(gh(r.id,t),e!=="stack"&&t.push(`Row ${r.id} may only appear inside a stack`),_m(r.height,WE)||t.push(`Row ${r.id} height must be an integer in the range 2-4 or "auto"`),!Array.isArray(r.children)||r.children.length===0){t.push(`Row ${r.id} must contain card nodes`);return}let i=0;for(const s of r.children){if(s.type!=="card"){t.push(`Row ${r.id} must contain only card nodes`);continue}Sm(s,"row",t,n),i+=Vr(s.width)}i!==Et&&t.push(`Row ${r.id} children must sum to 4 columns`)}function ZE(r,e,t,n){if(gh(r.id,t),e!=="strip"&&t.push(`Invalid nested stack at ${r.id}; stack children cannot contain another nested stack`),!Array.isArray(r.children)||r.children.length===0){t.push(`Stack ${r.id} must contain at least one child`);return}let i=0,s=0;for(const a of r.children){if(a.type==="stack"){t.push(`Stack ${r.id} cannot contain another nested stack`);continue}if(wm(a,"stack",t,n),a.height===Er){s+=1;continue}i+=a.height}if(i>nt&&t.push(`Stack ${r.id} exceeds the 6-row budget`),s===0)return;const o=nt-i;if(o<s*Wc||o%s!==0){t.push(`Stack ${r.id} has auto-height children that cannot resolve to whole height >= 2`);return}o/s<Wc&&t.push(`Stack ${r.id} has auto-height children below the minimum row size`)}function gh(r,e){(typeof r!="string"||r.length===0)&&e.push(`Node id must be a non-empty string: ${String(r)}`)}function VE(r){return r===fh||Number.isInteger(r)&&r>=gs&&r<=ph}function _m(r,e=zE){return r===Er||Number.isInteger(r)&&r>=Wc&&r<=e}function Vr(r){return r===fh?Et:r}function BE(r){if(r.type==="card")return{id:r.id,type:"card",width:Vr(r.width),cards:[{id:r.id,artifactID:r.artifactID,col:1,row:1,width:Vr(r.width),height:km(r.height,nt)}]};const e=GE(r.children),t=[];let n=1;for(let i=0;i<r.children.length;i+=1){const s=r.children[i],o=e[i];if(s.type==="card")t.push({id:s.id,artifactID:s.artifactID,col:1,row:n,width:Math.min(Et,Vr(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:n,width:Vr(c.width),height:o}),a+=Vr(c.width)}n+=o}return{id:r.id,type:"stack",width:t.reduce((i,s)=>Math.max(i,s.col+s.width-1),1),cards:t}}function GE(r){let e=0,t=0;for(const i of r)i.height===Er?t+=1:e+=i.height;const n=t>0?(nt-e)/t:0;return r.map(i=>km(i.height,n))}function km(r,e){return r===Er?e:r}function or(r){return{...r}}function Hc(r){return r.type==="card"?or(r):{...r,children:r.children.map(or)}}function xm(r,e={}){return{id:e.id??hl(),type:"card",artifactID:r,width:e.width??fh,height:e.height??Er}}function Em(r,e){return r.some(t=>Am(t,e))}function Am(r,e){switch(r.type){case"card":return r.artifactID===e;case"row":return r.children.some(t=>t.artifactID===e);case"stack":return r.children.some(t=>Am(t,e))}}function qp(r){return r.layout.flatMap($m)}function $m(r){switch(r.type){case"card":return[r.artifactID];case"row":return r.children.map(e=>e.artifactID);case"stack":return r.children.flatMap($m)}}const re=it(),Im=it(),Un=it(),jE=it();function qE(r){class e extends Error{constructor(n,i){super(n),this.name=r,i&&Object.assign(this,i)}}return e}const YE=qE("RequestError"),XE=200,KE=300;class JE{constructor(e,t){y(this,"serverURL");y(this,"token");this.serverURL=e.replace(/\/$/,""),this.token=t.token}async requestJSON(e,t,n){const i=await this.request(e,t,n!==void 0?JSON.stringify(n):void 0,n!==void 0?{"content-type":"application/json"}:void 0),s=await QE(i);if(!i.ok||i.status<XE||i.status>=KE)throw this.createError(typeof s.error=="string"?s.error:i.statusText,i.status);return s}async requestVoid(e,t){const n=await this.request(e,t);if(!n.ok)throw this.createError(await cc(n,n.statusText),n.status)}async requestText(e,t){const n=await this.request(e,t);if(!n.ok)throw this.createError(await cc(n,n.statusText),n.status);return n.text()}async requestRawVoid(e,t,n){const i=await this.request(e,t,n,{"content-type":"text/plain"});if(!i.ok)throw this.createError(await cc(i,i.statusText),i.status)}createError(e,t){const n={serverURL:this.serverURL};return t!==void 0&&(n.status=t),new YE(e,n)}async request(e,t,n,i){const s=`${this.serverURL}${t}`;try{return await fetch(s,{method:e,headers:this.buildHeaders(i),body:n})}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 QE(r){try{return await r.json()}catch{const e=await r.text().catch(()=>"");return e?{message:e}:{}}}async function cc(r,e){try{const t=await r.json();if(typeof t.error=="string")return t.error;if(typeof t.message=="string")return t.message}catch{}return e}function eA(r){return r.map(e=>`${e.name} (${e.id})`).join(", ")}var Dt,Ha,Tm;class tA{constructor(e){w(this,Ha);w(this,Dt);_(this,Dt,e)}list(){return l(this,Dt).requestJSON("GET","/screens")}async get(e={}){const t=await f(this,Ha,Tm).call(this,e.screenID);return l(this,Dt).requestJSON("GET",`/screens/${encodeURIComponent(t)}`)}create(e){const t={name:e.name};return e.id!==void 0&&(t.id=e.id),l(this,Dt).requestJSON("POST","/screens",t)}update(e){const{screenID:t,...n}=e;return l(this,Dt).requestJSON("PATCH",`/screens/${encodeURIComponent(t)}`,n)}remove(e){return l(this,Dt).requestJSON("DELETE",`/screens/${encodeURIComponent(e.screenID)}`)}}Dt=new WeakMap,Ha=new WeakSet,Tm=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,Dt).createError(`screenID is required when multiple screens exist. Available screens: ${eA(t)}`)};var Oe;class rA{constructor(e){w(this,Oe);_(this,Oe,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,Oe).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 n=t.toString();return l(this,Oe).requestJSON("GET",n?`/artifacts?${n}`:"/artifacts")}get(e){return l(this,Oe).requestJSON("GET",`/artifacts/${encodeURIComponent(e.artifactID)}`)}update(e){const t={};return e.title!==void 0&&(t.title=e.title),l(this,Oe).requestJSON("PATCH",`/artifacts/${encodeURIComponent(e.artifactID)}`,t)}edit(e){return l(this,Oe).requestJSON("POST",`/artifacts/${encodeURIComponent(e.artifactID)}/edit`)}commitPending(e){return l(this,Oe).requestJSON("POST",`/artifacts/${encodeURIComponent(e.artifactID)}/commit`)}abandonPending(e){return l(this,Oe).requestVoid("POST",`/artifacts/${encodeURIComponent(e.artifactID)}/abandon`)}attach(e){return l(this,Oe).requestJSON("POST",`/screens/${encodeURIComponent(e.screenID)}/artifacts/${encodeURIComponent(e.artifactID)}`)}detach(e){return l(this,Oe).requestJSON("DELETE",`/screens/${encodeURIComponent(e.screenID)}/artifacts/${encodeURIComponent(e.artifactID)}`)}delete(e){return l(this,Oe).requestJSON("DELETE",`/artifacts/${encodeURIComponent(e.artifactID)}`)}getContent(e){return l(this,Oe).requestText("GET",`/artifacts/${encodeURIComponent(e.artifactID)}/content`)}putContent(e){return l(this,Oe).requestRawVoid("PUT",`/artifacts/${encodeURIComponent(e.artifactID)}/content`,e.content)}}Oe=new WeakMap;var Xr;class nA{constructor(e){w(this,Xr);_(this,Xr,e)}state(){return l(this,Xr).requestJSON("GET","/viewer/state")}setActive(e){return l(this,Xr).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,Xr).requestJSON("POST","/viewer/focus",t)}}Xr=new WeakMap;var _s;class iA{constructor(e){w(this,_s);_(this,_s,e)}async list(){const{views:e}=await l(this,_s).requestJSON("GET","/views");return e}}_s=new WeakMap;var Kt;class sA{constructor(e,t={}){y(this,"screens");y(this,"artifacts");y(this,"viewer");y(this,"views");w(this,Kt);_(this,Kt,new JE(e,t)),this.screens=new tA(l(this,Kt)),this.artifacts=new rA(l(this,Kt)),this.viewer=new nA(l(this,Kt)),this.views=new iA(l(this,Kt))}health(){return l(this,Kt).requestJSON("GET","/health")}}Kt=new WeakMap;const oA={focusCommandInput:{label:"Focus Command Input",trigger:{key:"k",meta:!0}}},aA=_o(Ht);var Kr,qe,Jr,Fe,mt,fr,gr,te,Fr,Cm,ks,Pm,Rm,Dm,Lm,Zc,Vc,Bc,zm;class lA extends aA{constructor(t){var i;super();w(this,te);y(this,"id");y(this,"server");w(this,Kr);w(this,qe,new Map);w(this,Jr);w(this,Fe);w(this,mt);w(this,fr);w(this,gr,null);w(this,ks,t=>{if(this.disposed)return;const n=t.event;switch(n.type){case"screen-updated":n.screen.id===this.id&&f(this,te,Pm).call(this,n.screen);break;case"artifact-created":break;case"artifact-attached":n.screenID===this.id&&f(this,te,Rm).call(this,n.cardID,n.artifact);break;case"artifact-updated":f(this,te,Dm).call(this,n.artifact);break;case"artifact-removed":n.screenID===this.id&&f(this,te,Lm).call(this,n.artifactID);break;case"artifact-content-changed":l(this,qe).has(n.artifactID)&&this.dispatchEvent(new jE("artifact-content-changed",{artifactID:n.artifactID}));break}});this.id=t.screen.id,this.server=t.server,_(this,Kr,t.localStore),_(this,Jr,t.screen.name),_(this,Fe,structuredClone(t.screen.layout)),_(this,mt,t.screen.pinned);const n=((i=l(this,Kr).get().screens[this.id])==null?void 0:i.scrollPosition)??0;_(this,fr,Math.max(0,n)),this.server.addEventListener("server-event",l(this,ks)),f(this,te,Cm).call(this)}get name(){return l(this,Jr)}get layout(){return l(this,Fe)}get pinned(){return l(this,mt)}get scrollPosition(){return l(this,fr)}get artifacts(){return l(this,qe)}setScrollPosition(t){f(this,te,Fr).call(this);const n=Math.max(0,t);n!==l(this,fr)&&(_(this,fr,n),f(this,te,zm).call(this),this.dispatchEvent(new re("change")))}setLayout(t){f(this,te,Fr).call(this);const n=fm(t);if(!mm(n).valid)return;const s=f(this,te,Vc).call(this);_(this,Fe,n),_(this,gr,{layout:n,snapshot:s}),this.dispatchEvent(new re("change")),this.server.client.screens.update({screenID:this.id,layout:n.map(o=>structuredClone(o))}).catch(()=>{var o;this.disposed||((o=l(this,gr))==null?void 0:o.layout)===n&&(_(this,gr,null),f(this,te,Bc).call(this,s),this.dispatchEvent(new re("change")))})}rename(t){f(this,te,Fr).call(this),_(this,Jr,t),this.dispatchEvent(new re("change")),this.server.client.screens.update({screenID:this.id,name:t}).catch(()=>{})}setPinned(t){if(f(this,te,Fr).call(this),l(this,mt)===t)return;const n=l(this,mt);_(this,mt,t),this.dispatchEvent(new re("change")),this.server.client.screens.update({screenID:this.id,pinned:t}).catch(()=>{this.disposed||l(this,mt)===t&&(_(this,mt,n),this.dispatchEvent(new re("change")))})}async remove(){f(this,te,Fr).call(this),await this.server.client.screens.remove({screenID:this.id})}removeArtifact(t){if(f(this,te,Fr).call(this),!l(this,qe).has(t))return;const n=f(this,te,Vc).call(this);f(this,te,Zc).call(this,t),this.dispatchEvent(new re("change")),this.server.client.artifacts.detach({artifactID:t,screenID:this.id}).catch(()=>{this.disposed||(f(this,te,Bc).call(this,n),this.dispatchEvent(new re("change")))})}dispose(){this.server.removeEventListener("server-event",l(this,ks))}}Kr=new WeakMap,qe=new WeakMap,Jr=new WeakMap,Fe=new WeakMap,mt=new WeakMap,fr=new WeakMap,gr=new WeakMap,te=new WeakSet,Fr=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 n of t.artifacts)l(this,qe).set(n.id,n);this.dispatchEvent(new re("change"))}catch{}},ks=new WeakMap,Pm=function(t){l(this,gr)&&_(this,gr,null),_(this,Jr,t.name),_(this,Fe,structuredClone(t.layout)),_(this,mt,t.pinned),this.dispatchEvent(new re("change"))},Rm=function(t,n){Em(l(this,Fe),n.id)||_(this,Fe,[...l(this,Fe),xm(n.id,{id:t})]),l(this,qe).set(n.id,n),this.dispatchEvent(new re("change"))},Dm=function(t){const n=l(this,qe).get(t.id);n&&(l(this,qe).set(t.id,{...n,...t}),this.dispatchEvent(new re("change")))},Lm=function(t){f(this,te,Zc).call(this,t)&&this.dispatchEvent(new re("change"))},Zc=function(t){const n=l(this,qe).delete(t),i=qp({layout:l(this,Fe)}).length,s=gm(l(this,Fe),t),o=qp({layout:s}).length;return _(this,Fe,s),n||i!==o},Vc=function(){return{layout:structuredClone(l(this,Fe)),artifacts:new Map([...l(this,qe).entries()].map(([t,n])=>[t,structuredClone(n)]))}},Bc=function(t){_(this,Fe,structuredClone(t.layout)),l(this,qe).clear();for(const[n,i]of t.artifacts)l(this,qe).set(n,structuredClone(i))},zm=function(){const t=l(this,Kr).get();l(this,Kr).set({...t,screens:{...t.screens,[this.id]:{scrollPosition:l(this,fr)}}})};const cA=_o(Ht);var ot,Lt,vt,xs,Es,As,ri,aa;class uA extends cA{constructor(t){super();w(this,ri);w(this,ot);w(this,Lt);w(this,vt,null);w(this,xs,()=>{this.disposed||f(this,ri,aa).call(this)});w(this,Es,()=>{this.disposed||f(this,ri,aa).call(this)});w(this,As,t=>{var i;if(this.disposed)return;const n=t.event;if(n.type==="screen-removed"&&((i=l(this,vt))==null?void 0:i.id)===n.screenID&&this.clearActive(),n.type==="viewer-active-screen-changed"){const s=l(this,Lt).servers.get(t.serverURL);s&&s.screens.has(n.screenID)&&this.setActive(t.serverURL,n.screenID)}});_(this,ot,t.localStore),_(this,Lt,t.serverManager),l(this,ot).addEventListener("change",l(this,xs)),l(this,Lt).addEventListener("change",l(this,Es)),l(this,Lt).addEventListener("server-event",l(this,As)),f(this,ri,aa).call(this)}get activeScreen(){return l(this,vt)}setActive(t,n){const i=l(this,ot).get();i.activeServerURL===t&&i.activeScreenID===n||l(this,ot).set({...i,activeServerURL:t,activeScreenID:n})}clearActive(){const t=l(this,ot).get();t.activeScreenID!==null&&l(this,ot).set({...t,activeScreenID:null})}dispose(){var t;l(this,ot).removeEventListener("change",l(this,xs)),l(this,Lt).removeEventListener("change",l(this,Es)),l(this,Lt).removeEventListener("server-event",l(this,As)),(t=l(this,vt))==null||t.dispose(),_(this,vt,null)}}ot=new WeakMap,Lt=new WeakMap,vt=new WeakMap,xs=new WeakMap,Es=new WeakMap,As=new WeakMap,ri=new WeakSet,aa=function(){var c,u,h;const{activeServerURL:t,activeScreenID:n}=l(this,ot).get(),i=t?l(this,Lt).servers.get(t)??null:null,s=i&&n?i.screens.get(n)??null:null,o=((c=l(this,vt))==null?void 0:c.id)??null,a=(s==null?void 0:s.id)??null;o===a&&((u=l(this,vt))==null?void 0:u.server)===i||((h=l(this,vt))==null||h.dispose(),_(this,vt,i&&s?new lA({screen:s,server:i,localStore:l(this,ot)}):null),i&&i.acpClient.setScreenContext(s?{screenID:s.id,screenName:s.name}:null),this.dispatchEvent(new AE("active-screen-changed")))};const hA="Local",dA="store-";function gt(r){return new URL(r).origin}function pA(r){return{servers:[{url:gt(r),name:hA}],activeServerURL:null,activeScreenID:null,screens:{}}}var Qr,en,tn;class fA extends Ht{constructor(t,n,i={}){super();w(this,Qr);w(this,en);w(this,tn);_(this,Qr,`${dA}${t}`),_(this,en,i.storage??gA());const s=l(this,en).getItem(l(this,Qr));s===null?(_(this,tn,n),l(this,en).setItem(l(this,Qr),JSON.stringify(n))):_(this,tn,JSON.parse(s))}get(){return l(this,tn)}set(t){_(this,tn,t),l(this,en).setItem(l(this,Qr),JSON.stringify(t)),this.dispatchEvent(new re("change"))}}Qr=new WeakMap,en=new WeakMap,tn=new WeakMap;function gA(){const r=globalThis.localStorage;if(!r)throw new Error("LocalStore: no storage adapter supplied and window.localStorage is unavailable");return r}function A(r,e,t){function n(a,c){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:c,constr:o,traits:new Set},enumerable:!1}),a._zod.traits.has(r))return;a._zod.traits.add(r),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:r});function o(a){var c;const u=t!=null&&t.Parent?new s:this;n(u,a),(c=u._zod).deferred??(c.deferred=[]);for(const h of u._zod.deferred)h();return u}return Object.defineProperty(o,"init",{value:n}),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(r)}}),Object.defineProperty(o,"name",{value:r}),o}class ti extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Om extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}}const Mm={};function Ar(r){return Mm}function Nm(r){const e=Object.values(r).filter(n=>typeof n=="number");return Object.entries(r).filter(([n,i])=>e.indexOf(+n)===-1).map(([n,i])=>i)}function Gc(r,e){return typeof e=="bigint"?e.toString():e}function mh(r){return{get value(){{const e=r();return Object.defineProperty(this,"value",{value:e}),e}}}}function vh(r){return r==null}function yh(r){const e=r.startsWith("^")?1:0,t=r.endsWith("$")?r.length-1:r.length;return r.slice(e,t)}function mA(r,e){const t=(r.toString().split(".")[1]||"").length,n=e.toString();let i=(n.split(".")[1]||"").length;if(i===0&&/\d?e-\d?/.test(n)){const c=n.match(/\d?e-(\d?)/);c!=null&&c[1]&&(i=Number.parseInt(c[1]))}const s=t>i?t:i,o=Number.parseInt(r.toFixed(s).replace(".","")),a=Number.parseInt(e.toFixed(s).replace(".",""));return o%a/10**s}const Yp=Symbol("evaluating");function ie(r,e,t){let n;Object.defineProperty(r,e,{get(){if(n!==Yp)return n===void 0&&(n=Yp,n=t()),n},set(i){Object.defineProperty(r,e,{value:i})},configurable:!0})}function An(r,e,t){Object.defineProperty(r,e,{value:t,writable:!0,enumerable:!0,configurable:!0})}function Rr(...r){const e={};for(const t of r){const n=Object.getOwnPropertyDescriptors(t);Object.assign(e,n)}return Object.defineProperties({},e)}function Xp(r){return JSON.stringify(r)}function vA(r){return r.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Um="captureStackTrace"in Error?Error.captureStackTrace:(...r)=>{};function Ca(r){return typeof r=="object"&&r!==null&&!Array.isArray(r)}const yA=mh(()=>{var r;if(typeof navigator<"u"&&((r=navigator==null?void 0:navigator.userAgent)!=null&&r.includes("Cloudflare")))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function xi(r){if(Ca(r)===!1)return!1;const e=r.constructor;if(e===void 0||typeof e!="function")return!0;const t=e.prototype;return!(Ca(t)===!1||Object.prototype.hasOwnProperty.call(t,"isPrototypeOf")===!1)}function Fm(r){return xi(r)?{...r}:Array.isArray(r)?[...r]:r}const bA=new Set(["string","number","symbol"]);function Ei(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Dr(r,e,t){const n=new r._zod.constr(e??r._zod.def);return(!e||t!=null&&t.parent)&&(n._zod.parent=r),n}function z(r){const e=r;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 wA(r){return Object.keys(r).filter(e=>r[e]._zod.optin==="optional"&&r[e]._zod.optout==="optional")}const SA={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 _A(r,e){const t=r._zod.def,n=t.checks;if(n&&n.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const s=Rr(r._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 An(this,"shape",o),o},checks:[]});return Dr(r,s)}function kA(r,e){const t=r._zod.def,n=t.checks;if(n&&n.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const s=Rr(r._zod.def,{get shape(){const o={...r._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 An(this,"shape",o),o},checks:[]});return Dr(r,s)}function xA(r,e){if(!xi(e))throw new Error("Invalid input to extend: expected a plain object");const t=r._zod.def.checks;if(t&&t.length>0){const s=r._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=Rr(r._zod.def,{get shape(){const s={...r._zod.def.shape,...e};return An(this,"shape",s),s}});return Dr(r,i)}function EA(r,e){if(!xi(e))throw new Error("Invalid input to safeExtend: expected a plain object");const t=Rr(r._zod.def,{get shape(){const n={...r._zod.def.shape,...e};return An(this,"shape",n),n}});return Dr(r,t)}function AA(r,e){const t=Rr(r._zod.def,{get shape(){const n={...r._zod.def.shape,...e._zod.def.shape};return An(this,"shape",n),n},get catchall(){return e._zod.def.catchall},checks:[]});return Dr(r,t)}function $A(r,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=Rr(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]=r?new r({type:"optional",innerType:a[u]}):a[u])}else for(const u in a)c[u]=r?new r({type:"optional",innerType:a[u]}):a[u];return An(this,"shape",c),c},checks:[]});return Dr(e,o)}function IA(r,e,t){const n=Rr(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 r({type:"nonoptional",innerType:i[o]}))}else for(const o in i)s[o]=new r({type:"nonoptional",innerType:i[o]});return An(this,"shape",s),s}});return Dr(e,n)}function Jn(r,e=0){var t;if(r.aborted===!0)return!0;for(let n=e;n<r.issues.length;n++)if(((t=r.issues[n])==null?void 0:t.continue)!==!0)return!0;return!1}function Qn(r,e){return e.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(r),t})}function Ho(r){return typeof r=="string"?r:r==null?void 0:r.message}function $r(r,e,t){var i,s,o,a,c,u;const n={...r,path:r.path??[]};if(!r.message){const h=Ho((o=(s=(i=r.inst)==null?void 0:i._zod.def)==null?void 0:s.error)==null?void 0:o.call(s,r))??Ho((a=e==null?void 0:e.error)==null?void 0:a.call(e,r))??Ho((c=t.customError)==null?void 0:c.call(t,r))??Ho((u=t.localeError)==null?void 0:u.call(t,r))??"Invalid input";n.message=h}return delete n.inst,delete n.continue,e!=null&&e.reportInput||delete n.input,n}function bh(r){return Array.isArray(r)?"array":typeof r=="string"?"string":"unknown"}function ms(...r){const[e,t,n]=r;return typeof e=="string"?{message:e,code:"custom",input:t,inst:n}:{...e}}const Wm=(r,e)=>{r.name="$ZodError",Object.defineProperty(r,"_zod",{value:r._zod,enumerable:!1}),Object.defineProperty(r,"issues",{value:e,enumerable:!1}),r.message=JSON.stringify(e,Gc,2),Object.defineProperty(r,"toString",{value:()=>r.message,enumerable:!1})},Hm=A("$ZodError",Wm),Zm=A("$ZodError",Wm,{Parent:Error});function TA(r,e=t=>t.message){const t={},n=[];for(const i of r.issues)i.path.length>0?(t[i.path[0]]=t[i.path[0]]||[],t[i.path[0]].push(e(i))):n.push(e(i));return{formErrors:n,fieldErrors:t}}function CA(r,e=t=>t.message){const t={_errors:[]},n=i=>{for(const s of i.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(o=>n({issues:o}));else if(s.code==="invalid_key")n({issues:s.issues});else if(s.code==="invalid_element")n({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 n(r),t}const wh=r=>(e,t,n,i)=>{const s=n?Object.assign(n,{async:!1}):{async:!1},o=e._zod.run({value:t,issues:[]},s);if(o instanceof Promise)throw new ti;if(o.issues.length){const a=new((i==null?void 0:i.Err)??r)(o.issues.map(c=>$r(c,s,Ar())));throw Um(a,i==null?void 0:i.callee),a}return o.value},Sh=r=>async(e,t,n,i)=>{const s=n?Object.assign(n,{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)??r)(o.issues.map(c=>$r(c,s,Ar())));throw Um(a,i==null?void 0:i.callee),a}return o.value},dl=r=>(e,t,n)=>{const i=n?{...n,async:!1}:{async:!1},s=e._zod.run({value:t,issues:[]},i);if(s instanceof Promise)throw new ti;return s.issues.length?{success:!1,error:new(r??Hm)(s.issues.map(o=>$r(o,i,Ar())))}:{success:!0,data:s.value}},PA=dl(Zm),pl=r=>async(e,t,n)=>{const i=n?Object.assign(n,{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 r(s.issues.map(o=>$r(o,i,Ar())))}:{success:!0,data:s.value}},RA=pl(Zm),DA=r=>(e,t,n)=>{const i=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return wh(r)(e,t,i)},LA=r=>(e,t,n)=>wh(r)(e,t,n),zA=r=>async(e,t,n)=>{const i=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return Sh(r)(e,t,i)},OA=r=>async(e,t,n)=>Sh(r)(e,t,n),MA=r=>(e,t,n)=>{const i=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return dl(r)(e,t,i)},NA=r=>(e,t,n)=>dl(r)(e,t,n),UA=r=>async(e,t,n)=>{const i=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return pl(r)(e,t,i)},FA=r=>async(e,t,n)=>pl(r)(e,t,n),WA=/^[cC][^\s-]{8,}$/,HA=/^[0-9a-z]+$/,ZA=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,VA=/^[0-9a-vA-V]{20}$/,BA=/^[A-Za-z0-9]{27}$/,GA=/^[a-zA-Z0-9_-]{21}$/,jA=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,qA=/^([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})$/,Kp=r=>r?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${r}[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)$/,YA=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,XA="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function KA(){return new RegExp(XA,"u")}const JA=/^(?:(?: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])$/,QA=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,e$=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,t$=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,r$=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Vm=/^[A-Za-z0-9_-]*$/,n$=/^\+[1-9]\d{6,14}$/,Bm="(?:(?:\\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])))",i$=new RegExp(`^${Bm}$`);function Gm(r){const e="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof r.precision=="number"?r.precision===-1?`${e}`:r.precision===0?`${e}:[0-5]\\d`:`${e}:[0-5]\\d\\.\\d{${r.precision}}`:`${e}(?::[0-5]\\d(?:\\.\\d+)?)?`}function s$(r){return new RegExp(`^${Gm(r)}$`)}function o$(r){const e=Gm({precision:r.precision}),t=["Z"];r.local&&t.push(""),r.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const n=`${e}(?:${t.join("|")})`;return new RegExp(`^${Bm}T(?:${n})$`)}const a$=r=>{const e=r?`[\\s\\S]{${(r==null?void 0:r.minimum)??0},${(r==null?void 0:r.maximum)??""}}`:"[\\s\\S]*";return new RegExp(`^${e}$`)},l$=/^-?\d+$/,jm=/^-?\d+(?:\.\d+)?$/,c$=/^(?:true|false)$/i,u$=/^[^A-Z]*$/,h$=/^[^a-z]*$/,et=A("$ZodCheck",(r,e)=>{var t;r._zod??(r._zod={}),r._zod.def=e,(t=r._zod).onattach??(t.onattach=[])}),qm={number:"number",bigint:"bigint",object:"date"},Ym=A("$ZodCheckLessThan",(r,e)=>{et.init(r,e);const t=qm[typeof e.value];r._zod.onattach.push(n=>{const i=n._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)}),r._zod.check=n=>{(e.inclusive?n.value<=e.value:n.value<e.value)||n.issues.push({origin:t,code:"too_big",maximum:typeof e.value=="object"?e.value.getTime():e.value,input:n.value,inclusive:e.inclusive,inst:r,continue:!e.abort})}}),Xm=A("$ZodCheckGreaterThan",(r,e)=>{et.init(r,e);const t=qm[typeof e.value];r._zod.onattach.push(n=>{const i=n._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)}),r._zod.check=n=>{(e.inclusive?n.value>=e.value:n.value>e.value)||n.issues.push({origin:t,code:"too_small",minimum:typeof e.value=="object"?e.value.getTime():e.value,input:n.value,inclusive:e.inclusive,inst:r,continue:!e.abort})}}),d$=A("$ZodCheckMultipleOf",(r,e)=>{et.init(r,e),r._zod.onattach.push(t=>{var n;(n=t._zod.bag).multipleOf??(n.multipleOf=e.value)}),r._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):mA(t.value,e.value)===0)||t.issues.push({origin:typeof t.value,code:"not_multiple_of",divisor:e.value,input:t.value,inst:r,continue:!e.abort})}}),p$=A("$ZodCheckNumberFormat",(r,e)=>{var o;et.init(r,e),e.format=e.format||"float64";const t=(o=e.format)==null?void 0:o.includes("int"),n=t?"int":"number",[i,s]=SA[e.format];r._zod.onattach.push(a=>{const c=a._zod.bag;c.format=e.format,c.minimum=i,c.maximum=s,t&&(c.pattern=l$)}),r._zod.check=a=>{const c=a.value;if(t){if(!Number.isInteger(c)){a.issues.push({expected:n,format:e.format,code:"invalid_type",continue:!1,input:c,inst:r});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:r,origin:n,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:r,origin:n,inclusive:!0,continue:!e.abort});return}}c<i&&a.issues.push({origin:"number",input:c,code:"too_small",minimum:i,inclusive:!0,inst:r,continue:!e.abort}),c>s&&a.issues.push({origin:"number",input:c,code:"too_big",maximum:s,inclusive:!0,inst:r,continue:!e.abort})}}),f$=A("$ZodCheckMaxLength",(r,e)=>{var t;et.init(r,e),(t=r._zod.def).when??(t.when=n=>{const i=n.value;return!vh(i)&&i.length!==void 0}),r._zod.onattach.push(n=>{const i=n._zod.bag.maximum??Number.POSITIVE_INFINITY;e.maximum<i&&(n._zod.bag.maximum=e.maximum)}),r._zod.check=n=>{const i=n.value;if(i.length<=e.maximum)return;const o=bh(i);n.issues.push({origin:o,code:"too_big",maximum:e.maximum,inclusive:!0,input:i,inst:r,continue:!e.abort})}}),g$=A("$ZodCheckMinLength",(r,e)=>{var t;et.init(r,e),(t=r._zod.def).when??(t.when=n=>{const i=n.value;return!vh(i)&&i.length!==void 0}),r._zod.onattach.push(n=>{const i=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;e.minimum>i&&(n._zod.bag.minimum=e.minimum)}),r._zod.check=n=>{const i=n.value;if(i.length>=e.minimum)return;const o=bh(i);n.issues.push({origin:o,code:"too_small",minimum:e.minimum,inclusive:!0,input:i,inst:r,continue:!e.abort})}}),m$=A("$ZodCheckLengthEquals",(r,e)=>{var t;et.init(r,e),(t=r._zod.def).when??(t.when=n=>{const i=n.value;return!vh(i)&&i.length!==void 0}),r._zod.onattach.push(n=>{const i=n._zod.bag;i.minimum=e.length,i.maximum=e.length,i.length=e.length}),r._zod.check=n=>{const i=n.value,s=i.length;if(s===e.length)return;const o=bh(i),a=s>e.length;n.issues.push({origin:o,...a?{code:"too_big",maximum:e.length}:{code:"too_small",minimum:e.length},inclusive:!0,exact:!0,input:n.value,inst:r,continue:!e.abort})}}),fl=A("$ZodCheckStringFormat",(r,e)=>{var t,n;et.init(r,e),r._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=r._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:r,continue:!e.abort})}):(n=r._zod).check??(n.check=()=>{})}),v$=A("$ZodCheckRegex",(r,e)=>{fl.init(r,e),r._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:r,continue:!e.abort})}}),y$=A("$ZodCheckLowerCase",(r,e)=>{e.pattern??(e.pattern=u$),fl.init(r,e)}),b$=A("$ZodCheckUpperCase",(r,e)=>{e.pattern??(e.pattern=h$),fl.init(r,e)}),w$=A("$ZodCheckIncludes",(r,e)=>{et.init(r,e);const t=Ei(e.includes),n=new RegExp(typeof e.position=="number"?`^.{${e.position}}${t}`:t);e.pattern=n,r._zod.onattach.push(i=>{const s=i._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(n)}),r._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:r,continue:!e.abort})}}),S$=A("$ZodCheckStartsWith",(r,e)=>{et.init(r,e);const t=new RegExp(`^${Ei(e.prefix)}.*`);e.pattern??(e.pattern=t),r._zod.onattach.push(n=>{const i=n._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(t)}),r._zod.check=n=>{n.value.startsWith(e.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:e.prefix,input:n.value,inst:r,continue:!e.abort})}}),_$=A("$ZodCheckEndsWith",(r,e)=>{et.init(r,e);const t=new RegExp(`.*${Ei(e.suffix)}$`);e.pattern??(e.pattern=t),r._zod.onattach.push(n=>{const i=n._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(t)}),r._zod.check=n=>{n.value.endsWith(e.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:e.suffix,input:n.value,inst:r,continue:!e.abort})}}),k$=A("$ZodCheckOverwrite",(r,e)=>{et.init(r,e),r._zod.check=t=>{t.value=e.tx(t.value)}});class x${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 n=e.split(`
5
- `).filter(o=>o),i=Math.min(...n.map(o=>o.length-o.trimStart().length)),s=n.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 E$={major:4,minor:3,patch:6},fe=A("$ZodType",(r,e)=>{var i;var t;r??(r={}),r._zod.def=e,r._zod.bag=r._zod.bag||{},r._zod.version=E$;const n=[...r._zod.def.checks??[]];r._zod.traits.has("$ZodCheck")&&n.unshift(r);for(const s of n)for(const o of s._zod.onattach)o(r);if(n.length===0)(t=r._zod).deferred??(t.deferred=[]),(i=r._zod.deferred)==null||i.push(()=>{r._zod.run=r._zod.parse});else{const s=(a,c,u)=>{let h=Jn(a),p;for(const v of c){if(v._zod.def.when){if(!v._zod.def.when(a))continue}else if(h)continue;const m=a.issues.length,E=v._zod.check(a);if(E instanceof Promise&&(u==null?void 0:u.async)===!1)throw new ti;if(p||E instanceof Promise)p=(p??Promise.resolve()).then(async()=>{await E,a.issues.length!==m&&(h||(h=Jn(a,m)))});else{if(a.issues.length===m)continue;h||(h=Jn(a,m))}}return p?p.then(()=>a):a},o=(a,c,u)=>{if(Jn(a))return a.aborted=!0,a;const h=s(c,n,u);if(h instanceof Promise){if(u.async===!1)throw new ti;return h.then(p=>r._zod.parse(p,u))}return r._zod.parse(h,u)};r._zod.run=(a,c)=>{if(c.skipChecks)return r._zod.parse(a,c);if(c.direction==="backward"){const h=r._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=r._zod.parse(a,c);if(u instanceof Promise){if(c.async===!1)throw new ti;return u.then(h=>s(h,n,c))}return s(u,n,c)}}ie(r,"~standard",()=>({validate:s=>{var o;try{const a=PA(r,s);return a.success?{value:a.data}:{issues:(o=a.error)==null?void 0:o.issues}}catch{return RA(r,s).then(c=>{var u;return c.success?{value:c.data}:{issues:(u=c.error)==null?void 0:u.issues}})}},vendor:"zod",version:1}))}),_h=A("$ZodString",(r,e)=>{var t;fe.init(r,e),r._zod.pattern=[...((t=r==null?void 0:r._zod.bag)==null?void 0:t.patterns)??[]].pop()??a$(r._zod.bag),r._zod.parse=(n,i)=>{if(e.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:r}),n}}),de=A("$ZodStringFormat",(r,e)=>{fl.init(r,e),_h.init(r,e)}),A$=A("$ZodGUID",(r,e)=>{e.pattern??(e.pattern=qA),de.init(r,e)}),$$=A("$ZodUUID",(r,e)=>{if(e.version){const n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[e.version];if(n===void 0)throw new Error(`Invalid UUID version: "${e.version}"`);e.pattern??(e.pattern=Kp(n))}else e.pattern??(e.pattern=Kp());de.init(r,e)}),I$=A("$ZodEmail",(r,e)=>{e.pattern??(e.pattern=YA),de.init(r,e)}),T$=A("$ZodURL",(r,e)=>{de.init(r,e),r._zod.check=t=>{try{const n=t.value.trim(),i=new URL(n);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:r,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:r,continue:!e.abort})),e.normalize?t.value=i.href:t.value=n;return}catch{t.issues.push({code:"invalid_format",format:"url",input:t.value,inst:r,continue:!e.abort})}}}),C$=A("$ZodEmoji",(r,e)=>{e.pattern??(e.pattern=KA()),de.init(r,e)}),P$=A("$ZodNanoID",(r,e)=>{e.pattern??(e.pattern=GA),de.init(r,e)}),R$=A("$ZodCUID",(r,e)=>{e.pattern??(e.pattern=WA),de.init(r,e)}),D$=A("$ZodCUID2",(r,e)=>{e.pattern??(e.pattern=HA),de.init(r,e)}),L$=A("$ZodULID",(r,e)=>{e.pattern??(e.pattern=ZA),de.init(r,e)}),z$=A("$ZodXID",(r,e)=>{e.pattern??(e.pattern=VA),de.init(r,e)}),O$=A("$ZodKSUID",(r,e)=>{e.pattern??(e.pattern=BA),de.init(r,e)}),M$=A("$ZodISODateTime",(r,e)=>{e.pattern??(e.pattern=o$(e)),de.init(r,e)}),N$=A("$ZodISODate",(r,e)=>{e.pattern??(e.pattern=i$),de.init(r,e)}),U$=A("$ZodISOTime",(r,e)=>{e.pattern??(e.pattern=s$(e)),de.init(r,e)}),F$=A("$ZodISODuration",(r,e)=>{e.pattern??(e.pattern=jA),de.init(r,e)}),W$=A("$ZodIPv4",(r,e)=>{e.pattern??(e.pattern=JA),de.init(r,e),r._zod.bag.format="ipv4"}),H$=A("$ZodIPv6",(r,e)=>{e.pattern??(e.pattern=QA),de.init(r,e),r._zod.bag.format="ipv6",r._zod.check=t=>{try{new URL(`http://[${t.value}]`)}catch{t.issues.push({code:"invalid_format",format:"ipv6",input:t.value,inst:r,continue:!e.abort})}}}),Z$=A("$ZodCIDRv4",(r,e)=>{e.pattern??(e.pattern=e$),de.init(r,e)}),V$=A("$ZodCIDRv6",(r,e)=>{e.pattern??(e.pattern=t$),de.init(r,e),r._zod.check=t=>{const n=t.value.split("/");try{if(n.length!==2)throw new Error;const[i,s]=n;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:r,continue:!e.abort})}}});function Km(r){if(r==="")return!0;if(r.length%4!==0)return!1;try{return atob(r),!0}catch{return!1}}const B$=A("$ZodBase64",(r,e)=>{e.pattern??(e.pattern=r$),de.init(r,e),r._zod.bag.contentEncoding="base64",r._zod.check=t=>{Km(t.value)||t.issues.push({code:"invalid_format",format:"base64",input:t.value,inst:r,continue:!e.abort})}});function G$(r){if(!Vm.test(r))return!1;const e=r.replace(/[-_]/g,n=>n==="-"?"+":"/"),t=e.padEnd(Math.ceil(e.length/4)*4,"=");return Km(t)}const j$=A("$ZodBase64URL",(r,e)=>{e.pattern??(e.pattern=Vm),de.init(r,e),r._zod.bag.contentEncoding="base64url",r._zod.check=t=>{G$(t.value)||t.issues.push({code:"invalid_format",format:"base64url",input:t.value,inst:r,continue:!e.abort})}}),q$=A("$ZodE164",(r,e)=>{e.pattern??(e.pattern=n$),de.init(r,e)});function Y$(r,e=null){try{const t=r.split(".");if(t.length!==3)return!1;const[n]=t;if(!n)return!1;const i=JSON.parse(atob(n));return!("typ"in i&&(i==null?void 0:i.typ)!=="JWT"||!i.alg||e&&(!("alg"in i)||i.alg!==e))}catch{return!1}}const X$=A("$ZodJWT",(r,e)=>{de.init(r,e),r._zod.check=t=>{Y$(t.value,e.alg)||t.issues.push({code:"invalid_format",format:"jwt",input:t.value,inst:r,continue:!e.abort})}}),Jm=A("$ZodNumber",(r,e)=>{fe.init(r,e),r._zod.pattern=r._zod.bag.pattern??jm,r._zod.parse=(t,n)=>{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:r,...s?{received:s}:{}}),t}}),K$=A("$ZodNumberFormat",(r,e)=>{p$.init(r,e),Jm.init(r,e)}),J$=A("$ZodBoolean",(r,e)=>{fe.init(r,e),r._zod.pattern=c$,r._zod.parse=(t,n)=>{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:r}),t}}),Q$=A("$ZodUnknown",(r,e)=>{fe.init(r,e),r._zod.parse=t=>t}),eI=A("$ZodNever",(r,e)=>{fe.init(r,e),r._zod.parse=(t,n)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:r}),t)});function Jp(r,e,t){r.issues.length&&e.issues.push(...Qn(t,r.issues)),e.value[t]=r.value}const tI=A("$ZodArray",(r,e)=>{fe.init(r,e),r._zod.parse=(t,n)=>{const i=t.value;if(!Array.isArray(i))return t.issues.push({expected:"array",code:"invalid_type",input:i,inst:r}),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:[]},n);c instanceof Promise?s.push(c.then(u=>Jp(u,t,o))):Jp(c,t,o)}return s.length?Promise.all(s).then(()=>t):t}});function Pa(r,e,t,n,i){if(r.issues.length){if(i&&!(t in n))return;e.issues.push(...Qn(t,r.issues))}r.value===void 0?t in n&&(e.value[t]=void 0):e.value[t]=r.value}function Qm(r){var n,i,s,o;const e=Object.keys(r.shape);for(const a of e)if(!((o=(s=(i=(n=r.shape)==null?void 0:n[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=wA(r.shape);return{...r,keys:e,keySet:new Set(e),numKeys:e.length,optionalKeys:new Set(t)}}function ev(r,e,t,n,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:[]},n);v instanceof Promise?r.push(v.then(m=>Pa(m,t,p,e,h))):Pa(v,t,p,e,h)}return o.length&&t.issues.push({code:"unrecognized_keys",keys:o,input:e,inst:s}),r.length?Promise.all(r).then(()=>t):t}const rI=A("$ZodObject",(r,e)=>{fe.init(r,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 n=mh(()=>Qm(e));ie(r._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=Ca,s=e.catchall;let o;r._zod.parse=(a,c)=>{o??(o=n.value);const u=a.value;if(!i(u))return a.issues.push({expected:"object",code:"invalid_type",input:u,inst:r}),a;a.value={};const h=[],p=o.shape;for(const v of o.keys){const m=p[v],E=m._zod.optout==="optional",x=m._zod.run({value:u[v],issues:[]},c);x instanceof Promise?h.push(x.then(T=>Pa(T,a,v,u,E))):Pa(x,a,v,u,E)}return s?ev(h,u,a,c,n.value,r):h.length?Promise.all(h).then(()=>a):a}}),nI=A("$ZodObjectJIT",(r,e)=>{rI.init(r,e);const t=r._zod.parse,n=mh(()=>Qm(e)),i=v=>{var Z;const m=new x$(["shape","payload","ctx"]),E=n.value,x=F=>{const B=Xp(F);return`shape[${B}]._zod.run({ value: input[${B}], issues: [] }, ctx)`};m.write("const input = payload.value;");const T=Object.create(null);let O=0;for(const F of E.keys)T[F]=`key_${O++}`;m.write("const newResult = {};");for(const F of E.keys){const B=T[F],N=Xp(F),J=v[F],j=((Z=J==null?void 0:J._zod)==null?void 0:Z.optout)==="optional";m.write(`const ${B} = ${x(F)};`),j?m.write(`
7
- if (${B}.issues.length) {
8
- if (${N} in input) {
9
- payload.issues = payload.issues.concat(${B}.issues.map(iss => ({
10
- ...iss,
11
- path: iss.path ? [${N}, ...iss.path] : [${N}]
12
- })));
13
- }
14
- }
15
-
16
- if (${B}.value === undefined) {
17
- if (${N} in input) {
18
- newResult[${N}] = undefined;
19
- }
20
- } else {
21
- newResult[${N}] = ${B}.value;
22
- }
23
-
24
- `):m.write(`
25
- if (${B}.issues.length) {
26
- payload.issues = payload.issues.concat(${B}.issues.map(iss => ({
27
- ...iss,
28
- path: iss.path ? [${N}, ...iss.path] : [${N}]
29
- })));
30
- }
31
-
32
- if (${B}.value === undefined) {
33
- if (${N} in input) {
34
- newResult[${N}] = undefined;
35
- }
36
- } else {
37
- newResult[${N}] = ${B}.value;
38
- }
39
-
40
- `)}m.write("payload.value = newResult;"),m.write("return payload;");const P=m.compile();return(F,B)=>P(v,F,B)};let s;const o=Ca,a=!Mm.jitless,u=a&&yA.value,h=e.catchall;let p;r._zod.parse=(v,m)=>{p??(p=n.value);const E=v.value;return o(E)?a&&u&&(m==null?void 0:m.async)===!1&&m.jitless!==!0?(s||(s=i(e.shape)),v=s(v,m),h?ev([],E,v,m,p,r):v):t(v,m):(v.issues.push({expected:"object",code:"invalid_type",input:E,inst:r}),v)}});function Qp(r,e,t,n){for(const s of r)if(s.issues.length===0)return e.value=s.value,e;const i=r.filter(s=>!Jn(s));return i.length===1?(e.value=i[0].value,i[0]):(e.issues.push({code:"invalid_union",input:e.value,inst:t,errors:r.map(s=>s.issues.map(o=>$r(o,n,Ar())))}),e)}const iI=A("$ZodUnion",(r,e)=>{fe.init(r,e),ie(r._zod,"optin",()=>e.options.some(i=>i._zod.optin==="optional")?"optional":void 0),ie(r._zod,"optout",()=>e.options.some(i=>i._zod.optout==="optional")?"optional":void 0),ie(r._zod,"values",()=>{if(e.options.every(i=>i._zod.values))return new Set(e.options.flatMap(i=>Array.from(i._zod.values)))}),ie(r._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=>yh(s.source)).join("|")})$`)}});const t=e.options.length===1,n=e.options[0]._zod.run;r._zod.parse=(i,s)=>{if(t)return n(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=>Qp(c,i,r,s)):Qp(a,i,r,s)}}),sI=A("$ZodIntersection",(r,e)=>{fe.init(r,e),r._zod.parse=(t,n)=>{const i=t.value,s=e.left._zod.run({value:i,issues:[]},n),o=e.right._zod.run({value:i,issues:[]},n);return s instanceof Promise||o instanceof Promise?Promise.all([s,o]).then(([c,u])=>ef(t,c,u)):ef(t,s,o)}});function jc(r,e){if(r===e)return{valid:!0,data:r};if(r instanceof Date&&e instanceof Date&&+r==+e)return{valid:!0,data:r};if(xi(r)&&xi(e)){const t=Object.keys(e),n=Object.keys(r).filter(s=>t.indexOf(s)!==-1),i={...r,...e};for(const s of n){const o=jc(r[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(r)&&Array.isArray(e)){if(r.length!==e.length)return{valid:!1,mergeErrorPath:[]};const t=[];for(let n=0;n<r.length;n++){const i=r[n],s=e[n],o=jc(i,s);if(!o.valid)return{valid:!1,mergeErrorPath:[n,...o.mergeErrorPath]};t.push(o.data)}return{valid:!0,data:t}}return{valid:!1,mergeErrorPath:[]}}function ef(r,e,t){const n=new Map;let i;for(const a of e.issues)if(a.code==="unrecognized_keys"){i??(i=a);for(const c of a.keys)n.has(c)||n.set(c,{}),n.get(c).l=!0}else r.issues.push(a);for(const a of t.issues)if(a.code==="unrecognized_keys")for(const c of a.keys)n.has(c)||n.set(c,{}),n.get(c).r=!0;else r.issues.push(a);const s=[...n].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(s.length&&i&&r.issues.push({...i,keys:s}),Jn(r))return r;const o=jc(e.value,t.value);if(!o.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return r.value=o.data,r}const oI=A("$ZodRecord",(r,e)=>{fe.init(r,e),r._zod.parse=(t,n)=>{const i=t.value;if(!xi(i))return t.issues.push({expected:"record",code:"invalid_type",input:i,inst:r}),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:[]},n);h instanceof Promise?s.push(h.then(p=>{p.issues.length&&t.issues.push(...Qn(u,p.issues)),t.value[u]=p.value})):(h.issues.length&&t.issues.push(...Qn(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:r,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:[]},n);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof a=="string"&&jm.test(a)&&c.issues.length){const p=e.keyType._zod.run({value:Number(a),issues:[]},n);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=>$r(p,n,Ar())),input:a,path:[a],inst:r});continue}const h=e.valueType._zod.run({value:i[a],issues:[]},n);h instanceof Promise?s.push(h.then(p=>{p.issues.length&&t.issues.push(...Qn(a,p.issues)),t.value[c.value]=p.value})):(h.issues.length&&t.issues.push(...Qn(a,h.issues)),t.value[c.value]=h.value)}}return s.length?Promise.all(s).then(()=>t):t}}),aI=A("$ZodEnum",(r,e)=>{fe.init(r,e);const t=Nm(e.entries),n=new Set(t);r._zod.values=n,r._zod.pattern=new RegExp(`^(${t.filter(i=>bA.has(typeof i)).map(i=>typeof i=="string"?Ei(i):i.toString()).join("|")})$`),r._zod.parse=(i,s)=>{const o=i.value;return n.has(o)||i.issues.push({code:"invalid_value",values:t,input:o,inst:r}),i}}),lI=A("$ZodLiteral",(r,e)=>{if(fe.init(r,e),e.values.length===0)throw new Error("Cannot create literal schema with no valid values");const t=new Set(e.values);r._zod.values=t,r._zod.pattern=new RegExp(`^(${e.values.map(n=>typeof n=="string"?Ei(n):n?Ei(n.toString()):String(n)).join("|")})$`),r._zod.parse=(n,i)=>{const s=n.value;return t.has(s)||n.issues.push({code:"invalid_value",values:e.values,input:s,inst:r}),n}}),cI=A("$ZodTransform",(r,e)=>{fe.init(r,e),r._zod.parse=(t,n)=>{if(n.direction==="backward")throw new Om(r.constructor.name);const i=e.transform(t.value,t);if(n.async)return(i instanceof Promise?i:Promise.resolve(i)).then(o=>(t.value=o,t));if(i instanceof Promise)throw new ti;return t.value=i,t}});function tf(r,e){return r.issues.length&&e===void 0?{issues:[],value:void 0}:r}const tv=A("$ZodOptional",(r,e)=>{fe.init(r,e),r._zod.optin="optional",r._zod.optout="optional",ie(r._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,void 0]):void 0),ie(r._zod,"pattern",()=>{const t=e.innerType._zod.pattern;return t?new RegExp(`^(${yh(t.source)})?$`):void 0}),r._zod.parse=(t,n)=>{if(e.innerType._zod.optin==="optional"){const i=e.innerType._zod.run(t,n);return i instanceof Promise?i.then(s=>tf(s,t.value)):tf(i,t.value)}return t.value===void 0?t:e.innerType._zod.run(t,n)}}),uI=A("$ZodExactOptional",(r,e)=>{tv.init(r,e),ie(r._zod,"values",()=>e.innerType._zod.values),ie(r._zod,"pattern",()=>e.innerType._zod.pattern),r._zod.parse=(t,n)=>e.innerType._zod.run(t,n)}),hI=A("$ZodNullable",(r,e)=>{fe.init(r,e),ie(r._zod,"optin",()=>e.innerType._zod.optin),ie(r._zod,"optout",()=>e.innerType._zod.optout),ie(r._zod,"pattern",()=>{const t=e.innerType._zod.pattern;return t?new RegExp(`^(${yh(t.source)}|null)$`):void 0}),ie(r._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,null]):void 0),r._zod.parse=(t,n)=>t.value===null?t:e.innerType._zod.run(t,n)}),dI=A("$ZodDefault",(r,e)=>{fe.init(r,e),r._zod.optin="optional",ie(r._zod,"values",()=>e.innerType._zod.values),r._zod.parse=(t,n)=>{if(n.direction==="backward")return e.innerType._zod.run(t,n);if(t.value===void 0)return t.value=e.defaultValue,t;const i=e.innerType._zod.run(t,n);return i instanceof Promise?i.then(s=>rf(s,e)):rf(i,e)}});function rf(r,e){return r.value===void 0&&(r.value=e.defaultValue),r}const pI=A("$ZodPrefault",(r,e)=>{fe.init(r,e),r._zod.optin="optional",ie(r._zod,"values",()=>e.innerType._zod.values),r._zod.parse=(t,n)=>(n.direction==="backward"||t.value===void 0&&(t.value=e.defaultValue),e.innerType._zod.run(t,n))}),fI=A("$ZodNonOptional",(r,e)=>{fe.init(r,e),ie(r._zod,"values",()=>{const t=e.innerType._zod.values;return t?new Set([...t].filter(n=>n!==void 0)):void 0}),r._zod.parse=(t,n)=>{const i=e.innerType._zod.run(t,n);return i instanceof Promise?i.then(s=>nf(s,r)):nf(i,r)}});function nf(r,e){return!r.issues.length&&r.value===void 0&&r.issues.push({code:"invalid_type",expected:"nonoptional",input:r.value,inst:e}),r}const gI=A("$ZodCatch",(r,e)=>{fe.init(r,e),ie(r._zod,"optin",()=>e.innerType._zod.optin),ie(r._zod,"optout",()=>e.innerType._zod.optout),ie(r._zod,"values",()=>e.innerType._zod.values),r._zod.parse=(t,n)=>{if(n.direction==="backward")return e.innerType._zod.run(t,n);const i=e.innerType._zod.run(t,n);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=>$r(o,n,Ar()))},input:t.value}),t.issues=[]),t)):(t.value=i.value,i.issues.length&&(t.value=e.catchValue({...t,error:{issues:i.issues.map(s=>$r(s,n,Ar()))},input:t.value}),t.issues=[]),t)}}),mI=A("$ZodPipe",(r,e)=>{fe.init(r,e),ie(r._zod,"values",()=>e.in._zod.values),ie(r._zod,"optin",()=>e.in._zod.optin),ie(r._zod,"optout",()=>e.out._zod.optout),ie(r._zod,"propValues",()=>e.in._zod.propValues),r._zod.parse=(t,n)=>{if(n.direction==="backward"){const s=e.out._zod.run(t,n);return s instanceof Promise?s.then(o=>Zo(o,e.in,n)):Zo(s,e.in,n)}const i=e.in._zod.run(t,n);return i instanceof Promise?i.then(s=>Zo(s,e.out,n)):Zo(i,e.out,n)}});function Zo(r,e,t){return r.issues.length?(r.aborted=!0,r):e._zod.run({value:r.value,issues:r.issues},t)}const vI=A("$ZodReadonly",(r,e)=>{fe.init(r,e),ie(r._zod,"propValues",()=>e.innerType._zod.propValues),ie(r._zod,"values",()=>e.innerType._zod.values),ie(r._zod,"optin",()=>{var t,n;return(n=(t=e.innerType)==null?void 0:t._zod)==null?void 0:n.optin}),ie(r._zod,"optout",()=>{var t,n;return(n=(t=e.innerType)==null?void 0:t._zod)==null?void 0:n.optout}),r._zod.parse=(t,n)=>{if(n.direction==="backward")return e.innerType._zod.run(t,n);const i=e.innerType._zod.run(t,n);return i instanceof Promise?i.then(sf):sf(i)}});function sf(r){return r.value=Object.freeze(r.value),r}const yI=A("$ZodCustom",(r,e)=>{et.init(r,e),fe.init(r,e),r._zod.parse=(t,n)=>t,r._zod.check=t=>{const n=t.value,i=e.fn(n);if(i instanceof Promise)return i.then(s=>of(s,t,n,r));of(i,t,n,r)}});function of(r,e,t,n){if(!r){const i={code:"custom",input:t,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(i.params=n._zod.def.params),e.issues.push(ms(i))}}var af;class bI{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){const n=t[0];return this._map.set(e,n),n&&typeof n=="object"&&"id"in n&&this._idmap.set(n.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 n={...this.get(t)??{}};delete n.id;const i={...n,...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 wI(){return new bI}(af=globalThis).__zod_globalRegistry??(af.__zod_globalRegistry=wI());const ts=globalThis.__zod_globalRegistry;function SI(r,e){return new r({type:"string",...z(e)})}function _I(r,e){return new r({type:"string",format:"email",check:"string_format",abort:!1,...z(e)})}function lf(r,e){return new r({type:"string",format:"guid",check:"string_format",abort:!1,...z(e)})}function kI(r,e){return new r({type:"string",format:"uuid",check:"string_format",abort:!1,...z(e)})}function xI(r,e){return new r({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...z(e)})}function EI(r,e){return new r({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...z(e)})}function AI(r,e){return new r({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...z(e)})}function $I(r,e){return new r({type:"string",format:"url",check:"string_format",abort:!1,...z(e)})}function II(r,e){return new r({type:"string",format:"emoji",check:"string_format",abort:!1,...z(e)})}function TI(r,e){return new r({type:"string",format:"nanoid",check:"string_format",abort:!1,...z(e)})}function CI(r,e){return new r({type:"string",format:"cuid",check:"string_format",abort:!1,...z(e)})}function PI(r,e){return new r({type:"string",format:"cuid2",check:"string_format",abort:!1,...z(e)})}function RI(r,e){return new r({type:"string",format:"ulid",check:"string_format",abort:!1,...z(e)})}function DI(r,e){return new r({type:"string",format:"xid",check:"string_format",abort:!1,...z(e)})}function LI(r,e){return new r({type:"string",format:"ksuid",check:"string_format",abort:!1,...z(e)})}function zI(r,e){return new r({type:"string",format:"ipv4",check:"string_format",abort:!1,...z(e)})}function OI(r,e){return new r({type:"string",format:"ipv6",check:"string_format",abort:!1,...z(e)})}function MI(r,e){return new r({type:"string",format:"cidrv4",check:"string_format",abort:!1,...z(e)})}function NI(r,e){return new r({type:"string",format:"cidrv6",check:"string_format",abort:!1,...z(e)})}function UI(r,e){return new r({type:"string",format:"base64",check:"string_format",abort:!1,...z(e)})}function FI(r,e){return new r({type:"string",format:"base64url",check:"string_format",abort:!1,...z(e)})}function WI(r,e){return new r({type:"string",format:"e164",check:"string_format",abort:!1,...z(e)})}function HI(r,e){return new r({type:"string",format:"jwt",check:"string_format",abort:!1,...z(e)})}function ZI(r,e){return new r({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...z(e)})}function VI(r,e){return new r({type:"string",format:"date",check:"string_format",...z(e)})}function BI(r,e){return new r({type:"string",format:"time",check:"string_format",precision:null,...z(e)})}function GI(r,e){return new r({type:"string",format:"duration",check:"string_format",...z(e)})}function jI(r,e){return new r({type:"number",checks:[],...z(e)})}function qI(r,e){return new r({type:"number",check:"number_format",abort:!1,format:"safeint",...z(e)})}function YI(r,e){return new r({type:"boolean",...z(e)})}function XI(r){return new r({type:"unknown"})}function KI(r,e){return new r({type:"never",...z(e)})}function cf(r,e){return new Ym({check:"less_than",...z(e),value:r,inclusive:!1})}function uc(r,e){return new Ym({check:"less_than",...z(e),value:r,inclusive:!0})}function uf(r,e){return new Xm({check:"greater_than",...z(e),value:r,inclusive:!1})}function hc(r,e){return new Xm({check:"greater_than",...z(e),value:r,inclusive:!0})}function hf(r,e){return new d$({check:"multiple_of",...z(e),value:r})}function rv(r,e){return new f$({check:"max_length",...z(e),maximum:r})}function Ra(r,e){return new g$({check:"min_length",...z(e),minimum:r})}function nv(r,e){return new m$({check:"length_equals",...z(e),length:r})}function JI(r,e){return new v$({check:"string_format",format:"regex",...z(e),pattern:r})}function QI(r){return new y$({check:"string_format",format:"lowercase",...z(r)})}function eT(r){return new b$({check:"string_format",format:"uppercase",...z(r)})}function tT(r,e){return new w$({check:"string_format",format:"includes",...z(e),includes:r})}function rT(r,e){return new S$({check:"string_format",format:"starts_with",...z(e),prefix:r})}function nT(r,e){return new _$({check:"string_format",format:"ends_with",...z(e),suffix:r})}function Oi(r){return new k$({check:"overwrite",tx:r})}function iT(r){return Oi(e=>e.normalize(r))}function sT(){return Oi(r=>r.trim())}function oT(){return Oi(r=>r.toLowerCase())}function aT(){return Oi(r=>r.toUpperCase())}function lT(){return Oi(r=>vA(r))}function cT(r,e,t){return new r({type:"array",element:e,...z(t)})}function uT(r,e,t){return new r({type:"custom",check:"custom",fn:e,...z(t)})}function hT(r){const e=dT(t=>(t.addIssue=n=>{if(typeof n=="string")t.issues.push(ms(n,t.value,e._zod.def));else{const i=n;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(ms(i))}},r(t.value,t)));return e}function dT(r,e){const t=new et({check:"custom",...z(e)});return t._zod.check=r,t}function iv(r){let e=(r==null?void 0:r.target)??"draft-2020-12";return e==="draft-4"&&(e="draft-04"),e==="draft-7"&&(e="draft-07"),{processors:r.processors??{},metadataRegistry:(r==null?void 0:r.metadata)??ts,target:e,unrepresentable:(r==null?void 0:r.unrepresentable)??"throw",override:(r==null?void 0:r.override)??(()=>{}),io:(r==null?void 0:r.io)??"output",counter:0,seen:new Map,cycles:(r==null?void 0:r.cycles)??"ref",reused:(r==null?void 0:r.reused)??"inline",external:(r==null?void 0:r.external)??void 0}}function Se(r,e,t={path:[],schemaPath:[]}){var h,p;var n;const i=r._zod.def,s=e.seen.get(r);if(s)return s.count++,t.schemaPath.includes(r)&&(s.cycle=t.path),s.schema;const o={schema:{},count:1,cycle:void 0,path:t.path};e.seen.set(r,o);const a=(p=(h=r._zod).toJSONSchema)==null?void 0:p.call(h);if(a)o.schema=a;else{const v={...t,schemaPath:[...t.schemaPath,r],path:t.path};if(r._zod.processJSONSchema)r._zod.processJSONSchema(e,o.schema,v);else{const E=o.schema,x=e.processors[i.type];if(!x)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);x(r,e,E,v)}const m=r._zod.parent;m&&(o.ref||(o.ref=m),Se(m,e,v),e.seen.get(m).isParent=!0)}const c=e.metadataRegistry.get(r);return c&&Object.assign(o.schema,c),e.io==="input"&&Ue(r)&&(delete o.schema.examples,delete o.schema.default),e.io==="input"&&o.schema._prefault&&((n=o.schema).default??(n.default=o.schema._prefault)),delete o.schema._prefault,e.seen.get(r).schema}function sv(r,e){var o,a,c,u;const t=r.seen.get(e);if(!t)throw new Error("Unprocessed schema. This is a bug in Zod.");const n=new Map;for(const h of r.seen.entries()){const p=(o=r.metadataRegistry.get(h[0]))==null?void 0:o.id;if(p){const v=n.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.`);n.set(p,h[0])}}const i=h=>{var x;const p=r.target==="draft-2020-12"?"$defs":"definitions";if(r.external){const T=(x=r.external.registry.get(h[0]))==null?void 0:x.id,O=r.external.uri??(Z=>Z);if(T)return{ref:O(T)};const P=h[1].defId??h[1].schema.id??`schema${r.counter++}`;return h[1].defId=P,{defId:P,ref:`${O("__shared")}#/${p}/${P}`}}if(h[1]===t)return{ref:"#"};const m=`#/${p}/`,E=h[1].schema.id??`__schema${r.counter++}`;return{defId:E,ref:m+E}},s=h=>{if(h[1].schema.$ref)return;const p=h[1],{ref:v,defId:m}=i(h);p.def={...p.schema},m&&(p.defId=m);const E=p.schema;for(const x in E)delete E[x];E.$ref=v};if(r.cycles==="throw")for(const h of r.seen.entries()){const p=h[1];if(p.cycle)throw new Error(`Cycle detected: #/${(a=p.cycle)==null?void 0:a.join("/")}/<root>
41
-
42
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const h of r.seen.entries()){const p=h[1];if(e===h[0]){s(h);continue}if(r.external){const m=(c=r.external.registry.get(h[0]))==null?void 0:c.id;if(e!==h[0]&&m){s(h);continue}}if((u=r.metadataRegistry.get(h[0]))==null?void 0:u.id){s(h);continue}if(p.cycle){s(h);continue}if(p.count>1&&r.reused==="ref"){s(h);continue}}}function ov(r,e){var o,a,c;const t=r.seen.get(e);if(!t)throw new Error("Unprocessed schema. This is a bug in Zod.");const n=u=>{const h=r.seen.get(u);if(h.ref===null)return;const p=h.def??h.schema,v={...p},m=h.ref;if(h.ref=null,m){n(m);const x=r.seen.get(m),T=x.schema;if(T.$ref&&(r.target==="draft-07"||r.target==="draft-04"||r.target==="openapi-3.0")?(p.allOf=p.allOf??[],p.allOf.push(T)):Object.assign(p,T),Object.assign(p,v),u._zod.parent===m)for(const P in p)P==="$ref"||P==="allOf"||P in v||delete p[P];if(T.$ref&&x.def)for(const P in p)P==="$ref"||P==="allOf"||P in x.def&&JSON.stringify(p[P])===JSON.stringify(x.def[P])&&delete p[P]}const E=u._zod.parent;if(E&&E!==m){n(E);const x=r.seen.get(E);if(x!=null&&x.schema.$ref&&(p.$ref=x.schema.$ref,x.def))for(const T in p)T==="$ref"||T==="allOf"||T in x.def&&JSON.stringify(p[T])===JSON.stringify(x.def[T])&&delete p[T]}r.override({zodSchema:u,jsonSchema:p,path:h.path??[]})};for(const u of[...r.seen.entries()].reverse())n(u[0]);const i={};if(r.target==="draft-2020-12"?i.$schema="https://json-schema.org/draft/2020-12/schema":r.target==="draft-07"?i.$schema="http://json-schema.org/draft-07/schema#":r.target==="draft-04"?i.$schema="http://json-schema.org/draft-04/schema#":r.target,(o=r.external)!=null&&o.uri){const u=(a=r.external.registry.get(e))==null?void 0:a.id;if(!u)throw new Error("Schema is missing an `id` property");i.$id=r.external.uri(u)}Object.assign(i,t.def??t.schema);const s=((c=r.external)==null?void 0:c.defs)??{};for(const u of r.seen.entries()){const h=u[1];h.def&&h.defId&&(s[h.defId]=h.def)}r.external||Object.keys(s).length>0&&(r.target==="draft-2020-12"?i.$defs=s:i.definitions=s);try{const u=JSON.parse(JSON.stringify(i));return Object.defineProperty(u,"~standard",{value:{...e["~standard"],jsonSchema:{input:Da(e,"input",r.processors),output:Da(e,"output",r.processors)}},enumerable:!1,writable:!1}),u}catch{throw new Error("Error converting schema to JSON.")}}function Ue(r,e){const t=e??{seen:new Set};if(t.seen.has(r))return!1;t.seen.add(r);const n=r._zod.def;if(n.type==="transform")return!0;if(n.type==="array")return Ue(n.element,t);if(n.type==="set")return Ue(n.valueType,t);if(n.type==="lazy")return Ue(n.getter(),t);if(n.type==="promise"||n.type==="optional"||n.type==="nonoptional"||n.type==="nullable"||n.type==="readonly"||n.type==="default"||n.type==="prefault")return Ue(n.innerType,t);if(n.type==="intersection")return Ue(n.left,t)||Ue(n.right,t);if(n.type==="record"||n.type==="map")return Ue(n.keyType,t)||Ue(n.valueType,t);if(n.type==="pipe")return Ue(n.in,t)||Ue(n.out,t);if(n.type==="object"){for(const i in n.shape)if(Ue(n.shape[i],t))return!0;return!1}if(n.type==="union"){for(const i of n.options)if(Ue(i,t))return!0;return!1}if(n.type==="tuple"){for(const i of n.items)if(Ue(i,t))return!0;return!!(n.rest&&Ue(n.rest,t))}return!1}const pT=(r,e={})=>t=>{const n=iv({...t,processors:e});return Se(r,n),sv(n,r),ov(n,r)},Da=(r,e,t={})=>n=>{const{libraryOptions:i,target:s}=n??{},o=iv({...i??{},target:s,io:e,processors:t});return Se(r,o),sv(o,r),ov(o,r)},fT={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},gT=(r,e,t,n)=>{const i=t;i.type="string";const{minimum:s,maximum:o,format:a,patterns:c,contentEncoding:u}=r._zod.bag;if(typeof s=="number"&&(i.minLength=s),typeof o=="number"&&(i.maxLength=o),a&&(i.format=fT[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}))])}},mT=(r,e,t,n)=>{const i=t,{minimum:s,maximum:o,format:a,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:h}=r._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)},vT=(r,e,t,n)=>{t.type="boolean"},yT=(r,e,t,n)=>{t.not={}},bT=(r,e,t,n)=>{},wT=(r,e,t,n)=>{const i=r._zod.def,s=Nm(i.entries);s.every(o=>typeof o=="number")&&(t.type="number"),s.every(o=>typeof o=="string")&&(t.type="string"),t.enum=s},ST=(r,e,t,n)=>{const i=r._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},_T=(r,e,t,n)=>{if(e.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},kT=(r,e,t,n)=>{if(e.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},xT=(r,e,t,n)=>{const i=t,s=r._zod.def,{minimum:o,maximum:a}=r._zod.bag;typeof o=="number"&&(i.minItems=o),typeof a=="number"&&(i.maxItems=a),i.type="array",i.items=Se(s.element,e,{...n,path:[...n.path,"items"]})},ET=(r,e,t,n)=>{var u;const i=t,s=r._zod.def;i.type="object",i.properties={};const o=s.shape;for(const h in o)i.properties[h]=Se(o[h],e,{...n,path:[...n.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=Se(s.catchall,e,{...n,path:[...n.path,"additionalProperties"]})):e.io==="output"&&(i.additionalProperties=!1)},AT=(r,e,t,n)=>{const i=r._zod.def,s=i.inclusive===!1,o=i.options.map((a,c)=>Se(a,e,{...n,path:[...n.path,s?"oneOf":"anyOf",c]}));s?t.oneOf=o:t.anyOf=o},$T=(r,e,t,n)=>{const i=r._zod.def,s=Se(i.left,e,{...n,path:[...n.path,"allOf",0]}),o=Se(i.right,e,{...n,path:[...n.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},IT=(r,e,t,n)=>{const i=t,s=r._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=Se(s.valueType,e,{...n,path:[...n.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=Se(s.keyType,e,{...n,path:[...n.path,"propertyNames"]})),i.additionalProperties=Se(s.valueType,e,{...n,path:[...n.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)}},TT=(r,e,t,n)=>{const i=r._zod.def,s=Se(i.innerType,e,n),o=e.seen.get(r);e.target==="openapi-3.0"?(o.ref=i.innerType,t.nullable=!0):t.anyOf=[s,{type:"null"}]},CT=(r,e,t,n)=>{const i=r._zod.def;Se(i.innerType,e,n);const s=e.seen.get(r);s.ref=i.innerType},PT=(r,e,t,n)=>{const i=r._zod.def;Se(i.innerType,e,n);const s=e.seen.get(r);s.ref=i.innerType,t.default=JSON.parse(JSON.stringify(i.defaultValue))},RT=(r,e,t,n)=>{const i=r._zod.def;Se(i.innerType,e,n);const s=e.seen.get(r);s.ref=i.innerType,e.io==="input"&&(t._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},DT=(r,e,t,n)=>{const i=r._zod.def;Se(i.innerType,e,n);const s=e.seen.get(r);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},LT=(r,e,t,n)=>{const i=r._zod.def,s=e.io==="input"?i.in._zod.def.type==="transform"?i.out:i.in:i.out;Se(s,e,n);const o=e.seen.get(r);o.ref=s},zT=(r,e,t,n)=>{const i=r._zod.def;Se(i.innerType,e,n);const s=e.seen.get(r);s.ref=i.innerType,t.readOnly=!0},av=(r,e,t,n)=>{const i=r._zod.def;Se(i.innerType,e,n);const s=e.seen.get(r);s.ref=i.innerType},OT=A("ZodISODateTime",(r,e)=>{M$.init(r,e),me.init(r,e)});function MT(r){return ZI(OT,r)}const NT=A("ZodISODate",(r,e)=>{N$.init(r,e),me.init(r,e)});function UT(r){return VI(NT,r)}const FT=A("ZodISOTime",(r,e)=>{U$.init(r,e),me.init(r,e)});function WT(r){return BI(FT,r)}const HT=A("ZodISODuration",(r,e)=>{F$.init(r,e),me.init(r,e)});function ZT(r){return GI(HT,r)}const lv=(r,e)=>{Hm.init(r,e),r.name="ZodError",Object.defineProperties(r,{format:{value:t=>CA(r,t)},flatten:{value:t=>TA(r,t)},addIssue:{value:t=>{r.issues.push(t),r.message=JSON.stringify(r.issues,Gc,2)}},addIssues:{value:t=>{r.issues.push(...t),r.message=JSON.stringify(r.issues,Gc,2)}},isEmpty:{get(){return r.issues.length===0}}})},df=A("ZodError",lv),ft=A("ZodError",lv,{Parent:Error}),VT=wh(ft),BT=Sh(ft),GT=dl(ft),jT=pl(ft),qT=DA(ft),YT=LA(ft),XT=zA(ft),KT=OA(ft),JT=MA(ft),QT=NA(ft),e1=UA(ft),t1=FA(ft),ge=A("ZodType",(r,e)=>(fe.init(r,e),Object.assign(r["~standard"],{jsonSchema:{input:Da(r,"input"),output:Da(r,"output")}}),r.toJSONSchema=pT(r,{}),r.def=e,r.type=e.type,Object.defineProperty(r,"_def",{value:e}),r.check=(...t)=>r.clone(Rr(e,{checks:[...e.checks??[],...t.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0}),r.with=r.check,r.clone=(t,n)=>Dr(r,t,n),r.brand=()=>r,r.register=(t,n)=>(t.add(r,n),r),r.parse=(t,n)=>VT(r,t,n,{callee:r.parse}),r.safeParse=(t,n)=>GT(r,t,n),r.parseAsync=async(t,n)=>BT(r,t,n,{callee:r.parseAsync}),r.safeParseAsync=async(t,n)=>jT(r,t,n),r.spa=r.safeParseAsync,r.encode=(t,n)=>qT(r,t,n),r.decode=(t,n)=>YT(r,t,n),r.encodeAsync=async(t,n)=>XT(r,t,n),r.decodeAsync=async(t,n)=>KT(r,t,n),r.safeEncode=(t,n)=>JT(r,t,n),r.safeDecode=(t,n)=>QT(r,t,n),r.safeEncodeAsync=async(t,n)=>e1(r,t,n),r.safeDecodeAsync=async(t,n)=>t1(r,t,n),r.refine=(t,n)=>r.check(G1(t,n)),r.superRefine=t=>r.check(j1(t)),r.overwrite=t=>r.check(Oi(t)),r.optional=()=>gf(r),r.exactOptional=()=>D1(r),r.nullable=()=>mf(r),r.nullish=()=>gf(mf(r)),r.nonoptional=t=>U1(r,t),r.array=()=>D(r),r.or=t=>G([r,t]),r.and=t=>gl(r,t),r.transform=t=>vf(r,P1(t)),r.default=t=>O1(r,t),r.prefault=t=>N1(r,t),r.catch=t=>W1(r,t),r.pipe=t=>vf(r,t),r.readonly=()=>V1(r),r.describe=t=>{const n=r.clone();return ts.add(n,{description:t}),n},Object.defineProperty(r,"description",{get(){var t;return(t=ts.get(r))==null?void 0:t.description},configurable:!0}),r.meta=(...t)=>{if(t.length===0)return ts.get(r);const n=r.clone();return ts.add(n,t[0]),n},r.isOptional=()=>r.safeParse(void 0).success,r.isNullable=()=>r.safeParse(null).success,r.apply=t=>t(r),r)),cv=A("_ZodString",(r,e)=>{_h.init(r,e),ge.init(r,e),r._zod.processJSONSchema=(n,i,s)=>gT(r,n,i);const t=r._zod.bag;r.format=t.format??null,r.minLength=t.minimum??null,r.maxLength=t.maximum??null,r.regex=(...n)=>r.check(JI(...n)),r.includes=(...n)=>r.check(tT(...n)),r.startsWith=(...n)=>r.check(rT(...n)),r.endsWith=(...n)=>r.check(nT(...n)),r.min=(...n)=>r.check(Ra(...n)),r.max=(...n)=>r.check(rv(...n)),r.length=(...n)=>r.check(nv(...n)),r.nonempty=(...n)=>r.check(Ra(1,...n)),r.lowercase=n=>r.check(QI(n)),r.uppercase=n=>r.check(eT(n)),r.trim=()=>r.check(sT()),r.normalize=(...n)=>r.check(iT(...n)),r.toLowerCase=()=>r.check(oT()),r.toUpperCase=()=>r.check(aT()),r.slugify=()=>r.check(lT())}),r1=A("ZodString",(r,e)=>{_h.init(r,e),cv.init(r,e),r.email=t=>r.check(_I(n1,t)),r.url=t=>r.check($I(i1,t)),r.jwt=t=>r.check(HI(b1,t)),r.emoji=t=>r.check(II(s1,t)),r.guid=t=>r.check(lf(pf,t)),r.uuid=t=>r.check(kI(Vo,t)),r.uuidv4=t=>r.check(xI(Vo,t)),r.uuidv6=t=>r.check(EI(Vo,t)),r.uuidv7=t=>r.check(AI(Vo,t)),r.nanoid=t=>r.check(TI(o1,t)),r.guid=t=>r.check(lf(pf,t)),r.cuid=t=>r.check(CI(a1,t)),r.cuid2=t=>r.check(PI(l1,t)),r.ulid=t=>r.check(RI(c1,t)),r.base64=t=>r.check(UI(m1,t)),r.base64url=t=>r.check(FI(v1,t)),r.xid=t=>r.check(DI(u1,t)),r.ksuid=t=>r.check(LI(h1,t)),r.ipv4=t=>r.check(zI(d1,t)),r.ipv6=t=>r.check(OI(p1,t)),r.cidrv4=t=>r.check(MI(f1,t)),r.cidrv6=t=>r.check(NI(g1,t)),r.e164=t=>r.check(WI(y1,t)),r.datetime=t=>r.check(MT(t)),r.date=t=>r.check(UT(t)),r.time=t=>r.check(WT(t)),r.duration=t=>r.check(ZT(t))});function d(r){return SI(r1,r)}const me=A("ZodStringFormat",(r,e)=>{de.init(r,e),cv.init(r,e)}),n1=A("ZodEmail",(r,e)=>{I$.init(r,e),me.init(r,e)}),pf=A("ZodGUID",(r,e)=>{A$.init(r,e),me.init(r,e)}),Vo=A("ZodUUID",(r,e)=>{$$.init(r,e),me.init(r,e)}),i1=A("ZodURL",(r,e)=>{T$.init(r,e),me.init(r,e)}),s1=A("ZodEmoji",(r,e)=>{C$.init(r,e),me.init(r,e)}),o1=A("ZodNanoID",(r,e)=>{P$.init(r,e),me.init(r,e)}),a1=A("ZodCUID",(r,e)=>{R$.init(r,e),me.init(r,e)}),l1=A("ZodCUID2",(r,e)=>{D$.init(r,e),me.init(r,e)}),c1=A("ZodULID",(r,e)=>{L$.init(r,e),me.init(r,e)}),u1=A("ZodXID",(r,e)=>{z$.init(r,e),me.init(r,e)}),h1=A("ZodKSUID",(r,e)=>{O$.init(r,e),me.init(r,e)}),d1=A("ZodIPv4",(r,e)=>{W$.init(r,e),me.init(r,e)}),p1=A("ZodIPv6",(r,e)=>{H$.init(r,e),me.init(r,e)}),f1=A("ZodCIDRv4",(r,e)=>{Z$.init(r,e),me.init(r,e)}),g1=A("ZodCIDRv6",(r,e)=>{V$.init(r,e),me.init(r,e)}),m1=A("ZodBase64",(r,e)=>{B$.init(r,e),me.init(r,e)}),v1=A("ZodBase64URL",(r,e)=>{j$.init(r,e),me.init(r,e)}),y1=A("ZodE164",(r,e)=>{q$.init(r,e),me.init(r,e)}),b1=A("ZodJWT",(r,e)=>{X$.init(r,e),me.init(r,e)}),uv=A("ZodNumber",(r,e)=>{Jm.init(r,e),ge.init(r,e),r._zod.processJSONSchema=(n,i,s)=>mT(r,n,i),r.gt=(n,i)=>r.check(uf(n,i)),r.gte=(n,i)=>r.check(hc(n,i)),r.min=(n,i)=>r.check(hc(n,i)),r.lt=(n,i)=>r.check(cf(n,i)),r.lte=(n,i)=>r.check(uc(n,i)),r.max=(n,i)=>r.check(uc(n,i)),r.int=n=>r.check(ff(n)),r.safe=n=>r.check(ff(n)),r.positive=n=>r.check(uf(0,n)),r.nonnegative=n=>r.check(hc(0,n)),r.negative=n=>r.check(cf(0,n)),r.nonpositive=n=>r.check(uc(0,n)),r.multipleOf=(n,i)=>r.check(hf(n,i)),r.step=(n,i)=>r.check(hf(n,i)),r.finite=()=>r;const t=r._zod.bag;r.minValue=Math.max(t.minimum??Number.NEGATIVE_INFINITY,t.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,r.maxValue=Math.min(t.maximum??Number.POSITIVE_INFINITY,t.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,r.isInt=(t.format??"").includes("int")||Number.isSafeInteger(t.multipleOf??.5),r.isFinite=!0,r.format=t.format??null});function W(r){return jI(uv,r)}const w1=A("ZodNumberFormat",(r,e)=>{K$.init(r,e),uv.init(r,e)});function ff(r){return qI(w1,r)}const S1=A("ZodBoolean",(r,e)=>{J$.init(r,e),ge.init(r,e),r._zod.processJSONSchema=(t,n,i)=>vT(r,t,n)});function Te(r){return YI(S1,r)}const _1=A("ZodUnknown",(r,e)=>{Q$.init(r,e),ge.init(r,e),r._zod.processJSONSchema=(t,n,i)=>bT()});function S(){return XI(_1)}const k1=A("ZodNever",(r,e)=>{eI.init(r,e),ge.init(r,e),r._zod.processJSONSchema=(t,n,i)=>yT(r,t,n)});function x1(r){return KI(k1,r)}const E1=A("ZodArray",(r,e)=>{tI.init(r,e),ge.init(r,e),r._zod.processJSONSchema=(t,n,i)=>xT(r,t,n,i),r.element=e.element,r.min=(t,n)=>r.check(Ra(t,n)),r.nonempty=t=>r.check(Ra(1,t)),r.max=(t,n)=>r.check(rv(t,n)),r.length=(t,n)=>r.check(nv(t,n)),r.unwrap=()=>r.element});function D(r,e){return cT(E1,r,e)}const hv=A("ZodObject",(r,e)=>{nI.init(r,e),ge.init(r,e),r._zod.processJSONSchema=(t,n,i)=>ET(r,t,n,i),ie(r,"shape",()=>e.shape),r.keyof=()=>La(Object.keys(r._zod.def.shape)),r.catchall=t=>r.clone({...r._zod.def,catchall:t}),r.passthrough=()=>r.clone({...r._zod.def,catchall:S()}),r.loose=()=>r.clone({...r._zod.def,catchall:S()}),r.strict=()=>r.clone({...r._zod.def,catchall:x1()}),r.strip=()=>r.clone({...r._zod.def,catchall:void 0}),r.extend=t=>xA(r,t),r.safeExtend=t=>EA(r,t),r.merge=t=>AA(r,t),r.pick=t=>_A(r,t),r.omit=t=>kA(r,t),r.partial=(...t)=>$A(pv,r,t[0]),r.required=(...t)=>IA(fv,r,t[0])});function dv(r,e){const t={type:"object",shape:r??{},...z(e)};return new hv(t)}function g(r,e){return new hv({type:"object",shape:r,catchall:S(),...z(e)})}const A1=A("ZodUnion",(r,e)=>{iI.init(r,e),ge.init(r,e),r._zod.processJSONSchema=(t,n,i)=>AT(r,t,n,i),r.options=e.options});function G(r,e){return new A1({type:"union",options:r,...z(e)})}const $1=A("ZodIntersection",(r,e)=>{sI.init(r,e),ge.init(r,e),r._zod.processJSONSchema=(t,n,i)=>$T(r,t,n,i)});function gl(r,e){return new $1({type:"intersection",left:r,right:e})}const I1=A("ZodRecord",(r,e)=>{oI.init(r,e),ge.init(r,e),r._zod.processJSONSchema=(t,n,i)=>IT(r,t,n,i),r.keyType=e.keyType,r.valueType=e.valueType});function k(r,e,t){return new I1({type:"record",keyType:r,valueType:e,...z(t)})}const qc=A("ZodEnum",(r,e)=>{aI.init(r,e),ge.init(r,e),r._zod.processJSONSchema=(n,i,s)=>wT(r,n,i),r.enum=e.entries,r.options=Object.values(e.entries);const t=new Set(Object.keys(e.entries));r.extract=(n,i)=>{const s={};for(const o of n)if(t.has(o))s[o]=e.entries[o];else throw new Error(`Key ${o} not found in enum`);return new qc({...e,checks:[],...z(i),entries:s})},r.exclude=(n,i)=>{const s={...e.entries};for(const o of n)if(t.has(o))delete s[o];else throw new Error(`Key ${o} not found in enum`);return new qc({...e,checks:[],...z(i),entries:s})}});function La(r,e){const t=Array.isArray(r)?Object.fromEntries(r.map(n=>[n,n])):r;return new qc({type:"enum",entries:t,...z(e)})}const T1=A("ZodLiteral",(r,e)=>{lI.init(r,e),ge.init(r,e),r._zod.processJSONSchema=(t,n,i)=>ST(r,t,n),r.values=new Set(e.values),Object.defineProperty(r,"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 $(r,e){return new T1({type:"literal",values:Array.isArray(r)?r:[r],...z(e)})}const C1=A("ZodTransform",(r,e)=>{cI.init(r,e),ge.init(r,e),r._zod.processJSONSchema=(t,n,i)=>kT(r,t),r._zod.parse=(t,n)=>{if(n.direction==="backward")throw new Om(r.constructor.name);t.addIssue=s=>{if(typeof s=="string")t.issues.push(ms(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=r),t.issues.push(ms(o))}};const i=e.transform(t.value,t);return i instanceof Promise?i.then(s=>(t.value=s,t)):(t.value=i,t)}});function P1(r){return new C1({type:"transform",transform:r})}const pv=A("ZodOptional",(r,e)=>{tv.init(r,e),ge.init(r,e),r._zod.processJSONSchema=(t,n,i)=>av(r,t,n,i),r.unwrap=()=>r._zod.def.innerType});function gf(r){return new pv({type:"optional",innerType:r})}const R1=A("ZodExactOptional",(r,e)=>{uI.init(r,e),ge.init(r,e),r._zod.processJSONSchema=(t,n,i)=>av(r,t,n,i),r.unwrap=()=>r._zod.def.innerType});function D1(r){return new R1({type:"optional",innerType:r})}const L1=A("ZodNullable",(r,e)=>{hI.init(r,e),ge.init(r,e),r._zod.processJSONSchema=(t,n,i)=>TT(r,t,n,i),r.unwrap=()=>r._zod.def.innerType});function mf(r){return new L1({type:"nullable",innerType:r})}const z1=A("ZodDefault",(r,e)=>{dI.init(r,e),ge.init(r,e),r._zod.processJSONSchema=(t,n,i)=>PT(r,t,n,i),r.unwrap=()=>r._zod.def.innerType,r.removeDefault=r.unwrap});function O1(r,e){return new z1({type:"default",innerType:r,get defaultValue(){return typeof e=="function"?e():Fm(e)}})}const M1=A("ZodPrefault",(r,e)=>{pI.init(r,e),ge.init(r,e),r._zod.processJSONSchema=(t,n,i)=>RT(r,t,n,i),r.unwrap=()=>r._zod.def.innerType});function N1(r,e){return new M1({type:"prefault",innerType:r,get defaultValue(){return typeof e=="function"?e():Fm(e)}})}const fv=A("ZodNonOptional",(r,e)=>{fI.init(r,e),ge.init(r,e),r._zod.processJSONSchema=(t,n,i)=>CT(r,t,n,i),r.unwrap=()=>r._zod.def.innerType});function U1(r,e){return new fv({type:"nonoptional",innerType:r,...z(e)})}const F1=A("ZodCatch",(r,e)=>{gI.init(r,e),ge.init(r,e),r._zod.processJSONSchema=(t,n,i)=>DT(r,t,n,i),r.unwrap=()=>r._zod.def.innerType,r.removeCatch=r.unwrap});function W1(r,e){return new F1({type:"catch",innerType:r,catchValue:typeof e=="function"?e:()=>e})}const H1=A("ZodPipe",(r,e)=>{mI.init(r,e),ge.init(r,e),r._zod.processJSONSchema=(t,n,i)=>LT(r,t,n,i),r.in=e.in,r.out=e.out});function vf(r,e){return new H1({type:"pipe",in:r,out:e})}const Z1=A("ZodReadonly",(r,e)=>{vI.init(r,e),ge.init(r,e),r._zod.processJSONSchema=(t,n,i)=>zT(r,t,n,i),r.unwrap=()=>r._zod.def.innerType});function V1(r){return new Z1({type:"readonly",innerType:r})}const B1=A("ZodCustom",(r,e)=>{yI.init(r,e),ge.init(r,e),r._zod.processJSONSchema=(t,n,i)=>_T(r,t)});function G1(r,e={}){return uT(B1,r,e)}function j1(r){return hT(r)}const dc={custom:"custom"},q1=["text/markdown","text/html"],Y1=["committed","pending"];function X1(r){let e;try{e=new URL(r)}catch{return!1}return e.protocol==="http:"||e.protocol==="https:"}dv({id:d().min(1),type:La(q1),title:d(),status:La(Y1),externalFilePath:d().optional(),externalURL:d().optional()}).superRefine((r,e)=>{r.externalFilePath!==void 0&&r.externalURL!==void 0&&e.addIssue({code:dc.custom,message:"externalFilePath and externalURL are mutually exclusive",path:["externalURL"]}),r.externalURL!==void 0&&(X1(r.externalURL)||e.addIssue({code:dc.custom,message:"externalURL must be an http(s) URL",path:["externalURL"]}),r.status!=="committed"&&e.addIssue({code:dc.custom,message:"URL-backed artifacts must have status committed",path:["status"]}))});dv({name:d().min(1),description:d(),accepts:D(d().min(1)).min(1)});function gv(r){return typeof r=="object"&&r!==null}function K1(r){return!gv(r)||r.type!=="ready"?!1:!("id"in r)}function J1(r){return!(!gv(r)||r.type!=="update-content"||typeof r.id!="string"||typeof r.content!="string")}function Q1(r,e){if(r===e)return 2;if(r==="*/*")return 0;const t=r.indexOf("/");if(t>0&&r.slice(t+1)==="*"){const n=r.slice(0,t),i=e.indexOf("/");if(i>0&&e.slice(0,i)===n)return 1}return null}function eC(r,e){let t=null;for(const n of r.accepts){const i=Q1(n,e);i!==null&&(t===null||i>t)&&(t=i)}return t}function tC(r,e){let t=-1,n=null;for(const i of e){const s=eC(i,r);s!==null&&(s>t||s===t&&n!==null&&i.id<n.id)&&(t=s,n=i)}return n}const he={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"},qt={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"},rC=1,nC=g({_meta:k(d(),S()).nullish(),terminal:Te().optional().default(!1)}),iC=g({_meta:k(d(),S()).nullish(),label:d().nullish(),name:d(),optional:Te().optional().default(!1),secret:Te().optional().default(!0)}),sC=g({_meta:k(d(),S()).nullish(),description:d().nullish(),id:d(),name:d()}),oC=g({_meta:k(d(),S()).nullish(),description:d().nullish(),id:d(),link:d().nullish(),name:d(),vars:D(iC)}),aC=g({_meta:k(d(),S()).nullish(),args:D(d()).optional(),description:d().nullish(),env:k(d(),d()).optional(),id:d(),name:d()}),lC=G([oC.and(g({type:$("env_var")})),aC.and(g({type:$("terminal")})),sC]),cC=g({_meta:k(d(),S()).nullish(),methodId:d()}),uC=g({_meta:k(d(),S()).nullish()}),hC=g({_meta:k(d(),S()).nullish(),blob:d(),mimeType:d().nullish(),uri:d()}),dC=g({default:Te().nullish(),description:d().nullish(),title:d().nullish()}),pC=g({_meta:k(d(),S()).nullish()}),fC=g({_meta:k(d(),S()).nullish()}),gC=g({amount:W(),currency:d()}),mC=g({_meta:k(d(),S()).nullish(),terminalId:d()}),vC=g({_meta:k(d(),S()).nullish(),newText:d(),oldText:d().nullish(),path:d()}),yC=G([d(),W(),W(),Te(),D(d())]),bC=g({content:k(d(),yC).nullish()}),wC=G([bC.and(g({action:$("accept")})),g({action:$("decline")}),g({action:$("cancel")})]),SC=g({_meta:k(d(),S()).nullish()}),mv=d(),_C=g({_meta:k(d(),S()).nullish(),elicitationId:mv}),kC=g({_meta:k(d(),S()).nullish(),action:wC}),xC=$("object"),EC=$("string"),AC=g({_meta:k(d(),S()).nullish()}),$C=g({_meta:k(d(),S()).nullish(),form:SC.nullish(),url:AC.nullish()}),IC=g({elicitationId:mv,url:d().url()}),vv=g({const:d(),title:d()}),yv=g({_meta:k(d(),S()).nullish(),name:d(),value:d()}),TC=G([$(-32700),$(-32600),$(-32601),$(-32602),$(-32603),$(-32800),$(-32e3),$(-32002),$(-32042),W().int().min(-2147483648,{message:"Invalid value: Expected int32 to be >= -2147483648"}).max(2147483647,{message:"Invalid value: Expected int32 to be <= 2147483647"})]),bv=g({code:TC,data:S().optional(),message:d()}),wv=S(),Sv=S(),_v=S(),CC=g({_meta:k(d(),S()).nullish(),readTextFile:Te().optional().default(!1),writeTextFile:Te().optional().default(!1)}),kv=g({_meta:k(d(),S()).nullish(),name:d(),value:d()}),xv=g({_meta:k(d(),S()).nullish(),name:d(),title:d().nullish(),version:d()}),PC=g({default:W().nullish(),description:d().nullish(),maximum:W().nullish(),minimum:W().nullish(),title:d().nullish()}),RC=g({_meta:k(d(),S()).nullish()}),DC=g({_meta:k(d(),S()).nullish(),additionalDirectories:D(d()).optional(),cursor:d().nullish(),cwd:d().nullish()}),LC=g({_meta:k(d(),S()).nullish()}),zC=g({_meta:k(d(),S()).nullish(),logout:LC.nullish()}),OC=g({_meta:k(d(),S()).nullish()}),MC=g({_meta:k(d(),S()).nullish()}),NC=g({_meta:k(d(),S()).nullish(),http:Te().optional().default(!1),sse:Te().optional().default(!1)}),UC=g({_meta:k(d(),S()).nullish(),headers:D(kv),name:d(),url:d()}),FC=g({_meta:k(d(),S()).nullish(),headers:D(kv),name:d(),url:d()}),WC=g({_meta:k(d(),S()).nullish(),args:D(d()),command:d(),env:D(yv),name:d()}),ml=G([UC.and(g({type:$("http")})),FC.and(g({type:$("sse")})),WC]),kh=d(),HC=g({_meta:k(d(),S()).nullish(),description:d().nullish(),modelId:kh,name:d()}),ZC=G([$("error"),$("warning"),$("information"),$("hint")]),VC=g({_meta:k(d(),S()).nullish()}),BC=g({_meta:k(d(),S()).nullish()}),GC=g({_meta:k(d(),S()).nullish()}),jC=g({_meta:k(d(),S()).nullish()}),qC=g({_meta:k(d(),S()).nullish()}),YC=g({_meta:k(d(),S()).nullish(),maxCount:W().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),XC=g({diff:d(),uri:d()}),KC=g({endLine:W().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),startLine:W().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),text:d()}),JC=g({_meta:k(d(),S()).nullish()}),QC=g({_meta:k(d(),S()).nullish()}),eP=g({languageId:d(),text:d(),uri:d()}),tP=g({_meta:k(d(),S()).nullish(),maxCount:W().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),rP=G([$("rejected"),$("ignored"),$("replaced"),$("cancelled")]),nP=g({excerpts:D(KC),uri:d()}),iP=g({_meta:k(d(),S()).nullish()}),sP=g({_meta:k(d(),S()).nullish()}),oP=g({name:d(),owner:d(),remoteUrl:d()}),aP=g({_meta:k(d(),S()).nullish()}),lP=g({_meta:k(d(),S()).nullish(),jump:JC.nullish(),rename:sP.nullish(),searchAndReplace:aP.nullish()}),cP=g({id:d(),isRegex:Te().nullish(),replace:d(),search:d(),uri:d()}),uP=G([$("automatic"),$("diagnostic"),$("manual")]),hP=g({_meta:k(d(),S()).nullish(),maxCount:W().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),dP=g({_meta:k(d(),S()).nullish(),diagnostics:VC.nullish(),editHistory:YC.nullish(),openFiles:QC.nullish(),recentFiles:tP.nullish(),relatedSnippets:iP.nullish(),userActions:hP.nullish()}),pP=g({_meta:k(d(),S()).nullish(),additionalDirectories:D(d()).optional(),cwd:d(),mcpServers:D(ml)}),fP=g({default:W().nullish(),description:d().nullish(),maximum:W().nullish(),minimum:W().nullish(),title:d().nullish()}),Ev=d(),gP=G([$("allow_once"),$("allow_always"),$("reject_once"),$("reject_always")]),mP=g({_meta:k(d(),S()).nullish(),kind:gP,name:d(),optionId:Ev}),vP=G([$("high"),$("medium"),$("low")]),yP=G([$("pending"),$("in_progress"),$("completed")]),bP=g({_meta:k(d(),S()).nullish(),content:d(),priority:vP,status:yP}),wP=g({_meta:k(d(),S()).nullish(),entries:D(bP)}),Ir=g({character:W().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),line:W().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"})}),SP=g({id:d(),position:Ir,uri:d()}),_P=g({id:d(),newName:d(),position:Ir,uri:d()}),kP=g({action:d(),position:Ir,timestampMs:W(),uri:d()}),Av=G([$("utf-16"),$("utf-32"),$("utf-8")]),xP=g({_meta:k(d(),S()).nullish(),auth:nC.optional().default({terminal:!1}),elicitation:$C.nullish(),fs:CC.optional().default({readTextFile:!1,writeTextFile:!1}),nes:lP.nullish(),positionEncodings:D(Av).optional(),terminal:Te().optional().default(!1)}),EP=g({_meta:k(d(),S()).nullish(),audio:Te().optional().default(!1),embeddedContext:Te().optional().default(!1),image:Te().optional().default(!1)}),$v=W().int().gte(0).lte(65535),AP=g({_meta:k(d(),S()).nullish(),clientCapabilities:xP.optional().default({auth:{terminal:!1},fs:{readTextFile:!1,writeTextFile:!1},terminal:!1}),clientInfo:xv.nullish(),protocolVersion:$v}),Mi=g({end:Ir,start:Ir}),$P=g({message:d(),range:Mi,severity:ZC,uri:d()}),IP=g({languageId:d(),lastFocusedMs:W().nullish(),uri:d(),visibleRange:Mi.nullish()}),TP=g({_meta:k(d(),S()).nullish(),diagnostics:D($P).nullish(),editHistory:D(XC).nullish(),openFiles:D(IP).nullish(),recentFiles:D(eP).nullish(),relatedSnippets:D(nP).nullish(),userActions:D(kP).nullish()}),CP=g({newText:d(),range:Mi}),PP=g({cursorPosition:Ir.nullish(),edits:D(CP),id:d(),uri:d()}),RP=G([PP.and(g({kind:$("edit")})),SP.and(g({kind:$("jump")})),_P.and(g({kind:$("rename")})),cP.and(g({kind:$("searchAndReplace")}))]),DP=g({_meta:k(d(),S()).nullish(),content:d()}),LP=g({_meta:k(d(),S()).nullish()}),bn=G([W(),d()]).nullable();g({_meta:k(d(),S()).nullish(),requestId:bn});const zP=La(["assistant","user"]),ko=g({_meta:k(d(),S()).nullish(),audience:D(zP).nullish(),lastModified:d().nullish(),priority:W().nullish()}),OP=g({_meta:k(d(),S()).nullish(),annotations:ko.nullish(),data:d(),mimeType:d()}),MP=g({_meta:k(d(),S()).nullish(),annotations:ko.nullish(),data:d(),mimeType:d(),uri:d().nullish()}),NP=g({_meta:k(d(),S()).nullish(),annotations:ko.nullish(),description:d().nullish(),mimeType:d().nullish(),name:d(),size:W().nullish(),title:d().nullish(),uri:d()}),UP=g({_meta:k(d(),S()).nullish(),optionId:Ev}),FP=G([g({outcome:$("cancelled")}),UP.and(g({outcome:$("selected")}))]),WP=g({_meta:k(d(),S()).nullish(),outcome:FP}),HP=g({_meta:k(d(),S()).nullish()}),ZP=g({_meta:k(d(),S()).nullish()}),VP=g({currentValue:Te()}),BP=d(),Iv=d(),GP=G([$("mode"),$("model"),$("thought_level"),d()]),xh=d(),Tv=g({_meta:k(d(),S()).nullish(),description:d().nullish(),name:d(),value:xh}),jP=g({_meta:k(d(),S()).nullish(),group:BP,name:d(),options:D(Tv)}),qP=G([D(Tv),D(jP)]),YP=g({currentValue:xh,options:qP}),Ni=gl(G([YP.and(g({type:$("select")})),VP.and(g({type:$("boolean")}))]),g({_meta:k(d(),S()).nullish(),category:GP.nullish(),description:d().nullish(),id:Iv,name:d()})),XP=g({_meta:k(d(),S()).nullish(),configOptions:D(Ni)}),KP=g({_meta:k(d(),S()).nullish()}),ee=d(),JP=g({_meta:k(d(),S()).nullish(),id:d(),sessionId:ee}),QP=g({_meta:k(d(),S()).nullish(),sessionId:ee}),eR=g({_meta:k(d(),S()).nullish(),sessionId:ee}),tR=g({_meta:k(d(),S()).nullish(),sessionId:ee}),Cv=g({_meta:k(d(),S()).nullish(),args:D(d()).optional(),command:d(),cwd:d().nullish(),env:D(yv).optional(),outputByteLimit:W().nullish(),sessionId:ee}),rR=g({_meta:k(d(),S()).nullish(),sessionId:ee,uri:d()}),nR=g({_meta:k(d(),S()).nullish(),position:Ir,sessionId:ee,uri:d(),version:W(),visibleRange:Mi}),iR=g({_meta:k(d(),S()).nullish(),languageId:d(),sessionId:ee,text:d(),uri:d(),version:W()}),sR=g({_meta:k(d(),S()).nullish(),sessionId:ee,uri:d()}),oR=g({_meta:k(d(),S()).nullish(),additionalDirectories:D(d()).optional(),cwd:d(),mcpServers:D(ml).optional(),sessionId:ee}),Pv=g({_meta:k(d(),S()).nullish(),sessionId:ee,terminalId:d()}),aR=g({_meta:k(d(),S()).nullish(),additionalDirectories:D(d()).optional(),cwd:d(),mcpServers:D(ml),sessionId:ee}),Rv=g({_meta:k(d(),S()).nullish(),limit:W().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),line:W().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:d(),sessionId:ee}),lR=g({_meta:k(d(),S()).nullish(),id:d(),reason:rP.nullish(),sessionId:ee}),Dv=g({_meta:k(d(),S()).nullish(),sessionId:ee,terminalId:d()}),cR=g({_meta:k(d(),S()).nullish(),additionalDirectories:D(d()).optional(),cwd:d(),mcpServers:D(ml).optional(),sessionId:ee}),uR=g({_meta:k(d(),S()).nullish(),additionalDirectories:D(d()).optional(),cwd:d(),sessionId:ee,title:d().nullish(),updatedAt:d().nullish()}),hR=g({_meta:k(d(),S()).nullish(),nextCursor:d().nullish(),sessions:D(uR)}),dR=g({_meta:k(d(),S()).nullish(),title:d().nullish(),updatedAt:d().nullish()}),pR=g({_meta:k(d(),S()).nullish()}),vl=d(),fR=g({_meta:k(d(),S()).nullish(),currentModeId:vl}),gR=g({_meta:k(d(),S()).nullish(),description:d().nullish(),id:vl,name:d()}),yl=g({_meta:k(d(),S()).nullish(),availableModes:D(gR),currentModeId:vl}),bl=g({_meta:k(d(),S()).nullish(),availableModels:D(HC),currentModelId:kh}),mR=g({_meta:k(d(),S()).nullish(),configOptions:D(Ni).nullish(),models:bl.nullish(),modes:yl.nullish(),sessionId:ee}),vR=g({_meta:k(d(),S()).nullish(),configOptions:D(Ni).nullish(),models:bl.nullish(),modes:yl.nullish()}),yR=g({_meta:k(d(),S()).nullish(),configOptions:D(Ni).nullish(),models:bl.nullish(),modes:yl.nullish(),sessionId:ee}),bR=g({_meta:k(d(),S()).nullish(),configOptions:D(Ni).nullish(),models:bl.nullish(),modes:yl.nullish()}),wR=g({_meta:k(d(),S()).nullish()}),SR=g({_meta:k(d(),S()).nullish(),additionalDirectories:HP.nullish(),close:ZP.nullish(),fork:KP.nullish(),list:pR.nullish(),resume:wR.nullish()}),_R=gl(G([g({type:$("boolean"),value:Te()}),g({value:xh})]),g({_meta:k(d(),S()).nullish(),configId:Iv,sessionId:ee})),kR=g({_meta:k(d(),S()).nullish(),configOptions:D(Ni)}),xR=g({_meta:k(d(),S()).nullish(),modeId:vl,sessionId:ee}),ER=g({_meta:k(d(),S()).nullish()}),AR=g({_meta:k(d(),S()).nullish(),modelId:kh,sessionId:ee}),$R=g({_meta:k(d(),S()).nullish()}),IR=g({_meta:k(d(),S()).nullish(),sessionId:ee}),TR=G([$("end_turn"),$("max_tokens"),$("max_turn_requests"),$("refusal"),$("cancelled")]),CR=G([$("email"),$("uri"),$("date"),$("date-time")]),PR=g({default:d().nullish(),description:d().nullish(),enum:D(d()).nullish(),format:CR.nullish(),maxLength:W().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),minLength:W().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),oneOf:D(vv).nullish(),pattern:d().nullish(),title:d().nullish()}),RR=g({_meta:k(d(),S()).nullish(),context:TP.nullish(),position:Ir,selection:Mi.nullish(),sessionId:ee,triggerKind:uP,uri:d(),version:W()}),DR=g({_meta:k(d(),S()).nullish(),suggestions:D(RP)}),LR=g({_meta:k(d(),S()).nullish(),terminalId:d()}),zR=g({_meta:k(d(),S()).nullish(),exitCode:W().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:d().nullish()}),Lv=g({_meta:k(d(),S()).nullish(),sessionId:ee,terminalId:d()}),OR=g({_meta:k(d(),S()).nullish(),exitStatus:zR.nullish(),output:d(),truncated:Te()}),MR=g({_meta:k(d(),S()).nullish(),annotations:ko.nullish(),text:d()}),NR=g({range:Mi.nullish(),text:d()}),UR=g({_meta:k(d(),S()).nullish(),contentChanges:D(NR),sessionId:ee,uri:d(),version:W()});g({method:d(),params:G([QP,iR,UR,rR,sR,nR,JP,lR,wv]).nullish()});const FR=G([$("full"),$("incremental")]),WR=g({_meta:k(d(),S()).nullish(),syncKind:FR}),HR=g({_meta:k(d(),S()).nullish(),didChange:WR.nullish(),didClose:BC.nullish(),didFocus:GC.nullish(),didOpen:jC.nullish(),didSave:qC.nullish()}),ZR=g({_meta:k(d(),S()).nullish(),document:HR.nullish()}),VR=g({_meta:k(d(),S()).nullish(),context:dP.nullish(),events:ZR.nullish()}),BR=g({_meta:k(d(),S()).nullish(),auth:zC.optional().default({}),loadSession:Te().optional().default(!1),mcpCapabilities:NC.optional().default({http:!1,sse:!1}),nes:VR.nullish(),positionEncoding:Av.nullish(),promptCapabilities:EP.optional().default({audio:!1,embeddedContext:!1,image:!1}),sessionCapabilities:SR.optional().default({})}),GR=g({_meta:k(d(),S()).nullish(),agentCapabilities:BR.optional().default({auth:{},loadSession:!1,mcpCapabilities:{http:!1,sse:!1},promptCapabilities:{audio:!1,embeddedContext:!1,image:!1},sessionCapabilities:{}}),agentInfo:xv.nullish(),authMethods:D(lC).optional().default([]),protocolVersion:$v}),jR=g({_meta:k(d(),S()).nullish(),mimeType:d().nullish(),text:d(),uri:d()}),qR=G([jR,hC]),YR=g({_meta:k(d(),S()).nullish(),annotations:ko.nullish(),resource:qR}),Eh=G([MR.and(g({type:$("text")})),MP.and(g({type:$("image")})),OP.and(g({type:$("audio")})),NP.and(g({type:$("resource_link")})),YR.and(g({type:$("resource")}))]),XR=g({_meta:k(d(),S()).nullish(),content:Eh}),pc=g({_meta:k(d(),S()).nullish(),content:Eh,messageId:d().nullish()}),KR=g({_meta:k(d(),S()).nullish(),messageId:d().nullish(),prompt:D(Eh),sessionId:ee}),JR=g({anyOf:D(vv)}),zv=G([XR.and(g({type:$("content")})),vC.and(g({type:$("diff")})),LR.and(g({type:$("terminal")}))]),Ov=d(),Mv=g({_meta:k(d(),S()).nullish(),line:W().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:d()}),Nv=G([$("pending"),$("in_progress"),$("completed"),$("failed")]),Uv=G([$("read"),$("edit"),$("delete"),$("move"),$("search"),$("execute"),$("think"),$("fetch"),$("switch_mode"),$("other")]),QR=g({_meta:k(d(),S()).nullish(),content:D(zv).optional(),kind:Uv.optional(),locations:D(Mv).optional(),rawInput:S().optional(),rawOutput:S().optional(),status:Nv.optional(),title:d(),toolCallId:Ov}),Fv=g({_meta:k(d(),S()).nullish(),content:D(zv).nullish(),kind:Uv.nullish(),locations:D(Mv).nullish(),rawInput:S().optional(),rawOutput:S().optional(),status:Nv.nullish(),title:d().nullish(),toolCallId:Ov}),Wv=g({_meta:k(d(),S()).nullish(),options:D(mP),sessionId:ee,toolCall:Fv}),eD=g({_meta:k(d(),S()).nullish(),hint:d()}),tD=eD,rD=g({_meta:k(d(),S()).nullish(),description:d(),input:tD.nullish(),name:d()}),nD=g({_meta:k(d(),S()).nullish(),availableCommands:D(rD)}),iD=g({enum:D(d()),type:EC}),sD=G([iD,JR]),oD=g({default:D(d()).nullish(),description:d().nullish(),items:sD,maxItems:W().nullish(),minItems:W().nullish(),title:d().nullish()}),aD=G([PR.and(g({type:$("string")})),fP.and(g({type:$("number")})),PC.and(g({type:$("integer")})),dC.and(g({type:$("boolean")})),oD.and(g({type:$("array")}))]),lD=g({description:d().nullish(),properties:k(d(),aD).optional().default({}),required:D(d()).nullish(),title:d().nullish(),type:xC.optional().default("object")}),cD=g({requestedSchema:lD}),uD=gl(G([cD.and(g({mode:$("form")})),IC.and(g({mode:$("url")}))]),g({_meta:k(d(),S()).nullish(),message:d(),sessionId:ee})),hD=g({cachedReadTokens:W().nullish(),cachedWriteTokens:W().nullish(),inputTokens:W(),outputTokens:W(),thoughtTokens:W().nullish(),totalTokens:W()}),dD=g({_meta:k(d(),S()).nullish(),stopReason:TR,usage:hD.nullish(),userMessageId:d().nullish()});G([g({id:bn,result:G([GR,uC,MC,yR,vR,hR,mR,bR,fC,ER,kR,dD,$R,IR,DR,pC,_v])}),g({error:bv,id:bn})]);const pD=g({_meta:k(d(),S()).nullish(),cost:gC.nullish(),size:W(),used:W()}),fD=G([pc.and(g({sessionUpdate:$("user_message_chunk")})),pc.and(g({sessionUpdate:$("agent_message_chunk")})),pc.and(g({sessionUpdate:$("agent_thought_chunk")})),QR.and(g({sessionUpdate:$("tool_call")})),Fv.and(g({sessionUpdate:$("tool_call_update")})),wP.and(g({sessionUpdate:$("plan")})),nD.and(g({sessionUpdate:$("available_commands_update")})),fR.and(g({sessionUpdate:$("current_mode_update")})),XP.and(g({sessionUpdate:$("config_option_update")})),dR.and(g({sessionUpdate:$("session_info_update")})),pD.and(g({sessionUpdate:$("usage_update")}))]),Hv=g({_meta:k(d(),S()).nullish(),sessionId:ee,update:fD});g({method:d(),params:G([Hv,_C,wv]).nullish()});const Zv=g({_meta:k(d(),S()).nullish(),sessionId:ee,terminalId:d()}),gD=g({_meta:k(d(),S()).nullish(),exitCode:W().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:d().nullish()}),mD=g({name:d(),uri:d()}),vD=g({_meta:k(d(),S()).nullish(),repository:oP.nullish(),workspaceFolders:D(mD).nullish(),workspaceUri:d().nullish()});g({id:bn,method:d(),params:G([AP,cC,OC,pP,aR,DC,oR,cR,tR,xR,_R,KR,AR,vD,RR,eR,Sv]).nullish()});const Vv=g({_meta:k(d(),S()).nullish(),content:d(),path:d(),sessionId:ee});g({id:bn,method:d(),params:G([Vv,Rv,Wv,Cv,Lv,Dv,Zv,Pv,uD,Sv]).nullish()});const yD=g({_meta:k(d(),S()).nullish()});G([g({id:bn,result:G([yD,DP,WP,mC,OR,LP,gD,RC,kC,_v])}),g({error:bv,id:bn})]);var Q;class bD{constructor(e,t){w(this,Q);const n=e(this),i=async(o,a)=>{var c,u,h,p,v,m,E;switch(o){case qt.fs_write_text_file:{const x=Vv.parse(a);return(c=n.writeTextFile)==null?void 0:c.call(n,x)}case qt.fs_read_text_file:{const x=Rv.parse(a);return(u=n.readTextFile)==null?void 0:u.call(n,x)}case qt.session_request_permission:{const x=Wv.parse(a);return n.requestPermission(x)}case qt.terminal_create:{const x=Cv.parse(a);return(h=n.createTerminal)==null?void 0:h.call(n,x)}case qt.terminal_output:{const x=Lv.parse(a);return(p=n.terminalOutput)==null?void 0:p.call(n,x)}case qt.terminal_release:{const x=Dv.parse(a);return await((v=n.releaseTerminal)==null?void 0:v.call(n,x))??{}}case qt.terminal_wait_for_exit:{const x=Zv.parse(a);return(m=n.waitForTerminalExit)==null?void 0:m.call(n,x)}case qt.terminal_kill:{const x=Pv.parse(a);return await((E=n.killTerminal)==null?void 0:E.call(n,x))??{}}default:if(n.extMethod)return n.extMethod(o,a);throw Ae.methodNotFound(o)}},s=async(o,a)=>{switch(o){case qt.session_update:{const c=Hv.parse(a);return n.sessionUpdate(c)}default:if(n.extNotification)return n.extNotification(o,a);throw Ae.methodNotFound(o)}};_(this,Q,new wD(i,s,t))}async initialize(e){return await l(this,Q).sendRequest(he.initialize,e)}async newSession(e){return await l(this,Q).sendRequest(he.session_new,e)}async loadSession(e){return await l(this,Q).sendRequest(he.session_load,e)??{}}async unstable_forkSession(e){return await l(this,Q).sendRequest(he.session_fork,e)}async listSessions(e){return await l(this,Q).sendRequest(he.session_list,e)}async unstable_resumeSession(e){return await l(this,Q).sendRequest(he.session_resume,e)}async unstable_closeSession(e){return await l(this,Q).sendRequest(he.session_close,e)}async setSessionMode(e){return await l(this,Q).sendRequest(he.session_set_mode,e)??{}}async unstable_setSessionModel(e){return await l(this,Q).sendRequest(he.session_set_model,e)??{}}async setSessionConfigOption(e){return await l(this,Q).sendRequest(he.session_set_config_option,e)}async authenticate(e){return await l(this,Q).sendRequest(he.authenticate,e)??{}}async unstable_logout(e){return await l(this,Q).sendRequest(he.logout,e)??{}}async prompt(e){return await l(this,Q).sendRequest(he.session_prompt,e)}async cancel(e){return await l(this,Q).sendNotification(he.session_cancel,e)}async unstable_startNes(e){return await l(this,Q).sendRequest(he.nes_start,e)}async unstable_suggestNes(e){return await l(this,Q).sendRequest(he.nes_suggest,e)}async unstable_closeNes(e){return await l(this,Q).sendRequest(he.nes_close,e)??{}}async unstable_didOpenDocument(e){return await l(this,Q).sendNotification(he.document_did_open,e)}async unstable_didChangeDocument(e){return await l(this,Q).sendNotification(he.document_did_change,e)}async unstable_didCloseDocument(e){return await l(this,Q).sendNotification(he.document_did_close,e)}async unstable_didSaveDocument(e){return await l(this,Q).sendNotification(he.document_did_save,e)}async unstable_didFocusDocument(e){return await l(this,Q).sendNotification(he.document_did_focus,e)}async unstable_acceptNes(e){return await l(this,Q).sendNotification(he.nes_accept,e)}async unstable_rejectNes(e){return await l(this,Q).sendNotification(he.nes_reject,e)}async extMethod(e,t){return await l(this,Q).sendRequest(e,t)}async extNotification(e,t){return await l(this,Q).sendNotification(e,t)}get signal(){return l(this,Q).signal}get closed(){return l(this,Q).closed}}Q=new WeakMap;var mr,Za,$s,Is,ni,ii,zt,Ts,pe,Bv,Yc,Gv,jv,qv,Yv,Xc,rs;class wD{constructor(e,t,n){w(this,pe);w(this,mr,new Map);w(this,Za,0);w(this,$s);w(this,Is);w(this,ni);w(this,ii,Promise.resolve());w(this,zt,new AbortController);w(this,Ts);_(this,$s,e),_(this,Is,t),_(this,ni,n),_(this,Ts,new Promise(i=>{l(this,zt).signal.addEventListener("abort",()=>i())})),f(this,pe,Bv).call(this)}get signal(){return l(this,zt).signal}get closed(){return l(this,Ts)}async sendRequest(e,t){f(this,pe,Xc).call(this);const n=yd(this,Za)._++,i=new Promise((s,o)=>{l(this,mr).set(n,{resolve:s,reject:o})});return await f(this,pe,rs).call(this,{jsonrpc:"2.0",id:n,method:e,params:t}),i}async sendNotification(e,t){f(this,pe,Xc).call(this),await f(this,pe,rs).call(this,{jsonrpc:"2.0",method:e,params:t})}}mr=new WeakMap,Za=new WeakMap,$s=new WeakMap,Is=new WeakMap,ni=new WeakMap,ii=new WeakMap,zt=new WeakMap,Ts=new WeakMap,pe=new WeakSet,Bv=async function(){let e;try{const t=l(this,ni).readable.getReader();try{for(;!l(this,zt).signal.aborted;){const{value:n,done:i}=await t.read();if(i)break;if(n)try{f(this,pe,Gv).call(this,n)}catch(s){console.error("Unexpected error during message processing:",n,s),"id"in n&&n.id!==void 0&&f(this,pe,rs).call(this,{jsonrpc:"2.0",id:n.id,error:{code:-32700,message:"Parse error"}})}}}finally{t.releaseLock()}}catch(t){e=t}finally{f(this,pe,Yc).call(this,e)}},Yc=function(e){if(l(this,zt).signal.aborted)return;const t=e??new Error("ACP connection closed");for(const n of l(this,mr).values())n.reject(t);l(this,mr).clear(),l(this,zt).abort(t)},Gv=async function(e){if("method"in e&&"id"in e){const t=await f(this,pe,jv).call(this,e.method,e.params);"error"in t&&console.error("Error handling request",e,t.error),await f(this,pe,rs).call(this,{jsonrpc:"2.0",id:e.id,...t})}else if("method"in e){const t=await f(this,pe,qv).call(this,e.method,e.params);"error"in t&&console.error("Error handling notification",e,t.error)}else"id"in e?f(this,pe,Yv).call(this,e):console.error("Invalid message",{message:e})},jv=async function(e,t){try{return{result:await l(this,$s).call(this,e,t)??null}}catch(n){if(n instanceof Ae)return n.toResult();if(n instanceof df)return Ae.invalidParams(n.format()).toResult();let i;(n instanceof Error||typeof n=="object"&&n!=null&&"message"in n&&typeof n.message=="string")&&(i=n.message);try{return Ae.internalError(i?JSON.parse(i):{}).toResult()}catch{return Ae.internalError({details:i}).toResult()}}},qv=async function(e,t){try{return await l(this,Is).call(this,e,t),{result:null}}catch(n){if(n instanceof Ae)return n.toResult();if(n instanceof df)return Ae.invalidParams(n.format()).toResult();let i;(n instanceof Error||typeof n=="object"&&n!=null&&"message"in n&&typeof n.message=="string")&&(i=n.message);try{return Ae.internalError(i?JSON.parse(i):{}).toResult()}catch{return Ae.internalError({details:i}).toResult()}}},Yv=function(e){const t=l(this,mr).get(e.id);if(t){if("result"in e)t.resolve(e.result);else if("error"in e){const{code:n,message:i,data:s}=e.error;t.reject(new Ae(n,i,s))}l(this,mr).delete(e.id)}else console.error("Got response to unknown request",e.id)},Xc=function(){if(l(this,zt).signal.aborted)throw l(this,zt).signal.reason??new Error("ACP connection closed")},rs=async function(e){return _(this,ii,l(this,ii).then(async()=>{const t=l(this,ni).writable.getWriter();try{await t.write(e)}finally{t.releaseLock()}}).catch(t=>{f(this,pe,Yc).call(this,t)})),l(this,ii)};class Ae extends Error{constructor(t,n,i){super(n);y(this,"code");y(this,"data");this.code=t,this.name="RequestError",this.data=i}static parseError(t,n){return new Ae(-32700,`Parse error${n?`: ${n}`:""}`,t)}static invalidRequest(t,n){return new Ae(-32600,`Invalid request${n?`: ${n}`:""}`,t)}static methodNotFound(t){return new Ae(-32601,`"Method not found": ${t}`,{method:t})}static invalidParams(t,n){return new Ae(-32602,`Invalid params${n?`: ${n}`:""}`,t)}static internalError(t,n){return new Ae(-32603,`Internal error${n?`: ${n}`:""}`,t)}static authRequired(t,n){return new Ae(-32e3,`Authentication required${n?`: ${n}`:""}`,t)}static resourceNotFound(t){return new Ae(-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?/,_D=/^\[[^\n]*Working directory:[^\n]*\]\n\n?/,kD=/\[Television screen context\][\s\S]*?\[\/Television screen context\]\n*/,xD=/\b(tv|television|screen|artifact|artifacts|viewer|filmstrip|layout|focus|pinned)\b/i,ED=/\[\[\s*(?:reply_to_current|reply_to\s*:\s*[^\]\n]+|audio_as_voice)\s*\]\]\s*/gi,AD="single_session",$D={name:"television-acp-client",version:"0.0.0"},Xv="agent:main:television",ID=_o(Ht);var se,Jt,si,Qt,rn,nn,sn,on,vr,oi,Ot,We,er,ai,an,tr,yr,Cs,rr,yt,Va,nr,I,Kv,Jv,Qv,Kc,ey,ty,ry,ny,iy,sy,oy,Wr,Zn,Vn,je,ay,Bn,Jc,Qc,la,ly,cy,Ps,Rs,eu,Gn,uy,hy;class TD extends ID{constructor(t){super();w(this,I);w(this,se,PD());w(this,Jt,null);w(this,si,null);w(this,Qt,null);w(this,rn,null);w(this,nn,null);w(this,sn,null);w(this,on);w(this,vr,null);w(this,oi,1);w(this,Ot,null);w(this,We,null);w(this,er,!1);w(this,ai,!1);w(this,an,!1);w(this,tr,null);w(this,yr,new Set);w(this,Cs);w(this,rr);w(this,yt);w(this,Va,t=>{f(this,I,Jv).call(this,t)});w(this,nr,null);w(this,Ps,()=>{f(this,I,Gn).call(this,"ACP bridge websocket closed")});w(this,Rs,()=>{f(this,I,Gn).call(this,"ACP bridge websocket error")});_(this,rr,t),_(this,yt,t.sessionMode??AD),_(this,on,t.mappedSessionStore??CD()),_(this,Cs,t.createSocket??(n=>new WebSocket(n)))}getState(){return l(this,se)}get messages(){return l(this,se).messageOrder.map(t=>l(this,se).messagesById[t]).filter(t=>t!==void 0)}async connect(){if(this.disposed)throw new Error("ACPClient has been disposed");if(l(this,se).lifecycle.status!=="ready"){f(this,I,je).call(this,{lifecycle:{status:"connecting"}}),l(this,si)??_(this,si,f(this,I,Kv).call(this));try{await l(this,si),await f(this,I,Kc).call(this)}catch(t){throw f(this,I,Gn).call(this,Bo(t)),t}}}dispose(){f(this,I,eu).call(this),f(this,I,je).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,se).lifecycle.status!=="ready"||l(this,se).run.status==="running"||l(this,se).run.status==="cancelling")throw new Error("ACPClient is not ready to send a new message");const n=t.text.trim();if(!n)throw new Error("Cannot send an empty message");f(this,I,Zn).call(this,{id:f(this,I,Bn).call(this,"user"),kind:"user",text:n,status:"final"}),f(this,I,je).call(this,{run:{status:"running",stopReason:null,canCancel:!0,error:null}});try{const i=await f(this,I,la).call(this).prompt({sessionId:f(this,I,Qc).call(this),prompt:[{type:"text",text:f(this,I,ay).call(this,n)}]});f(this,I,Wr).call(this,i.stopReason==="cancelled"?"cancelled":"final"),f(this,I,je).call(this,{run:{status:i.stopReason==="cancelled"?"cancelled":"completed",stopReason:i.stopReason,canCancel:!1,error:null}})}catch(i){throw f(this,I,hy).call(this)||(f(this,I,Wr).call(this,"error"),f(this,I,je).call(this,{run:{status:"error",stopReason:null,canCancel:!1,error:Bo(i)}})),i}}async cancel(){if(await this.connect(),!l(this,se).run.canCancel||l(this,se).run.status!=="running")throw new Error("No active cancellable run");f(this,I,je).call(this,{run:{...l(this,se).run,status:"cancelling"}}),await f(this,I,la).call(this).cancel({sessionId:f(this,I,Qc).call(this)})}setScreenContext(t){var s,o,a;if(t===null){if(l(this,We)===null)return;_(this,We,null),_(this,er,!1);return}const n={screenID:t.screenID,screenName:t.screenName};if(((s=l(this,We))==null?void 0:s.screenID)===n.screenID&&((o=l(this,We))==null?void 0:o.screenName)===n.screenName)return;const i=((a=l(this,We))==null?void 0:a.screenID)??null;if(_(this,We,n),l(this,yt)==="single_session"){(!l(this,vr)||i!==n.screenID)&&_(this,er,!0);return}l(this,vr)!==yf(l(this,yt),n.screenID,l(this,rr).clientGUID??"default-client")&&(_(this,Qt,null),_(this,rn,null),l(this,Jt)&&l(this,se).run.status==="idle"&&f(this,I,Kc).call(this).catch(c=>{f(this,I,Gn).call(this,Bo(c))}))}}se=new WeakMap,Jt=new WeakMap,si=new WeakMap,Qt=new WeakMap,rn=new WeakMap,nn=new WeakMap,sn=new WeakMap,on=new WeakMap,vr=new WeakMap,oi=new WeakMap,Ot=new WeakMap,We=new WeakMap,er=new WeakMap,ai=new WeakMap,an=new WeakMap,tr=new WeakMap,yr=new WeakMap,Cs=new WeakMap,rr=new WeakMap,yt=new WeakMap,Va=new WeakMap,nr=new WeakMap,I=new WeakSet,Kv=async function(){try{f(this,I,je).call(this,{lifecycle:{status:"connecting"}});const{stream:t,socket:n,metadata:i}=await LD({serverURL:l(this,rr).serverURL,token:l(this,rr).token,createSocket:l(this,Cs),onDisconnect:l(this,Va)});_(this,sn,i),f(this,I,je).call(this,{bridge:i}),_(this,nr,n),n.addEventListener("close",l(this,Ps)),n.addEventListener("error",l(this,Rs)),_(this,Jt,new bD(s=>({connection:s,sessionUpdate:async o=>{await f(this,I,ty).call(this,o)},requestPermission:async o=>f(this,I,ry).call(this,o)}),t)),await l(this,Jt).initialize({protocolVersion:rC,clientCapabilities:{},clientInfo:$D})}catch(t){throw t}},Jv=function(t){f(this,I,Gn).call(this,Bo(t))},Qv=function(t){const n=t==null?void 0:t.models;if(!(n!=null&&n.currentModelId))return;const i=n.availableModels.find(s=>s.modelId===n.currentModelId);console.info("[ACPClient] Current model:",(i==null?void 0:i.name)??n.currentModelId,`(${n.currentModelId})`)},Kc=async function(){const t=f(this,I,cy).call(this);if(l(this,Qt)&&l(this,rn)===t){await l(this,Qt);return}_(this,rn,t),_(this,Qt,f(this,I,ey).call(this,t)),await l(this,Qt)},ey=async function(t){var c;const n=f(this,I,la).call(this);f(this,I,uy).call(this);let i,s=!1,o=null;const a={cwd:f(this,I,ly).call(this),mcpServers:[],_meta:{sessionKey:t}};try{if(_(this,an,!0),_(this,tr,null),((c=l(this,sn))==null?void 0:c.sessionIdStrategy)==="mapped"){const u=l(this,on).getActualSessionId(t);if(u)try{const h=await n.loadSession({...a,sessionId:u});if(RD(h))throw new Error("Mapped ACP session was not found");o=h,i=u,s=!0}catch{const h=await n.newSession(a);o=h,i=h.sessionId,l(this,on).setActualSessionId(t,i),s=!1}else{const h=await n.newSession(a);o=h,i=h.sessionId,l(this,on).setActualSessionId(t,i),s=!1}}else try{o=await n.loadSession({...a,sessionId:t}),i=t,s=l(this,se).messageOrder.length>0}catch{const u=await n.newSession(a);o=u,i=u.sessionId,s=!1}}finally{_(this,an,!1),_(this,tr,null),f(this,I,Wr).call(this,"final")}f(this,I,Qv).call(this,o),await n.setSessionConfigOption({sessionId:i,configId:"verbose_level",value:"full"}),_(this,nn,i),_(this,vr,t),_(this,ai,!0),s?(l(this,yr).add(t),l(this,yt)==="single_session"&&_(this,er,!1)):(l(this,yr).delete(t),_(this,er,l(this,yt)==="single_session")),f(this,I,je).call(this,{lifecycle:{status:"ready"}})},ty=async function(t){const n=t.update;switch(n.sessionUpdate){case"user_message_chunk":n.content.type==="text"&&f(this,I,oy).call(this,n.content.text);return;case"agent_message_chunk":n.content.type==="text"&&f(this,I,ny).call(this,n.content.text);return;case"tool_call":f(this,I,iy).call(this,n);return;case"tool_call_update":f(this,I,sy).call(this,n);return;case"agent_thought_chunk":return;default:return}},ry=async function(t){return{outcome:{outcome:"cancelled"}}},ny=function(t){_(this,tr,null);const n=DD(t);if(!n)return;if(!l(this,Ot)){const s={id:f(this,I,Bn).call(this,"assistant"),kind:"assistant",text:n,status:"streaming"};_(this,Ot,s.id),f(this,I,Zn).call(this,s);return}const i=l(this,se).messagesById[l(this,Ot)];if(!i||i.kind!=="assistant")throw new Error("Open assistant message invariant violated");f(this,I,Vn).call(this,{...i,text:`${i.text}${n}`,status:"streaming"})},iy=function(t){f(this,I,Wr).call(this,"final");const n=f(this,I,Jc).call(this,t.toolCallId),i=wf("content"in t?t.content:void 0),s={id:(n==null?void 0:n.id)??f(this,I,Bn).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:(n==null?void 0:n.text)??i,locations:t.locations??(n==null?void 0:n.locations)};if(n){f(this,I,Vn).call(this,s);return}f(this,I,Zn).call(this,s)},sy=function(t){const n=f(this,I,Jc).call(this,t.toolCallId),i=(n==null?void 0:n.text)??"",s=wf(t.content),o=s?`${i}${s}`:i,a={id:(n==null?void 0:n.id)??f(this,I,Bn).call(this,"tool"),kind:"tool_call",toolCallId:t.toolCallId,title:(n==null?void 0:n.title)??t.toolCallId,toolKind:(n==null?void 0:n.toolKind)??"other",status:t.status==="failed"?"failed":t.status==="completed"?"completed":"in_progress",text:o,locations:t.locations??(n==null?void 0:n.locations)};if(n){f(this,I,Vn).call(this,a);return}f(this,I,Zn).call(this,a)},oy=function(t){if(f(this,I,Wr).call(this,"final"),!t)return;const n=l(this,an)?l(this,tr):null;if(!n){const s=bf(t);if(!s)return;const o={id:f(this,I,Bn).call(this,"user"),kind:"user",text:s,status:"final"};f(this,I,Zn).call(this,o),l(this,an)&&_(this,tr,o.id);return}const i=l(this,se).messagesById[n];if(!i||i.kind!=="user")throw new Error("Replay user message invariant violated");f(this,I,Vn).call(this,{...i,text:bf(`${i.text}${t}`)})},Wr=function(t){if(!l(this,Ot))return;const n=l(this,se).messagesById[l(this,Ot)];(n==null?void 0:n.kind)==="assistant"&&f(this,I,Vn).call(this,{...n,status:t}),_(this,Ot,null)},Zn=function(t){f(this,I,je).call(this,{messagesById:{...l(this,se).messagesById,[t.id]:t},messageOrder:[...l(this,se).messageOrder,t.id]})},Vn=function(t){f(this,I,je).call(this,{messagesById:{...l(this,se).messagesById,[t.id]:t}})},je=function(t){const n={...l(this,se),...t};_(this,se,{...n,sendDisabled:n.lifecycle.status!=="ready"||n.run.status==="running"||n.run.status==="cancelling",cancelDisabled:!(n.run.status==="running"||n.run.status==="cancelling")||!n.run.canCancel}),this.dispatchEvent(new re("change"))},ay=function(t){const n=l(this,vr);if(!n)return t;const i=l(this,We)?l(this,yt)==="single_session"?l(this,er)||!l(this,yr).has(n):!l(this,yr).has(n):!1,s=l(this,ai)&&(l(this,We)!==null||xD.test(t));if(!(s||i))return t;s&&_(this,ai,!1),i&&(_(this,er,!1),l(this,yr).add(n));const a=["[Television screen context]","This chat session is coming from a Television client.","Television guidance is split across bundled skills.","For screens, lifecycle work, and the `tv` CLI, read the `television` skill.","For artifact authoring, use `tv skills install` or `tv skills show`, then let the matching `artifact-*` skill guide the output."];return l(this,We)?(a.push("This conversation is currently attached to the screen below."),a.push(`screen_id: ${l(this,We).screenID}`),a.push(`screen_name: ${l(this,We).screenName??""}`),a.push("When the user asks to inspect or change Television state with the tv CLI, use this screen ID with the --screen argument.")):a.push("There is currently no active Television screen."),a.push("[/Television screen context]","",t),a.join(`
43
- `)},Bn=function(t){const n=`${t}-${l(this,oi)}`;return _(this,oi,l(this,oi)+1),n},Jc=function(t){for(const n of l(this,se).messageOrder){const i=l(this,se).messagesById[n];if((i==null?void 0:i.kind)==="tool_call"&&i.toolCallId===t)return i}return null},Qc=function(){if(!l(this,nn))throw new Error("ACP session is not ready");return l(this,nn)},la=function(){if(!l(this,Jt))throw new Error("ACP connection is not ready");return l(this,Jt)},ly=function(){var n;const t=(n=l(this,sn))==null?void 0:n.sessionCwd;if(!t)throw new Error("ACP bridge session cwd is not ready");return t},cy=function(){var n;if(l(this,yt)==="single_session")return`${Xv}-${(l(this,rr).clientGUID??"default-client").toLowerCase()}`;const t=(n=l(this,We))==null?void 0:n.screenID;if(!t)throw new Error("Screen context is required for per-screen session mode");return yf(l(this,yt),t,l(this,rr).clientGUID??"default-client")},Ps=new WeakMap,Rs=new WeakMap,eu=function(){_(this,Jt,null),_(this,si,null),_(this,Qt,null),_(this,rn,null),_(this,nn,null),_(this,vr,null),_(this,sn,null),l(this,nr)&&(l(this,nr).removeEventListener("close",l(this,Ps)),l(this,nr).removeEventListener("error",l(this,Rs)),l(this,nr).close(),_(this,nr,null))},Gn=function(t){this.disposed||l(this,se).lifecycle.status==="disconnected"||(f(this,I,Wr).call(this,"error"),f(this,I,eu).call(this),f(this,I,je).call(this,{lifecycle:{status:"disconnected",...t?{error:t}:{}},run:{status:"idle",stopReason:null,canCancel:!1,error:null},bridge:null}))},uy=function(){_(this,Ot,null),_(this,tr,null),_(this,oi,1),f(this,I,je).call(this,{run:{status:"idle",stopReason:null,canCancel:!1,error:null},messagesById:{},messageOrder:[]})},hy=function(){return l(this,se).lifecycle.status==="disconnected"};function CD(){const r=new Map;return{getActualSessionId(e){return r.get(e)??null},setActualSessionId(e,t){r.set(e,t)},clearActualSessionId(e){r.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 RD(r){return r==null?!0:typeof r=="object"&&Object.keys(r).length===0}function yf(r,e,t){return r==="single_session"?`${Xv}-${t.toLowerCase()}`:`agent:main:television-${t.toLowerCase()}-${e.toLowerCase()}`}function dy(r){return r.replace(/^(?:\s*\n)+/,"")}function bf(r){let e=r;return e=e.replace(SD,""),e=e.replace(_D,""),e=e.replace(kD,""),e=dy(e),e}function DD(r){let e=r;return e=e.replace(ED,""),e=dy(e),e}function wf(r){return!r||r.length===0?"":r.flatMap(e=>e.type==="content"&&e.content.type==="text"?[e.content.text]:[]).join("")}async function LD(r){const e=r.createSocket(MD(r.serverURL,r.token));let t=!1,n,i;const s=new Promise((u,h)=>{n=u,i=h}),o=new ReadableStream({start(u){let h=!1;const p=()=>{e.send(JSON.stringify({type:"acp-bridge-connect"}))},v=x=>{const T=OD(x);if(!T)return;let O;try{O=JSON.parse(T)}catch(P){const Z=P instanceof Error?P:new Error(String(P));i(Z),u.error(Z);return}switch(O.type){case"acp-bridge-status":if(O.status==="ready"){let P;try{P=zD(O)}catch(Z){const F=Z instanceof Error?Z:new Error(String(Z));t||i(F),u.error(F);return}t||(t=!0,n(P));return}if(O.status==="error"||O.status==="exited"){const P=new Error(O.error??`ACP bridge ${O.status}`);t||i(P),u.error(P)}return;case"acp-bridge-message":u.enqueue(O.message);return}},m=()=>{var T;if(h)return;h=!0;const x=new Error("ACP bridge websocket closed");t||i(x),(T=r.onDisconnect)==null||T.call(r,x),u.close()},E=()=>{var T;if(h)return;h=!0;const x=new Error("ACP bridge websocket error");t||i(x),(T=r.onDisconnect)==null||T.call(r,x),u.error(x)};e.addEventListener("open",p),e.addEventListener("message",v),e.addEventListener("close",m),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 zD(r){const{agent:e,sessionIdStrategy:t,sessionCwd:n}=r;if((e==="openclaw"||e==="hermes")&&(t==="deterministic"||t==="mapped")&&typeof n=="string"&&n.length>0)return{agent:e,sessionIdStrategy:t,sessionCwd:n};throw new Error("ACP bridge ready status missing bootstrap metadata")}function OD(r){if(typeof r=="string")return r;if(r instanceof Uint8Array)return new TextDecoder().decode(r);if(typeof Buffer<"u"&&r instanceof Buffer)return r.toString("utf8");if(typeof r=="object"&&r!==null&&"data"in r){const e=r.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 MD(r,e){const t=new URL(r);return t.protocol=t.protocol==="https:"?"wss:":"ws:",t.pathname="/acp",t.search="",t.searchParams.set("token",e),t.hash="",t.toString()}function Bo(r){return r instanceof Error?r.message:String(r)}const Sf="television.acpClientGUID",_f="television.acpMappedSessions",kf=1;var li;class ND{constructor(){w(this,li,new Map)}getActualSessionId(e){return l(this,li).get(e)??null}setActualSessionId(e,t){l(this,li).set(e,t)}clearActualSessionId(e){l(this,li).delete(e)}}li=new WeakMap;var ci,Ds,rt,ca,ua,tu;class UD{constructor(e,t){w(this,rt);w(this,ci);w(this,Ds);_(this,ci,e),_(this,Ds,t)}getActualSessionId(e){const t=f(this,rt,ua).call(this)[f(this,rt,ca).call(this,e)];return typeof t=="string"&&t.length>0?t:null}setActualSessionId(e,t){const n=f(this,rt,ua).call(this);n[f(this,rt,ca).call(this,e)]=t,f(this,rt,tu).call(this,n)}clearActualSessionId(e){const t=f(this,rt,ua).call(this);delete t[f(this,rt,ca).call(this,e)],f(this,rt,tu).call(this,t)}}ci=new WeakMap,Ds=new WeakMap,rt=new WeakSet,ca=function(e){return JSON.stringify([l(this,Ds),e])},ua=function(){const e=l(this,ci).getItem(_f);if(!e)return{};let t;try{t=JSON.parse(e)}catch{return{}}if(typeof t!="object"||t===null||Array.isArray(t))return{};const n=t;return n.version!==kf?{}:typeof n.entries!="object"||n.entries===null||Array.isArray(n.entries)?{}:Object.fromEntries(Object.entries(n.entries).filter(i=>typeof i[1]=="string"))},tu=function(e){const t={version:kf,entries:e};l(this,ci).setItem(_f,JSON.stringify(t))};function FD(){return typeof window>"u"?null:window.localStorage}function WD(r){const e=r.getItem(Sf);if(e)return e;const t=hl().toLowerCase();return r.setItem(Sf,t),t}const HD=4401;class ru extends Error{constructor(e="Authentication required"){super(e),this.name="AuthError"}}class py extends Ht{constructor(t){super();y(this,"url");y(this,"name");y(this,"token");y(this,"status","disconnected");y(this,"screens",new Map);y(this,"views",[]);y(this,"client");y(this,"acpClient");y(this,"createSocket");y(this,"createClient");y(this,"socket",null);y(this,"connectAttempt",0);this.url=gt(t.url),this.name=t.name,this.token=t.token??null,this.createSocket=t.createSocket??(i=>new WebSocket(i)),this.createClient=t.createClient??((i,s)=>new sA(i,{token:s??void 0})),this.client=this.createClient(this.url,this.token);const n=t.mappedSessionStore??(t.acpStorage?new UD(t.acpStorage,this.url):new ND);this.acpClient=new TD({serverURL:this.url,token:this.token??"",...t.createACPSocket?{createSocket:t.createACPSocket}:t.createSocket?{createSocket:t.createSocket}:{},...t.clientGUID?{clientGUID:t.clientGUID}:{},mappedSessionStore:n})}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 re("change"));const n=this.createSocket(ZD(this.url,this.token));return this.socket=n,await new Promise((s,o)=>{let a=!1;const c=()=>{a||this.connectAttempt!==t||(a=!0,this.status="connected",this.dispatchEvent(new re("change")),s())},u=p=>{a||this.connectAttempt!==t||(a=!0,this.status="disconnected",this.dispatchEvent(new re("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(m=>[m.id,structuredClone(m)])),this.views=v,this.dispatchEvent(new re("change")),c()}catch(p){u(p instanceof Error?p:new Error(String(p)))}};n.addEventListener("open",()=>{h()}),n.addEventListener("message",p=>{const v=BD(p);v&&(this.applyServerEvent(v),this.dispatchEvent(new Im("server-event",{serverURL:this.url,event:v})))}),n.addEventListener("close",p=>{if(this.connectAttempt===t){if(this.socket=null,VD(p)===HD){u(new ru);return}if(!a){u(new Error("Connection closed before initialization"));return}this.status="disconnected",this.dispatchEvent(new re("change"))}}),n.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 re("change"))}dispose(){this.disconnect(),this.acpClient.dispose()}getViewURL(t){const n=tC(t.type,this.views);if(!n)return null;const i=`${this.url}/views/${encodeURIComponent(n.id)}/`;return this.token===null?i:`${i}?token=${encodeURIComponent(this.token)}`}getContentURL(t){const n=`${this.url}/artifacts/${encodeURIComponent(t)}/content/`;return this.token===null?n:`${n}?token=${encodeURIComponent(this.token)}`}async createScreen(t){const{screen:n}=await this.client.screens.create({name:t});return this.screens.set(n.id,structuredClone(n)),n}async setPinned(t,n){const i=this.screens.get(t);if(!i||i.pinned===n)return;const s=i.pinned;i.pinned=n,this.dispatchEvent(new Hn("screens-changed"));try{await this.client.screens.update({screenID:t,pinned:n})}catch{const o=this.screens.get(t);o&&o.pinned===n&&(o.pinned=s,this.dispatchEvent(new Hn("screens-changed")))}}applyServerEvent(t){switch(t.type){case"screen-created":this.screens.set(t.screen.id,structuredClone(t.screen)),this.dispatchEvent(new Hn("screens-changed"));break;case"screen-updated":this.screens.set(t.screen.id,structuredClone(t.screen)),this.dispatchEvent(new Hn("screens-changed"));break;case"screen-removed":this.screens.delete(t.screenID),this.dispatchEvent(new Hn("screens-changed"));break;case"artifact-created":break;case"artifact-attached":{const n=this.screens.get(t.screenID);n&&!Em(n.layout,t.artifact.id)&&(n.layout=[...n.layout,xm(t.artifact.id,{id:t.cardID})]);break}case"artifact-removed":{const n=this.screens.get(t.screenID);n&&(n.layout=gm(n.layout,t.artifactID));break}}}}function ZD(r,e){const t=new URL(r);return t.protocol=t.protocol==="https:"?"wss:":"ws:",t.pathname="/events",t.search="",e&&t.searchParams.set("token",e),t.hash="",t.toString()}function VD(r){return typeof r=="object"&&r!==null&&"code"in r&&typeof r.code=="number"?r.code:null}function BD(r){const e=typeof r=="string"?r:typeof r=="object"&&r!==null&&"data"in r&&typeof r.data=="string"?r.data:"";if(!e)return null;try{return JSON.parse(e)}catch{return null}}const GD="Local";var Ls,nu;class jD extends Ht{constructor(t){super();w(this,Ls);y(this,"servers",new Map);y(this,"localServerURL");y(this,"clientGUID");y(this,"acpStorage");y(this,"localStore");y(this,"createSocket");y(this,"lastActiveServerURL");y(this,"serverListeners",new Map);y(this,"handleLocalStoreChange",()=>{const t=this.localStore.get().activeServerURL;t!==this.lastActiveServerURL&&(this.lastActiveServerURL=t,this.dispatchEvent(new re("change")))});this.localStore=t.localStore,this.localServerURL=t.localServerURL?gt(t.localServerURL):null,this.createSocket=t.createSocket??(i=>new WebSocket(i)),this.lastActiveServerURL=this.localStore.get().activeServerURL;const n=t.acpStorage===void 0?FD():t.acpStorage;this.acpStorage=n,this.clientGUID=t.clientGUID??(n?WD(n):hl().toLowerCase()),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 n=gt(t.url);this.servers.get(n)&&this.remove(n),this.servers.set(n,t);const s=()=>{this.dispatchEvent(new re("change"))},o=c=>{this.dispatchEvent(new Im("server-event",{serverURL:c.serverURL,event:c.event}))},a=()=>{this.dispatchEvent(new Hn("screens-changed"))};t.addEventListener("change",s),t.addEventListener("server-event",o),t.addEventListener("screens-changed",a),this.serverListeners.set(n,{onServerChange:s,onServerEvent:o,onScreensChanged:a}),this.dispatchEvent(new re("change"))}remove(t){const n=gt(t);if(this.localServerURL&&n===this.localServerURL)return;const i=this.servers.get(n);if(!i)return;const s=this.serverListeners.get(n);s&&(i.removeEventListener("change",s.onServerChange),i.removeEventListener("server-event",s.onServerEvent),i.removeEventListener("screens-changed",s.onScreensChanged),this.serverListeners.delete(n)),i.dispose(),this.servers.delete(n);const o=this.localStore.get(),a=o.activeServerURL===n;this.localStore.set({...o,servers:o.servers.filter(c=>c.url!==n),activeServerURL:a?null:o.activeServerURL}),this.dispatchEvent(new re("change"))}setActive(t){const n=this.localStore.get(),i=t?gt(t.url):null;n.activeServerURL!==i&&this.localStore.set({...n,activeServerURL:i})}connectConfiguredServers(t,n){const i=t?gt(t):null;if(i){const a=this.localStore.get();a.servers.some(u=>gt(u.url)===i)||this.localStore.set({...a,servers:[...a.servers,{url:i,name:GD}]})}const s=this.localStore.get().servers;for(const a of s){const c=gt(a.url),u=i!==null&&c===i,h=f(this,Ls,nu).call(this,{url:a.url,name:a.name,token:u?n??null:null});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,n){const i=gt(t);this.remove(i);const s=this.localStore.get();this.localStore.set({...s,servers:[...s.servers.filter(a=>gt(a.url)!==i),{url:i,name:n}]});const o=f(this,Ls,nu).call(this,{url:i,name:n,token:null});this.add(o),this.setActive(o),o.connect().catch(()=>{})}removeServer(t){this.remove(t)}}Ls=new WeakSet,nu=function(t){return new py({url:t.url,name:t.name,token:t.token,createSocket:this.createSocket,clientGUID:this.clientGUID,acpStorage:this.acpStorage})};var zs;class qD extends Ht{constructor(){super();w(this,zs,t=>{const n=YD(t);n!==null&&(t.preventDefault(),this.dispatchEvent(new $E("shortcut-triggered",{shortcut:n})))});document.addEventListener("keydown",l(this,zs))}dispose(){document.removeEventListener("keydown",l(this,zs))}}zs=new WeakMap;function YD(r){for(const[e,t]of Object.entries(oA))if(XD(r,t.trigger))return e;return null}function XD(r,e){return!(r.key.toLowerCase()!==e.key.toLowerCase()||r.metaKey!==!!e.meta||r.ctrlKey!==!!e.ctrl||r.shiftKey!==!!e.shift||r.altKey!==!!e.alt)}const KD="serverURL",JD="token",QD="mode",eL="electron";function fy(r=window.location.search,e=window.location.origin){const n=new URLSearchParams(r).get(KD);return n?new URL(n).origin:new URL(e).origin}function xf(r=window.location.search){return new URLSearchParams(r).get(JD)}function Ah(r=window.location.search){return new URLSearchParams(r).get(QD)===eL}/**
44
- * @license
45
- * Copyright 2017 Google LLC
46
- * SPDX-License-Identifier: BSD-3-Clause
47
- */const ds=globalThis,Ef=r=>r,za=ds.trustedTypes,Af=za?za.createPolicy("lit-html",{createHTML:r=>r}):void 0,gy="$lit$",pr=`lit$${Math.random().toFixed(9).slice(2)}$`,my="?"+pr,tL=`<${my}>`,wn=document,vs=()=>wn.createComment(""),ys=r=>r===null||typeof r!="object"&&typeof r!="function",$h=Array.isArray,rL=r=>$h(r)||typeof(r==null?void 0:r[Symbol.iterator])=="function",fc=`[
48
- \f\r]`,Gi=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,$f=/-->/g,If=/>/g,Mr=RegExp(`>|${fc}(?:([^\\s"'>=/]+)(${fc}*=${fc}*(?:[^
49
- \f\r"'\`<>=]|("|')|))|$)`,"g"),Tf=/'/g,Cf=/"/g,vy=/^(?:script|style|textarea|title)$/i,nL=r=>(e,...t)=>({_$litType$:r,strings:e,values:t}),U=nL(1),Ai=Symbol.for("lit-noChange"),le=Symbol.for("lit-nothing"),Pf=new WeakMap,qr=wn.createTreeWalker(wn,129);function yy(r,e){if(!$h(r)||!r.hasOwnProperty("raw"))throw Error("invalid template strings array");return Af!==void 0?Af.createHTML(e):e}const iL=(r,e)=>{const t=r.length-1,n=[];let i,s=e===2?"<svg>":e===3?"<math>":"",o=Gi;for(let a=0;a<t;a++){const c=r[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===Gi?h[1]==="!--"?o=$f:h[1]!==void 0?o=If:h[2]!==void 0?(vy.test(h[2])&&(i=RegExp("</"+h[2],"g")),o=Mr):h[3]!==void 0&&(o=Mr):o===Mr?h[0]===">"?(o=i??Gi,p=-1):h[1]===void 0?p=-2:(p=o.lastIndex-h[2].length,u=h[1],o=h[3]===void 0?Mr:h[3]==='"'?Cf:Tf):o===Cf||o===Tf?o=Mr:o===$f||o===If?o=Gi:(o=Mr,i=void 0);const m=o===Mr&&r[a+1].startsWith("/>")?" ":"";s+=o===Gi?c+tL:p>=0?(n.push(u),c.slice(0,p)+gy+c.slice(p)+pr+m):c+pr+(p===-2?a:m)}return[yy(r,s+(r[t]||"<?>")+(e===2?"</svg>":e===3?"</math>":"")),n]};class bs{constructor({strings:e,_$litType$:t},n){let i;this.parts=[];let s=0,o=0;const a=e.length-1,c=this.parts,[u,h]=iL(e,t);if(this.el=bs.createElement(u,n),qr.currentNode=this.el.content,t===2||t===3){const p=this.el.content.firstChild;p.replaceWith(...p.childNodes)}for(;(i=qr.nextNode())!==null&&c.length<a;){if(i.nodeType===1){if(i.hasAttributes())for(const p of i.getAttributeNames())if(p.endsWith(gy)){const v=h[o++],m=i.getAttribute(p).split(pr),E=/([.?@])?(.*)/.exec(v);c.push({type:1,index:s,name:E[2],strings:m,ctor:E[1]==="."?oL:E[1]==="?"?aL:E[1]==="@"?lL:wl}),i.removeAttribute(p)}else p.startsWith(pr)&&(c.push({type:6,index:s}),i.removeAttribute(p));if(vy.test(i.tagName)){const p=i.textContent.split(pr),v=p.length-1;if(v>0){i.textContent=za?za.emptyScript:"";for(let m=0;m<v;m++)i.append(p[m],vs()),qr.nextNode(),c.push({type:2,index:++s});i.append(p[v],vs())}}}else if(i.nodeType===8)if(i.data===my)c.push({type:2,index:s});else{let p=-1;for(;(p=i.data.indexOf(pr,p+1))!==-1;)c.push({type:7,index:s}),p+=pr.length-1}s++}}static createElement(e,t){const n=wn.createElement("template");return n.innerHTML=e,n}}function $i(r,e,t=r,n){var o,a;if(e===Ai)return e;let i=n!==void 0?(o=t._$Co)==null?void 0:o[n]:t._$Cl;const s=ys(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(r),i._$AT(r,t,n)),n!==void 0?(t._$Co??(t._$Co=[]))[n]=i:t._$Cl=i),i!==void 0&&(e=$i(r,i._$AS(r,e.values),i,n)),e}class sL{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:n}=this._$AD,i=((e==null?void 0:e.creationScope)??wn).importNode(t,!0);qr.currentNode=i;let s=qr.nextNode(),o=0,a=0,c=n[0];for(;c!==void 0;){if(o===c.index){let u;c.type===2?u=new Ih(s,s.nextSibling,this,e):c.type===1?u=new c.ctor(s,c.name,c.strings,this,e):c.type===6&&(u=new cL(s,this,e)),this._$AV.push(u),c=n[++a]}o!==(c==null?void 0:c.index)&&(s=qr.nextNode(),o++)}return qr.currentNode=wn,i}p(e){let t=0;for(const n of this._$AV)n!==void 0&&(n.strings!==void 0?(n._$AI(e,n,t),t+=n.strings.length-2):n._$AI(e[t])),t++}}let Ih=class by{get _$AU(){var e;return((e=this._$AM)==null?void 0:e._$AU)??this._$Cv}constructor(e,t,n,i){this.type=2,this._$AH=le,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=n,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=$i(this,e,t),ys(e)?e===le||e==null||e===""?(this._$AH!==le&&this._$AR(),this._$AH=le):e!==this._$AH&&e!==Ai&&this._(e):e._$litType$!==void 0?this.$(e):e.nodeType!==void 0?this.T(e):rL(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!==le&&ys(this._$AH)?this._$AA.nextSibling.data=e:this.T(wn.createTextNode(e)),this._$AH=e}$(e){var s;const{values:t,_$litType$:n}=e,i=typeof n=="number"?this._$AC(e):(n.el===void 0&&(n.el=bs.createElement(yy(n.h,n.h[0]),this.options)),n);if(((s=this._$AH)==null?void 0:s._$AD)===i)this._$AH.p(t);else{const o=new sL(i,this),a=o.u(this.options);o.p(t),this.T(a),this._$AH=o}}_$AC(e){let t=Pf.get(e.strings);return t===void 0&&Pf.set(e.strings,t=new bs(e)),t}k(e){$h(this._$AH)||(this._$AH=[],this._$AR());const t=this._$AH;let n,i=0;for(const s of e)i===t.length?t.push(n=new by(this.O(vs()),this.O(vs()),this,this.options)):n=t[i],n._$AI(s),i++;i<t.length&&(this._$AR(n&&n._$AB.nextSibling,i),t.length=i)}_$AR(e=this._$AA.nextSibling,t){var n;for((n=this._$AP)==null?void 0:n.call(this,!1,!0,t);e!==this._$AB;){const i=Ef(e).nextSibling;Ef(e).remove(),e=i}}setConnected(e){var t;this._$AM===void 0&&(this._$Cv=e,(t=this._$AP)==null||t.call(this,e))}},wl=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,n,i,s){this.type=1,this._$AH=le,this._$AN=void 0,this.element=e,this.name=t,this._$AM=i,this.options=s,n.length>2||n[0]!==""||n[1]!==""?(this._$AH=Array(n.length-1).fill(new String),this.strings=n):this._$AH=le}_$AI(e,t=this,n,i){const s=this.strings;let o=!1;if(s===void 0)e=$i(this,e,t,0),o=!ys(e)||e!==this._$AH&&e!==Ai,o&&(this._$AH=e);else{const a=e;let c,u;for(e=s[0],c=0;c<s.length-1;c++)u=$i(this,a[n+c],t,c),u===Ai&&(u=this._$AH[c]),o||(o=!ys(u)||u!==this._$AH[c]),u===le?e=le:e!==le&&(e+=(u??"")+s[c+1]),this._$AH[c]=u}o&&!i&&this.j(e)}j(e){e===le?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}},oL=class extends wl{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===le?void 0:e}},aL=class extends wl{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==le)}},lL=class extends wl{constructor(e,t,n,i,s){super(e,t,n,i,s),this.type=5}_$AI(e,t=this){if((e=$i(this,e,t,0)??le)===Ai)return;const n=this._$AH,i=e===le&&n!==le||e.capture!==n.capture||e.once!==n.once||e.passive!==n.passive,s=e!==le&&(n===le||i);i&&this.element.removeEventListener(this.name,this,n),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 cL{constructor(e,t,n){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=n}get _$AU(){return this._$AM._$AU}_$AI(e){$i(this,e)}}const gc=ds.litHtmlPolyfillSupport;gc==null||gc(bs,Ih),(ds.litHtmlVersions??(ds.litHtmlVersions=[])).push("3.3.2");const Me=(r,e,t)=>{const n=e;let i=n._$litPart$;return i===void 0&&(n._$litPart$=i=new Ih(e.insertBefore(vs(),null),null,void 0,{})),i._$AI(r),i},uL=.5,Rf=.1,Df=8,hL=4,wy=3,Sy=3,dL=4,Yr=255,_y=.2126,ky=.7152,xy=.0722;async function Ey(r){const e=pL(r);if(!e)return"light";try{return await mL(r,e)>=uL?"light":"dark"}catch{return"light"}}function pL(r){if(typeof document.elementsFromPoint!="function")return null;const e=r.getBoundingClientRect(),t=e.left+e.width/2,n=e.top+e.height/2,i=document.elementsFromPoint(t,n);for(const s of i){if(!(s instanceof HTMLElement)||s===r||r.contains(s))continue;const o=window.getComputedStyle(s);if(fL(o))return s}return null}function fL(r){return r.backgroundImage&&r.backgroundImage!=="none"?!0:gL(r.backgroundColor)>0}function gL(r){if(!r)return 0;const e=r.match(/rgba?\(([^)]+)\)/);if(!e)return 0;const t=e[1].split(/[\s,/]+/).filter(Boolean);return t.length===dL?parseFloat(t[wy]):t.length===Sy?1:0}async function mL(r,e){const t=r.getBoundingClientRect(),n=e.getBoundingClientRect(),i={x:Go((t.left-n.left)/n.width),y:Go((t.top-n.top)/n.height),width:Go(t.width/n.width),height:Go(t.height/n.height)},s=window.getComputedStyle(e),o=vL(s.backgroundImage);return o?bL({url:o,surfaceWidth:n.width,surfaceHeight:n.height,region:i}):wL(s.backgroundColor)}function vL(r){const e=r.match(/url\(\s*["']?([^"')]+)["']?\s*\)/);return e?e[1]:null}const Lf=new Map;function yL(r){let e=Lf.get(r);return e||(e=new Promise((t,n)=>{const i=new Image;i.crossOrigin="anonymous",i.onload=()=>t(i),i.onerror=()=>n(new Error(`Failed to load ${r}`)),i.src=r}),Lf.set(r,e),e)}async function bL(r){const e=await yL(r.url),t=Math.max(Df,Math.ceil(r.surfaceWidth*Rf)),n=Math.max(Df,Math.ceil(r.surfaceHeight*Rf)),i=document.createElement("canvas");i.width=t,i.height=n;const s=i.getContext("2d",{willReadFrequently:!0});if(!s)return 1;const o=r.surfaceWidth/r.surfaceHeight,a=e.naturalWidth/e.naturalHeight;let c,u;a>o?(u=n,c=n*a):(c=t,u=t/a);const h=(t-c)/2,p=(n-u)/2;s.drawImage(e,h,p,c,u);const v=Math.max(0,Math.floor(r.region.x*t)),m=Math.max(0,Math.floor(r.region.y*n)),E=Math.max(1,Math.min(t-v,Math.floor(r.region.width*t))),x=Math.max(1,Math.min(n-m,Math.floor(r.region.height*n))),T=s.getImageData(v,m,E,x).data;let O=0,P=0;for(let Z=0;Z<T.length;Z+=hL){const F=T[Z]/Yr,B=T[Z+1]/Yr,N=T[Z+2]/Yr,J=T[Z+wy]/Yr;O+=J*(_y*F+ky*B+xy*N),P+=1}return P>0?O/P:1}function wL(r){const e=r.match(/rgba?\(([^)]+)\)/);if(!e)return 1;const t=e[1].split(/[\s,/]+/).filter(Boolean).map(parseFloat);if(t.length<Sy)return 1;const n=t[0]/Yr,i=t[1]/Yr,s=t[2]/Yr;return _y*n+ky*i+xy*s}function Go(r){return r<0?0:r>1?1:r}const SL=["ghost","glass"],ws=[...SL.flatMap(r=>[`button[variant="${r}"]`,`segmented-control[variant="${r}"]`]),'[material="glass"]'].join(", "),jo=new WeakSet,zf=new WeakSet;function Ay(r){if(zf.has(r))return;zf.add(r);for(const t of r.querySelectorAll(ws))mc(t);if(typeof MutationObserver!="function")return;new MutationObserver(t=>{for(const n of t)if(n.type==="childList")for(const i of n.addedNodes)_L(i,mc);else n.type==="attributes"&&n.target instanceof HTMLElement&&n.target.matches(ws)&&mc(n.target)}).observe(r,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["variant","material"]})}function _L(r,e){if(r instanceof Element){r instanceof HTMLElement&&r.matches(ws)&&e(r);for(const t of r.querySelectorAll(ws))e(t)}}async function mc(r){if(jo.has(r)||r.hasAttribute("tone"))return;jo.add(r);const e=await Ey(r);if(!r.matches(ws)){jo.delete(r);return}if(r.hasAttribute("tone")){jo.delete(r);return}r.setAttribute("tone",e)}const kL="*,*: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;--control-height-xs: 18px;--control-height-sm: 24px;--control-height-md: 28px;--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{border:.5px solid var(--tint-300);border-radius:var(--radius-12);background:var(--tint-100);color:inherit;font:inherit;box-sizing:border-box;transition:background .12s ease,border-color .12s ease,box-shadow .12s ease}input{height:var(--control-height-md);padding:0 10px}textarea{padding:6px 10px;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);box-sizing:border-box;height:var(--control-height-md);padding:0 14px 2px;font:inherit;cursor:default}button,segmented-control{background:var(--color-surface);border:.5px solid var(--tint-200);border-radius:var(--radius-12);box-shadow:var(--shadow-control);color:inherit}button:not([material]):hover:not(:disabled){background:color-mix(in srgb,var(--color-surface) 96%,black)}button:not([material]):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);backdrop-filter:saturate(1.2);-webkit-backdrop-filter:saturate(1.2)}button[variant=ghost]:active:not(:disabled){background:var(--color-overlay-active);backdrop-filter:saturate(1.4);-webkit-backdrop-filter:saturate(1.4);box-shadow:none}button[variant=ghost][data-active]:not(:disabled),button[variant=ghost][data-active]:hover:not(:disabled),button[variant=ghost][aria-pressed=true]:not(:disabled),button[variant=ghost][aria-pressed=true]: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);backdrop-filter:saturate(1.3);-webkit-backdrop-filter:saturate(1.3);box-shadow:none}button[variant=glass],segmented-control[variant=glass]{background:transparent;border:.5px solid color-mix(in srgb,var(--black) var(--alpha-100),transparent);box-shadow:none}button[variant=glass]{backdrop-filter:blur(20px) brightness(.95) saturate(1.5);-webkit-backdrop-filter:blur(20px) brightness(.95) saturate(1.5)}button[variant=glass]:hover:not(:disabled){background:linear-gradient(var(--color-overlay-hover),var(--color-overlay-hover));backdrop-filter:blur(20px) brightness(.95) saturate(1.8);-webkit-backdrop-filter:blur(20px) brightness(.95) saturate(1.8)}button[variant=glass]:active:not(:disabled){background:linear-gradient(var(--color-overlay-active),var(--color-overlay-active));backdrop-filter:blur(20px) brightness(.95) saturate(2.2);-webkit-backdrop-filter:blur(20px) brightness(.95) saturate(2.2)}button[variant=glass][aria-pressed=true]:not(:disabled),button[variant=glass][aria-pressed=true]:hover:not(:disabled),button[variant=glass][aria-expanded=true]:not(:disabled),button[variant=glass][aria-expanded=true]:hover:not(:disabled){background:linear-gradient(var(--color-overlay-active),var(--color-overlay-active));backdrop-filter:blur(20px) brightness(.95) saturate(2);-webkit-backdrop-filter:blur(20px) brightness(.95) saturate(2)}[tone=dark] button[variant=glass],[tone=dark] segmented-control[variant=glass]{border-color:var(--tint-400)}button[material],segmented-control[material]{color:inherit;box-shadow:none}button[material]:hover:not(:disabled){background-image:linear-gradient(var(--color-overlay-hover),var(--color-overlay-hover))}button[material]:active:not(:disabled){background-image:linear-gradient(var(--color-overlay-active),var(--color-overlay-active))}[tone=dark] button[material],[tone=dark] segmented-control[material]{border-color:var(--tint-400)}button:disabled{background:var(--tint-300);border-color:transparent;color:var(--tint-700);box-shadow:none}:where([tone=dark]) button:not([variant]):not([material]):not(:disabled),:where([tone=dark]) button[variant=default]:not([material]):not(:disabled),:where([tone=dark]) segmented-control:not([variant]):not([material]),:where([tone=dark]) segmented-control[variant=default]:not([material]){background:var(--tint-200);border-color:var(--tint-300);box-shadow:inset 0 .5px 0 var(--tint-300)}:where([tone=dark]) button:not([variant]):hover:not(:disabled),:where([tone=dark]) button[variant=default]:hover:not(:disabled){background:var(--tint-300)}:where([tone=dark]) button:not([variant]):active:not(:disabled),:where([tone=dark]) button[variant=default]:active:not(:disabled){background:var(--tint-400);box-shadow:inset 0 1px 2px #0003}:where([tone=light]) button:not([variant]):not([material]):not(:disabled),:where([tone=light]) button[variant=default]:not([material]):not(:disabled),:where([tone=light]) segmented-control:not([variant]):not([material]),:where([tone=light]) segmented-control[variant=default]:not([material]){background:var(--color-surface);border-color:var(--tint-200);box-shadow:var(--shadow-control)}:where([tone=light]) button:not([variant]):hover:not(:disabled){background:color-mix(in srgb,var(--color-surface) 96%,black)}:where([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],segmented-control[size=sm]{height:var(--control-height-sm)}button[size=sm][icon-only]{width:var(--control-height-sm)}button[size=xs]{height:var(--control-height-xs);padding:0 var(--space-6) 1px;border-radius:var(--radius-8)}button[size=xs][icon-only]{width:var(--control-height-xs);padding:0}button[icon-only]{width:var(--control-height-md);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:transparent;border:.5px solid color-mix(in srgb,var(--black) var(--alpha-100),transparent);backdrop-filter:blur(20px) brightness(.95) saturate(1.5);-webkit-backdrop-filter:blur(20px) brightness(.95) saturate(1.5)}[material=glass-frosted]{background:color-mix(in srgb,var(--white) var(--alpha-800),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-100), transparent);--color-overlay-active: color-mix(in srgb, var(--white) var(--alpha-200), transparent)}[tone=dark][material=paper]{background:#000}[tone=dark][material=glass-frosted]{background:color-mix(in srgb,var(--black) 70%,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-50), transparent);--color-overlay-active: color-mix(in srgb, var(--black) var(--alpha-100), 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}ui-popover.dropdown-popover::part(panel){min-width:192px;padding:var(--space-4)}.dropdown-list{display:flex;flex-direction:column;gap:2px}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,dropdown-item[action]: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)}editable-text{display:inline-block;max-width:100%;vertical-align:top}editable-text>.editable-text-span{display:inline-block;max-width:100%;outline:none;overflow:hidden;white-space:nowrap;cursor:inherit;vertical-align:top}editable-text:not([data-editing])>.editable-text-span{text-overflow:ellipsis}editable-text[data-editing]>.editable-text-span{cursor:text}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;inset:0 auto auto 0;margin:0;min-width:192px;max-width:384px;padding:var(--space-16) var(--space-20);border-radius:var(--radius-12);outline:none;z-index:2000}segmented-control{display:inline-flex;align-items:stretch;box-sizing:border-box;height:var(--control-height-md)}segmented-control>button{height:auto}segmented-control[variant=ghost]{background:transparent;box-shadow:none}[tone=dark] segmented-control[variant=ghost]{border-color:var(--tint-400)}segmented-control>button{position:relative}segmented-control>button[icon-only]{width:auto;height:auto;padding:0 var(--space-6)}segmented-control>button:not([variant]):not(:disabled),[tone] segmented-control>button:not([variant]):not(:disabled){background:transparent;border:0;box-shadow:none}segmented-control>button:first-child{border-top-right-radius:0;border-bottom-right-radius:0}segmented-control>button:last-child{border-top-left-radius:0;border-bottom-left-radius:0}segmented-control>button:not(:first-child):not(:last-child){border-radius:0}segmented-control>button:not([variant]):hover:not(:disabled),[tone] segmented-control>button:not([variant]):hover:not(:disabled){background:var(--color-overlay-hover)}segmented-control>button:not([variant]):active:not(:disabled),[tone] segmented-control>button:not([variant]):active:not(:disabled){background:var(--color-overlay-active);box-shadow:none}segmented-control>button:not([variant])[aria-pressed=true]:not(:disabled),segmented-control>button:not([variant])[aria-current]:not([aria-current=false]):not(:disabled),segmented-control>button:not([variant])[aria-expanded=true]:not(:disabled),[tone] segmented-control>button:not([variant])[aria-pressed=true]:not(:disabled),[tone] segmented-control>button:not([variant])[aria-current]:not([aria-current=false]):not(:disabled),[tone] segmented-control>button:not([variant])[aria-expanded=true]:not(:disabled){background:linear-gradient(var(--color-overlay-active),var(--color-overlay-active))}segmented-control>button:not(:last-child):after{content:"";position:absolute;top:0;bottom:0;right:0;width:.5px;background:var(--tint-200);pointer-events:none}[tone=dark] segmented-control>button:not(:last-child):after{background:var(--tint-400)}segmented-control>dropdown-menu{display:inline-flex;align-items:stretch;height:auto}segmented-control>dropdown-menu>[slot=trigger]{height:auto;position:relative}segmented-control>dropdown-menu>[slot=trigger]:not([variant]):not(:disabled),[tone] segmented-control>dropdown-menu>[slot=trigger]:not([variant]):not(:disabled){background:transparent;border:0;box-shadow:none}segmented-control>dropdown-menu:first-child>[slot=trigger]{border-top-right-radius:0;border-bottom-right-radius:0}segmented-control>dropdown-menu:last-child>[slot=trigger]{border-top-left-radius:0;border-bottom-left-radius:0}segmented-control>dropdown-menu:not(:first-child):not(:last-child)>[slot=trigger]{border-radius:0}segmented-control>dropdown-menu>[slot=trigger]:not([variant]):hover:not(:disabled),[tone] segmented-control>dropdown-menu>[slot=trigger]:not([variant]):hover:not(:disabled){background:var(--color-overlay-hover)}segmented-control>dropdown-menu>[slot=trigger]:not([variant]):active:not(:disabled),[tone] segmented-control>dropdown-menu>[slot=trigger]:not([variant]):active:not(:disabled){background:var(--color-overlay-active);box-shadow:none}segmented-control>dropdown-menu>[slot=trigger]:not([variant])[aria-pressed=true]:not(:disabled),segmented-control>dropdown-menu>[slot=trigger]:not([variant])[aria-current]:not([aria-current=false]):not(:disabled),segmented-control>dropdown-menu>[slot=trigger]:not([variant])[aria-expanded=true]:not(:disabled),[tone] segmented-control>dropdown-menu>[slot=trigger]:not([variant])[aria-pressed=true]:not(:disabled),[tone] segmented-control>dropdown-menu>[slot=trigger]:not([variant])[aria-current]:not([aria-current=false]):not(:disabled),[tone] segmented-control>dropdown-menu>[slot=trigger]:not([variant])[aria-expanded=true]:not(:disabled){background:linear-gradient(var(--color-overlay-active),var(--color-overlay-active))}segmented-control[variant=glass]>button,segmented-control[variant=glass]>dropdown-menu{backdrop-filter:blur(20px) brightness(.95) saturate(1.5);-webkit-backdrop-filter:blur(20px) brightness(.95) saturate(1.5)}segmented-control[variant=glass]>button:not(:disabled):hover,segmented-control[variant=glass]>dropdown-menu:has(>[slot=trigger]:not(:disabled):hover){backdrop-filter:blur(20px) brightness(.95) saturate(1.8);-webkit-backdrop-filter:blur(20px) brightness(.95) saturate(1.8)}segmented-control[variant=glass]>button:not(:disabled):active,segmented-control[variant=glass]>dropdown-menu:has(>[slot=trigger]:not(:disabled):active){backdrop-filter:blur(20px) brightness(.95) saturate(2.2);-webkit-backdrop-filter:blur(20px) brightness(.95) saturate(2.2)}segmented-control[variant=glass]>button:not(:disabled)[aria-pressed=true],segmented-control[variant=glass]>button:not(:disabled)[aria-current]:not([aria-current=false]),segmented-control[variant=glass]>dropdown-menu:has(>[slot=trigger]:not(:disabled)[aria-pressed=true]),segmented-control[variant=glass]>dropdown-menu:has(>[slot=trigger]:not(:disabled)[aria-current]:not([aria-current=false])){backdrop-filter:blur(20px) brightness(.95) saturate(1.8);-webkit-backdrop-filter:blur(20px) brightness(.95) saturate(1.8)}segmented-control[variant=glass]>button:not(:disabled)[aria-expanded=true],segmented-control[variant=glass]>dropdown-menu:has(>[slot=trigger]:not(:disabled)[aria-expanded=true]){backdrop-filter:blur(20px) brightness(.95) saturate(2);-webkit-backdrop-filter:blur(20px) brightness(.95) saturate(2)}segmented-control>dropdown-menu:not(:last-child):after{content:"";position:absolute;top:0;bottom:0;right:0;width:.5px;background:var(--tint-200);pointer-events:none}[tone=dark] segmented-control>dropdown-menu:not(:last-child):after{background:var(--tint-400)}ui-pill{display:inline-block;vertical-align:baseline;margin:2px 0;padding:0 var(--space-8);font-size:var(--text-sm);font-weight:500;line-height:1.7;border-radius:var(--radius-full);border:1px solid var(--neutral-300);background:var(--neutral-200);color:var(--neutral-900);white-space:nowrap}ui-pill[color=gray]{border-color:var(--neutral-300);background:var(--neutral-200);color:var(--neutral-900)}ui-pill[color=red]{border-color:var(--red-200);background:var(--red-100);color:var(--red-950)}ui-pill[color=orange]{border-color:var(--orange-200);background:var(--orange-100);color:var(--orange-950)}ui-pill[color=yellow]{border-color:var(--yellow-200);background:var(--yellow-100);color:var(--yellow-950)}ui-pill[color=green]{border-color:var(--green-200);background:var(--green-100);color:var(--green-950)}ui-pill[color=blue]{border-color:var(--blue-200);background:var(--blue-100);color:var(--blue-950)}ui-pill[color=purple]{border-color:var(--purple-200);background:var(--purple-100);color:var(--purple-950)}',Th=new CSSStyleSheet;Th.replaceSync(kL);try{document.adoptedStyleSheets=[...document.adoptedStyleSheets,Th]}catch{}Ay(document);function $y(r){try{r.adoptedStyleSheets=[...r.adoptedStyleSheets,Th]}catch{}Ay(r)}/**
50
- * @license
51
- * Copyright 2017 Google LLC
52
- * SPDX-License-Identifier: BSD-3-Clause
53
- */const Iy={CHILD:2},Ch=r=>(...e)=>({_$litDirective$:r,values:e});class Ty{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,t,n){this._$Ct=e,this._$AM=t,this._$Ci=n}_$AS(e,t){return this.update(e,t)}update(e,t){return this.render(...t)}}/**
54
- * @license
55
- * Copyright 2017 Google LLC
56
- * SPDX-License-Identifier: BSD-3-Clause
57
- */let Oa=class extends Ty{constructor(e){if(super(e),this.it=le,e.type!==Iy.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(e){if(e===le||e==null)return this._t=void 0,this.it=e;if(e===Ai)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:[]}}};Oa.directiveName="unsafeHTML",Oa.resultType=1;const xL=Ch(Oa);/**
58
- * @license
59
- * Copyright 2017 Google LLC
60
- * SPDX-License-Identifier: BSD-3-Clause
61
- */class iu extends Oa{}iu.directiveName="unsafeSVG",iu.resultType=2;const EL=Ch(iu),AL={size:16,color:"currentColor",weight:"regular"};function $L(r){return typeof r=="string"?{regular:r}:r}function $n(r,e="0 0 256 256"){const t=$L(r);return n=>{const{size:i,color:s,weight:o}={...AL,...n},a=t[o]??t.regular;return U`<svg
62
- xmlns="http://www.w3.org/2000/svg"
63
- data-ui-icon=""
64
- width="${i}"
65
- height="${i}"
66
- viewBox="${e}"
67
- fill="${s}"
68
- >${EL(a)}</svg>`}}/**
69
- * @license
70
- * Copyright 2020 Google LLC
71
- * SPDX-License-Identifier: BSD-3-Clause
72
- */const IL=r=>r.strings===void 0;/**
73
- * @license
74
- * Copyright 2017 Google LLC
75
- * SPDX-License-Identifier: BSD-3-Clause
76
- */const ps=(r,e)=>{var n;const t=r._$AN;if(t===void 0)return!1;for(const i of t)(n=i._$AO)==null||n.call(i,e,!1),ps(i,e);return!0},Ma=r=>{let e,t;do{if((e=r._$AM)===void 0)break;t=e._$AN,t.delete(r),r=e}while((t==null?void 0:t.size)===0)},Cy=r=>{for(let e;e=r._$AM;r=e){let t=e._$AN;if(t===void 0)e._$AN=t=new Set;else if(t.has(r))break;t.add(r),PL(e)}};function TL(r){this._$AN!==void 0?(Ma(this),this._$AM=r,Cy(this)):this._$AM=r}function CL(r,e=!1,t=0){const n=this._$AH,i=this._$AN;if(i!==void 0&&i.size!==0)if(e)if(Array.isArray(n))for(let s=t;s<n.length;s++)ps(n[s],!1),Ma(n[s]);else n!=null&&(ps(n,!1),Ma(n));else ps(this,r)}const PL=r=>{r.type==Iy.CHILD&&(r._$AP??(r._$AP=CL),r._$AQ??(r._$AQ=TL))};class RL extends Ty{constructor(){super(...arguments),this._$AN=void 0}_$AT(e,t,n){super._$AT(e,t,n),Cy(this),this.isConnected=e._$AU}_$AO(e,t=!0){var n,i;e!==this.isConnected&&(this.isConnected=e,e?(n=this.reconnected)==null||n.call(this):(i=this.disconnected)==null||i.call(this)),t&&(ps(this,e),Ma(this))}setValue(e){if(IL(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(){}}/**
77
- * @license
78
- * Copyright 2020 Google LLC
79
- * SPDX-License-Identifier: BSD-3-Clause
80
- */const ha=()=>new DL;class DL{}const vc=new WeakMap,da=Ch(class extends RL{render(r){return le}update(r,[e]){var n;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=(n=r.options)==null?void 0:n.host,this.rt(this.ct=r.element)),le}rt(r){if(this.isConnected||(r=void 0),typeof this.G=="function"){const e=this.ht??globalThis;let t=vc.get(e);t===void 0&&(t=new WeakMap,vc.set(e,t)),t.get(this.G)!==void 0&&this.G.call(this.ht,void 0),t.set(this.G,r),r!==void 0&&this.G.call(this.ht,r)}else this.G.value=r}get lt(){var r,e;return typeof this.G=="function"?(r=vc.get(this.ht??globalThis))==null?void 0:r.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)}}),LL=$n('<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"/>'),Ph=$n('<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"/>'),Py=$n('<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"/>'),zL=$n({regular:'<path d="M216,64H147.31l34.35-34.34a8,8,0,1,0-11.32-11.32L128,60.69,85.66,18.34A8,8,0,0,0,74.34,29.66L108.69,64H40A16,16,0,0,0,24,80V200a16,16,0,0,0,16,16H216a16,16,0,0,0,16-16V80A16,16,0,0,0,216,64Zm0,136H40V80H216V200Z"/>',bold:'<path d="M216,60H157l27.52-27.52a12,12,0,0,0-17-17L128,55,88.49,15.51a12,12,0,0,0-17,17L99,60H40A20,20,0,0,0,20,80V200a20,20,0,0,0,20,20H216a20,20,0,0,0,20-20V80A20,20,0,0,0,216,60Zm-4,136H44V84H212Z"/>'}),OL=$n({regular:'<path d="M104,40H56A16,16,0,0,0,40,56v48a16,16,0,0,0,16,16h48a16,16,0,0,0,16-16V56A16,16,0,0,0,104,40Zm0,64H56V56h48v48Zm96-64H152a16,16,0,0,0-16,16v48a16,16,0,0,0,16,16h48a16,16,0,0,0,16-16V56A16,16,0,0,0,200,40Zm0,64H152V56h48v48Zm-96,32H56a16,16,0,0,0-16,16v48a16,16,0,0,0,16,16h48a16,16,0,0,0,16-16V152A16,16,0,0,0,104,136Zm0,64H56V152h48v48Zm96-64H152a16,16,0,0,0-16,16v48a16,16,0,0,0,16,16h48a16,16,0,0,0,16-16V152A16,16,0,0,0,200,136Zm0,64H152V152h48v48Z"/>',bold:'<path d="M100,36H56A20,20,0,0,0,36,56v44a20,20,0,0,0,20,20h44a20,20,0,0,0,20-20V56A20,20,0,0,0,100,36ZM96,96H60V60H96ZM200,36H156a20,20,0,0,0-20,20v44a20,20,0,0,0,20,20h44a20,20,0,0,0,20-20V56A20,20,0,0,0,200,36Zm-4,60H160V60h36Zm-96,40H56a20,20,0,0,0-20,20v44a20,20,0,0,0,20,20h44a20,20,0,0,0,20-20V156A20,20,0,0,0,100,136Zm-4,60H60V160H96Zm104-60H156a20,20,0,0,0-20,20v44a20,20,0,0,0,20,20h44a20,20,0,0,0,20-20V156A20,20,0,0,0,200,136Zm-4,60H160V160h36Z"/>'}),ML=$n('<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"/>'),NL=$n({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"/>'});class UL extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}const Of='a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])',yc=4;var Re,Ye,ln,Xe,Os,ui,hi,V,su,ou,Dy,pa,Ly,au,lu,Ms,Ns,cn,zy,cu,Oy,My,fa,jn;class Ry extends HTMLElement{constructor(){super();w(this,V);w(this,Re,!1);w(this,Ye,null);w(this,ln);w(this,Xe,null);w(this,Os,"bottom-start");w(this,ui,!1);w(this,hi,!1);w(this,Ms,t=>{l(this,Re)&&(l(this,ui)||t.composedPath().includes(this)||(this.open=!1))});w(this,Ns,t=>{if(l(this,Re)){if(t.key==="Escape"){t.preventDefault(),this.open=!1;return}t.key==="Tab"&&f(this,V,zy).call(this,t)}});w(this,cn,()=>{l(this,Re)&&f(this,V,fa).call(this)});_(this,ln,this.attachShadow({mode:"open"})),$y(l(this,ln)),f(this,V,ou).call(this,"anchor")}connectedCallback(){this.removeAttribute("popover"),this.hasAttribute("tone")||this.setAttribute("tone","light"),f(this,V,ou).call(this,"open"),f(this,V,jn).call(this),l(this,Re)&&(f(this,V,au).call(this),f(this,V,pa).call(this))}disconnectedCallback(){var t;f(this,V,lu).call(this),(t=l(this,Ye))==null||t.removeAttribute("aria-expanded")}attributeChangedCallback(t){t==="open"?f(this,V,Dy).call(this,this.hasAttribute("open")):t==="material"&&l(this,Re)&&(f(this,V,jn).call(this),f(this,V,pa).call(this))}get open(){return l(this,Re)}set open(t){this.toggleAttribute("open",t)}get anchor(){return l(this,Ye)}set anchor(t){l(this,Ye)!==t&&(l(this,Ye)&&l(this,Ye).removeAttribute("aria-expanded"),_(this,Ye,t),f(this,V,su).call(this),l(this,Re)&&f(this,V,fa).call(this))}}Re=new WeakMap,Ye=new WeakMap,ln=new WeakMap,Xe=new WeakMap,Os=new WeakMap,ui=new WeakMap,hi=new WeakMap,V=new WeakSet,su=function(){l(this,Ye)&&l(this,Ye).setAttribute("aria-expanded",l(this,Re)?"true":"false")},ou=function(t){if(!Object.prototype.hasOwnProperty.call(this,t))return;const n=this,i=n[t];delete n[t],n[t]=i},Dy=function(t){var n,i,s;if(l(this,Re)!==t){if(_(this,Re,t),f(this,V,su).call(this),!this.isConnected){f(this,V,jn).call(this);return}t?(_(this,ui,!0),setTimeout(()=>{_(this,ui,!1)},0),f(this,V,jn).call(this),f(this,V,au).call(this),f(this,V,pa).call(this)):(f(this,V,lu).call(this),(i=(n=l(this,Xe))==null?void 0:n.hidePopover)==null||i.call(n),f(this,V,jn).call(this),(s=l(this,Ye))==null||s.focus(),this.dispatchEvent(new UL))}},pa=function(){l(this,hi)||(_(this,hi,!0),queueMicrotask(()=>{_(this,hi,!1),!(!l(this,Re)||!this.isConnected)&&(f(this,V,Ly).call(this),f(this,V,My).call(this))}))},Ly=function(){var t,n;if(l(this,Xe)){try{(n=(t=l(this,Xe)).showPopover)==null||n.call(t)}catch{}f(this,V,fa).call(this)}},au=function(){document.addEventListener("click",l(this,Ms)),document.addEventListener("keydown",l(this,Ns),!0),window.addEventListener("resize",l(this,cn)),window.addEventListener("scroll",l(this,cn),!0)},lu=function(){document.removeEventListener("click",l(this,Ms)),document.removeEventListener("keydown",l(this,Ns),!0),window.removeEventListener("resize",l(this,cn)),window.removeEventListener("scroll",l(this,cn),!0)},Ms=new WeakMap,Ns=new WeakMap,cn=new WeakMap,zy=function(t){const n=f(this,V,cu).call(this);if(n.length===0){t.preventDefault();return}const i=n[0],s=n[n.length-1],o=f(this,V,Oy).call(this),a=o instanceof HTMLElement&&n.includes(o);t.shiftKey?(!a||o===i)&&(t.preventDefault(),s.focus()):(!a||o===s)&&(t.preventDefault(),i.focus())},cu=function(){if(!l(this,Xe))return[];const t=l(this,Xe).querySelector("slot");if(!(t instanceof HTMLSlotElement))return[];const n=[];for(const i of t.assignedElements({flatten:!0}))if(i instanceof HTMLElement){i.matches(Of)&&n.push(i);for(const s of i.querySelectorAll(Of))n.push(s)}return n},Oy=function(){var n;let t=document.activeElement;for(;t&&((n=t.shadowRoot)!=null&&n.activeElement);)t=t.shadowRoot.activeElement;return t},My=function(){var n;const t=f(this,V,cu).call(this);t.length>0?t[0].focus():(n=l(this,Xe))==null||n.focus()},fa=function(){if(!l(this,Re)||!l(this,Ye)||!l(this,Xe))return;const t=l(this,Ye).getBoundingClientRect(),n=l(this,Xe).getBoundingClientRect(),s=window.innerHeight-t.bottom,o=n.height+yc,a=s<o&&t.top>o?"top-start":"bottom-start";_(this,Os,a);const c=a==="bottom-start"?t.bottom+yc:t.top-n.height-yc,u=t.left;l(this,Xe).style.transform=`translate(${u}px, ${c}px)`,l(this,Xe).setAttribute("data-placement",a)},jn=function(){this.toggleAttribute("open",l(this,Re));const t=this.getAttribute("material")??"paper";Me(l(this,Re)?U`<div
81
- class="panel"
82
- part="panel"
83
- popover="manual"
84
- data-placement=${l(this,Os)}
85
- tabindex="-1"
86
- role="dialog"
87
- material=${t}
88
- level="1"
89
- >
90
- <slot></slot>
91
- </div>`:le,l(this,ln)),_(this,Xe,l(this,ln).querySelector(".panel"))},y(Ry,"observedAttributes",["open","material"]);customElements.get("ui-popover")||customElements.define("ui-popover",Ry);class Ny extends Event{constructor(t){super("dropdown-item-select",{bubbles:!0,composed:!0});y(this,"value");this.value=t}}class FL extends Event{constructor(t){super("select",{bubbles:!0,composed:!0});y(this,"value");this.value=t}}var Ke,bt,br,wr,oe,Us,Fs,L,Fy,ns,Wy,Hy,uu,Zy,is,Hr,un,Ws,Ba,Hs,Ga,Vy,By,hu,ss,du,pu,Yt;class Uy extends HTMLElement{constructor(){super();w(this,L);w(this,Ke,!1);w(this,bt,null);w(this,br,null);w(this,wr);w(this,oe,null);w(this,Us,ha());w(this,Fs,new MutationObserver(t=>f(this,L,Vy).call(this,t)));w(this,un,()=>{f(this,L,is).call(this,!l(this,Ke))});w(this,Ws,t=>{t.key!=="Enter"&&t.key!==" "||(t.preventDefault(),l(this,un).call(this))});w(this,Ba,()=>{l(this,Ke)&&f(this,L,is).call(this,!1)});w(this,Hs,t=>{t instanceof Ny&&(t.stopPropagation(),_(this,Ke,!1),f(this,L,ns).call(this,t.value),f(this,L,Yt).call(this),this.dispatchEvent(new FL(t.value)))});w(this,Ga,()=>{f(this,L,hu).call(this)});_(this,wr,this.attachShadow({mode:"open"})),$y(l(this,wr))}connectedCallback(){this.addEventListener("dropdown-item-select",l(this,Hs)),f(this,L,Fy).call(this),l(this,Fs).observe(this,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["selected","value","slot"]}),f(this,L,Yt).call(this)}disconnectedCallback(){this.removeEventListener("dropdown-item-select",l(this,Hs)),l(this,Fs).disconnect(),f(this,L,pu).call(this)}attributeChangedCallback(t){if(t==="open"){f(this,L,is).call(this,this.hasAttribute("open"));return}f(this,L,Yt).call(this)}get open(){return l(this,Ke)}set open(t){this.toggleAttribute("open",t)}get title(){return this.getAttribute("title")??""}get value(){return l(this,bt)}set value(t){t===null?(f(this,L,Hr).call(this,null,null),f(this,L,Wy).call(this)):f(this,L,ns).call(this,t),f(this,L,Yt).call(this)}close(){f(this,L,is).call(this,!1)}}Ke=new WeakMap,bt=new WeakMap,br=new WeakMap,wr=new WeakMap,oe=new WeakMap,Us=new WeakMap,Fs=new WeakMap,L=new WeakSet,Fy=function(){var n;const t=this.querySelector("dropdown-item[selected]");t&&f(this,L,Hr).call(this,t.value,((n=t.textContent)==null?void 0:n.trim())??null)},ns=function(t){var n;for(const i of l(this,L,uu))i.value===t?(f(this,L,Hr).call(this,t,((n=i.textContent)==null?void 0:n.trim())??null),i.hasAttribute("selected")||i.setAttribute("selected","")):i.hasAttribute("selected")&&i.removeAttribute("selected")},Wy=function(){const t=this.querySelectorAll("dropdown-item[selected]");for(const n of t)n.removeAttribute("selected")},Hy=function(t){for(const n of l(this,L,uu))if(n.value===t)return n;return null},uu=function(){return this.querySelectorAll("dropdown-item")},Zy=function(){return l(this,br)??this.title},is=function(t){l(this,Ke)!==t&&(_(this,Ke,t),f(this,L,Yt).call(this))},Hr=function(t,n){_(this,bt,t),_(this,br,n)},un=new WeakMap,Ws=new WeakMap,Ba=new WeakMap,Hs=new WeakMap,Ga=new WeakMap,Vy=function(t){t.every(i=>i.target instanceof Element?i.target.closest('[slot="trigger"]')!==null:!1)||f(this,L,By).call(this)},By=function(){var n,i;const t=this.querySelector("dropdown-item[selected]");if(t){const s=t.value,o=((n=t.textContent)==null?void 0:n.trim())??null,a=l(this,bt)!==s||l(this,br)!==o;f(this,L,Hr).call(this,s,o),f(this,L,ns).call(this,s),a?f(this,L,Yt).call(this):f(this,L,ss).call(this);return}if(l(this,bt)!==null){const s=f(this,L,Hy).call(this,l(this,bt));if(s){const o=((i=s.textContent)==null?void 0:i.trim())??null,a=l(this,br)!==o;f(this,L,Hr).call(this,l(this,bt),o),f(this,L,ns).call(this,l(this,bt)),a?f(this,L,Yt).call(this):f(this,L,ss).call(this);return}}if(l(this,bt)!==null||l(this,br)!==null){f(this,L,Hr).call(this,null,null),f(this,L,Yt).call(this);return}f(this,L,ss).call(this)},hu=function(){const t=l(this,wr).querySelector('slot[name="trigger"]'),n=t instanceof HTMLSlotElement?t.assignedElements()[0]??null:null;l(this,oe)!==n&&(f(this,L,pu).call(this),_(this,oe,n),l(this,oe)&&(l(this,oe).addEventListener("click",l(this,un)),l(this,oe)instanceof HTMLButtonElement?l(this,oe).hasAttribute("type")||(l(this,oe).type="button"):(l(this,oe).hasAttribute("role")||l(this,oe).setAttribute("role","button"),l(this,oe).hasAttribute("tabindex")||(l(this,oe).tabIndex=0),l(this,oe).addEventListener("keydown",l(this,Ws))))),f(this,L,ss).call(this),f(this,L,du).call(this)},ss=function(){l(this,oe)&&(l(this,oe).setAttribute("data-dropdown-trigger",""),l(this,oe).setAttribute("aria-haspopup","listbox"),l(this,oe).setAttribute("aria-expanded",l(this,Ke)?"true":"false"))},du=function(){const t=l(this,Us).value;if(!t)return;const n=l(this,wr).querySelector("button.fallback-trigger");t.anchor=l(this,oe)??n??null},pu=function(){l(this,oe)&&(l(this,oe).removeEventListener("click",l(this,un)),l(this,oe).removeEventListener("keydown",l(this,Ws)),l(this,oe).removeAttribute("data-dropdown-trigger"),l(this,oe).removeAttribute("aria-haspopup"),l(this,oe).removeAttribute("aria-expanded"),_(this,oe,null))},Yt=function(){this.toggleAttribute("open",l(this,Ke)),Me(U`
92
- <slot name="trigger" @slotchange=${l(this,Ga)}>
93
- <button
94
- class="fallback-trigger"
95
- part="trigger"
96
- type="button"
97
- aria-haspopup="listbox"
98
- aria-expanded=${l(this,Ke)?"true":"false"}
99
- @click=${l(this,un)}
100
- >
101
- <span class="trigger-label" part="trigger-label">${l(this,L,Zy)}</span>
102
- <span class="trigger-icon" part="trigger-icon" aria-hidden="true">
103
- ${Py({size:16})}
104
- </span>
105
- </button>
106
- </slot>
107
- <ui-popover
108
- class="dropdown-popover"
109
- material="glass-frosted"
110
- ?open=${l(this,Ke)}
111
- @close=${l(this,Ba)}
112
- ${da(l(this,Us))}
113
- >
114
- ${l(this,Ke)?U`<div class="dropdown-list" part="list" role="listbox">
115
- <slot></slot>
116
- </div>`:le}
117
- </ui-popover>
118
- `,l(this,wr)),f(this,L,du).call(this),queueMicrotask(()=>f(this,L,hu).call(this))},y(Uy,"observedAttributes",["title","open"]);class WL extends HTMLElement{}class HL extends HTMLElement{}class ZL extends HTMLElement{}var kn,fu,jy,Zs,Vs;class Gy extends HTMLElement{constructor(){super(...arguments);w(this,kn);w(this,Zs,()=>{this.action||f(this,kn,jy).call(this)});w(this,Vs,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,Zs)),this.addEventListener("keydown",l(this,Vs)),f(this,kn,fu).call(this)}disconnectedCallback(){this.removeEventListener("click",l(this,Zs)),this.removeEventListener("keydown",l(this,Vs))}attributeChangedCallback(){f(this,kn,fu).call(this)}get value(){return this.getAttribute("value")??""}get selected(){return this.hasAttribute("selected")}get action(){return this.hasAttribute("action")}}kn=new WeakSet,fu=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")},jy=function(){this.dispatchEvent(new Ny(this.value))},Zs=new WeakMap,Vs=new WeakMap,y(Gy,"observedAttributes",["action","selected","value"]);customElements.get("dropdown-menu")||customElements.define("dropdown-menu",Uy);customElements.get("dropdown-group")||customElements.define("dropdown-group",WL);customElements.get("dropdown-label")||customElements.define("dropdown-label",HL);customElements.get("dropdown-divider")||customElements.define("dropdown-divider",ZL);customElements.get("dropdown-item")||customElements.define("dropdown-item",Gy);class VL extends Event{constructor(t){super("rename",{bubbles:!0,composed:!0});y(this,"value");this.value=t}}var Mt,wt,ae,De,os,Bs,gu,ga,mu,Gs,js,qs;class qy extends HTMLElement{constructor(){super(...arguments);w(this,De);w(this,Mt,"");w(this,wt,!1);w(this,ae,null);w(this,Bs,t=>{l(this,wt)||(t.preventDefault(),f(this,De,gu).call(this))});w(this,Gs,t=>{t.stopPropagation()});w(this,js,t=>{var n,i;t.key==="Enter"?(t.preventDefault(),f(this,De,ga).call(this,!0),(n=l(this,ae))==null||n.blur()):t.key==="Escape"&&(t.preventDefault(),f(this,De,ga).call(this,!1),(i=l(this,ae))==null||i.blur())});w(this,qs,()=>{f(this,De,ga).call(this,!0)})}connectedCallback(){l(this,ae)||(_(this,ae,document.createElement("span")),l(this,ae).className="editable-text-span",this.append(l(this,ae)));const t=this.getAttribute("value");t!==null&&_(this,Mt,t),f(this,De,os).call(this),this.addEventListener("dblclick",l(this,Bs))}disconnectedCallback(){this.removeEventListener("dblclick",l(this,Bs)),l(this,wt)&&f(this,De,mu).call(this)}attributeChangedCallback(t){if(t==="value"){const n=this.getAttribute("value")??"";_(this,Mt,n),l(this,wt)||f(this,De,os).call(this)}}get value(){return l(this,Mt)}set value(t){_(this,Mt,t),l(this,wt)||f(this,De,os).call(this)}startEditing(){l(this,wt)||f(this,De,gu).call(this)}}Mt=new WeakMap,wt=new WeakMap,ae=new WeakMap,De=new WeakSet,os=function(){l(this,ae)&&(l(this,ae).textContent=l(this,Mt))},Bs=new WeakMap,gu=function(){l(this,ae)&&(_(this,wt,!0),l(this,ae).setAttribute("contenteditable","plaintext-only"),l(this,ae).setAttribute("spellcheck","false"),l(this,ae).addEventListener("keydown",l(this,js)),l(this,ae).addEventListener("blur",l(this,qs)),l(this,ae).addEventListener("mousedown",l(this,Gs)),this.toggleAttribute("data-editing",!0),queueMicrotask(()=>{var n;if(!l(this,ae))return;l(this,ae).focus();const t=(n=this.ownerDocument.defaultView)==null?void 0:n.getSelection();t==null||t.selectAllChildren(l(this,ae))}))},ga=function(t){if(!l(this,wt)||!l(this,ae))return;const n=(l(this,ae).textContent??"").trim();_(this,wt,!1),l(this,ae).removeAttribute("contenteditable"),l(this,ae).removeAttribute("spellcheck"),this.toggleAttribute("data-editing",!1),f(this,De,mu).call(this),t&&n.length>0&&n!==l(this,Mt)&&(_(this,Mt,n),this.dispatchEvent(new VL(n))),f(this,De,os).call(this)},mu=function(){var t,n,i;(t=l(this,ae))==null||t.removeEventListener("keydown",l(this,js)),(n=l(this,ae))==null||n.removeEventListener("blur",l(this,qs)),(i=l(this,ae))==null||i.removeEventListener("mousedown",l(this,Gs))},Gs=new WeakMap,js=new WeakMap,qs=new WeakMap,y(qy,"observedAttributes",["value"]);customElements.get("editable-text")||customElements.define("editable-text",qy);class BL extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}var Ys,Tr,vu,ja,Xs,yu;class Yy extends HTMLElement{constructor(){super();w(this,Tr);w(this,Ys);w(this,ja,t=>{t.target===t.currentTarget&&f(this,Tr,vu).call(this)});w(this,Xs,t=>{this.open&&t.key==="Escape"&&f(this,Tr,vu).call(this)});_(this,Ys,this.attachShadow({mode:"open"}))}connectedCallback(){document.addEventListener("keydown",l(this,Xs)),f(this,Tr,yu).call(this)}disconnectedCallback(){document.removeEventListener("keydown",l(this,Xs))}attributeChangedCallback(){f(this,Tr,yu).call(this)}get open(){return this.hasAttribute("open")}}Ys=new WeakMap,Tr=new WeakSet,vu=function(){this.dispatchEvent(new BL)},ja=new WeakMap,Xs=new WeakMap,yu=function(){Me(U`
119
- ${this.open?U`
120
- <div class="backdrop" part="backdrop" @click=${l(this,ja)}>
121
- <slot></slot>
122
- </div>
123
- `:null}
124
- `,l(this,Ys))},y(Yy,"observedAttributes",["open"]);customElements.get("modal-overlay")||customElements.define("modal-overlay",Yy);class GL extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}class jL extends HTMLElement{}var Ks,Js,bu;class Xy extends HTMLElement{constructor(){super();w(this,Js);w(this,Ks);_(this,Ks,this.attachShadow({mode:"open"}))}connectedCallback(){f(this,Js,bu).call(this)}attributeChangedCallback(){f(this,Js,bu).call(this)}get closable(){return this.hasAttribute("closable")}}Ks=new WeakMap,Js=new WeakSet,bu=function(){const t=this.querySelector("panel-page");Me(U`
125
- <section class="panel" part="panel">
126
- <header class="title-bar" part="header">
127
- <h2 class="title" part="title">${(t==null?void 0:t.getAttribute("title"))??""}</h2>
128
- ${this.closable?U`
129
- <button
130
- type="button"
131
- class="title-button"
132
- part="button close-button"
133
- aria-label="Close"
134
- @click=${()=>this.dispatchEvent(new GL)}
135
- >
136
- <span class="close-icon" part="icon close-icon">${Ph({size:16})}</span>
137
- </button>
138
- `:null}
139
- </header>
140
- <slot></slot>
141
- </section>
142
- `,l(this,Ks))},y(Xy,"observedAttributes",["closable"]);customElements.get("panel-view")||customElements.define("panel-view",Xy);customElements.get("panel-page")||customElements.define("panel-page",jL);function Sl(r){return typeof r=="object"&&r!==null}function qL(r){return!Sl(r)||r.type!=="wheel"||typeof r.deltaX!="number"||typeof r.deltaY!="number"||typeof r.shiftKey!="boolean"?!1:!("id"in r)}function YL(r){return!Sl(r)||r.type!=="swipe-move"||typeof r.deltaX!="number"?!1:!("id"in r)}function XL(r){return!Sl(r)||r.type!=="swipe-end"||typeof r.velocityX!="number"?!1:!("id"in r)}function Ky(r){return!Sl(r)||r.type!=="open-artifact"||typeof r.artifactID!="string"?!1:!("id"in r)}function KL(r=window){if(r.parent===r)return;let e=0,t=0;r.document.documentElement&&(r.document.documentElement.style.touchAction="pan-y"),r.addEventListener("wheel",u=>{const h=u;e=h.clientX,t=h.clientY,r.parent.postMessage({type:"wheel",deltaX:h.deltaX,deltaY:h.deltaY,shiftKey:h.shiftKey},"*"),h.preventDefault()},{passive:!1});const n=8,i=100,s=1e3,o=new Map;r.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}),r.addEventListener("pointermove",u=>{const h=u,p=o.get(h.pointerId);if(!p||p.discarded)return;if(!p.active){const x=h.clientX-p.startX,T=h.clientY-p.startY,O=Math.abs(x),P=Math.abs(T);if(O<n&&P<n)return;if(P>=O){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 m=h.timeStamp-i;let E=0;for(let x=0;x<p.samples.length;x+=1){if(p.samples[x].time>=m){E=x;break}E=x+1}if(E>0){const x=Math.max(0,E-1);p.samples.splice(0,x)}r.parent.postMessage({type:"swipe-move",deltaX:v},"*"),h.preventDefault()},{passive:!1}),r.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 m=p.samples[0],E=p.samples[p.samples.length-1],x=E.time-m.time;x>0&&(v=(E.offset-m.offset)/x*s)}r.parent.postMessage({type:"swipe-end",velocityX:v},"*")}),r.addEventListener("pointercancel",u=>{const h=u,p=o.get(h.pointerId);p&&(o.delete(h.pointerId),p.active&&r.parent.postMessage({type:"swipe-end",velocityX:0},"*"))}),r.addEventListener("message",u=>{var x,T;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,m=typeof p.deltaY=="number"?p.deltaY:0;let E=((T=(x=r.document).elementFromPoint)==null?void 0:T.call(x,e,t))??null;for(;E!==null;){const O=r.getComputedStyle(E);if(m!==0){const P=(O.overflowY==="auto"||O.overflowY==="scroll")&&E.scrollHeight>E.clientHeight,Z=m>0?E.scrollTop+E.clientHeight<E.scrollHeight:E.scrollTop>0;if(P&&Z){E.scrollBy(v,m);return}}if(v!==0){const P=(O.overflowX==="auto"||O.overflowX==="scroll")&&E.scrollWidth>E.clientWidth,Z=v>0?E.scrollLeft+E.clientWidth<E.scrollWidth:E.scrollLeft>0;if(P&&Z){E.scrollBy(v,m);return}}E=E.parentElement}r.scrollBy(v,m)});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:(r.parent.postMessage({type:"open-artifact",artifactID:p},"*"),!0)}r.document.addEventListener("click",u=>{const h=u,p=typeof h.composedPath=="function"?h.composedPath():[];let v=null;for(const x of p)if(x instanceof HTMLAnchorElement||x&&x.tagName==="A"){v=x;break}if(v===null)return;const m=v.getAttribute("href");if(m===null)return;let E;try{E=new URL(m,r.document.baseURI).toString()}catch{return}a(E)&&u.preventDefault()},!0);const c=r.navigation;c&&c.addEventListener("navigate",u=>{var p;a((p=u.destination)==null?void 0:p.url)&&u.preventDefault()})}function JL(){return`(${KL.toString()})(window);`}const QL=it(),ez=it(),tz="No handler registered for update-content",rz="handleUpdateContent: handler already registered";function nz(r){return r instanceof Error&&typeof r.message=="string"?r.message:String(r)}const iz=_o(Ht);var di,pi,fi,hn,dn,Qs,Le,wu,Jy,Qy,as,Su,pg;let sz=(pg=class extends iz{constructor(t){super();w(this,Le);w(this,di);w(this,pi);w(this,fi);w(this,hn,null);w(this,dn,null);w(this,Qs,!1);_(this,di,t);const n=t.ownerDocument.defaultView;if(!n)throw new Error("ArtifactView: iframe has no owner window");_(this,pi,n),_(this,fi,i=>f(this,Le,Jy).call(this,i)),l(this,pi).addEventListener("message",l(this,fi))}get content(){return l(this,dn)}set content(t){f(this,Le,Su).call(this),_(this,dn,t),l(this,Qs)&&f(this,Le,wu).call(this,t)}handleUpdateContent(t){if(f(this,Le,Su).call(this),l(this,hn)!==null)throw new Error(rz);_(this,hn,t)}dispose(){l(this,pi).removeEventListener("message",l(this,fi)),_(this,hn,null)}},di=new WeakMap,pi=new WeakMap,fi=new WeakMap,hn=new WeakMap,dn=new WeakMap,Qs=new WeakMap,Le=new WeakSet,wu=function(t){const n={type:"content-updated",content:t};f(this,Le,as).call(this,n)},Jy=function(t){if(this.disposed||t.source!==l(this,di).contentWindow)return;const n=t.data;if(K1(n)){_(this,Qs,!0),this.dispatchEvent(new QL("ready")),l(this,dn)!==null&&f(this,Le,wu).call(this,l(this,dn));return}if(J1(n)){f(this,Le,Qy).call(this,n);return}if(Ky(n)){this.dispatchEvent(new ez("open-artifact",{artifactID:n.artifactID}));return}},Qy=async function(t){const n=l(this,hn);if(n===null){f(this,Le,as).call(this,{type:"response",id:t.id,error:{message:tz}});return}try{await n(t.content)}catch(i){if(this.disposed)return;f(this,Le,as).call(this,{type:"response",id:t.id,error:{message:nz(i)}});return}this.disposed||f(this,Le,as).call(this,{type:"response",id:t.id,result:{}})},as=function(t){const n=l(this,di).contentWindow;n&&n.postMessage(t,"*")},Su=function(){if(this.disposed)throw new Error("ArtifactView is disposed")},pg);async function oz(r){const e=await fetch(r);if(!e.ok)throw new Error(`Failed to fetch artifact content: ${e.status}`);const t=await e.text(),n=new DOMParser().parseFromString(t,"text/html"),i=n.createElement("base");i.href=new URL(r,window.location.href).href,n.head.insertBefore(i,n.head.firstChild);const s=n.createElement("script");s.textContent=JL(),n.head.appendChild(s);const o=new Blob([`<!DOCTYPE html>
143
- ${n.documentElement.outerHTML}`],{type:"text/html"});return URL.createObjectURL(o)}const Mf="television-artifact-bridge",eb=it(),az=it();class lz extends HTMLElement{constructor(){super(...arguments);y(this,"_artifact",null);y(this,"_viewURL",null);y(this,"_contentURL",null);y(this,"_screen",null);y(this,"_subscribedScreen",null);y(this,"_activeView",null);y(this,"_contentState",{kind:"idle"});y(this,"_fetchSequence",0);y(this,"_blobSequence",0);y(this,"_mountedViewURL",null);y(this,"_directRender",!1);y(this,"_blobURL",null);y(this,"_subscribedWebview",null);y(this,"_directRenderMessageListener",null);y(this,"handleScreenContentChanged",t=>{!this._artifact||t.artifactID!==this._artifact.id||this._activeView!==null&&this.refetchContent()});y(this,"handleOpenArtifact",t=>{this.requestFocus(t.artifactID)});y(this,"handleIframeMessage",t=>{const n=this.querySelector("iframe.artifact-frame");!n||n.contentWindow!==t.source||qL(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=n.contentWindow)==null||o.postMessage(s,this.iframeTargetOrigin(n))})});y(this,"handleWebviewIpcMessage",t=>{var o;const n=t.detail??t;if(!n||n.channel!==Mf)return;const i=(o=n.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 n=this._artifact;this._artifact=t,this.render(),n!==null&&n!==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 eb("close-artifact",{artifactID:this._artifact.id,bubbles:!0,composed:!0}))}syncView(){var t,n;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 sz(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(),((n=this._artifact)==null?void 0:n.status)==="committed"&&this.loadBlobFrame(this._contentURL);return}this.teardownView(),this._contentState={kind:"idle"},this.render()}}async saveContent(t){const n=this._screen,i=this._artifact;if(!n||!i)throw new Error("artifact-view: cannot save without a screen and artifact");await n.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,n=this._contentURL,i=this._activeView;if(!i||n===null){this._contentState={kind:"error"},this.render();return}this._contentState={kind:"loading"},(async()=>{try{const s=await fetch(n);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,n=this._contentURL,i=this._activeView;!i||n===null||(async()=>{try{const s=await fetch(n);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 n=this._blobSequence;(async()=>{try{const i=await oz(t);if(n!==this._blobSequence){URL.revokeObjectURL(i);return}this._blobURL=i,this.render();const s=this.querySelector("iframe.artifact-frame");s&&(s.src=i)}catch{if(n!==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=n=>{const i=this.querySelector("iframe.artifact-frame");i&&n.source===i.contentWindow&&Ky(n.data)&&this.requestFocus(n.data.artifactID)};this._directRenderMessageListener=t,window.addEventListener("message",t)}removeDirectRenderMessageListener(){this._directRenderMessageListener!==null&&(window.removeEventListener("message",this._directRenderMessageListener),this._directRenderMessageListener=null)}requestFocus(t){const n=this._screen;n&&n.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 n=this._artifact.externalURL;return Ah()?U`
144
- <webview
145
- class="artifact-frame artifact-content"
146
- src=${n}
147
- allowpopups
148
- ></webview>
149
- `:U`
150
- <iframe
151
- class="artifact-frame artifact-content"
152
- src=${n}
153
- sandbox="allow-scripts"
154
- ></iframe>
155
- `}return this._contentState.kind==="error"?U`
156
- <div class="artifact-content artifact-placeholder">
157
- <em>Failed to load content</em>
158
- </div>
159
- `:this._viewURL!==null||this._directRender?U`
160
- <iframe
161
- class="artifact-frame artifact-content"
162
- src=${this._blobURL??"about:blank"}
163
- sandbox="allow-scripts"
164
- ></iframe>
165
- `:U`
166
- <div class="artifact-content artifact-placeholder">
167
- <em>Artifact unavailable</em>
168
- </div>
169
- `}template(){const t=this._artifact;return U`
170
- ${this.contentTemplate()}
171
- <footer class="artifact-title-bar" drag-handle material="glass-frosted">
172
- <div class="artifact-title-group">
173
- <span class="artifact-title-icon">${LL({size:16})}</span>
174
- <span class="artifact-title">${t.title}</span>
175
- </div>
176
- <button
177
- icon-only
178
- variant="ghost"
179
- class="artifact-close-btn"
180
- @click=${()=>this.handleClose()}
181
- aria-label="Close"
182
- >
183
- ${Ph({size:16})}
184
- </button>
185
- </footer>
186
- `}render(){this._artifact&&(this.setAttribute("type",this._artifact.type),Me(this.template(),this),this.syncWebviewSubscription())}dispatchArtifactWheel(t,n){this.dispatchEvent(new az("artifact-wheel",{bubbles:!0,composed:!0,deltaX:t.deltaX,deltaY:t.deltaY,shiftKey:t.shiftKey,scrollNative:n}))}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 n=t.getAttribute("sandbox")??"";if(!new Set(n.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",lz);const Ee=r=>({type:"px",...r}),ye=r=>({type:"unit",...r}),qo=2;class cz{constructor(e){y(this,"basis");y(this,"min");y(this,"_gap");y(this,"_viewport");y(this,"_unit");this.basis=e.basis,this.min=e.min,this._viewport=e.viewport,this._gap=e.gap??Ee({x:ce,y:ce});const t=this._viewport.x??yn,n=this._viewport.y??Ta,i=this._gap.x??ce,s=this._gap.y??ce,o=t<=OE,a=o?t-i*qo:Math.min(yn,t-i*qo),c=o?n-s*qo:Math.min(Ta,n-s*qo),u=(a-i*(Et-1))/Et,h=(c-s*(nt-1))/nt,p=this.basis.x??0,v=this.basis.y??0,m=this.min.x??0,E=this.min.y??0;this._unit=Ee(o?{x:Math.max(m,u),y:Math.max(E,h)}:{x:Math.max(m,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 ye({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,n=this._unit.y??0,i=this._gap.x??ce,s=this._gap.y??ce,o=e.x==null?void 0:e.x*t+Math.max(0,e.x-1)*i,a=e.y==null?void 0:e.y*n+Math.max(0,e.y-1)*s;return Ee({x:o,y:a})}}const Sn=1e-4,_t=1e-6,uz=40,hz=24;function tb(r,e){return Math.max(0,r-e*2)}function rb(r){const e=[0];for(const t of r)e.push((e[e.length-1]??0)+t);return e}function nb(r){const e=[0];for(let t=0;t<r.length;t+=1){const n=e[t]??0;e.push(n+r[t]+ce)}return e}function ib(r,e,t){if(e<0||e>=r.length)return 0;let n=0,i=0;for(let s=e;s<r.length;s+=1){const o=r[s],a=i===0?o:n+ce+o;if(a>t+Sn)break;n=a,i+=1}return Math.max(1,i)}function dz(r,e,t){if(e<0||e>=r.length)return 0;let n=0,i=0;for(let s=e;s>=0;s-=1){const o=r[s],a=i===0?o:n+ce+o;if(a>t+Sn)break;n=a,i+=1}return Math.max(1,i)}function pz(r,e){if(r.length===0)return 0;let t=0,n=0;for(let i=r.length-1;i>=0;i-=1){const s=r[i],o=n===0?s:t+ce+s;if(o>e+Sn)break;t=o,n+=1}return Math.max(1,n)}function Rh(r,e){if(r.length===0)return 0;const t=pz(r,e);return Math.max(0,r.length-t)}function Nf(r,e,t){if(r.length===0)return 0;const n=ib(r,e,t),i=Math.min(r.length,e+n);if(i<=e)return 0;const s=r.slice(e,i);return s.reduce((o,a)=>o+a,0)+Math.max(0,s.length-1)*ce}function _u(r,e,t){const n=r[e]??0;return t-n}function qn(r,e,t,n,i){if(r.length===0)return 0;const s=Rh(r,i),o=e[s]??0,a=Math.max(0,Math.min(o,t));let c=0;for(let B=0;B<s;B+=1){const N=e[B]??0,J=e[B+1]??N;if(a>=N&&a<=J+Sn){c=B;break}c=B+1}const u=Math.min(c+1,s),h=e[c]??0,p=e[u]??h,v=Math.max(p-h,Sn),m=u===c?0:(a-h)/v,E=nb(r),x=Nf(r,c,i),T=Nf(r,u,i),O=(n-x)/2,P=(n-T)/2,Z=_u(E,c,O),F=_u(E,u,P);return Z+(F-Z)*m}function fz(r,e,t,n,i){const s=Rh(r,n),o=e[s]??0;let a=0,c=o;for(let u=0;u<uz;u+=1){const h=(a+c)/2;qn(r,e,h,t,n)>i?a=h:c=h}return(a+c)/2}function gz(r,e,t){const n=nb(r),[i,s]=e,o=r.slice(i,s+1),a=o.reduce((u,h)=>u+h,0)+Math.max(0,o.length-1)*ce,c=(t-a)/2;return _u(n,i,c)}function mz(r,e,t){const n=ib(r,e,t);return[e,Math.min(r.length-1,e+n-1)]}function vz(r,e,t){const n=dz(r,e,t);return[Math.max(0,e-n+1),e]}function yz(r,e){return r[0]===e[0]&&r[1]===e[1]}function bz(r){const{nodeCols:e,nodeWidthsPx:t,viewportWidthPx:n}=r;if(e.length===0||t.length===0)return{viewspans:[],minScroll:0,maxScroll:0};const i=t.length,s=r.gapPx??ce,o=tb(n,s),a=rb(e),c=Rh(t,o),u=a[c]??0;function h(T){const O=gz(t,T,n),P=fz(t,a,n,o,O);return{nodeRange:T,anchor:Math.max(0,Math.min(u,P))}}const p=[];for(let T=0;T<i;){const O=mz(t,T,o);p.push(h(O)),T=O[1]+1}const v=h(vz(t,i-1,o)),m=p.filter(T=>T.nodeRange[0]<v.nodeRange[0]),E=m[m.length-1];return{viewspans:E&&yz(E.nodeRange,v.nodeRange)?m:[...m,v],minScroll:0,maxScroll:u}}function Fn(r,e){var i;let t=0,n=Number.POSITIVE_INFINITY;for(let s=0;s<r.length;s+=1){const o=Math.abs((((i=r[s])==null?void 0:i.anchor)??0)-e);if(o+_t<n){n=o,t=s;continue}Math.abs(o-n)<=_t&&s<t&&(t=s)}return t}function wz(r,e,t){return t<=0?0:Math.max(0,Math.min(t-1,r+e))}function Nr(r,e,t){return Math.max(e,Math.min(t,r))}function Sz(r,e){var t;for(let n=0;n<r.length;n+=1)if(Math.abs((((t=r[n])==null?void 0:t.anchor)??0)-e)<=_t)return n;return-1}function _z(r,e,t){var i,s;if(r.length===0)return e;const n=Sz(r,e);if(n>=0){const o=r[n+t];return(o==null?void 0:o.anchor)??r[t>0?r.length-1:0].anchor}if(t>0){for(const o of r)if(o.anchor>e+_t)return o.anchor;return((i=r[r.length-1])==null?void 0:i.anchor)??e}for(let o=r.length-1;o>=0;o-=1){const a=r[o];if(a&&a.anchor<e-_t)return a.anchor}return((s=r[0])==null?void 0:s.anchor)??e}class kz extends Ht{constructor(t){super();y(this,"_scroll",0);y(this,"_minScroll",0);y(this,"_maxScroll",0);y(this,"_viewspans",[]);y(this,"_activeViewspanIndex",0);y(this,"_nodeWidthsPx",[]);y(this,"_boundaryCols",[0]);y(this,"_viewportWidthPx",0);y(this,"_framedViewportWidthPx",0);this._scroll=(t==null?void 0:t.x)??0}get scroll(){return ye({x:this._scroll})}get translate(){return Ee({x:qn(this._nodeWidthsPx,this._boundaryCols,this._scroll,this._viewportWidthPx,this._framedViewportWidthPx)})}get activeViewspan(){return this._viewspans[this._activeViewspanIndex]??null}get viewspans(){return this._viewspans}set scroll(t){const n=Nr(t.x??this._scroll,this._minScroll,this._maxScroll);Math.abs(n-this._scroll)<=_t||(this._scroll=n,this._activeViewspanIndex=Fn(this._viewspans,this._scroll),this.dispatchEvent(new Un("layout-scroll",{scroll:this.scroll})))}rebuild(t){var v;const n=t.nodeWidths.map(m=>Math.max(0,m.x??0)),i=n.map(m=>t.grid.toPixels(ye({x:m})).x??0),s=t.grid.viewport.x??0,o=t.grid.gap.x??ce,a=bz({nodeCols:n,nodeWidthsPx:i,viewportWidthPx:s,gapPx:o});this._nodeWidthsPx=i,this._boundaryCols=rb(n),this._viewportWidthPx=s,this._framedViewportWidthPx=tb(s,o),this._viewspans=a.viewspans,this._minScroll=a.minScroll,this._maxScroll=a.maxScroll;const c=Nr(this._scroll,this._minScroll,this._maxScroll);this._activeViewspanIndex=Fn(this._viewspans,c);const h=t.snap!==!1?((v=this._viewspans[this._activeViewspanIndex])==null?void 0:v.anchor)??c:c,p=Nr(h,this._minScroll,this._maxScroll);Math.abs(p-this._scroll)>_t&&(this._scroll=p,this.dispatchEvent(new Un("layout-scroll",{scroll:this.scroll})))}step(t){var o;if(this._viewspans.length===0)return;const n=wz(this._activeViewspanIndex,t,this._viewspans.length),i=((o=this._viewspans[n])==null?void 0:o.anchor)??this._scroll,s=Nr(i,this._minScroll,this._maxScroll);this._activeViewspanIndex=n,!(Math.abs(s-this._scroll)<=_t)&&(this._scroll=s,this.dispatchEvent(new Un("layout-scroll",{scroll:this.scroll})))}snap(t){var s;if(this._viewspans.length===0)return;const n=t===void 0?((s=this._viewspans[Fn(this._viewspans,this._scroll)])==null?void 0:s.anchor)??this._scroll:_z(this._viewspans,this._scroll,t),i=Nr(n,this._minScroll,this._maxScroll);this._activeViewspanIndex=Fn(this._viewspans,i),!(Math.abs(i-this._scroll)<=_t)&&(this._scroll=i,this.dispatchEvent(new Un("layout-scroll",{scroll:this.scroll})))}wheel(t){const n=Nr(this._scroll+(t.x??0),this._minScroll,this._maxScroll);Math.abs(n-this._scroll)<=_t||(this._scroll=n,this._activeViewspanIndex=Fn(this._viewspans,this._scroll),this.dispatchEvent(new Un("layout-scroll",{scroll:this.scroll})))}wheelPixels(t){const n=t.x??0;if(Math.abs(n)<=Sn)return;const i=qn(this._nodeWidthsPx,this._boundaryCols,this._scroll,this._viewportWidthPx,this._framedViewportWidthPx),s=i-n,o=qn(this._nodeWidthsPx,this._boundaryCols,this._maxScroll,this._viewportWidthPx,this._framedViewportWidthPx),a=qn(this._nodeWidthsPx,this._boundaryCols,this._minScroll,this._viewportWidthPx,this._framedViewportWidthPx),c=Math.max(o,Math.min(a,s));if(Math.abs(c-i)<=Sn)return;let u=this._minScroll,h=this._maxScroll;for(let v=0;v<hz;v+=1){const m=(u+h)/2;qn(this._nodeWidthsPx,this._boundaryCols,m,this._viewportWidthPx,this._framedViewportWidthPx)>c?u=m:h=m}const p=Nr((u+h)/2,this._minScroll,this._maxScroll);Math.abs(p-this._scroll)<=_t||(this._scroll=p,this._activeViewspanIndex=Fn(this._viewspans,this._scroll),this.dispatchEvent(new Un("layout-scroll",{scroll:this.scroll})))}}const bc={"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}},xz=["stack-above","stack-below","reorder-before","reorder-after"];function wc(r,e){return{left:r.left+r.width*e.left,top:r.top+r.height*e.top,width:r.width*e.width,height:r.height*e.height}}function Ur(r,e,t){return r>=t.left&&r<t.left+t.width&&e>=t.top&&e<t.top+t.height}function ku(r){return Number.isFinite(r)?Math.max(gs,Math.min(ph,Math.round(r))):gs}function Ez(r,e,t){const n=r.findIndex(a=>a.type==="card"&&a.id===e);if(n===-1)return r;const i=r[n];if(!i||i.type!=="card")return r;const s=ku(t);if(i.width===s)return r;const o=[...r];return o[n]={...i,width:s},o}function Dh(r,e){for(const t of r){if(t.type==="card"&&t.id===e)return t;if(t.type==="stack")for(const n of t.children){if(n.type==="card"&&n.id===e)return n;if(n.type==="row"){for(const i of n.children)if(i.id===e)return i}}}return null}function xu(r){return r.height===nt||r.height===Er?{...r,height:Er}:r}function Eu(r){return r.height===Er?{...r,height:nt}:r}function Az(r,e,t,n){const i=r.findIndex(h=>h.type==="stack"&&h.id===e);if(i===-1)return r;const s=r[i];if(!s||s.type!=="stack")return r;const o=s.children.find(h=>h.type==="card"&&h.id===t);if(!o||o.type!=="card")return r;const a=s.children.filter(h=>h.id!==t);if(a.length===s.children.length||a.length<1)return r;const c=[...r];if(a.length===1){const[h]=a;c[i]=h.type==="card"?Eu(h):h}else c[i]={...s,children:a};const u=Math.max(0,Math.min(n,c.length));return c.splice(u,0,Eu(o)),c}const $z=it(),Iz=it(),Tz=50;function Cz(r,e){if(r.type!==e.type)return!1;switch(r.type){case"reorder":return e.index===r.index;case"stack":return e.targetCardId===r.targetCardId&&e.position===r.position;case"stack-child-noop":return!0;case"stack-child-extract":return e.toIndex===r.toIndex;case"stack-child-reorder":return e.position===r.position;default:return!1}}function xo(r){return{id:r.id,type:"drop-target",width:r.width,height:r.height}}function Uf(r){return r.map(Rz)}function Pz(r){return r.type==="drop-target"?{id:r.id,type:"card",artifactID:r.id,width:r.width,height:r.height}:r}function Rz(r){return r.type==="drop-target"?{id:r.id,type:"card",artifactID:r.id,width:r.width,height:r.height}:r.type==="stack"?{...r,children:r.children.map(Pz)}:r}function sb(r,e){return r.find(n=>n.type==="card"&&n.id===e)??null}function Ff(r,e){return r.find(n=>n.type==="stack"&&n.id===e)??null}function Dz(r,e){const t=[...e],n=t.findIndex(a=>a.type==="card"&&a.id===r.nodeId);if(n===-1)return null;const i=t[n];if(!i||i.type!=="card")return null;t.splice(n,1);const s=Math.max(0,Math.min(r.lastReorderIndex,t.length));t.splice(s,0,i);const o=t.findIndex(a=>a.type==="card"&&a.id===r.nodeId);return o===-1?null:{base:t,visualDraggedIndex:o}}function Lz(r,e,t,n){const i=[...r.base];i.splice(r.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=sb(n,e.nodeId);if(!a)return null;const c=xu(a),u=xu(o),h=xo(c),p=t.position==="above"?[h,u]:[u,h];return i[s]={id:o.id,type:"stack",children:p},i}function Sc(r,e){return r.parentStackId?Oz(r,e):zz(r,e)}function zz(r,e){const t=r.hitTarget;if(t.type==="reorder"){const n=e[r.sourceIndex];if(!n||n.type!=="card")return[...e];const i=[...e];return i.splice(r.sourceIndex,1),i.splice(t.index,0,xo(n)),i}if(t.type==="stack"){const n=Dz(r,e);return n?Lz(n,r,t,e)??[...e]:[...e]}return[...e]}function Oz(r,e){const t=r.hitTarget;switch(t.type){case"stack-child-reorder":return Mz(r,e,t.position);case"stack-child-extract":return Nz(r,e,t.toIndex);case"stack-child-noop":return Uz(r,e);default:return[...e]}}function Mz(r,e,t){const n=e.findIndex(v=>v.type==="stack"&&v.id===r.parentStackId);if(n===-1)return[...e];const i=e[n];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===r.nodeId);if(o===-1)return[...e];const a=s[o],c=s.filter(v=>v.id!==r.nodeId),u=xo(a),h=t==="above"?[u,...c]:[...c,u],p=[...e];return p[n]={...i,children:h},p}function Nz(r,e,t){if(!r.parentStackId)return[...e];const n=Az(e,r.parentStackId,r.nodeId,t);if(n===e)return[...e];const i=n.findIndex(a=>a.type==="card"&&a.id===r.nodeId);if(i===-1)return[...e];const s=n[i];if(!s||s.type!=="card")return[...e];const o=[...n];return o[i]=xo(s),o}function Uz(r,e){const t=e.findIndex(c=>c.type==="stack"&&c.id===r.parentStackId);if(t===-1)return[...e];const n=e[t];if(!n||n.type!=="stack")return[...e];const i=n.children.findIndex(c=>c.type==="card"&&c.id===r.nodeId);if(i===-1)return[...e];const s=n.children[i];if(!s||s.type!=="card")return[...e];const o=[...e],a=[...n.children];return a[i]=xo(s),o[t]={...n,children:a},o}function Fz(r,e){return e.find(n=>n.type==="stack"&&n.id===r.id)?r.id:hl()}function Wz(r,e,t){if(r.type==="drop-target"){const n=Dh(e,t);if(!n)throw new Error(`finalize: missing dragged card ${t}`);return xu(n)}return r}function Hz(r,e,t){const n=r.children.map(s=>Wz(s,e,t));return{id:Fz(r,e),type:"stack",children:n}}function Zz(r,e,t){if(r.type==="drop-target"){const n=Dh(e,t);if(!n)throw new Error(`finalize: missing dragged card ${t}`);return sb(e,t)!==null?n:Eu(n)}return r.type==="card"||r.type==="row"?r:Hz(r,e,t)}function Vz(r,e,t){return r.map(n=>Zz(n,e,t))}function Bz(r,e){return JSON.stringify(r)===JSON.stringify(e)}const Gz=_o(Ht);class jz extends Gz{constructor(t={}){super();y(this,"pending",null);y(this,"active",null)}start(t){if(this.pending||this.active)return;const n=t.pointer.x??0,i=t.pointer.y??0;this.pending={startX:n,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 n=t.pointer.x??0,i=t.pointer.y??0,s=this.pending;if(s){const u=n-s.startX,h=i-s.startY;Math.hypot(u,h)>=NE&&(this.pending=null,this.active={...s,pointerX:n,pointerY:i,hitTarget:{type:"reorder",index:s.sourceIndex},lastReorderIndex:s.sourceIndex},this.emitDrag(),this.dispatchEvent(new re("change")));return}if(!this.active)return;const o=Sc(this.active,this.active.baseLayout),a=this.getHitTargetForPointer(n,i,t,o),c=a.type==="reorder"?a.index:this.active.lastReorderIndex;this.active.pointerX===n&&this.active.pointerY===i&&Cz(this.active.hitTarget,a)&&this.active.lastReorderIndex===c||(this.active={...this.active,pointerX:n,pointerY:i,hitTarget:a,lastReorderIndex:c},this.emitDrag(),this.dispatchEvent(new re("change")))}drop(){if(this.pending){this.cancel();return}if(!this.active)return;const t=this.active.baseLayout;let n=null;try{const i=Sc(this.active,t),s=Vz(i,t,this.active.nodeId);Bz(s,t)||(n=s)}catch{n=null}this.reset(),n&&this.dispatchEvent(new Iz("drop",{layout:n})),this.dispatchEvent(new re("change"))}cancel(){!this.pending&&!this.active||(this.reset(),this.dispatchEvent(new re("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=Sc(this.active,this.active.baseLayout);this.dispatchEvent(new $z("drag",{nodeId:this.active.nodeId,source:{index:this.active.sourceIndex,parentId:this.active.parentStackId},grabOffset:Ee({x:this.active.grabOffsetX,y:this.active.grabOffsetY}),pointer:Ee({x:this.active.pointerX,y:this.active.pointerY}),size:Ee({x:this.active.width,y:this.active.height}),projectedLayout:t}))}getHitTargetForPointer(t,n,i,s){return this.active?this.isPointerInsideDragBounds(t,n,i.viewport)?this.active.parentStackId?this.getStackChildHitTarget(t,n,i,s):this.getTopLevelCardHitTarget(t,n,i,s):{type:"reorder",index:this.active.sourceIndex}:{type:"reorder",index:0}}getStackChildHitTarget(t,n,i,s){var u;if(!((u=this.active)!=null&&u.parentStackId))return{type:"stack-child-noop"};const o=this.getSourceStackInteractionRect(i.geometry);if(o&&Ur(t,n,o)){const h=o.top+o.height/2;return{type:"stack-child-reorder",position:n<h?"above":"below"}}const a=this.getSourceRemainingSiblingRect(i.geometry);if(a&&Ur(t,n,a)){const h=a.top+a.height/2;return{type:"stack-child-reorder",position:n<h?"above":"below"}}return{type:"stack-child-extract",toIndex:this.getTopLevelReorderIndexForPointer(t,n,i,s)}}getSourceRemainingSiblingRect(t){var s,o;if(!((s=this.active)!=null&&s.parentStackId))return;const n=Ff(this.active.baseLayout,this.active.parentStackId);if(!n)return;const i=n.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 n=t.find(a=>{var c;return a.id===((c=this.active)==null?void 0:c.parentStackId)});if(n)return this.active.sourceStackRect=n.rect,n.rect;const i=Ff(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,n,i,s){var m,E,x;const o=this.getTopLevelZoneNodes(i.geometry,s);if(o.length===0)return{type:"reorder",index:((m=this.active)==null?void 0:m.sourceIndex)??0};const c=(i.effectiveVelocity??0)<=Tz;for(const T of o){const O=T.rect;if(!Ur(t,n,O))continue;const P=this.resolveTopLevelTargetForCard(t,n,T,T.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:((x=this.active)==null?void 0:x.sourceIndex)??0};const h=Math.max(u.rect.left,Math.min(u.rect.left+u.rect.width,t)),p=this.resolveTopLevelTargetForCard(h,n,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,n,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(!Ur(t,n,p.rect))continue;const v=wc(p.rect,bc["reorder-before"]);if(Ur(t,n,v))return p.logicalIndex;const m=wc(p.rect,bc["reorder-after"]);if(Ur(t,n,m))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,n){const i=new Map(n.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,n,i,s,o){const a=i.rect;for(const c of xz){if(!o&&(c==="stack-above"||c==="stack-below"))continue;const u=bc[c],h=wc(a,u);if(Ur(t,n,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,n){let i=null,s=Number.POSITIVE_INFINITY;for(const o of n){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,n,i){return t>=i.left&&t<=i.left+i.width&&n>=i.top&&n<=i.top+i.height}}const Wf=60,qz=80,Hf=.5,Zf=10;class Yz{constructor(){y(this,"awaitingFreshWheelGesture",!1);y(this,"lastWheelEventAt",Number.NEGATIVE_INFINITY);y(this,"lastWheelDeltaX",0);y(this,"activeGestureType","none");y(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:n,deltaX:i,deltaY:s,overArtifactContent:o}=e;t-this.lastWheelGestureAt>=Wf&&(this.activeGestureType="none");const c=n&&s!==0,u=c?s:i,h=Math.abs(u),p=Math.abs(s);return this.activeGestureType==="vertical-artifact"&&o?h>=Hf&&h>=p*Zf?this.classifyHorizontal(t,u):(this.lastWheelGestureAt=t,{type:"scroll-native"}):this.activeGestureType==="horizontal-filmstrip"?!c&&o&&p>0&&p>=h*Zf?(this.activeGestureType="vertical-artifact",this.lastWheelGestureAt=t,{type:"scroll-native"}):this.classifyHorizontal(t,u):h<Hf?(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 n=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)+qz;return this.awaitingFreshWheelGesture&&n<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 Xz=100,Kz=1e3;class Jz{constructor(e,t){y(this,"_status","idle");y(this,"cumulativeOffset",0);y(this,"samples",[]);y(this,"scroll");y(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(Ee({x:-t})))}end(){if(this._status!=="active")return;const e=this.computeVelocityPxPerSec();this.setAnimating(!0),Math.abs(e)<FE?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-Xz;let n=0;for(let i=0;i<this.samples.length;i+=1){if(this.samples[i].time>=t){n=i;break}n=i+1}if(n>0){const i=Math.max(0,n-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],n=t.time-e.time;return n<=0?0:(t.offset-e.offset)/n*Kz}}const Qz=2,Vf=1e3,Yo=1e-4,eO=120,Bf=!1;function tO(r){return r.replace(/["\\]/g,"\\$&")}function Gf(r,e,t){if(r===0)return 0;const n=e.toPixels(ye({y:nt})).y??0;return(t-n)/Qz}function _c(r){const e=r.clientWidth>0?r.clientWidth:yn,t=r.clientHeight>0?r.clientHeight:Ta;let n=0,i=0;if(r.isConnected){const o=getComputedStyle(r);n=parseFloat(o.paddingTop)||0,i=parseFloat(o.paddingBottom)||0}const s=Math.max(1,t-n-i);return{width:e,height:s,offsetY:n}}class rO extends Event{constructor(t){super("scroll",{bubbles:!0,composed:!0});y(this,"scrollPosition");this.scrollPosition=t}}class ob extends Event{constructor(t){super("layout-change",{bubbles:!0,composed:!0});y(this,"layout");this.layout=t}}class nO extends HTMLElement{constructor(){super();y(this,"_layout",[]);y(this,"_scrollPosition",0);y(this,"layoutGrid",null);y(this,"layoutScroll",new kz(ye({x:0})));y(this,"scrollModelKey","");y(this,"resizeObserver",null);y(this,"renderPending",!1);y(this,"animateNextRender",!0);y(this,"wheelGesture",new Yz);y(this,"swipeGesture",new Jz(this.layoutScroll,t=>{this.animateNextRender=t}));y(this,"swipePointerId",null);y(this,"swipeStartX",0);y(this,"swipeStartY",0);y(this,"swipeLastX",0);y(this,"swipeActive",!1);y(this,"swipeShouldSuppressClick",!1);y(this,"swipeListenersAttached",!1);y(this,"wheelIdleSnapTimer",null);y(this,"dragController",new jz);y(this,"dragState",null);y(this,"activeDragPointerId",null);y(this,"dragListenersAttached",!1);y(this,"dragFrame",0);y(this,"lastDragFrameTime",0);y(this,"lastPointerX",0);y(this,"lastPointerY",0);y(this,"pointerVelocityPxPerSec",0);y(this,"scrollVelocityPxPerSec",0);y(this,"motionSampleTime",0);y(this,"motionSampleX",0);y(this,"motionSampleY",0);y(this,"dragTrackOffsetXPx",0);y(this,"previousProjectedLayoutForOffset",null);y(this,"resizeState",null);y(this,"resizeListenersAttached",!1);y(this,"renderContent",()=>U``);y(this,"onDragControllerChange",()=>{this.dragController.status==="idle"&&(this.dragState=null,this.dragTrackOffsetXPx=0,this.previousProjectedLayoutForOffset=null),this.scheduleRender()});y(this,"onDragControllerDrag",t=>{const n=Uf(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,n,t.nodeId,t.source.parentId,s,this.dragTrackOffsetXPx):0,this.previousProjectedLayoutForOffset=n,this.dragState={nodeId:t.nodeId,source:t.source,grabOffset:t.grabOffset,pointer:t.pointer,size:t.size,projectedLayout:t.projectedLayout},this.scheduleRender()});y(this,"onDragControllerDrop",t=>{this.dragState=null,this.dragTrackOffsetXPx=0,this.previousProjectedLayoutForOffset=null,this.commitLayout(t.layout)});y(this,"onLayoutScrollInternal",t=>{const i=t.scroll.x??0;Math.abs(i-this._scrollPosition)<Yo||(this._scrollPosition=i,this.emitScrollPositionChanged(i),this.scheduleRender())});y(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)))});y(this,"handleWheel",t=>{if(this._layout.length===0)return;const n=this.wheelGesture.decide({now:Date.now(),shiftKey:t.shiftKey,deltaX:t.deltaX,deltaY:t.deltaY,overArtifactContent:!1});n.type==="scroll-horizontal"&&(t.preventDefault(),this.applyHorizontalWheel(n.horizontalDelta))});y(this,"handleWindowMessage",t=>{if(this._layout.length===0)return;const n=this.findManagedArtifactFrame(t.source);if(n&&this.isTrustedArtifactFrameMessage(t,n)){if(YL(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(XL(t.data)){this.swipeGesture.status==="active"&&this.swipeGesture.end();return}}});y(this,"handleArtifactWheel",t=>{if(this._layout.length===0)return;const n=this.wheelGesture.decide({now:Date.now(),shiftKey:t.shiftKey,deltaX:t.deltaX,deltaY:t.deltaY,overArtifactContent:!0});if(n.type==="scroll-horizontal"){this.applyHorizontalWheel(n.horizontalDelta);return}n.type==="scroll-native"&&t.scrollNative(t.deltaY)});y(this,"handlePointerDown",t=>{if(t.button!==0||this.dragController.status!=="idle"||this.resizeState)return;const n=t.target;if(!(n instanceof Element))return;const i=n.closest("[data-resize-handle]");if(i){this.beginResize(t,i);return}const s=n.closest("[drag-handle]")!==null,o=n.closest("button, input, textarea, select, a, [role='button']")!==null;if(t.pointerType==="touch"&&!s&&!o&&this._layout.length>0){this.beginSwipeTracking(t);return}if(!s){if(!o){const p=n.closest(".node");if(p&&!p.hasAttribute("data-foreground")){const v=p.getAttribute("layout-node");if(v!==null){const m=parseInt(v,10);if(!isNaN(m)){const E=this.findViewspanContainingNode(m);if(E){this.clearWheelIdleSnap(),this.animateNextRender=!0,this.layoutScroll.scroll=ye({x:E.anchor}),t.preventDefault(),t.stopPropagation();return}}}}}return}if(o)return;const a=n.closest(".card-slot");if(!a)return;const c=a.getAttribute("data-layout-node-id");if(!c)return;const u=sO(this._layout,c);if(!u)return;const h=a.getBoundingClientRect();this.lastPointerX=t.clientX,this.lastPointerY=t.clientY,this.resetMotionTracking(t.clientX,t.clientY),this.focus(),this.dragController.start({nodeId:c,source:{index:u.topLevelIndex,parentId:u.sourceStackId},pointer:Ee({x:t.clientX,y:t.clientY}),grabOffset:Ee({x:t.clientX-h.left,y:t.clientY-h.top}),size:Ee({x:h.width,y:h.height}),layout:this._layout}),this.attachDragListeners(),this.activeDragPointerId=t.pointerId;try{this.setPointerCapture(t.pointerId)}catch{}t.preventDefault()});y(this,"handleResizePointerMove",t=>{const n=this.resizeState;if(!n||t.pointerId!==n.pointerId)return;const i=this.layoutGrid,s=((i==null?void 0:i.unit.x)??dr)+ce;if(s<=0)return;const o=t.clientX-n.startClientX,a=ku(n.startWidth+o/s);a!==n.currentWidth&&(n.currentWidth=a,this.scheduleRender())});y(this,"handleResizePointerUp",t=>{const n=this.resizeState;if(!n||t.pointerId!==n.pointerId)return;const i=n.currentWidth,s=n.startWidth,o=n.cardId;this.endResize(t.pointerId),i!==s?this.commitLayout(Ez(this._layout,o,i)):this.scheduleRender()});y(this,"handleResizePointerCancel",t=>{!this.resizeState||t.pointerId!==this.resizeState.pointerId||(this.endResize(t.pointerId),this.scheduleRender())});y(this,"handleResizeWindowBlur",()=>{this.resizeState&&(this.endResize(this.resizeState.pointerId),this.scheduleRender())});y(this,"handleResizeKeyDown",t=>{this.resizeState&&t.key==="Escape"&&(t.preventDefault(),this.endResize(this.resizeState.pointerId),this.scheduleRender())});y(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<jp&&a<jp)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 n=t.clientX-this.swipeLastX;this.swipeLastX=t.clientX,this.swipeGesture.move(t.timeStamp,n),t.preventDefault()});y(this,"handleSwipePointerUp",t=>{this.swipePointerId===null||t.pointerId!==this.swipePointerId||(this.swipeActive&&this.swipeGesture.end(),this.releaseSwipePointerCapture(t.pointerId),this.endSwipeTracking())});y(this,"handleSwipePointerCancel",t=>{this.swipePointerId===null||t.pointerId!==this.swipePointerId||(this.swipeActive&&this.swipeGesture.cancel(),this.releaseSwipePointerCapture(t.pointerId),this.endSwipeTracking())});y(this,"handleSwipeWindowBlur",()=>{this.swipePointerId!==null&&this.swipeActive&&this.swipeGesture.cancel(),this.swipePointerId!==null&&this.releaseSwipePointerCapture(this.swipePointerId),this.endSwipeTracking()});y(this,"handleSwipeClick",t=>{this.swipeShouldSuppressClick&&(this.swipeShouldSuppressClick=!1,t.preventDefault(),t.stopPropagation(),typeof t.stopImmediatePropagation=="function"&&t.stopImmediatePropagation())});y(this,"handleWindowPointerMove",t=>{this.lastPointerX=t.clientX,this.lastPointerY=t.clientY,this.updatePointerVelocity(t.clientX,t.clientY),this.syncDragTargetForLatestPointer(),this.ensureDragFrameLoop()});y(this,"handleWindowPointerUp",t=>{this.stopDragFrameLoop(),this.releasePointerCaptureForEvent(t.pointerId),this.dragController.drop(),this.clearMotionTracking(),this.detachDragListeners()});y(this,"handleWindowPointerCancel",t=>{this.stopDragFrameLoop(),this.releasePointerCaptureForEvent(t.pointerId),this.dragController.cancel(),this.clearMotionTracking(),this.detachDragListeners()});y(this,"handleWindowBlur",()=>{this.releaseActiveDragPointerCapture(),this.stopDragFrameLoop(),this.dragController.cancel(),this.clearMotionTracking(),this.detachDragListeners()});y(this,"runDragFrame",t=>{if(this.dragController.status==="idle"){this.dragFrame=0;return}const n=Math.max(0,t-this.lastDragFrameTime)/Vf;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,n);this.scrollVelocityPxPerSec=n>Yo?Math.abs(o)/n:0,Math.abs(o)>Yo&&(this.animateNextRender=!1,this.layoutScroll.wheelPixels(Ee({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.resizeState&&this.endResize(this.resizeState.pointerId),this.scrollModelKey="",this.syncScrollModel(),this.layoutScroll.scroll=ye({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)<Yo||(this.animateNextRender=!1,this.syncScrollModel(),this.layoutScroll.scroll=ye({x:t}))}get scrollPosition(){return this._scrollPosition}focusArtifact(t){const n=Kn(this._layout),i=n.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+=n.nodes[o].width;this.scrollPosition=s,queueMicrotask(()=>{const o=this.querySelector(`.card-slot[data-layout-card-id="${tO(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.clearWheelIdleSnap(),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(),this.resizeState&&this.endResize(this.resizeState.pointerId)}scheduleRender(){this.renderPending||(this.renderPending=!0,queueMicrotask(()=>{this.renderPending=!1,this.render()}))}createGrid(t,n){return new cz({basis:Ee({x:dr,y:dr}),min:Ee({x:Bp,y:Bp}),viewport:Ee({x:t,y:n}),gap:Ee({x:ce,y:ce})})}syncScrollModel(){const t=_c(this),i=Kn(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=>ye({x:o})),snap:Bf}))}emitScrollPositionChanged(t){this.dispatchEvent(new rO(t))}emitLayoutChanged(){this.dispatchEvent(new ob([...this._layout]))}shiftWindow(t){this.clearWheelIdleSnap(),this.syncScrollModel(),this.animateNextRender=!0,this.layoutScroll.step(t)}applyHorizontalWheel(t){this.syncScrollModel();const n=this.layoutGrid;if(!n)return;this.animateNextRender=!1;const i=n.toUnits(Ee({x:t}));this.layoutScroll.wheel(ye({x:i.x??0}))}scheduleWheelIdleSnap(){this.clearWheelIdleSnap(),this.wheelIdleSnapTimer=setTimeout(()=>{this.wheelIdleSnapTimer=null,this.animateNextRender=!0,this.layoutScroll.snap()},eO)}clearWheelIdleSnap(){this.wheelIdleSnapTimer!==null&&(clearTimeout(this.wheelIdleSnapTimer),this.wheelIdleSnapTimer=null)}findViewspanContainingNode(t){const n=this.layoutScroll.viewspans,i=this._scrollPosition;let s=null,o=Number.POSITIVE_INFINITY;for(const a of n)if(t>=a.nodeRange[0]&&t<=a.nodeRange[1]){const c=Math.abs(a.anchor-i);c<o&&(o=c,s=a)}return s}findManagedArtifactFrame(t){if(!t)return null;const n=this.querySelectorAll("iframe.artifact-frame");for(const i of n)if(i.contentWindow===t)return i;return null}isTrustedArtifactFrameMessage(t,n){if(t.origin==="null")return!0;const i=this.getArtifactFrameOrigin(n);return i===null||t.origin===i}getArtifactFrameOrigin(t){const n=t.getAttribute("src")??t.src;if(!n)return null;try{return new URL(n,window.location.href).origin}catch{return null}}beginResize(t,n){const i=n.getAttribute("data-resize-handle");if(!i)return;const s=this._layout.find(a=>a.type==="card"&&a.id===i);if(!s)return;const o=ku(typeof s.width=="number"?s.width:Et);this.resizeState={cardId:i,pointerId:t.pointerId,startClientX:t.clientX,startWidth:o,currentWidth:o},this.attachResizeListeners();try{this.setPointerCapture(t.pointerId)}catch{}t.preventDefault(),t.stopPropagation()}attachResizeListeners(){this.resizeListenersAttached||(window.addEventListener("pointermove",this.handleResizePointerMove),window.addEventListener("pointerup",this.handleResizePointerUp),window.addEventListener("pointercancel",this.handleResizePointerCancel),window.addEventListener("blur",this.handleResizeWindowBlur),this.addEventListener("keydown",this.handleResizeKeyDown),this.resizeListenersAttached=!0)}detachResizeListeners(){this.resizeListenersAttached&&(window.removeEventListener("pointermove",this.handleResizePointerMove),window.removeEventListener("pointerup",this.handleResizePointerUp),window.removeEventListener("pointercancel",this.handleResizePointerCancel),window.removeEventListener("blur",this.handleResizeWindowBlur),this.removeEventListener("keydown",this.handleResizeKeyDown),this.resizeListenersAttached=!1)}endResize(t){this.resizeState=null,this.detachResizeListeners();try{this.hasPointerCapture(t)&&this.releasePointerCapture(t)}catch{}}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.applyResizeOverride(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:Uf(this.dragState.projectedLayout),activePlaceholderId:this.dragState.nodeId,placeholdersById:t}}applyResizeOverride(t){const n=this.resizeState;if(!n)return t;const i=t.findIndex(a=>a.type==="card"&&a.id===n.cardId);if(i===-1)return t;const s=t[i];if(!s||s.type!=="card"||s.width===n.currentWidth)return t;const o=[...t];return o[i]={...s,width:n.currentWidth},o}render(){const t=_c(this),n=this.createGrid(t.width,t.height);this.layoutGrid=n;const i=this.getDisplayModel(),s=i.layout,o=this.dragController.status==="active",a=Kn(s),c=a.nodes.map(N=>N.width),u=`${t.width}x${t.height}:${c.join(",")}`;!o&&u!==this.scrollModelKey&&(this.scrollModelKey=u,this.layoutScroll.rebuild({grid:n,nodeWidths:c.map(N=>ye({x:N})),snap:Bf}),this._scrollPosition=this.layoutScroll.scroll.x??this._scrollPosition);const h=iO(s),p=n.unit.x??dr,v=n.unit.y??dr,m=o?this.dragTrackOffsetXPx:0,E=(this.layoutScroll.translate.x??0)+m,x=Gf(a.nodes.length,n,t.height),T=this.animateNextRender&&!o,O=[`transform: translate(${E}px, ${x}px);`,`transition-duration: ${T?ME: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",`${ce}px`);const P=this.dragState,Z={width:(P==null?void 0:P.size.x)??0,height:(P==null?void 0:P.size.y)??0},F=new Set;{for(let J=0;J<a.nodes.length;J+=1)n.toPixels(ye({x:a.nodes[J].width})).x;let N=E;for(let J=0;J<a.nodes.length;J+=1){const j=n.toPixels(ye({x:a.nodes[J].width})).x??0,st=N+j;N>=-1&&st<=t.width+1&&F.add(J),N=st+ce}}const B=N=>F.has(N);Me(U`
187
- <div class="track" style=${O}>
188
- ${a.nodes.map((N,J)=>U`
189
- <div
190
- class="node"
191
- layout-node=${String(J)}
192
- data-layout-node-id=${N.id}
193
- data-layout-placeholder=${String(i.activePlaceholderId===N.id)}
194
- layout-node-cols=${String(N.width)}
195
- ?data-foreground=${B(J)}
196
- style=${`width: ${n.toPixels(ye({x:N.width})).x}px; --card-width-px: ${n.toPixels(ye({x:N.width})).x};`}
197
- >
198
- <div class="node-inner" style=${`grid-template-columns: repeat(${N.width}, var(--layout-unit-x));`}>
199
- ${N.cards.map(j=>{const st=i.placeholdersById.get(j.id);if(P&&st)return U`
200
- <div
201
- class="card-slot card-placeholder"
202
- data-layout-placeholder-for=${P.nodeId}
203
- data-layout-placeholder-ghost="false"
204
- data-layout-source-stack=${P.source.parentId??""}
205
- style=${`grid-column: ${j.col} / span ${j.width}; grid-row: ${j.row} / span ${j.height};`}
206
- ></div>
207
- `;const Zt=h.get(j.id);if(!Zt)return null;const _e=N.type==="card";return U`
208
- <div
209
- class="card-slot"
210
- data-layout-card-id=${j.artifactID}
211
- data-layout-node-id=${j.id}
212
- layout-cols=${String(j.width)}
213
- layout-rows=${String(j.height)}
214
- style=${`grid-column: ${j.col} / span ${j.width}; grid-row: ${j.row} / span ${j.height};`}
215
- >
216
- ${this.renderContent(Zt,{isDragging:!1})}
217
- ${_e?U`<div
218
- class="resize-handle"
219
- data-resize-handle=${j.id}
220
- data-test-resize-handle=${j.id}
221
- ></div>`:null}
222
- </div>
223
- `})}
224
- </div>
225
- </div>
226
- `)}
227
- </div>
228
- ${P?(()=>{const N=this.getPlaceholderPixelSize(a,i.activePlaceholderId,n,Z),J=P.pointer.x??0,j=P.pointer.y??0,st=P.grabOffset.x??0,Zt=P.grabOffset.y??0;return U`
229
- <div
230
- class="drag-preview"
231
- data-layout-preview-card-id=${P.nodeId}
232
- style=${[`width: ${N.width}px;`,`height: ${N.height}px;`,`left: ${J-st}px;`,`top: ${j-Zt}px;`].join(" ")}
233
- >
234
- ${this.renderDraggedPreview(P.nodeId)}
235
- </div>
236
- `})():null}
237
- `,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 n=this.clampPointerToViewport(this.lastPointerX,this.lastPointerY,t);(n.x!==this.lastPointerX||n.y!==this.lastPointerY)&&this.syncDragTarget(n.x,n.y,t)}syncDragTarget(t,n,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:Ee({x:t,y:n}),viewport:{left:i.left,top:i.top,width:i.width,height:i.height},geometry:c,effectiveVelocity:Math.max(this.pointerVelocityPxPerSec,this.scrollVelocityPxPerSec)})}resetMotionTracking(t,n){this.pointerVelocityPxPerSec=0,this.scrollVelocityPxPerSec=0,this.motionSampleTime=performance.now(),this.motionSampleX=t,this.motionSampleY=n}clearMotionTracking(){this.pointerVelocityPxPerSec=0,this.scrollVelocityPxPerSec=0,this.motionSampleTime=0}updatePointerVelocity(t,n){this.samplePointerVelocityAt(performance.now(),t,n)}samplePointerVelocityAt(t,n,i){if(this.motionSampleTime===0){this.motionSampleTime=t,this.motionSampleX=n,this.motionSampleY=i,this.pointerVelocityPxPerSec=0;return}const s=t-this.motionSampleTime;if(s<100)return;const o=n-this.motionSampleX;this.pointerVelocityPxPerSec=Math.abs(o)/s*Vf,this.motionSampleTime=t,this.motionSampleX=n,this.motionSampleY=i}clampPointerToViewport(t,n,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,n))}}isPointerOutsideViewport(t,n,i){return t<i.left||t>i.left+i.width||n<i.top||n>i.top+i.height}getDragEdgeScrollDeltaPixels(t,n,i){var u;const s=n.left+Wo,o=n.left+n.width-Wo,a=((u=this.layoutGrid)==null?void 0:u.unit.x)??dr,c=UE*a;if(t<s){const h=Math.max(0,Math.min(1,(s-t)/Wo));return-(c*h**Gp)*i}if(t>o){const h=Math.max(0,Math.min(1,(t-o)/Wo));return c*h**Gp*i}return 0}measureLayoutGeometry(t,n,i=0){const s=this.layoutGrid;if(!s)return[];const o=Kn(t),a=new Map(o.nodes.map(x=>[x.id,x.width])),c=s.toPixels(ye({y:nt})).y??Ta,u=_c(this),h=(this.layoutScroll.translate.x??0)+i,p=Gf(o.nodes.length,s,u.height),v=u.offsetY+p,m=[];let E=h;for(const x of t){const T=a.get(x.id)??Et,O=s.toPixels(ye({x:T})).x??yn,P={left:E,top:v,width:O,height:c};m.push({id:x.id,rect:P}),E+=O+ce}return m}getPlaceholderPixelSize(t,n,i,s){if(!n)return s;for(const o of t.nodes)for(const a of o.cards)if(a.id===n)return{width:i.toPixels(ye({x:a.width})).x??s.width,height:i.toPixels(ye({y:a.height})).y??s.height};return s}renderDraggedPreview(t){const n=Dh(this._layout,t);return n?this.renderContent(n,{isDragging:!0}):U``}shouldApplyTrackOffset(t,n){if(n)return!0;for(const i of t){if(i.type!=="stack")continue;if(i.children.some(o=>o.type==="drop-target")&&n!==i.id)return!0}return!1}computeDragTrackOffset(t,n,i,s,o,a){if(!t)return a;const c=s?o??this.getStableAnchorCardId(t,n,i):this.getStableAnchorNodeId(t,n,i);if(!c)return a;const u=s?qf(t,c,this.layoutGrid):Yf(t,c,this.layoutGrid),h=s?qf(n,c,this.layoutGrid):Yf(n,c,this.layoutGrid);return u===null||h===null?a:a+(u-h)}getStableAnchorCardId(t,n,i){const s=jf(t),o=new Set(jf(n));for(const a of s)if(a!==i&&o.has(a))return a;return null}getStableAnchorNodeId(t,n,i){const s=new Set(n.map(o=>o.id));for(const o of t)if(o.id!==i&&s.has(o.id))return o.id;return null}getStackChildAnchorCardId(t,n){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!==n);return(s==null?void 0:s.id)??null}}function iO(r){const e=new Map;for(const t of r){if(t.type==="card"){e.set(t.id,t);continue}for(const n of t.children)if(n.type==="card")e.set(n.id,n);else for(const i of n.children)e.set(i.id,i)}return e}function sO(r,e){const t=r.findIndex(n=>n.type==="card"&&n.id===e);if(t!==-1)return{topLevelIndex:t};for(let n=0;n<r.length;n+=1){const i=r[n];if(!(!i||i.type!=="stack")&&i.children.some(s=>s.type==="card"&&s.id===e))return{topLevelIndex:n,sourceStackId:i.id}}return null}function jf(r){const e=[];for(const t of r){if(t.type==="card"){e.push(t.id);continue}if(t.type==="stack"){const n=t.children.find(i=>i.type==="card");n&&e.push(n.id)}}return e}function qf(r,e,t){if(!t)return null;const n=Kn(r),i=new Map(n.nodes.map(o=>[o.id,o.width]));let s=0;for(const o of r){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)??Et,c=t.toPixels(ye({x:a})).x??yn;s+=c+ce}return null}function Yf(r,e,t){if(!t)return null;const n=Kn(r),i=new Map(n.nodes.map(o=>[o.id,o.width]));let s=0;for(const o of r){if(o.id===e)return s;const a=i.get(o.id)??Et,c=t.toPixels(ye({x:a})).x??yn;s+=c+ce}return null}customElements.get("layout-view")||customElements.define("layout-view",nO);class oO extends HTMLElement{constructor(){super(...arguments);y(this,"screenManager",Wt.resolve("ScreenManager"));y(this,"boundModel",null);y(this,"handleActiveScreenChanged",()=>{this.rebindModel(),this.render()});y(this,"handleModelChange",()=>{this.render()});y(this,"handleCloseArtifact",t=>{t instanceof eb&&this.screenManager.activeScreen&&this.screenManager.activeScreen.removeArtifact(t.artifactID)});y(this,"handleScrollPositionChanged",t=>{const n=t;typeof n.scrollPosition=="number"&&Number.isFinite(n.scrollPosition)&&this.screenManager.activeScreen&&this.screenManager.activeScreen.setScrollPosition(n.scrollPosition)});y(this,"handleLayoutChanged",t=>{t instanceof ob&&this.screenManager.activeScreen&&this.screenManager.activeScreen.setLayout(t.layout)});y(this,"handleServerEvent",t=>{const n=t.event;if(n.type!=="viewer-focus"||!this.boundModel||n.screenID!==this.boundModel.id)return;const i=this.querySelector("layout-view");i&&i.focusArtifact(n.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,n=(t==null?void 0:t.layout)??[],i=this.buildArtifactMap();if(n.length===0){Me(U``,this);return}Me(U`
238
- <layout-view
239
- .layout=${n}
240
- .renderContent=${(o,a)=>{const c=i.get(o.artifactID);return!c||!t?U``:U`<artifact-view
241
- .artifact=${c}
242
- .screen=${t}
243
- .viewURL=${t.server.getViewURL(c)}
244
- .contentURL=${t.server.getContentURL(c.id)}
245
- .dragging=${a.isDragging}
246
- ></artifact-view>`}}
247
- .scrollPosition=${(t==null?void 0:t.scrollPosition)??0}
248
- @scroll=${this.handleScrollPositionChanged}
249
- @layout-change=${this.handleLayoutChanged}
250
- @close-artifact=${this.handleCloseArtifact}
251
- ></layout-view>
252
- `,this)}}customElements.define("screen-view",oO);class aO extends HTMLElement{connectedCallback(){}}customElements.get("home-screen")||customElements.define("home-screen",aO);function Na(r){return typeof r=="object"&&r!==null}const kc=new WeakMap,Xf=Object.prototype.hasOwnProperty,lO=(()=>{const r=new Set;let e=HTMLElement.prototype;for(;e;){for(const t of Object.getOwnPropertyNames(e))r.add(t);if(e===Node.prototype)break;e=Object.getPrototypeOf(e)}return r})();function cO(r,e){if(Na(r))return e===null?void 0:r.parse(e);if(r===Boolean)return e!==null;if(e!==null)return r===Number?Number(e):e}function uO(r,e){return Na(r)?e==null?null:r.serialize(e):r===Boolean?e?"":null:e==null?null:String(e)}var eo,Au,pn,at,Nt,gi,fn,mi,we,Yn,ab,lb,cb,ub,ma;const Gr=class Gr extends HTMLElement{constructor(){var i;super();w(this,we);w(this,pn,new Map);w(this,at,new Map);w(this,Nt,new Map);w(this,gi,!1);w(this,fn,!1);w(this,mi,!1);const t=f(i=Gr,eo,Au).call(i,this.constructor),n=this;for(const s of t.properties)Xf.call(n,s)&&(l(this,Nt).set(s,n[s]),delete n[s])}static get observedAttributes(){var t;return f(t=Gr,eo,Au).call(t,this).observedAttributes}connected(){}disconnected(){}changed(t){}connectedCallback(){if(f(this,we,ub).call(this),!l(this,fn))for(const t of f(this,we,Yn).call(this).properties)l(this,at).has(t)||l(this,at).set(t,void 0);this.dispatchEvent(new Event("reactive:connect")),this.connected(),f(this,we,ma).call(this)}disconnectedCallback(){this.dispatchEvent(new Event("reactive:disconnect")),this.disconnected()}attributeChangedCallback(t,n,i){if(n===i)return;const s=f(this,we,Yn).call(this).byAttr.get(t);s&&(l(this,Nt).has(s.property)||(this[s.property]=cO(s.type,i)))}};eo=new WeakSet,Au=function(t){const n=kc.get(t);if(n)return n;const i=[...t.properties??[]],s=t.attributes??{},o=new Map,a=new Map;for(const u of i)if(lO.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.`);if(Na(h.type)){if(typeof h.type.parse!="function")throw new Error(`Attribute "${u}" custom coercer is missing a \`parse\` function.`);if(typeof h.type.serialize!="function")throw new Error(`Attribute "${u}" custom coercer is missing a \`serialize\` function.`)}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,pn).get(u)},set(p){f(this,we,ab).call(this,u,p)}})}const c={properties:i,observedAttributes:Object.keys(s),byAttr:o,byProp:a};return kc.set(t,c),c},pn=new WeakMap,at=new WeakMap,Nt=new WeakMap,gi=new WeakMap,fn=new WeakMap,mi=new WeakMap,we=new WeakSet,Yn=function(){return kc.get(this.constructor)},ab=function(t,n){if(!l(this,mi)&&l(this,Nt).has(t))return;const i=l(this,pn).get(t);f(this,we,lb).call(this,t,i,n)||(l(this,at).has(t)||l(this,at).set(t,i),l(this,pn).set(t,n),l(this,Nt).delete(t),f(this,we,cb).call(this,t,n),this.isConnected&&f(this,we,ma).call(this))},lb=function(t,n,i){if(Object.is(n,i))return!0;const s=f(this,we,Yn).call(this).byProp.get(t);if(!s||!Na(s.type))return!1;const o=n==null,a=i==null;if(o||a)return o&&a;try{return s.type.serialize(n)===s.type.serialize(i)}catch{return!1}},cb=function(t,n){const i=f(this,we,Yn).call(this).byProp.get(t);if(!i)return;const{attribute:s,type:o}=i;if(o===Boolean){const c=this.hasAttribute(s);n&&!c?this.setAttribute(s,""):!n&&c&&this.removeAttribute(s);return}const a=uO(o,n);if(a===null){this.hasAttribute(s)&&this.removeAttribute(s);return}this.getAttribute(s)!==a&&this.setAttribute(s,a)},ub=function(){const t=this,n=f(this,we,Yn).call(this);for(const i of n.properties){if(!Xf.call(t,i))continue;const s=t[i];delete t[i],!(l(this,Nt).has(i)||l(this,pn).has(i))&&(t[i]=s)}_(this,mi,!0);try{for(const[i,s]of l(this,Nt))t[i]=s;l(this,Nt).clear()}finally{_(this,mi,!1)}},ma=function(){l(this,gi)||!this.isConnected||l(this,fn)&&l(this,at).size===0||(_(this,gi,!0),queueMicrotask(()=>{if(_(this,gi,!1),!this.isConnected||l(this,fn)&&l(this,at).size===0)return;const t=new Map(l(this,at));l(this,at).clear(),_(this,fn,!0);try{this.changed(t)}catch(n){console.error(n)}this.isConnected&&l(this,at).size>0&&f(this,we,ma).call(this)}))},w(Gr,eo),y(Gr,"properties"),y(Gr,"attributes");let Ss=Gr;var He,St,Sr,vi,yi,ir,to,xe,bi,Ut,H,hb,ro,no,io,$u,Iu,Tu,db,pb,fb,qa,Ya,Xa,Ka,Cu,gb,va,Ja,ya,Qa,mb,vb,yb,bb,wb,lt;class hO extends Ss{constructor(){super(...arguments);w(this,H);w(this,He,Wt.resolve("ScreenManager"));w(this,St,Wt.resolve("ServerManager"));w(this,Sr,null);w(this,vi,new DisposableStack);w(this,yi,ha());w(this,ir,ha());w(this,to,ha());w(this,xe,{kind:"none"});w(this,bi,!1);w(this,Ut,[]);w(this,ro,()=>{f(this,H,$u).call(this),_(this,xe,{kind:"none"}),l(this,lt).call(this)});w(this,no,()=>{l(this,lt).call(this)});w(this,io,()=>{l(this,lt).call(this)});w(this,qa,()=>{var i,s;if(l(this,xe).kind==="picker"){f(this,H,ya).call(this);return}_(this,Ut,f(this,H,gb).call(this));const t=((i=l(this,He).activeScreen)==null?void 0:i.id)??null,n=t&&l(this,Ut).some(o=>o.screenID===t)?t:((s=l(this,Ut)[0])==null?void 0:s.screenID)??null;_(this,xe,{kind:"picker",filter:"",highlightedID:n}),l(this,lt).call(this),queueMicrotask(()=>{var o;(o=l(this,to).value)==null||o.focus()})});w(this,Ya,t=>{var u;const n=l(this,xe);if(n.kind!=="picker")return;const i=t.target;if(!(i instanceof HTMLInputElement))return;const s=i.value,o=f(this,H,va).call(this,l(this,Ut),s),c=n.highlightedID!==null&&o.some(h=>h.screenID===n.highlightedID)?n.highlightedID:((u=o[0])==null?void 0:u.screenID)??null;_(this,xe,{kind:"picker",filter:s,highlightedID:c}),l(this,lt).call(this)});w(this,Xa,t=>{var s;const n=l(this,xe);if(n.kind!=="picker")return;if(t.key==="Escape"){t.preventDefault(),f(this,H,ya).call(this),(s=l(this,yi).value)==null||s.focus();return}const i=f(this,H,va).call(this,l(this,Ut),n.filter);if(t.key==="ArrowDown"||t.key==="ArrowUp"){if(t.preventDefault(),i.length===0)return;const o=i.findIndex(u=>u.screenID===n.highlightedID),a=t.key==="ArrowDown"?1:-1,c=o<0?0:Math.max(0,Math.min(i.length-1,o+a));_(this,xe,{kind:"picker",filter:n.filter,highlightedID:i[c].screenID}),l(this,lt).call(this);return}if(t.key==="Enter"){t.preventDefault();const o=i.find(a=>a.screenID===n.highlightedID);o&&f(this,H,Cu).call(this,o)}});w(this,Ka,t=>{f(this,H,Cu).call(this,t)});w(this,Ja,t=>{l(this,xe).kind==="picker"&&t.target===l(this,ir).value&&(_(this,xe,{kind:"none"}),l(this,lt).call(this))});w(this,Qa,async()=>{if(l(this,bi))return;const t=f(this,H,mb).call(this);if(t){_(this,bi,!0);try{const n=await t.createScreen(dO(new Date));t.setPinned(n.id,!0),l(this,He).setActive(t.url,n.id)}catch{}finally{_(this,bi,!1)}}});w(this,lt,()=>{const t=f(this,H,fb).call(this);Me(U`
253
- ${f(this,H,vb).call(this)}
254
- <div class="pills" role="group" aria-label="Open tabs">
255
- ${t.map(n=>f(this,H,yb).call(this,n))}
256
- </div>
257
- ${f(this,H,bb).call(this)}
258
- `,this),l(this,ir).value&&(l(this,ir).value.anchor=l(this,yi).value??null)})}connected(){l(this,He).addEventListener("active-screen-changed",l(this,ro)),l(this,St).addEventListener("screens-changed",l(this,no)),f(this,H,$u).call(this),l(this,lt).call(this),f(this,H,hb).call(this),l(this,vi).defer(()=>{l(this,He).removeEventListener("active-screen-changed",l(this,ro)),l(this,St).removeEventListener("screens-changed",l(this,no)),f(this,H,Iu).call(this)})}disconnected(){l(this,vi).dispose(),_(this,vi,new DisposableStack)}}He=new WeakMap,St=new WeakMap,Sr=new WeakMap,vi=new WeakMap,yi=new WeakMap,ir=new WeakMap,to=new WeakMap,xe=new WeakMap,bi=new WeakMap,Ut=new WeakMap,H=new WeakSet,hb=async function(){const t=await Ey(this);this.setAttribute("tone",t)},ro=new WeakMap,no=new WeakMap,io=new WeakMap,$u=function(){var n;const t=l(this,He).activeScreen;l(this,Sr)!==t&&(f(this,H,Iu).call(this),_(this,Sr,t),(n=l(this,Sr))==null||n.addEventListener("change",l(this,io)))},Iu=function(){var t;(t=l(this,Sr))==null||t.removeEventListener("change",l(this,io)),_(this,Sr,null)},Tu=function(t,n){l(this,He).setActive(t,n)},db=function(t,n,i){var o;i.stopPropagation();const s=l(this,St).servers.get(t);s&&(s.setPinned(n,!1),((o=l(this,He).activeScreen)==null?void 0:o.id)===n&&l(this,He).clearActive())},pb=function(t,n,i){const s=l(this,He).activeScreen;if((s==null?void 0:s.id)===n){s.rename(i.value);return}const o=l(this,St).servers.get(t),a=o==null?void 0:o.screens.get(n);!o||!a||o.client.screens.update({screenID:n,name:i.value}).catch(()=>{})},fb=function(){var i;const t=((i=l(this,He).activeScreen)==null?void 0:i.id)??null,n=[];for(const s of l(this,St).servers.values())for(const o of s.screens.values()){const a=o.id===t;!o.pinned&&!a||n.push({serverURL:s.url,screenID:o.id,name:o.name,isActive:a})}return n},qa=new WeakMap,Ya=new WeakMap,Xa=new WeakMap,Ka=new WeakMap,Cu=function(t){const n=l(this,St).servers.get(t.serverURL);n&&n.setPinned(t.screenID,!0),l(this,He).setActive(t.serverURL,t.screenID),f(this,H,ya).call(this)},gb=function(){const t=[];for(const n of l(this,St).servers.values())for(const i of n.screens.values())t.push({serverURL:n.url,screenID:i.id,name:i.name});return t},va=function(t,n){const i=n.trim().toLowerCase();return i.length===0?t:t.filter(s=>s.name.toLowerCase().includes(i))},Ja=new WeakMap,ya=function(){l(this,xe).kind==="picker"&&(l(this,ir).value&&(l(this,ir).value.open=!1),_(this,xe,{kind:"none"}),l(this,lt).call(this))},Qa=new WeakMap,mb=function(){for(const t of l(this,St).servers.values())return t;return null},vb=function(){return U`
259
- <segmented-control variant="glass" role="group" aria-label="Screens">
260
- <button
261
- type="button"
262
- ?icon-only=${!0}
263
- aria-label="Choose screen"
264
- @click=${l(this,qa)}
265
- ${da(l(this,yi))}
266
- >
267
- ${OL({size:16,weight:"regular"})}
268
- </button>
269
- <button
270
- type="button"
271
- ?icon-only=${!0}
272
- aria-label="New screen"
273
- @click=${l(this,Qa)}
274
- >
275
- ${ML({size:16,weight:"regular"})}
276
- </button>
277
- </segmented-control>
278
- `},yb=function(t){return U`
279
- <span class="tab" ?data-active=${t.isActive}>
280
- <button
281
- type="button"
282
- variant="glass"
283
- class="screen-name tab-body"
284
- aria-pressed=${t.isActive?"true":"false"}
285
- aria-current=${t.isActive?"page":le}
286
- aria-label=${t.isActive?`Current tab: ${t.name}`:`Switch to ${t.name}`}
287
- @mousedown=${n=>{n.button===0&&f(this,H,Tu).call(this,t.serverURL,t.screenID)}}
288
- @click=${()=>f(this,H,Tu).call(this,t.serverURL,t.screenID)}
289
- >
290
- <span class="tab-leading">
291
- ${zL({weight:"bold"})}
292
- </span>
293
- <editable-text
294
- class="tab-name"
295
- .value=${t.name}
296
- @rename=${n=>f(this,H,pb).call(this,t.serverURL,t.screenID,n)}
297
- ></editable-text>
298
- </button>
299
- <button
300
- type="button"
301
- variant="ghost"
302
- size="xs"
303
- icon-only
304
- class="tab-close"
305
- aria-label=${`Close ${t.name}`}
306
- @click=${n=>f(this,H,db).call(this,t.serverURL,t.screenID,n)}
307
- >
308
- ${Ph({weight:"bold"})}
309
- </button>
310
- </span>
311
- `},bb=function(){var o;const t=l(this,xe).kind==="picker"?l(this,xe).filter:"",n=l(this,xe).kind==="picker"?l(this,xe).highlightedID:null,i=((o=l(this,He).activeScreen)==null?void 0:o.id)??null,s=f(this,H,va).call(this,l(this,Ut),t);return U`
312
- <ui-popover
313
- class="picker-popover"
314
- material="glass-frosted"
315
- ?open=${l(this,xe).kind==="picker"}
316
- @close=${l(this,Ja)}
317
- @keydown=${l(this,Xa)}
318
- ${da(l(this,ir))}
319
- >
320
- <div class="picker">
321
- <input
322
- type="text"
323
- class="picker-filter"
324
- placeholder="Filter screens"
325
- aria-label="Filter screens"
326
- .value=${t}
327
- @input=${l(this,Ya)}
328
- ${da(l(this,to))}
329
- />
330
- ${s.length===0?U`<p class="picker-empty">
331
- ${l(this,Ut).length===0?"No screens":"No matches"}
332
- </p>`:f(this,H,wb).call(this,s,n,i)}
333
- </div>
334
- </ui-popover>
335
- `},wb=function(t,n,i){return U`
336
- <ul class="picker-list" role="listbox">
337
- <li class="picker-section-label" role="presentation">Recent</li>
338
- ${t.map(s=>{const o=s.screenID===i;return U`
339
- <li
340
- class="picker-row"
341
- role="option"
342
- aria-selected=${s.screenID===n}
343
- aria-current=${o?"true":le}
344
- ?data-highlighted=${s.screenID===n}
345
- ?data-active=${o}
346
- @click=${()=>l(this,Ka).call(this,s)}
347
- >
348
- <span class="picker-name">${s.name}</span>
349
- </li>
350
- `})}
351
- </ul>
352
- `},lt=new WeakMap;customElements.define("screen-select",hO);function dO(r){const e=r.toLocaleDateString("en-US",{month:"long",day:"numeric",year:"numeric"}),t=12,n=r.getHours(),i=n%t===0?t:n%t,s=r.getMinutes().toString().padStart(2,"0"),o=n>=t?"pm":"am";return`${e} at ${i}:${s}${o}`}const xc=6e4;var _r,gn,wi,ba;class pO extends HTMLElement{constructor(){super(...arguments);w(this,wi);w(this,_r,null);w(this,gn,null)}connectedCallback(){this.hasAttribute("material")||this.setAttribute("material","glass"),f(this,wi,ba).call(this);const t=xc-Date.now()%xc;_(this,_r,window.setTimeout(()=>{_(this,_r,null),f(this,wi,ba).call(this),_(this,gn,window.setInterval(()=>f(this,wi,ba).call(this),xc))},t))}disconnectedCallback(){l(this,_r)!==null&&clearTimeout(l(this,_r)),l(this,gn)!==null&&clearInterval(l(this,gn)),_(this,_r,null),_(this,gn,null)}}_r=new WeakMap,gn=new WeakMap,wi=new WeakSet,ba=function(){const t=new Date,n=new Intl.DateTimeFormat(void 0,{weekday:"short",month:"short",day:"numeric"}).format(t),i=new Intl.DateTimeFormat(void 0,{hour:"numeric",minute:"2-digit"}).format(t);Me(U`<span class="date">${n}</span><span class="time">${i}</span>`,this)};customElements.get("menu-bar-clock")||customElements.define("menu-bar-clock",pO);function fO(r,e){let t=null;const n=()=>e((t==null?void 0:t.messages)??[]),i=()=>{var a;const o=((a=r.activeServer)==null?void 0:a.acpClient)??null;o!==t&&(t==null||t.removeEventListener("change",n),t=o,t&&(t.addEventListener("change",n),t.connect().catch(c=>{console.error("ACPClient.connect() failed",c)})),n())};r.addEventListener("change",i),i();const s=()=>{r.removeEventListener("change",i),t==null||t.removeEventListener("change",n),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:Sb,setPrototypeOf:Kf,isFrozen:gO,getPrototypeOf:mO,getOwnPropertyDescriptor:vO}=Object;let{freeze:Ve,seal:dt,create:wa}=Object,{apply:Pu,construct:Ru}=typeof Reflect<"u"&&Reflect;Ve||(Ve=function(e){return e});dt||(dt=function(e){return e});Pu||(Pu=function(e,t){for(var n=arguments.length,i=new Array(n>2?n-2:0),s=2;s<n;s++)i[s-2]=arguments[s];return e.apply(t,i)});Ru||(Ru=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];return new e(...n)});const Xo=Be(Array.prototype.forEach),yO=Be(Array.prototype.lastIndexOf),Jf=Be(Array.prototype.pop),ji=Be(Array.prototype.push),bO=Be(Array.prototype.splice),Sa=Be(String.prototype.toLowerCase),Ec=Be(String.prototype.toString),Ac=Be(String.prototype.match),qi=Be(String.prototype.replace),wO=Be(String.prototype.indexOf),SO=Be(String.prototype.trim),tt=Be(Object.prototype.hasOwnProperty),Ne=Be(RegExp.prototype.test),Yi=_O(TypeError);function Be(r){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];return Pu(r,e,n)}}function _O(r){return function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return Ru(r,t)}}function q(r,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Sa;Kf&&Kf(r,null);let n=e.length;for(;n--;){let i=e[n];if(typeof i=="string"){const s=t(i);s!==i&&(gO(e)||(e[n]=s),i=s)}r[i]=!0}return r}function kO(r){for(let e=0;e<r.length;e++)tt(r,e)||(r[e]=null);return r}function Pt(r){const e=wa(null);for(const[t,n]of Sb(r))tt(r,t)&&(Array.isArray(n)?e[t]=kO(n):n&&typeof n=="object"&&n.constructor===Object?e[t]=Pt(n):e[t]=n);return e}function Xi(r,e){for(;r!==null;){const n=vO(r,e);if(n){if(n.get)return Be(n.get);if(typeof n.value=="function")return Be(n.value)}r=mO(r)}function t(){return null}return t}const Qf=Ve(["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"]),$c=Ve(["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"]),Ic=Ve(["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"]),xO=Ve(["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"]),Tc=Ve(["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=Ve(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),eg=Ve(["#text"]),tg=Ve(["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"]),Cc=Ve(["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"]),rg=Ve(["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"]),Ko=Ve(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),AO=dt(/\{\{[\w\W]*|[\w\W]*\}\}/gm),$O=dt(/<%[\w\W]*|[\w\W]*%>/gm),IO=dt(/\$\{[\w\W]*/gm),TO=dt(/^data-[\-\w.\u00B7-\uFFFF]+$/),CO=dt(/^aria-[\-\w]+$/),_b=dt(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),PO=dt(/^(?:\w+script|data):/i),RO=dt(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),kb=dt(/^html$/i),DO=dt(/^[a-z][.\w]*(-[.\w]+)+$/i);var ng=Object.freeze({__proto__:null,ARIA_ATTR:CO,ATTR_WHITESPACE:RO,CUSTOM_ELEMENT:DO,DATA_ATTR:TO,DOCTYPE_NAME:kb,ERB_EXPR:$O,IS_ALLOWED_URI:_b,IS_SCRIPT_OR_DATA:PO,MUSTACHE_EXPR:AO,TMPLIT_EXPR:IO});const Ki={element:1,text:3,progressingInstruction:7,comment:8,document:9},LO=function(){return typeof window>"u"?null:window},zO=function(e,t){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let n=null;const i="data-tt-policy-suffix";t&&t.hasAttribute(i)&&(n=t.getAttribute(i));const s="dompurify"+(n?"#"+n:"");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}},ig=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function xb(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:LO();const e=M=>xb(M);if(e.version="3.3.3",e.removed=[],!r||!r.document||r.document.nodeType!==Ki.document||!r.Element)return e.isSupported=!1,e;let{document:t}=r;const n=t,i=n.currentScript,{DocumentFragment:s,HTMLTemplateElement:o,Node:a,Element:c,NodeFilter:u,NamedNodeMap:h=r.NamedNodeMap||r.MozNamedAttrMap,HTMLFormElement:p,DOMParser:v,trustedTypes:m}=r,E=c.prototype,x=Xi(E,"cloneNode"),T=Xi(E,"remove"),O=Xi(E,"nextSibling"),P=Xi(E,"childNodes"),Z=Xi(E,"parentNode");if(typeof o=="function"){const M=t.createElement("template");M.content&&M.content.ownerDocument&&(t=M.content.ownerDocument)}let F,B="";const{implementation:N,createNodeIterator:J,createDocumentFragment:j,getElementsByTagName:st}=t,{importNode:Zt}=n;let _e=ig();e.isSupported=typeof Sb=="function"&&typeof Z=="function"&&N&&N.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:Lr,ERB_EXPR:At,TMPLIT_EXPR:ur,DATA_ATTR:xl,ARIA_ATTR:Ao,IS_SCRIPT_OR_DATA:Fb,ATTR_WHITESPACE:jh,CUSTOM_ELEMENT:Wb}=ng;let{IS_ALLOWED_URI:qh}=ng,$e=null;const Yh=q({},[...Qf,...$c,...Ic,...Tc,...eg]);let Ce=null;const Xh=q({},[...tg,...Cc,...rg,...Ko]);let ve=Object.seal(wa(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}})),Fi=null,$o=null;const hr=Object.seal(wa(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Kh=!0,El=!0,Jh=!1,Qh=!0,Tn=!1,Io=!0,zr=!1,Al=!1,$l=!1,Cn=!1,To=!1,Co=!1,ed=!0,td=!1;const Hb="user-content-";let Il=!0,Wi=!1,Pn={},$t=null;const Tl=q({},["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 rd=null;const nd=q({},["audio","video","img","source","image","track"]);let Cl=null;const id=q({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Po="http://www.w3.org/1998/Math/MathML",Ro="http://www.w3.org/2000/svg",Vt="http://www.w3.org/1999/xhtml";let Rn=Vt,Pl=!1,Rl=null;const Zb=q({},[Po,Ro,Vt],Ec);let Do=q({},["mi","mo","mn","ms","mtext"]),Lo=q({},["annotation-xml"]);const Vb=q({},["title","style","font","a","script"]);let Hi=null;const Bb=["application/xhtml+xml","text/html"],Gb="text/html";let ke=null,Dn=null;const jb=t.createElement("form"),sd=function(b){return b instanceof RegExp||b instanceof Function},Dl=function(){let b=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(Dn&&Dn===b)){if((!b||typeof b!="object")&&(b={}),b=Pt(b),Hi=Bb.indexOf(b.PARSER_MEDIA_TYPE)===-1?Gb:b.PARSER_MEDIA_TYPE,ke=Hi==="application/xhtml+xml"?Ec:Sa,$e=tt(b,"ALLOWED_TAGS")?q({},b.ALLOWED_TAGS,ke):Yh,Ce=tt(b,"ALLOWED_ATTR")?q({},b.ALLOWED_ATTR,ke):Xh,Rl=tt(b,"ALLOWED_NAMESPACES")?q({},b.ALLOWED_NAMESPACES,Ec):Zb,Cl=tt(b,"ADD_URI_SAFE_ATTR")?q(Pt(id),b.ADD_URI_SAFE_ATTR,ke):id,rd=tt(b,"ADD_DATA_URI_TAGS")?q(Pt(nd),b.ADD_DATA_URI_TAGS,ke):nd,$t=tt(b,"FORBID_CONTENTS")?q({},b.FORBID_CONTENTS,ke):Tl,Fi=tt(b,"FORBID_TAGS")?q({},b.FORBID_TAGS,ke):Pt({}),$o=tt(b,"FORBID_ATTR")?q({},b.FORBID_ATTR,ke):Pt({}),Pn=tt(b,"USE_PROFILES")?b.USE_PROFILES:!1,Kh=b.ALLOW_ARIA_ATTR!==!1,El=b.ALLOW_DATA_ATTR!==!1,Jh=b.ALLOW_UNKNOWN_PROTOCOLS||!1,Qh=b.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Tn=b.SAFE_FOR_TEMPLATES||!1,Io=b.SAFE_FOR_XML!==!1,zr=b.WHOLE_DOCUMENT||!1,Cn=b.RETURN_DOM||!1,To=b.RETURN_DOM_FRAGMENT||!1,Co=b.RETURN_TRUSTED_TYPE||!1,$l=b.FORCE_BODY||!1,ed=b.SANITIZE_DOM!==!1,td=b.SANITIZE_NAMED_PROPS||!1,Il=b.KEEP_CONTENT!==!1,Wi=b.IN_PLACE||!1,qh=b.ALLOWED_URI_REGEXP||_b,Rn=b.NAMESPACE||Vt,Do=b.MATHML_TEXT_INTEGRATION_POINTS||Do,Lo=b.HTML_INTEGRATION_POINTS||Lo,ve=b.CUSTOM_ELEMENT_HANDLING||{},b.CUSTOM_ELEMENT_HANDLING&&sd(b.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(ve.tagNameCheck=b.CUSTOM_ELEMENT_HANDLING.tagNameCheck),b.CUSTOM_ELEMENT_HANDLING&&sd(b.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(ve.attributeNameCheck=b.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),b.CUSTOM_ELEMENT_HANDLING&&typeof b.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(ve.allowCustomizedBuiltInElements=b.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Tn&&(El=!1),To&&(Cn=!0),Pn&&($e=q({},eg),Ce=wa(null),Pn.html===!0&&(q($e,Qf),q(Ce,tg)),Pn.svg===!0&&(q($e,$c),q(Ce,Cc),q(Ce,Ko)),Pn.svgFilters===!0&&(q($e,Ic),q(Ce,Cc),q(Ce,Ko)),Pn.mathMl===!0&&(q($e,Tc),q(Ce,rg),q(Ce,Ko))),tt(b,"ADD_TAGS")||(hr.tagCheck=null),tt(b,"ADD_ATTR")||(hr.attributeCheck=null),b.ADD_TAGS&&(typeof b.ADD_TAGS=="function"?hr.tagCheck=b.ADD_TAGS:($e===Yh&&($e=Pt($e)),q($e,b.ADD_TAGS,ke))),b.ADD_ATTR&&(typeof b.ADD_ATTR=="function"?hr.attributeCheck=b.ADD_ATTR:(Ce===Xh&&(Ce=Pt(Ce)),q(Ce,b.ADD_ATTR,ke))),b.ADD_URI_SAFE_ATTR&&q(Cl,b.ADD_URI_SAFE_ATTR,ke),b.FORBID_CONTENTS&&($t===Tl&&($t=Pt($t)),q($t,b.FORBID_CONTENTS,ke)),b.ADD_FORBID_CONTENTS&&($t===Tl&&($t=Pt($t)),q($t,b.ADD_FORBID_CONTENTS,ke)),Il&&($e["#text"]=!0),zr&&q($e,["html","head","body"]),$e.table&&(q($e,["tbody"]),delete Fi.tbody),b.TRUSTED_TYPES_POLICY){if(typeof b.TRUSTED_TYPES_POLICY.createHTML!="function")throw Yi('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof b.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Yi('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');F=b.TRUSTED_TYPES_POLICY,B=F.createHTML("")}else F===void 0&&(F=zO(m,i)),F!==null&&typeof B=="string"&&(B=F.createHTML(""));Ve&&Ve(b),Dn=b}},od=q({},[...$c,...Ic,...xO]),ad=q({},[...Tc,...EO]),qb=function(b){let C=Z(b);(!C||!C.tagName)&&(C={namespaceURI:Rn,tagName:"template"});const R=Sa(b.tagName),ue=Sa(C.tagName);return Rl[b.namespaceURI]?b.namespaceURI===Ro?C.namespaceURI===Vt?R==="svg":C.namespaceURI===Po?R==="svg"&&(ue==="annotation-xml"||Do[ue]):!!od[R]:b.namespaceURI===Po?C.namespaceURI===Vt?R==="math":C.namespaceURI===Ro?R==="math"&&Lo[ue]:!!ad[R]:b.namespaceURI===Vt?C.namespaceURI===Ro&&!Lo[ue]||C.namespaceURI===Po&&!Do[ue]?!1:!ad[R]&&(Vb[R]||!od[R]):!!(Hi==="application/xhtml+xml"&&Rl[b.namespaceURI]):!1},It=function(b){ji(e.removed,{element:b});try{Z(b).removeChild(b)}catch{T(b)}},Or=function(b,C){try{ji(e.removed,{attribute:C.getAttributeNode(b),from:C})}catch{ji(e.removed,{attribute:null,from:C})}if(C.removeAttribute(b),b==="is")if(Cn||To)try{It(C)}catch{}else try{C.setAttribute(b,"")}catch{}},ld=function(b){let C=null,R=null;if($l)b="<remove></remove>"+b;else{const be=Ac(b,/^[\r\n\t ]+/);R=be&&be[0]}Hi==="application/xhtml+xml"&&Rn===Vt&&(b='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+b+"</body></html>");const ue=F?F.createHTML(b):b;if(Rn===Vt)try{C=new v().parseFromString(ue,Hi)}catch{}if(!C||!C.documentElement){C=N.createDocument(Rn,"template",null);try{C.documentElement.innerHTML=Pl?B:ue}catch{}}const ze=C.body||C.documentElement;return b&&R&&ze.insertBefore(t.createTextNode(R),ze.childNodes[0]||null),Rn===Vt?st.call(C,zr?"html":"body")[0]:zr?C.documentElement:ze},cd=function(b){return J.call(b.ownerDocument||b,b,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},Ll=function(b){return b instanceof p&&(typeof b.nodeName!="string"||typeof b.textContent!="string"||typeof b.removeChild!="function"||!(b.attributes instanceof h)||typeof b.removeAttribute!="function"||typeof b.setAttribute!="function"||typeof b.namespaceURI!="string"||typeof b.insertBefore!="function"||typeof b.hasChildNodes!="function")},ud=function(b){return typeof a=="function"&&b instanceof a};function Bt(M,b,C){Xo(M,R=>{R.call(e,b,C,Dn)})}const hd=function(b){let C=null;if(Bt(_e.beforeSanitizeElements,b,null),Ll(b))return It(b),!0;const R=ke(b.nodeName);if(Bt(_e.uponSanitizeElement,b,{tagName:R,allowedTags:$e}),Io&&b.hasChildNodes()&&!ud(b.firstElementChild)&&Ne(/<[/\w!]/g,b.innerHTML)&&Ne(/<[/\w!]/g,b.textContent)||b.nodeType===Ki.progressingInstruction||Io&&b.nodeType===Ki.comment&&Ne(/<[/\w]/g,b.data))return It(b),!0;if(!(hr.tagCheck instanceof Function&&hr.tagCheck(R))&&(!$e[R]||Fi[R])){if(!Fi[R]&&pd(R)&&(ve.tagNameCheck instanceof RegExp&&Ne(ve.tagNameCheck,R)||ve.tagNameCheck instanceof Function&&ve.tagNameCheck(R)))return!1;if(Il&&!$t[R]){const ue=Z(b)||b.parentNode,ze=P(b)||b.childNodes;if(ze&&ue){const be=ze.length;for(let Ge=be-1;Ge>=0;--Ge){const Gt=x(ze[Ge],!0);Gt.__removalCount=(b.__removalCount||0)+1,ue.insertBefore(Gt,O(b))}}}return It(b),!0}return b instanceof c&&!qb(b)||(R==="noscript"||R==="noembed"||R==="noframes")&&Ne(/<\/no(script|embed|frames)/i,b.innerHTML)?(It(b),!0):(Tn&&b.nodeType===Ki.text&&(C=b.textContent,Xo([Lr,At,ur],ue=>{C=qi(C,ue," ")}),b.textContent!==C&&(ji(e.removed,{element:b.cloneNode()}),b.textContent=C)),Bt(_e.afterSanitizeElements,b,null),!1)},dd=function(b,C,R){if($o[C]||ed&&(C==="id"||C==="name")&&(R in t||R in jb))return!1;if(!(El&&!$o[C]&&Ne(xl,C))){if(!(Kh&&Ne(Ao,C))){if(!(hr.attributeCheck instanceof Function&&hr.attributeCheck(C,b))){if(!Ce[C]||$o[C]){if(!(pd(b)&&(ve.tagNameCheck instanceof RegExp&&Ne(ve.tagNameCheck,b)||ve.tagNameCheck instanceof Function&&ve.tagNameCheck(b))&&(ve.attributeNameCheck instanceof RegExp&&Ne(ve.attributeNameCheck,C)||ve.attributeNameCheck instanceof Function&&ve.attributeNameCheck(C,b))||C==="is"&&ve.allowCustomizedBuiltInElements&&(ve.tagNameCheck instanceof RegExp&&Ne(ve.tagNameCheck,R)||ve.tagNameCheck instanceof Function&&ve.tagNameCheck(R))))return!1}else if(!Cl[C]){if(!Ne(qh,qi(R,jh,""))){if(!((C==="src"||C==="xlink:href"||C==="href")&&b!=="script"&&wO(R,"data:")===0&&rd[b])){if(!(Jh&&!Ne(Fb,qi(R,jh,"")))){if(R)return!1}}}}}}}return!0},pd=function(b){return b!=="annotation-xml"&&Ac(b,Wb)},fd=function(b){Bt(_e.beforeSanitizeAttributes,b,null);const{attributes:C}=b;if(!C||Ll(b))return;const R={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Ce,forceKeepAttr:void 0};let ue=C.length;for(;ue--;){const ze=C[ue],{name:be,namespaceURI:Ge,value:Gt}=ze,Ln=ke(be),zl=Gt;let Pe=be==="value"?zl:SO(zl);if(R.attrName=Ln,R.attrValue=Pe,R.keepAttr=!0,R.forceKeepAttr=void 0,Bt(_e.uponSanitizeAttribute,b,R),Pe=R.attrValue,td&&(Ln==="id"||Ln==="name")&&(Or(be,b),Pe=Hb+Pe),Io&&Ne(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,Pe)){Or(be,b);continue}if(Ln==="attributename"&&Ac(Pe,"href")){Or(be,b);continue}if(R.forceKeepAttr)continue;if(!R.keepAttr){Or(be,b);continue}if(!Qh&&Ne(/\/>/i,Pe)){Or(be,b);continue}Tn&&Xo([Lr,At,ur],md=>{Pe=qi(Pe,md," ")});const gd=ke(b.nodeName);if(!dd(gd,Ln,Pe)){Or(be,b);continue}if(F&&typeof m=="object"&&typeof m.getAttributeType=="function"&&!Ge)switch(m.getAttributeType(gd,Ln)){case"TrustedHTML":{Pe=F.createHTML(Pe);break}case"TrustedScriptURL":{Pe=F.createScriptURL(Pe);break}}if(Pe!==zl)try{Ge?b.setAttributeNS(Ge,be,Pe):b.setAttribute(be,Pe),Ll(b)?It(b):Jf(e.removed)}catch{Or(be,b)}}Bt(_e.afterSanitizeAttributes,b,null)},Yb=function M(b){let C=null;const R=cd(b);for(Bt(_e.beforeSanitizeShadowDOM,b,null);C=R.nextNode();)Bt(_e.uponSanitizeShadowNode,C,null),hd(C),fd(C),C.content instanceof s&&M(C.content);Bt(_e.afterSanitizeShadowDOM,b,null)};return e.sanitize=function(M){let b=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},C=null,R=null,ue=null,ze=null;if(Pl=!M,Pl&&(M="<!-->"),typeof M!="string"&&!ud(M))if(typeof M.toString=="function"){if(M=M.toString(),typeof M!="string")throw Yi("dirty is not a string, aborting")}else throw Yi("toString is not a function");if(!e.isSupported)return M;if(Al||Dl(b),e.removed=[],typeof M=="string"&&(Wi=!1),Wi){if(M.nodeName){const Gt=ke(M.nodeName);if(!$e[Gt]||Fi[Gt])throw Yi("root node is forbidden and cannot be sanitized in-place")}}else if(M instanceof a)C=ld("<!---->"),R=C.ownerDocument.importNode(M,!0),R.nodeType===Ki.element&&R.nodeName==="BODY"||R.nodeName==="HTML"?C=R:C.appendChild(R);else{if(!Cn&&!Tn&&!zr&&M.indexOf("<")===-1)return F&&Co?F.createHTML(M):M;if(C=ld(M),!C)return Cn?null:Co?B:""}C&&$l&&It(C.firstChild);const be=cd(Wi?M:C);for(;ue=be.nextNode();)hd(ue),fd(ue),ue.content instanceof s&&Yb(ue.content);if(Wi)return M;if(Cn){if(To)for(ze=j.call(C.ownerDocument);C.firstChild;)ze.appendChild(C.firstChild);else ze=C;return(Ce.shadowroot||Ce.shadowrootmode)&&(ze=Zt.call(n,ze,!0)),ze}let Ge=zr?C.outerHTML:C.innerHTML;return zr&&$e["!doctype"]&&C.ownerDocument&&C.ownerDocument.doctype&&C.ownerDocument.doctype.name&&Ne(kb,C.ownerDocument.doctype.name)&&(Ge="<!DOCTYPE "+C.ownerDocument.doctype.name+`>
353
- `+Ge),Tn&&Xo([Lr,At,ur],Gt=>{Ge=qi(Ge,Gt," ")}),F&&Co?F.createHTML(Ge):Ge},e.setConfig=function(){let M=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Dl(M),Al=!0},e.clearConfig=function(){Dn=null,Al=!1},e.isValidAttribute=function(M,b,C){Dn||Dl({});const R=ke(M),ue=ke(b);return dd(R,ue,C)},e.addHook=function(M,b){typeof b=="function"&&ji(_e[M],b)},e.removeHook=function(M,b){if(b!==void 0){const C=yO(_e[M],b);return C===-1?void 0:bO(_e[M],C,1)[0]}return Jf(_e[M])},e.removeHooks=function(M){_e[M]=[]},e.removeAllHooks=function(){_e=ig()},e}var Eb=xb();function Lh(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var In=Lh();function Ab(r){In=r}var Br={exec:()=>null};function K(r,e=""){let t=typeof r=="string"?r:r.source,n={replace:(i,s)=>{let o=typeof s=="string"?s:s.source;return o=o.replace(Ze.caret,"$1"),t=t.replace(i,o),n},getRegex:()=>new RegExp(t,e)};return n}var OO=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),Ze={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:r=>new RegExp(`^( {0,3}${r})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:r=>new RegExp(`^ {0,${Math.min(3,r-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:r=>new RegExp(`^ {0,${Math.min(3,r-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:r=>new RegExp(`^ {0,${Math.min(3,r-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:r=>new RegExp(`^ {0,${Math.min(3,r-1)}}#`),htmlBeginRegex:r=>new RegExp(`^ {0,${Math.min(3,r-1)}}<(?:[a-z].*>|!--)`,"i"),blockquoteBeginRegex:r=>new RegExp(`^ {0,${Math.min(3,r-1)}}>`)},MO=/^(?:[ \t]*(?:\n|$))+/,NO=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,UO=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Eo=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,FO=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,zh=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,$b=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Ib=K($b).replace(/bull/g,zh).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(),WO=K($b).replace(/bull/g,zh).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(),Oh=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,HO=/^[^\n]+/,Mh=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,ZO=K(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Mh).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),VO=K(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,zh).getRegex(),_l="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",Nh=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,BO=K("^ {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",Nh).replace("tag",_l).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Tb=K(Oh).replace("hr",Eo).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",_l).getRegex(),GO=K(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Tb).getRegex(),Uh={blockquote:GO,code:NO,def:ZO,fences:UO,heading:FO,hr:Eo,html:BO,lheading:Ib,list:VO,newline:MO,paragraph:Tb,table:Br,text:HO},sg=K("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Eo).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",_l).getRegex(),jO={...Uh,lheading:WO,table:sg,paragraph:K(Oh).replace("hr",Eo).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",sg).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",_l).getRegex()},qO={...Uh,html:K(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Nh).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:Br,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:K(Oh).replace("hr",Eo).replace("heading",` *#{1,6} *[^
354
- ]`).replace("lheading",Ib).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},YO=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,XO=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Cb=/^( {2,}|\\)\n(?!\s*$)/,KO=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Ui=/[\p{P}\p{S}]/u,kl=/[\s\p{P}\p{S}]/u,Fh=/[^\s\p{P}\p{S}]/u,JO=K(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,kl).getRegex(),Pb=/(?!~)[\p{P}\p{S}]/u,QO=/(?!~)[\s\p{P}\p{S}]/u,e2=/(?:[^\s\p{P}\p{S}]|~)/u,t2=K(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",OO?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Rb=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,r2=K(Rb,"u").replace(/punct/g,Ui).getRegex(),n2=K(Rb,"u").replace(/punct/g,Pb).getRegex(),Db="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",i2=K(Db,"gu").replace(/notPunctSpace/g,Fh).replace(/punctSpace/g,kl).replace(/punct/g,Ui).getRegex(),s2=K(Db,"gu").replace(/notPunctSpace/g,e2).replace(/punctSpace/g,QO).replace(/punct/g,Pb).getRegex(),o2=K("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Fh).replace(/punctSpace/g,kl).replace(/punct/g,Ui).getRegex(),a2=K(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,Ui).getRegex(),l2="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",c2=K(l2,"gu").replace(/notPunctSpace/g,Fh).replace(/punctSpace/g,kl).replace(/punct/g,Ui).getRegex(),u2=K(/\\(punct)/,"gu").replace(/punct/g,Ui).getRegex(),h2=K(/^<(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(),d2=K(Nh).replace("(?:-->|$)","-->").getRegex(),p2=K("^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",d2).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Ua=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,f2=K(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",Ua).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Lb=K(/^!?\[(label)\]\[(ref)\]/).replace("label",Ua).replace("ref",Mh).getRegex(),zb=K(/^!?\[(ref)\](?:\[\])?/).replace("ref",Mh).getRegex(),g2=K("reflink|nolink(?!\\()","g").replace("reflink",Lb).replace("nolink",zb).getRegex(),og=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Wh={_backpedal:Br,anyPunctuation:u2,autolink:h2,blockSkip:t2,br:Cb,code:XO,del:Br,delLDelim:Br,delRDelim:Br,emStrongLDelim:r2,emStrongRDelimAst:i2,emStrongRDelimUnd:o2,escape:YO,link:f2,nolink:zb,punctuation:JO,reflink:Lb,reflinkSearch:g2,tag:p2,text:KO,url:Br},m2={...Wh,link:K(/^!?\[(label)\]\((.*?)\)/).replace("label",Ua).getRegex(),reflink:K(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Ua).getRegex()},Du={...Wh,emStrongRDelimAst:s2,emStrongLDelim:n2,delLDelim:a2,delRDelim:c2,url:K(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",og).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:K(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",og).getRegex()},v2={...Du,br:K(Cb).replace("{2,}","*").getRegex(),text:K(Du.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Jo={normal:Uh,gfm:jO,pedantic:qO},Ji={normal:Wh,gfm:Du,breaks:v2,pedantic:m2},y2={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},ag=r=>y2[r];function Rt(r,e){if(e){if(Ze.escapeTest.test(r))return r.replace(Ze.escapeReplace,ag)}else if(Ze.escapeTestNoEncode.test(r))return r.replace(Ze.escapeReplaceNoEncode,ag);return r}function lg(r){try{r=encodeURI(r).replace(Ze.percentDecode,"%")}catch{return null}return r}function cg(r,e){var s;let t=r.replace(Ze.findPipe,(o,a,c)=>{let u=!1,h=a;for(;--h>=0&&c[h]==="\\";)u=!u;return u?"|":" |"}),n=t.split(Ze.splitPipe),i=0;if(n[0].trim()||n.shift(),n.length>0&&!((s=n.at(-1))!=null&&s.trim())&&n.pop(),e)if(n.length>e)n.splice(e);else for(;n.length<e;)n.push("");for(;i<n.length;i++)n[i]=n[i].trim().replace(Ze.slashPipe,"|");return n}function Qi(r,e,t){let n=r.length;if(n===0)return"";let i=0;for(;i<n&&r.charAt(n-i-1)===e;)i++;return r.slice(0,n-i)}function b2(r,e){if(r.indexOf(e[1])===-1)return-1;let t=0;for(let n=0;n<r.length;n++)if(r[n]==="\\")n++;else if(r[n]===e[0])t++;else if(r[n]===e[1]&&(t--,t<0))return n;return t>0?-2:-1}function w2(r,e=0){let t=e,n="";for(let i of r)if(i===" "){let s=4-t%4;n+=" ".repeat(s),t+=s}else n+=i,t++;return n}function ug(r,e,t,n,i){let s=e.href,o=e.title||null,a=r[1].replace(i.other.outputLinkReplace,"$1");n.state.inLink=!0;let c={type:r[0].charAt(0)==="!"?"image":"link",raw:t,href:s,title:o,text:a,tokens:n.inlineTokens(a)};return n.state.inLink=!1,c}function S2(r,e,t){let n=r.match(t.other.indentCodeCompensation);if(n===null)return e;let i=n[1];return e.split(`
355
- `).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(`
356
- `)}var Fa=class{constructor(r){y(this,"options");y(this,"rules");y(this,"lexer");this.options=r||In}space(r){let e=this.rules.block.newline.exec(r);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(r){let e=this.rules.block.code.exec(r);if(e){let t=e[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:e[0],codeBlockStyle:"indented",text:this.options.pedantic?t:Qi(t,`
357
- `)}}}fences(r){let e=this.rules.block.fences.exec(r);if(e){let t=e[0],n=S2(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:n}}}heading(r){let e=this.rules.block.heading.exec(r);if(e){let t=e[2].trim();if(this.rules.other.endingHash.test(t)){let n=Qi(t,"#");(this.options.pedantic||!n||this.rules.other.endingSpaceChar.test(n))&&(t=n.trim())}return{type:"heading",raw:e[0],depth:e[1].length,text:t,tokens:this.lexer.inline(t)}}}hr(r){let e=this.rules.block.hr.exec(r);if(e)return{type:"hr",raw:Qi(e[0],`
358
- `)}}blockquote(r){let e=this.rules.block.blockquote.exec(r);if(e){let t=Qi(e[0],`
359
- `).split(`
360
- `),n="",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(`
361
- `),h=u.replace(this.rules.other.blockquoteSetextReplace,`
362
- $1`).replace(this.rules.other.blockquoteSetextReplace2,"");n=n?`${n}
363
- ${u}`:u,i=i?`${i}
364
- ${h}`:h;let p=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(h,s,!0),this.lexer.state.top=p,t.length===0)break;let v=s.at(-1);if((v==null?void 0:v.type)==="code")break;if((v==null?void 0:v.type)==="blockquote"){let m=v,E=m.raw+`
365
- `+t.join(`
366
- `),x=this.blockquote(E);s[s.length-1]=x,n=n.substring(0,n.length-m.raw.length)+x.raw,i=i.substring(0,i.length-m.text.length)+x.text;break}else if((v==null?void 0:v.type)==="list"){let m=v,E=m.raw+`
367
- `+t.join(`
368
- `),x=this.list(E);s[s.length-1]=x,n=n.substring(0,n.length-v.raw.length)+x.raw,i=i.substring(0,i.length-m.raw.length)+x.raw,t=E.substring(s.at(-1).raw.length).split(`
369
- `);continue}}return{type:"blockquote",raw:n,tokens:s,text:i}}}list(r){var t,n;let e=this.rules.block.list.exec(r);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(;r;){let h=!1,p="",v="";if(!(e=a.exec(r))||this.rules.block.hr.test(r))break;p=e[0],r=r.substring(p.length);let m=w2(e[2].split(`
370
- `,1)[0],e[1].length),E=r.split(`
371
- `,1)[0],x=!m.trim(),T=0;if(this.options.pedantic?(T=2,v=m.trimStart()):x?T=e[1].length+1:(T=m.search(this.rules.other.nonSpaceChar),T=T>4?1:T,v=m.slice(T),T+=e[1].length),x&&this.rules.other.blankLine.test(E)&&(p+=E+`
372
- `,r=r.substring(E.length+1),h=!0),!h){let O=this.rules.other.nextBulletRegex(T),P=this.rules.other.hrRegex(T),Z=this.rules.other.fencesBeginRegex(T),F=this.rules.other.headingBeginRegex(T),B=this.rules.other.htmlBeginRegex(T),N=this.rules.other.blockquoteBeginRegex(T);for(;r;){let J=r.split(`
373
- `,1)[0],j;if(E=J,this.options.pedantic?(E=E.replace(this.rules.other.listReplaceNesting," "),j=E):j=E.replace(this.rules.other.tabCharGlobal," "),Z.test(E)||F.test(E)||B.test(E)||N.test(E)||O.test(E)||P.test(E))break;if(j.search(this.rules.other.nonSpaceChar)>=T||!E.trim())v+=`
374
- `+j.slice(T);else{if(x||m.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||Z.test(m)||F.test(m)||P.test(m))break;v+=`
375
- `+E}x=!E.trim(),p+=J+`
376
- `,r=r.substring(J.length+1),m=j.slice(T)}}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"||((n=h.tokens[0])==null?void 0:n.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(m=>m.type==="space"),v=p.length>0&&p.some(m=>this.rules.other.anyLine.test(m.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(r){let e=this.rules.block.html.exec(r);if(e)return{type:"html",block:!0,raw:e[0],pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:e[0]}}def(r){let e=this.rules.block.def.exec(r);if(e){let t=e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),n=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:n,title:i}}}table(r){var o;let e=this.rules.block.table.exec(r);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;let t=cg(e[1]),n=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),i=(o=e[3])!=null&&o.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`
377
- `):[],s={type:"table",raw:e[0],header:[],align:[],rows:[]};if(t.length===n.length){for(let a of n)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(cg(a,s.header.length).map((c,u)=>({text:c,tokens:this.lexer.inline(c),header:!1,align:s.align[u]})));return s}}lheading(r){let e=this.rules.block.lheading.exec(r);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(r){let e=this.rules.block.paragraph.exec(r);if(e){let t=e[1].charAt(e[1].length-1)===`
378
- `?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:t,tokens:this.lexer.inline(t)}}}text(r){let e=this.rules.block.text.exec(r);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(r){let e=this.rules.inline.escape.exec(r);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(r){let e=this.rules.inline.tag.exec(r);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(r){let e=this.rules.inline.link.exec(r);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=Qi(t.slice(0,-1),"\\");if((t.length-s.length)%2===0)return}else{let s=b2(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 n=e[2],i="";if(this.options.pedantic){let s=this.rules.other.pedanticHrefTitle.exec(n);s&&(n=s[1],i=s[3])}else i=e[3]?e[3].slice(1,-1):"";return n=n.trim(),this.rules.other.startAngleBracket.test(n)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(t)?n=n.slice(1):n=n.slice(1,-1)),ug(e,{href:n&&n.replace(this.rules.inline.anyPunctuation,"$1"),title:i&&i.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer,this.rules)}}reflink(r,e){let t;if((t=this.rules.inline.reflink.exec(r))||(t=this.rules.inline.nolink.exec(r))){let n=(t[2]||t[1]).replace(this.rules.other.multipleSpaceGlobal," "),i=e[n.toLowerCase()];if(!i){let s=t[0].charAt(0);return{type:"text",raw:s,text:s}}return ug(t,i,t[0],this.lexer,this.rules)}}emStrong(r,e,t=""){let n=this.rules.inline.emStrongLDelim.exec(r);if(!(!n||!n[1]&&!n[2]&&!n[3]&&!n[4]||n[4]&&t.match(this.rules.other.unicodeAlphaNumeric))&&(!(n[1]||n[3])||!t||this.rules.inline.punctuation.exec(t))){let i=[...n[0]].length-1,s,o,a=i,c=0,u=n[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(u.lastIndex=0,e=e.slice(-1*r.length+i);(n=u.exec(e))!=null;){if(s=n[1]||n[2]||n[3]||n[4]||n[5]||n[6],!s)continue;if(o=[...s].length,n[3]||n[4]){a+=o;continue}else if((n[5]||n[6])&&i%3&&!((i+o)%3)){c+=o;continue}if(a-=o,a>0)continue;o=Math.min(o,o+a+c);let h=[...n[0]][0].length,p=r.slice(0,i+n.index+h+o);if(Math.min(i,o)%2){let m=p.slice(1,-1);return{type:"em",raw:p,text:m,tokens:this.lexer.inlineTokens(m)}}let v=p.slice(2,-2);return{type:"strong",raw:p,text:v,tokens:this.lexer.inlineTokens(v)}}}}codespan(r){let e=this.rules.inline.code.exec(r);if(e){let t=e[2].replace(this.rules.other.newLineCharGlobal," "),n=this.rules.other.nonSpaceChar.test(t),i=this.rules.other.startingSpaceChar.test(t)&&this.rules.other.endingSpaceChar.test(t);return n&&i&&(t=t.substring(1,t.length-1)),{type:"codespan",raw:e[0],text:t}}}br(r){let e=this.rules.inline.br.exec(r);if(e)return{type:"br",raw:e[0]}}del(r,e,t=""){let n=this.rules.inline.delLDelim.exec(r);if(n&&(!n[1]||!t||this.rules.inline.punctuation.exec(t))){let i=[...n[0]].length-1,s,o,a=i,c=this.rules.inline.delRDelim;for(c.lastIndex=0,e=e.slice(-1*r.length+i);(n=c.exec(e))!=null;){if(s=n[1]||n[2]||n[3]||n[4]||n[5]||n[6],!s||(o=[...s].length,o!==i))continue;if(n[3]||n[4]){a+=o;continue}if(a-=o,a>0)continue;o=Math.min(o,o+a);let u=[...n[0]][0].length,h=r.slice(0,i+n.index+u+o),p=h.slice(i,-i);return{type:"del",raw:h,text:p,tokens:this.lexer.inlineTokens(p)}}}}autolink(r){let e=this.rules.inline.autolink.exec(r);if(e){let t,n;return e[2]==="@"?(t=e[1],n="mailto:"+t):(t=e[1],n=t),{type:"link",raw:e[0],text:t,href:n,tokens:[{type:"text",raw:t,text:t}]}}}url(r){var t;let e;if(e=this.rules.inline.url.exec(r)){let n,i;if(e[2]==="@")n=e[0],i="mailto:"+n;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]);n=e[0],e[1]==="www."?i="http://"+e[0]:i=e[0]}return{type:"link",raw:e[0],text:n,href:i,tokens:[{type:"text",raw:n,text:n}]}}}inlineText(r){let e=this.rules.inline.text.exec(r);if(e){let t=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:e[0],escaped:t}}}},kt=class Lu{constructor(e){y(this,"tokens");y(this,"options");y(this,"state");y(this,"inlineQueue");y(this,"tokenizer");this.tokens=[],this.tokens.links=Object.create(null),this.options=e||In,this.options.tokenizer=this.options.tokenizer||new Fa,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:Ze,block:Jo.normal,inline:Ji.normal};this.options.pedantic?(t.block=Jo.pedantic,t.inline=Ji.pedantic):this.options.gfm&&(t.block=Jo.gfm,this.options.breaks?t.inline=Ji.breaks:t.inline=Ji.gfm),this.tokenizer.rules=t}static get rules(){return{block:Jo,inline:Ji}}static lex(e,t){return new Lu(t).lex(e)}static lexInline(e,t){return new Lu(t).inlineTokens(e)}lex(e){e=e.replace(Ze.carriageReturn,`
379
- `),this.blockTokens(e,this.tokens);for(let t=0;t<this.inlineQueue.length;t++){let n=this.inlineQueue[t];this.inlineTokens(n.src,n.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],n=!1){var i,s,o;for(this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(Ze.tabCharGlobal," ").replace(Ze.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+=`
380
- `: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(`
381
- `)?"":`
382
- `)+a.raw,u.text+=`
383
- `+a.text,this.inlineQueue.at(-1).src=u.text):t.push(a);continue}if(a=this.tokenizer.fences(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.heading(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.hr(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.blockquote(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.list(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.html(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.def(e)){e=e.substring(a.raw.length);let u=t.at(-1);(u==null?void 0:u.type)==="paragraph"||(u==null?void 0:u.type)==="text"?(u.raw+=(u.raw.endsWith(`
384
- `)?"":`
385
- `)+a.raw,u.text+=`
386
- `+a.raw,this.inlineQueue.at(-1).src=u.text):this.tokens.links[a.tag]||(this.tokens.links[a.tag]={href:a.href,title:a.title},t.push(a));continue}if(a=this.tokenizer.table(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.lheading(e)){e=e.substring(a.raw.length),t.push(a);continue}let c=e;if((o=this.options.extensions)!=null&&o.startBlock){let u=1/0,h=e.slice(1),p;this.options.extensions.startBlock.forEach(v=>{p=v.call({lexer:this},h),typeof p=="number"&&p>=0&&(u=Math.min(u,p))}),u<1/0&&u>=0&&(c=e.substring(0,u+1))}if(this.state.top&&(a=this.tokenizer.paragraph(c))){let u=t.at(-1);n&&(u==null?void 0:u.type)==="paragraph"?(u.raw+=(u.raw.endsWith(`
387
- `)?"":`
388
- `)+a.raw,u.text+=`
389
- `+a.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=u.text):t.push(a),n=c.length!==e.length,e=e.substring(a.raw.length);continue}if(a=this.tokenizer.text(e)){e=e.substring(a.raw.length);let u=t.at(-1);(u==null?void 0:u.type)==="text"?(u.raw+=(u.raw.endsWith(`
390
- `)?"":`
391
- `)+a.raw,u.text+=`
392
- `+a.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=u.text):t.push(a);continue}if(e){let u="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(u);break}else throw new Error(u)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){var c,u,h,p,v;this.tokenizer.lexer=this;let n=e,i=null;if(this.tokens.links){let m=Object.keys(this.tokens.links);if(m.length>0)for(;(i=this.tokenizer.rules.inline.reflinkSearch.exec(n))!=null;)m.includes(i[0].slice(i[0].lastIndexOf("[")+1,-1))&&(n=n.slice(0,i.index)+"["+"a".repeat(i[0].length-2)+"]"+n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(i=this.tokenizer.rules.inline.anyPunctuation.exec(n))!=null;)n=n.slice(0,i.index)+"++"+n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let s;for(;(i=this.tokenizer.rules.inline.blockSkip.exec(n))!=null;)s=i[2]?i[2].length:0,n=n.slice(0,i.index+s)+"["+"a".repeat(i[0].length-s-2)+"]"+n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);n=((u=(c=this.options.hooks)==null?void 0:c.emStrongMask)==null?void 0:u.call({lexer:this},n))??n;let o=!1,a="";for(;e;){o||(a=""),o=!1;let m;if((p=(h=this.options.extensions)==null?void 0:h.inline)!=null&&p.some(x=>(m=x.call({lexer:this},e,t))?(e=e.substring(m.raw.length),t.push(m),!0):!1))continue;if(m=this.tokenizer.escape(e)){e=e.substring(m.raw.length),t.push(m);continue}if(m=this.tokenizer.tag(e)){e=e.substring(m.raw.length),t.push(m);continue}if(m=this.tokenizer.link(e)){e=e.substring(m.raw.length),t.push(m);continue}if(m=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(m.raw.length);let x=t.at(-1);m.type==="text"&&(x==null?void 0:x.type)==="text"?(x.raw+=m.raw,x.text+=m.text):t.push(m);continue}if(m=this.tokenizer.emStrong(e,n,a)){e=e.substring(m.raw.length),t.push(m);continue}if(m=this.tokenizer.codespan(e)){e=e.substring(m.raw.length),t.push(m);continue}if(m=this.tokenizer.br(e)){e=e.substring(m.raw.length),t.push(m);continue}if(m=this.tokenizer.del(e,n,a)){e=e.substring(m.raw.length),t.push(m);continue}if(m=this.tokenizer.autolink(e)){e=e.substring(m.raw.length),t.push(m);continue}if(!this.state.inLink&&(m=this.tokenizer.url(e))){e=e.substring(m.raw.length),t.push(m);continue}let E=e;if((v=this.options.extensions)!=null&&v.startInline){let x=1/0,T=e.slice(1),O;this.options.extensions.startInline.forEach(P=>{O=P.call({lexer:this},T),typeof O=="number"&&O>=0&&(x=Math.min(x,O))}),x<1/0&&x>=0&&(E=e.substring(0,x+1))}if(m=this.tokenizer.inlineText(E)){e=e.substring(m.raw.length),m.raw.slice(-1)!=="_"&&(a=m.raw.slice(-1)),o=!0;let x=t.at(-1);(x==null?void 0:x.type)==="text"?(x.raw+=m.raw,x.text+=m.text):t.push(m);continue}if(e){let x="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(x);break}else throw new Error(x)}}return t}},Wa=class{constructor(r){y(this,"options");y(this,"parser");this.options=r||In}space(r){return""}code({text:r,lang:e,escaped:t}){var s;let n=(s=(e||"").match(Ze.notSpaceStart))==null?void 0:s[0],i=r.replace(Ze.endingNewline,"")+`
393
- `;return n?'<pre><code class="language-'+Rt(n)+'">'+(t?i:Rt(i,!0))+`</code></pre>
394
- `:"<pre><code>"+(t?i:Rt(i,!0))+`</code></pre>
395
- `}blockquote({tokens:r}){return`<blockquote>
396
- ${this.parser.parse(r)}</blockquote>
397
- `}html({text:r}){return r}def(r){return""}heading({tokens:r,depth:e}){return`<h${e}>${this.parser.parseInline(r)}</h${e}>
398
- `}hr(r){return`<hr>
399
- `}list(r){let e=r.ordered,t=r.start,n="";for(let o=0;o<r.items.length;o++){let a=r.items[o];n+=this.listitem(a)}let i=e?"ol":"ul",s=e&&t!==1?' start="'+t+'"':"";return"<"+i+s+`>
400
- `+n+"</"+i+`>
401
- `}listitem(r){return`<li>${this.parser.parse(r.tokens)}</li>
402
- `}checkbox({checked:r}){return"<input "+(r?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:r}){return`<p>${this.parser.parseInline(r)}</p>
403
- `}table(r){let e="",t="";for(let i=0;i<r.header.length;i++)t+=this.tablecell(r.header[i]);e+=this.tablerow({text:t});let n="";for(let i=0;i<r.rows.length;i++){let s=r.rows[i];t="";for(let o=0;o<s.length;o++)t+=this.tablecell(s[o]);n+=this.tablerow({text:t})}return n&&(n=`<tbody>${n}</tbody>`),`<table>
404
- <thead>
405
- `+e+`</thead>
406
- `+n+`</table>
407
- `}tablerow({text:r}){return`<tr>
408
- ${r}</tr>
409
- `}tablecell(r){let e=this.parser.parseInline(r.tokens),t=r.header?"th":"td";return(r.align?`<${t} align="${r.align}">`:`<${t}>`)+e+`</${t}>
410
- `}strong({tokens:r}){return`<strong>${this.parser.parseInline(r)}</strong>`}em({tokens:r}){return`<em>${this.parser.parseInline(r)}</em>`}codespan({text:r}){return`<code>${Rt(r,!0)}</code>`}br(r){return"<br>"}del({tokens:r}){return`<del>${this.parser.parseInline(r)}</del>`}link({href:r,title:e,tokens:t}){let n=this.parser.parseInline(t),i=lg(r);if(i===null)return n;r=i;let s='<a href="'+r+'"';return e&&(s+=' title="'+Rt(e)+'"'),s+=">"+n+"</a>",s}image({href:r,title:e,text:t,tokens:n}){n&&(t=this.parser.parseInline(n,this.parser.textRenderer));let i=lg(r);if(i===null)return Rt(t);r=i;let s=`<img src="${r}" alt="${Rt(t)}"`;return e&&(s+=` title="${Rt(e)}"`),s+=">",s}text(r){return"tokens"in r&&r.tokens?this.parser.parseInline(r.tokens):"escaped"in r&&r.escaped?r.text:Rt(r.text)}},Hh=class{strong({text:r}){return r}em({text:r}){return r}codespan({text:r}){return r}del({text:r}){return r}html({text:r}){return r}text({text:r}){return r}link({text:r}){return""+r}image({text:r}){return""+r}br(){return""}checkbox({raw:r}){return r}},xt=class zu{constructor(e){y(this,"options");y(this,"renderer");y(this,"textRenderer");this.options=e||In,this.options.renderer=this.options.renderer||new Wa,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Hh}static parse(e,t){return new zu(t).parse(e)}static parseInline(e,t){return new zu(t).parseInline(e)}parse(e){var n,i;this.renderer.parser=this;let t="";for(let s=0;s<e.length;s++){let o=e[s];if((i=(n=this.options.extensions)==null?void 0:n.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 n="";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)){n+=u||"";continue}}let c=a;switch(c.type){case"escape":{n+=t.text(c);break}case"html":{n+=t.html(c);break}case"link":{n+=t.link(c);break}case"image":{n+=t.image(c);break}case"checkbox":{n+=t.checkbox(c);break}case"strong":{n+=t.strong(c);break}case"em":{n+=t.em(c);break}case"codespan":{n+=t.codespan(c);break}case"br":{n+=t.br(c);break}case"del":{n+=t.del(c);break}case"text":{n+=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 n}},Qo,ls=(Qo=class{constructor(r){y(this,"options");y(this,"block");this.options=r||In}preprocess(r){return r}postprocess(r){return r}processAllTokens(r){return r}emStrongMask(r){return r}provideLexer(){return this.block?kt.lex:kt.lexInline}provideParser(){return this.block?xt.parse:xt.parseInline}},y(Qo,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),y(Qo,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),Qo),_2=class{constructor(...r){y(this,"defaults",Lh());y(this,"options",this.setOptions);y(this,"parse",this.parseMarkdown(!0));y(this,"parseInline",this.parseMarkdown(!1));y(this,"Parser",xt);y(this,"Renderer",Wa);y(this,"TextRenderer",Hh);y(this,"Lexer",kt);y(this,"Tokenizer",Fa);y(this,"Hooks",ls);this.use(...r)}walkTokens(r,e){var n,i;let t=[];for(let s of r)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=(n=this.defaults.extensions)==null?void 0:n.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(...r){let e=this.defaults.extensions||{renderers:{},childTokens:{}};return r.forEach(t=>{let n={...t};if(n.async=this.defaults.async||n.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)}),n.extensions=e),t.renderer){let i=this.defaults.renderer||new Wa(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||""}}n.renderer=i}if(t.tokenizer){let i=this.defaults.tokenizer||new Fa(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}}n.tokenizer=i}if(t.hooks){let i=this.defaults.hooks||new ls;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];ls.passThroughHooks.has(s)?i[o]=u=>{if(this.defaults.async&&ls.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}}n.hooks=i}if(t.walkTokens){let i=this.defaults.walkTokens,s=t.walkTokens;n.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,...n}}),this}setOptions(r){return this.defaults={...this.defaults,...r},this}lexer(r,e){return kt.lex(r,e??this.defaults)}parser(r,e){return xt.parse(r,e??this.defaults)}parseMarkdown(r){return(e,t)=>{let n={...t},i={...this.defaults,...n},s=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&n.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=r),i.async)return(async()=>{let o=i.hooks?await i.hooks.preprocess(e):e,a=await(i.hooks?await i.hooks.provideLexer():r?kt.lex:kt.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():r?xt.parse:xt.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():r?kt.lex:kt.lexInline)(e,i);i.hooks&&(o=i.hooks.processAllTokens(o)),i.walkTokens&&this.walkTokens(o,i.walkTokens);let a=(i.hooks?i.hooks.provideParser():r?xt.parse:xt.parseInline)(o,i);return i.hooks&&(a=i.hooks.postprocess(a)),a}catch(o){return s(o)}}}onError(r,e){return t=>{if(t.message+=`
411
- Please report this to https://github.com/markedjs/marked.`,r){let n="<p>An error occurred:</p><pre>"+Rt(t.message+"",!0)+"</pre>";return e?Promise.resolve(n):n}if(e)return Promise.reject(t);throw t}}},_n=new _2;function ne(r,e){return _n.parse(r,e)}ne.options=ne.setOptions=function(r){return _n.setOptions(r),ne.defaults=_n.defaults,Ab(ne.defaults),ne};ne.getDefaults=Lh;ne.defaults=In;ne.use=function(...r){return _n.use(...r),ne.defaults=_n.defaults,Ab(ne.defaults),ne};ne.walkTokens=function(r,e){return _n.walkTokens(r,e)};ne.parseInline=_n.parseInline;ne.Parser=xt;ne.parser=xt.parse;ne.Renderer=Wa;ne.TextRenderer=Hh;ne.Lexer=kt;ne.lexer=kt.lex;ne.Tokenizer=Fa;ne.Hooks=ls;ne.parse=ne;ne.options;ne.setOptions;ne.use;ne.walkTokens;ne.parseInline;xt.parse;kt.lex;Eb.addHook("afterSanitizeAttributes",r=>{r.tagName==="A"&&(r.setAttribute("target","_blank"),r.setAttribute("rel","noopener noreferrer"))});function k2(r){const e=ne.parse(r,{async:!1});return Eb.sanitize(e,{USE_PROFILES:{html:!0}})}const x2=8,hg=new WeakMap;function E2(r){const e=hg.get(r);if(e&&e.text===r.text)return e.html;const t=k2(r.text);return hg.set(r,{text:r.text,html:t}),t}function A2(r){return r.replace(/_/g," ")}function $2(r){return U`
412
- <div class="tool-call-header">
413
- <span class="tool-call-title">${r.title}</span>
414
- <span class="tool-call-meta">${r.toolKind} · ${A2(r.status)}</span>
415
- </div>
416
- ${r.text?U`<pre class="tool-call-text">${r.text}</pre>`:null}
417
- `}function dg(r){for(let e=r.length-1;e>=0;e-=1){const t=r[e];if(t&&t.kind==="user")return t.id}return null}var sr,mn,el,tl,so,Ou;class Ob extends Ss{constructor(){super(...arguments);w(this,so);y(this,"messages",[]);w(this,sr,!0);w(this,mn,null);w(this,el,()=>{const t=l(this,mn);if(!t)return;const i=t.scrollHeight-t.clientHeight-t.scrollTop<=x2;i!==l(this,sr)&&(_(this,sr,i),this.toggleAttribute("data-pinned",i))});w(this,tl,()=>{_(this,sr,!0),this.toggleAttribute("data-pinned",!0),f(this,so,Ou).call(this,!0)})}changed(t){let n=!1;if(t.has("messages")){const i=t.get("messages")??[],s=dg(this.messages);n=s!==null&&s!==dg(i),n&&_(this,sr,!0)}Me(this.template(),this),l(this,mn)||_(this,mn,this.querySelector(".history-scroll")),this.toggleAttribute("data-pinned",l(this,sr)),f(this,so,Ou).call(this,n)}template(){return U`
418
- <div class="history-scroll" @scroll=${l(this,el)}>
419
- ${this.messages.map(t=>{const n=t.kind==="assistant"?xL(E2(t)):t.kind==="tool_call"?$2(t):t.text;return U`<div
420
- class="message message-${t.kind}"
421
- data-message-id=${t.id}
422
- >${n}</div>`})}
423
- </div>
424
- <button
425
- type="button"
426
- class="history-jump"
427
- aria-label="Jump to latest message"
428
- @click=${l(this,tl)}
429
- >
430
- ${Py({size:16})}
431
- </button>
432
- `}}sr=new WeakMap,mn=new WeakMap,el=new WeakMap,tl=new WeakMap,so=new WeakSet,Ou=function(t){requestAnimationFrame(()=>{const n=l(this,mn);n&&(!l(this,sr)&&!t||(n.scrollTop=n.scrollHeight-n.clientHeight))})},y(Ob,"properties",["messages"]);customElements.define("message-history",Ob);var oo,ao,Si,rl,nl,ct,_a,lo,Nu,Uu,co,uo;class Mu extends Ss{constructor(){super(...arguments);w(this,ct);y(this,"placeholder","What do you want to do?");y(this,"open",!1);y(this,"messages",[]);w(this,oo,Wt.resolve("ServerManager"));w(this,ao,Wt.resolve("ShortcutService"));w(this,Si,null);y(this,"handleTriggerActivate",()=>{this.open=!0});y(this,"handleKeydown",t=>{var o;if(t.key!=="Enter"||t.shiftKey)return;const n=t.currentTarget,i=n.value.trim();if(t.preventDefault(),!i)return;n.value="",f(this,ct,_a).call(this,n);const s=(o=l(this,oo).activeServer)==null?void 0:o.acpClient;s&&s.sendMessage({text:i}).catch(a=>{console.error("ACPClient.sendMessage() failed",a)})});w(this,rl,t=>{f(this,ct,_a).call(this,t.currentTarget)});w(this,nl,t=>{if(t.target instanceof HTMLTextAreaElement)return;const n=t.currentTarget.querySelector("textarea");n==null||n.focus()});w(this,lo,t=>{if(t.shortcut!=="focusCommandInput")return;if(!this.open){this.open=!0;return}const n=this.querySelector("textarea");if(n){if(document.activeElement===n){this.open=!1;return}n.focus()}});w(this,co,t=>{t.target instanceof Node&&(this.contains(t.target)||(this.open=!1))});w(this,uo,t=>{t.key==="Escape"&&(this.open=!1)})}connected(){const t=new DisposableStack;_(this,Si,t);const n=fO(l(this,oo),i=>{this.messages=i});t.defer(()=>n.dispose()),l(this,ao).addEventListener("shortcut-triggered",l(this,lo)),t.defer(()=>l(this,ao).removeEventListener("shortcut-triggered",l(this,lo))),this.open&&f(this,ct,Nu).call(this)}disconnected(){var t;(t=l(this,Si))==null||t.dispose(),_(this,Si,null),f(this,ct,Uu).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")),Me(this.template(),this),t.has("open"))if(this.open){f(this,ct,Nu).call(this);const n=this.querySelector("textarea");n&&(f(this,ct,_a).call(this,n),n.focus())}else f(this,ct,Uu).call(this)}template(){return this.open?U`
433
- ${this.messages.length>0?U`
434
- <div
435
- class="chat"
436
- material="paper"
437
- tone="dark"
438
- level="overlay"
439
- >
440
- <message-history .messages=${this.messages}></message-history>
441
- </div>
442
- `:null}
443
- <div
444
- class="input"
445
- material="paper"
446
- tone="dark"
447
- level="overlay"
448
- @click=${l(this,nl)}
449
- >
450
- <textarea
451
- class="textarea"
452
- rows="1"
453
- @keydown=${this.handleKeydown}
454
- @input=${l(this,rl)}
455
- ></textarea>
456
- </div>
457
- `:U`
458
- <div
459
- class="trigger"
460
- tabindex="0"
461
- role="button"
462
- @click=${this.handleTriggerActivate}
463
- @focus=${this.handleTriggerActivate}
464
- >
465
- <span class="label">${this.placeholder}</span>
466
- <span class="kbd" aria-hidden="true">⌘K</span>
467
- </div>
468
- `}}oo=new WeakMap,ao=new WeakMap,Si=new WeakMap,rl=new WeakMap,nl=new WeakMap,ct=new WeakSet,_a=function(t){t.style.height="auto",t.style.height=`${t.scrollHeight}px`},lo=new WeakMap,Nu=function(){document.addEventListener("mousedown",l(this,co)),document.addEventListener("keydown",l(this,uo))},Uu=function(){document.removeEventListener("mousedown",l(this,co)),document.removeEventListener("keydown",l(this,uo))},co=new WeakMap,uo=new WeakMap,y(Mu,"properties",["placeholder","open","messages"]),y(Mu,"attributes",{placeholder:{type:String},open:{type:Boolean}});customElements.define("command-panel",Mu);class Mb extends Event{constructor(t){super("auth-submit",{bubbles:!0,composed:!0});y(this,"token");this.token=t}}class I2 extends HTMLElement{constructor(){super(...arguments);y(this,"_invalid",!1);y(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 n=t.currentTarget;this._tokenValue=n.value}handleSubmit(t){t.preventDefault();const n=this._tokenValue.trim();n&&this.dispatchEvent(new Mb(n))}render(){Me(U`
469
- <modal-overlay open>
470
- <section class="auth-modal">
471
- <form class="auth-form" @submit=${t=>this.handleSubmit(t)}>
472
- <h2 class="auth-modal-title">Enter access token</h2>
473
- <p class="auth-modal-copy">This Television server requires a token.</p>
474
- <label class="settings-field">
475
- <span>Token</span>
476
- <input
477
- class=${this.invalid?"auth-token-input-invalid":""}
478
- type="password"
479
- name="token"
480
- .value=${this.tokenValue}
481
- @input=${t=>this.handleInput(t)}
482
- required
483
- />
484
- </label>
485
- <button type="submit" class="settings-submit-button">Connect</button>
486
- </form>
487
- </section>
488
- </modal-overlay>
489
- `,this)}}customElements.get("auth-modal")||customElements.define("auth-modal",I2);class T2 extends HTMLElement{constructor(){super(...arguments);y(this,"runtimeServerURL",fy());y(this,"electronMode",Ah());y(this,"serverManager",Wt.resolve("ServerManager"));y(this,"screenManager",Wt.resolve("ScreenManager"));y(this,"connectError",null);y(this,"handleServerManagerChange",()=>{this.render()});y(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 n=t instanceof Mb?t.token:t instanceof CustomEvent&&typeof((i=t.detail)==null?void 0:i.token)=="string"?t.detail.token:null;n&&this.handleAuthSubmit(n)}),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,xf());return}if(this.serverManager.activeServer)return;const t=new py({url:this.runtimeServerURL,name:"Server",token:xf()});this.serverManager.add(t),this.serverManager.setActive(t);try{await t.connect(),this.connectError=null}catch(n){this.connectError=n instanceof Error&&!(n instanceof ru)?n.message:null}this.render()}async handleAuthSubmit(t){const n=this.serverManager.activeServer;if(n){this.connectError=null,n.token=t,this.updateTokenQueryParam(t);try{await n.connect()}catch(i){i instanceof ru||(this.connectError=i instanceof Error?i.message:String(i))}this.render()}}updateTokenQueryParam(t){const n=new URL(window.location.href);n.searchParams.set("token",t),window.history.replaceState({},"",`${n.pathname}${n.search}${n.hash}`)}render(){const t=this.serverManager.activeServer,n=(t==null?void 0:t.status)??null;if(n==="connecting"){Me(U`
490
- <main class="auth-gate"><p>Connecting...</p></main>
491
- `,this);return}if(n==="disconnected"){const o=t;if(!o)return;Me(U`
492
- <main class="auth-gate">
493
- <auth-modal
494
- .invalid=${!!o.token}
495
- .tokenValue=${o.token??""}
496
- ></auth-modal>
497
- </main>
498
- `,this);return}const s=this.screenManager.activeScreen?U`<screen-view></screen-view>`:U`<home-screen></home-screen>`;Me(U`
499
- <main>
500
- ${this.connectError?U`<p data-testid="auth-error">${this.connectError}</p>`:U`
501
- ${s}
502
- ${n==="connected"?U`
503
- <div class="chrome">
504
- <div class="top-row electron-draggable">
505
- <button
506
- type="button"
507
- variant="glass"
508
- icon-only
509
- aria-label="Home"
510
- @click=${()=>this.screenManager.clearActive()}
511
- >
512
- ${NL({size:16,weight:"regular"})}
513
- </button>
514
- <screen-select></screen-select>
515
- <menu-bar-clock></menu-bar-clock>
516
- </div>
517
- <command-panel></command-panel>
518
- </div>
519
- `:null}
520
- `}
521
- </main>
522
- `,this)}}customElements.get("television-app")||customElements.define("television-app",T2);const Zh=Ah(),Vh=fy(),Nb=new fA(Zh?"television-electron":"television-browser",pA(Vh)),Bh=new jD({localStore:Nb,localServerURL:Vh}),Ub=new uA({localStore:Nb,serverManager:Bh}),C2=new qD;Wt.register("ServerManager",()=>Bh);Wt.register("ScreenManager",()=>Ub);Wt.register("ShortcutService",()=>C2);globalThis.__telepath={screenManager:Ub,serverManager:Bh};const Gh=document.createElement("television-app");Gh.runtimeServerURL=Vh;Gh.electronMode=Zh;Zh&&document.body.classList.add("electron");document.body.appendChild(Gh);