@telepath-computer/television 0.1.52 → 0.1.54
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.
- package/dist/cli.cjs +2 -2
- package/dist/web/assets/index-B9Lt1Vk_.js +480 -0
- package/dist/web/index.html +1 -1
- package/package.json +1 -1
- package/dist/web/assets/index-D6QBxaGL.js +0 -480
|
@@ -0,0 +1,480 @@
|
|
|
1
|
+
var ub=Object.defineProperty;var Uh=t=>{throw TypeError(t)};var hb=(t,e,n)=>e in t?ub(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var b=(t,e,n)=>hb(t,typeof e!="symbol"?e+"":e,n),gl=(t,e,n)=>e.has(t)||Uh("Cannot "+n);var l=(t,e,n)=>(gl(t,e,"read from private field"),n?n.call(t):e.get(t)),S=(t,e,n)=>e.has(t)?Uh("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),k=(t,e,n,r)=>(gl(t,e,"write to private field"),r?r.call(t,n):e.set(t,n),n),g=(t,e,n)=>(gl(t,e,"access private method"),n);var Fh=(t,e,n,r)=>({set _(i){k(t,e,i,n)},get _(){return l(t,e,r)}});(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const s of i)if(s.type==="childList")for(const o of s.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(i){const s={};return i.integrity&&(s.integrity=i.integrity),i.referrerPolicy&&(s.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?s.credentials="include":i.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function r(i){if(i.ep)return;i.ep=!0;const s=n(i);fetch(i.href,s)}})();var Rn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function db(t){if(t.__esModule)return t;var e=t.default;if(typeof e=="function"){var n=function r(){return this instanceof r?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach(function(r){var i=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(n,r,i.get?i:{enumerable:!0,get:function(){return t[r]}})}),n}var Zh=Object.prototype.toString,Df=function(e){var n=Zh.call(e),r=n==="[object Arguments]";return r||(r=n!=="[object Array]"&&e!==null&&typeof e=="object"&&typeof e.length=="number"&&e.length>=0&&Zh.call(e.callee)==="[object Function]"),r},ml,Hh;function pb(){if(Hh)return ml;Hh=1;var t;if(!Object.keys){var e=Object.prototype.hasOwnProperty,n=Object.prototype.toString,r=Df,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(y){var v=y.constructor;return v&&v.prototype===y},u={$applicationCache:!0,$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$onmozfullscreenchange:!0,$onmozfullscreenerror:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},d=function(){if(typeof window>"u")return!1;for(var y in window)try{if(!u["$"+y]&&e.call(window,y)&&window[y]!==null&&typeof window[y]=="object")try{c(window[y])}catch{return!0}}catch{return!0}return!1}(),p=function(y){if(typeof window>"u"||!d)return c(y);try{return c(y)}catch{return!1}};t=function(v){var A=v!==null&&typeof v=="object",E=n.call(v)==="[object Function]",I=r(v),Z=A&&n.call(v)==="[object String]",P=[];if(!A&&!E&&!I)throw new TypeError("Object.keys called on a non-object");var V=o&&E;if(Z&&v.length>0&&!e.call(v,0))for(var O=0;O<v.length;++O)P.push(String(O));if(I&&v.length>0)for(var H=0;H<v.length;++H)P.push(String(H));else for(var N in v)!(V&&N==="prototype")&&e.call(v,N)&&P.push(String(N));if(s)for(var ce=p(v),ue=0;ue<a.length;++ue)!(ce&&a[ue]==="constructor")&&e.call(v,a[ue])&&P.push(a[ue]);return P}}return ml=t,ml}var fb=Array.prototype.slice,gb=Df,Bh=Object.keys,Uo=Bh?function(e){return Bh(e)}:pb(),jh=Object.keys;Uo.shim=function(){if(Object.keys){var e=function(){var n=Object.keys(arguments);return n&&n.length===arguments.length}(1,2);e||(Object.keys=function(r){return gb(r)?jh(fb.call(r)):jh(r)})}else Object.keys=Uo;return Object.keys||Uo};var mb=Uo,Fo=Object.defineProperty||!1;if(Fo)try{Fo({},"a",{value:1})}catch{Fo=!1}var Ys=Fo,Kt=SyntaxError,W=TypeError,vb=Object.getOwnPropertyDescriptor,Zo=vb;if(Zo)try{Zo([],"length")}catch{Zo=null}var di=Zo,Vh=Ys,yb=Kt,xr=W,Gh=di,Of=function(e,n,r){if(!e||typeof e!="object"&&typeof e!="function")throw new xr("`obj` must be an object or a function`");if(typeof n!="string"&&typeof n!="symbol")throw new xr("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new xr("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new xr("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new xr("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new xr("`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=!!Gh&&Gh(e,n);if(Vh)Vh(e,n,{configurable:o===null&&c?c.configurable:!o,enumerable:i===null&&c?c.enumerable:!i,value:r,writable:s===null&&c?c.writable:!s});else if(a||!i&&!s&&!o)e[n]=r;else throw new yb("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},lc=Ys,zf=function(){return!!lc};zf.hasArrayLengthDefineBug=function(){if(!lc)return null;try{return lc([],"length",{value:1}).length!==1}catch{return!0}};var Na=zf,bb=mb,wb=typeof Symbol=="function"&&typeof Symbol("foo")=="symbol",Sb=Object.prototype.toString,_b=Array.prototype.concat,Wh=Of,kb=function(t){return typeof t=="function"&&Sb.call(t)==="[object Function]"},Lf=Na(),Eb=function(t,e,n,r){if(e in t){if(r===!0){if(t[e]===n)return}else if(!kb(r)||!r())return}Lf?Wh(t,e,n,!0):Wh(t,e,n)},Mf=function(t,e){var n=arguments.length>2?arguments[2]:{},r=bb(e);wb&&(r=_b.call(r,Object.getOwnPropertySymbols(e)));for(var i=0;i<r.length;i+=1)Eb(t,r[i],e[r[i]],n[r[i]])};Mf.supportsDescriptors=!!Lf;var gr=Mf,Ho={exports:{}};typeof self<"u"?Ho.exports=self:typeof window<"u"?Ho.exports=window:Ho.exports=Function("return this")();var Nf=Ho.exports,xb=Nf,Uf=function(){return typeof Rn!="object"||!Rn||Rn.Math!==Math||Rn.Array!==Array?xb:Rn},$b=gr,Ab=di,Tb=Uf,Cb=function(){var e=Tb();if($b.supportsDescriptors){var n=Ab(e,"globalThis");(!n||n.configurable&&(n.enumerable||!n.writable||globalThis!==e))&&Object.defineProperty(e,"globalThis",{configurable:!0,enumerable:!1,value:e,writable:!0})}else(typeof globalThis!="object"||globalThis!==e)&&(e.globalThis=e);return e},Ib=gr,Pb=Nf,Ff=Uf,Rb=Cb,Db=Ff(),Zf=function(){return Db};Ib(Zf,{getPolyfill:Ff,implementation:Pb,shim:Rb});var uu=Zf,Jt=function(e){return!!e&&(typeof e=="function"||typeof e=="object")},hu=Object,Hf=Error,Ob=EvalError,zb=RangeError,du=ReferenceError,Lb=URIError,Mb=Math.abs,Nb=Math.floor,Ub=Math.max,Fb=Math.min,Zb=Math.pow,Hb=Math.round,pu=Number.isNaN||function(e){return e!==e},Bb=pu,jb=function(e){return Bb(e)||e===0?e:e<0?-1:1},pi=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var e={},n=Symbol("test"),r=Object(n);if(typeof n=="string"||Object.prototype.toString.call(n)!=="[object Symbol]"||Object.prototype.toString.call(r)!=="[object Symbol]")return!1;var i=42;e[n]=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]!==n||!Object.prototype.propertyIsEnumerable.call(e,n))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var a=Object.getOwnPropertyDescriptor(e,n);if(a.value!==i||a.enumerable!==!0)return!1}return!0},qh=typeof Symbol<"u"&&Symbol,Vb=pi,fu=function(){return typeof qh!="function"||typeof Symbol!="function"||typeof qh("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:Vb()},Bf=typeof Reflect<"u"&&Reflect.getPrototypeOf||null,Gb=hu,jf=Gb.getPrototypeOf||null,Wb="Function.prototype.bind called on incompatible ",qb=Object.prototype.toString,Yb=Math.max,Kb="[object Function]",Yh=function(e,n){for(var r=[],i=0;i<e.length;i+=1)r[i]=e[i];for(var s=0;s<n.length;s+=1)r[s+e.length]=n[s];return r},Jb=function(e,n){for(var r=[],i=n,s=0;i<e.length;i+=1,s+=1)r[s]=e[i];return r},Xb=function(t,e){for(var n="",r=0;r<t.length;r+=1)n+=t[r],r+1<t.length&&(n+=e);return n},Qb=function(e){var n=this;if(typeof n!="function"||qb.apply(n)!==Kb)throw new TypeError(Wb+n);for(var r=Jb(arguments,1),i,s=function(){if(this instanceof i){var d=n.apply(this,Yh(r,arguments));return Object(d)===d?d:this}return n.apply(e,Yh(r,arguments))},o=Yb(0,n.length-r.length),a=[],c=0;c<o;c++)a[c]="$"+c;if(i=Function("binder","return function ("+Xb(a,",")+"){ return binder.apply(this,arguments); }")(s),n.prototype){var u=function(){};u.prototype=n.prototype,i.prototype=new u,u.prototype=null}return i},ew=Qb,Ks=Function.prototype.bind||ew,gu=Function.prototype.call,mu=Function.prototype.apply,tw=typeof Reflect<"u"&&Reflect&&Reflect.apply,nw=Ks,rw=mu,iw=gu,sw=tw,Vf=sw||nw.call(iw,rw),ow=Ks,aw=W,lw=gu,cw=Vf,Ua=function(e){if(e.length<1||typeof e[0]!="function")throw new aw("a function is required");return cw(ow,lw,e)},uw=Ua,Kh=di,Gf;try{Gf=[].__proto__===Array.prototype}catch(t){if(!t||typeof t!="object"||!("code"in t)||t.code!=="ERR_PROTO_ACCESS")throw t}var vl=!!Gf&&Kh&&Kh(Object.prototype,"__proto__"),Wf=Object,Jh=Wf.getPrototypeOf,hw=vl&&typeof vl.get=="function"?uw([vl.get]):typeof Jh=="function"?function(e){return Jh(e==null?e:Wf(e))}:!1,Xh=Bf,Qh=jf,ed=hw,qf=Xh?function(e){return Xh(e)}:Qh?function(e){if(!e||typeof e!="object"&&typeof e!="function")throw new TypeError("getProto: not an object");return Qh(e)}:ed?function(e){return ed(e)}:null,dw=Function.prototype.call,pw=Object.prototype.hasOwnProperty,fw=Ks,Xt=fw.call(dw,pw),G,gw=hu,mw=Hf,vw=Ob,yw=zb,bw=du,oi=Kt,Fr=W,ww=Lb,Sw=Mb,_w=Nb,kw=Ub,Ew=Fb,xw=Zb,$w=Hb,Aw=jb,Yf=Function,yl=function(t){try{return Yf('"use strict"; return ('+t+").constructor;")()}catch{}},rs=di,Tw=Ys,bl=function(){throw new Fr},Cw=rs?function(){try{return arguments.callee,bl}catch{try{return rs(arguments,"callee").get}catch{return bl}}}():bl,$r=fu(),_e=qf,Iw=jf,Pw=Bf,Kf=mu,Js=gu,Cr={},Rw=typeof Uint8Array>"u"||!_e?G:_e(Uint8Array),lr={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?G:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?G:ArrayBuffer,"%ArrayIteratorPrototype%":$r&&_e?_e([][Symbol.iterator]()):G,"%AsyncFromSyncIteratorPrototype%":G,"%AsyncFunction%":Cr,"%AsyncGenerator%":Cr,"%AsyncGeneratorFunction%":Cr,"%AsyncIteratorPrototype%":Cr,"%Atomics%":typeof Atomics>"u"?G:Atomics,"%BigInt%":typeof BigInt>"u"?G:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?G:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?G:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?G:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":mw,"%eval%":eval,"%EvalError%":vw,"%Float16Array%":typeof Float16Array>"u"?G:Float16Array,"%Float32Array%":typeof Float32Array>"u"?G:Float32Array,"%Float64Array%":typeof Float64Array>"u"?G:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?G:FinalizationRegistry,"%Function%":Yf,"%GeneratorFunction%":Cr,"%Int8Array%":typeof Int8Array>"u"?G:Int8Array,"%Int16Array%":typeof Int16Array>"u"?G:Int16Array,"%Int32Array%":typeof Int32Array>"u"?G:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":$r&&_e?_e(_e([][Symbol.iterator]())):G,"%JSON%":typeof JSON=="object"?JSON:G,"%Map%":typeof Map>"u"?G:Map,"%MapIteratorPrototype%":typeof Map>"u"||!$r||!_e?G:_e(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":gw,"%Object.getOwnPropertyDescriptor%":rs,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?G:Promise,"%Proxy%":typeof Proxy>"u"?G:Proxy,"%RangeError%":yw,"%ReferenceError%":bw,"%Reflect%":typeof Reflect>"u"?G:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?G:Set,"%SetIteratorPrototype%":typeof Set>"u"||!$r||!_e?G:_e(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?G:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":$r&&_e?_e(""[Symbol.iterator]()):G,"%Symbol%":$r?Symbol:G,"%SyntaxError%":oi,"%ThrowTypeError%":Cw,"%TypedArray%":Rw,"%TypeError%":Fr,"%Uint8Array%":typeof Uint8Array>"u"?G:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?G:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?G:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?G:Uint32Array,"%URIError%":ww,"%WeakMap%":typeof WeakMap>"u"?G:WeakMap,"%WeakRef%":typeof WeakRef>"u"?G:WeakRef,"%WeakSet%":typeof WeakSet>"u"?G:WeakSet,"%Function.prototype.call%":Js,"%Function.prototype.apply%":Kf,"%Object.defineProperty%":Tw,"%Object.getPrototypeOf%":Iw,"%Math.abs%":Sw,"%Math.floor%":_w,"%Math.max%":kw,"%Math.min%":Ew,"%Math.pow%":xw,"%Math.round%":$w,"%Math.sign%":Aw,"%Reflect.getPrototypeOf%":Pw};if(_e)try{null.error}catch(t){var Dw=_e(_e(t));lr["%Error.prototype%"]=Dw}var Ow=function t(e){var n;if(e==="%AsyncFunction%")n=yl("async function () {}");else if(e==="%GeneratorFunction%")n=yl("function* () {}");else if(e==="%AsyncGeneratorFunction%")n=yl("async function* () {}");else if(e==="%AsyncGenerator%"){var r=t("%AsyncGeneratorFunction%");r&&(n=r.prototype)}else if(e==="%AsyncIteratorPrototype%"){var i=t("%AsyncGenerator%");i&&_e&&(n=_e(i.prototype))}return lr[e]=n,n},td={__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"]},Xs=Ks,na=Xt,zw=Xs.call(Js,Array.prototype.concat),Lw=Xs.call(Kf,Array.prototype.splice),nd=Xs.call(Js,String.prototype.replace),ra=Xs.call(Js,String.prototype.slice),Mw=Xs.call(Js,RegExp.prototype.exec),Nw=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,Uw=/\\(\\)?/g,Fw=function(e){var n=ra(e,0,1),r=ra(e,-1);if(n==="%"&&r!=="%")throw new oi("invalid intrinsic syntax, expected closing `%`");if(r==="%"&&n!=="%")throw new oi("invalid intrinsic syntax, expected opening `%`");var i=[];return nd(e,Nw,function(s,o,a,c){i[i.length]=a?nd(c,Uw,"$1"):o||s}),i},Zw=function(e,n){var r=e,i;if(na(td,r)&&(i=td[r],r="%"+i[0]+"%"),na(lr,r)){var s=lr[r];if(s===Cr&&(s=Ow(r)),typeof s>"u"&&!n)throw new Fr("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:i,name:r,value:s}}throw new oi("intrinsic "+e+" does not exist!")},ot=function(e,n){if(typeof e!="string"||e.length===0)throw new Fr("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof n!="boolean")throw new Fr('"allowMissing" argument must be a boolean');if(Mw(/^%?[^%]*%?$/,e)===null)throw new oi("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var r=Fw(e),i=r.length>0?r[0]:"",s=Zw("%"+i+"%",n),o=s.name,a=s.value,c=!1,u=s.alias;u&&(i=u[0],Lw(r,zw([0,1],u)));for(var d=1,p=!0;d<r.length;d+=1){var y=r[d],v=ra(y,0,1),A=ra(y,-1);if((v==='"'||v==="'"||v==="`"||A==='"'||A==="'"||A==="`")&&v!==A)throw new oi("property names with quotes must have matching quotes");if((y==="constructor"||!p)&&(c=!0),i+="."+y,o="%"+i+"%",na(lr,o))a=lr[o];else if(a!=null){if(!(y in a)){if(!n)throw new Fr("base intrinsic for "+e+" exists, but the property is not available.");return}if(rs&&d+1>=r.length){var E=rs(a,y);p=!!E,p&&"get"in E&&!("originalValue"in E.get)?a=E.get:a=a[y]}else p=na(a,y),a=a[y];p&&!c&&(lr[o]=a)}}return a},wl,rd;function Sn(){if(rd)return wl;rd=1;var t=ot,e=Ua,n=e([t("%String.prototype.indexOf%")]);return wl=function(i,s){var o=t(i,!!s);return typeof o=="function"&&n(i,".prototype.")>-1?e([o]):o},wl}var Sl,id;function vu(){if(id)return Sl;id=1;var t=ot,e=t("%Array%"),n=!e.isArray&&Sn()("Object.prototype.toString");return Sl=e.isArray||function(i){return n(i)==="[object Array]"},Sl}var Hw=Na,sd=Ys,Jf=Hw.hasArrayLengthDefineBug(),Bw=Jf&&vu(),jw=Sn(),Vw=jw("Object.prototype.propertyIsEnumerable"),yu=function(e,n,r,i,s,o){if(!sd){if(!e(o)||!o["[[Configurable]]"]||!o["[[Writable]]"]||s in i&&Vw(i,s)!==!!o["[[Enumerable]]"])return!1;var a=o["[[Value]]"];return i[s]=a,n(i[s],a)}return Jf&&s==="length"&&"[[Value]]"in o&&Bw(i)&&i.length!==o["[[Value]]"]?(i.length=o["[[Value]]"],i.length===o["[[Value]]"]):(sd(i,s,r(o)),!0)},Gw=W,Ci=Xt,Ww={__proto__:null,"[[Configurable]]":!0,"[[Enumerable]]":!0,"[[Get]]":!0,"[[Set]]":!0,"[[Value]]":!0,"[[Writable]]":!0},fi=function(e){if(!e||typeof e!="object")return!1;for(var n in e)if(Ci(e,n)&&!Ww[n])return!1;var r=Ci(e,"[[Value]]")||Ci(e,"[[Writable]]"),i=Ci(e,"[[Get]]")||Ci(e,"[[Set]]");if(r&&i)throw new Gw("Property Descriptors may not be both accessor and data descriptors");return!0},Xf=function(e){if(typeof e>"u")return e;var n={};return"[[Value]]"in e&&(n.value=e["[[Value]]"]),"[[Writable]]"in e&&(n.writable=!!e["[[Writable]]"]),"[[Get]]"in e&&(n.get=e["[[Get]]"]),"[[Set]]"in e&&(n.set=e["[[Set]]"]),"[[Enumerable]]"in e&&(n.enumerable=!!e["[[Enumerable]]"]),"[[Configurable]]"in e&&(n.configurable=!!e["[[Configurable]]"]),n},qw=W,Yw=fi,Kw=Xf,Qf=function(e){if(typeof e<"u"&&!Yw(e))throw new qw("Assertion failed: `Desc` must be a Property Descriptor");return Kw(e)},Jw=W,od=Xt,Xw=fi,eg=function(e){if(typeof e>"u")return!1;if(!Xw(e))throw new Jw("Assertion failed: `Desc` must be a Property Descriptor");return!(!od(e,"[[Value]]")&&!od(e,"[[Writable]]"))},gi=function(e){return typeof e=="string"||typeof e=="symbol"},ad=pu,tg=function(e,n){return e===n?e===0?1/e===1/n:!0:ad(e)&&ad(n)},ld=W,Qw=Jt,e0=yu,t0=Qf,n0=eg,r0=gi,i0=tg,bu=function(e,n,r){if(!Qw(e))throw new ld("Assertion failed: Type(O) is not Object");if(!r0(n))throw new ld("Assertion failed: P is not a Property Key");var i={"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Value]]":r,"[[Writable]]":!0};return e0(n0,i0,t0,e,n,i)},ng=Function.prototype.toString,Lr=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,cc,Bo;if(typeof Lr=="function"&&typeof Object.defineProperty=="function")try{cc=Object.defineProperty({},"length",{get:function(){throw Bo}}),Bo={},Lr(function(){throw 42},null,cc)}catch(t){t!==Bo&&(Lr=null)}else Lr=null;var s0=/^\s*class\b/,uc=function(e){try{var n=ng.call(e);return s0.test(n)}catch{return!1}},_l=function(e){try{return uc(e)?!1:(ng.call(e),!0)}catch{return!1}},jo=Object.prototype.toString,o0="[object Object]",a0="[object Function]",l0="[object GeneratorFunction]",c0="[object HTMLAllCollection]",u0="[object HTML document.all class]",h0="[object HTMLCollection]",d0=typeof Symbol=="function"&&!!Symbol.toStringTag,p0=!(0 in[,]),hc=function(){return!1};if(typeof document=="object"){var f0=document.all;jo.call(f0)===jo.call(document.all)&&(hc=function(e){if((p0||!e)&&(typeof e>"u"||typeof e=="object"))try{var n=jo.call(e);return(n===c0||n===u0||n===h0||n===o0)&&e("")==null}catch{}return!1})}var rg=Lr?function(e){if(hc(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;try{Lr(e,null,cc)}catch(n){if(n!==Bo)return!1}return!uc(e)&&_l(e)}:function(e){if(hc(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;if(d0)return _l(e);if(uc(e))return!1;var n=jo.call(e);return n!==a0&&n!==l0&&!/^\[object HTML/.test(n)?!1:_l(e)},g0=rg,m0=function(e){return!!e},wt=Xt,bo=W,v0=Jt,cd=g0,kl=m0,y0=function(e){if(!v0(e))throw new bo("ToPropertyDescriptor requires an object");var n={};if(wt(e,"enumerable")&&(n["[[Enumerable]]"]=kl(e.enumerable)),wt(e,"configurable")&&(n["[[Configurable]]"]=kl(e.configurable)),wt(e,"value")&&(n["[[Value]]"]=e.value),wt(e,"writable")&&(n["[[Writable]]"]=kl(e.writable)),wt(e,"get")){var r=e.get;if(typeof r<"u"&&!cd(r))throw new bo("getter must be a function");n["[[Get]]"]=r}if(wt(e,"set")){var i=e.set;if(typeof i<"u"&&!cd(i))throw new bo("setter must be a function");n["[[Set]]"]=i}if((wt(n,"[[Get]]")||wt(n,"[[Set]]"))&&(wt(n,"[[Value]]")||wt(n,"[[Writable]]")))throw new bo("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute");return n},El=W,b0=Jt,ud=fi,w0=yu,S0=Qf,_0=eg,k0=gi,E0=tg,x0=y0,$0=function(e,n,r){if(!b0(e))throw new El("Assertion failed: Type(O) is not Object");if(!k0(n))throw new El("Assertion failed: P is not a Property Key");var i=ud(r)?r:x0(r);if(!ud(i))throw new El("Assertion failed: Desc is not a valid Property Descriptor");return w0(_0,E0,S0,e,n,i)},hd=W,A0=Jt,T0=$0,C0=gi,I0=function(e,n,r){if(!A0(e))throw new hd("Assertion failed: Type(O) is not Object");if(!C0(n))throw new hd("Assertion failed: P is not a Property Key");var i={"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Value]]":r,"[[Writable]]":!0};return T0(e,n,i)},P0=typeof Reflect<"u"&&Reflect.setPrototypeOf||null,R0=hu,D0=R0.setPrototypeOf||null,O0=Ua,dd=di,z0=W,ig={};try{ig.__proto__=null}catch(t){if(!t||typeof t!="object"||!("code"in t)||t.code!=="ERR_PROTO_ACCESS")throw t}var L0=!("toString"in ig),xl=dd&&dd(Object.prototype,"__proto__"),M0=L0&&(!!xl&&typeof xl.set=="function"&&O0([xl.set])||function(e,n){if(e==null)throw new z0("set Object.prototype.__proto__ called on null or undefined");return e.__proto__=n,n}),pd=P0,N0=D0,fd=M0,U0=W,F0=pd?function(e,n){if(pd(e,n))return e;throw new U0("Reflect.setPrototypeOf: failed to set [[Prototype]]")}:N0||(fd?function(e,n){return fd(e,n),e}:null),gd=W,Z0=Jt,md=qf,H0=function(e){if(!Z0(e))throw new gd("Assertion failed: O must be an Object");if(!md)throw new gd("This environment does not support fetching prototypes.");return md(e)},B0=W,j0=F0,V0=Jt,G0=H0,W0=function(e,n){if(n!==null&&!V0(n))throw new B0("Assertion failed: V must be Object or Null");try{j0(e,n)}catch{return!1}return G0(e)===n},$l=bu,vd=I0,sg=W0,q0=Na(),wu=Hf;function Qs(t,e,n){var r=new wu(n);return sg(r,Vo),delete r.constructor,vd(r,"error",t),vd(r,"suppressed",e),r}q0&&Object.defineProperty(Qs,"prototype",{writable:!1});var Vo=Qs.prototype;if(!$l(Vo,"constructor",Qs)||!$l(Vo,"message","")||!$l(Vo,"name","SuppressedError"))throw new wu("unable to install SuppressedError.prototype properties; please report this!");sg(Qs.prototype,wu.prototype);var Y0=Qs,K0=Y0,og=function(){return typeof SuppressedError=="function"?SuppressedError:K0},J0=gr,yd=uu(),X0=og,Q0=function(){var e=X0();return J0(yd,{SuppressedError:e},{SuppressedError:function(){return yd.SuppressedError!==e}}),e};Q0();var eS=W,tS=fi,nS=Xf,rS=function(e){if(typeof e<"u"&&!tS(e))throw new eS("Assertion failed: `Desc` must be a Property Descriptor");return nS(e)},iS=W,bd=Xt,sS=fi,oS=function(e){if(typeof e>"u")return!1;if(!sS(e))throw new iS("Assertion failed: `Desc` must be a Property Descriptor");return!(!bd(e,"[[Value]]")&&!bd(e,"[[Writable]]"))},wd=pu,aS=function(e,n){return e===n?e===0?1/e===1/n:!0:wd(e)&&wd(n)},mi=rg,lS=function(e){return!!e},St=Xt,wo=W,cS=Jt,Sd=mi,Al=lS,uS=function(e){if(!cS(e))throw new wo("ToPropertyDescriptor requires an object");var n={};if(St(e,"enumerable")&&(n["[[Enumerable]]"]=Al(e.enumerable)),St(e,"configurable")&&(n["[[Configurable]]"]=Al(e.configurable)),St(e,"value")&&(n["[[Value]]"]=e.value),St(e,"writable")&&(n["[[Writable]]"]=Al(e.writable)),St(e,"get")){var r=e.get;if(typeof r<"u"&&!Sd(r))throw new wo("getter must be a function");n["[[Get]]"]=r}if(St(e,"set")){var i=e.set;if(typeof i<"u"&&!Sd(i))throw new wo("setter must be a function");n["[[Set]]"]=i}if((St(n,"[[Get]]")||St(n,"[[Set]]"))&&(St(n,"[[Value]]")||St(n,"[[Writable]]")))throw new wo("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute");return n},Tl=W,hS=Jt,_d=fi,dS=yu,pS=rS,fS=oS,gS=gi,mS=aS,vS=uS,eo=function(e,n,r){if(!hS(e))throw new Tl("Assertion failed: Type(O) is not Object");if(!gS(n))throw new Tl("Assertion failed: P is not a Property Key");var i=_d(r)?r:vS(r);if(!_d(i))throw new Tl("Assertion failed: Desc is not a valid Property Descriptor");return dS(fS,mS,pS,e,n,i)},yS=pi(),bS=yS?Symbol.dispose||Symbol("Symbol.dispose"):null,wS=pi,SS=bS,Su=function(){return wS()&&Symbol.dispose||SS},_S=fu,kS=eo,ES=Su,xS=function(){var e=ES();return _S()&&kS(Symbol,"dispose",{"[[Configurable]]":!1,"[[Enumerable]]":!1,"[[Writable]]":!1,"[[Value]]":e}),e},$S=pi(),AS=$S?Symbol.asyncDispose||Symbol("Symbol.asyncDispose"):null,TS=pi,CS=AS,_u=function(){return TS()&&Symbol.asyncDispose||CS},IS=fu,PS=eo,RS=_u,DS=function(){var e=RS();return IS()&&PS(Symbol,"asyncDispose",{"[[Configurable]]":!1,"[[Enumerable]]":!1,"[[Writable]]":!1,"[[Value]]":e}),e},OS=vu(),zS=ot,LS=Sn(),MS=W,NS=OS,US=zS("%Reflect.apply%",!0)||LS("Function.prototype.apply"),Fa=function(e,n){var r=arguments.length>2?arguments[2]:[];if(!NS(r))throw new MS("Assertion failed: optional `argumentsList`, if provided, must be a List");return US(e,n,r)};const FS={},ZS=Object.freeze(Object.defineProperty({__proto__:null,default:FS},Symbol.toStringTag,{value:"Module"})),HS=db(ZS);var ku=typeof Map=="function"&&Map.prototype,Cl=Object.getOwnPropertyDescriptor&&ku?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,ia=ku&&Cl&&typeof Cl.get=="function"?Cl.get:null,kd=ku&&Map.prototype.forEach,Eu=typeof Set=="function"&&Set.prototype,Il=Object.getOwnPropertyDescriptor&&Eu?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,sa=Eu&&Il&&typeof Il.get=="function"?Il.get:null,Ed=Eu&&Set.prototype.forEach,BS=typeof WeakMap=="function"&&WeakMap.prototype,Xi=BS?WeakMap.prototype.has:null,jS=typeof WeakSet=="function"&&WeakSet.prototype,Qi=jS?WeakSet.prototype.has:null,VS=typeof WeakRef=="function"&&WeakRef.prototype,xd=VS?WeakRef.prototype.deref:null,GS=Boolean.prototype.valueOf,WS=Object.prototype.toString,qS=Function.prototype.toString,YS=String.prototype.match,xu=String.prototype.slice,dn=String.prototype.replace,KS=String.prototype.toUpperCase,$d=String.prototype.toLowerCase,ag=RegExp.prototype.test,Ad=Array.prototype.concat,It=Array.prototype.join,JS=Array.prototype.slice,Td=Math.floor,dc=typeof BigInt=="function"?BigInt.prototype.valueOf:null,Pl=Object.getOwnPropertySymbols,pc=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,ai=typeof Symbol=="function"&&typeof Symbol.iterator=="object",es=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===ai||!0)?Symbol.toStringTag:null,lg=Object.prototype.propertyIsEnumerable,Cd=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(t){return t.__proto__}:null);function Id(t,e){if(t===1/0||t===-1/0||t!==t||t&&t>-1e3&&t<1e3||ag.call(/e/,e))return e;var n=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof t=="number"){var r=t<0?-Td(-t):Td(t);if(r!==t){var i=String(r),s=xu.call(e,i.length+1);return dn.call(i,n,"$&_")+"."+dn.call(dn.call(s,/([0-9]{3})/g,"$&_"),/_$/,"")}}return dn.call(e,n,"$&_")}var fc=HS,Pd=fc.custom,Rd=hg(Pd)?Pd:null,cg={__proto__:null,double:'"',single:"'"},XS={__proto__:null,double:/(["\\])/g,single:/(['\\])/g},vi=function t(e,n,r,i){var s=n||{};if(Nt(s,"quoteStyle")&&!Nt(cg,s.quoteStyle))throw new TypeError('option "quoteStyle" must be "single" or "double"');if(Nt(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=Nt(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(Nt(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(Nt(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 pg(e,s);if(typeof e=="number"){if(e===0)return 1/0/e>0?"0":"-0";var c=String(e);return a?Id(e,c):c}if(typeof e=="bigint"){var u=String(e)+"n";return a?Id(e,u):u}var d=typeof s.depth>"u"?5:s.depth;if(typeof r>"u"&&(r=0),r>=d&&d>0&&typeof e=="object")return gc(e)?"[Array]":"[Object]";var p=m_(s,r);if(typeof i>"u")i=[];else if(dg(i,e)>=0)return"[Circular]";function y(vt,en,rl){if(en&&(i=JS.call(i),i.push(en)),rl){var co={depth:s.depth};return Nt(s,"quoteStyle")&&(co.quoteStyle=s.quoteStyle),t(vt,co,r+1,i)}return t(vt,s,r+1,i)}if(typeof e=="function"&&!Dd(e)){var v=a_(e),A=So(e,y);return"[Function"+(v?": "+v:" (anonymous)")+"]"+(A.length>0?" { "+It.call(A,", ")+" }":"")}if(hg(e)){var E=ai?dn.call(String(e),/^(Symbol\(.*\))_[^)]*$/,"$1"):pc.call(e);return typeof e=="object"&&!ai?Ii(E):E}if(p_(e)){for(var I="<"+$d.call(String(e.nodeName)),Z=e.attributes||[],P=0;P<Z.length;P++)I+=" "+Z[P].name+"="+ug(QS(Z[P].value),"double",s);return I+=">",e.childNodes&&e.childNodes.length&&(I+="..."),I+="</"+$d.call(String(e.nodeName))+">",I}if(gc(e)){if(e.length===0)return"[]";var V=So(e,y);return p&&!g_(V)?"["+mc(V,p)+"]":"[ "+It.call(V,", ")+" ]"}if(t_(e)){var O=So(e,y);return!("cause"in Error.prototype)&&"cause"in e&&!lg.call(e,"cause")?"{ ["+String(e)+"] "+It.call(Ad.call("[cause]: "+y(e.cause),O),", ")+" }":O.length===0?"["+String(e)+"]":"{ ["+String(e)+"] "+It.call(O,", ")+" }"}if(typeof e=="object"&&o){if(Rd&&typeof e[Rd]=="function"&&fc)return fc(e,{depth:d-r});if(o!=="symbol"&&typeof e.inspect=="function")return e.inspect()}if(l_(e)){var H=[];return kd&&kd.call(e,function(vt,en){H.push(y(en,e,!0)+" => "+y(vt,e))}),Od("Map",ia.call(e),H,p)}if(h_(e)){var N=[];return Ed&&Ed.call(e,function(vt){N.push(y(vt,e))}),Od("Set",sa.call(e),N,p)}if(c_(e))return Rl("WeakMap");if(d_(e))return Rl("WeakSet");if(u_(e))return Rl("WeakRef");if(r_(e))return Ii(y(Number(e)));if(s_(e))return Ii(y(dc.call(e)));if(i_(e))return Ii(GS.call(e));if(n_(e))return Ii(y(String(e)));if(typeof window<"u"&&e===window)return"{ [object Window] }";if(typeof globalThis<"u"&&e===globalThis||typeof Rn<"u"&&e===Rn)return"{ [object globalThis] }";if(!e_(e)&&!Dd(e)){var ce=So(e,y),ue=Cd?Cd(e)===Object.prototype:e instanceof Object||e.constructor===Object,xi=e instanceof Object?"":"null prototype",lo=!ue&&es&&Object(e)===e&&es in e?xu.call(_n(e),8,-1):xi?"Object":"",xe=ue||typeof e.constructor!="function"?"":e.constructor.name?e.constructor.name+" ":"",xn=xe+(lo||xi?"["+It.call(Ad.call([],lo||[],xi||[]),": ")+"] ":"");return ce.length===0?xn+"{}":p?xn+"{"+mc(ce,p)+"}":xn+"{ "+It.call(ce,", ")+" }"}return String(e)};function ug(t,e,n){var r=n.quoteStyle||e,i=cg[r];return i+t+i}function QS(t){return dn.call(String(t),/"/g,""")}function mr(t){return!es||!(typeof t=="object"&&(es in t||typeof t[es]<"u"))}function gc(t){return _n(t)==="[object Array]"&&mr(t)}function e_(t){return _n(t)==="[object Date]"&&mr(t)}function Dd(t){return _n(t)==="[object RegExp]"&&mr(t)}function t_(t){return _n(t)==="[object Error]"&&mr(t)}function n_(t){return _n(t)==="[object String]"&&mr(t)}function r_(t){return _n(t)==="[object Number]"&&mr(t)}function i_(t){return _n(t)==="[object Boolean]"&&mr(t)}function hg(t){if(ai)return t&&typeof t=="object"&&t instanceof Symbol;if(typeof t=="symbol")return!0;if(!t||typeof t!="object"||!pc)return!1;try{return pc.call(t),!0}catch{}return!1}function s_(t){if(!t||typeof t!="object"||!dc)return!1;try{return dc.call(t),!0}catch{}return!1}var o_=Object.prototype.hasOwnProperty||function(t){return t in this};function Nt(t,e){return o_.call(t,e)}function _n(t){return WS.call(t)}function a_(t){if(t.name)return t.name;var e=YS.call(qS.call(t),/^function\s*([\w$]+)/);return e?e[1]:null}function dg(t,e){if(t.indexOf)return t.indexOf(e);for(var n=0,r=t.length;n<r;n++)if(t[n]===e)return n;return-1}function l_(t){if(!ia||!t||typeof t!="object")return!1;try{ia.call(t);try{sa.call(t)}catch{return!0}return t instanceof Map}catch{}return!1}function c_(t){if(!Xi||!t||typeof t!="object")return!1;try{Xi.call(t,Xi);try{Qi.call(t,Qi)}catch{return!0}return t instanceof WeakMap}catch{}return!1}function u_(t){if(!xd||!t||typeof t!="object")return!1;try{return xd.call(t),!0}catch{}return!1}function h_(t){if(!sa||!t||typeof t!="object")return!1;try{sa.call(t);try{ia.call(t)}catch{return!0}return t instanceof Set}catch{}return!1}function d_(t){if(!Qi||!t||typeof t!="object")return!1;try{Qi.call(t,Qi);try{Xi.call(t,Xi)}catch{return!0}return t instanceof WeakSet}catch{}return!1}function p_(t){return!t||typeof t!="object"?!1:typeof HTMLElement<"u"&&t instanceof HTMLElement?!0:typeof t.nodeName=="string"&&typeof t.getAttribute=="function"}function pg(t,e){if(t.length>e.maxStringLength){var n=t.length-e.maxStringLength,r="... "+n+" more character"+(n>1?"s":"");return pg(xu.call(t,0,e.maxStringLength),e)+r}var i=XS[e.quoteStyle||"single"];i.lastIndex=0;var s=dn.call(dn.call(t,i,"\\$1"),/[\x00-\x1f]/g,f_);return ug(s,"single",e)}function f_(t){var e=t.charCodeAt(0),n={8:"b",9:"t",10:"n",12:"f",13:"r"}[e];return n?"\\"+n:"\\x"+(e<16?"0":"")+KS.call(e.toString(16))}function Ii(t){return"Object("+t+")"}function Rl(t){return t+" { ? }"}function Od(t,e,n,r){var i=r?mc(n,r):It.call(n,", ");return t+" ("+e+") {"+i+"}"}function g_(t){for(var e=0;e<t.length;e++)if(dg(t[e],`
|
|
2
|
+
`)>=0)return!1;return!0}function m_(t,e){var n;if(t.indent===" ")n=" ";else if(typeof t.indent=="number"&&t.indent>0)n=It.call(Array(t.indent+1)," ");else return null;return{base:n,prev:It.call(Array(e+1),n)}}function mc(t,e){if(t.length===0)return"";var n=`
|
|
3
|
+
`+e.prev+e.base;return n+It.call(t,","+n)+`
|
|
4
|
+
`+e.prev}function So(t,e){var n=gc(t),r=[];if(n){r.length=t.length;for(var i=0;i<t.length;i++)r[i]=Nt(t,i)?e(t[i],t):""}var s=typeof Pl=="function"?Pl(t):[],o;if(ai){o={};for(var a=0;a<s.length;a++)o["$"+s[a]]=s[a]}for(var c in t)Nt(t,c)&&(n&&String(Number(c))===c&&c<t.length||ai&&o["$"+c]instanceof Symbol||(ag.call(/[^\w$]/,c)?r.push(e(c,t)+": "+e(t[c],t)):r.push(c+": "+e(t[c],t))));if(typeof Pl=="function")for(var u=0;u<s.length;u++)lg.call(t,s[u])&&r.push("["+e(s[u])+"]: "+e(t[s[u]],t));return r}var v_=vi,y_=W,Za=function(t,e,n){for(var r=t,i;(i=r.next)!=null;r=i)if(i.key===e)return r.next=i.next,n||(i.next=t.next,t.next=i),i},b_=function(t,e){if(t){var n=Za(t,e);return n&&n.value}},w_=function(t,e,n){var r=Za(t,e);r?r.value=n:t.next={key:e,next:t.next,value:n}},S_=function(t,e){return t?!!Za(t,e):!1},__=function(t,e){if(t)return Za(t,e,!0)},k_=function(){var e,n={assert:function(r){if(!n.has(r))throw new y_("Side channel does not contain "+v_(r))},delete:function(r){var i=e&&e.next,s=__(e,r);return s&&i&&i===s&&(e=void 0),!!s},get:function(r){return b_(e,r)},has:function(r){return S_(e,r)},set:function(r,i){e||(e={next:void 0}),w_(e,r,i)}};return n},E_=ot,to=Sn(),x_=vi,$_=W,zd=E_("%Map%",!0),A_=to("Map.prototype.get",!0),T_=to("Map.prototype.set",!0),C_=to("Map.prototype.has",!0),I_=to("Map.prototype.delete",!0),P_=to("Map.prototype.size",!0),fg=!!zd&&function(){var e,n={assert:function(r){if(!n.has(r))throw new $_("Side channel does not contain "+x_(r))},delete:function(r){if(e){var i=I_(e,r);return P_(e)===0&&(e=void 0),i}return!1},get:function(r){if(e)return A_(e,r)},has:function(r){return e?C_(e,r):!1},set:function(r,i){e||(e=new zd),T_(e,r,i)}};return n},R_=ot,Ha=Sn(),D_=vi,_o=fg,O_=W,Ar=R_("%WeakMap%",!0),z_=Ha("WeakMap.prototype.get",!0),L_=Ha("WeakMap.prototype.set",!0),M_=Ha("WeakMap.prototype.has",!0),N_=Ha("WeakMap.prototype.delete",!0),U_=Ar?function(){var e,n,r={assert:function(i){if(!r.has(i))throw new O_("Side channel does not contain "+D_(i))},delete:function(i){if(Ar&&i&&(typeof i=="object"||typeof i=="function")){if(e)return N_(e,i)}else if(_o&&n)return n.delete(i);return!1},get:function(i){return Ar&&i&&(typeof i=="object"||typeof i=="function")&&e?z_(e,i):n&&n.get(i)},has:function(i){return Ar&&i&&(typeof i=="object"||typeof i=="function")&&e?M_(e,i):!!n&&n.has(i)},set:function(i,s){Ar&&i&&(typeof i=="object"||typeof i=="function")?(e||(e=new Ar),L_(e,i,s)):_o&&(n||(n=_o()),n.set(i,s))}};return r}:_o,F_=W,Z_=vi,H_=k_,B_=fg,j_=U_,V_=j_||B_||H_,G_=function(){var e,n={assert:function(r){if(!n.has(r))throw new F_("Side channel does not contain "+Z_(r))},delete:function(r){return!!e&&e.delete(r)},get:function(r){return e&&e.get(r)},has:function(r){return!!e&&e.has(r)},set:function(r,i){e||(e=V_()),e.set(r,i)}};return n},W_=Xt,Pi=G_(),zt=W,$u={assert:function(t,e){if(!t||typeof t!="object"&&typeof t!="function")throw new zt("`O` is not an object");if(typeof e!="string")throw new zt("`slot` must be a string");if(Pi.assert(t),!$u.has(t,e))throw new zt("`"+e+"` is not present on `O`")},get:function(t,e){if(!t||typeof t!="object"&&typeof t!="function")throw new zt("`O` is not an object");if(typeof e!="string")throw new zt("`slot` must be a string");var n=Pi.get(t);return n&&n["$"+e]},has:function(t,e){if(!t||typeof t!="object"&&typeof t!="function")throw new zt("`O` is not an object");if(typeof e!="string")throw new zt("`slot` must be a string");var n=Pi.get(t);return!!n&&W_(n,"$"+e)},set:function(t,e,n){if(!t||typeof t!="object"&&typeof t!="function")throw new zt("`O` is not an object");if(typeof e!="string")throw new zt("`slot` must be a string");var r=Pi.get(t);r||(r={},Pi.set(t,r)),r["$"+e]=n}};Object.freeze&&Object.freeze($u);var Au=$u,gg=Kt,pn=Au,no=function t(e,n){if(!(this instanceof t))return new t(e,n);if(e!=="normal"&&e!=="break"&&e!=="continue"&&e!=="return"&&e!=="throw")throw new gg('Assertion failed: `type` must be one of "normal", "break", "continue", "return", or "throw"');pn.set(this,"[[Type]]",e),pn.set(this,"[[Value]]",n)};no.prototype.type=function(){return pn.get(this,"[[Type]]")};no.prototype.value=function(){return pn.get(this,"[[Value]]")};no.prototype["?"]=function(){var e=pn.get(this,"[[Type]]"),n=pn.get(this,"[[Value]]");if(e==="throw")throw n;return n};no.prototype["!"]=function(){var e=pn.get(this,"[[Type]]");if(e!=="normal")throw new gg('Assertion failed: Completion Record is not of type "normal"');return pn.get(this,"[[Value]]")};var Tu=no,q_=Tu,Cu=function(e){return new q_("normal",e)},Dl,Ld;function Y_(){if(Ld)return Dl;Ld=1;var t=pi;return Dl=function(){return t()&&!!Symbol.toStringTag},Dl}var K_=ot,Md=K_("%Object.defineProperty%",!0),J_=Y_()(),X_=Xt,Q_=W,ko=J_?Symbol.toStringTag:null,mg=function(e,n){var r=arguments.length>2&&!!arguments[2]&&arguments[2].force,i=arguments.length>2&&!!arguments[2]&&arguments[2].nonConfigurable;if(typeof r<"u"&&typeof r!="boolean"||typeof i<"u"&&typeof i!="boolean")throw new Q_("if provided, the `overrideIfSet` and `nonConfigurable` options must be booleans");ko&&(r||!X_(e,ko))&&(Md?Md(e,ko,{configurable:!i,enumerable:!1,value:n,writable:!1}):e[ko]=n)},vg={exports:{}},ek=ot,Nd=Of,tk=Na(),Ud=di,Fd=W,nk=ek("%Math.floor%"),rk=function(e,n){if(typeof e!="function")throw new Fd("`fn` is not a function");if(typeof n!="number"||n<0||n>4294967295||nk(n)!==n)throw new Fd("`length` must be a positive 32-bit integer");var r=arguments.length>2&&!!arguments[2],i=!0,s=!0;if("length"in e&&Ud){var o=Ud(e,"length");o&&!o.configurable&&(i=!1),o&&!o.writable&&(s=!1)}return(i||s||!r)&&(tk?Nd(e,"length",n,!0,!0):Nd(e,"length",n)),e},ik=Ks,sk=mu,ok=Vf,ak=function(){return ok(ik,sk,arguments)};(function(t){var e=rk,n=Ys,r=Ua,i=ak;t.exports=function(o){var a=r(arguments),c=1+o.length-(arguments.length-1);return e(a,c>0?c:0,!0)},n?n(t.exports,"apply",{value:i}):t.exports.apply=i})(vg);var Iu=vg.exports,lk=function(e,n){for(var r=0;r<e.length;r+=1)if(!n(e[r],r,e))return!1;return!0},ck=Object,uk=function(e){return e&&typeof e=="object"&&(typeof e["[[ResourceValue]]"]>"u"||ck(e["[[ResourceValue]]"])===e["[[ResourceValue]]"])&&(e["[[Hint]]"]==="SYNC-DISPOSE"||e["[[Hint]]"]==="ASYNC-DISPOSE")&&(typeof e["[[DisposeMethod]]"]=="function"||typeof e["[[DisposeMethod]]"]>"u")},hk=Xt,dk=vu(),pk=lk,fk=uk,gk=function(e){return e&&typeof e=="object"&&hk(e,"[[DisposableResourceStack]]")&&dk(e["[[DisposableResourceStack]]"])&&(e["[[DisposableResourceStack]]"].length===0||pk(e["[[DisposableResourceStack]]"],fk))},mk=Jt,vk=function(e){if(e===null)return"Null";if(typeof e>"u")return"Undefined";if(mk(e))return"Object";if(typeof e=="number")return"Number";if(typeof e=="boolean")return"Boolean";if(typeof e=="string")return"String"},yk=vk,Pu=function(e){return typeof e=="symbol"?"Symbol":typeof e=="bigint"?"BigInt":yk(e)},bk=W,wk=vi,Sk=gi,_k=function(e,n){if(!Sk(n))throw new bk("Assertion failed: P is not a Property Key, got "+wk(n));return e[n]},Zd=W,kk=_k,Ek=mi,xk=gi,Hd=vi,$k=function(e,n){if(!xk(n))throw new Zd("Assertion failed: P is not a Property Key");var r=kk(e,n);if(r!=null){if(!Ek(r))throw new Zd(Hd(n)+" is not a function: "+Hd(r));return r}},vc={exports:{}},Ak=ot,Tk=Ak,Bd=Tk("%Reflect.construct%",!0),oa=eo;try{oa({},"",{"[[Get]]":function(){}})}catch{oa=null}if(oa&&Bd){var jd={},Vd={};oa(Vd,"length",{"[[Get]]":function(){throw jd},"[[Enumerable]]":!0}),vc.exports=function(e){try{Bd(e,Vd)}catch(n){return n===jd}}}else vc.exports=function(e){return typeof e=="function"&&!!e.prototype};var Ck=vc.exports,Ol=W,Gd=mi,Ik=Ck,Pk=function(e){if(!Ik(e))throw new Ol("C must be a constructor");var n={"[[Resolve]]":void 0,"[[Reject]]":void 0},r=new e(function(i,s){if(typeof n["[[Resolve]]"]<"u"||typeof n["[[Reject]]"]<"u")throw new Ol("executor has already been called");n["[[Resolve]]"]=i,n["[[Reject]]"]=s});if(!Gd(n["[[Resolve]]"])||!Gd(n["[[Reject]]"]))throw new Ol("executor must provide valid resolve and reject functions");return{"[[Promise]]":r,"[[Resolve]]":n["[[Resolve]]"],"[[Reject]]":n["[[Reject]]"]}},Wd=Kt,Rk=W,zl=Fa,qd=$k,Dk=Pk,Ok=Pu,Yd=Su(),Kd=_u(),zk=function(e,n){if(Ok(e)!=="Object")throw new Rk("`V` must be an Object");if(n!=="SYNC-DISPOSE"&&n!=="ASYNC-DISPOSE")throw new Wd("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");var r;if(n==="ASYNC-DISPOSE"&&Kd&&(r=qd(e,Kd)),!r){if(!Yd)throw new Wd("`Symbol.dispose` is not supported");if(r=qd(e,Yd),typeof r<"u")return function(){var i=this;if(n==="ASYNC-DISPOSE"){var s=Dk(Promise);try{zl(r,i),zl(s["[[Resolve]]"],void 0,[void 0])}catch(o){s["[[Reject]]"](o)}return s["[[Promise]]"]}zl(r,i)}}return r},Lk=Kt,Ll=W,Mk=mi,Nk=Pu,Uk=zk,Fk=function(e,n){if(n!=="SYNC-DISPOSE"&&n!=="ASYNC-DISPOSE")throw new Lk("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");var r;if(arguments.length<3)if(e==null)e=void 0,r=void 0;else{if(typeof e<"u"&&Nk(e)!=="Object")throw new Ll("`V` must be an Object, or `null` or `undefined`");if(r=Uk(e,n),typeof r>"u")throw new Ll("dispose method must not be `undefined` on `V` when an object `V` is provided")}else if(r=arguments[2],!Mk(r))throw new Ll("`method`, when provided, must be a function");return{"[[ResourceValue]]":e,"[[Hint]]":n,"[[DisposeMethod]]":r}},Zk=Kt,Eo=W,Hk=gk,Jd=Fk,Bk=Sn(),jk=Bk("Array.prototype.push"),yg=function(e,n,r){if(!Hk(e))throw new Eo("Assertion failed: `disposeCapability` must be a DisposeCapability Record");if(r!=="SYNC-DISPOSE"&&r!=="ASYNC-DISPOSE")throw new Zk("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 Eo("Assertion failed: `method`, when present, must be a function");if(!e["[[DisposableResourceStack]]"])throw new Eo("Assertion failed: `disposeCapability.[[DisposableResourceStack]]` must not be ~EMPTY~");var s;if(arguments.length<4){if(n==null&&r==="SYNC_DISPOSE")return"UNUSED";s=Jd(n,r)}else{if(typeof n<"u")throw new Eo("Assertion failed: `V` must be undefined when `method` is present");s=Jd(void 0,r,i)}return jk(e["[[DisposableResourceStack]]"],s),"UNUSED"},Ml,Xd;function Ru(){if(Xd)return Ml;Xd=1;var t=ot,e=Iu,n=Kt,r=t("%Promise.resolve%",!0),i=r&&e(r);return Ml=function(o,a){if(!i)throw new n("This environment does not support Promises.");return i(o,a)},Ml}var Nl,Qd;function Vk(){if(Qd)return Nl;Qd=1;var t=ot,e=Kt,n=t("%Promise%",!0),r=Fa,i=Ru(),s=Pu;return Nl=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 d=typeof u>"u"?u:r(u,a);if(c==="ASYNC-DISPOSE")return i(n,d)},Nl}var Ul,ep;function Gk(){if(ep)return Ul;ep=1;var t=Tu;return Ul=function(n){return new t("throw",n)},Ul}var Wk=ot,Fl=Kt,tp=W,qk=Wk("%Promise%",!0),Yk=Sn(),np=Yk("Promise.prototype.then",!0),Kk=Tu,rp=Vk(),Jk=Cu,Xk=Ru(),ip=Gk(),Qk=og(),bg=function(e,n){if(!(n instanceof Kk))throw new tp("`completion` must be a Completion Record");var r=e["[[DisposableResourceStack]]"];if(!r)throw new tp("Assertion failed: `disposeCapability.[[DisposableResourceStack]]` must not be ~EMPTY~");for(var i,s=r.length-1;s>=0;s-=1)if(!i)i=r[s]["[[Hint]]"];else if(i!==r[s]["[[Hint]]"])throw new Fl("mixed hint stacks are not supported");for(var o=i==="ASYNC-DISPOSE"&&Xk(qk,n),a=function(y){if(n.type()==="throw"){var v=n.value(),A=new Qk(y,v);n=ip(A)}else n=ip(y)},c=i==="ASYNC-DISPOSE"&&function(v){return np(o,function(){var A=rp(v["[[ResourceValue]]"],v["[[Hint]]"],v["[[DisposeMethod]]"]);if(!A)throw new Fl("Assertion failed: non-`~ASYNC-DISPOSE~` resource returned a promise from Dispose");return np(A,Jk)},a)},u=r.length-1;u>=0;u-=1)if(i==="ASYNC-DISPOSE")o=c(r[u]);else{var d=r[u];try{var p=rp(d["[[ResourceValue]]"],d["[[Hint]]"],d["[[DisposeMethod]]"]);if(p)throw new Fl("Assertion failed: `~SYNC-DISPOSE~` resource returned something from Dispose")}catch(y){a(y)}}return e["[[DisposableResourceStack]]"]=null,i==="ASYNC-DISPOSE"?o:n},wg=function(){var e=[];return{"[[DisposableResourceStack]]":e}},Ba=du,Du=W,eE=Fa,yi=bu,tE=eo,Sg=mi,nE=Cu,Ve=Au,rE=mg,_g=gr.supportsDescriptors,iE=Iu,Ou=yg,sE=bg,kg=wg,sp=Su(),rt=function t(){if(!(this instanceof t)||Ve.has(this,"[[DisposableState]]")||Ve.has(this,"[[DisposeCapability]]"))throw new Du("can only be used with new");Ve.set(this,"[[DisposableState]]","PENDING"),Ve.set(this,"[[DisposeCapability]]",kg())},Eg=function(){var e=this;return Ve.assert(e,"[[DisposableState]]"),Ve.get(e,"[[DisposableState]]")==="DISPOSED"},ro=iE(Eg);_g?tE(rt.prototype,"disposed",{"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Get]]":Eg}):rt.prototype.disposed=!1;var xg=function(e){Ve.set(e,"[[DisposableState]]","DISPOSED"),_g||(e.disposed=!0)};yi(rt.prototype,"dispose",function(){var e=this;if(!ro(e))return xg(e),sE(Ve.get(e,"[[DisposeCapability]]"),nE())["?"]()});yi(rt.prototype,"use",function(e){var n=this;if(ro(n))throw new Ba("a disposed stack can not use anything new");return Ou(Ve.get(n,"[[DisposeCapability]]"),e,"SYNC-DISPOSE"),e});yi(rt.prototype,"adopt",function(e,n){var r=this;if(ro(r))throw new Ba("a disposed stack can not use anything new");if(!Sg(n))throw new Du("`onDispose` must be a function");var i=function(){return eE(n,void 0,[e])};return Ou(Ve.get(r,"[[DisposeCapability]]"),void 0,"SYNC-DISPOSE",i),e});yi(rt.prototype,"defer",function(e){var n=this;if(ro(n))throw new Ba("a disposed stack can not defer anything new");if(!Sg(e))throw new Du("`onDispose` must be a function");Ou(Ve.get(n,"[[DisposeCapability]]"),void 0,"SYNC-DISPOSE",e)});yi(rt.prototype,"move",function(){var e=this;if(ro(e))throw new Ba("a disposed stack can not use anything new");var n=new rt;return Ve.set(n,"[[DisposeCapability]]",Ve.get(e,"[[DisposeCapability]]")),Ve.set(e,"[[DisposeCapability]]",kg()),xg(e),n});sp&&yi(rt.prototype,sp,rt.prototype.dispose);rE(rt.prototype,"DisposableStack");var oE=rt,aE=oE,lE=function(){return typeof DisposableStack=="function"?DisposableStack:aE},cE=gr,uE=uu(),hE=lE,dE=function(){var e=hE();return cE(uE,{DisposableStack:e},{DisposableStack:!0}),e},pE=ot,ja=du,zu=W,op=pE("%Promise%",!0),Lu=yg,fE=Fa,bi=bu,gE=eo,mE=bg,$g=mi,Ag=wg,vE=Cu,ap=Ru(),Ge=Au,yE=mg,Tg=gr.supportsDescriptors,bE=Iu,wE=Sn(),SE=wE("Promise.prototype.then",!0),lp=_u(),it=function t(){if(!(this instanceof t)||Ge.has(this,"[[AsyncDisposableState]]")||Ge.has(this,"[[DisposeCapability]]"))throw new zu("can only be used with new");Ge.set(this,"[[AsyncDisposableState]]","pending"),Ge.set(this,"[[DisposeCapability]]",Ag())},Cg=function(){var e=this;return Ge.assert(e,"[[AsyncDisposableState]]"),Ge.get(e,"[[AsyncDisposableState]]")==="disposed"},io=bE(Cg);Tg?gE(it.prototype,"disposed",{"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Get]]":Cg}):it.prototype.disposed=!1;var Ig=function(e){Ge.set(e,"[[AsyncDisposableState]]","disposed"),Tg||(e.disposed=!0)};bi(it.prototype,"disposeAsync",function(){var e=this;return io(e)?ap(op):(Ig(e),SE(ap(op,mE(Ge.get(e,"[[DisposeCapability]]"),vE())),function(n){return n["?"]()}))});bi(it.prototype,"use",function(e){var n=this;if(io(n))throw new ja("a disposed stack can not use anything new");return Lu(Ge.get(n,"[[DisposeCapability]]"),e,"ASYNC-DISPOSE"),e});bi(it.prototype,"adopt",function(e,n){var r=this;if(io(r))throw new ja("a disposed stack can not use anything new");if(!$g(n))throw new zu("`onDisposeAsync` must be a function");var i=function(){return fE(n,void 0,[e])};return i.value=e,Lu(Ge.get(r,"[[DisposeCapability]]"),void 0,"ASYNC-DISPOSE",i),e});bi(it.prototype,"defer",function(e){var n=this;if(io(n))throw new ja("a disposed stack can not defer anything new");if(!$g(e))throw new zu("`onDispose` must be a function");Lu(Ge.get(n,"[[DisposeCapability]]"),void 0,"ASYNC-DISPOSE",e)});bi(it.prototype,"move",function(){var e=this;if(io(e))throw new ja("a disposed stack can not use anything new");var n=new it;return Ge.set(n,"[[DisposeCapability]]",Ge.get(e,"[[DisposeCapability]]")),Ge.set(e,"[[DisposeCapability]]",Ag()),Ig(e),n});lp&&bi(it.prototype,lp,it.prototype.disposeAsync);yE(it.prototype,"AsyncDisposableStack");var _E=it,kE=_E,EE=function(){return typeof AsyncDisposableStack=="function"?AsyncDisposableStack:kE},xE=gr,$E=uu(),AE=EE,TE=function(){var e=AE();return xE($E,{AsyncDisposableStack:e},{AsyncDisposableStack:!0}),e},CE=xS,IE=DS,PE=dE,RE=TE,DE=function(){CE(),IE(),PE(),RE()};DE();const cp=new WeakMap;function OE(t){return(typeof t=="object"||typeof t=="function")&&t!==null&&"then"in t&&typeof t.then=="function"}function Tr(t){return typeof t=="string"?t:typeof t=="symbol"?t.description??t.toString():t.name||"(anonymous class)"}function up(){return new Error("register(Key, factory) requires a factory function. Wrap existing instances as () => instance.")}function zE(){return new Error("register(Key, factory) does not accept async factories. Await setup before registering.")}class LE{constructor(){b(this,"entries",new Map);b(this,"constructionStack",[])}register(e,n){if(n===void 0){if(typeof e!="function")throw up();this.validateClassRegistration(e),this.storeFactory(e,()=>this.instantiateClass(e));return}if(typeof n!="function")throw up();if(n.constructor.name==="AsyncFunction")throw zE();this.storeFactory(e,n)}has(e){var n;return((n=this.entries.get(e))==null?void 0:n.factory)!==void 0}resolve(e){return this.resolveAny(e)}storeFactory(e,n){const r=this.getOrCreateEntry(e);r.factory=n,r.instance=void 0,r.error=void 0}validateClassRegistration(e){const n=cp.get(e);if(n){if(e.length!==n.length)throw new Error(`${Tr(e)} cannot be registered with register(Class). @injectable(...) declared ${n.length} dependencies but constructor arity is ${e.length}. Use register(Key, () => value) instead.`);return}if(e.length!==0)throw new Error(`${Tr(e)} cannot be registered with register(Class). Undecorated classes must have zero required constructor parameters. Use register(Key, () => value) instead.`)}instantiateClass(e){const n=cp.get(e);if(!n)return new e;const r=n.map(i=>this.resolveAny(i));return new e(...r)}resolveAny(e){return this.getOrCreateEntry(e).proxy}getOrCreateEntry(e){let n=this.entries.get(e);return n||(n={key:e},n.proxy=this.createProxy(n),this.entries.set(e,n),n)}createProxy(e){return new Proxy({},{get:(n,r)=>{if(r==="then")return;const i=this.getInstance(e),s=Reflect.get(i,r,i);return typeof s=="function"?s.bind(i):s},set:(n,r,i)=>{const s=this.getInstance(e);return Reflect.set(s,r,i,s)},has:(n,r)=>{const i=this.getInstance(e);return r in i}})}getInstance(e){if(e.instance)return e.instance;if(e.error)throw e.error;if(!e.factory)throw new Error(`${Tr(e.key)} was resolved but never registered`);const n=this.constructionStack.indexOf(e.key);if(n!==-1){const r=[...this.constructionStack.slice(n),e.key].map(i=>Tr(i)).join(" -> ");throw new Error(`Circular dependency detected: ${r}`)}this.constructionStack.push(e.key);try{const r=e.factory();if(OE(r))throw new Error(`Factory for ${Tr(e.key)} returned a Promise. Await setup before registering.`);if(typeof r!="object"||r===null)throw new Error(`Factory for ${Tr(e.key)} returned a non-object value. Wrap primitives in an object.`);return e.instance=r,r}catch(r){throw e.error=r,r}finally{this.constructionStack.pop()}}}const We=new LE,ME=new Set(["target","currentTarget","eventPhase","defaultPrevented","isTrusted","timeStamp","srcElement","returnValue","cancelBubble","NONE","CAPTURING_PHASE","AT_TARGET","BUBBLING_PHASE","composedPath","stopPropagation","stopImmediatePropagation","preventDefault","initEvent"]);function NE(t){for(const e of Object.keys(t))if(ME.has(e))throw new Error(`Event payload key "${e}" is reserved; choose a different property name`)}function UE(t,e){NE(e);for(const n of Object.keys(e))Object.defineProperty(t,n,{value:e[n],writable:!0,enumerable:!0,configurable:!0})}function gt(){class t extends Event{constructor(n,r){const{type:i,bubbles:s,cancelable:o,composed:a,...c}=r??{};if(i!==void 0)throw new Error('Do not pass "type" in init; use the constructor argument instead');super(n,{bubbles:s,cancelable:o,composed:a}),UE(this,c)}}return t}class mt extends globalThis.EventTarget{}function FE(t,e,n){const r=t.dispose.bind(t);t.dispose=()=>{if(!e())return n(),r()}}function wi(t){var n;class e extends t{constructor(...s){super(...s);S(this,n,!1);FE(this,()=>l(this,n),()=>{k(this,n,!0)})}[Symbol.dispose](){this.dispose()}get disposed(){return l(this,n)}}return n=new WeakMap,e}const ZE=gt(),HE=gt(),Go=gt(),Pg="0123456789ABCDEFGHJKMNPQRSTVWXYZ",aa=32,BE=16,Rg=10,hp=0xffffffffffff;var Mn;(function(t){t.Base32IncorrectEncoding="B32_ENC_INVALID",t.DecodeTimeInvalidCharacter="DEC_TIME_CHAR",t.DecodeTimeValueMalformed="DEC_TIME_MALFORMED",t.EncodeTimeNegative="ENC_TIME_NEG",t.EncodeTimeSizeExceeded="ENC_TIME_SIZE_EXCEED",t.EncodeTimeValueMalformed="ENC_TIME_MALFORMED",t.PRNGDetectFailure="PRNG_DETECT",t.ULIDInvalid="ULID_INVALID",t.Unexpected="UNEXPECTED",t.UUIDInvalid="UUID_INVALID"})(Mn||(Mn={}));class Hi extends Error{constructor(e,n){super(`${n} (${e})`),this.name="ULIDError",this.code=e}}function jE(t){const e=Math.floor(t()*aa)%aa;return Pg.charAt(e)}function VE(t){const e=GE(),n=e&&(e.crypto||e.msCrypto)||null;if(typeof(n==null?void 0:n.getRandomValues)=="function")return()=>{const r=new Uint8Array(1);return n.getRandomValues(r),r[0]/256};if(typeof(n==null?void 0:n.randomBytes)=="function")return()=>n.randomBytes(1).readUInt8()/256;throw new Hi(Mn.PRNGDetectFailure,"Failed to find a reliable PRNG")}function GE(){return YE()?self:typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:null}function WE(t,e){let n="";for(;t>0;t--)n=jE(e)+n;return n}function qE(t,e=Rg){if(isNaN(t))throw new Hi(Mn.EncodeTimeValueMalformed,`Time must be a number: ${t}`);if(t>hp)throw new Hi(Mn.EncodeTimeSizeExceeded,`Cannot encode a time larger than ${hp}: ${t}`);if(t<0)throw new Hi(Mn.EncodeTimeNegative,`Time must be positive: ${t}`);if(Number.isInteger(t)===!1)throw new Hi(Mn.EncodeTimeValueMalformed,`Time must be an integer: ${t}`);let n,r="";for(let i=e;i>0;i--)n=t%aa,r=Pg.charAt(n)+r,t=(t-n)/aa;return r}function YE(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}function Mu(t,e){const n=VE(),r=Date.now();return qE(r,Rg)+WE(BE,n)}const Pt=4,Qe=6,Dg=2,yc=2,KE=Pt,JE=Qe,Nu="auto",fn="auto",Dn=120,dp=75,ge=16,cr=Dn*Pt+ge*(Pt-1),la=Dn*Qe+ge*(Qe-1),XE=200,QE=4,xo=150,ex=10,pp=2,tx=4;function Og(t){return Mg(t)}function zg(t,e){return Mg(t.flatMap(n=>Ug(n,e)))}function Lg(t){const e=[],n=new Set;for(const r of t){if(r.type==="row"){e.push(`Top-level rows are invalid: ${r.id}`);continue}Fg(r,"strip",e,n)}return{valid:e.length===0,errors:e}}function Mr(t){const e=Og(t),n=Lg(e);if(!n.valid)throw new Error(`Invalid layout: ${n.errors.join("; ")}`);return{totalNodes:e.length,nodes:e.filter(r=>r.type!=="row").map(sx)}}function Mg(t){const e=[];for(const n of t){const r=Ng(n);for(const i of r){if(i.type==="row"){e.push(...i.children.map(qt));continue}e.push(i)}}return e}function Ng(t){switch(t.type){case"card":return[qt(t)];case"row":{const e=t.children.map(qt);return e.length===0?[]:e.length===1?[e[0]]:[{...t,children:e}]}case"stack":{const e=[];for(const n of t.children){const r=Ng(n);for(const i of r){if(i.type==="stack"){e.push(...i.children.map(bc));continue}if(i.type==="row"){e.push({...i,children:i.children.map(qt)});continue}e.push(qt(i))}}return e.length===0?[]:e.length===1?[bc(e[0])]:[{...t,children:e}]}}}function Ug(t,e){switch(t.type){case"card":return t.artifactID===e?[]:[qt(t)];case"row":{const n=t.children.filter(r=>r.artifactID!==e).map(qt);return n.length===0?[]:n.length===1?[n[0]]:[{...t,children:n}]}case"stack":{const n=t.children.flatMap(r=>Ug(r,e).filter(s=>s.type!=="stack"));return n.length===0?[]:n.length===1?[bc(n[0])]:[{...t,children:n}]}}}function Fg(t,e,n,r){switch(t.type){case"card":Zg(t,e,n,r);return;case"row":nx(t,e,n,r);return;case"stack":rx(t,e,n,r);return}}function Zg(t,e,n,r){Uu(t.id,n),typeof t.artifactID!="string"||t.artifactID.length===0?n.push(`Card ${t.id} is missing artifactID`):r.has(t.artifactID)?n.push(`Duplicate artifactID in layout: ${t.artifactID}`):r.add(t.artifactID),ix(t.width)||n.push(`Card ${t.id} width must be an integer in the range 2-4`),Hg(t.height)||n.push(`Card ${t.id} height must be an integer in the range 2-6 or "auto"`);const i=On(t.width);e==="row"&&i<Dg&&n.push(`Row child ${t.id} must be at least 2 columns wide`)}function nx(t,e,n,r){if(Uu(t.id,n),e!=="stack"&&n.push(`Row ${t.id} may only appear inside a stack`),Hg(t.height,tx)||n.push(`Row ${t.id} height must be an integer in the range 2-4 or "auto"`),!Array.isArray(t.children)||t.children.length===0){n.push(`Row ${t.id} must contain card nodes`);return}let i=0;for(const s of t.children){if(s.type!=="card"){n.push(`Row ${t.id} must contain only card nodes`);continue}Zg(s,"row",n,r),i+=On(s.width)}i!==Pt&&n.push(`Row ${t.id} children must sum to 4 columns`)}function rx(t,e,n,r){if(Uu(t.id,n),e!=="strip"&&n.push(`Invalid nested stack at ${t.id}; stack children cannot contain another nested stack`),!Array.isArray(t.children)||t.children.length===0){n.push(`Stack ${t.id} must contain at least one child`);return}let i=0,s=0;for(const a of t.children){if(a.type==="stack"){n.push(`Stack ${t.id} cannot contain another nested stack`);continue}if(Fg(a,"stack",n,r),a.height===fn){s+=1;continue}i+=a.height}if(i>Qe&&n.push(`Stack ${t.id} exceeds the 6-row budget`),s===0)return;const o=Qe-i;if(o<s*yc||o%s!==0){n.push(`Stack ${t.id} has auto-height children that cannot resolve to whole height >= 2`);return}o/s<yc&&n.push(`Stack ${t.id} has auto-height children below the minimum row size`)}function Uu(t,e){(typeof t!="string"||t.length===0)&&e.push(`Node id must be a non-empty string: ${String(t)}`)}function ix(t){return t===Nu||Number.isInteger(t)&&t>=Dg&&t<=KE}function Hg(t,e=JE){return t===fn||Number.isInteger(t)&&t>=yc&&t<=e}function On(t){return t===Nu?Pt:t}function sx(t){if(t.type==="card")return{id:t.id,type:"card",width:On(t.width),cards:[{id:t.id,artifactID:t.artifactID,col:1,row:1,width:On(t.width),height:Bg(t.height,Qe)}]};const e=ox(t.children),n=[];let r=1;for(let i=0;i<t.children.length;i+=1){const s=t.children[i],o=e[i];if(s.type==="card")n.push({id:s.id,artifactID:s.artifactID,col:1,row:r,width:On(s.width),height:o});else{let a=1;for(const c of s.children)n.push({id:c.id,artifactID:c.artifactID,col:a,row:r,width:On(c.width),height:o}),a+=On(c.width)}r+=o}return{id:t.id,type:"stack",width:n.reduce((i,s)=>Math.max(i,s.col+s.width-1),1),cards:n}}function ox(t){let e=0,n=0;for(const i of t)i.height===fn?n+=1:e+=i.height;const r=n>0?(Qe-e)/n:0;return t.map(i=>Bg(i.height,r))}function Bg(t,e){return t===fn?e:t}function qt(t){return{...t}}function bc(t){return t.type==="card"?qt(t):{...t,children:t.children.map(qt)}}function jg(t,e={}){return{id:e.id??Mu(),type:"card",artifactID:t,width:e.width??Nu,height:e.height??fn}}function Vg(t,e){return t.some(n=>Gg(n,e))}function Gg(t,e){switch(t.type){case"card":return t.artifactID===e;case"row":return t.children.some(n=>n.artifactID===e);case"stack":return t.children.some(n=>Gg(n,e))}}function fp(t){return t.layout.flatMap(Wg)}function Wg(t){switch(t.type){case"card":return[t.artifactID];case"row":return t.children.map(e=>e.artifactID);case"stack":return t.children.flatMap(Wg)}}const ee=gt(),qg=gt(),Ri=gt(),ax=gt();function lx(t){class e extends Error{constructor(r,i){super(r),this.name=t,i&&Object.assign(this,i)}}return e}const cx=lx("RequestError"),ux=200,hx=300;class dx{constructor(e,n){b(this,"serverURL");b(this,"token");this.serverURL=e.replace(/\/$/,""),this.token=n.token}async requestJSON(e,n,r){const i=await this.request(e,n,r!==void 0?JSON.stringify(r):void 0,r!==void 0?{"content-type":"application/json"}:void 0),s=await px(i);if(!i.ok||i.status<ux||i.status>=hx)throw this.createError(typeof s.error=="string"?s.error:i.statusText,i.status);return s}async requestVoid(e,n){const r=await this.request(e,n);if(!r.ok)throw this.createError(await Zl(r,r.statusText),r.status)}async requestText(e,n){const r=await this.request(e,n);if(!r.ok)throw this.createError(await Zl(r,r.statusText),r.status);return r.text()}async requestRawVoid(e,n,r){const i=await this.request(e,n,r,{"content-type":"text/plain"});if(!i.ok)throw this.createError(await Zl(i,i.statusText),i.status)}createError(e,n){const r={serverURL:this.serverURL};return n!==void 0&&(r.status=n),new cx(e,r)}async request(e,n,r,i){const s=`${this.serverURL}${n}`;try{return await fetch(s,{method:e,headers:this.buildHeaders(i),body:r})}catch(o){throw this.createError(o instanceof Error?o.message:"Failed to reach server")}}buildHeaders(e){const n={...e??{}};return this.token&&(n.Authorization=`Bearer ${this.token}`),Object.keys(n).length>0?n:void 0}}async function px(t){try{return await t.json()}catch{const e=await t.text().catch(()=>"");return e?{message:e}:{}}}async function Zl(t,e){try{const n=await t.json();if(typeof n.error=="string")return n.error;if(typeof n.message=="string")return n.message}catch{}return e}function fx(t){return t.map(e=>`${e.name} (${e.id})`).join(", ")}var xt,wa,Yg;class gx{constructor(e){S(this,wa);S(this,xt);k(this,xt,e)}list(){return l(this,xt).requestJSON("GET","/screens")}async get(e={}){const n=await g(this,wa,Yg).call(this,e.screenID);return l(this,xt).requestJSON("GET",`/screens/${encodeURIComponent(n)}`)}create(e){const n={name:e.name};return e.id!==void 0&&(n.id=e.id),l(this,xt).requestJSON("POST","/screens",n)}update(e){const n={};return e.name!==void 0&&(n.name=e.name),e.layout!==void 0&&(n.layout=e.layout),l(this,xt).requestJSON("PATCH",`/screens/${encodeURIComponent(e.screenID)}`,n)}remove(e){return l(this,xt).requestJSON("DELETE",`/screens/${encodeURIComponent(e.screenID)}`)}}xt=new WeakMap,wa=new WeakSet,Yg=async function(e){if(e!==void 0)return e;const{screens:n}=await this.list();if(n.length===1)return n[0].id;throw l(this,xt).createError(`screenID is required when multiple screens exist. Available screens: ${fx(n)}`)};var Oe;class mx{constructor(e){S(this,Oe);k(this,Oe,e)}create(e){const n={type:e.type,title:e.title};return e.externalFilePath!==void 0&&(n.externalFilePath=e.externalFilePath),e.screenID!==void 0&&(n.screenID=e.screenID),l(this,Oe).requestJSON("POST","/artifacts",n)}list(e={}){const n=new URLSearchParams;e.screenID!==void 0&&n.set("screenID",e.screenID),e.unplaced&&n.set("unplaced","true");const r=n.toString();return l(this,Oe).requestJSON("GET",r?`/artifacts?${r}`:"/artifacts")}get(e){return l(this,Oe).requestJSON("GET",`/artifacts/${encodeURIComponent(e.artifactID)}`)}update(e){const n={};return e.title!==void 0&&(n.title=e.title),l(this,Oe).requestJSON("PATCH",`/artifacts/${encodeURIComponent(e.artifactID)}`,n)}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 Fn;class vx{constructor(e){S(this,Fn);k(this,Fn,e)}state(){return l(this,Fn).requestJSON("GET","/viewer/state")}setActive(e){return l(this,Fn).requestJSON("PUT","/viewer/active-screen",{screenID:e.screenID})}focus(e){const n={artifactID:e.artifactID};return e.screenID!==void 0&&(n.screenID=e.screenID),l(this,Fn).requestJSON("POST","/viewer/focus",n)}}Fn=new WeakMap;var cs;class yx{constructor(e){S(this,cs);k(this,cs,e)}async list(){const{views:e}=await l(this,cs).requestJSON("GET","/views");return e}}cs=new WeakMap;var Ut;class bx{constructor(e,n={}){b(this,"screens");b(this,"artifacts");b(this,"viewer");b(this,"views");S(this,Ut);k(this,Ut,new dx(e,n)),this.screens=new gx(l(this,Ut)),this.artifacts=new mx(l(this,Ut)),this.viewer=new vx(l(this,Ut)),this.views=new yx(l(this,Ut))}health(){return l(this,Ut).requestJSON("GET","/health")}}Ut=new WeakMap;const wx={focusCommandInput:{label:"Focus Command Input",trigger:{key:"k",meta:!0}}},Sx=wi(mt);var Zn,Be,Hn,Me,rn,sn,X,Ir,Kg,us,Jg,Xg,Qg,em,wc,Sc,_c,tm;class _x extends Sx{constructor(n){var i;super();S(this,X);b(this,"id");b(this,"server");S(this,Zn);S(this,Be,new Map);S(this,Hn);S(this,Me);S(this,rn);S(this,sn,null);S(this,us,n=>{if(this.disposed)return;const r=n.event;switch(r.type){case"screen-updated":r.screen.id===this.id&&g(this,X,Jg).call(this,r.screen);break;case"artifact-created":break;case"artifact-attached":r.screenID===this.id&&g(this,X,Xg).call(this,r.cardID,r.artifact);break;case"artifact-updated":g(this,X,Qg).call(this,r.artifact);break;case"artifact-removed":r.screenID===this.id&&g(this,X,em).call(this,r.artifactID);break;case"artifact-content-changed":l(this,Be).has(r.artifactID)&&this.dispatchEvent(new ax("artifact-content-changed",{artifactID:r.artifactID}));break}});this.id=n.screen.id,this.server=n.server,k(this,Zn,n.localStore),k(this,Hn,n.screen.name),k(this,Me,structuredClone(n.screen.layout));const r=((i=l(this,Zn).get().screens[this.id])==null?void 0:i.scrollPosition)??0;k(this,rn,Math.max(0,r)),this.server.addEventListener("server-event",l(this,us)),g(this,X,Kg).call(this)}get name(){return l(this,Hn)}get layout(){return l(this,Me)}get scrollPosition(){return l(this,rn)}get artifacts(){return l(this,Be)}setScrollPosition(n){g(this,X,Ir).call(this);const r=Math.max(0,n);r!==l(this,rn)&&(k(this,rn,r),g(this,X,tm).call(this),this.dispatchEvent(new ee("change")))}setLayout(n){g(this,X,Ir).call(this);const r=Og(n);if(!Lg(r).valid)return;const s=g(this,X,Sc).call(this);k(this,Me,r),k(this,sn,{layout:r,snapshot:s}),this.dispatchEvent(new ee("change")),this.server.client.screens.update({screenID:this.id,layout:r.map(o=>structuredClone(o))}).catch(()=>{var o;this.disposed||((o=l(this,sn))==null?void 0:o.layout)===r&&(k(this,sn,null),g(this,X,_c).call(this,s),this.dispatchEvent(new ee("change")))})}rename(n){g(this,X,Ir).call(this),k(this,Hn,n),this.dispatchEvent(new ee("change")),this.server.client.screens.update({screenID:this.id,name:n}).catch(()=>{})}async remove(){g(this,X,Ir).call(this),await this.server.client.screens.remove({screenID:this.id})}removeArtifact(n){if(g(this,X,Ir).call(this),!l(this,Be).has(n))return;const r=g(this,X,Sc).call(this);g(this,X,wc).call(this,n),this.dispatchEvent(new ee("change")),this.server.client.artifacts.detach({artifactID:n,screenID:this.id}).catch(()=>{this.disposed||(g(this,X,_c).call(this,r),this.dispatchEvent(new ee("change")))})}dispose(){this.server.removeEventListener("server-event",l(this,us))}}Zn=new WeakMap,Be=new WeakMap,Hn=new WeakMap,Me=new WeakMap,rn=new WeakMap,sn=new WeakMap,X=new WeakSet,Ir=function(){if(this.disposed)throw new Error("ScreenModel is disposed")},Kg=async function(){try{const n=await this.server.client.screens.get({screenID:this.id});if(this.disposed)return;for(const r of n.artifacts)l(this,Be).set(r.id,r);this.dispatchEvent(new ee("change"))}catch{}},us=new WeakMap,Jg=function(n){l(this,sn)&&k(this,sn,null),k(this,Hn,n.name),k(this,Me,structuredClone(n.layout)),this.dispatchEvent(new ee("change"))},Xg=function(n,r){Vg(l(this,Me),r.id)||k(this,Me,[...l(this,Me),jg(r.id,{id:n})]),l(this,Be).set(r.id,r),this.dispatchEvent(new ee("change"))},Qg=function(n){const r=l(this,Be).get(n.id);r&&(l(this,Be).set(n.id,{...r,...n}),this.dispatchEvent(new ee("change")))},em=function(n){g(this,X,wc).call(this,n)&&this.dispatchEvent(new ee("change"))},wc=function(n){const r=l(this,Be).delete(n),i=fp({layout:l(this,Me)}).length,s=zg(l(this,Me),n),o=fp({layout:s}).length;return k(this,Me,s),r||i!==o},Sc=function(){return{layout:structuredClone(l(this,Me)),artifacts:new Map([...l(this,Be).entries()].map(([n,r])=>[n,structuredClone(r)]))}},_c=function(n){k(this,Me,structuredClone(n.layout)),l(this,Be).clear();for(const[r,i]of n.artifacts)l(this,Be).set(r,structuredClone(i))},tm=function(){const n=l(this,Zn).get();l(this,Zn).set({...n,screens:{...n.screens,[this.id]:{scrollPosition:l(this,rn)}}})};const kx=wi(mt);var et,$t,lt,hs,ds,ps,Hr,Wo;class Ex extends kx{constructor(n){super();S(this,Hr);S(this,et);S(this,$t);S(this,lt,null);S(this,hs,()=>{this.disposed||g(this,Hr,Wo).call(this)});S(this,ds,()=>{this.disposed||g(this,Hr,Wo).call(this)});S(this,ps,n=>{var i;if(this.disposed)return;const r=n.event;if(r.type==="screen-removed"&&((i=l(this,lt))==null?void 0:i.id)===r.screenID&&this.clearActive(),r.type==="viewer-active-screen-changed"){const s=l(this,$t).servers.get(n.serverURL);s&&s.screens.has(r.screenID)&&this.setActive(n.serverURL,r.screenID)}});k(this,et,n.localStore),k(this,$t,n.serverManager),l(this,et).addEventListener("change",l(this,hs)),l(this,$t).addEventListener("change",l(this,ds)),l(this,$t).addEventListener("server-event",l(this,ps)),g(this,Hr,Wo).call(this)}get activeScreen(){return l(this,lt)}setActive(n,r){const i=l(this,et).get();i.activeServerURL===n&&i.activeScreenID===r||l(this,et).set({...i,activeServerURL:n,activeScreenID:r})}clearActive(){const n=l(this,et).get();n.activeScreenID!==null&&l(this,et).set({...n,activeScreenID:null})}dispose(){var n;l(this,et).removeEventListener("change",l(this,hs)),l(this,$t).removeEventListener("change",l(this,ds)),l(this,$t).removeEventListener("server-event",l(this,ps)),(n=l(this,lt))==null||n.dispose(),k(this,lt,null)}}et=new WeakMap,$t=new WeakMap,lt=new WeakMap,hs=new WeakMap,ds=new WeakMap,ps=new WeakMap,Hr=new WeakSet,Wo=function(){var c,u,d;const{activeServerURL:n,activeScreenID:r}=l(this,et).get(),i=n?l(this,$t).servers.get(n)??null:null,s=i&&r?i.screens.get(r)??null:null,o=((c=l(this,lt))==null?void 0:c.id)??null,a=(s==null?void 0:s.id)??null;o===a&&((u=l(this,lt))==null?void 0:u.server)===i||((d=l(this,lt))==null||d.dispose(),k(this,lt,i&&s?new _x({screen:s,server:i,localStore:l(this,et)}):null),this.dispatchEvent(new ZE("active-screen-changed")))};const xx="Local",$x="store-";function Et(t){return new URL(t).origin}function Ax(t){return{servers:[{url:Et(t),name:xx}],activeServerURL:null,activeScreenID:null,screens:{}}}var Bn,jn,Vn;class Tx extends mt{constructor(n,r,i={}){super();S(this,Bn);S(this,jn);S(this,Vn);k(this,Bn,`${$x}${n}`),k(this,jn,i.storage??Cx());const s=l(this,jn).getItem(l(this,Bn));s===null?(k(this,Vn,r),l(this,jn).setItem(l(this,Bn),JSON.stringify(r))):k(this,Vn,JSON.parse(s))}get(){return l(this,Vn)}set(n){k(this,Vn,n),l(this,jn).setItem(l(this,Bn),JSON.stringify(n)),this.dispatchEvent(new ee("change"))}}Bn=new WeakMap,jn=new WeakMap,Vn=new WeakMap;function Cx(){const t=globalThis.localStorage;if(!t)throw new Error("LocalStore: no storage adapter supplied and window.localStorage is unavailable");return t}function x(t,e,n){function r(a,c){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:c,constr:o,traits:new Set},enumerable:!1}),a._zod.traits.has(t))return;a._zod.traits.add(t),e(a,c);const u=o.prototype,d=Object.keys(u);for(let p=0;p<d.length;p++){const y=d[p];y in a||(a[y]=u[y].bind(a))}}const i=(n==null?void 0:n.Parent)??Object;class s extends i{}Object.defineProperty(s,"name",{value:t});function o(a){var c;const u=n!=null&&n.Parent?new s:this;r(u,a),(c=u._zod).deferred??(c.deferred=[]);for(const d of u._zod.deferred)d();return u}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:a=>{var c,u;return n!=null&&n.Parent&&a instanceof n.Parent?!0:(u=(c=a==null?void 0:a._zod)==null?void 0:c.traits)==null?void 0:u.has(t)}}),Object.defineProperty(o,"name",{value:t}),o}class Zr extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class nm extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}}const rm={};function gn(t){return rm}function im(t){const e=Object.values(t).filter(r=>typeof r=="number");return Object.entries(t).filter(([r,i])=>e.indexOf(+r)===-1).map(([r,i])=>i)}function kc(t,e){return typeof e=="bigint"?e.toString():e}function Fu(t){return{get value(){{const e=t();return Object.defineProperty(this,"value",{value:e}),e}}}}function Zu(t){return t==null}function Hu(t){const e=t.startsWith("^")?1:0,n=t.endsWith("$")?t.length-1:t.length;return t.slice(e,n)}function Ix(t,e){const n=(t.toString().split(".")[1]||"").length,r=e.toString();let i=(r.split(".")[1]||"").length;if(i===0&&/\d?e-\d?/.test(r)){const c=r.match(/\d?e-(\d?)/);c!=null&&c[1]&&(i=Number.parseInt(c[1]))}const s=n>i?n:i,o=Number.parseInt(t.toFixed(s).replace(".","")),a=Number.parseInt(e.toFixed(s).replace(".",""));return o%a/10**s}const gp=Symbol("evaluating");function Q(t,e,n){let r;Object.defineProperty(t,e,{get(){if(r!==gp)return r===void 0&&(r=gp,r=n()),r},set(i){Object.defineProperty(t,e,{value:i})},configurable:!0})}function vr(t,e,n){Object.defineProperty(t,e,{value:n,writable:!0,enumerable:!0,configurable:!0})}function kn(...t){const e={};for(const n of t){const r=Object.getOwnPropertyDescriptors(n);Object.assign(e,r)}return Object.defineProperties({},e)}function mp(t){return JSON.stringify(t)}function Px(t){return t.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const sm="captureStackTrace"in Error?Error.captureStackTrace:(...t)=>{};function ca(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}const Rx=Fu(()=>{var t;if(typeof navigator<"u"&&((t=navigator==null?void 0:navigator.userAgent)!=null&&t.includes("Cloudflare")))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function li(t){if(ca(t)===!1)return!1;const e=t.constructor;if(e===void 0||typeof e!="function")return!0;const n=e.prototype;return!(ca(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function om(t){return li(t)?{...t}:Array.isArray(t)?[...t]:t}const Dx=new Set(["string","number","symbol"]);function ci(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function En(t,e,n){const r=new t._zod.constr(e??t._zod.def);return(!e||n!=null&&n.parent)&&(r._zod.parent=t),r}function z(t){const e=t;if(!e)return{};if(typeof e=="string")return{error:()=>e};if((e==null?void 0:e.message)!==void 0){if((e==null?void 0:e.error)!==void 0)throw new Error("Cannot specify both `message` and `error` params");e.error=e.message}return delete e.message,typeof e.error=="string"?{...e,error:()=>e.error}:e}function Ox(t){return Object.keys(t).filter(e=>t[e]._zod.optin==="optional"&&t[e]._zod.optout==="optional")}const zx={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 Lx(t,e){const n=t._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const s=kn(t._zod.def,{get shape(){const o={};for(const a in e){if(!(a in n.shape))throw new Error(`Unrecognized key: "${a}"`);e[a]&&(o[a]=n.shape[a])}return vr(this,"shape",o),o},checks:[]});return En(t,s)}function Mx(t,e){const n=t._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const s=kn(t._zod.def,{get shape(){const o={...t._zod.def.shape};for(const a in e){if(!(a in n.shape))throw new Error(`Unrecognized key: "${a}"`);e[a]&&delete o[a]}return vr(this,"shape",o),o},checks:[]});return En(t,s)}function Nx(t,e){if(!li(e))throw new Error("Invalid input to extend: expected a plain object");const n=t._zod.def.checks;if(n&&n.length>0){const s=t._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=kn(t._zod.def,{get shape(){const s={...t._zod.def.shape,...e};return vr(this,"shape",s),s}});return En(t,i)}function Ux(t,e){if(!li(e))throw new Error("Invalid input to safeExtend: expected a plain object");const n=kn(t._zod.def,{get shape(){const r={...t._zod.def.shape,...e};return vr(this,"shape",r),r}});return En(t,n)}function Fx(t,e){const n=kn(t._zod.def,{get shape(){const r={...t._zod.def.shape,...e._zod.def.shape};return vr(this,"shape",r),r},get catchall(){return e._zod.def.catchall},checks:[]});return En(t,n)}function Zx(t,e,n){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=kn(e._zod.def,{get shape(){const a=e._zod.def.shape,c={...a};if(n)for(const u in n){if(!(u in a))throw new Error(`Unrecognized key: "${u}"`);n[u]&&(c[u]=t?new t({type:"optional",innerType:a[u]}):a[u])}else for(const u in a)c[u]=t?new t({type:"optional",innerType:a[u]}):a[u];return vr(this,"shape",c),c},checks:[]});return En(e,o)}function Hx(t,e,n){const r=kn(e._zod.def,{get shape(){const i=e._zod.def.shape,s={...i};if(n)for(const o in n){if(!(o in s))throw new Error(`Unrecognized key: "${o}"`);n[o]&&(s[o]=new t({type:"nonoptional",innerType:i[o]}))}else for(const o in i)s[o]=new t({type:"nonoptional",innerType:i[o]});return vr(this,"shape",s),s}});return En(e,r)}function Nr(t,e=0){var n;if(t.aborted===!0)return!0;for(let r=e;r<t.issues.length;r++)if(((n=t.issues[r])==null?void 0:n.continue)!==!0)return!0;return!1}function Ur(t,e){return e.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(t),n})}function $o(t){return typeof t=="string"?t:t==null?void 0:t.message}function mn(t,e,n){var i,s,o,a,c,u;const r={...t,path:t.path??[]};if(!t.message){const d=$o((o=(s=(i=t.inst)==null?void 0:i._zod.def)==null?void 0:s.error)==null?void 0:o.call(s,t))??$o((a=e==null?void 0:e.error)==null?void 0:a.call(e,t))??$o((c=n.customError)==null?void 0:c.call(n,t))??$o((u=n.localeError)==null?void 0:u.call(n,t))??"Invalid input";r.message=d}return delete r.inst,delete r.continue,e!=null&&e.reportInput||delete r.input,r}function Bu(t){return Array.isArray(t)?"array":typeof t=="string"?"string":"unknown"}function is(...t){const[e,n,r]=t;return typeof e=="string"?{message:e,code:"custom",input:n,inst:r}:{...e}}const am=(t,e)=>{t.name="$ZodError",Object.defineProperty(t,"_zod",{value:t._zod,enumerable:!1}),Object.defineProperty(t,"issues",{value:e,enumerable:!1}),t.message=JSON.stringify(e,kc,2),Object.defineProperty(t,"toString",{value:()=>t.message,enumerable:!1})},lm=x("$ZodError",am),cm=x("$ZodError",am,{Parent:Error});function Bx(t,e=n=>n.message){const n={},r=[];for(const i of t.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(e(i))):r.push(e(i));return{formErrors:r,fieldErrors:n}}function jx(t,e=n=>n.message){const n={_errors:[]},r=i=>{for(const s of i.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(o=>r({issues:o}));else if(s.code==="invalid_key")r({issues:s.issues});else if(s.code==="invalid_element")r({issues:s.issues});else if(s.path.length===0)n._errors.push(e(s));else{let o=n,a=0;for(;a<s.path.length;){const c=s.path[a];a===s.path.length-1?(o[c]=o[c]||{_errors:[]},o[c]._errors.push(e(s))):o[c]=o[c]||{_errors:[]},o=o[c],a++}}};return r(t),n}const ju=t=>(e,n,r,i)=>{const s=r?Object.assign(r,{async:!1}):{async:!1},o=e._zod.run({value:n,issues:[]},s);if(o instanceof Promise)throw new Zr;if(o.issues.length){const a=new((i==null?void 0:i.Err)??t)(o.issues.map(c=>mn(c,s,gn())));throw sm(a,i==null?void 0:i.callee),a}return o.value},Vu=t=>async(e,n,r,i)=>{const s=r?Object.assign(r,{async:!0}):{async:!0};let o=e._zod.run({value:n,issues:[]},s);if(o instanceof Promise&&(o=await o),o.issues.length){const a=new((i==null?void 0:i.Err)??t)(o.issues.map(c=>mn(c,s,gn())));throw sm(a,i==null?void 0:i.callee),a}return o.value},Va=t=>(e,n,r)=>{const i=r?{...r,async:!1}:{async:!1},s=e._zod.run({value:n,issues:[]},i);if(s instanceof Promise)throw new Zr;return s.issues.length?{success:!1,error:new(t??lm)(s.issues.map(o=>mn(o,i,gn())))}:{success:!0,data:s.value}},Vx=Va(cm),Ga=t=>async(e,n,r)=>{const i=r?Object.assign(r,{async:!0}):{async:!0};let s=e._zod.run({value:n,issues:[]},i);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new t(s.issues.map(o=>mn(o,i,gn())))}:{success:!0,data:s.value}},Gx=Ga(cm),Wx=t=>(e,n,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return ju(t)(e,n,i)},qx=t=>(e,n,r)=>ju(t)(e,n,r),Yx=t=>async(e,n,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Vu(t)(e,n,i)},Kx=t=>async(e,n,r)=>Vu(t)(e,n,r),Jx=t=>(e,n,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Va(t)(e,n,i)},Xx=t=>(e,n,r)=>Va(t)(e,n,r),Qx=t=>async(e,n,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Ga(t)(e,n,i)},e$=t=>async(e,n,r)=>Ga(t)(e,n,r),t$=/^[cC][^\s-]{8,}$/,n$=/^[0-9a-z]+$/,r$=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,i$=/^[0-9a-vA-V]{20}$/,s$=/^[A-Za-z0-9]{27}$/,o$=/^[a-zA-Z0-9_-]{21}$/,a$=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,l$=/^([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})$/,vp=t=>t?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${t}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,c$=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,u$="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function h$(){return new RegExp(u$,"u")}const d$=/^(?:(?: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])$/,p$=/^(([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}|:))$/,f$=/^((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])$/,g$=/^(([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])$/,m$=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,um=/^[A-Za-z0-9_-]*$/,v$=/^\+[1-9]\d{6,14}$/,hm="(?:(?:\\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])))",y$=new RegExp(`^${hm}$`);function dm(t){const e="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof t.precision=="number"?t.precision===-1?`${e}`:t.precision===0?`${e}:[0-5]\\d`:`${e}:[0-5]\\d\\.\\d{${t.precision}}`:`${e}(?::[0-5]\\d(?:\\.\\d+)?)?`}function b$(t){return new RegExp(`^${dm(t)}$`)}function w$(t){const e=dm({precision:t.precision}),n=["Z"];t.local&&n.push(""),t.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${e}(?:${n.join("|")})`;return new RegExp(`^${hm}T(?:${r})$`)}const S$=t=>{const e=t?`[\\s\\S]{${(t==null?void 0:t.minimum)??0},${(t==null?void 0:t.maximum)??""}}`:"[\\s\\S]*";return new RegExp(`^${e}$`)},_$=/^-?\d+$/,pm=/^-?\d+(?:\.\d+)?$/,k$=/^(?:true|false)$/i,E$=/^[^A-Z]*$/,x$=/^[^a-z]*$/,qe=x("$ZodCheck",(t,e)=>{var n;t._zod??(t._zod={}),t._zod.def=e,(n=t._zod).onattach??(n.onattach=[])}),fm={number:"number",bigint:"bigint",object:"date"},gm=x("$ZodCheckLessThan",(t,e)=>{qe.init(t,e);const n=fm[typeof e.value];t._zod.onattach.push(r=>{const i=r._zod.bag,s=(e.inclusive?i.maximum:i.exclusiveMaximum)??Number.POSITIVE_INFINITY;e.value<s&&(e.inclusive?i.maximum=e.value:i.exclusiveMaximum=e.value)}),t._zod.check=r=>{(e.inclusive?r.value<=e.value:r.value<e.value)||r.issues.push({origin:n,code:"too_big",maximum:typeof e.value=="object"?e.value.getTime():e.value,input:r.value,inclusive:e.inclusive,inst:t,continue:!e.abort})}}),mm=x("$ZodCheckGreaterThan",(t,e)=>{qe.init(t,e);const n=fm[typeof e.value];t._zod.onattach.push(r=>{const i=r._zod.bag,s=(e.inclusive?i.minimum:i.exclusiveMinimum)??Number.NEGATIVE_INFINITY;e.value>s&&(e.inclusive?i.minimum=e.value:i.exclusiveMinimum=e.value)}),t._zod.check=r=>{(e.inclusive?r.value>=e.value:r.value>e.value)||r.issues.push({origin:n,code:"too_small",minimum:typeof e.value=="object"?e.value.getTime():e.value,input:r.value,inclusive:e.inclusive,inst:t,continue:!e.abort})}}),$$=x("$ZodCheckMultipleOf",(t,e)=>{qe.init(t,e),t._zod.onattach.push(n=>{var r;(r=n._zod.bag).multipleOf??(r.multipleOf=e.value)}),t._zod.check=n=>{if(typeof n.value!=typeof e.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%e.value===BigInt(0):Ix(n.value,e.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:e.value,input:n.value,inst:t,continue:!e.abort})}}),A$=x("$ZodCheckNumberFormat",(t,e)=>{var o;qe.init(t,e),e.format=e.format||"float64";const n=(o=e.format)==null?void 0:o.includes("int"),r=n?"int":"number",[i,s]=zx[e.format];t._zod.onattach.push(a=>{const c=a._zod.bag;c.format=e.format,c.minimum=i,c.maximum=s,n&&(c.pattern=_$)}),t._zod.check=a=>{const c=a.value;if(n){if(!Number.isInteger(c)){a.issues.push({expected:r,format:e.format,code:"invalid_type",continue:!1,input:c,inst:t});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:t,origin:r,inclusive:!0,continue:!e.abort}):a.issues.push({input:c,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:r,inclusive:!0,continue:!e.abort});return}}c<i&&a.issues.push({origin:"number",input:c,code:"too_small",minimum:i,inclusive:!0,inst:t,continue:!e.abort}),c>s&&a.issues.push({origin:"number",input:c,code:"too_big",maximum:s,inclusive:!0,inst:t,continue:!e.abort})}}),T$=x("$ZodCheckMaxLength",(t,e)=>{var n;qe.init(t,e),(n=t._zod.def).when??(n.when=r=>{const i=r.value;return!Zu(i)&&i.length!==void 0}),t._zod.onattach.push(r=>{const i=r._zod.bag.maximum??Number.POSITIVE_INFINITY;e.maximum<i&&(r._zod.bag.maximum=e.maximum)}),t._zod.check=r=>{const i=r.value;if(i.length<=e.maximum)return;const o=Bu(i);r.issues.push({origin:o,code:"too_big",maximum:e.maximum,inclusive:!0,input:i,inst:t,continue:!e.abort})}}),C$=x("$ZodCheckMinLength",(t,e)=>{var n;qe.init(t,e),(n=t._zod.def).when??(n.when=r=>{const i=r.value;return!Zu(i)&&i.length!==void 0}),t._zod.onattach.push(r=>{const i=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;e.minimum>i&&(r._zod.bag.minimum=e.minimum)}),t._zod.check=r=>{const i=r.value;if(i.length>=e.minimum)return;const o=Bu(i);r.issues.push({origin:o,code:"too_small",minimum:e.minimum,inclusive:!0,input:i,inst:t,continue:!e.abort})}}),I$=x("$ZodCheckLengthEquals",(t,e)=>{var n;qe.init(t,e),(n=t._zod.def).when??(n.when=r=>{const i=r.value;return!Zu(i)&&i.length!==void 0}),t._zod.onattach.push(r=>{const i=r._zod.bag;i.minimum=e.length,i.maximum=e.length,i.length=e.length}),t._zod.check=r=>{const i=r.value,s=i.length;if(s===e.length)return;const o=Bu(i),a=s>e.length;r.issues.push({origin:o,...a?{code:"too_big",maximum:e.length}:{code:"too_small",minimum:e.length},inclusive:!0,exact:!0,input:r.value,inst:t,continue:!e.abort})}}),Wa=x("$ZodCheckStringFormat",(t,e)=>{var n,r;qe.init(t,e),t._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?(n=t._zod).check??(n.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:t,continue:!e.abort})}):(r=t._zod).check??(r.check=()=>{})}),P$=x("$ZodCheckRegex",(t,e)=>{Wa.init(t,e),t._zod.check=n=>{e.pattern.lastIndex=0,!e.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:e.pattern.toString(),inst:t,continue:!e.abort})}}),R$=x("$ZodCheckLowerCase",(t,e)=>{e.pattern??(e.pattern=E$),Wa.init(t,e)}),D$=x("$ZodCheckUpperCase",(t,e)=>{e.pattern??(e.pattern=x$),Wa.init(t,e)}),O$=x("$ZodCheckIncludes",(t,e)=>{qe.init(t,e);const n=ci(e.includes),r=new RegExp(typeof e.position=="number"?`^.{${e.position}}${n}`:n);e.pattern=r,t._zod.onattach.push(i=>{const s=i._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(r)}),t._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:t,continue:!e.abort})}}),z$=x("$ZodCheckStartsWith",(t,e)=>{qe.init(t,e);const n=new RegExp(`^${ci(e.prefix)}.*`);e.pattern??(e.pattern=n),t._zod.onattach.push(r=>{const i=r._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(n)}),t._zod.check=r=>{r.value.startsWith(e.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:e.prefix,input:r.value,inst:t,continue:!e.abort})}}),L$=x("$ZodCheckEndsWith",(t,e)=>{qe.init(t,e);const n=new RegExp(`.*${ci(e.suffix)}$`);e.pattern??(e.pattern=n),t._zod.onattach.push(r=>{const i=r._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(n)}),t._zod.check=r=>{r.value.endsWith(e.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:e.suffix,input:r.value,inst:t,continue:!e.abort})}}),M$=x("$ZodCheckOverwrite",(t,e)=>{qe.init(t,e),t._zod.check=n=>{n.value=e.tx(n.value)}});class N${constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if(typeof e=="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}const r=e.split(`
|
|
5
|
+
`).filter(o=>o),i=Math.min(...r.map(o=>o.length-o.trimStart().length)),s=r.map(o=>o.slice(i)).map(o=>" ".repeat(this.indent*2)+o);for(const o of s)this.content.push(o)}compile(){const e=Function,n=this==null?void 0:this.args,i=[...((this==null?void 0:this.content)??[""]).map(s=>` ${s}`)];return new e(...n,i.join(`
|
|
6
|
+
`))}}const U$={major:4,minor:3,patch:6},de=x("$ZodType",(t,e)=>{var i;var n;t??(t={}),t._zod.def=e,t._zod.bag=t._zod.bag||{},t._zod.version=U$;const r=[...t._zod.def.checks??[]];t._zod.traits.has("$ZodCheck")&&r.unshift(t);for(const s of r)for(const o of s._zod.onattach)o(t);if(r.length===0)(n=t._zod).deferred??(n.deferred=[]),(i=t._zod.deferred)==null||i.push(()=>{t._zod.run=t._zod.parse});else{const s=(a,c,u)=>{let d=Nr(a),p;for(const y of c){if(y._zod.def.when){if(!y._zod.def.when(a))continue}else if(d)continue;const v=a.issues.length,A=y._zod.check(a);if(A instanceof Promise&&(u==null?void 0:u.async)===!1)throw new Zr;if(p||A instanceof Promise)p=(p??Promise.resolve()).then(async()=>{await A,a.issues.length!==v&&(d||(d=Nr(a,v)))});else{if(a.issues.length===v)continue;d||(d=Nr(a,v))}}return p?p.then(()=>a):a},o=(a,c,u)=>{if(Nr(a))return a.aborted=!0,a;const d=s(c,r,u);if(d instanceof Promise){if(u.async===!1)throw new Zr;return d.then(p=>t._zod.parse(p,u))}return t._zod.parse(d,u)};t._zod.run=(a,c)=>{if(c.skipChecks)return t._zod.parse(a,c);if(c.direction==="backward"){const d=t._zod.parse({value:a.value,issues:[]},{...c,skipChecks:!0});return d instanceof Promise?d.then(p=>o(p,a,c)):o(d,a,c)}const u=t._zod.parse(a,c);if(u instanceof Promise){if(c.async===!1)throw new Zr;return u.then(d=>s(d,r,c))}return s(u,r,c)}}Q(t,"~standard",()=>({validate:s=>{var o;try{const a=Vx(t,s);return a.success?{value:a.data}:{issues:(o=a.error)==null?void 0:o.issues}}catch{return Gx(t,s).then(c=>{var u;return c.success?{value:c.data}:{issues:(u=c.error)==null?void 0:u.issues}})}},vendor:"zod",version:1}))}),Gu=x("$ZodString",(t,e)=>{var n;de.init(t,e),t._zod.pattern=[...((n=t==null?void 0:t._zod.bag)==null?void 0:n.patterns)??[]].pop()??S$(t._zod.bag),t._zod.parse=(r,i)=>{if(e.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:t}),r}}),le=x("$ZodStringFormat",(t,e)=>{Wa.init(t,e),Gu.init(t,e)}),F$=x("$ZodGUID",(t,e)=>{e.pattern??(e.pattern=l$),le.init(t,e)}),Z$=x("$ZodUUID",(t,e)=>{if(e.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[e.version];if(r===void 0)throw new Error(`Invalid UUID version: "${e.version}"`);e.pattern??(e.pattern=vp(r))}else e.pattern??(e.pattern=vp());le.init(t,e)}),H$=x("$ZodEmail",(t,e)=>{e.pattern??(e.pattern=c$),le.init(t,e)}),B$=x("$ZodURL",(t,e)=>{le.init(t,e),t._zod.check=n=>{try{const r=n.value.trim(),i=new URL(r);e.hostname&&(e.hostname.lastIndex=0,e.hostname.test(i.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:e.hostname.source,input:n.value,inst:t,continue:!e.abort})),e.protocol&&(e.protocol.lastIndex=0,e.protocol.test(i.protocol.endsWith(":")?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:e.protocol.source,input:n.value,inst:t,continue:!e.abort})),e.normalize?n.value=i.href:n.value=r;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:t,continue:!e.abort})}}}),j$=x("$ZodEmoji",(t,e)=>{e.pattern??(e.pattern=h$()),le.init(t,e)}),V$=x("$ZodNanoID",(t,e)=>{e.pattern??(e.pattern=o$),le.init(t,e)}),G$=x("$ZodCUID",(t,e)=>{e.pattern??(e.pattern=t$),le.init(t,e)}),W$=x("$ZodCUID2",(t,e)=>{e.pattern??(e.pattern=n$),le.init(t,e)}),q$=x("$ZodULID",(t,e)=>{e.pattern??(e.pattern=r$),le.init(t,e)}),Y$=x("$ZodXID",(t,e)=>{e.pattern??(e.pattern=i$),le.init(t,e)}),K$=x("$ZodKSUID",(t,e)=>{e.pattern??(e.pattern=s$),le.init(t,e)}),J$=x("$ZodISODateTime",(t,e)=>{e.pattern??(e.pattern=w$(e)),le.init(t,e)}),X$=x("$ZodISODate",(t,e)=>{e.pattern??(e.pattern=y$),le.init(t,e)}),Q$=x("$ZodISOTime",(t,e)=>{e.pattern??(e.pattern=b$(e)),le.init(t,e)}),eA=x("$ZodISODuration",(t,e)=>{e.pattern??(e.pattern=a$),le.init(t,e)}),tA=x("$ZodIPv4",(t,e)=>{e.pattern??(e.pattern=d$),le.init(t,e),t._zod.bag.format="ipv4"}),nA=x("$ZodIPv6",(t,e)=>{e.pattern??(e.pattern=p$),le.init(t,e),t._zod.bag.format="ipv6",t._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:t,continue:!e.abort})}}}),rA=x("$ZodCIDRv4",(t,e)=>{e.pattern??(e.pattern=f$),le.init(t,e)}),iA=x("$ZodCIDRv6",(t,e)=>{e.pattern??(e.pattern=g$),le.init(t,e),t._zod.check=n=>{const r=n.value.split("/");try{if(r.length!==2)throw new Error;const[i,s]=r;if(!s)throw new Error;const o=Number(s);if(`${o}`!==s)throw new Error;if(o<0||o>128)throw new Error;new URL(`http://[${i}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:t,continue:!e.abort})}}});function vm(t){if(t==="")return!0;if(t.length%4!==0)return!1;try{return atob(t),!0}catch{return!1}}const sA=x("$ZodBase64",(t,e)=>{e.pattern??(e.pattern=m$),le.init(t,e),t._zod.bag.contentEncoding="base64",t._zod.check=n=>{vm(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:t,continue:!e.abort})}});function oA(t){if(!um.test(t))return!1;const e=t.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=e.padEnd(Math.ceil(e.length/4)*4,"=");return vm(n)}const aA=x("$ZodBase64URL",(t,e)=>{e.pattern??(e.pattern=um),le.init(t,e),t._zod.bag.contentEncoding="base64url",t._zod.check=n=>{oA(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:t,continue:!e.abort})}}),lA=x("$ZodE164",(t,e)=>{e.pattern??(e.pattern=v$),le.init(t,e)});function cA(t,e=null){try{const n=t.split(".");if(n.length!==3)return!1;const[r]=n;if(!r)return!1;const i=JSON.parse(atob(r));return!("typ"in i&&(i==null?void 0:i.typ)!=="JWT"||!i.alg||e&&(!("alg"in i)||i.alg!==e))}catch{return!1}}const uA=x("$ZodJWT",(t,e)=>{le.init(t,e),t._zod.check=n=>{cA(n.value,e.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:t,continue:!e.abort})}}),ym=x("$ZodNumber",(t,e)=>{de.init(t,e),t._zod.pattern=t._zod.bag.pattern??pm,t._zod.parse=(n,r)=>{if(e.coerce)try{n.value=Number(n.value)}catch{}const i=n.value;if(typeof i=="number"&&!Number.isNaN(i)&&Number.isFinite(i))return n;const s=typeof i=="number"?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:i,inst:t,...s?{received:s}:{}}),n}}),hA=x("$ZodNumberFormat",(t,e)=>{A$.init(t,e),ym.init(t,e)}),dA=x("$ZodBoolean",(t,e)=>{de.init(t,e),t._zod.pattern=k$,t._zod.parse=(n,r)=>{if(e.coerce)try{n.value=!!n.value}catch{}const i=n.value;return typeof i=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:t}),n}}),pA=x("$ZodUnknown",(t,e)=>{de.init(t,e),t._zod.parse=n=>n}),fA=x("$ZodNever",(t,e)=>{de.init(t,e),t._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:t}),n)});function yp(t,e,n){t.issues.length&&e.issues.push(...Ur(n,t.issues)),e.value[n]=t.value}const gA=x("$ZodArray",(t,e)=>{de.init(t,e),t._zod.parse=(n,r)=>{const i=n.value;if(!Array.isArray(i))return n.issues.push({expected:"array",code:"invalid_type",input:i,inst:t}),n;n.value=Array(i.length);const s=[];for(let o=0;o<i.length;o++){const a=i[o],c=e.element._zod.run({value:a,issues:[]},r);c instanceof Promise?s.push(c.then(u=>yp(u,n,o))):yp(c,n,o)}return s.length?Promise.all(s).then(()=>n):n}});function ua(t,e,n,r,i){if(t.issues.length){if(i&&!(n in r))return;e.issues.push(...Ur(n,t.issues))}t.value===void 0?n in r&&(e.value[n]=void 0):e.value[n]=t.value}function bm(t){var r,i,s,o;const e=Object.keys(t.shape);for(const a of e)if(!((o=(s=(i=(r=t.shape)==null?void 0:r[a])==null?void 0:i._zod)==null?void 0:s.traits)!=null&&o.has("$ZodType")))throw new Error(`Invalid element at key "${a}": expected a Zod schema`);const n=Ox(t.shape);return{...t,keys:e,keySet:new Set(e),numKeys:e.length,optionalKeys:new Set(n)}}function wm(t,e,n,r,i,s){const o=[],a=i.keySet,c=i.catchall._zod,u=c.def.type,d=c.optout==="optional";for(const p in e){if(a.has(p))continue;if(u==="never"){o.push(p);continue}const y=c.run({value:e[p],issues:[]},r);y instanceof Promise?t.push(y.then(v=>ua(v,n,p,e,d))):ua(y,n,p,e,d)}return o.length&&n.issues.push({code:"unrecognized_keys",keys:o,input:e,inst:s}),t.length?Promise.all(t).then(()=>n):n}const mA=x("$ZodObject",(t,e)=>{de.init(t,e);const n=Object.getOwnPropertyDescriptor(e,"shape");if(!(n!=null&&n.get)){const a=e.shape;Object.defineProperty(e,"shape",{get:()=>{const c={...a};return Object.defineProperty(e,"shape",{value:c}),c}})}const r=Fu(()=>bm(e));Q(t._zod,"propValues",()=>{const a=e.shape,c={};for(const u in a){const d=a[u]._zod;if(d.values){c[u]??(c[u]=new Set);for(const p of d.values)c[u].add(p)}}return c});const i=ca,s=e.catchall;let o;t._zod.parse=(a,c)=>{o??(o=r.value);const u=a.value;if(!i(u))return a.issues.push({expected:"object",code:"invalid_type",input:u,inst:t}),a;a.value={};const d=[],p=o.shape;for(const y of o.keys){const v=p[y],A=v._zod.optout==="optional",E=v._zod.run({value:u[y],issues:[]},c);E instanceof Promise?d.push(E.then(I=>ua(I,a,y,u,A))):ua(E,a,y,u,A)}return s?wm(d,u,a,c,r.value,t):d.length?Promise.all(d).then(()=>a):a}}),vA=x("$ZodObjectJIT",(t,e)=>{mA.init(t,e);const n=t._zod.parse,r=Fu(()=>bm(e)),i=y=>{var V;const v=new N$(["shape","payload","ctx"]),A=r.value,E=O=>{const H=mp(O);return`shape[${H}]._zod.run({ value: input[${H}], issues: [] }, ctx)`};v.write("const input = payload.value;");const I=Object.create(null);let Z=0;for(const O of A.keys)I[O]=`key_${Z++}`;v.write("const newResult = {};");for(const O of A.keys){const H=I[O],N=mp(O),ce=y[O],ue=((V=ce==null?void 0:ce._zod)==null?void 0:V.optout)==="optional";v.write(`const ${H} = ${E(O)};`),ue?v.write(`
|
|
7
|
+
if (${H}.issues.length) {
|
|
8
|
+
if (${N} in input) {
|
|
9
|
+
payload.issues = payload.issues.concat(${H}.issues.map(iss => ({
|
|
10
|
+
...iss,
|
|
11
|
+
path: iss.path ? [${N}, ...iss.path] : [${N}]
|
|
12
|
+
})));
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
if (${H}.value === undefined) {
|
|
17
|
+
if (${N} in input) {
|
|
18
|
+
newResult[${N}] = undefined;
|
|
19
|
+
}
|
|
20
|
+
} else {
|
|
21
|
+
newResult[${N}] = ${H}.value;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
`):v.write(`
|
|
25
|
+
if (${H}.issues.length) {
|
|
26
|
+
payload.issues = payload.issues.concat(${H}.issues.map(iss => ({
|
|
27
|
+
...iss,
|
|
28
|
+
path: iss.path ? [${N}, ...iss.path] : [${N}]
|
|
29
|
+
})));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (${H}.value === undefined) {
|
|
33
|
+
if (${N} in input) {
|
|
34
|
+
newResult[${N}] = undefined;
|
|
35
|
+
}
|
|
36
|
+
} else {
|
|
37
|
+
newResult[${N}] = ${H}.value;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
`)}v.write("payload.value = newResult;"),v.write("return payload;");const P=v.compile();return(O,H)=>P(y,O,H)};let s;const o=ca,a=!rm.jitless,u=a&&Rx.value,d=e.catchall;let p;t._zod.parse=(y,v)=>{p??(p=r.value);const A=y.value;return o(A)?a&&u&&(v==null?void 0:v.async)===!1&&v.jitless!==!0?(s||(s=i(e.shape)),y=s(y,v),d?wm([],A,y,v,p,t):y):n(y,v):(y.issues.push({expected:"object",code:"invalid_type",input:A,inst:t}),y)}});function bp(t,e,n,r){for(const s of t)if(s.issues.length===0)return e.value=s.value,e;const i=t.filter(s=>!Nr(s));return i.length===1?(e.value=i[0].value,i[0]):(e.issues.push({code:"invalid_union",input:e.value,inst:n,errors:t.map(s=>s.issues.map(o=>mn(o,r,gn())))}),e)}const yA=x("$ZodUnion",(t,e)=>{de.init(t,e),Q(t._zod,"optin",()=>e.options.some(i=>i._zod.optin==="optional")?"optional":void 0),Q(t._zod,"optout",()=>e.options.some(i=>i._zod.optout==="optional")?"optional":void 0),Q(t._zod,"values",()=>{if(e.options.every(i=>i._zod.values))return new Set(e.options.flatMap(i=>Array.from(i._zod.values)))}),Q(t._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=>Hu(s.source)).join("|")})$`)}});const n=e.options.length===1,r=e.options[0]._zod.run;t._zod.parse=(i,s)=>{if(n)return r(i,s);let o=!1;const a=[];for(const c of e.options){const u=c._zod.run({value:i.value,issues:[]},s);if(u instanceof Promise)a.push(u),o=!0;else{if(u.issues.length===0)return u;a.push(u)}}return o?Promise.all(a).then(c=>bp(c,i,t,s)):bp(a,i,t,s)}}),bA=x("$ZodIntersection",(t,e)=>{de.init(t,e),t._zod.parse=(n,r)=>{const i=n.value,s=e.left._zod.run({value:i,issues:[]},r),o=e.right._zod.run({value:i,issues:[]},r);return s instanceof Promise||o instanceof Promise?Promise.all([s,o]).then(([c,u])=>wp(n,c,u)):wp(n,s,o)}});function Ec(t,e){if(t===e)return{valid:!0,data:t};if(t instanceof Date&&e instanceof Date&&+t==+e)return{valid:!0,data:t};if(li(t)&&li(e)){const n=Object.keys(e),r=Object.keys(t).filter(s=>n.indexOf(s)!==-1),i={...t,...e};for(const s of r){const o=Ec(t[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(t)&&Array.isArray(e)){if(t.length!==e.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<t.length;r++){const i=t[r],s=e[r],o=Ec(i,s);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function wp(t,e,n){const r=new Map;let i;for(const a of e.issues)if(a.code==="unrecognized_keys"){i??(i=a);for(const c of a.keys)r.has(c)||r.set(c,{}),r.get(c).l=!0}else t.issues.push(a);for(const a of n.issues)if(a.code==="unrecognized_keys")for(const c of a.keys)r.has(c)||r.set(c,{}),r.get(c).r=!0;else t.issues.push(a);const s=[...r].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(s.length&&i&&t.issues.push({...i,keys:s}),Nr(t))return t;const o=Ec(e.value,n.value);if(!o.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return t.value=o.data,t}const wA=x("$ZodRecord",(t,e)=>{de.init(t,e),t._zod.parse=(n,r)=>{const i=n.value;if(!li(i))return n.issues.push({expected:"record",code:"invalid_type",input:i,inst:t}),n;const s=[],o=e.keyType._zod.values;if(o){n.value={};const a=new Set;for(const u of o)if(typeof u=="string"||typeof u=="number"||typeof u=="symbol"){a.add(typeof u=="number"?u.toString():u);const d=e.valueType._zod.run({value:i[u],issues:[]},r);d instanceof Promise?s.push(d.then(p=>{p.issues.length&&n.issues.push(...Ur(u,p.issues)),n.value[u]=p.value})):(d.issues.length&&n.issues.push(...Ur(u,d.issues)),n.value[u]=d.value)}let c;for(const u in i)a.has(u)||(c=c??[],c.push(u));c&&c.length>0&&n.issues.push({code:"unrecognized_keys",input:i,inst:t,keys:c})}else{n.value={};for(const a of Reflect.ownKeys(i)){if(a==="__proto__")continue;let c=e.keyType._zod.run({value:a,issues:[]},r);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof a=="string"&&pm.test(a)&&c.issues.length){const p=e.keyType._zod.run({value:Number(a),issues:[]},r);if(p instanceof Promise)throw new Error("Async schemas not supported in object keys currently");p.issues.length===0&&(c=p)}if(c.issues.length){e.mode==="loose"?n.value[a]=i[a]:n.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(p=>mn(p,r,gn())),input:a,path:[a],inst:t});continue}const d=e.valueType._zod.run({value:i[a],issues:[]},r);d instanceof Promise?s.push(d.then(p=>{p.issues.length&&n.issues.push(...Ur(a,p.issues)),n.value[c.value]=p.value})):(d.issues.length&&n.issues.push(...Ur(a,d.issues)),n.value[c.value]=d.value)}}return s.length?Promise.all(s).then(()=>n):n}}),SA=x("$ZodEnum",(t,e)=>{de.init(t,e);const n=im(e.entries),r=new Set(n);t._zod.values=r,t._zod.pattern=new RegExp(`^(${n.filter(i=>Dx.has(typeof i)).map(i=>typeof i=="string"?ci(i):i.toString()).join("|")})$`),t._zod.parse=(i,s)=>{const o=i.value;return r.has(o)||i.issues.push({code:"invalid_value",values:n,input:o,inst:t}),i}}),_A=x("$ZodLiteral",(t,e)=>{if(de.init(t,e),e.values.length===0)throw new Error("Cannot create literal schema with no valid values");const n=new Set(e.values);t._zod.values=n,t._zod.pattern=new RegExp(`^(${e.values.map(r=>typeof r=="string"?ci(r):r?ci(r.toString()):String(r)).join("|")})$`),t._zod.parse=(r,i)=>{const s=r.value;return n.has(s)||r.issues.push({code:"invalid_value",values:e.values,input:s,inst:t}),r}}),kA=x("$ZodTransform",(t,e)=>{de.init(t,e),t._zod.parse=(n,r)=>{if(r.direction==="backward")throw new nm(t.constructor.name);const i=e.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(o=>(n.value=o,n));if(i instanceof Promise)throw new Zr;return n.value=i,n}});function Sp(t,e){return t.issues.length&&e===void 0?{issues:[],value:void 0}:t}const Sm=x("$ZodOptional",(t,e)=>{de.init(t,e),t._zod.optin="optional",t._zod.optout="optional",Q(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,void 0]):void 0),Q(t._zod,"pattern",()=>{const n=e.innerType._zod.pattern;return n?new RegExp(`^(${Hu(n.source)})?$`):void 0}),t._zod.parse=(n,r)=>{if(e.innerType._zod.optin==="optional"){const i=e.innerType._zod.run(n,r);return i instanceof Promise?i.then(s=>Sp(s,n.value)):Sp(i,n.value)}return n.value===void 0?n:e.innerType._zod.run(n,r)}}),EA=x("$ZodExactOptional",(t,e)=>{Sm.init(t,e),Q(t._zod,"values",()=>e.innerType._zod.values),Q(t._zod,"pattern",()=>e.innerType._zod.pattern),t._zod.parse=(n,r)=>e.innerType._zod.run(n,r)}),xA=x("$ZodNullable",(t,e)=>{de.init(t,e),Q(t._zod,"optin",()=>e.innerType._zod.optin),Q(t._zod,"optout",()=>e.innerType._zod.optout),Q(t._zod,"pattern",()=>{const n=e.innerType._zod.pattern;return n?new RegExp(`^(${Hu(n.source)}|null)$`):void 0}),Q(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,null]):void 0),t._zod.parse=(n,r)=>n.value===null?n:e.innerType._zod.run(n,r)}),$A=x("$ZodDefault",(t,e)=>{de.init(t,e),t._zod.optin="optional",Q(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(n,r)=>{if(r.direction==="backward")return e.innerType._zod.run(n,r);if(n.value===void 0)return n.value=e.defaultValue,n;const i=e.innerType._zod.run(n,r);return i instanceof Promise?i.then(s=>_p(s,e)):_p(i,e)}});function _p(t,e){return t.value===void 0&&(t.value=e.defaultValue),t}const AA=x("$ZodPrefault",(t,e)=>{de.init(t,e),t._zod.optin="optional",Q(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(n,r)=>(r.direction==="backward"||n.value===void 0&&(n.value=e.defaultValue),e.innerType._zod.run(n,r))}),TA=x("$ZodNonOptional",(t,e)=>{de.init(t,e),Q(t._zod,"values",()=>{const n=e.innerType._zod.values;return n?new Set([...n].filter(r=>r!==void 0)):void 0}),t._zod.parse=(n,r)=>{const i=e.innerType._zod.run(n,r);return i instanceof Promise?i.then(s=>kp(s,t)):kp(i,t)}});function kp(t,e){return!t.issues.length&&t.value===void 0&&t.issues.push({code:"invalid_type",expected:"nonoptional",input:t.value,inst:e}),t}const CA=x("$ZodCatch",(t,e)=>{de.init(t,e),Q(t._zod,"optin",()=>e.innerType._zod.optin),Q(t._zod,"optout",()=>e.innerType._zod.optout),Q(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(n,r)=>{if(r.direction==="backward")return e.innerType._zod.run(n,r);const i=e.innerType._zod.run(n,r);return i instanceof Promise?i.then(s=>(n.value=s.value,s.issues.length&&(n.value=e.catchValue({...n,error:{issues:s.issues.map(o=>mn(o,r,gn()))},input:n.value}),n.issues=[]),n)):(n.value=i.value,i.issues.length&&(n.value=e.catchValue({...n,error:{issues:i.issues.map(s=>mn(s,r,gn()))},input:n.value}),n.issues=[]),n)}}),IA=x("$ZodPipe",(t,e)=>{de.init(t,e),Q(t._zod,"values",()=>e.in._zod.values),Q(t._zod,"optin",()=>e.in._zod.optin),Q(t._zod,"optout",()=>e.out._zod.optout),Q(t._zod,"propValues",()=>e.in._zod.propValues),t._zod.parse=(n,r)=>{if(r.direction==="backward"){const s=e.out._zod.run(n,r);return s instanceof Promise?s.then(o=>Ao(o,e.in,r)):Ao(s,e.in,r)}const i=e.in._zod.run(n,r);return i instanceof Promise?i.then(s=>Ao(s,e.out,r)):Ao(i,e.out,r)}});function Ao(t,e,n){return t.issues.length?(t.aborted=!0,t):e._zod.run({value:t.value,issues:t.issues},n)}const PA=x("$ZodReadonly",(t,e)=>{de.init(t,e),Q(t._zod,"propValues",()=>e.innerType._zod.propValues),Q(t._zod,"values",()=>e.innerType._zod.values),Q(t._zod,"optin",()=>{var n,r;return(r=(n=e.innerType)==null?void 0:n._zod)==null?void 0:r.optin}),Q(t._zod,"optout",()=>{var n,r;return(r=(n=e.innerType)==null?void 0:n._zod)==null?void 0:r.optout}),t._zod.parse=(n,r)=>{if(r.direction==="backward")return e.innerType._zod.run(n,r);const i=e.innerType._zod.run(n,r);return i instanceof Promise?i.then(Ep):Ep(i)}});function Ep(t){return t.value=Object.freeze(t.value),t}const RA=x("$ZodCustom",(t,e)=>{qe.init(t,e),de.init(t,e),t._zod.parse=(n,r)=>n,t._zod.check=n=>{const r=n.value,i=e.fn(r);if(i instanceof Promise)return i.then(s=>xp(s,n,r,t));xp(i,n,r,t)}});function xp(t,e,n,r){if(!t){const i={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(i.params=r._zod.def.params),e.issues.push(is(i))}}var $p;class DA{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...n){const r=n[0];return this._map.set(e,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){const n=this._map.get(e);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(e),this}get(e){const n=e._zod.parent;if(n){const r={...this.get(n)??{}};delete r.id;const i={...r,...this._map.get(e)};return Object.keys(i).length?i:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function OA(){return new DA}($p=globalThis).__zod_globalRegistry??($p.__zod_globalRegistry=OA());const Bi=globalThis.__zod_globalRegistry;function zA(t,e){return new t({type:"string",...z(e)})}function LA(t,e){return new t({type:"string",format:"email",check:"string_format",abort:!1,...z(e)})}function Ap(t,e){return new t({type:"string",format:"guid",check:"string_format",abort:!1,...z(e)})}function MA(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,...z(e)})}function NA(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...z(e)})}function UA(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...z(e)})}function FA(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...z(e)})}function ZA(t,e){return new t({type:"string",format:"url",check:"string_format",abort:!1,...z(e)})}function HA(t,e){return new t({type:"string",format:"emoji",check:"string_format",abort:!1,...z(e)})}function BA(t,e){return new t({type:"string",format:"nanoid",check:"string_format",abort:!1,...z(e)})}function jA(t,e){return new t({type:"string",format:"cuid",check:"string_format",abort:!1,...z(e)})}function VA(t,e){return new t({type:"string",format:"cuid2",check:"string_format",abort:!1,...z(e)})}function GA(t,e){return new t({type:"string",format:"ulid",check:"string_format",abort:!1,...z(e)})}function WA(t,e){return new t({type:"string",format:"xid",check:"string_format",abort:!1,...z(e)})}function qA(t,e){return new t({type:"string",format:"ksuid",check:"string_format",abort:!1,...z(e)})}function YA(t,e){return new t({type:"string",format:"ipv4",check:"string_format",abort:!1,...z(e)})}function KA(t,e){return new t({type:"string",format:"ipv6",check:"string_format",abort:!1,...z(e)})}function JA(t,e){return new t({type:"string",format:"cidrv4",check:"string_format",abort:!1,...z(e)})}function XA(t,e){return new t({type:"string",format:"cidrv6",check:"string_format",abort:!1,...z(e)})}function QA(t,e){return new t({type:"string",format:"base64",check:"string_format",abort:!1,...z(e)})}function e1(t,e){return new t({type:"string",format:"base64url",check:"string_format",abort:!1,...z(e)})}function t1(t,e){return new t({type:"string",format:"e164",check:"string_format",abort:!1,...z(e)})}function n1(t,e){return new t({type:"string",format:"jwt",check:"string_format",abort:!1,...z(e)})}function r1(t,e){return new t({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...z(e)})}function i1(t,e){return new t({type:"string",format:"date",check:"string_format",...z(e)})}function s1(t,e){return new t({type:"string",format:"time",check:"string_format",precision:null,...z(e)})}function o1(t,e){return new t({type:"string",format:"duration",check:"string_format",...z(e)})}function a1(t,e){return new t({type:"number",checks:[],...z(e)})}function l1(t,e){return new t({type:"number",check:"number_format",abort:!1,format:"safeint",...z(e)})}function c1(t,e){return new t({type:"boolean",...z(e)})}function u1(t){return new t({type:"unknown"})}function h1(t,e){return new t({type:"never",...z(e)})}function Tp(t,e){return new gm({check:"less_than",...z(e),value:t,inclusive:!1})}function Hl(t,e){return new gm({check:"less_than",...z(e),value:t,inclusive:!0})}function Cp(t,e){return new mm({check:"greater_than",...z(e),value:t,inclusive:!1})}function Bl(t,e){return new mm({check:"greater_than",...z(e),value:t,inclusive:!0})}function Ip(t,e){return new $$({check:"multiple_of",...z(e),value:t})}function _m(t,e){return new T$({check:"max_length",...z(e),maximum:t})}function ha(t,e){return new C$({check:"min_length",...z(e),minimum:t})}function km(t,e){return new I$({check:"length_equals",...z(e),length:t})}function d1(t,e){return new P$({check:"string_format",format:"regex",...z(e),pattern:t})}function p1(t){return new R$({check:"string_format",format:"lowercase",...z(t)})}function f1(t){return new D$({check:"string_format",format:"uppercase",...z(t)})}function g1(t,e){return new O$({check:"string_format",format:"includes",...z(e),includes:t})}function m1(t,e){return new z$({check:"string_format",format:"starts_with",...z(e),prefix:t})}function v1(t,e){return new L$({check:"string_format",format:"ends_with",...z(e),suffix:t})}function Si(t){return new M$({check:"overwrite",tx:t})}function y1(t){return Si(e=>e.normalize(t))}function b1(){return Si(t=>t.trim())}function w1(){return Si(t=>t.toLowerCase())}function S1(){return Si(t=>t.toUpperCase())}function _1(){return Si(t=>Px(t))}function k1(t,e,n){return new t({type:"array",element:e,...z(n)})}function E1(t,e,n){return new t({type:"custom",check:"custom",fn:e,...z(n)})}function x1(t){const e=$1(n=>(n.addIssue=r=>{if(typeof r=="string")n.issues.push(is(r,n.value,e._zod.def));else{const i=r;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=n.value),i.inst??(i.inst=e),i.continue??(i.continue=!e._zod.def.abort),n.issues.push(is(i))}},t(n.value,n)));return e}function $1(t,e){const n=new qe({check:"custom",...z(e)});return n._zod.check=t,n}function Em(t){let e=(t==null?void 0:t.target)??"draft-2020-12";return e==="draft-4"&&(e="draft-04"),e==="draft-7"&&(e="draft-07"),{processors:t.processors??{},metadataRegistry:(t==null?void 0:t.metadata)??Bi,target:e,unrepresentable:(t==null?void 0:t.unrepresentable)??"throw",override:(t==null?void 0:t.override)??(()=>{}),io:(t==null?void 0:t.io)??"output",counter:0,seen:new Map,cycles:(t==null?void 0:t.cycles)??"ref",reused:(t==null?void 0:t.reused)??"inline",external:(t==null?void 0:t.external)??void 0}}function ye(t,e,n={path:[],schemaPath:[]}){var d,p;var r;const i=t._zod.def,s=e.seen.get(t);if(s)return s.count++,n.schemaPath.includes(t)&&(s.cycle=n.path),s.schema;const o={schema:{},count:1,cycle:void 0,path:n.path};e.seen.set(t,o);const a=(p=(d=t._zod).toJSONSchema)==null?void 0:p.call(d);if(a)o.schema=a;else{const y={...n,schemaPath:[...n.schemaPath,t],path:n.path};if(t._zod.processJSONSchema)t._zod.processJSONSchema(e,o.schema,y);else{const A=o.schema,E=e.processors[i.type];if(!E)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);E(t,e,A,y)}const v=t._zod.parent;v&&(o.ref||(o.ref=v),ye(v,e,y),e.seen.get(v).isParent=!0)}const c=e.metadataRegistry.get(t);return c&&Object.assign(o.schema,c),e.io==="input"&&Le(t)&&(delete o.schema.examples,delete o.schema.default),e.io==="input"&&o.schema._prefault&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,e.seen.get(t).schema}function xm(t,e){var o,a,c,u;const n=t.seen.get(e);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=new Map;for(const d of t.seen.entries()){const p=(o=t.metadataRegistry.get(d[0]))==null?void 0:o.id;if(p){const y=r.get(p);if(y&&y!==d[0])throw new Error(`Duplicate schema id "${p}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(p,d[0])}}const i=d=>{var E;const p=t.target==="draft-2020-12"?"$defs":"definitions";if(t.external){const I=(E=t.external.registry.get(d[0]))==null?void 0:E.id,Z=t.external.uri??(V=>V);if(I)return{ref:Z(I)};const P=d[1].defId??d[1].schema.id??`schema${t.counter++}`;return d[1].defId=P,{defId:P,ref:`${Z("__shared")}#/${p}/${P}`}}if(d[1]===n)return{ref:"#"};const v=`#/${p}/`,A=d[1].schema.id??`__schema${t.counter++}`;return{defId:A,ref:v+A}},s=d=>{if(d[1].schema.$ref)return;const p=d[1],{ref:y,defId:v}=i(d);p.def={...p.schema},v&&(p.defId=v);const A=p.schema;for(const E in A)delete A[E];A.$ref=y};if(t.cycles==="throw")for(const d of t.seen.entries()){const p=d[1];if(p.cycle)throw new Error(`Cycle detected: #/${(a=p.cycle)==null?void 0:a.join("/")}/<root>
|
|
41
|
+
|
|
42
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const d of t.seen.entries()){const p=d[1];if(e===d[0]){s(d);continue}if(t.external){const v=(c=t.external.registry.get(d[0]))==null?void 0:c.id;if(e!==d[0]&&v){s(d);continue}}if((u=t.metadataRegistry.get(d[0]))==null?void 0:u.id){s(d);continue}if(p.cycle){s(d);continue}if(p.count>1&&t.reused==="ref"){s(d);continue}}}function $m(t,e){var o,a,c;const n=t.seen.get(e);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=u=>{const d=t.seen.get(u);if(d.ref===null)return;const p=d.def??d.schema,y={...p},v=d.ref;if(d.ref=null,v){r(v);const E=t.seen.get(v),I=E.schema;if(I.$ref&&(t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0")?(p.allOf=p.allOf??[],p.allOf.push(I)):Object.assign(p,I),Object.assign(p,y),u._zod.parent===v)for(const P in p)P==="$ref"||P==="allOf"||P in y||delete p[P];if(I.$ref&&E.def)for(const P in p)P==="$ref"||P==="allOf"||P in E.def&&JSON.stringify(p[P])===JSON.stringify(E.def[P])&&delete p[P]}const A=u._zod.parent;if(A&&A!==v){r(A);const E=t.seen.get(A);if(E!=null&&E.schema.$ref&&(p.$ref=E.schema.$ref,E.def))for(const I in p)I==="$ref"||I==="allOf"||I in E.def&&JSON.stringify(p[I])===JSON.stringify(E.def[I])&&delete p[I]}t.override({zodSchema:u,jsonSchema:p,path:d.path??[]})};for(const u of[...t.seen.entries()].reverse())r(u[0]);const i={};if(t.target==="draft-2020-12"?i.$schema="https://json-schema.org/draft/2020-12/schema":t.target==="draft-07"?i.$schema="http://json-schema.org/draft-07/schema#":t.target==="draft-04"?i.$schema="http://json-schema.org/draft-04/schema#":t.target,(o=t.external)!=null&&o.uri){const u=(a=t.external.registry.get(e))==null?void 0:a.id;if(!u)throw new Error("Schema is missing an `id` property");i.$id=t.external.uri(u)}Object.assign(i,n.def??n.schema);const s=((c=t.external)==null?void 0:c.defs)??{};for(const u of t.seen.entries()){const d=u[1];d.def&&d.defId&&(s[d.defId]=d.def)}t.external||Object.keys(s).length>0&&(t.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",t.processors),output:da(e,"output",t.processors)}},enumerable:!1,writable:!1}),u}catch{throw new Error("Error converting schema to JSON.")}}function Le(t,e){const n=e??{seen:new Set};if(n.seen.has(t))return!1;n.seen.add(t);const r=t._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return Le(r.element,n);if(r.type==="set")return Le(r.valueType,n);if(r.type==="lazy")return Le(r.getter(),n);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault")return Le(r.innerType,n);if(r.type==="intersection")return Le(r.left,n)||Le(r.right,n);if(r.type==="record"||r.type==="map")return Le(r.keyType,n)||Le(r.valueType,n);if(r.type==="pipe")return Le(r.in,n)||Le(r.out,n);if(r.type==="object"){for(const i in r.shape)if(Le(r.shape[i],n))return!0;return!1}if(r.type==="union"){for(const i of r.options)if(Le(i,n))return!0;return!1}if(r.type==="tuple"){for(const i of r.items)if(Le(i,n))return!0;return!!(r.rest&&Le(r.rest,n))}return!1}const A1=(t,e={})=>n=>{const r=Em({...n,processors:e});return ye(t,r),xm(r,t),$m(r,t)},da=(t,e,n={})=>r=>{const{libraryOptions:i,target:s}=r??{},o=Em({...i??{},target:s,io:e,processors:n});return ye(t,o),xm(o,t),$m(o,t)},T1={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},C1=(t,e,n,r)=>{const i=n;i.type="string";const{minimum:s,maximum:o,format:a,patterns:c,contentEncoding:u}=t._zod.bag;if(typeof s=="number"&&(i.minLength=s),typeof o=="number"&&(i.maxLength=o),a&&(i.format=T1[a]??a,i.format===""&&delete i.format,a==="time"&&delete i.format),u&&(i.contentEncoding=u),c&&c.size>0){const d=[...c];d.length===1?i.pattern=d[0].source:d.length>1&&(i.allOf=[...d.map(p=>({...e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"?{type:"string"}:{},pattern:p.source}))])}},I1=(t,e,n,r)=>{const i=n,{minimum:s,maximum:o,format:a,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:d}=t._zod.bag;typeof a=="string"&&a.includes("int")?i.type="integer":i.type="number",typeof d=="number"&&(e.target==="draft-04"||e.target==="openapi-3.0"?(i.minimum=d,i.exclusiveMinimum=!0):i.exclusiveMinimum=d),typeof s=="number"&&(i.minimum=s,typeof d=="number"&&e.target!=="draft-04"&&(d>=s?delete i.minimum:delete i.exclusiveMinimum)),typeof u=="number"&&(e.target==="draft-04"||e.target==="openapi-3.0"?(i.maximum=u,i.exclusiveMaximum=!0):i.exclusiveMaximum=u),typeof o=="number"&&(i.maximum=o,typeof u=="number"&&e.target!=="draft-04"&&(u<=o?delete i.maximum:delete i.exclusiveMaximum)),typeof c=="number"&&(i.multipleOf=c)},P1=(t,e,n,r)=>{n.type="boolean"},R1=(t,e,n,r)=>{n.not={}},D1=(t,e,n,r)=>{},O1=(t,e,n,r)=>{const i=t._zod.def,s=im(i.entries);s.every(o=>typeof o=="number")&&(n.type="number"),s.every(o=>typeof o=="string")&&(n.type="string"),n.enum=s},z1=(t,e,n,r)=>{const i=t._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];n.type=o===null?"null":typeof o,e.target==="draft-04"||e.target==="openapi-3.0"?n.enum=[o]:n.const=o}else s.every(o=>typeof o=="number")&&(n.type="number"),s.every(o=>typeof o=="string")&&(n.type="string"),s.every(o=>typeof o=="boolean")&&(n.type="boolean"),s.every(o=>o===null)&&(n.type="null"),n.enum=s},L1=(t,e,n,r)=>{if(e.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},M1=(t,e,n,r)=>{if(e.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},N1=(t,e,n,r)=>{const i=n,s=t._zod.def,{minimum:o,maximum:a}=t._zod.bag;typeof o=="number"&&(i.minItems=o),typeof a=="number"&&(i.maxItems=a),i.type="array",i.items=ye(s.element,e,{...r,path:[...r.path,"items"]})},U1=(t,e,n,r)=>{var u;const i=n,s=t._zod.def;i.type="object",i.properties={};const o=s.shape;for(const d in o)i.properties[d]=ye(o[d],e,{...r,path:[...r.path,"properties",d]});const a=new Set(Object.keys(o)),c=new Set([...a].filter(d=>{const p=s.shape[d]._zod;return e.io==="input"?p.optin===void 0:p.optout===void 0}));c.size>0&&(i.required=Array.from(c)),((u=s.catchall)==null?void 0:u._zod.def.type)==="never"?i.additionalProperties=!1:s.catchall?s.catchall&&(i.additionalProperties=ye(s.catchall,e,{...r,path:[...r.path,"additionalProperties"]})):e.io==="output"&&(i.additionalProperties=!1)},F1=(t,e,n,r)=>{const i=t._zod.def,s=i.inclusive===!1,o=i.options.map((a,c)=>ye(a,e,{...r,path:[...r.path,s?"oneOf":"anyOf",c]}));s?n.oneOf=o:n.anyOf=o},Z1=(t,e,n,r)=>{const i=t._zod.def,s=ye(i.left,e,{...r,path:[...r.path,"allOf",0]}),o=ye(i.right,e,{...r,path:[...r.path,"allOf",1]}),a=u=>"allOf"in u&&Object.keys(u).length===1,c=[...a(s)?s.allOf:[s],...a(o)?o.allOf:[o]];n.allOf=c},H1=(t,e,n,r)=>{const i=n,s=t._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 d=ye(s.valueType,e,{...r,path:[...r.path,"patternProperties","*"]});i.patternProperties={};for(const p of c)i.patternProperties[p.source]=d}else(e.target==="draft-07"||e.target==="draft-2020-12")&&(i.propertyNames=ye(s.keyType,e,{...r,path:[...r.path,"propertyNames"]})),i.additionalProperties=ye(s.valueType,e,{...r,path:[...r.path,"additionalProperties"]});const u=o._zod.values;if(u){const d=[...u].filter(p=>typeof p=="string"||typeof p=="number");d.length>0&&(i.required=d)}},B1=(t,e,n,r)=>{const i=t._zod.def,s=ye(i.innerType,e,r),o=e.seen.get(t);e.target==="openapi-3.0"?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[s,{type:"null"}]},j1=(t,e,n,r)=>{const i=t._zod.def;ye(i.innerType,e,r);const s=e.seen.get(t);s.ref=i.innerType},V1=(t,e,n,r)=>{const i=t._zod.def;ye(i.innerType,e,r);const s=e.seen.get(t);s.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},G1=(t,e,n,r)=>{const i=t._zod.def;ye(i.innerType,e,r);const s=e.seen.get(t);s.ref=i.innerType,e.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},W1=(t,e,n,r)=>{const i=t._zod.def;ye(i.innerType,e,r);const s=e.seen.get(t);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")}n.default=o},q1=(t,e,n,r)=>{const i=t._zod.def,s=e.io==="input"?i.in._zod.def.type==="transform"?i.out:i.in:i.out;ye(s,e,r);const o=e.seen.get(t);o.ref=s},Y1=(t,e,n,r)=>{const i=t._zod.def;ye(i.innerType,e,r);const s=e.seen.get(t);s.ref=i.innerType,n.readOnly=!0},Am=(t,e,n,r)=>{const i=t._zod.def;ye(i.innerType,e,r);const s=e.seen.get(t);s.ref=i.innerType},K1=x("ZodISODateTime",(t,e)=>{J$.init(t,e),fe.init(t,e)});function J1(t){return r1(K1,t)}const X1=x("ZodISODate",(t,e)=>{X$.init(t,e),fe.init(t,e)});function Q1(t){return i1(X1,t)}const eT=x("ZodISOTime",(t,e)=>{Q$.init(t,e),fe.init(t,e)});function tT(t){return s1(eT,t)}const nT=x("ZodISODuration",(t,e)=>{eA.init(t,e),fe.init(t,e)});function rT(t){return o1(nT,t)}const Tm=(t,e)=>{lm.init(t,e),t.name="ZodError",Object.defineProperties(t,{format:{value:n=>jx(t,n)},flatten:{value:n=>Bx(t,n)},addIssue:{value:n=>{t.issues.push(n),t.message=JSON.stringify(t.issues,kc,2)}},addIssues:{value:n=>{t.issues.push(...n),t.message=JSON.stringify(t.issues,kc,2)}},isEmpty:{get(){return t.issues.length===0}}})},Pp=x("ZodError",Tm),at=x("ZodError",Tm,{Parent:Error}),iT=ju(at),sT=Vu(at),oT=Va(at),aT=Ga(at),lT=Wx(at),cT=qx(at),uT=Yx(at),hT=Kx(at),dT=Jx(at),pT=Xx(at),fT=Qx(at),gT=e$(at),pe=x("ZodType",(t,e)=>(de.init(t,e),Object.assign(t["~standard"],{jsonSchema:{input:da(t,"input"),output:da(t,"output")}}),t.toJSONSchema=A1(t,{}),t.def=e,t.type=e.type,Object.defineProperty(t,"_def",{value:e}),t.check=(...n)=>t.clone(kn(e,{checks:[...e.checks??[],...n.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0}),t.with=t.check,t.clone=(n,r)=>En(t,n,r),t.brand=()=>t,t.register=(n,r)=>(n.add(t,r),t),t.parse=(n,r)=>iT(t,n,r,{callee:t.parse}),t.safeParse=(n,r)=>oT(t,n,r),t.parseAsync=async(n,r)=>sT(t,n,r,{callee:t.parseAsync}),t.safeParseAsync=async(n,r)=>aT(t,n,r),t.spa=t.safeParseAsync,t.encode=(n,r)=>lT(t,n,r),t.decode=(n,r)=>cT(t,n,r),t.encodeAsync=async(n,r)=>uT(t,n,r),t.decodeAsync=async(n,r)=>hT(t,n,r),t.safeEncode=(n,r)=>dT(t,n,r),t.safeDecode=(n,r)=>pT(t,n,r),t.safeEncodeAsync=async(n,r)=>fT(t,n,r),t.safeDecodeAsync=async(n,r)=>gT(t,n,r),t.refine=(n,r)=>t.check(oC(n,r)),t.superRefine=n=>t.check(aC(n)),t.overwrite=n=>t.check(Si(n)),t.optional=()=>Op(t),t.exactOptional=()=>WT(t),t.nullable=()=>zp(t),t.nullish=()=>Op(zp(t)),t.nonoptional=n=>QT(t,n),t.array=()=>D(t),t.or=n=>B([t,n]),t.and=n=>qa(t,n),t.transform=n=>Lp(t,VT(n)),t.default=n=>KT(t,n),t.prefault=n=>XT(t,n),t.catch=n=>tC(t,n),t.pipe=n=>Lp(t,n),t.readonly=()=>iC(t),t.describe=n=>{const r=t.clone();return Bi.add(r,{description:n}),r},Object.defineProperty(t,"description",{get(){var n;return(n=Bi.get(t))==null?void 0:n.description},configurable:!0}),t.meta=(...n)=>{if(n.length===0)return Bi.get(t);const r=t.clone();return Bi.add(r,n[0]),r},t.isOptional=()=>t.safeParse(void 0).success,t.isNullable=()=>t.safeParse(null).success,t.apply=n=>n(t),t)),Cm=x("_ZodString",(t,e)=>{Gu.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(r,i,s)=>C1(t,r,i);const n=t._zod.bag;t.format=n.format??null,t.minLength=n.minimum??null,t.maxLength=n.maximum??null,t.regex=(...r)=>t.check(d1(...r)),t.includes=(...r)=>t.check(g1(...r)),t.startsWith=(...r)=>t.check(m1(...r)),t.endsWith=(...r)=>t.check(v1(...r)),t.min=(...r)=>t.check(ha(...r)),t.max=(...r)=>t.check(_m(...r)),t.length=(...r)=>t.check(km(...r)),t.nonempty=(...r)=>t.check(ha(1,...r)),t.lowercase=r=>t.check(p1(r)),t.uppercase=r=>t.check(f1(r)),t.trim=()=>t.check(b1()),t.normalize=(...r)=>t.check(y1(...r)),t.toLowerCase=()=>t.check(w1()),t.toUpperCase=()=>t.check(S1()),t.slugify=()=>t.check(_1())}),mT=x("ZodString",(t,e)=>{Gu.init(t,e),Cm.init(t,e),t.email=n=>t.check(LA(vT,n)),t.url=n=>t.check(ZA(yT,n)),t.jwt=n=>t.check(n1(DT,n)),t.emoji=n=>t.check(HA(bT,n)),t.guid=n=>t.check(Ap(Rp,n)),t.uuid=n=>t.check(MA(To,n)),t.uuidv4=n=>t.check(NA(To,n)),t.uuidv6=n=>t.check(UA(To,n)),t.uuidv7=n=>t.check(FA(To,n)),t.nanoid=n=>t.check(BA(wT,n)),t.guid=n=>t.check(Ap(Rp,n)),t.cuid=n=>t.check(jA(ST,n)),t.cuid2=n=>t.check(VA(_T,n)),t.ulid=n=>t.check(GA(kT,n)),t.base64=n=>t.check(QA(IT,n)),t.base64url=n=>t.check(e1(PT,n)),t.xid=n=>t.check(WA(ET,n)),t.ksuid=n=>t.check(qA(xT,n)),t.ipv4=n=>t.check(YA($T,n)),t.ipv6=n=>t.check(KA(AT,n)),t.cidrv4=n=>t.check(JA(TT,n)),t.cidrv6=n=>t.check(XA(CT,n)),t.e164=n=>t.check(t1(RT,n)),t.datetime=n=>t.check(J1(n)),t.date=n=>t.check(Q1(n)),t.time=n=>t.check(tT(n)),t.duration=n=>t.check(rT(n))});function h(t){return zA(mT,t)}const fe=x("ZodStringFormat",(t,e)=>{le.init(t,e),Cm.init(t,e)}),vT=x("ZodEmail",(t,e)=>{H$.init(t,e),fe.init(t,e)}),Rp=x("ZodGUID",(t,e)=>{F$.init(t,e),fe.init(t,e)}),To=x("ZodUUID",(t,e)=>{Z$.init(t,e),fe.init(t,e)}),yT=x("ZodURL",(t,e)=>{B$.init(t,e),fe.init(t,e)}),bT=x("ZodEmoji",(t,e)=>{j$.init(t,e),fe.init(t,e)}),wT=x("ZodNanoID",(t,e)=>{V$.init(t,e),fe.init(t,e)}),ST=x("ZodCUID",(t,e)=>{G$.init(t,e),fe.init(t,e)}),_T=x("ZodCUID2",(t,e)=>{W$.init(t,e),fe.init(t,e)}),kT=x("ZodULID",(t,e)=>{q$.init(t,e),fe.init(t,e)}),ET=x("ZodXID",(t,e)=>{Y$.init(t,e),fe.init(t,e)}),xT=x("ZodKSUID",(t,e)=>{K$.init(t,e),fe.init(t,e)}),$T=x("ZodIPv4",(t,e)=>{tA.init(t,e),fe.init(t,e)}),AT=x("ZodIPv6",(t,e)=>{nA.init(t,e),fe.init(t,e)}),TT=x("ZodCIDRv4",(t,e)=>{rA.init(t,e),fe.init(t,e)}),CT=x("ZodCIDRv6",(t,e)=>{iA.init(t,e),fe.init(t,e)}),IT=x("ZodBase64",(t,e)=>{sA.init(t,e),fe.init(t,e)}),PT=x("ZodBase64URL",(t,e)=>{aA.init(t,e),fe.init(t,e)}),RT=x("ZodE164",(t,e)=>{lA.init(t,e),fe.init(t,e)}),DT=x("ZodJWT",(t,e)=>{uA.init(t,e),fe.init(t,e)}),Im=x("ZodNumber",(t,e)=>{ym.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(r,i,s)=>I1(t,r,i),t.gt=(r,i)=>t.check(Cp(r,i)),t.gte=(r,i)=>t.check(Bl(r,i)),t.min=(r,i)=>t.check(Bl(r,i)),t.lt=(r,i)=>t.check(Tp(r,i)),t.lte=(r,i)=>t.check(Hl(r,i)),t.max=(r,i)=>t.check(Hl(r,i)),t.int=r=>t.check(Dp(r)),t.safe=r=>t.check(Dp(r)),t.positive=r=>t.check(Cp(0,r)),t.nonnegative=r=>t.check(Bl(0,r)),t.negative=r=>t.check(Tp(0,r)),t.nonpositive=r=>t.check(Hl(0,r)),t.multipleOf=(r,i)=>t.check(Ip(r,i)),t.step=(r,i)=>t.check(Ip(r,i)),t.finite=()=>t;const n=t._zod.bag;t.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,t.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,t.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),t.isFinite=!0,t.format=n.format??null});function F(t){return a1(Im,t)}const OT=x("ZodNumberFormat",(t,e)=>{hA.init(t,e),Im.init(t,e)});function Dp(t){return l1(OT,t)}const zT=x("ZodBoolean",(t,e)=>{dA.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(n,r,i)=>P1(t,n,r)});function Ee(t){return c1(zT,t)}const LT=x("ZodUnknown",(t,e)=>{pA.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(n,r,i)=>D1()});function w(){return u1(LT)}const MT=x("ZodNever",(t,e)=>{fA.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(n,r,i)=>R1(t,n,r)});function NT(t){return h1(MT,t)}const UT=x("ZodArray",(t,e)=>{gA.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(n,r,i)=>N1(t,n,r,i),t.element=e.element,t.min=(n,r)=>t.check(ha(n,r)),t.nonempty=n=>t.check(ha(1,n)),t.max=(n,r)=>t.check(_m(n,r)),t.length=(n,r)=>t.check(km(n,r)),t.unwrap=()=>t.element});function D(t,e){return k1(UT,t,e)}const Pm=x("ZodObject",(t,e)=>{vA.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(n,r,i)=>U1(t,n,r,i),Q(t,"shape",()=>e.shape),t.keyof=()=>pa(Object.keys(t._zod.def.shape)),t.catchall=n=>t.clone({...t._zod.def,catchall:n}),t.passthrough=()=>t.clone({...t._zod.def,catchall:w()}),t.loose=()=>t.clone({...t._zod.def,catchall:w()}),t.strict=()=>t.clone({...t._zod.def,catchall:NT()}),t.strip=()=>t.clone({...t._zod.def,catchall:void 0}),t.extend=n=>Nx(t,n),t.safeExtend=n=>Ux(t,n),t.merge=n=>Fx(t,n),t.pick=n=>Lx(t,n),t.omit=n=>Mx(t,n),t.partial=(...n)=>Zx(Dm,t,n[0]),t.required=(...n)=>Hx(Om,t,n[0])});function Rm(t,e){const n={type:"object",shape:t??{},...z(e)};return new Pm(n)}function f(t,e){return new Pm({type:"object",shape:t,catchall:w(),...z(e)})}const FT=x("ZodUnion",(t,e)=>{yA.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(n,r,i)=>F1(t,n,r,i),t.options=e.options});function B(t,e){return new FT({type:"union",options:t,...z(e)})}const ZT=x("ZodIntersection",(t,e)=>{bA.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(n,r,i)=>Z1(t,n,r,i)});function qa(t,e){return new ZT({type:"intersection",left:t,right:e})}const HT=x("ZodRecord",(t,e)=>{wA.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(n,r,i)=>H1(t,n,r,i),t.keyType=e.keyType,t.valueType=e.valueType});function _(t,e,n){return new HT({type:"record",keyType:t,valueType:e,...z(n)})}const xc=x("ZodEnum",(t,e)=>{SA.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(r,i,s)=>O1(t,r,i),t.enum=e.entries,t.options=Object.values(e.entries);const n=new Set(Object.keys(e.entries));t.extract=(r,i)=>{const s={};for(const o of r)if(n.has(o))s[o]=e.entries[o];else throw new Error(`Key ${o} not found in enum`);return new xc({...e,checks:[],...z(i),entries:s})},t.exclude=(r,i)=>{const s={...e.entries};for(const o of r)if(n.has(o))delete s[o];else throw new Error(`Key ${o} not found in enum`);return new xc({...e,checks:[],...z(i),entries:s})}});function pa(t,e){const n=Array.isArray(t)?Object.fromEntries(t.map(r=>[r,r])):t;return new xc({type:"enum",entries:n,...z(e)})}const BT=x("ZodLiteral",(t,e)=>{_A.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(n,r,i)=>z1(t,n,r),t.values=new Set(e.values),Object.defineProperty(t,"value",{get(){if(e.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return e.values[0]}})});function $(t,e){return new BT({type:"literal",values:Array.isArray(t)?t:[t],...z(e)})}const jT=x("ZodTransform",(t,e)=>{kA.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(n,r,i)=>M1(t,n),t._zod.parse=(n,r)=>{if(r.direction==="backward")throw new nm(t.constructor.name);n.addIssue=s=>{if(typeof s=="string")n.issues.push(is(s,n.value,e));else{const o=s;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=n.value),o.inst??(o.inst=t),n.issues.push(is(o))}};const i=e.transform(n.value,n);return i instanceof Promise?i.then(s=>(n.value=s,n)):(n.value=i,n)}});function VT(t){return new jT({type:"transform",transform:t})}const Dm=x("ZodOptional",(t,e)=>{Sm.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(n,r,i)=>Am(t,n,r,i),t.unwrap=()=>t._zod.def.innerType});function Op(t){return new Dm({type:"optional",innerType:t})}const GT=x("ZodExactOptional",(t,e)=>{EA.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(n,r,i)=>Am(t,n,r,i),t.unwrap=()=>t._zod.def.innerType});function WT(t){return new GT({type:"optional",innerType:t})}const qT=x("ZodNullable",(t,e)=>{xA.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(n,r,i)=>B1(t,n,r,i),t.unwrap=()=>t._zod.def.innerType});function zp(t){return new qT({type:"nullable",innerType:t})}const YT=x("ZodDefault",(t,e)=>{$A.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(n,r,i)=>V1(t,n,r,i),t.unwrap=()=>t._zod.def.innerType,t.removeDefault=t.unwrap});function KT(t,e){return new YT({type:"default",innerType:t,get defaultValue(){return typeof e=="function"?e():om(e)}})}const JT=x("ZodPrefault",(t,e)=>{AA.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(n,r,i)=>G1(t,n,r,i),t.unwrap=()=>t._zod.def.innerType});function XT(t,e){return new JT({type:"prefault",innerType:t,get defaultValue(){return typeof e=="function"?e():om(e)}})}const Om=x("ZodNonOptional",(t,e)=>{TA.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(n,r,i)=>j1(t,n,r,i),t.unwrap=()=>t._zod.def.innerType});function QT(t,e){return new Om({type:"nonoptional",innerType:t,...z(e)})}const eC=x("ZodCatch",(t,e)=>{CA.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(n,r,i)=>W1(t,n,r,i),t.unwrap=()=>t._zod.def.innerType,t.removeCatch=t.unwrap});function tC(t,e){return new eC({type:"catch",innerType:t,catchValue:typeof e=="function"?e:()=>e})}const nC=x("ZodPipe",(t,e)=>{IA.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(n,r,i)=>q1(t,n,r,i),t.in=e.in,t.out=e.out});function Lp(t,e){return new nC({type:"pipe",in:t,out:e})}const rC=x("ZodReadonly",(t,e)=>{PA.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(n,r,i)=>Y1(t,n,r,i),t.unwrap=()=>t._zod.def.innerType});function iC(t){return new rC({type:"readonly",innerType:t})}const sC=x("ZodCustom",(t,e)=>{RA.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(n,r,i)=>L1(t,n)});function oC(t,e={}){return E1(sC,t,e)}function aC(t){return x1(t)}const lC=["text/markdown","text/html"],cC=["committed","pending"];Rm({id:h().min(1),type:pa(lC),title:h(),status:pa(cC),externalFilePath:h().optional()});Rm({name:h().min(1),description:h(),accepts:D(h().min(1)).min(1)});function Wu(t){return typeof t=="object"&&t!==null}function uC(t){return!Wu(t)||t.type!=="ready"?!1:!("id"in t)}function hC(t){return!(!Wu(t)||t.type!=="update-content"||typeof t.id!="string"||typeof t.content!="string")}function dC(t){return!Wu(t)||t.type!=="wheel"||typeof t.deltaX!="number"||typeof t.deltaY!="number"||typeof t.shiftKey!="boolean"?!1:!("id"in t)}function pC(t,e){if(t===e)return 2;if(t==="*/*")return 0;const n=t.indexOf("/");if(n>0&&t.slice(n+1)==="*"){const r=t.slice(0,n),i=e.indexOf("/");if(i>0&&e.slice(0,i)===r)return 1}return null}function fC(t,e){let n=null;for(const r of t.accepts){const i=pC(r,e);i!==null&&(n===null||i>n)&&(n=i)}return n}function gC(t,e){let n=-1,r=null;for(const i of e){const s=fC(i,t);s!==null&&(s>n||s===n&&r!==null&&i.id<r.id)&&(n=s,r=i)}return r}const mC=4401;class $c extends Error{constructor(e="Authentication required"){super(e),this.name="AuthError"}}class Ac extends mt{constructor(n){super();b(this,"url");b(this,"name");b(this,"token");b(this,"status","disconnected");b(this,"screens",new Map);b(this,"views",[]);b(this,"client");b(this,"createSocket");b(this,"createClient");b(this,"socket",null);b(this,"connectAttempt",0);this.url=Et(n.url),this.name=n.name,this.token=n.token??null,this.createSocket=n.createSocket??(r=>new WebSocket(r)),this.createClient=n.createClient??((r,i)=>new bx(r,{token:i??void 0})),this.client=this.createClient(this.url,this.token)}async connect(){var i;this.connectAttempt+=1;const n=this.connectAttempt;(i=this.socket)==null||i.close(),this.client=this.createClient(this.url,this.token),this.status="connecting",this.dispatchEvent(new ee("change"));const r=this.createSocket(vC(this.url,this.token));return this.socket=r,await new Promise((s,o)=>{let a=!1;const c=()=>{a||this.connectAttempt!==n||(a=!0,this.status="connected",this.dispatchEvent(new ee("change")),s())},u=p=>{a||this.connectAttempt!==n||(a=!0,this.status="disconnected",this.dispatchEvent(new ee("change")),o(p))},d=async()=>{try{const[{screens:p},y]=await Promise.all([this.client.screens.list(),this.client.views.list()]);this.screens=new Map(p.map(v=>[v.id,structuredClone(v)])),this.views=y,this.dispatchEvent(new ee("change")),c()}catch(p){u(p instanceof Error?p:new Error(String(p)))}};r.addEventListener("open",()=>{d()}),r.addEventListener("message",p=>{const y=bC(p);y&&(this.applyServerEvent(y),this.dispatchEvent(new qg("server-event",{serverURL:this.url,event:y})))}),r.addEventListener("close",p=>{if(this.connectAttempt===n){if(this.socket=null,yC(p)===mC){u(new $c);return}if(!a){u(new Error("Connection closed before initialization"));return}this.status="disconnected",this.dispatchEvent(new ee("change"))}}),r.addEventListener("error",()=>{u(new Error("WebSocket connection failed"))})})}disconnect(){var n;this.connectAttempt+=1,(n=this.socket)==null||n.close(),this.socket=null,this.status="disconnected",this.dispatchEvent(new ee("change"))}getViewURL(n){const r=gC(n.type,this.views);if(!r)return null;const i=`${this.url}/views/${encodeURIComponent(r.id)}/`;return this.token===null?i:`${i}?token=${encodeURIComponent(this.token)}`}getContentURL(n){const r=`${this.url}/artifacts/${encodeURIComponent(n)}/content`;return this.token===null?r:`${r}?token=${encodeURIComponent(this.token)}`}async createScreen(n){const{screen:r}=await this.client.screens.create({name:n});return this.screens.set(r.id,structuredClone(r)),r}applyServerEvent(n){switch(n.type){case"screen-created":this.screens.set(n.screen.id,structuredClone(n.screen)),this.dispatchEvent(new Go("screens-changed"));break;case"screen-updated":this.screens.set(n.screen.id,structuredClone(n.screen)),this.dispatchEvent(new Go("screens-changed"));break;case"screen-removed":this.screens.delete(n.screenID),this.dispatchEvent(new Go("screens-changed"));break;case"artifact-created":break;case"artifact-attached":{const r=this.screens.get(n.screenID);r&&!Vg(r.layout,n.artifact.id)&&(r.layout=[...r.layout,jg(n.artifact.id,{id:n.cardID})]);break}case"artifact-removed":{const r=this.screens.get(n.screenID);r&&(r.layout=zg(r.layout,n.artifactID));break}}}}function vC(t,e){const n=new URL(t);return n.protocol=n.protocol==="https:"?"wss:":"ws:",n.pathname="/events",n.search="",e&&n.searchParams.set("token",e),n.hash="",n.toString()}function yC(t){return typeof t=="object"&&t!==null&&"code"in t&&typeof t.code=="number"?t.code:null}function bC(t){const e=typeof t=="string"?t:typeof t=="object"&&t!==null&&"data"in t&&typeof t.data=="string"?t.data:"";if(!e)return null;try{return JSON.parse(e)}catch{return null}}class wC extends mt{constructor(n){super();b(this,"servers",new Map);b(this,"localServerURL");b(this,"localStore");b(this,"createSocket");b(this,"lastActiveServerURL");b(this,"serverListeners",new Map);b(this,"handleLocalStoreChange",()=>{const n=this.localStore.get().activeServerURL;n!==this.lastActiveServerURL&&(this.lastActiveServerURL=n,this.dispatchEvent(new ee("change")))});this.localStore=n.localStore,this.localServerURL=n.localServerURL?Et(n.localServerURL):null,this.createSocket=n.createSocket??(r=>new WebSocket(r)),this.lastActiveServerURL=this.localStore.get().activeServerURL,this.localStore.addEventListener("change",this.handleLocalStoreChange)}get activeServer(){const n=this.localStore.get().activeServerURL;return n===null?null:this.servers.get(n)??null}add(n){const r=Et(n.url);this.servers.get(r)&&this.remove(r),this.servers.set(r,n);const s=()=>{this.dispatchEvent(new ee("change"))},o=c=>{this.dispatchEvent(new qg("server-event",{serverURL:c.serverURL,event:c.event}))},a=()=>{this.dispatchEvent(new Go("screens-changed"))};n.addEventListener("change",s),n.addEventListener("server-event",o),n.addEventListener("screens-changed",a),this.serverListeners.set(r,{onServerChange:s,onServerEvent:o,onScreensChanged:a}),this.dispatchEvent(new ee("change"))}remove(n){const r=Et(n);if(this.localServerURL&&r===this.localServerURL)return;const i=this.servers.get(r);if(!i)return;const s=this.serverListeners.get(r);s&&(i.removeEventListener("change",s.onServerChange),i.removeEventListener("server-event",s.onServerEvent),i.removeEventListener("screens-changed",s.onScreensChanged),this.serverListeners.delete(r)),i.disconnect(),this.servers.delete(r);const o=this.localStore.get(),a=o.activeServerURL===r;this.localStore.set({...o,servers:o.servers.filter(c=>c.url!==r),activeServerURL:a?null:o.activeServerURL}),this.dispatchEvent(new ee("change"))}setActive(n){const r=this.localStore.get(),i=n?Et(n.url):null;r.activeServerURL!==i&&this.localStore.set({...r,activeServerURL:i})}connectConfiguredServers(n,r){const i=this.localStore.get().servers,s=n?Et(n):null;for(const a of i){const c=Et(a.url),u=s!==null&&c===s,d=new Ac({url:a.url,name:a.name,token:u?r??null:null,createSocket:this.createSocket});this.add(d),d.connect().catch(()=>{})}const o=s?this.servers.get(s)??null:null;this.setActive(o??this.servers.values().next().value??null)}addServer(n,r){const i=Et(n);this.remove(i);const s=this.localStore.get();this.localStore.set({...s,servers:[...s.servers.filter(a=>Et(a.url)!==i),{url:i,name:r}]});const o=new Ac({url:i,name:r,createSocket:this.createSocket});this.add(o),this.setActive(o),o.connect().catch(()=>{})}removeServer(n){this.remove(n)}}const oe={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"},Lt={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"},SC=1,_C=f({_meta:_(h(),w()).nullish(),terminal:Ee().optional().default(!1)}),kC=f({_meta:_(h(),w()).nullish(),label:h().nullish(),name:h(),optional:Ee().optional().default(!1),secret:Ee().optional().default(!0)}),EC=f({_meta:_(h(),w()).nullish(),description:h().nullish(),id:h(),name:h()}),xC=f({_meta:_(h(),w()).nullish(),description:h().nullish(),id:h(),link:h().nullish(),name:h(),vars:D(kC)}),$C=f({_meta:_(h(),w()).nullish(),args:D(h()).optional(),description:h().nullish(),env:_(h(),h()).optional(),id:h(),name:h()}),AC=B([xC.and(f({type:$("env_var")})),$C.and(f({type:$("terminal")})),EC]),TC=f({_meta:_(h(),w()).nullish(),methodId:h()}),CC=f({_meta:_(h(),w()).nullish()}),IC=f({_meta:_(h(),w()).nullish(),blob:h(),mimeType:h().nullish(),uri:h()}),PC=f({default:Ee().nullish(),description:h().nullish(),title:h().nullish()}),RC=f({_meta:_(h(),w()).nullish()}),DC=f({_meta:_(h(),w()).nullish()}),OC=f({amount:F(),currency:h()}),zC=f({_meta:_(h(),w()).nullish(),terminalId:h()}),LC=f({_meta:_(h(),w()).nullish(),newText:h(),oldText:h().nullish(),path:h()}),MC=B([h(),F(),F(),Ee(),D(h())]),NC=f({content:_(h(),MC).nullish()}),UC=B([NC.and(f({action:$("accept")})),f({action:$("decline")}),f({action:$("cancel")})]),FC=f({_meta:_(h(),w()).nullish()}),zm=h(),ZC=f({_meta:_(h(),w()).nullish(),elicitationId:zm}),HC=f({_meta:_(h(),w()).nullish(),action:UC}),BC=$("object"),jC=$("string"),VC=f({_meta:_(h(),w()).nullish()}),GC=f({_meta:_(h(),w()).nullish(),form:FC.nullish(),url:VC.nullish()}),WC=f({elicitationId:zm,url:h().url()}),Lm=f({const:h(),title:h()}),Mm=f({_meta:_(h(),w()).nullish(),name:h(),value:h()}),qC=B([$(-32700),$(-32600),$(-32601),$(-32602),$(-32603),$(-32800),$(-32e3),$(-32002),$(-32042),F().int().min(-2147483648,{message:"Invalid value: Expected int32 to be >= -2147483648"}).max(2147483647,{message:"Invalid value: Expected int32 to be <= 2147483647"})]),Nm=f({code:qC,data:w().optional(),message:h()}),Um=w(),Fm=w(),Zm=w(),YC=f({_meta:_(h(),w()).nullish(),readTextFile:Ee().optional().default(!1),writeTextFile:Ee().optional().default(!1)}),Hm=f({_meta:_(h(),w()).nullish(),name:h(),value:h()}),Bm=f({_meta:_(h(),w()).nullish(),name:h(),title:h().nullish(),version:h()}),KC=f({default:F().nullish(),description:h().nullish(),maximum:F().nullish(),minimum:F().nullish(),title:h().nullish()}),JC=f({_meta:_(h(),w()).nullish()}),XC=f({_meta:_(h(),w()).nullish(),additionalDirectories:D(h()).optional(),cursor:h().nullish(),cwd:h().nullish()}),QC=f({_meta:_(h(),w()).nullish()}),eI=f({_meta:_(h(),w()).nullish(),logout:QC.nullish()}),tI=f({_meta:_(h(),w()).nullish()}),nI=f({_meta:_(h(),w()).nullish()}),rI=f({_meta:_(h(),w()).nullish(),http:Ee().optional().default(!1),sse:Ee().optional().default(!1)}),iI=f({_meta:_(h(),w()).nullish(),headers:D(Hm),name:h(),url:h()}),sI=f({_meta:_(h(),w()).nullish(),headers:D(Hm),name:h(),url:h()}),oI=f({_meta:_(h(),w()).nullish(),args:D(h()),command:h(),env:D(Mm),name:h()}),Ya=B([iI.and(f({type:$("http")})),sI.and(f({type:$("sse")})),oI]),qu=h(),aI=f({_meta:_(h(),w()).nullish(),description:h().nullish(),modelId:qu,name:h()}),lI=B([$("error"),$("warning"),$("information"),$("hint")]),cI=f({_meta:_(h(),w()).nullish()}),uI=f({_meta:_(h(),w()).nullish()}),hI=f({_meta:_(h(),w()).nullish()}),dI=f({_meta:_(h(),w()).nullish()}),pI=f({_meta:_(h(),w()).nullish()}),fI=f({_meta:_(h(),w()).nullish(),maxCount:F().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),gI=f({diff:h(),uri:h()}),mI=f({endLine:F().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),startLine:F().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),text:h()}),vI=f({_meta:_(h(),w()).nullish()}),yI=f({_meta:_(h(),w()).nullish()}),bI=f({languageId:h(),text:h(),uri:h()}),wI=f({_meta:_(h(),w()).nullish(),maxCount:F().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),SI=B([$("rejected"),$("ignored"),$("replaced"),$("cancelled")]),_I=f({excerpts:D(mI),uri:h()}),kI=f({_meta:_(h(),w()).nullish()}),EI=f({_meta:_(h(),w()).nullish()}),xI=f({name:h(),owner:h(),remoteUrl:h()}),$I=f({_meta:_(h(),w()).nullish()}),AI=f({_meta:_(h(),w()).nullish(),jump:vI.nullish(),rename:EI.nullish(),searchAndReplace:$I.nullish()}),TI=f({id:h(),isRegex:Ee().nullish(),replace:h(),search:h(),uri:h()}),CI=B([$("automatic"),$("diagnostic"),$("manual")]),II=f({_meta:_(h(),w()).nullish(),maxCount:F().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),PI=f({_meta:_(h(),w()).nullish(),diagnostics:cI.nullish(),editHistory:fI.nullish(),openFiles:yI.nullish(),recentFiles:wI.nullish(),relatedSnippets:kI.nullish(),userActions:II.nullish()}),RI=f({_meta:_(h(),w()).nullish(),additionalDirectories:D(h()).optional(),cwd:h(),mcpServers:D(Ya)}),DI=f({default:F().nullish(),description:h().nullish(),maximum:F().nullish(),minimum:F().nullish(),title:h().nullish()}),jm=h(),OI=B([$("allow_once"),$("allow_always"),$("reject_once"),$("reject_always")]),zI=f({_meta:_(h(),w()).nullish(),kind:OI,name:h(),optionId:jm}),LI=B([$("high"),$("medium"),$("low")]),MI=B([$("pending"),$("in_progress"),$("completed")]),NI=f({_meta:_(h(),w()).nullish(),content:h(),priority:LI,status:MI}),UI=f({_meta:_(h(),w()).nullish(),entries:D(NI)}),vn=f({character:F().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),line:F().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"})}),FI=f({id:h(),position:vn,uri:h()}),ZI=f({id:h(),newName:h(),position:vn,uri:h()}),HI=f({action:h(),position:vn,timestampMs:F(),uri:h()}),Vm=B([$("utf-16"),$("utf-32"),$("utf-8")]),BI=f({_meta:_(h(),w()).nullish(),auth:_C.optional().default({terminal:!1}),elicitation:GC.nullish(),fs:YC.optional().default({readTextFile:!1,writeTextFile:!1}),nes:AI.nullish(),positionEncodings:D(Vm).optional(),terminal:Ee().optional().default(!1)}),jI=f({_meta:_(h(),w()).nullish(),audio:Ee().optional().default(!1),embeddedContext:Ee().optional().default(!1),image:Ee().optional().default(!1)}),Gm=F().int().gte(0).lte(65535),VI=f({_meta:_(h(),w()).nullish(),clientCapabilities:BI.optional().default({auth:{terminal:!1},fs:{readTextFile:!1,writeTextFile:!1},terminal:!1}),clientInfo:Bm.nullish(),protocolVersion:Gm}),_i=f({end:vn,start:vn}),GI=f({message:h(),range:_i,severity:lI,uri:h()}),WI=f({languageId:h(),lastFocusedMs:F().nullish(),uri:h(),visibleRange:_i.nullish()}),qI=f({_meta:_(h(),w()).nullish(),diagnostics:D(GI).nullish(),editHistory:D(gI).nullish(),openFiles:D(WI).nullish(),recentFiles:D(bI).nullish(),relatedSnippets:D(_I).nullish(),userActions:D(HI).nullish()}),YI=f({newText:h(),range:_i}),KI=f({cursorPosition:vn.nullish(),edits:D(YI),id:h(),uri:h()}),JI=B([KI.and(f({kind:$("edit")})),FI.and(f({kind:$("jump")})),ZI.and(f({kind:$("rename")})),TI.and(f({kind:$("searchAndReplace")}))]),XI=f({_meta:_(h(),w()).nullish(),content:h()}),QI=f({_meta:_(h(),w()).nullish()}),ur=B([F(),h()]).nullable();f({_meta:_(h(),w()).nullish(),requestId:ur});const eP=pa(["assistant","user"]),so=f({_meta:_(h(),w()).nullish(),audience:D(eP).nullish(),lastModified:h().nullish(),priority:F().nullish()}),tP=f({_meta:_(h(),w()).nullish(),annotations:so.nullish(),data:h(),mimeType:h()}),nP=f({_meta:_(h(),w()).nullish(),annotations:so.nullish(),data:h(),mimeType:h(),uri:h().nullish()}),rP=f({_meta:_(h(),w()).nullish(),annotations:so.nullish(),description:h().nullish(),mimeType:h().nullish(),name:h(),size:F().nullish(),title:h().nullish(),uri:h()}),iP=f({_meta:_(h(),w()).nullish(),optionId:jm}),sP=B([f({outcome:$("cancelled")}),iP.and(f({outcome:$("selected")}))]),oP=f({_meta:_(h(),w()).nullish(),outcome:sP}),aP=f({_meta:_(h(),w()).nullish()}),lP=f({_meta:_(h(),w()).nullish()}),cP=f({currentValue:Ee()}),uP=h(),Wm=h(),hP=B([$("mode"),$("model"),$("thought_level"),h()]),Yu=h(),qm=f({_meta:_(h(),w()).nullish(),description:h().nullish(),name:h(),value:Yu}),dP=f({_meta:_(h(),w()).nullish(),group:uP,name:h(),options:D(qm)}),pP=B([D(qm),D(dP)]),fP=f({currentValue:Yu,options:pP}),ki=qa(B([fP.and(f({type:$("select")})),cP.and(f({type:$("boolean")}))]),f({_meta:_(h(),w()).nullish(),category:hP.nullish(),description:h().nullish(),id:Wm,name:h()})),gP=f({_meta:_(h(),w()).nullish(),configOptions:D(ki)}),mP=f({_meta:_(h(),w()).nullish()}),K=h(),vP=f({_meta:_(h(),w()).nullish(),id:h(),sessionId:K}),yP=f({_meta:_(h(),w()).nullish(),sessionId:K}),bP=f({_meta:_(h(),w()).nullish(),sessionId:K}),wP=f({_meta:_(h(),w()).nullish(),sessionId:K}),Ym=f({_meta:_(h(),w()).nullish(),args:D(h()).optional(),command:h(),cwd:h().nullish(),env:D(Mm).optional(),outputByteLimit:F().nullish(),sessionId:K}),SP=f({_meta:_(h(),w()).nullish(),sessionId:K,uri:h()}),_P=f({_meta:_(h(),w()).nullish(),position:vn,sessionId:K,uri:h(),version:F(),visibleRange:_i}),kP=f({_meta:_(h(),w()).nullish(),languageId:h(),sessionId:K,text:h(),uri:h(),version:F()}),EP=f({_meta:_(h(),w()).nullish(),sessionId:K,uri:h()}),xP=f({_meta:_(h(),w()).nullish(),additionalDirectories:D(h()).optional(),cwd:h(),mcpServers:D(Ya).optional(),sessionId:K}),Km=f({_meta:_(h(),w()).nullish(),sessionId:K,terminalId:h()}),$P=f({_meta:_(h(),w()).nullish(),additionalDirectories:D(h()).optional(),cwd:h(),mcpServers:D(Ya),sessionId:K}),Jm=f({_meta:_(h(),w()).nullish(),limit:F().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),line:F().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:h(),sessionId:K}),AP=f({_meta:_(h(),w()).nullish(),id:h(),reason:SI.nullish(),sessionId:K}),Xm=f({_meta:_(h(),w()).nullish(),sessionId:K,terminalId:h()}),TP=f({_meta:_(h(),w()).nullish(),additionalDirectories:D(h()).optional(),cwd:h(),mcpServers:D(Ya).optional(),sessionId:K}),CP=f({_meta:_(h(),w()).nullish(),additionalDirectories:D(h()).optional(),cwd:h(),sessionId:K,title:h().nullish(),updatedAt:h().nullish()}),IP=f({_meta:_(h(),w()).nullish(),nextCursor:h().nullish(),sessions:D(CP)}),PP=f({_meta:_(h(),w()).nullish(),title:h().nullish(),updatedAt:h().nullish()}),RP=f({_meta:_(h(),w()).nullish()}),Ka=h(),DP=f({_meta:_(h(),w()).nullish(),currentModeId:Ka}),OP=f({_meta:_(h(),w()).nullish(),description:h().nullish(),id:Ka,name:h()}),Ja=f({_meta:_(h(),w()).nullish(),availableModes:D(OP),currentModeId:Ka}),Xa=f({_meta:_(h(),w()).nullish(),availableModels:D(aI),currentModelId:qu}),zP=f({_meta:_(h(),w()).nullish(),configOptions:D(ki).nullish(),models:Xa.nullish(),modes:Ja.nullish(),sessionId:K}),LP=f({_meta:_(h(),w()).nullish(),configOptions:D(ki).nullish(),models:Xa.nullish(),modes:Ja.nullish()}),MP=f({_meta:_(h(),w()).nullish(),configOptions:D(ki).nullish(),models:Xa.nullish(),modes:Ja.nullish(),sessionId:K}),NP=f({_meta:_(h(),w()).nullish(),configOptions:D(ki).nullish(),models:Xa.nullish(),modes:Ja.nullish()}),UP=f({_meta:_(h(),w()).nullish()}),FP=f({_meta:_(h(),w()).nullish(),additionalDirectories:aP.nullish(),close:lP.nullish(),fork:mP.nullish(),list:RP.nullish(),resume:UP.nullish()}),ZP=qa(B([f({type:$("boolean"),value:Ee()}),f({value:Yu})]),f({_meta:_(h(),w()).nullish(),configId:Wm,sessionId:K})),HP=f({_meta:_(h(),w()).nullish(),configOptions:D(ki)}),BP=f({_meta:_(h(),w()).nullish(),modeId:Ka,sessionId:K}),jP=f({_meta:_(h(),w()).nullish()}),VP=f({_meta:_(h(),w()).nullish(),modelId:qu,sessionId:K}),GP=f({_meta:_(h(),w()).nullish()}),WP=f({_meta:_(h(),w()).nullish(),sessionId:K}),qP=B([$("end_turn"),$("max_tokens"),$("max_turn_requests"),$("refusal"),$("cancelled")]),YP=B([$("email"),$("uri"),$("date"),$("date-time")]),KP=f({default:h().nullish(),description:h().nullish(),enum:D(h()).nullish(),format:YP.nullish(),maxLength:F().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),minLength:F().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),oneOf:D(Lm).nullish(),pattern:h().nullish(),title:h().nullish()}),JP=f({_meta:_(h(),w()).nullish(),context:qI.nullish(),position:vn,selection:_i.nullish(),sessionId:K,triggerKind:CI,uri:h(),version:F()}),XP=f({_meta:_(h(),w()).nullish(),suggestions:D(JI)}),QP=f({_meta:_(h(),w()).nullish(),terminalId:h()}),eR=f({_meta:_(h(),w()).nullish(),exitCode:F().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:h().nullish()}),Qm=f({_meta:_(h(),w()).nullish(),sessionId:K,terminalId:h()}),tR=f({_meta:_(h(),w()).nullish(),exitStatus:eR.nullish(),output:h(),truncated:Ee()}),nR=f({_meta:_(h(),w()).nullish(),annotations:so.nullish(),text:h()}),rR=f({range:_i.nullish(),text:h()}),iR=f({_meta:_(h(),w()).nullish(),contentChanges:D(rR),sessionId:K,uri:h(),version:F()});f({method:h(),params:B([yP,kP,iR,SP,EP,_P,vP,AP,Um]).nullish()});const sR=B([$("full"),$("incremental")]),oR=f({_meta:_(h(),w()).nullish(),syncKind:sR}),aR=f({_meta:_(h(),w()).nullish(),didChange:oR.nullish(),didClose:uI.nullish(),didFocus:hI.nullish(),didOpen:dI.nullish(),didSave:pI.nullish()}),lR=f({_meta:_(h(),w()).nullish(),document:aR.nullish()}),cR=f({_meta:_(h(),w()).nullish(),context:PI.nullish(),events:lR.nullish()}),uR=f({_meta:_(h(),w()).nullish(),auth:eI.optional().default({}),loadSession:Ee().optional().default(!1),mcpCapabilities:rI.optional().default({http:!1,sse:!1}),nes:cR.nullish(),positionEncoding:Vm.nullish(),promptCapabilities:jI.optional().default({audio:!1,embeddedContext:!1,image:!1}),sessionCapabilities:FP.optional().default({})}),hR=f({_meta:_(h(),w()).nullish(),agentCapabilities:uR.optional().default({auth:{},loadSession:!1,mcpCapabilities:{http:!1,sse:!1},promptCapabilities:{audio:!1,embeddedContext:!1,image:!1},sessionCapabilities:{}}),agentInfo:Bm.nullish(),authMethods:D(AC).optional().default([]),protocolVersion:Gm}),dR=f({_meta:_(h(),w()).nullish(),mimeType:h().nullish(),text:h(),uri:h()}),pR=B([dR,IC]),fR=f({_meta:_(h(),w()).nullish(),annotations:so.nullish(),resource:pR}),Ku=B([nR.and(f({type:$("text")})),nP.and(f({type:$("image")})),tP.and(f({type:$("audio")})),rP.and(f({type:$("resource_link")})),fR.and(f({type:$("resource")}))]),gR=f({_meta:_(h(),w()).nullish(),content:Ku}),jl=f({_meta:_(h(),w()).nullish(),content:Ku,messageId:h().nullish()}),mR=f({_meta:_(h(),w()).nullish(),messageId:h().nullish(),prompt:D(Ku),sessionId:K}),vR=f({anyOf:D(Lm)}),ev=B([gR.and(f({type:$("content")})),LC.and(f({type:$("diff")})),QP.and(f({type:$("terminal")}))]),tv=h(),nv=f({_meta:_(h(),w()).nullish(),line:F().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:h()}),rv=B([$("pending"),$("in_progress"),$("completed"),$("failed")]),iv=B([$("read"),$("edit"),$("delete"),$("move"),$("search"),$("execute"),$("think"),$("fetch"),$("switch_mode"),$("other")]),yR=f({_meta:_(h(),w()).nullish(),content:D(ev).optional(),kind:iv.optional(),locations:D(nv).optional(),rawInput:w().optional(),rawOutput:w().optional(),status:rv.optional(),title:h(),toolCallId:tv}),sv=f({_meta:_(h(),w()).nullish(),content:D(ev).nullish(),kind:iv.nullish(),locations:D(nv).nullish(),rawInput:w().optional(),rawOutput:w().optional(),status:rv.nullish(),title:h().nullish(),toolCallId:tv}),ov=f({_meta:_(h(),w()).nullish(),options:D(zI),sessionId:K,toolCall:sv}),bR=f({_meta:_(h(),w()).nullish(),hint:h()}),wR=bR,SR=f({_meta:_(h(),w()).nullish(),description:h(),input:wR.nullish(),name:h()}),_R=f({_meta:_(h(),w()).nullish(),availableCommands:D(SR)}),kR=f({enum:D(h()),type:jC}),ER=B([kR,vR]),xR=f({default:D(h()).nullish(),description:h().nullish(),items:ER,maxItems:F().nullish(),minItems:F().nullish(),title:h().nullish()}),$R=B([KP.and(f({type:$("string")})),DI.and(f({type:$("number")})),KC.and(f({type:$("integer")})),PC.and(f({type:$("boolean")})),xR.and(f({type:$("array")}))]),AR=f({description:h().nullish(),properties:_(h(),$R).optional().default({}),required:D(h()).nullish(),title:h().nullish(),type:BC.optional().default("object")}),TR=f({requestedSchema:AR}),CR=qa(B([TR.and(f({mode:$("form")})),WC.and(f({mode:$("url")}))]),f({_meta:_(h(),w()).nullish(),message:h(),sessionId:K})),IR=f({cachedReadTokens:F().nullish(),cachedWriteTokens:F().nullish(),inputTokens:F(),outputTokens:F(),thoughtTokens:F().nullish(),totalTokens:F()}),PR=f({_meta:_(h(),w()).nullish(),stopReason:qP,usage:IR.nullish(),userMessageId:h().nullish()});B([f({id:ur,result:B([hR,CC,nI,MP,LP,IP,zP,NP,DC,jP,HP,PR,GP,WP,XP,RC,Zm])}),f({error:Nm,id:ur})]);const RR=f({_meta:_(h(),w()).nullish(),cost:OC.nullish(),size:F(),used:F()}),DR=B([jl.and(f({sessionUpdate:$("user_message_chunk")})),jl.and(f({sessionUpdate:$("agent_message_chunk")})),jl.and(f({sessionUpdate:$("agent_thought_chunk")})),yR.and(f({sessionUpdate:$("tool_call")})),sv.and(f({sessionUpdate:$("tool_call_update")})),UI.and(f({sessionUpdate:$("plan")})),_R.and(f({sessionUpdate:$("available_commands_update")})),DP.and(f({sessionUpdate:$("current_mode_update")})),gP.and(f({sessionUpdate:$("config_option_update")})),PP.and(f({sessionUpdate:$("session_info_update")})),RR.and(f({sessionUpdate:$("usage_update")}))]),av=f({_meta:_(h(),w()).nullish(),sessionId:K,update:DR});f({method:h(),params:B([av,ZC,Um]).nullish()});const lv=f({_meta:_(h(),w()).nullish(),sessionId:K,terminalId:h()}),OR=f({_meta:_(h(),w()).nullish(),exitCode:F().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:h().nullish()}),zR=f({name:h(),uri:h()}),LR=f({_meta:_(h(),w()).nullish(),repository:xI.nullish(),workspaceFolders:D(zR).nullish(),workspaceUri:h().nullish()});f({id:ur,method:h(),params:B([VI,TC,tI,RI,$P,XC,xP,TP,wP,BP,ZP,mR,VP,LR,JP,bP,Fm]).nullish()});const cv=f({_meta:_(h(),w()).nullish(),content:h(),path:h(),sessionId:K});f({id:ur,method:h(),params:B([cv,Jm,ov,Ym,Qm,Xm,lv,Km,CR,Fm]).nullish()});const MR=f({_meta:_(h(),w()).nullish()});B([f({id:ur,result:B([MR,XI,oP,zC,tR,QI,OR,JC,HC,Zm])}),f({error:Nm,id:ur})]);var Y;class NR{constructor(e,n){S(this,Y);const r=e(this),i=async(o,a)=>{var c,u,d,p,y,v,A;switch(o){case Lt.fs_write_text_file:{const E=cv.parse(a);return(c=r.writeTextFile)==null?void 0:c.call(r,E)}case Lt.fs_read_text_file:{const E=Jm.parse(a);return(u=r.readTextFile)==null?void 0:u.call(r,E)}case Lt.session_request_permission:{const E=ov.parse(a);return r.requestPermission(E)}case Lt.terminal_create:{const E=Ym.parse(a);return(d=r.createTerminal)==null?void 0:d.call(r,E)}case Lt.terminal_output:{const E=Qm.parse(a);return(p=r.terminalOutput)==null?void 0:p.call(r,E)}case Lt.terminal_release:{const E=Xm.parse(a);return await((y=r.releaseTerminal)==null?void 0:y.call(r,E))??{}}case Lt.terminal_wait_for_exit:{const E=lv.parse(a);return(v=r.waitForTerminalExit)==null?void 0:v.call(r,E)}case Lt.terminal_kill:{const E=Km.parse(a);return await((A=r.killTerminal)==null?void 0:A.call(r,E))??{}}default:if(r.extMethod)return r.extMethod(o,a);throw we.methodNotFound(o)}},s=async(o,a)=>{switch(o){case Lt.session_update:{const c=av.parse(a);return r.sessionUpdate(c)}default:if(r.extNotification)return r.extNotification(o,a);throw we.methodNotFound(o)}};k(this,Y,new UR(i,s,n))}async initialize(e){return await l(this,Y).sendRequest(oe.initialize,e)}async newSession(e){return await l(this,Y).sendRequest(oe.session_new,e)}async loadSession(e){return await l(this,Y).sendRequest(oe.session_load,e)??{}}async unstable_forkSession(e){return await l(this,Y).sendRequest(oe.session_fork,e)}async listSessions(e){return await l(this,Y).sendRequest(oe.session_list,e)}async unstable_resumeSession(e){return await l(this,Y).sendRequest(oe.session_resume,e)}async unstable_closeSession(e){return await l(this,Y).sendRequest(oe.session_close,e)}async setSessionMode(e){return await l(this,Y).sendRequest(oe.session_set_mode,e)??{}}async unstable_setSessionModel(e){return await l(this,Y).sendRequest(oe.session_set_model,e)??{}}async setSessionConfigOption(e){return await l(this,Y).sendRequest(oe.session_set_config_option,e)}async authenticate(e){return await l(this,Y).sendRequest(oe.authenticate,e)??{}}async unstable_logout(e){return await l(this,Y).sendRequest(oe.logout,e)??{}}async prompt(e){return await l(this,Y).sendRequest(oe.session_prompt,e)}async cancel(e){return await l(this,Y).sendNotification(oe.session_cancel,e)}async unstable_startNes(e){return await l(this,Y).sendRequest(oe.nes_start,e)}async unstable_suggestNes(e){return await l(this,Y).sendRequest(oe.nes_suggest,e)}async unstable_closeNes(e){return await l(this,Y).sendRequest(oe.nes_close,e)??{}}async unstable_didOpenDocument(e){return await l(this,Y).sendNotification(oe.document_did_open,e)}async unstable_didChangeDocument(e){return await l(this,Y).sendNotification(oe.document_did_change,e)}async unstable_didCloseDocument(e){return await l(this,Y).sendNotification(oe.document_did_close,e)}async unstable_didSaveDocument(e){return await l(this,Y).sendNotification(oe.document_did_save,e)}async unstable_didFocusDocument(e){return await l(this,Y).sendNotification(oe.document_did_focus,e)}async unstable_acceptNes(e){return await l(this,Y).sendNotification(oe.nes_accept,e)}async unstable_rejectNes(e){return await l(this,Y).sendNotification(oe.nes_reject,e)}async extMethod(e,n){return await l(this,Y).sendRequest(e,n)}async extNotification(e,n){return await l(this,Y).sendNotification(e,n)}get signal(){return l(this,Y).signal}get closed(){return l(this,Y).closed}}Y=new WeakMap;var on,Sa,fs,gs,Br,jr,At,ms,he,uv,Tc,hv,dv,pv,fv,Cc,ji;class UR{constructor(e,n,r){S(this,he);S(this,on,new Map);S(this,Sa,0);S(this,fs);S(this,gs);S(this,Br);S(this,jr,Promise.resolve());S(this,At,new AbortController);S(this,ms);k(this,fs,e),k(this,gs,n),k(this,Br,r),k(this,ms,new Promise(i=>{l(this,At).signal.addEventListener("abort",()=>i())})),g(this,he,uv).call(this)}get signal(){return l(this,At).signal}get closed(){return l(this,ms)}async sendRequest(e,n){g(this,he,Cc).call(this);const r=Fh(this,Sa)._++,i=new Promise((s,o)=>{l(this,on).set(r,{resolve:s,reject:o})});return await g(this,he,ji).call(this,{jsonrpc:"2.0",id:r,method:e,params:n}),i}async sendNotification(e,n){g(this,he,Cc).call(this),await g(this,he,ji).call(this,{jsonrpc:"2.0",method:e,params:n})}}on=new WeakMap,Sa=new WeakMap,fs=new WeakMap,gs=new WeakMap,Br=new WeakMap,jr=new WeakMap,At=new WeakMap,ms=new WeakMap,he=new WeakSet,uv=async function(){let e;try{const n=l(this,Br).readable.getReader();try{for(;!l(this,At).signal.aborted;){const{value:r,done:i}=await n.read();if(i)break;if(r)try{g(this,he,hv).call(this,r)}catch(s){console.error("Unexpected error during message processing:",r,s),"id"in r&&r.id!==void 0&&g(this,he,ji).call(this,{jsonrpc:"2.0",id:r.id,error:{code:-32700,message:"Parse error"}})}}}finally{n.releaseLock()}}catch(n){e=n}finally{g(this,he,Tc).call(this,e)}},Tc=function(e){if(l(this,At).signal.aborted)return;const n=e??new Error("ACP connection closed");for(const r of l(this,on).values())r.reject(n);l(this,on).clear(),l(this,At).abort(n)},hv=async function(e){if("method"in e&&"id"in e){const n=await g(this,he,dv).call(this,e.method,e.params);"error"in n&&console.error("Error handling request",e,n.error),await g(this,he,ji).call(this,{jsonrpc:"2.0",id:e.id,...n})}else if("method"in e){const n=await g(this,he,pv).call(this,e.method,e.params);"error"in n&&console.error("Error handling notification",e,n.error)}else"id"in e?g(this,he,fv).call(this,e):console.error("Invalid message",{message:e})},dv=async function(e,n){try{return{result:await l(this,fs).call(this,e,n)??null}}catch(r){if(r instanceof we)return r.toResult();if(r instanceof Pp)return we.invalidParams(r.format()).toResult();let i;(r instanceof Error||typeof r=="object"&&r!=null&&"message"in r&&typeof r.message=="string")&&(i=r.message);try{return we.internalError(i?JSON.parse(i):{}).toResult()}catch{return we.internalError({details:i}).toResult()}}},pv=async function(e,n){try{return await l(this,gs).call(this,e,n),{result:null}}catch(r){if(r instanceof we)return r.toResult();if(r instanceof Pp)return we.invalidParams(r.format()).toResult();let i;(r instanceof Error||typeof r=="object"&&r!=null&&"message"in r&&typeof r.message=="string")&&(i=r.message);try{return we.internalError(i?JSON.parse(i):{}).toResult()}catch{return we.internalError({details:i}).toResult()}}},fv=function(e){const n=l(this,on).get(e.id);if(n){if("result"in e)n.resolve(e.result);else if("error"in e){const{code:r,message:i,data:s}=e.error;n.reject(new we(r,i,s))}l(this,on).delete(e.id)}else console.error("Got response to unknown request",e.id)},Cc=function(){if(l(this,At).signal.aborted)throw l(this,At).signal.reason??new Error("ACP connection closed")},ji=async function(e){return k(this,jr,l(this,jr).then(async()=>{const n=l(this,Br).writable.getWriter();try{await n.write(e)}finally{n.releaseLock()}}).catch(n=>{g(this,he,Tc).call(this,n)})),l(this,jr)};class we extends Error{constructor(n,r,i){super(r);b(this,"code");b(this,"data");this.code=n,this.name="RequestError",this.data=i}static parseError(n,r){return new we(-32700,`Parse error${r?`: ${r}`:""}`,n)}static invalidRequest(n,r){return new we(-32600,`Invalid request${r?`: ${r}`:""}`,n)}static methodNotFound(n){return new we(-32601,`"Method not found": ${n}`,{method:n})}static invalidParams(n,r){return new we(-32602,`Invalid params${r?`: ${r}`:""}`,n)}static internalError(n,r){return new we(-32603,`Internal error${r?`: ${r}`:""}`,n)}static authRequired(n,r){return new we(-32e3,`Authentication required${r?`: ${r}`:""}`,n)}static resourceNotFound(n){return new we(-32002,`Resource not found${n?`: ${n}`:""}`,n&&{uri:n})}toResult(){return{error:{code:this.code,message:this.message,data:this.data}}}toErrorResponse(){return{code:this.code,message:this.message,data:this.data}}}const FR=/^Sender \(untrusted metadata\):\n```json\n[\s\S]*?\n```\n\n?/,ZR=/^\[[^\n]*Working directory:[^\n]*\]\n\n?/,HR=/\[Television screen context\][\s\S]*?\[\/Television screen context\]\n*/,BR=/\[\[\s*(?:reply_to_current|reply_to\s*:\s*[^\]\n]+|audio_as_voice)\s*\]\]\s*/gi,jR="single_session",VR={name:"television-acp-client",version:"0.0.0"},gv="agent:main:television",GR=wi(mt);var te,Ft,Vr,Zt,Gn,Wn,qn,Yn,an,Gr,Tt,ct,ln,Kn,Ht,cn,vs,Bt,ut,_a,jt,C,mv,vv,Ic,yv,bv,wv,Sv,_v,kv,Ev,In,Pr,Rr,He,xv,Dr,Pc,Rc,qo,$v,Av,ys,bs,Dc,Or,Tv,Cv;class WR extends GR{constructor(n){super();S(this,C);S(this,te,YR());S(this,Ft,null);S(this,Vr,null);S(this,Zt,null);S(this,Gn,null);S(this,Wn,null);S(this,qn,null);S(this,Yn);S(this,an,null);S(this,Gr,1);S(this,Tt,null);S(this,ct,null);S(this,ln,!1);S(this,Kn,!1);S(this,Ht,null);S(this,cn,new Set);S(this,vs);S(this,Bt);S(this,ut);S(this,_a,n=>{g(this,C,vv).call(this,n)});S(this,jt,null);S(this,ys,()=>{g(this,C,Or).call(this,"ACP bridge websocket closed")});S(this,bs,()=>{g(this,C,Or).call(this,"ACP bridge websocket error")});k(this,Bt,n),k(this,ut,n.sessionMode??jR),k(this,Yn,n.mappedSessionStore??qR()),k(this,vs,n.createSocket??(r=>new WebSocket(r)))}getState(){return l(this,te)}get messages(){return l(this,te).messageOrder.map(n=>l(this,te).messagesById[n]).filter(n=>n!==void 0)}async connect(){if(this.disposed)throw new Error("ACPClient has been disposed");if(l(this,te).lifecycle.status!=="ready"){g(this,C,He).call(this,{lifecycle:{status:"connecting"}}),l(this,Vr)??k(this,Vr,g(this,C,mv).call(this));try{await l(this,Vr),await g(this,C,Ic).call(this)}catch(n){throw g(this,C,Or).call(this,Co(n)),n}}}dispose(){g(this,C,Dc).call(this),g(this,C,He).call(this,{lifecycle:{status:"disposed"},run:{status:"idle",stopReason:null,canCancel:!1,error:null},bridge:null})}async sendMessage(n){if(await this.connect(),l(this,te).lifecycle.status!=="ready"||l(this,te).run.status==="running"||l(this,te).run.status==="cancelling")throw new Error("ACPClient is not ready to send a new message");const r=n.text.trim();if(!r)throw new Error("Cannot send an empty message");g(this,C,Pr).call(this,{id:g(this,C,Dr).call(this,"user"),kind:"user",text:r,status:"final"}),g(this,C,He).call(this,{run:{status:"running",stopReason:null,canCancel:!0,error:null}});try{const i=await g(this,C,qo).call(this).prompt({sessionId:g(this,C,Rc).call(this),prompt:[{type:"text",text:g(this,C,xv).call(this,r)}]});g(this,C,In).call(this,i.stopReason==="cancelled"?"cancelled":"final"),g(this,C,He).call(this,{run:{status:i.stopReason==="cancelled"?"cancelled":"completed",stopReason:i.stopReason,canCancel:!1,error:null}})}catch(i){throw g(this,C,Cv).call(this)||(g(this,C,In).call(this,"error"),g(this,C,He).call(this,{run:{status:"error",stopReason:null,canCancel:!1,error:Co(i)}})),i}}async cancel(){if(await this.connect(),!l(this,te).run.canCancel||l(this,te).run.status!=="running")throw new Error("No active cancellable run");g(this,C,He).call(this,{run:{...l(this,te).run,status:"cancelling"}}),await g(this,C,qo).call(this).cancel({sessionId:g(this,C,Rc).call(this)})}setScreenContext(n){var s,o,a;const r={screenID:n.screenID,screenName:n.screenName};if(((s=l(this,ct))==null?void 0:s.screenID)===r.screenID&&((o=l(this,ct))==null?void 0:o.screenName)===r.screenName)return;const i=((a=l(this,ct))==null?void 0:a.screenID)??null;if(k(this,ct,r),l(this,ut)==="single_session"){(!l(this,an)||i!==r.screenID)&&k(this,ln,!0);return}l(this,an)!==Mp(l(this,ut),r.screenID,l(this,Bt).clientGUID??"default-client")&&(k(this,Zt,null),k(this,Gn,null),l(this,Ft)&&l(this,te).run.status==="idle"&&g(this,C,Ic).call(this).catch(c=>{g(this,C,Or).call(this,Co(c))}))}}te=new WeakMap,Ft=new WeakMap,Vr=new WeakMap,Zt=new WeakMap,Gn=new WeakMap,Wn=new WeakMap,qn=new WeakMap,Yn=new WeakMap,an=new WeakMap,Gr=new WeakMap,Tt=new WeakMap,ct=new WeakMap,ln=new WeakMap,Kn=new WeakMap,Ht=new WeakMap,cn=new WeakMap,vs=new WeakMap,Bt=new WeakMap,ut=new WeakMap,_a=new WeakMap,jt=new WeakMap,C=new WeakSet,mv=async function(){try{g(this,C,He).call(this,{lifecycle:{status:"connecting"}});const{stream:n,socket:r,metadata:i}=await XR({serverURL:l(this,Bt).serverURL,token:l(this,Bt).token,createSocket:l(this,vs),onDisconnect:l(this,_a)});k(this,qn,i),g(this,C,He).call(this,{bridge:i}),k(this,jt,r),r.addEventListener("close",l(this,ys)),r.addEventListener("error",l(this,bs)),k(this,Ft,new NR(s=>({connection:s,sessionUpdate:async o=>{await g(this,C,bv).call(this,o)},requestPermission:async o=>g(this,C,wv).call(this,o)}),n)),await l(this,Ft).initialize({protocolVersion:SC,clientCapabilities:{},clientInfo:VR})}catch(n){throw n}},vv=function(n){g(this,C,Or).call(this,Co(n))},Ic=async function(){const n=g(this,C,Av).call(this);if(l(this,Zt)&&l(this,Gn)===n){await l(this,Zt);return}k(this,Gn,n),k(this,Zt,g(this,C,yv).call(this,n)),await l(this,Zt)},yv=async function(n){var a;const r=g(this,C,qo).call(this);g(this,C,Tv).call(this);let i,s=!1;const o={cwd:g(this,C,$v).call(this),mcpServers:[],_meta:{sessionKey:n}};try{if(k(this,Kn,!0),k(this,Ht,null),((a=l(this,qn))==null?void 0:a.sessionIdStrategy)==="mapped"){const c=l(this,Yn).getActualSessionId(n);if(c)try{const u=await r.loadSession({...o,sessionId:c});if(KR(u))throw new Error("Mapped ACP session was not found");i=c,s=!0}catch{i=(await r.newSession(o)).sessionId,l(this,Yn).setActualSessionId(n,i),s=!1}else i=(await r.newSession(o)).sessionId,l(this,Yn).setActualSessionId(n,i),s=!1}else try{await r.loadSession({...o,sessionId:n}),i=n,s=l(this,te).messageOrder.length>0}catch{i=(await r.newSession(o)).sessionId,s=!1}}finally{k(this,Kn,!1),k(this,Ht,null),g(this,C,In).call(this,"final")}await r.setSessionConfigOption({sessionId:i,configId:"verbose_level",value:"full"}),k(this,Wn,i),k(this,an,n),s?(l(this,cn).add(n),l(this,ut)==="single_session"&&k(this,ln,!1)):(l(this,cn).delete(n),k(this,ln,l(this,ut)==="single_session")),g(this,C,He).call(this,{lifecycle:{status:"ready"}})},bv=async function(n){const r=n.update;switch(r.sessionUpdate){case"user_message_chunk":r.content.type==="text"&&g(this,C,Ev).call(this,r.content.text);return;case"agent_message_chunk":r.content.type==="text"&&g(this,C,Sv).call(this,r.content.text);return;case"tool_call":g(this,C,_v).call(this,r);return;case"tool_call_update":g(this,C,kv).call(this,r);return;case"agent_thought_chunk":return;default:return}},wv=async function(n){return{outcome:{outcome:"cancelled"}}},Sv=function(n){k(this,Ht,null);const r=JR(n);if(!r)return;if(!l(this,Tt)){const s={id:g(this,C,Dr).call(this,"assistant"),kind:"assistant",text:r,status:"streaming"};k(this,Tt,s.id),g(this,C,Pr).call(this,s);return}const i=l(this,te).messagesById[l(this,Tt)];if(!i||i.kind!=="assistant")throw new Error("Open assistant message invariant violated");g(this,C,Rr).call(this,{...i,text:`${i.text}${r}`,status:"streaming"})},_v=function(n){g(this,C,In).call(this,"final");const r=g(this,C,Pc).call(this,n.toolCallId),i=Up("content"in n?n.content:void 0),s={id:(r==null?void 0:r.id)??g(this,C,Dr).call(this,"tool"),kind:"tool_call",toolCallId:n.toolCallId,title:n.title,toolKind:n.kind??"other",status:n.status==="failed"?"failed":n.status==="completed"?"completed":"in_progress",text:(r==null?void 0:r.text)??i,locations:n.locations??(r==null?void 0:r.locations)};if(r){g(this,C,Rr).call(this,s);return}g(this,C,Pr).call(this,s)},kv=function(n){const r=g(this,C,Pc).call(this,n.toolCallId),i=(r==null?void 0:r.text)??"",s=Up(n.content),o=s?`${i}${s}`:i,a={id:(r==null?void 0:r.id)??g(this,C,Dr).call(this,"tool"),kind:"tool_call",toolCallId:n.toolCallId,title:(r==null?void 0:r.title)??n.toolCallId,toolKind:(r==null?void 0:r.toolKind)??"other",status:n.status==="failed"?"failed":n.status==="completed"?"completed":"in_progress",text:o,locations:n.locations??(r==null?void 0:r.locations)};if(r){g(this,C,Rr).call(this,a);return}g(this,C,Pr).call(this,a)},Ev=function(n){if(g(this,C,In).call(this,"final"),!n)return;const r=l(this,Kn)?l(this,Ht):null;if(!r){const s=Np(n);if(!s)return;const o={id:g(this,C,Dr).call(this,"user"),kind:"user",text:s,status:"final"};g(this,C,Pr).call(this,o),l(this,Kn)&&k(this,Ht,o.id);return}const i=l(this,te).messagesById[r];if(!i||i.kind!=="user")throw new Error("Replay user message invariant violated");g(this,C,Rr).call(this,{...i,text:Np(`${i.text}${n}`)})},In=function(n){if(!l(this,Tt))return;const r=l(this,te).messagesById[l(this,Tt)];(r==null?void 0:r.kind)==="assistant"&&g(this,C,Rr).call(this,{...r,status:n}),k(this,Tt,null)},Pr=function(n){g(this,C,He).call(this,{messagesById:{...l(this,te).messagesById,[n.id]:n},messageOrder:[...l(this,te).messageOrder,n.id]})},Rr=function(n){g(this,C,He).call(this,{messagesById:{...l(this,te).messagesById,[n.id]:n}})},He=function(n){const r={...l(this,te),...n};k(this,te,{...r,sendDisabled:r.lifecycle.status!=="ready"||r.run.status==="running"||r.run.status==="cancelling",cancelDisabled:!(r.run.status==="running"||r.run.status==="cancelling")||!r.run.canCancel}),this.dispatchEvent(new ee("change"))},xv=function(n){const r=l(this,an);return!l(this,ct)||!r||!(l(this,ut)==="single_session"?l(this,ln)||!l(this,cn).has(r):!l(this,cn).has(r))?n:(k(this,ln,!1),l(this,cn).add(r),["[Television screen context]","This chat session is coming from a Television client in the screen below.",`screen_id: ${l(this,ct).screenID}`,`screen_name: ${l(this,ct).screenName??""}`,"When the user asks to inspect or change Television state with the tv CLI, use this screen ID with the --screen argument.","[/Television screen context]","",n].join(`
|
|
43
|
+
`))},Dr=function(n){const r=`${n}-${l(this,Gr)}`;return k(this,Gr,l(this,Gr)+1),r},Pc=function(n){for(const r of l(this,te).messageOrder){const i=l(this,te).messagesById[r];if((i==null?void 0:i.kind)==="tool_call"&&i.toolCallId===n)return i}return null},Rc=function(){if(!l(this,Wn))throw new Error("ACP session is not ready");return l(this,Wn)},qo=function(){if(!l(this,Ft))throw new Error("ACP connection is not ready");return l(this,Ft)},$v=function(){var r;const n=(r=l(this,qn))==null?void 0:r.sessionCwd;if(!n)throw new Error("ACP bridge session cwd is not ready");return n},Av=function(){var r;if(l(this,ut)==="single_session")return`${gv}-${(l(this,Bt).clientGUID??"default-client").toLowerCase()}`;const n=(r=l(this,ct))==null?void 0:r.screenID;if(!n)throw new Error("Screen context is required for per-screen session mode");return Mp(l(this,ut),n,l(this,Bt).clientGUID??"default-client")},ys=new WeakMap,bs=new WeakMap,Dc=function(){k(this,Ft,null),k(this,Vr,null),k(this,Zt,null),k(this,Gn,null),k(this,Wn,null),k(this,an,null),k(this,qn,null),l(this,jt)&&(l(this,jt).removeEventListener("close",l(this,ys)),l(this,jt).removeEventListener("error",l(this,bs)),l(this,jt).close(),k(this,jt,null))},Or=function(n){this.disposed||l(this,te).lifecycle.status==="disconnected"||(g(this,C,In).call(this,"error"),g(this,C,Dc).call(this),g(this,C,He).call(this,{lifecycle:{status:"disconnected",...n?{error:n}:{}},run:{status:"idle",stopReason:null,canCancel:!1,error:null},bridge:null}))},Tv=function(){k(this,Tt,null),k(this,Ht,null),k(this,Gr,1),g(this,C,He).call(this,{run:{status:"idle",stopReason:null,canCancel:!1,error:null},messagesById:{},messageOrder:[]})},Cv=function(){return l(this,te).lifecycle.status==="disconnected"};function qR(){const t=new Map;return{getActualSessionId(e){return t.get(e)??null},setActualSessionId(e,n){t.set(e,n)},clearActualSessionId(e){t.delete(e)}}}function YR(){return{lifecycle:{status:"connecting"},run:{status:"idle",stopReason:null,canCancel:!1,error:null},bridge:null,messagesById:{},messageOrder:[],sendDisabled:!0,cancelDisabled:!0}}function KR(t){return t==null?!0:typeof t=="object"&&Object.keys(t).length===0}function Mp(t,e,n){return t==="single_session"?`${gv}-${n.toLowerCase()}`:`agent:main:television-${n.toLowerCase()}-${e.toLowerCase()}`}function Iv(t){return t.replace(/^(?:\s*\n)+/,"")}function Np(t){let e=t;return e=e.replace(FR,""),e=e.replace(ZR,""),e=e.replace(HR,""),e=Iv(e),e}function JR(t){let e=t;return e=e.replace(BR,""),e=Iv(e),e}function Up(t){return!t||t.length===0?"":t.flatMap(e=>e.type==="content"&&e.content.type==="text"?[e.content.text]:[]).join("")}async function XR(t){const e=t.createSocket(tD(t.serverURL,t.token));let n=!1,r,i;const s=new Promise((u,d)=>{r=u,i=d}),o=new ReadableStream({start(u){let d=!1;const p=()=>{e.send(JSON.stringify({type:"acp-bridge-connect"}))},y=E=>{const I=eD(E);if(!I)return;let Z;try{Z=JSON.parse(I)}catch(P){const V=P instanceof Error?P:new Error(String(P));i(V),u.error(V);return}switch(Z.type){case"acp-bridge-status":if(Z.status==="ready"){let P;try{P=QR(Z)}catch(V){const O=V instanceof Error?V:new Error(String(V));n||i(O),u.error(O);return}n||(n=!0,r(P));return}if(Z.status==="error"||Z.status==="exited"){const P=new Error(Z.error??`ACP bridge ${Z.status}`);n||i(P),u.error(P)}return;case"acp-bridge-message":u.enqueue(Z.message);return}},v=()=>{var I;if(d)return;d=!0;const E=new Error("ACP bridge websocket closed");n||i(E),(I=t.onDisconnect)==null||I.call(t,E),u.close()},A=()=>{var I;if(d)return;d=!0;const E=new Error("ACP bridge websocket error");n||i(E),(I=t.onDisconnect)==null||I.call(t,E),u.error(E)};e.addEventListener("open",p),e.addEventListener("message",y),e.addEventListener("close",v),e.addEventListener("error",A)}}),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 QR(t){const{agent:e,sessionIdStrategy:n,sessionCwd:r}=t;if((e==="openclaw"||e==="hermes")&&(n==="deterministic"||n==="mapped")&&typeof r=="string"&&r.length>0)return{agent:e,sessionIdStrategy:n,sessionCwd:r};throw new Error("ACP bridge ready status missing bootstrap metadata")}function eD(t){if(typeof t=="string")return t;if(t instanceof Uint8Array)return new TextDecoder().decode(t);if(typeof Buffer<"u"&&t instanceof Buffer)return t.toString("utf8");if(typeof t=="object"&&t!==null&&"data"in t){const e=t.data;if(typeof e=="string")return e;if(e instanceof Uint8Array)return new TextDecoder().decode(e);if(Array.isArray(e))return Buffer.concat(e).toString("utf8")}return null}function tD(t,e){const n=new URL(t);return n.protocol=n.protocol==="https:"?"wss:":"ws:",n.pathname="/acp",n.search="",n.searchParams.set("token",e),n.hash="",n.toString()}function Co(t){return t instanceof Error?t.message:String(t)}const Fp="television.acpClientGUID",Zp="television.acpMappedSessions",nD=wi(mt);class rD extends nD{constructor(n){super();b(this,"screenManager");b(this,"clients",new Map);b(this,"options");b(this,"sessionMode");b(this,"clientGUID");b(this,"mappedSessionStore");b(this,"activeClient",null);b(this,"handleActiveScreenChanged",()=>{this.syncActiveClient()});this.screenManager=n.screenManager,this.sessionMode=n.sessionMode??"single_session";const r=n.storage??oD();this.options={serverURL:n.serverURL,token:n.token,...n.createSocket?{createSocket:n.createSocket}:{},...n.sessionMode?{sessionMode:n.sessionMode}:{}},this.clientGUID=n.clientGUID??lD(aD(r)),this.mappedSessionStore=n.mappedSessionStore??(r?new sD(r,n.serverURL):new iD),this.screenManager.addEventListener("active-screen-changed",this.handleActiveScreenChanged),this.syncActiveClient()}getActiveClient(){return this.activeClient}dispose(){this.screenManager.removeEventListener("active-screen-changed",this.handleActiveScreenChanged);for(const n of this.clients.values())n.dispose();this.clients.clear(),this.activeClient=null}syncActiveClient(){const n=this.screenManager.activeScreen,r=n?this.getClientForScreen(n):null;this.activeClient!==r&&(this.activeClient=r,this.dispatchEvent(new ee("change")))}getClientForScreen(n){const r=this.sessionMode==="single_session"?"single_session":n.id;let i=this.clients.get(r);return i||(i=new WR({...this.options,sessionMode:this.sessionMode,clientGUID:this.clientGUID,mappedSessionStore:this.mappedSessionStore}),this.clients.set(r,i)),i.setScreenContext({screenID:n.id,screenName:n.name}),i}}var Wr;class iD{constructor(){S(this,Wr,new Map)}getActualSessionId(e){return l(this,Wr).get(e)??null}setActualSessionId(e,n){l(this,Wr).set(e,n)}clearActualSessionId(e){l(this,Wr).delete(e)}}Wr=new WeakMap;const Hp=1;var qr,ws,Xe,Yo,Ko,Oc;class sD{constructor(e,n){S(this,Xe);S(this,qr);S(this,ws);k(this,qr,e),k(this,ws,n)}getActualSessionId(e){const n=g(this,Xe,Ko).call(this)[g(this,Xe,Yo).call(this,e)];return typeof n=="string"&&n.length>0?n:null}setActualSessionId(e,n){const r=g(this,Xe,Ko).call(this);r[g(this,Xe,Yo).call(this,e)]=n,g(this,Xe,Oc).call(this,r)}clearActualSessionId(e){const n=g(this,Xe,Ko).call(this);delete n[g(this,Xe,Yo).call(this,e)],g(this,Xe,Oc).call(this,n)}}qr=new WeakMap,ws=new WeakMap,Xe=new WeakSet,Yo=function(e){return JSON.stringify([l(this,ws),e])},Ko=function(){const e=l(this,qr).getItem(Zp);if(!e)return{};let n;try{n=JSON.parse(e)}catch{return{}}if(typeof n!="object"||n===null||Array.isArray(n))return{};const r=n;return r.version!==Hp?{}:typeof r.entries!="object"||r.entries===null||Array.isArray(r.entries)?{}:Object.fromEntries(Object.entries(r.entries).filter(i=>typeof i[1]=="string"))},Oc=function(e){const n={version:Hp,entries:e};l(this,qr).setItem(Zp,JSON.stringify(n))};function oD(){return typeof window>"u"?null:window.localStorage}function aD(t){if(!t)throw new Error("ACPClientManager requires storage when clientGUID is not provided");return t}function lD(t){const e=t.getItem(Fp);if(e)return e;const n=Mu().toLowerCase();return t.setItem(Fp,n),n}var Ss;class cD extends mt{constructor(){super();S(this,Ss,n=>{const r=uD(n);r!==null&&(n.preventDefault(),this.dispatchEvent(new HE("shortcut-triggered",{shortcut:r})))});document.addEventListener("keydown",l(this,Ss))}dispose(){document.removeEventListener("keydown",l(this,Ss))}}Ss=new WeakMap;function uD(t){for(const[e,n]of Object.entries(wx))if(hD(t,n.trigger))return e;return null}function hD(t,e){return!(t.key.toLowerCase()!==e.key.toLowerCase()||t.metaKey!==!!e.meta||t.ctrlKey!==!!e.ctrl||t.shiftKey!==!!e.shift||t.altKey!==!!e.alt)}const dD="serverURL",pD="token",fD="mode",gD="electron";function Pv(t=window.location.search,e=window.location.origin){const r=new URLSearchParams(t).get(dD);return r?new URL(r).origin:new URL(e).origin}function zc(t=window.location.search){return new URLSearchParams(t).get(pD)}function Rv(t=window.location.search){return new URLSearchParams(t).get(fD)===gD}/**
|
|
44
|
+
* @license
|
|
45
|
+
* Copyright 2017 Google LLC
|
|
46
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
47
|
+
*/const ts=globalThis,Bp=t=>t,fa=ts.trustedTypes,jp=fa?fa.createPolicy("lit-html",{createHTML:t=>t}):void 0,Dv="$lit$",nn=`lit$${Math.random().toFixed(9).slice(2)}$`,Ov="?"+nn,mD=`<${Ov}>`,hr=document,ss=()=>hr.createComment(""),os=t=>t===null||typeof t!="object"&&typeof t!="function",Ju=Array.isArray,vD=t=>Ju(t)||typeof(t==null?void 0:t[Symbol.iterator])=="function",Vl=`[
|
|
48
|
+
\f\r]`,Di=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Vp=/-->/g,Gp=/>/g,Tn=RegExp(`>|${Vl}(?:([^\\s"'>=/]+)(${Vl}*=${Vl}*(?:[^
|
|
49
|
+
\f\r"'\`<>=]|("|')|))|$)`,"g"),Wp=/'/g,qp=/"/g,zv=/^(?:script|style|textarea|title)$/i,yD=t=>(e,...n)=>({_$litType$:t,strings:e,values:n}),U=yD(1),ui=Symbol.for("lit-noChange"),ae=Symbol.for("lit-nothing"),Yp=new WeakMap,Nn=hr.createTreeWalker(hr,129);function Lv(t,e){if(!Ju(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return jp!==void 0?jp.createHTML(e):e}const bD=(t,e)=>{const n=t.length-1,r=[];let i,s=e===2?"<svg>":e===3?"<math>":"",o=Di;for(let a=0;a<n;a++){const c=t[a];let u,d,p=-1,y=0;for(;y<c.length&&(o.lastIndex=y,d=o.exec(c),d!==null);)y=o.lastIndex,o===Di?d[1]==="!--"?o=Vp:d[1]!==void 0?o=Gp:d[2]!==void 0?(zv.test(d[2])&&(i=RegExp("</"+d[2],"g")),o=Tn):d[3]!==void 0&&(o=Tn):o===Tn?d[0]===">"?(o=i??Di,p=-1):d[1]===void 0?p=-2:(p=o.lastIndex-d[2].length,u=d[1],o=d[3]===void 0?Tn:d[3]==='"'?qp:Wp):o===qp||o===Wp?o=Tn:o===Vp||o===Gp?o=Di:(o=Tn,i=void 0);const v=o===Tn&&t[a+1].startsWith("/>")?" ":"";s+=o===Di?c+mD:p>=0?(r.push(u),c.slice(0,p)+Dv+c.slice(p)+nn+v):c+nn+(p===-2?a:v)}return[Lv(t,s+(t[n]||"<?>")+(e===2?"</svg>":e===3?"</math>":"")),r]};class as{constructor({strings:e,_$litType$:n},r){let i;this.parts=[];let s=0,o=0;const a=e.length-1,c=this.parts,[u,d]=bD(e,n);if(this.el=as.createElement(u,r),Nn.currentNode=this.el.content,n===2||n===3){const p=this.el.content.firstChild;p.replaceWith(...p.childNodes)}for(;(i=Nn.nextNode())!==null&&c.length<a;){if(i.nodeType===1){if(i.hasAttributes())for(const p of i.getAttributeNames())if(p.endsWith(Dv)){const y=d[o++],v=i.getAttribute(p).split(nn),A=/([.?@])?(.*)/.exec(y);c.push({type:1,index:s,name:A[2],strings:v,ctor:A[1]==="."?SD:A[1]==="?"?_D:A[1]==="@"?kD:Qa}),i.removeAttribute(p)}else p.startsWith(nn)&&(c.push({type:6,index:s}),i.removeAttribute(p));if(zv.test(i.tagName)){const p=i.textContent.split(nn),y=p.length-1;if(y>0){i.textContent=fa?fa.emptyScript:"";for(let v=0;v<y;v++)i.append(p[v],ss()),Nn.nextNode(),c.push({type:2,index:++s});i.append(p[y],ss())}}}else if(i.nodeType===8)if(i.data===Ov)c.push({type:2,index:s});else{let p=-1;for(;(p=i.data.indexOf(nn,p+1))!==-1;)c.push({type:7,index:s}),p+=nn.length-1}s++}}static createElement(e,n){const r=hr.createElement("template");return r.innerHTML=e,r}}function hi(t,e,n=t,r){var o,a;if(e===ui)return e;let i=r!==void 0?(o=n._$Co)==null?void 0:o[r]:n._$Cl;const s=os(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(t),i._$AT(t,n,r)),r!==void 0?(n._$Co??(n._$Co=[]))[r]=i:n._$Cl=i),i!==void 0&&(e=hi(t,i._$AS(t,e.values),i,r)),e}class wD{constructor(e,n){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=n}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){const{el:{content:n},parts:r}=this._$AD,i=((e==null?void 0:e.creationScope)??hr).importNode(n,!0);Nn.currentNode=i;let s=Nn.nextNode(),o=0,a=0,c=r[0];for(;c!==void 0;){if(o===c.index){let u;c.type===2?u=new Xu(s,s.nextSibling,this,e):c.type===1?u=new c.ctor(s,c.name,c.strings,this,e):c.type===6&&(u=new ED(s,this,e)),this._$AV.push(u),c=r[++a]}o!==(c==null?void 0:c.index)&&(s=Nn.nextNode(),o++)}return Nn.currentNode=hr,i}p(e){let n=0;for(const r of this._$AV)r!==void 0&&(r.strings!==void 0?(r._$AI(e,r,n),n+=r.strings.length-2):r._$AI(e[n])),n++}}let Xu=class Mv{get _$AU(){var e;return((e=this._$AM)==null?void 0:e._$AU)??this._$Cv}constructor(e,n,r,i){this.type=2,this._$AH=ae,this._$AN=void 0,this._$AA=e,this._$AB=n,this._$AM=r,this.options=i,this._$Cv=(i==null?void 0:i.isConnected)??!0}get parentNode(){let e=this._$AA.parentNode;const n=this._$AM;return n!==void 0&&(e==null?void 0:e.nodeType)===11&&(e=n.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,n=this){e=hi(this,e,n),os(e)?e===ae||e==null||e===""?(this._$AH!==ae&&this._$AR(),this._$AH=ae):e!==this._$AH&&e!==ui&&this._(e):e._$litType$!==void 0?this.$(e):e.nodeType!==void 0?this.T(e):vD(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!==ae&&os(this._$AH)?this._$AA.nextSibling.data=e:this.T(hr.createTextNode(e)),this._$AH=e}$(e){var s;const{values:n,_$litType$:r}=e,i=typeof r=="number"?this._$AC(e):(r.el===void 0&&(r.el=as.createElement(Lv(r.h,r.h[0]),this.options)),r);if(((s=this._$AH)==null?void 0:s._$AD)===i)this._$AH.p(n);else{const o=new wD(i,this),a=o.u(this.options);o.p(n),this.T(a),this._$AH=o}}_$AC(e){let n=Yp.get(e.strings);return n===void 0&&Yp.set(e.strings,n=new as(e)),n}k(e){Ju(this._$AH)||(this._$AH=[],this._$AR());const n=this._$AH;let r,i=0;for(const s of e)i===n.length?n.push(r=new Mv(this.O(ss()),this.O(ss()),this,this.options)):r=n[i],r._$AI(s),i++;i<n.length&&(this._$AR(r&&r._$AB.nextSibling,i),n.length=i)}_$AR(e=this._$AA.nextSibling,n){var r;for((r=this._$AP)==null?void 0:r.call(this,!1,!0,n);e!==this._$AB;){const i=Bp(e).nextSibling;Bp(e).remove(),e=i}}setConnected(e){var n;this._$AM===void 0&&(this._$Cv=e,(n=this._$AP)==null||n.call(this,e))}},Qa=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,n,r,i,s){this.type=1,this._$AH=ae,this._$AN=void 0,this.element=e,this.name=n,this._$AM=i,this.options=s,r.length>2||r[0]!==""||r[1]!==""?(this._$AH=Array(r.length-1).fill(new String),this.strings=r):this._$AH=ae}_$AI(e,n=this,r,i){const s=this.strings;let o=!1;if(s===void 0)e=hi(this,e,n,0),o=!os(e)||e!==this._$AH&&e!==ui,o&&(this._$AH=e);else{const a=e;let c,u;for(e=s[0],c=0;c<s.length-1;c++)u=hi(this,a[r+c],n,c),u===ui&&(u=this._$AH[c]),o||(o=!os(u)||u!==this._$AH[c]),u===ae?e=ae:e!==ae&&(e+=(u??"")+s[c+1]),this._$AH[c]=u}o&&!i&&this.j(e)}j(e){e===ae?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}},SD=class extends Qa{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===ae?void 0:e}},_D=class extends Qa{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==ae)}},kD=class extends Qa{constructor(e,n,r,i,s){super(e,n,r,i,s),this.type=5}_$AI(e,n=this){if((e=hi(this,e,n,0)??ae)===ui)return;const r=this._$AH,i=e===ae&&r!==ae||e.capture!==r.capture||e.once!==r.once||e.passive!==r.passive,s=e!==ae&&(r===ae||i);i&&this.element.removeEventListener(this.name,this,r),s&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){var n;typeof this._$AH=="function"?this._$AH.call(((n=this.options)==null?void 0:n.host)??this.element,e):this._$AH.handleEvent(e)}};class ED{constructor(e,n,r){this.element=e,this.type=6,this._$AN=void 0,this._$AM=n,this.options=r}get _$AU(){return this._$AM._$AU}_$AI(e){hi(this,e)}}const Gl=ts.litHtmlPolyfillSupport;Gl==null||Gl(as,Xu),(ts.litHtmlVersions??(ts.litHtmlVersions=[])).push("3.3.2");const Re=(t,e,n)=>{const r=e;let i=r._$litPart$;return i===void 0&&(r._$litPart$=i=new Xu(e.insertBefore(ss(),null),null,void 0,{})),i._$AI(t),i},xD=.5,Kp=.1,Jp=8,$D=4,Nv=3,Uv=3,AD=4,Un=255,Fv=.2126,Zv=.7152,Hv=.0722;async function Qu(t){const e=TD(t);if(!e)return"light";try{return await PD(t,e)>=xD?"light":"dark"}catch{return"light"}}function TD(t){if(typeof document.elementsFromPoint!="function")return null;const e=t.getBoundingClientRect(),n=e.left+e.width/2,r=e.top+e.height/2,i=document.elementsFromPoint(n,r);for(const s of i){if(!(s instanceof HTMLElement)||s===t||t.contains(s))continue;const o=window.getComputedStyle(s);if(CD(o))return s}return null}function CD(t){return t.backgroundImage&&t.backgroundImage!=="none"?!0:ID(t.backgroundColor)>0}function ID(t){if(!t)return 0;const e=t.match(/rgba?\(([^)]+)\)/);if(!e)return 0;const n=e[1].split(/[\s,/]+/).filter(Boolean);return n.length===AD?parseFloat(n[Nv]):n.length===Uv?1:0}async function PD(t,e){const n=t.getBoundingClientRect(),r=e.getBoundingClientRect(),i={x:Io((n.left-r.left)/r.width),y:Io((n.top-r.top)/r.height),width:Io(n.width/r.width),height:Io(n.height/r.height)},s=window.getComputedStyle(e),o=RD(s.backgroundImage);return o?OD({url:o,surfaceWidth:r.width,surfaceHeight:r.height,region:i}):zD(s.backgroundColor)}function RD(t){const e=t.match(/url\(\s*["']?([^"')]+)["']?\s*\)/);return e?e[1]:null}const Xp=new Map;function DD(t){let e=Xp.get(t);return e||(e=new Promise((n,r)=>{const i=new Image;i.crossOrigin="anonymous",i.onload=()=>n(i),i.onerror=()=>r(new Error(`Failed to load ${t}`)),i.src=t}),Xp.set(t,e),e)}async function OD(t){const e=await DD(t.url),n=Math.max(Jp,Math.ceil(t.surfaceWidth*Kp)),r=Math.max(Jp,Math.ceil(t.surfaceHeight*Kp)),i=document.createElement("canvas");i.width=n,i.height=r;const s=i.getContext("2d",{willReadFrequently:!0});if(!s)return 1;const o=t.surfaceWidth/t.surfaceHeight,a=e.naturalWidth/e.naturalHeight;let c,u;a>o?(u=r,c=r*a):(c=n,u=n/a);const d=(n-c)/2,p=(r-u)/2;s.drawImage(e,d,p,c,u);const y=Math.max(0,Math.floor(t.region.x*n)),v=Math.max(0,Math.floor(t.region.y*r)),A=Math.max(1,Math.min(n-y,Math.floor(t.region.width*n))),E=Math.max(1,Math.min(r-v,Math.floor(t.region.height*r))),I=s.getImageData(y,v,A,E).data;let Z=0,P=0;for(let V=0;V<I.length;V+=$D){const O=I[V]/Un,H=I[V+1]/Un,N=I[V+2]/Un,ce=I[V+Nv]/Un;Z+=ce*(Fv*O+Zv*H+Hv*N),P+=1}return P>0?Z/P:1}function zD(t){const e=t.match(/rgba?\(([^)]+)\)/);if(!e)return 1;const n=e[1].split(/[\s,/]+/).filter(Boolean).map(parseFloat);if(n.length<Uv)return 1;const r=n[0]/Un,i=n[1]/Un,s=n[2]/Un;return Fv*r+Zv*i+Hv*s}function Io(t){return t<0?0:t>1?1:t}const Wl=new WeakSet,Qp=new WeakSet;function Bv(t){if(Qp.has(t))return;Qp.add(t);for(const n of t.querySelectorAll('button[variant="ghost"]'))ql(n);if(typeof MutationObserver!="function")return;new MutationObserver(n=>{for(const r of n)if(r.type==="childList")for(const i of r.addedNodes)LD(i,ql);else r.type==="attributes"&&r.target instanceof HTMLButtonElement&&r.target.getAttribute("variant")==="ghost"&&ql(r.target)}).observe(t,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["variant"]})}function LD(t,e){if(t instanceof Element){t instanceof HTMLButtonElement&&t.getAttribute("variant")==="ghost"&&e(t);for(const n of t.querySelectorAll('button[variant="ghost"]'))e(n)}}async function ql(t){if(Wl.has(t))return;Wl.add(t);const e=await Qu(t);if(t.getAttribute("variant")!=="ghost"){Wl.delete(t);return}t.setAttribute("tone",e)}const MD="*,*:before,*:after{box-sizing:border-box}html,body{margin:0;padding:0;width:100%;height:100%}h1,h2,h3,h4,h5,h6,p,ul,ol,blockquote,pre,hr{margin:0}button,input,textarea,select{font:inherit;color:inherit}@font-face{font-family:Hind;src:url("+new URL("Hind-Variable-C47b_dt9.woff2",import.meta.url).href+') format("woff2-variations");font-weight:300 700;font-style:normal;font-display:swap}:root{--font-sans: "Hind", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;--font-brand: var(--font-sans);--font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, monospace;--font-weight-body: 500;--text-base: 13.5px;--text-scale: 1.125;--text-sm: round(calc(var(--text-base) / var(--text-scale)), 1px);--text-lg: round(calc(var(--text-base) * var(--text-scale)), 1px);--text-xl: round(calc(var(--text-lg) * var(--text-scale)), 1px);--leading-base: 1.5;--space-2: 2px;--space-4: 4px;--space-6: 6px;--space-8: 8px;--space-12: 12px;--space-16: 16px;--space-20: 20px;--space-24: 24px;--space-32: 32px;--space-48: 48px;--space-64: 64px;--radius-4: 4px;--radius-8: 8px;--radius-12: 12px;--radius-16: 16px;--radius-24: 24px;--radius-full: 9999px;--shadow-hairline: 0 0 0 .5px var(--color-border);--shadow-control: 0 1px 1px rgb(0 0 0 / .04), 0 2px 6px rgb(0 0 0 / .06);--alpha-50: 4%;--alpha-100: 8%;--alpha-200: 15%;--alpha-300: 22%;--alpha-400: 30%;--alpha-500: 40%;--alpha-600: 50%;--alpha-700: 65%;--alpha-800: 80%;--alpha-900: 90%;--alpha-950: 95%;--tint-50: color-mix(in srgb, currentColor var(--alpha-50), transparent);--tint-100: color-mix(in srgb, currentColor var(--alpha-100), transparent);--tint-200: color-mix(in srgb, currentColor var(--alpha-200), transparent);--tint-300: color-mix(in srgb, currentColor var(--alpha-300), transparent);--tint-400: color-mix(in srgb, currentColor var(--alpha-400), transparent);--tint-500: color-mix(in srgb, currentColor var(--alpha-500), transparent);--tint-600: color-mix(in srgb, currentColor var(--alpha-600), transparent);--tint-700: color-mix(in srgb, currentColor var(--alpha-700), transparent);--tint-800: color-mix(in srgb, currentColor var(--alpha-800), transparent);--tint-900: color-mix(in srgb, currentColor var(--alpha-900), transparent);--tint-950: color-mix(in srgb, currentColor var(--alpha-950), transparent);--color-overlay-hover: color-mix(in srgb, var(--black) var(--alpha-100), transparent);--color-overlay-active: color-mix(in srgb, var(--black) var(--alpha-300), transparent);--backdrop-blur-glass: blur(20px) saturate(1.4);--black: #000000;--white: #ffffff;--neutral-50: oklch(.985 0 0);--neutral-100: oklch(.97 0 0);--neutral-200: oklch(.923 0 0);--neutral-300: oklch(.869 0 0);--neutral-350: oklch(.79 0 0);--neutral-400: oklch(.709 0 0);--neutral-500: oklch(.553 0 0);--neutral-600: oklch(.444 0 0);--neutral-700: oklch(.374 0 0);--neutral-800: oklch(.268 0 0);--neutral-900: oklch(.216 0 0);--neutral-950: oklch(.147 0 0);--red-50: oklch(.969 .015 12.422);--red-100: oklch(.941 .03 12.58);--red-200: oklch(.892 .058 10.001);--red-300: oklch(.81 .117 11.638);--red-400: oklch(.712 .194 13.428);--red-500: oklch(.645 .246 16.439);--red-600: oklch(.586 .253 17.585);--red-700: oklch(.514 .222 16.935);--red-800: oklch(.455 .188 13.697);--red-900: oklch(.41 .159 10.272);--red-950: oklch(.271 .105 12.094);--orange-50: oklch(.98 .016 73.684);--orange-100: oklch(.954 .038 75.164);--orange-200: oklch(.901 .076 70.697);--orange-300: oklch(.837 .128 66.29);--orange-400: oklch(.75 .183 55.934);--orange-500: oklch(.705 .213 47.604);--orange-600: oklch(.646 .222 41.116);--orange-700: oklch(.553 .195 38.402);--orange-800: oklch(.47 .157 37.304);--orange-900: oklch(.408 .123 38.172);--orange-950: oklch(.266 .079 36.259);--yellow-50: oklch(.987 .026 102.212);--yellow-100: oklch(.973 .071 103.193);--yellow-200: oklch(.945 .129 101.54);--yellow-300: oklch(.905 .182 98.111);--yellow-400: oklch(.852 .199 91.936);--yellow-500: oklch(.795 .184 86.047);--yellow-600: oklch(.681 .162 75.834);--yellow-700: oklch(.554 .135 66.442);--yellow-800: oklch(.476 .114 61.907);--yellow-900: oklch(.421 .095 57.708);--yellow-950: oklch(.286 .066 53.813);--green-50: oklch(.979 .021 166.113);--green-100: oklch(.95 .052 163.051);--green-200: oklch(.905 .093 164.15);--green-300: oklch(.845 .143 164.978);--green-400: oklch(.765 .177 163.223);--green-500: oklch(.696 .17 162.48);--green-600: oklch(.596 .145 163.225);--green-700: oklch(.508 .118 165.612);--green-800: oklch(.432 .095 166.913);--green-900: oklch(.378 .077 168.94);--green-950: oklch(.262 .051 172.552);--blue-50: oklch(.97 .014 254.604);--blue-100: oklch(.932 .032 255.585);--blue-200: oklch(.882 .059 254.128);--blue-300: oklch(.809 .105 251.813);--blue-400: oklch(.707 .165 254.624);--blue-500: oklch(.623 .214 259.815);--blue-600: oklch(.546 .245 262.881);--blue-700: oklch(.488 .243 264.376);--blue-800: oklch(.424 .199 265.638);--blue-900: oklch(.379 .146 265.522);--blue-950: oklch(.282 .091 267.935);--purple-50: oklch(.969 .016 293.756);--purple-100: oklch(.943 .029 294.588);--purple-200: oklch(.894 .057 293.283);--purple-300: oklch(.811 .111 293.571);--purple-400: oklch(.702 .183 293.541);--purple-500: oklch(.606 .25 292.717);--purple-600: oklch(.541 .281 293.009);--purple-700: oklch(.491 .27 292.581);--purple-800: oklch(.432 .232 292.759);--purple-900: oklch(.38 .189 293.745);--purple-950: oklch(.283 .141 291.089)}@supports (corner-shape: squircle){:root{--radius-8: 10px;--radius-12: 15px;--radius-16: 20px;--radius-24: 30px}}:root[data-font=system]{--font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif}:root{--color-bg: var(--neutral-50);--color-bg-muted: var(--neutral-100);--color-surface: var(--white);--color-surface-muted: var(--neutral-100);--color-interactive: var(--neutral-200);--color-interactive-hover: var(--neutral-300);--color-border: rgba(0, 0, 0, .1);--color-border-muted: rgba(0, 0, 0, .06);--color-text: var(--neutral-900);--color-text-muted: var(--neutral-500);--color-link: inherit;--color-focus-ring: var(--neutral-500);--color-overlay-backdrop: rgb(0 0 0 / .5);--color-highlight: rgb(255 255 255 / .5);--color-primary: var(--blue-500);--color-danger: var(--red-600);color-scheme:light}body{font-family:var(--font-sans);font-size:var(--text-base);font-weight:var(--font-weight-body);line-height:var(--leading-base);letter-spacing:.015em;color:var(--color-text);background:var(--color-bg);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}a{color:var(--color-link);text-underline-offset:.15em;text-decoration-thickness:.08em}h1,h2,h3,h4,h5,h6{font-weight:600;color:inherit}code{font-family:var(--font-mono);font-size:.9em;background:var(--color-bg-muted);padding:var(--space-2) var(--space-4);border-radius:var(--radius-4)}pre{font-family:var(--font-mono);background:var(--color-bg-muted);padding:var(--space-12);border-radius:var(--radius-8);overflow-x:auto}pre code{background:none;padding:0}blockquote{padding-left:var(--space-16);border-left:3px solid var(--color-border);color:var(--color-text-muted)}hr{border:none;border-top:1px solid var(--color-border)}table{border-collapse:collapse}th,td{padding:var(--space-8) var(--space-12);border:1px solid var(--color-border);text-align:left}th{background:var(--color-bg-muted);font-weight:600}input,textarea{padding:6px 10px;border:.5px solid var(--tint-300);border-radius:var(--radius-12);background:var(--tint-100);color:inherit;font:inherit;transition:background .12s ease,border-color .12s ease,box-shadow .12s ease}textarea{resize:none}input::placeholder,textarea::placeholder{color:var(--tint-500)}input:focus,textarea:focus{background:color-mix(in srgb,var(--white) var(--alpha-300),transparent);border-color:var(--color-primary);outline:none;box-shadow:0 0 0 1.5px var(--color-primary)}label.field{display:grid;gap:4px;font-size:13px}label.field>span{font-size:11.5px;font-weight:450;color:var(--tint-800)}@supports (corner-shape: squircle){*{corner-shape:squircle}}button{display:inline-flex;align-items:center;justify-content:center;gap:var(--space-6);padding:4px 14px;border:.5px solid var(--tint-200);border-radius:var(--radius-12);background:var(--color-surface);color:inherit;font:inherit;cursor:default;box-shadow:var(--shadow-control)}button:hover:not(:disabled){background:color-mix(in srgb,var(--color-surface) 96%,black)}button:active:not(:disabled){background:color-mix(in srgb,var(--color-surface) 88%,black);box-shadow:inset 0 1px 2px #00000014}button:focus-visible{outline:2px solid var(--color-focus-ring);outline-offset:2px}button[variant=primary]{background:var(--color-primary);border-color:#0000002e;color:var(--white)}button[variant=primary]:hover:not(:disabled){background:color-mix(in srgb,var(--color-primary) 92%,black)}button[variant=primary]:active:not(:disabled){background:color-mix(in srgb,var(--color-primary) 82%,black);box-shadow:inset 0 1px 2px #0000002e}button[variant=danger]{background:var(--color-danger);border-color:#0000002e;color:var(--white)}button[variant=danger]:hover:not(:disabled){background:color-mix(in srgb,var(--color-danger) 92%,black)}button[variant=danger]:active:not(:disabled){background:color-mix(in srgb,var(--color-danger) 82%,black);box-shadow:inset 0 1px 2px #0000002e}button[variant=ghost]{background:transparent;border-color:transparent;color:inherit;box-shadow:none}button[variant=ghost]:hover:not(:disabled){background:var(--color-overlay-hover)}button[variant=ghost]:active:not(:disabled){background:var(--color-overlay-active);box-shadow:none}button[variant=ghost][data-active]:not(:disabled),button[variant=ghost][data-active]:hover:not(:disabled),button[variant=ghost][aria-expanded=true]:not(:disabled),button[variant=ghost][aria-expanded=true]:hover:not(:disabled){background:var(--color-overlay-active);box-shadow:none}button:disabled{background:var(--tint-300);border-color:transparent;color:var(--tint-700);box-shadow:none}[tone=dark] button:not([variant]):not(:disabled){background:var(--tint-200);border-color:var(--tint-300);box-shadow:inset 0 .5px 0 var(--tint-300)}[tone=dark] button:not([variant]):hover:not(:disabled){background:var(--tint-300)}[tone=dark] button:not([variant]):active:not(:disabled){background:var(--tint-400);box-shadow:inset 0 1px 2px #0003}[tone=light] button:not([variant]):not(:disabled){background:var(--color-surface);border-color:var(--tint-200);box-shadow:var(--shadow-control)}[tone=light] button:not([variant]):hover:not(:disabled){background:color-mix(in srgb,var(--color-surface) 96%,black)}[tone=light] button:not([variant]):active:not(:disabled){background:color-mix(in srgb,var(--color-surface) 88%,black);box-shadow:inset 0 1px 2px #00000014}button[size=sm]{min-height:24px;padding:var(--space-2) var(--space-8)}button[size=md]{min-height:32px;padding:var(--space-6) var(--space-12)}button[icon-only]{width:24px;height:24px;min-height:0;padding:0}[data-ui-icon]{display:inline-block;vertical-align:middle}.prose{line-height:var(--leading-base)}.prose h1{font-size:var(--text-xl);margin-bottom:var(--space-8)}.prose h2{font-size:var(--text-lg);margin-top:var(--space-24);margin-bottom:var(--space-8)}.prose h3,.prose h4,.prose h5,.prose h6{font-size:var(--text-base);margin-top:var(--space-24);margin-bottom:var(--space-8)}.prose p{margin:var(--space-12) 0}.prose ul,.prose ol{padding-left:var(--space-24);margin:var(--space-12) 0}.prose blockquote,.prose pre{margin:var(--space-12) 0}.prose hr{margin:var(--space-24) 0}.prose table{width:100%;margin:var(--space-12) 0}.prose img{max-width:100%;height:auto}.prose>:first-child{margin-top:0}.prose>:last-child{margin-bottom:0}[material=paper]{background:var(--white);border:.5px solid color-mix(in srgb,var(--black) var(--alpha-100),transparent);color:var(--color-text)}[material=glass]{background:color-mix(in srgb,var(--white) var(--alpha-700),transparent);border:.5px solid color-mix(in srgb,var(--black) var(--alpha-100),transparent);color:var(--color-text);backdrop-filter:var(--backdrop-blur-glass);-webkit-backdrop-filter:var(--backdrop-blur-glass)}[tone=dark]{color:color-mix(in srgb,var(--white) var(--alpha-950),transparent);border-color:color-mix(in srgb,var(--white) var(--alpha-200),transparent);--color-overlay-hover: color-mix(in srgb, var(--white) var(--alpha-200), transparent);--color-overlay-active: color-mix(in srgb, var(--black) var(--alpha-500), transparent)}[tone=dark][material=paper]{background:#000}[tone=dark][material=glass]{background:color-mix(in srgb,var(--black) var(--alpha-600),transparent)}[tone=light]{color:var(--color-text);border-color:color-mix(in srgb,var(--black) var(--alpha-100),transparent);--color-overlay-hover: color-mix(in srgb, var(--black) var(--alpha-100), transparent);--color-overlay-active: color-mix(in srgb, var(--black) var(--alpha-300), transparent)}[level="1"]{box-shadow:0 12px 32px #00000024}[level="2"]{box-shadow:0 4px 6px -2px #0000001f,0 40px 60px -16px #00000038}dropdown-menu{position:relative;display:inline-block;color:inherit}dropdown-group{display:grid;gap:var(--space-4)}dropdown-label{display:block;padding:var(--space-4) var(--space-8);color:var(--color-text-muted);font:inherit;font-size:var(--text-sm);font-weight:600;letter-spacing:.04em;text-transform:uppercase}dropdown-divider{display:block;height:1px;margin:2px 0;background:var(--color-border)}[data-dropdown-trigger][aria-expanded=true],[data-dropdown-trigger][aria-expanded=true]:hover,dropdown-menu[open]::part(trigger),dropdown-menu[open]::part(trigger):hover{background:color-mix(in srgb,var(--color-surface) 88%,black);box-shadow:inset 0 1px 2px #00000014}[data-dropdown-trigger-label],dropdown-menu::part(trigger-label){min-width:0}[data-dropdown-trigger-icon],dropdown-menu::part(trigger-icon){display:inline-flex;align-items:center;justify-content:center;flex:none;color:var(--color-text-muted);transform:translateY(1px)}dropdown-item:focus-visible{outline:2px solid var(--color-focus-ring);outline-offset:2px}dropdown-menu::part(panel){position:absolute;left:0;min-width:192px;padding:var(--space-4);border-radius:var(--radius-8);display:flex;flex-direction:column;gap:2px;z-index:2000}dropdown-menu::part(panel-bottom){top:calc(100% + var(--space-4))}dropdown-menu::part(panel-top){bottom:calc(100% + var(--space-4))}dropdown-item{display:flex;align-items:center;gap:var(--space-8);margin:0;padding:6px 12px;border-radius:var(--radius-8);font:inherit;line-height:1.2;color:inherit;font-weight:var(--font-weight-body);-webkit-user-select:none;user-select:none}dropdown-item>[data-ui-icon]{flex:none}dropdown-item[selected]{background:var(--color-overlay-active)}dropdown-item:hover{background:var(--color-primary);color:var(--white)}dropdown-item[action]{color:inherit}dropdown-item[danger]{color:var(--color-danger)}dropdown-item[danger]:hover{background:var(--color-danger);color:var(--white)}modal-overlay{color:inherit}modal-overlay::part(backdrop){position:fixed;top:0;right:0;bottom:0;left:0;z-index:var(--layer-overlay);display:flex;align-items:center;justify-content:center;padding:var(--space-16);background:var(--color-overlay-backdrop)}panel-view{display:block}panel-view::part(panel){display:flex;flex-direction:column;gap:var(--space-16);color:var(--color-text)}panel-view::part(header){display:flex;align-items:center;justify-content:space-between;gap:var(--space-12)}panel-view::part(title){margin:0;font:inherit;font-size:var(--text-lg);font-weight:600;color:var(--color-text)}panel-view::part(button){display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;margin:0;border:1px solid var(--color-border);border-radius:var(--radius-4);background:var(--color-surface);color:var(--color-text);box-shadow:none}panel-view::part(button):hover{background:var(--color-interactive-hover)}panel-view::part(button):focus-visible{outline:2px solid var(--color-focus-ring);outline-offset:2px}panel-view::part(icon){display:inline-flex;align-items:center;justify-content:center;flex:none}ui-popover{display:contents}ui-popover::part(panel){position:fixed;min-width:192px;max-width:384px;padding:var(--space-16) var(--space-20);border-radius:var(--radius-16);outline:none;z-index:2000}ui-pill{display:inline-block;vertical-align:baseline;margin:2px 0;padding:0 var(--space-8);font-size:var(--text-sm);font-weight:500;line-height:1.7;border-radius:var(--radius-full);border:1px solid var(--neutral-300);background:var(--neutral-200);color:var(--neutral-900);white-space:nowrap}ui-pill[color=gray]{border-color:var(--neutral-300);background:var(--neutral-200);color:var(--neutral-900)}ui-pill[color=red]{border-color:var(--red-200);background:var(--red-100);color:var(--red-950)}ui-pill[color=orange]{border-color:var(--orange-200);background:var(--orange-100);color:var(--orange-950)}ui-pill[color=yellow]{border-color:var(--yellow-200);background:var(--yellow-100);color:var(--yellow-950)}ui-pill[color=green]{border-color:var(--green-200);background:var(--green-100);color:var(--green-950)}ui-pill[color=blue]{border-color:var(--blue-200);background:var(--blue-100);color:var(--blue-950)}ui-pill[color=purple]{border-color:var(--purple-200);background:var(--purple-100);color:var(--purple-950)}',eh=new CSSStyleSheet;eh.replaceSync(MD);try{document.adoptedStyleSheets=[...document.adoptedStyleSheets,eh]}catch{}Bv(document);function jv(t){try{t.adoptedStyleSheets=[...t.adoptedStyleSheets,eh]}catch{}Bv(t)}/**
|
|
50
|
+
* @license
|
|
51
|
+
* Copyright 2017 Google LLC
|
|
52
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
53
|
+
*/const Vv={CHILD:2},th=t=>(...e)=>({_$litDirective$:t,values:e});class Gv{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,n,r){this._$Ct=e,this._$AM=n,this._$Ci=r}_$AS(e,n){return this.update(e,n)}update(e,n){return this.render(...n)}}/**
|
|
54
|
+
* @license
|
|
55
|
+
* Copyright 2017 Google LLC
|
|
56
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
57
|
+
*/let ga=class extends Gv{constructor(e){if(super(e),this.it=ae,e.type!==Vv.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(e){if(e===ae||e==null)return this._t=void 0,this.it=e;if(e===ui)return e;if(typeof e!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(e===this.it)return this._t;this.it=e;const n=[e];return n.raw=n,this._t={_$litType$:this.constructor.resultType,strings:n,values:[]}}};ga.directiveName="unsafeHTML",ga.resultType=1;const ND=th(ga);/**
|
|
58
|
+
* @license
|
|
59
|
+
* Copyright 2017 Google LLC
|
|
60
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
61
|
+
*/class Lc extends ga{}Lc.directiveName="unsafeSVG",Lc.resultType=2;const UD=th(Lc),FD={size:16,color:"currentColor",weight:"regular"};function ZD(t){return typeof t=="string"?{regular:t}:t}function Qt(t,e="0 0 256 256"){const n=ZD(t);return r=>{const{size:i,color:s,weight:o}={...FD,...r},a=n[o]??n.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
|
+
>${UD(a)}</svg>`}}const HD=Qt('<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"/>'),Wv=Qt('<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"/>'),BD=Qt('<path d="M181.66,133.66l-80,80a8,8,0,0,1-11.32-11.32L164.69,128,90.34,53.66a8,8,0,0,1,11.32-11.32l80,80A8,8,0,0,1,181.66,133.66Z"/>'),qv=Qt('<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"/>'),jD=Qt('<path d="M213.66,162.34l-80-80a8,8,0,0,0-11.32,0l-80,80A8,8,0,0,0,53.66,173.66L128,99.31l74.34,74.35a8,8,0,0,0,11.32-11.32Z"/>'),VD=Qt('<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"/>'),GD=Qt({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"/>'}),WD=Qt({regular:'<path d="M227.31,73.37,182.63,28.68a16,16,0,0,0-22.63,0L36.69,152A15.86,15.86,0,0,0,32,163.31V208a16,16,0,0,0,16,16H92.69A15.86,15.86,0,0,0,104,219.31L227.31,96a16,16,0,0,0,0-22.63ZM51.31,160,136,75.31,152.69,92,68,176.68ZM48,179.31,76.69,208H48Zm48,25.38L79.31,188,164,103.31,180.69,120Zm96-96L147.31,64l24-24L216,84.68Z"/>',bold:'<path d="M230.14,70.54,185.46,25.85a20,20,0,0,0-28.29,0L33.86,149.17A19.85,19.85,0,0,0,28,163.31V208a20,20,0,0,0,20,20H92.69a19.86,19.86,0,0,0,14.14-5.86L230.14,98.82a20,20,0,0,0,0-28.28ZM93,180l71-71,11,11-71,71ZM76,163,65,152l71-71,11,11ZM52,173l15.51,15.51h0L83,204H52ZM192,103,153,64l18.34-18.34,39,39Z"/>'}),qD=Qt({regular:'<path d="M216,48H176V40a24,24,0,0,0-24-24H104A24,24,0,0,0,80,40v8H40a8,8,0,0,0,0,16h8V208a16,16,0,0,0,16,16H192a16,16,0,0,0,16-16V64h8a8,8,0,0,0,0-16ZM96,40a8,8,0,0,1,8-8h48a8,8,0,0,1,8,8v8H96Zm96,168H64V64H192ZM112,104v64a8,8,0,0,1-16,0V104a8,8,0,0,1,16,0Zm48,0v64a8,8,0,0,1-16,0V104a8,8,0,0,1,16,0Z"/>',bold:'<path d="M216,44H176V40a24,24,0,0,0-24-24H104A24,24,0,0,0,80,40v4H40a12,12,0,0,0,0,24h4V208a20,20,0,0,0,20,20H192a20,20,0,0,0,20-20V68h4a12,12,0,0,0,0-24ZM104,40h48v4H104Zm84,164H68V68H188Zm-84-48V120a12,12,0,0,1,24,0v36a12,12,0,0,1-24,0Zm40,0V120a12,12,0,0,1,24,0v36a12,12,0,0,1-24,0Z"/>'});class Yv extends Event{constructor(n){super("dropdown-item-select",{bubbles:!0,composed:!0});b(this,"value");this.value=n}}class YD extends Event{constructor(n){super("select",{bubbles:!0,composed:!0});b(this,"value");this.value=n}}var Ke,ht,un,Jn,ne,_s,L,Jv,Vi,Xv,Qv,Mc,ey,Gi,Pn,Xn,ks,Es,xs,ka,ty,ny,Nc,Wi,ry,Uc,Mt;class Kv extends HTMLElement{constructor(){super();S(this,L);S(this,Ke,!1);S(this,ht,null);S(this,un,null);S(this,Jn);S(this,ne,null);S(this,_s,new MutationObserver(n=>g(this,L,ty).call(this,n)));S(this,Xn,()=>{g(this,L,Gi).call(this,!l(this,Ke))});S(this,ks,n=>{n.key!=="Enter"&&n.key!==" "||(n.preventDefault(),l(this,Xn).call(this))});S(this,Es,n=>{l(this,Ke)&&(n.composedPath().includes(this)||g(this,L,Gi).call(this,!1))});S(this,xs,n=>{n instanceof Yv&&(n.stopPropagation(),k(this,Ke,!1),g(this,L,Vi).call(this,n.value),g(this,L,Mt).call(this),this.dispatchEvent(new YD(n.value)))});S(this,ka,()=>{g(this,L,Nc).call(this)});k(this,Jn,this.attachShadow({mode:"open"})),jv(l(this,Jn))}connectedCallback(){this.addEventListener("dropdown-item-select",l(this,xs)),document.addEventListener("click",l(this,Es),!0),g(this,L,Jv).call(this),l(this,_s).observe(this,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["selected","value","slot"]}),g(this,L,Mt).call(this)}disconnectedCallback(){this.removeEventListener("dropdown-item-select",l(this,xs)),document.removeEventListener("click",l(this,Es),!0),l(this,_s).disconnect(),g(this,L,Uc).call(this)}attributeChangedCallback(n){if(n==="open"){g(this,L,Gi).call(this,this.hasAttribute("open"));return}g(this,L,Mt).call(this)}get open(){return l(this,Ke)}set open(n){this.toggleAttribute("open",n)}get title(){return this.getAttribute("title")??""}get placement(){return this.getAttribute("placement")==="top"?"top":"bottom"}get value(){return l(this,ht)}set value(n){n===null?(g(this,L,Pn).call(this,null,null),g(this,L,Xv).call(this)):g(this,L,Vi).call(this,n),g(this,L,Mt).call(this)}close(){g(this,L,Gi).call(this,!1)}}Ke=new WeakMap,ht=new WeakMap,un=new WeakMap,Jn=new WeakMap,ne=new WeakMap,_s=new WeakMap,L=new WeakSet,Jv=function(){var r;const n=this.querySelector("dropdown-item[selected]");n&&g(this,L,Pn).call(this,n.value,((r=n.textContent)==null?void 0:r.trim())??null)},Vi=function(n){var r;for(const i of l(this,L,Mc))i.value===n?(g(this,L,Pn).call(this,n,((r=i.textContent)==null?void 0:r.trim())??null),i.hasAttribute("selected")||i.setAttribute("selected","")):i.hasAttribute("selected")&&i.removeAttribute("selected")},Xv=function(){const n=this.querySelectorAll("dropdown-item[selected]");for(const r of n)r.removeAttribute("selected")},Qv=function(n){for(const r of l(this,L,Mc))if(r.value===n)return r;return null},Mc=function(){return this.querySelectorAll("dropdown-item")},ey=function(){return l(this,un)??this.title},Gi=function(n){l(this,Ke)!==n&&(k(this,Ke,n),g(this,L,Mt).call(this))},Pn=function(n,r){k(this,ht,n),k(this,un,r)},Xn=new WeakMap,ks=new WeakMap,Es=new WeakMap,xs=new WeakMap,ka=new WeakMap,ty=function(n){n.every(i=>i.target instanceof Element?i.target.closest('[slot="trigger"]')!==null:!1)||g(this,L,ny).call(this)},ny=function(){var r,i;const n=this.querySelector("dropdown-item[selected]");if(n){const s=n.value,o=((r=n.textContent)==null?void 0:r.trim())??null,a=l(this,ht)!==s||l(this,un)!==o;g(this,L,Pn).call(this,s,o),g(this,L,Vi).call(this,s),a?g(this,L,Mt).call(this):g(this,L,Wi).call(this);return}if(l(this,ht)!==null){const s=g(this,L,Qv).call(this,l(this,ht));if(s){const o=((i=s.textContent)==null?void 0:i.trim())??null,a=l(this,un)!==o;g(this,L,Pn).call(this,l(this,ht),o),g(this,L,Vi).call(this,l(this,ht)),a?g(this,L,Mt).call(this):g(this,L,Wi).call(this);return}}if(l(this,ht)!==null||l(this,un)!==null){g(this,L,Pn).call(this,null,null),g(this,L,Mt).call(this);return}g(this,L,Wi).call(this)},Nc=function(){const n=l(this,Jn).querySelector('slot[name="trigger"]'),r=n instanceof HTMLSlotElement?n.assignedElements()[0]??null:null;l(this,ne)!==r&&(g(this,L,Uc).call(this),k(this,ne,r),l(this,ne)&&(l(this,ne).addEventListener("click",l(this,Xn)),l(this,ne)instanceof HTMLButtonElement?l(this,ne).hasAttribute("type")||(l(this,ne).type="button"):(l(this,ne).hasAttribute("role")||l(this,ne).setAttribute("role","button"),l(this,ne).hasAttribute("tabindex")||(l(this,ne).tabIndex=0),l(this,ne).addEventListener("keydown",l(this,ks))))),g(this,L,Wi).call(this)},Wi=function(){l(this,ne)&&(l(this,ne).setAttribute("data-dropdown-trigger",""),l(this,ne).setAttribute("aria-haspopup","listbox"),l(this,ne).setAttribute("aria-expanded",l(this,Ke)?"true":"false"))},ry=function(){return this.placement==="top"?jD:qv},Uc=function(){l(this,ne)&&(l(this,ne).removeEventListener("click",l(this,Xn)),l(this,ne).removeEventListener("keydown",l(this,ks)),l(this,ne).removeAttribute("data-dropdown-trigger"),l(this,ne).removeAttribute("aria-haspopup"),l(this,ne).removeAttribute("aria-expanded"),k(this,ne,null))},Mt=function(){this.toggleAttribute("open",l(this,Ke)),Re(U`
|
|
69
|
+
<slot name="trigger" @slotchange=${l(this,ka)}>
|
|
70
|
+
<button
|
|
71
|
+
class="fallback-trigger"
|
|
72
|
+
part="trigger"
|
|
73
|
+
type="button"
|
|
74
|
+
aria-haspopup="listbox"
|
|
75
|
+
aria-expanded=${l(this,Ke)?"true":"false"}
|
|
76
|
+
@click=${l(this,Xn)}
|
|
77
|
+
>
|
|
78
|
+
<span class="trigger-label" part="trigger-label">${l(this,L,ey)}</span>
|
|
79
|
+
<span class="trigger-icon" part="trigger-icon" aria-hidden="true">
|
|
80
|
+
${l(this,L,ry).call(this,{size:16})}
|
|
81
|
+
</span>
|
|
82
|
+
</button>
|
|
83
|
+
</slot>
|
|
84
|
+
${l(this,Ke)?U`
|
|
85
|
+
<div
|
|
86
|
+
class="panel"
|
|
87
|
+
part="panel panel-${this.placement}"
|
|
88
|
+
role="listbox"
|
|
89
|
+
material="paper"
|
|
90
|
+
level="1"
|
|
91
|
+
>
|
|
92
|
+
<slot></slot>
|
|
93
|
+
</div>
|
|
94
|
+
`:null}
|
|
95
|
+
`,l(this,Jn)),queueMicrotask(()=>g(this,L,Nc).call(this))},b(Kv,"observedAttributes",["title","placement","open"]);class KD extends HTMLElement{}class JD extends HTMLElement{}class XD extends HTMLElement{}var fr,Fc,sy,$s,As;class iy extends HTMLElement{constructor(){super(...arguments);S(this,fr);S(this,$s,()=>{this.action||g(this,fr,sy).call(this)});S(this,As,n=>{n.key!=="Enter"&&n.key!==" "||(n.preventDefault(),this.click())})}connectedCallback(){this.hasAttribute("role")||this.setAttribute("role","option"),this.hasAttribute("tabindex")||(this.tabIndex=0),this.addEventListener("click",l(this,$s)),this.addEventListener("keydown",l(this,As)),g(this,fr,Fc).call(this)}disconnectedCallback(){this.removeEventListener("click",l(this,$s)),this.removeEventListener("keydown",l(this,As))}attributeChangedCallback(){g(this,fr,Fc).call(this)}get value(){return this.getAttribute("value")??""}get selected(){return this.hasAttribute("selected")}get action(){return this.hasAttribute("action")}}fr=new WeakSet,Fc=function(){if(this.action){this.setAttribute("role","button"),this.removeAttribute("aria-selected");return}this.setAttribute("role","option"),this.setAttribute("aria-selected",this.selected?"true":"false")},sy=function(){this.dispatchEvent(new Yv(this.value))},$s=new WeakMap,As=new WeakMap,b(iy,"observedAttributes",["action","selected","value"]);customElements.get("dropdown-menu")||customElements.define("dropdown-menu",Kv);customElements.get("dropdown-group")||customElements.define("dropdown-group",KD);customElements.get("dropdown-label")||customElements.define("dropdown-label",JD);customElements.get("dropdown-divider")||customElements.define("dropdown-divider",XD);customElements.get("dropdown-item")||customElements.define("dropdown-item",iy);class QD extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}var Ts,yn,Zc,Ea,Cs,Hc;class oy extends HTMLElement{constructor(){super();S(this,yn);S(this,Ts);S(this,Ea,n=>{n.target===n.currentTarget&&g(this,yn,Zc).call(this)});S(this,Cs,n=>{this.open&&n.key==="Escape"&&g(this,yn,Zc).call(this)});k(this,Ts,this.attachShadow({mode:"open"}))}connectedCallback(){document.addEventListener("keydown",l(this,Cs)),g(this,yn,Hc).call(this)}disconnectedCallback(){document.removeEventListener("keydown",l(this,Cs))}attributeChangedCallback(){g(this,yn,Hc).call(this)}get open(){return this.hasAttribute("open")}}Ts=new WeakMap,yn=new WeakSet,Zc=function(){this.dispatchEvent(new QD)},Ea=new WeakMap,Cs=new WeakMap,Hc=function(){Re(U`
|
|
96
|
+
${this.open?U`
|
|
97
|
+
<div class="backdrop" part="backdrop" @click=${l(this,Ea)}>
|
|
98
|
+
<slot></slot>
|
|
99
|
+
</div>
|
|
100
|
+
`:null}
|
|
101
|
+
`,l(this,Ts))},b(oy,"observedAttributes",["open"]);customElements.get("modal-overlay")||customElements.define("modal-overlay",oy);class eO extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}class tO extends HTMLElement{}var Is,Ps,Bc;class ay extends HTMLElement{constructor(){super();S(this,Ps);S(this,Is);k(this,Is,this.attachShadow({mode:"open"}))}connectedCallback(){g(this,Ps,Bc).call(this)}attributeChangedCallback(){g(this,Ps,Bc).call(this)}get closable(){return this.hasAttribute("closable")}}Is=new WeakMap,Ps=new WeakSet,Bc=function(){const n=this.querySelector("panel-page");Re(U`
|
|
102
|
+
<section class="panel" part="panel">
|
|
103
|
+
<header class="title-bar" part="header">
|
|
104
|
+
<h2 class="title" part="title">${(n==null?void 0:n.getAttribute("title"))??""}</h2>
|
|
105
|
+
${this.closable?U`
|
|
106
|
+
<button
|
|
107
|
+
type="button"
|
|
108
|
+
class="title-button"
|
|
109
|
+
part="button close-button"
|
|
110
|
+
aria-label="Close"
|
|
111
|
+
@click=${()=>this.dispatchEvent(new eO)}
|
|
112
|
+
>
|
|
113
|
+
<span class="close-icon" part="icon close-icon">${Wv({size:16})}</span>
|
|
114
|
+
</button>
|
|
115
|
+
`:null}
|
|
116
|
+
</header>
|
|
117
|
+
<slot></slot>
|
|
118
|
+
</section>
|
|
119
|
+
`,l(this,Is))},b(ay,"observedAttributes",["closable"]);customElements.get("panel-view")||customElements.define("panel-view",ay);customElements.get("panel-page")||customElements.define("panel-page",tO);class nO extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}const ef='a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])',Yl=4;var je,Vt,Qn,tt,Rs,Yr,re,cy,uy,jc,Ds,Os,er,hy,Vc,dy,py,Jo,Xo;class ly extends HTMLElement{constructor(){super();S(this,re);S(this,je,!1);S(this,Vt,null);S(this,Qn);S(this,tt,null);S(this,Rs,"bottom-start");S(this,Yr,!1);S(this,Ds,n=>{l(this,je)&&(l(this,Yr)||n.composedPath().includes(this)||(this.open=!1))});S(this,Os,n=>{if(l(this,je)){if(n.key==="Escape"){n.preventDefault(),this.open=!1;return}n.key==="Tab"&&g(this,re,hy).call(this,n)}});S(this,er,()=>{l(this,je)&&g(this,re,Jo).call(this)});k(this,Qn,this.attachShadow({mode:"open"})),jv(l(this,Qn))}connectedCallback(){this.hasAttribute("tone")||this.setAttribute("tone","light"),g(this,re,Xo).call(this)}disconnectedCallback(){g(this,re,jc).call(this)}attributeChangedCallback(n){n==="open"&&g(this,re,cy).call(this,this.hasAttribute("open"))}get open(){return l(this,je)}set open(n){this.toggleAttribute("open",n)}get anchor(){return l(this,Vt)}set anchor(n){l(this,Vt)!==n&&(k(this,Vt,n),l(this,je)&&g(this,re,Jo).call(this))}}je=new WeakMap,Vt=new WeakMap,Qn=new WeakMap,tt=new WeakMap,Rs=new WeakMap,Yr=new WeakMap,re=new WeakSet,cy=function(n){var r;l(this,je)!==n&&(k(this,je,n),n?(k(this,Yr,!0),setTimeout(()=>{k(this,Yr,!1)},0),g(this,re,Xo).call(this),g(this,re,uy).call(this),queueMicrotask(()=>{l(this,je)&&(g(this,re,Jo).call(this),g(this,re,py).call(this))})):(g(this,re,jc).call(this),g(this,re,Xo).call(this),(r=l(this,Vt))==null||r.focus(),this.dispatchEvent(new nO)))},uy=function(){document.addEventListener("click",l(this,Ds)),document.addEventListener("keydown",l(this,Os),!0),window.addEventListener("resize",l(this,er)),window.addEventListener("scroll",l(this,er),!0)},jc=function(){document.removeEventListener("click",l(this,Ds)),document.removeEventListener("keydown",l(this,Os),!0),window.removeEventListener("resize",l(this,er)),window.removeEventListener("scroll",l(this,er),!0)},Ds=new WeakMap,Os=new WeakMap,er=new WeakMap,hy=function(n){const r=g(this,re,Vc).call(this);if(r.length===0){n.preventDefault();return}const i=r[0],s=r[r.length-1],o=g(this,re,dy).call(this),a=o instanceof HTMLElement&&r.includes(o);n.shiftKey?(!a||o===i)&&(n.preventDefault(),s.focus()):(!a||o===s)&&(n.preventDefault(),i.focus())},Vc=function(){if(!l(this,tt))return[];const n=l(this,tt).querySelector("slot");if(!(n instanceof HTMLSlotElement))return[];const r=[];for(const i of n.assignedElements({flatten:!0}))if(i instanceof HTMLElement){i.matches(ef)&&r.push(i);for(const s of i.querySelectorAll(ef))r.push(s)}return r},dy=function(){var r;let n=document.activeElement;for(;n&&((r=n.shadowRoot)!=null&&r.activeElement);)n=n.shadowRoot.activeElement;return n},py=function(){var r;const n=g(this,re,Vc).call(this);n.length>0?n[0].focus():(r=l(this,tt))==null||r.focus()},Jo=function(){if(!l(this,je)||!l(this,Vt)||!l(this,tt))return;const n=l(this,Vt).getBoundingClientRect(),r=l(this,tt).getBoundingClientRect(),s=window.innerHeight-n.bottom,o=r.height+Yl,a=s<o&&n.top>o?"top-start":"bottom-start";k(this,Rs,a);const c=a==="bottom-start"?n.bottom+Yl:n.top-r.height-Yl,u=n.left;l(this,tt).style.top=`${c}px`,l(this,tt).style.left=`${u}px`,l(this,tt).setAttribute("data-placement",a)},Xo=function(){this.toggleAttribute("open",l(this,je)),Re(l(this,je)?U`<div
|
|
120
|
+
class="panel"
|
|
121
|
+
part="panel"
|
|
122
|
+
data-placement=${l(this,Rs)}
|
|
123
|
+
tabindex="-1"
|
|
124
|
+
role="dialog"
|
|
125
|
+
material="paper"
|
|
126
|
+
level="1"
|
|
127
|
+
>
|
|
128
|
+
<slot></slot>
|
|
129
|
+
</div>`:ae,l(this,Qn)),k(this,tt,l(this,Qn).querySelector(".panel"))},b(ly,"observedAttributes",["open"]);customElements.get("ui-popover")||customElements.define("ui-popover",ly);const rO=gt(),iO="No handler registered for update-content",sO="handleUpdateContent: handler already registered";function oO(t){return t instanceof Error&&typeof t.message=="string"?t.message:String(t)}const aO=wi(mt);var Kr,Jr,Xr,tr,nr,zs,Ce,Gc,fy,gy,qi,Wc,Rf;let lO=(Rf=class extends aO{constructor(n){super();S(this,Ce);S(this,Kr);S(this,Jr);S(this,Xr);S(this,tr,null);S(this,nr,null);S(this,zs,!1);k(this,Kr,n);const r=n.ownerDocument.defaultView;if(!r)throw new Error("ArtifactView: iframe has no owner window");k(this,Jr,r),k(this,Xr,i=>g(this,Ce,fy).call(this,i)),l(this,Jr).addEventListener("message",l(this,Xr))}get content(){return l(this,nr)}set content(n){g(this,Ce,Wc).call(this),k(this,nr,n),l(this,zs)&&g(this,Ce,Gc).call(this,n)}handleUpdateContent(n){if(g(this,Ce,Wc).call(this),l(this,tr)!==null)throw new Error(sO);k(this,tr,n)}dispose(){l(this,Jr).removeEventListener("message",l(this,Xr)),k(this,tr,null)}},Kr=new WeakMap,Jr=new WeakMap,Xr=new WeakMap,tr=new WeakMap,nr=new WeakMap,zs=new WeakMap,Ce=new WeakSet,Gc=function(n){const r={type:"content-updated",content:n};g(this,Ce,qi).call(this,r)},fy=function(n){if(this.disposed||n.source!==l(this,Kr).contentWindow)return;const r=n.data;if(uC(r)){k(this,zs,!0),this.dispatchEvent(new rO("ready")),l(this,nr)!==null&&g(this,Ce,Gc).call(this,l(this,nr));return}if(hC(r)){g(this,Ce,gy).call(this,r);return}},gy=async function(n){const r=l(this,tr);if(r===null){g(this,Ce,qi).call(this,{type:"response",id:n.id,error:{message:iO}});return}try{await r(n.content)}catch(i){if(this.disposed)return;g(this,Ce,qi).call(this,{type:"response",id:n.id,error:{message:oO(i)}});return}this.disposed||g(this,Ce,qi).call(this,{type:"response",id:n.id,result:{}})},qi=function(n){const r=l(this,Kr).contentWindow;r&&r.postMessage(n,"*")},Wc=function(){if(this.disposed)throw new Error("ArtifactView is disposed")},Rf);function cO(t=window){if(t.parent===t)return;let e=0,n=0;t.addEventListener("wheel",r=>{const i=r;e=i.clientX,n=i.clientY,t.parent.postMessage({type:"wheel",deltaX:i.deltaX,deltaY:i.deltaY,shiftKey:i.shiftKey},"*"),i.preventDefault()},{passive:!1}),t.addEventListener("message",r=>{var u,d;const i=r.data;if(i===null||typeof i!="object"||i.type!=="scroll")return;const s=i,o=typeof s.deltaX=="number"?s.deltaX:0,a=typeof s.deltaY=="number"?s.deltaY:0;let c=((d=(u=t.document).elementFromPoint)==null?void 0:d.call(u,e,n))??null;for(;c!==null;){const p=t.getComputedStyle(c);if(a!==0){const y=(p.overflowY==="auto"||p.overflowY==="scroll")&&c.scrollHeight>c.clientHeight,v=a>0?c.scrollTop+c.clientHeight<c.scrollHeight:c.scrollTop>0;if(y&&v){c.scrollBy(o,a);return}}if(o!==0){const y=(p.overflowX==="auto"||p.overflowX==="scroll")&&c.scrollWidth>c.clientWidth,v=o>0?c.scrollLeft+c.clientWidth<c.scrollWidth:c.scrollLeft>0;if(y&&v){c.scrollBy(o,a);return}}c=c.parentElement}t.scrollBy(o,a)})}function uO(){return`(${cO.toString()})(window);`}async function hO(t){const e=await fetch(t);if(!e.ok)throw new Error(`Failed to fetch artifact content: ${e.status}`);const n=await e.text(),r=new DOMParser().parseFromString(n,"text/html"),i=r.createElement("base");i.href=t,r.head.insertBefore(i,r.head.firstChild);const s=r.createElement("script");s.textContent=uO(),r.head.appendChild(s);const o=new Blob([`<!DOCTYPE html>
|
|
130
|
+
${r.documentElement.outerHTML}`],{type:"text/html"});return URL.createObjectURL(o)}const my=gt();class dO extends HTMLElement{constructor(){super(...arguments);b(this,"_artifact",null);b(this,"_viewURL",null);b(this,"_contentURL",null);b(this,"_screen",null);b(this,"_subscribedScreen",null);b(this,"_activeView",null);b(this,"_contentState",{kind:"idle"});b(this,"_fetchSequence",0);b(this,"_blobSequence",0);b(this,"_mountedViewURL",null);b(this,"_directRender",!1);b(this,"_blobURL",null);b(this,"handleScreenContentChanged",n=>{!this._artifact||n.artifactID!==this._artifact.id||this._activeView!==null&&this.refetchContent()})}set artifact(n){const r=this._artifact;this._artifact=n,this.render(),r!==null&&r!==n&&this.syncView()}get artifact(){return this._artifact}set viewURL(n){this._viewURL!==n&&(this._viewURL=n,this.syncView())}get viewURL(){return this._viewURL}set contentURL(n){this._contentURL!==n&&(this._contentURL=n,this.syncView())}get contentURL(){return this._contentURL}set screen(n){this._screen!==n&&(this._screen=n,this.syncScreenSubscription())}get screen(){return this._screen}set dragging(n){n?this.setAttribute("dragging","true"):this.removeAttribute("dragging")}get dragging(){return this.getAttribute("dragging")==="true"}get activeView(){return this._activeView}connectedCallback(){this.setAttribute("level","2"),this.render(),this.syncView(),this.syncScreenSubscription()}disconnectedCallback(){this.teardownView(),this.unsubscribeFromScreen()}handleClose(){this._artifact&&this.dispatchEvent(new my("close-artifact",{artifactID:this._artifact.id,bubbles:!0,composed:!0}))}syncView(){var n;if(this.isConnected){if(this._viewURL!==null){if(this._directRender&&this.teardownView(),this._mountedViewURL!==this._viewURL){this.teardownView(),this._contentState={kind:"loading"},this._mountedViewURL=this._viewURL,this.render();const r=this.querySelector("iframe.artifact-frame");if(!r){this._contentState={kind:"error"},this.render();return}this._activeView=new lO(r),this._activeView.handleUpdateContent(async i=>{await this.saveContent(i)}),this.loadBlobFrame(this._viewURL),this.startContentFetch();return}this._activeView!==null&&this.startContentFetch();return}if(this._contentURL!==null){this.teardownView(),this._directRender=!0,this._contentState={kind:"idle"},this.render(),((n=this._artifact)==null?void 0:n.status)==="committed"&&this.loadBlobFrame(this._contentURL);return}this.teardownView(),this._contentState={kind:"idle"},this.render()}}async saveContent(n){const r=this._screen,i=this._artifact;if(!r||!i)throw new Error("artifact-view: cannot save without a screen and artifact");await r.server.client.artifacts.putContent({artifactID:i.id,content:n})}syncScreenSubscription(){if(!this.isConnected){this.unsubscribeFromScreen();return}this._subscribedScreen!==this._screen&&(this.unsubscribeFromScreen(),this._screen!==null&&(this._screen.addEventListener("artifact-content-changed",this.handleScreenContentChanged),this._subscribedScreen=this._screen))}unsubscribeFromScreen(){this._subscribedScreen!==null&&(this._subscribedScreen.removeEventListener("artifact-content-changed",this.handleScreenContentChanged),this._subscribedScreen=null)}startContentFetch(){this._fetchSequence+=1;const n=this._fetchSequence,r=this._contentURL,i=this._activeView;if(!i||r===null){this._contentState={kind:"error"},this.render();return}this._contentState={kind:"loading"},(async()=>{try{const s=await fetch(r);if(n!==this._fetchSequence)return;if(!s.ok){this._contentState={kind:"error"},this.teardownView(),this.render();return}const o=await s.text();if(n!==this._fetchSequence||this._activeView!==i)return;this._activeView.content=o,this._contentState={kind:"ready"}}catch{if(n!==this._fetchSequence)return;this._contentState={kind:"error"},this.teardownView(),this.render()}})()}refetchContent(){this._fetchSequence+=1;const n=this._fetchSequence,r=this._contentURL,i=this._activeView;!i||r===null||(async()=>{try{const s=await fetch(r);if(n!==this._fetchSequence||!s.ok)return;const o=await s.text();if(n!==this._fetchSequence||this._activeView!==i)return;this._activeView.content=o}catch{}})()}loadBlobFrame(n){this._blobSequence+=1;const r=this._blobSequence;(async()=>{try{const i=await hO(n);if(r!==this._blobSequence){URL.revokeObjectURL(i);return}this._blobURL=i,this.render();const s=this.querySelector("iframe.artifact-frame");s&&(s.src=i)}catch{if(r!==this._blobSequence)return;this._contentState={kind:"error"},this.teardownView(),this.render()}})()}teardownView(){this._activeView!==null&&(this._activeView.dispose(),this._activeView=null),this._blobURL!==null&&(URL.revokeObjectURL(this._blobURL),this._blobURL=null),this._mountedViewURL=null,this._directRender=!1,this._fetchSequence+=1,this._blobSequence+=1}contentTemplate(){return this._contentState.kind==="error"?U`
|
|
131
|
+
<div class="artifact-content artifact-placeholder">
|
|
132
|
+
<em>Failed to load content</em>
|
|
133
|
+
</div>
|
|
134
|
+
`:this._viewURL!==null||this._directRender?U`
|
|
135
|
+
<iframe
|
|
136
|
+
class="artifact-frame artifact-content"
|
|
137
|
+
src=${this._blobURL??"about:blank"}
|
|
138
|
+
sandbox="allow-scripts"
|
|
139
|
+
></iframe>
|
|
140
|
+
`:U`
|
|
141
|
+
<div class="artifact-content artifact-placeholder">
|
|
142
|
+
<em>Artifact unavailable</em>
|
|
143
|
+
</div>
|
|
144
|
+
`}template(){const n=this._artifact;return U`
|
|
145
|
+
${this.contentTemplate()}
|
|
146
|
+
<footer class="artifact-title-bar" drag-handle material="glass">
|
|
147
|
+
<div class="artifact-title-group">
|
|
148
|
+
<span class="artifact-title-icon">${HD({size:16})}</span>
|
|
149
|
+
<span class="artifact-title">${n.title}</span>
|
|
150
|
+
</div>
|
|
151
|
+
<button
|
|
152
|
+
icon-only
|
|
153
|
+
variant="ghost"
|
|
154
|
+
class="artifact-close-btn"
|
|
155
|
+
@click=${()=>this.handleClose()}
|
|
156
|
+
aria-label="Close"
|
|
157
|
+
>
|
|
158
|
+
${Wv({size:16})}
|
|
159
|
+
</button>
|
|
160
|
+
</footer>
|
|
161
|
+
`}render(){this._artifact&&(this.setAttribute("type",this._artifact.type),Re(this.template(),this))}}customElements.define("artifact-view",dO);const ke=t=>({type:"px",...t}),Te=t=>({type:"unit",...t}),Po=2,pO=2;class fO{constructor(e){b(this,"basis");b(this,"min");b(this,"_gap");b(this,"_viewport");b(this,"_unit");this.basis=e.basis,this.min=e.min,this._viewport=e.viewport,this._gap=e.gap??ke({x:ge,y:ge});const n=this._viewport.x??cr,r=this._viewport.y??la,i=this._gap.x??ge,s=this._gap.y??ge,o=cr+i*pO,a=n<=o,c=a?n-i*Po:Math.min(cr,n-i*Po),u=a?r-s*Po:Math.min(la,r-s*Po),d=(c-i*(Pt-1))/Pt,p=(u-s*(Qe-1))/Qe,y=this.basis.x??0,v=this.basis.y??0,A=this.min.x??0,E=this.min.y??0;this._unit=ke(a?{x:Math.max(A,d),y:Math.max(E,p)}:{x:Math.max(A,Math.min(y,d)),y:Math.max(E,Math.min(v,p))})}get unit(){return this._unit}get viewport(){return this._viewport}get gap(){return this._gap}toUnits(e){return Te({x:e.x==null?void 0:e.x/(this._unit.x??1),y:e.y==null?void 0:e.y/(this._unit.y??1)})}toPixels(e){const n=this._unit.x??0,r=this._unit.y??0,i=this._gap.x??ge,s=this._gap.y??ge,o=e.x==null?void 0:e.x*n+Math.max(0,e.x-1)*i,a=e.y==null?void 0:e.y*r+Math.max(0,e.y-1)*s;return ke({x:o,y:a})}}const dr=1e-4,Wt=1e-6,gO=40,mO=24;function vy(t,e){return Math.max(0,t-e*2)}function yy(t){const e=[0];for(const n of t)e.push((e[e.length-1]??0)+n);return e}function by(t){const e=[0];for(let n=0;n<t.length;n+=1){const r=e[n]??0;e.push(r+t[n]+ge)}return e}function wy(t,e,n){if(e<0||e>=t.length)return 0;let r=0,i=0;for(let s=e;s<t.length;s+=1){const o=t[s],a=i===0?o:r+ge+o;if(a>n+dr)break;r=a,i+=1}return Math.max(1,i)}function vO(t,e,n){if(e<0||e>=t.length)return 0;let r=0,i=0;for(let s=e;s>=0;s-=1){const o=t[s],a=i===0?o:r+ge+o;if(a>n+dr)break;r=a,i+=1}return Math.max(1,i)}function yO(t,e){if(t.length===0)return 0;let n=0,r=0;for(let i=t.length-1;i>=0;i-=1){const s=t[i],o=r===0?s:n+ge+s;if(o>e+dr)break;n=o,r+=1}return Math.max(1,r)}function nh(t,e){if(t.length===0)return 0;const n=yO(t,e);return Math.max(0,t.length-n)}function tf(t,e,n){if(t.length===0)return 0;const r=wy(t,e,n),i=Math.min(t.length,e+r);if(i<=e)return 0;const s=t.slice(e,i);return s.reduce((o,a)=>o+a,0)+Math.max(0,s.length-1)*ge}function qc(t,e,n){const r=t[e]??0;return n-r}function zr(t,e,n,r,i){if(t.length===0)return 0;const s=nh(t,i),o=e[s]??0,a=Math.max(0,Math.min(o,n));let c=0;for(let H=0;H<s;H+=1){const N=e[H]??0,ce=e[H+1]??N;if(a>=N&&a<=ce+dr){c=H;break}c=H+1}const u=Math.min(c+1,s),d=e[c]??0,p=e[u]??d,y=Math.max(p-d,dr),v=u===c?0:(a-d)/y,A=by(t),E=tf(t,c,i),I=tf(t,u,i),Z=(r-E)/2,P=(r-I)/2,V=qc(A,c,Z),O=qc(A,u,P);return V+(O-V)*v}function nf(t,e,n,r,i){const s=nh(t,r),o=e[s]??0;let a=0,c=o;for(let u=0;u<gO;u+=1){const d=(a+c)/2;zr(t,e,d,n,r)>i?a=d:c=d}return(a+c)/2}function rf(t,e,n){const r=by(t),[i,s]=e,o=t.slice(i,s+1),a=o.reduce((u,d)=>u+d,0)+Math.max(0,o.length-1)*ge,c=(n-a)/2;return qc(r,i,c)}function bO(t,e,n){const r=wy(t,e,n);return[e,Math.min(t.length-1,e+r-1)]}function wO(t,e,n){const r=vO(t,e,n);return[Math.max(0,e-r+1),e]}function SO(t){const e=new Set,n=[];for(const r of t){const i=`${r.nodeRange[0]}:${r.nodeRange[1]}`;if(e.has(i))continue;const s=n[n.length-1];s&&Math.abs(s.anchor-r.anchor)<=Wt||(e.add(i),n.push(r))}return n}function _O(t){const{nodeCols:e,nodeWidthsPx:n,viewportWidthPx:r}=t;if(e.length===0||n.length===0)return{viewspans:[],minScroll:0,maxScroll:0};const i=t.gapPx??ge,s=vy(r,i),o=yy(e),a=nh(n,s),c=o[a]??0,u=[];for(let d=0;d<=a;d+=1){const p=bO(n,d,s),y=rf(n,p,r),v=nf(n,o,r,s,y);u.push({nodeRange:p,anchor:Math.max(0,Math.min(c,v))})}for(let d=n.length-1;d>=0;d-=1){const p=wO(n,d,s),y=`${p[0]}:${p[1]}`;if(u.some(E=>`${E.nodeRange[0]}:${E.nodeRange[1]}`===y))continue;const v=rf(n,p,r),A=nf(n,o,r,s,v);u.push({nodeRange:p,anchor:Math.max(0,Math.min(c,A))})}return u.sort((d,p)=>Math.abs(d.anchor-p.anchor)>Wt?d.anchor-p.anchor:d.nodeRange[0]!==p.nodeRange[0]?d.nodeRange[0]-p.nodeRange[0]:d.nodeRange[1]-p.nodeRange[1]),{viewspans:SO(u),minScroll:0,maxScroll:c}}function kO(t,e){var i;let n=0,r=Number.POSITIVE_INFINITY;for(let s=0;s<t.length;s+=1){const o=Math.abs((((i=t[s])==null?void 0:i.anchor)??0)-e);if(o+Wt<r){r=o,n=s;continue}Math.abs(o-r)<=Wt&&s<n&&(n=s)}return n}function EO(t,e,n){return n<=0?0:Math.max(0,Math.min(n-1,t+e))}function Oi(t,e,n){return Math.max(e,Math.min(n,t))}class xO extends mt{constructor(n){super();b(this,"_scroll",0);b(this,"minScroll",0);b(this,"maxScroll",0);b(this,"viewspans",[]);b(this,"activeViewspanIndex",null);b(this,"nodeWidthsPx",[]);b(this,"boundaryCols",[0]);b(this,"viewportWidthPx",0);b(this,"framedViewportWidthPx",0);this._scroll=(n==null?void 0:n.x)??0}get scroll(){return Te({x:this._scroll})}get translate(){return ke({x:zr(this.nodeWidthsPx,this.boundaryCols,this._scroll,this.viewportWidthPx,this.framedViewportWidthPx)})}set scroll(n){const r=Oi(n.x??this._scroll,this.minScroll,this.maxScroll);Math.abs(r-this._scroll)<=Wt||(this._scroll=r,this.activeViewspanIndex=null,this.dispatchEvent(new Ri("layout-scroll",{scroll:this.scroll})))}rebuild(n){const r=n.nodeWidths.map(u=>Math.max(0,u.x??0)),i=r.map(u=>n.grid.toPixels(Te({x:u})).x??0),s=n.grid.viewport.x??0,o=n.grid.gap.x??ge,a=_O({nodeCols:r,nodeWidthsPx:i,viewportWidthPx:s,gapPx:o});this.nodeWidthsPx=i,this.boundaryCols=yy(r),this.viewportWidthPx=s,this.framedViewportWidthPx=vy(s,o),this.viewspans=a.viewspans,this.minScroll=a.minScroll,this.maxScroll=a.maxScroll,this.activeViewspanIndex=null;const c=Oi(this._scroll,this.minScroll,this.maxScroll);Math.abs(c-this._scroll)>Wt&&(this._scroll=c,this.dispatchEvent(new Ri("layout-scroll",{scroll:this.scroll})))}step(n){var a;if(this.viewspans.length===0)return;const r=this.activeViewspanIndex??kO(this.viewspans,this._scroll),i=EO(r,n,this.viewspans.length),s=((a=this.viewspans[i])==null?void 0:a.anchor)??this._scroll,o=Oi(s,this.minScroll,this.maxScroll);this.activeViewspanIndex=i,!(Math.abs(o-this._scroll)<=Wt)&&(this._scroll=o,this.dispatchEvent(new Ri("layout-scroll",{scroll:this.scroll})))}wheel(n){const r=Oi(this._scroll+(n.x??0),this.minScroll,this.maxScroll);this.activeViewspanIndex=null,!(Math.abs(r-this._scroll)<=Wt)&&(this._scroll=r,this.dispatchEvent(new Ri("layout-scroll",{scroll:this.scroll})))}wheelPixels(n){const r=n.x??0;if(Math.abs(r)<=dr)return;this.activeViewspanIndex=null;const i=zr(this.nodeWidthsPx,this.boundaryCols,this._scroll,this.viewportWidthPx,this.framedViewportWidthPx),s=i-r,o=zr(this.nodeWidthsPx,this.boundaryCols,this.maxScroll,this.viewportWidthPx,this.framedViewportWidthPx),a=zr(this.nodeWidthsPx,this.boundaryCols,this.minScroll,this.viewportWidthPx,this.framedViewportWidthPx),c=Math.max(o,Math.min(a,s));if(Math.abs(c-i)<=dr)return;let u=this.minScroll,d=this.maxScroll;for(let y=0;y<mO;y+=1){const v=(u+d)/2;zr(this.nodeWidthsPx,this.boundaryCols,v,this.viewportWidthPx,this.framedViewportWidthPx)>c?u=v:d=v}const p=Oi((u+d)/2,this.minScroll,this.maxScroll);Math.abs(p-this._scroll)<=Wt||(this._scroll=p,this.dispatchEvent(new Ri("layout-scroll",{scroll:this.scroll})))}}const Kl={"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}},$O=["stack-above","stack-below","reorder-before","reorder-after"];function Jl(t,e){return{left:t.left+t.width*e.left,top:t.top+t.height*e.top,width:t.width*e.width,height:t.height*e.height}}function Cn(t,e,n){return t>=n.left&&t<n.left+n.width&&e>=n.top&&e<n.top+n.height}function rh(t,e){for(const n of t){if(n.type==="card"&&n.id===e)return n;if(n.type==="stack")for(const r of n.children){if(r.type==="card"&&r.id===e)return r;if(r.type==="row"){for(const i of r.children)if(i.id===e)return i}}}return null}function Yc(t){return t.height===Qe||t.height===fn?{...t,height:fn}:t}function Kc(t){return t.height===fn?{...t,height:Qe}:t}function AO(t,e,n,r){const i=t.findIndex(d=>d.type==="stack"&&d.id===e);if(i===-1)return t;const s=t[i];if(!s||s.type!=="stack")return t;const o=s.children.find(d=>d.type==="card"&&d.id===n);if(!o||o.type!=="card")return t;const a=s.children.filter(d=>d.id!==n);if(a.length===s.children.length||a.length<1)return t;const c=[...t];if(a.length===1){const[d]=a;c[i]=d.type==="card"?Kc(d):d}else c[i]={...s,children:a};const u=Math.max(0,Math.min(r,c.length));return c.splice(u,0,Kc(o)),c}const TO=gt(),CO=gt(),IO=50;function PO(t,e){if(t.type!==e.type)return!1;switch(t.type){case"reorder":return e.index===t.index;case"stack":return e.targetCardId===t.targetCardId&&e.position===t.position;case"stack-child-noop":return!0;case"stack-child-extract":return e.toIndex===t.toIndex;case"stack-child-reorder":return e.position===t.position;default:return!1}}function oo(t){return{id:t.id,type:"drop-target",width:t.width,height:t.height}}function sf(t){return t.map(DO)}function RO(t){return t.type==="drop-target"?{id:t.id,type:"card",artifactID:t.id,width:t.width,height:t.height}:t}function DO(t){return t.type==="drop-target"?{id:t.id,type:"card",artifactID:t.id,width:t.width,height:t.height}:t.type==="stack"?{...t,children:t.children.map(RO)}:t}function Sy(t,e){return t.find(r=>r.type==="card"&&r.id===e)??null}function of(t,e){return t.find(r=>r.type==="stack"&&r.id===e)??null}function OO(t,e){const n=[...e],r=n.findIndex(a=>a.type==="card"&&a.id===t.nodeId);if(r===-1)return null;const i=n[r];if(!i||i.type!=="card")return null;n.splice(r,1);const s=Math.max(0,Math.min(t.lastReorderIndex,n.length));n.splice(s,0,i);const o=n.findIndex(a=>a.type==="card"&&a.id===t.nodeId);return o===-1?null:{base:n,visualDraggedIndex:o}}function zO(t,e,n,r){const i=[...t.base];i.splice(t.visualDraggedIndex,1);const s=i.findIndex(y=>y.type==="card"&&y.id===n.targetCardId),o=s===-1?null:i[s];if(!o||o.type!=="card")return null;const a=Sy(r,e.nodeId);if(!a)return null;const c=Yc(a),u=Yc(o),d=oo(c),p=n.position==="above"?[d,u]:[u,d];return i[s]={id:o.id,type:"stack",children:p},i}function Xl(t,e){return t.parentStackId?MO(t,e):LO(t,e)}function LO(t,e){const n=t.hitTarget;if(n.type==="reorder"){const r=e[t.sourceIndex];if(!r||r.type!=="card")return[...e];const i=[...e];return i.splice(t.sourceIndex,1),i.splice(n.index,0,oo(r)),i}if(n.type==="stack"){const r=OO(t,e);return r?zO(r,t,n,e)??[...e]:[...e]}return[...e]}function MO(t,e){const n=t.hitTarget;switch(n.type){case"stack-child-reorder":return NO(t,e,n.position);case"stack-child-extract":return UO(t,e,n.toIndex);case"stack-child-noop":return FO(t,e);default:return[...e]}}function NO(t,e,n){const r=e.findIndex(y=>y.type==="stack"&&y.id===t.parentStackId);if(r===-1)return[...e];const i=e[r];if(!i||i.type!=="stack")return[...e];if(!i.children.every(y=>y.type==="card"))return[...e];const s=i.children,o=s.findIndex(y=>y.id===t.nodeId);if(o===-1)return[...e];const a=s[o],c=s.filter(y=>y.id!==t.nodeId),u=oo(a),d=n==="above"?[u,...c]:[...c,u],p=[...e];return p[r]={...i,children:d},p}function UO(t,e,n){if(!t.parentStackId)return[...e];const r=AO(e,t.parentStackId,t.nodeId,n);if(r===e)return[...e];const i=r.findIndex(a=>a.type==="card"&&a.id===t.nodeId);if(i===-1)return[...e];const s=r[i];if(!s||s.type!=="card")return[...e];const o=[...r];return o[i]=oo(s),o}function FO(t,e){const n=e.findIndex(c=>c.type==="stack"&&c.id===t.parentStackId);if(n===-1)return[...e];const r=e[n];if(!r||r.type!=="stack")return[...e];const i=r.children.findIndex(c=>c.type==="card"&&c.id===t.nodeId);if(i===-1)return[...e];const s=r.children[i];if(!s||s.type!=="card")return[...e];const o=[...e],a=[...r.children];return a[i]=oo(s),o[n]={...r,children:a},o}function ZO(t,e){return e.find(r=>r.type==="stack"&&r.id===t.id)?t.id:Mu()}function HO(t,e,n){if(t.type==="drop-target"){const r=rh(e,n);if(!r)throw new Error(`finalize: missing dragged card ${n}`);return Yc(r)}return t}function BO(t,e,n){const r=t.children.map(s=>HO(s,e,n));return{id:ZO(t,e),type:"stack",children:r}}function jO(t,e,n){if(t.type==="drop-target"){const r=rh(e,n);if(!r)throw new Error(`finalize: missing dragged card ${n}`);return Sy(e,n)!==null?r:Kc(r)}return t.type==="card"||t.type==="row"?t:BO(t,e,n)}function VO(t,e,n){return t.map(r=>jO(r,e,n))}function GO(t,e){return JSON.stringify(t)===JSON.stringify(e)}const WO=wi(mt);class qO extends WO{constructor(n={}){super();b(this,"pending",null);b(this,"active",null)}start(n){if(this.pending||this.active)return;const r=n.pointer.x??0,i=n.pointer.y??0;this.pending={startX:r,startY:i,grabOffsetX:n.grabOffset.x??0,grabOffsetY:n.grabOffset.y??0,nodeId:n.nodeId,sourceIndex:n.source.index,parentStackId:n.source.parentId,width:n.size.x??0,height:n.size.y??0,baseLayout:n.layout}}update(n){const r=n.pointer.x??0,i=n.pointer.y??0,s=this.pending;if(s){const u=r-s.startX,d=i-s.startY;Math.hypot(u,d)>=QE&&(this.pending=null,this.active={...s,pointerX:r,pointerY:i,hitTarget:{type:"reorder",index:s.sourceIndex},lastReorderIndex:s.sourceIndex},this.emitDrag(),this.dispatchEvent(new ee("change")));return}if(!this.active)return;const o=Xl(this.active,this.active.baseLayout),a=this.getHitTargetForPointer(r,i,n,o),c=a.type==="reorder"?a.index:this.active.lastReorderIndex;this.active.pointerX===r&&this.active.pointerY===i&&PO(this.active.hitTarget,a)&&this.active.lastReorderIndex===c||(this.active={...this.active,pointerX:r,pointerY:i,hitTarget:a,lastReorderIndex:c},this.emitDrag(),this.dispatchEvent(new ee("change")))}drop(){if(this.pending){this.cancel();return}if(!this.active)return;const n=this.active.baseLayout;let r=null;try{const i=Xl(this.active,n),s=VO(i,n,this.active.nodeId);GO(s,n)||(r=s)}catch{r=null}this.reset(),r&&this.dispatchEvent(new CO("drop",{layout:r})),this.dispatchEvent(new ee("change"))}cancel(){!this.pending&&!this.active||(this.reset(),this.dispatchEvent(new ee("change")))}dispose(){this.reset()}get status(){return this.active?"active":this.pending?"pending":"idle"}reset(){this.pending=null,this.active=null}emitDrag(){if(!this.active)return;const n=Xl(this.active,this.active.baseLayout);this.dispatchEvent(new TO("drag",{nodeId:this.active.nodeId,source:{index:this.active.sourceIndex,parentId:this.active.parentStackId},grabOffset:ke({x:this.active.grabOffsetX,y:this.active.grabOffsetY}),pointer:ke({x:this.active.pointerX,y:this.active.pointerY}),size:ke({x:this.active.width,y:this.active.height}),projectedLayout:n}))}getHitTargetForPointer(n,r,i,s){return this.active?this.isPointerInsideDragBounds(n,r,i.viewport)?this.active.parentStackId?this.getStackChildHitTarget(n,r,i,s):this.getTopLevelCardHitTarget(n,r,i,s):{type:"reorder",index:this.active.sourceIndex}:{type:"reorder",index:0}}getStackChildHitTarget(n,r,i,s){var u;if(!((u=this.active)!=null&&u.parentStackId))return{type:"stack-child-noop"};const o=this.getSourceStackInteractionRect(i.geometry);if(o&&Cn(n,r,o)){const d=o.top+o.height/2;return{type:"stack-child-reorder",position:r<d?"above":"below"}}const a=this.getSourceRemainingSiblingRect(i.geometry);if(a&&Cn(n,r,a)){const d=a.top+a.height/2;return{type:"stack-child-reorder",position:r<d?"above":"below"}}return{type:"stack-child-extract",toIndex:this.getTopLevelReorderIndexForPointer(n,r,i,s)}}getSourceRemainingSiblingRect(n){var s,o;if(!((s=this.active)!=null&&s.parentStackId))return;const r=of(this.active.baseLayout,this.active.parentStackId);if(!r)return;const i=r.children.find(a=>{var c;return a.type==="card"&&a.id!==((c=this.active)==null?void 0:c.nodeId)});if(i)return(o=n.find(a=>a.id===i.id))==null?void 0:o.rect}getSourceStackInteractionRect(n){var o;if(!((o=this.active)!=null&&o.parentStackId))return;const r=n.find(a=>{var c;return a.id===((c=this.active)==null?void 0:c.parentStackId)});if(r)return this.active.sourceStackRect=r.rect,r.rect;const i=of(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=n.find(c=>c.id===s.id);if(a)return a.rect}return this.active.sourceStackRect}getTopLevelCardHitTarget(n,r,i,s){var v,A,E;const o=this.getTopLevelZoneNodes(i.geometry,s);if(o.length===0)return{type:"reorder",index:((v=this.active)==null?void 0:v.sourceIndex)??0};const c=(i.effectiveVelocity??0)<=IO;for(const I of o){const Z=I.rect;if(!Cn(n,r,Z))continue;const P=this.resolveTopLevelTargetForCard(n,r,I,I.logicalIndex,c);if(P)return P;if(!c&&((A=this.active)!=null&&A.hitTarget))return this.active.hitTarget}const u=this.getNearestTargetableZone(n,o);if(!u)return{type:"reorder",index:((E=this.active)==null?void 0:E.sourceIndex)??0};const d=Math.max(u.rect.left,Math.min(u.rect.left+u.rect.width,n)),p=this.resolveTopLevelTargetForCard(d,r,u,u.logicalIndex,c);if(p)return p;const y=u.rect.left+u.rect.width/2;return{type:"reorder",index:n<y?u.logicalIndex:u.logicalIndex+1}}getTopLevelReorderIndexForPointer(n,r,i,s){var u,d;const o=this.getTopLevelZoneNodes(i.geometry,s);if(o.length===0)return((u=this.active)==null?void 0:u.sourceIndex)??0;for(const p of o){if(!Cn(n,r,p.rect))continue;const y=Jl(p.rect,Kl["reorder-before"]);if(Cn(n,r,y))return p.logicalIndex;const v=Jl(p.rect,Kl["reorder-after"]);if(Cn(n,r,v))return p.logicalIndex+1}const a=this.getNearestTargetableZone(n,o);if(!a)return((d=this.active)==null?void 0:d.sourceIndex)??0;const c=a.rect.left+a.rect.width/2;return n<c?a.logicalIndex:a.logicalIndex+1}getTopLevelZoneNodes(n,r){const i=new Map(r.map(a=>[a.id,a])),s=[];let o=0;for(const a of n){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(n,r,i,s,o){const a=i.rect;for(const c of $O){if(!o&&(c==="stack-above"||c==="stack-below"))continue;const u=Kl[c],d=Jl(a,u);if(Cn(n,r,d))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(n,r){let i=null,s=Number.POSITIVE_INFINITY;for(const o of r){const a=o.rect.left,c=o.rect.left+o.rect.width,u=n<a?a-n:n>c?n-c:0;u<s&&(s=u,i=o)}return i}isPointerInsideDragBounds(n,r,i){return n>=i.left&&n<=i.left+i.width&&r>=i.top&&r<=i.top+i.height}}const af=60,YO=80,lf=.5,cf=10;class KO{constructor(){b(this,"awaitingFreshWheelGesture",!1);b(this,"lastWheelEventAt",Number.NEGATIVE_INFINITY);b(this,"lastWheelDeltaX",0);b(this,"activeGestureType","none");b(this,"lastWheelGestureAt",Number.NEGATIVE_INFINITY)}markKeyboardNavigation(e){this.awaitingFreshWheelGesture=!0,this.lastWheelEventAt=e,this.activeGestureType="none"}reset(){this.awaitingFreshWheelGesture=!1,this.lastWheelEventAt=Number.NEGATIVE_INFINITY,this.lastWheelDeltaX=0,this.activeGestureType="none",this.lastWheelGestureAt=Number.NEGATIVE_INFINITY}decide(e){const{now:n,shiftKey:r,deltaX:i,deltaY:s,overArtifactContent:o}=e;n-this.lastWheelGestureAt>=af&&(this.activeGestureType="none");const c=r&&s!==0,u=c?s:i,d=Math.abs(u),p=Math.abs(s);return this.activeGestureType==="vertical-artifact"&&o?d>=lf&&d>=p*cf?this.classifyHorizontal(n,u):(this.lastWheelGestureAt=n,{type:"scroll-native"}):this.activeGestureType==="horizontal-filmstrip"?!c&&o&&p>0&&p>=d*cf?(this.activeGestureType="vertical-artifact",this.lastWheelGestureAt=n,{type:"scroll-native"}):this.classifyHorizontal(n,u):d<lf?(o&&(this.activeGestureType="vertical-artifact"),this.lastWheelGestureAt=n,{type:"scroll-native"}):c||d>p?this.classifyHorizontal(n,u):p>d?(o&&(this.activeGestureType="vertical-artifact"),this.lastWheelGestureAt=n,{type:"scroll-native"}):o?(this.activeGestureType="vertical-artifact",this.lastWheelGestureAt=n,{type:"scroll-native"}):this.classifyHorizontal(n,u)}classifyHorizontal(e,n){const r=e-this.lastWheelEventAt,i=Math.sign(this.lastWheelDeltaX),s=Math.sign(n),o=i!==0&&s!==0&&i!==s,a=i!==0&&Math.abs(n)>=Math.abs(this.lastWheelDeltaX)+YO;return this.awaitingFreshWheelGesture&&r<af&&!o&&!a?{type:"ignore"}:(this.lastWheelEventAt=e,this.lastWheelDeltaX=n,this.lastWheelGestureAt=e,this.awaitingFreshWheelGesture=!1,this.activeGestureType="horizontal-filmstrip",{type:"scroll-horizontal",horizontalDelta:n})}}const JO=2,uf=1e3,Ro=1e-4;function XO(t){return t.replace(/["\\]/g,"\\$&")}function hf(t,e,n){if(t===0)return 0;const r=e.toPixels(Te({y:Qe})).y??0;return(n-r)/JO}function Ql(t){const e=t.clientWidth>0?t.clientWidth:cr,n=t.clientHeight>0?t.clientHeight:la;let r=0,i=0;if(t.isConnected){const o=getComputedStyle(t);r=parseFloat(o.paddingTop)||0,i=parseFloat(o.paddingBottom)||0}const s=Math.max(1,n-r-i);return{width:e,height:s,offsetY:r}}class QO extends Event{constructor(n){super("scroll",{bubbles:!0,composed:!0});b(this,"scrollPosition");this.scrollPosition=n}}class _y extends Event{constructor(n){super("layout-change",{bubbles:!0,composed:!0});b(this,"layout");this.layout=n}}class e2 extends HTMLElement{constructor(){super();b(this,"_layout",[]);b(this,"_scrollPosition",0);b(this,"layoutGrid",null);b(this,"layoutScroll",new xO(Te({x:0})));b(this,"scrollModelKey","");b(this,"resizeObserver",null);b(this,"renderPending",!1);b(this,"animateNextRender",!0);b(this,"wheelGesture",new KO);b(this,"dragController",new qO);b(this,"dragState",null);b(this,"activeDragPointerId",null);b(this,"dragListenersAttached",!1);b(this,"dragFrame",0);b(this,"lastDragFrameTime",0);b(this,"lastPointerX",0);b(this,"lastPointerY",0);b(this,"pointerVelocityPxPerSec",0);b(this,"scrollVelocityPxPerSec",0);b(this,"motionSampleTime",0);b(this,"motionSampleX",0);b(this,"motionSampleY",0);b(this,"dragTrackOffsetXPx",0);b(this,"previousProjectedLayoutForOffset",null);b(this,"renderContent",()=>U``);b(this,"onDragControllerChange",()=>{this.dragController.status==="idle"&&(this.dragState=null,this.dragTrackOffsetXPx=0,this.previousProjectedLayoutForOffset=null),this.scheduleRender()});b(this,"onDragControllerDrag",n=>{const r=sf(n.projectedLayout),i=this.shouldApplyTrackOffset(n.projectedLayout,n.source.parentId),s=n.source.parentId?this.getStackChildAnchorCardId(n.source.parentId,n.nodeId):null;this.dragTrackOffsetXPx=i?this.computeDragTrackOffset(this.previousProjectedLayoutForOffset,r,n.nodeId,n.source.parentId,s,this.dragTrackOffsetXPx):0,this.previousProjectedLayoutForOffset=r,this.dragState={nodeId:n.nodeId,source:n.source,grabOffset:n.grabOffset,pointer:n.pointer,size:n.size,projectedLayout:n.projectedLayout},this.scheduleRender()});b(this,"onDragControllerDrop",n=>{this.dragState=null,this.dragTrackOffsetXPx=0,this.previousProjectedLayoutForOffset=null,this.commitLayout(n.layout)});b(this,"onLayoutScrollInternal",n=>{const i=n.scroll.x??0;Math.abs(i-this._scrollPosition)<Ro||(this._scrollPosition=i,this.emitScrollPositionChanged(i),this.scheduleRender())});b(this,"handleKeyDown",n=>{if(n.key==="Escape"&&this.dragController.status!=="idle"){n.preventDefault(),this.stopDragFrameLoop(),this.releaseActiveDragPointerCapture(),this.dragController.cancel(),this.detachDragListeners();return}this.dragController.status==="idle"&&(n.key==="ArrowRight"?(n.preventDefault(),this.wheelGesture.markKeyboardNavigation(Date.now()),this.shiftWindow(1)):n.key==="ArrowLeft"&&(n.preventDefault(),this.wheelGesture.markKeyboardNavigation(Date.now()),this.shiftWindow(-1)))});b(this,"handleWheel",n=>{if(this._layout.length===0)return;const r=this.wheelGesture.decide({now:Date.now(),shiftKey:n.shiftKey,deltaX:n.deltaX,deltaY:n.deltaY,overArtifactContent:!1});r.type==="scroll-horizontal"&&(n.preventDefault(),this.applyHorizontalWheel(r.horizontalDelta))});b(this,"handleWindowMessage",n=>{var o;if(this._layout.length===0)return;const r=this.findManagedArtifactFrame(n.source);if(!r||!this.isTrustedArtifactFrameMessage(n,r)||!dC(n.data))return;const i=this.wheelGesture.decide({now:Date.now(),shiftKey:n.data.shiftKey,deltaX:n.data.deltaX,deltaY:n.data.deltaY,overArtifactContent:!0});if(i.type==="scroll-horizontal"){this.applyHorizontalWheel(i.horizontalDelta);return}if(i.type!=="scroll-native")return;const s={type:"scroll",deltaX:0,deltaY:n.data.deltaY};(o=r.contentWindow)==null||o.postMessage(s,this.getArtifactFrameTargetOrigin(r))});b(this,"handlePointerDown",n=>{if(n.button!==0||this.dragController.status!=="idle")return;const r=n.target;if(!(r instanceof Element)||!r.closest("[drag-handle]")||r.closest("button, input, textarea, select, a, [role='button']"))return;const i=r.closest(".card-slot");if(!i)return;const s=i.getAttribute("data-layout-node-id");if(!s)return;const o=n2(this._layout,s);if(!o)return;const a=i.getBoundingClientRect();this.lastPointerX=n.clientX,this.lastPointerY=n.clientY,this.resetMotionTracking(n.clientX,n.clientY),this.focus(),this.dragController.start({nodeId:s,source:{index:o.topLevelIndex,parentId:o.sourceStackId},pointer:ke({x:n.clientX,y:n.clientY}),grabOffset:ke({x:n.clientX-a.left,y:n.clientY-a.top}),size:ke({x:a.width,y:a.height}),layout:this._layout}),this.attachDragListeners(),this.activeDragPointerId=n.pointerId;try{this.setPointerCapture(n.pointerId)}catch{}n.preventDefault()});b(this,"handleWindowPointerMove",n=>{this.lastPointerX=n.clientX,this.lastPointerY=n.clientY,this.updatePointerVelocity(n.clientX,n.clientY),this.syncDragTargetForLatestPointer(),this.ensureDragFrameLoop()});b(this,"handleWindowPointerUp",n=>{this.stopDragFrameLoop(),this.releasePointerCaptureForEvent(n.pointerId),this.dragController.drop(),this.clearMotionTracking(),this.detachDragListeners()});b(this,"handleWindowPointerCancel",n=>{this.stopDragFrameLoop(),this.releasePointerCaptureForEvent(n.pointerId),this.dragController.cancel(),this.clearMotionTracking(),this.detachDragListeners()});b(this,"handleWindowBlur",()=>{this.releaseActiveDragPointerCapture(),this.stopDragFrameLoop(),this.dragController.cancel(),this.clearMotionTracking(),this.detachDragListeners()});b(this,"runDragFrame",n=>{if(this.dragController.status==="idle"){this.dragFrame=0;return}const r=Math.max(0,n-this.lastDragFrameTime)/uf;this.lastDragFrameTime=n,this.samplePointerVelocityAt(n,this.lastPointerX,this.lastPointerY);const i=this.getBoundingClientRect(),s=this.clampPointerToViewport(this.lastPointerX,this.lastPointerY,i),o=this.getDragEdgeScrollDeltaPixels(s.x,i,r);this.scrollVelocityPxPerSec=r>Ro?Math.abs(o)/r:0,Math.abs(o)>Ro&&(this.animateNextRender=!1,this.layoutScroll.wheelPixels(ke({x:o}))),this.dragController.status==="active"&&this.syncDragTarget(s.x,s.y,i),this.dragFrame=requestAnimationFrame(this.runDragFrame)});this.dragController.addEventListener("change",this.onDragControllerChange),this.dragController.addEventListener("drag",this.onDragControllerDrag),this.dragController.addEventListener("drop",this.onDragControllerDrop),this.layoutScroll.addEventListener("layout-scroll",this.onLayoutScrollInternal)}set layout(n){this._layout=[...n],this.stopDragFrameLoop(),this.dragController.cancel(),this.scrollModelKey="",this.syncScrollModel(),this.layoutScroll.scroll=Te({x:this._scrollPosition}),this.scheduleRender()}get layout(){return this._layout}commitLayout(n){this.layout=n,this.emitLayoutChanged()}set scrollPosition(n){Math.abs(n-this._scrollPosition)<Ro||(this.animateNextRender=!1,this.syncScrollModel(),this.layoutScroll.scroll=Te({x:n}))}get scrollPosition(){return this._scrollPosition}focusArtifact(n){const r=Mr(this._layout),i=r.nodes.findIndex(o=>o.cards.some(a=>a.artifactID===n));if(i<0)return;let s=0;for(let o=0;o<i;o+=1)s+=r.nodes[o].width;this.scrollPosition=s,queueMicrotask(()=>{const o=this.querySelector(`.card-slot[data-layout-card-id="${XO(n)}"]`);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),window.addEventListener("message",this.handleWindowMessage),typeof ResizeObserver<"u"&&(this.resizeObserver=new ResizeObserver(()=>this.render()),this.resizeObserver.observe(this)),this.render()}disconnectedCallback(){var n;this.removeEventListener("keydown",this.handleKeyDown),this.removeEventListener("wheel",this.handleWheel),this.removeEventListener("pointerdown",this.handlePointerDown),window.removeEventListener("message",this.handleWindowMessage),(n=this.resizeObserver)==null||n.disconnect(),this.resizeObserver=null,this.wheelGesture.reset(),this.detachDragListeners(),this.dragController.removeEventListener("change",this.onDragControllerChange),this.dragController.removeEventListener("drag",this.onDragControllerDrag),this.dragController.removeEventListener("drop",this.onDragControllerDrop),this.layoutScroll.removeEventListener("layout-scroll",this.onLayoutScrollInternal),this.dragController.dispose(),this.stopDragFrameLoop()}scheduleRender(){this.renderPending||(this.renderPending=!0,queueMicrotask(()=>{this.renderPending=!1,this.render()}))}createGrid(n,r){return new fO({basis:ke({x:Dn,y:Dn}),min:ke({x:dp,y:dp}),viewport:ke({x:n,y:r}),gap:ke({x:ge,y:ge})})}syncScrollModel(){const n=Ql(this),i=Mr(this._layout).nodes.map(o=>o.width),s=`${n.width}x${n.height}:${i.join(",")}`;s===this.scrollModelKey&&this.layoutGrid||(this.scrollModelKey=s,this.layoutGrid=this.createGrid(n.width,n.height),this.layoutScroll.rebuild({grid:this.layoutGrid,nodeWidths:i.map(o=>Te({x:o}))}))}emitScrollPositionChanged(n){this.dispatchEvent(new QO(n))}emitLayoutChanged(){this.dispatchEvent(new _y([...this._layout]))}shiftWindow(n){this.syncScrollModel(),this.animateNextRender=!0,this.layoutScroll.step(n)}applyHorizontalWheel(n){this.syncScrollModel();const r=this.layoutGrid;if(!r)return;this.animateNextRender=!1;const i=r.toUnits(ke({x:n}));this.layoutScroll.wheel(Te({x:i.x??0}))}findManagedArtifactFrame(n){if(!n)return null;const r=this.querySelectorAll("iframe.artifact-frame");for(const i of r)if(i.contentWindow===n)return i;return null}isTrustedArtifactFrameMessage(n,r){if(n.origin==="null")return!0;const i=this.getArtifactFrameOrigin(r);return i===null||n.origin===i}getArtifactFrameTargetOrigin(n){const r=n.getAttribute("sandbox")??"";return new Set(r.split(/\s+/).filter(Boolean)).has("allow-same-origin")?this.getArtifactFrameOrigin(n)??"*":"*"}getArtifactFrameOrigin(n){const r=n.getAttribute("src")??n.src;if(!r)return null;try{return new URL(r,window.location.href).origin}catch{return null}}releaseActiveDragPointerCapture(){this.activeDragPointerId!==null&&this.releasePointerCaptureForEvent(this.activeDragPointerId)}releasePointerCaptureForEvent(n){try{this.hasPointerCapture(n)&&this.releasePointerCapture(n)}catch{}}attachDragListeners(){this.dragListenersAttached||(window.addEventListener("pointermove",this.handleWindowPointerMove),window.addEventListener("pointerup",this.handleWindowPointerUp),window.addEventListener("pointercancel",this.handleWindowPointerCancel),this.addEventListener("pointermove",this.handleWindowPointerMove),this.addEventListener("pointerup",this.handleWindowPointerUp),this.addEventListener("pointercancel",this.handleWindowPointerCancel),window.addEventListener("blur",this.handleWindowBlur),this.dragListenersAttached=!0)}detachDragListeners(){this.dragListenersAttached&&(window.removeEventListener("pointermove",this.handleWindowPointerMove),window.removeEventListener("pointerup",this.handleWindowPointerUp),window.removeEventListener("pointercancel",this.handleWindowPointerCancel),this.removeEventListener("pointermove",this.handleWindowPointerMove),this.removeEventListener("pointerup",this.handleWindowPointerUp),this.removeEventListener("pointercancel",this.handleWindowPointerCancel),window.removeEventListener("blur",this.handleWindowBlur),this.dragListenersAttached=!1,this.activeDragPointerId=null)}getDisplayModel(){if(this.dragController.status!=="active"||!this.dragState)return{layout:this._layout,activePlaceholderId:null,placeholdersById:new Map};const n=new Map;return n.set(this.dragState.nodeId,{id:this.dragState.nodeId,sourceCardId:this.dragState.nodeId}),{layout:sf(this.dragState.projectedLayout),activePlaceholderId:this.dragState.nodeId,placeholdersById:n}}render(){const n=Ql(this),r=this.createGrid(n.width,n.height);this.layoutGrid=r;const i=this.getDisplayModel(),s=i.layout,o=this.dragController.status==="active",a=Mr(s),c=a.nodes.map(O=>O.width),u=`${n.width}x${n.height}:${c.join(",")}`;!o&&u!==this.scrollModelKey&&(this.scrollModelKey=u,this.layoutScroll.rebuild({grid:r,nodeWidths:c.map(O=>Te({x:O}))}),this._scrollPosition=this.layoutScroll.scroll.x??this._scrollPosition);const d=t2(s),p=r.unit.x??Dn,y=r.unit.y??Dn,v=o?this.dragTrackOffsetXPx:0,A=(this.layoutScroll.translate.x??0)+v,E=hf(a.nodes.length,r,n.height),I=this.animateNextRender&&!o,Z=[`transform: translate(${A}px, ${E}px);`,`transition-duration: ${I?XE: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",`${y}px`),this.style.setProperty("--layout-gap",`${ge}px`);const P=this.dragState,V={width:(P==null?void 0:P.size.x)??0,height:(P==null?void 0:P.size.y)??0};Re(U`
|
|
162
|
+
<div class="track" style=${Z}>
|
|
163
|
+
${a.nodes.map((O,H)=>U`
|
|
164
|
+
<div
|
|
165
|
+
class="node"
|
|
166
|
+
layout-node=${String(H)}
|
|
167
|
+
data-layout-node-id=${O.id}
|
|
168
|
+
data-layout-placeholder=${String(i.activePlaceholderId===O.id)}
|
|
169
|
+
layout-node-cols=${String(O.width)}
|
|
170
|
+
style=${`grid-template-columns: repeat(${O.width}, var(--layout-unit-x)); width: ${r.toPixels(Te({x:O.width})).x}px;`}
|
|
171
|
+
>
|
|
172
|
+
${O.cards.map(N=>{const ce=i.placeholdersById.get(N.id);if(P&&ce)return U`
|
|
173
|
+
<div
|
|
174
|
+
class="card-slot card-placeholder"
|
|
175
|
+
data-layout-placeholder-for=${P.nodeId}
|
|
176
|
+
data-layout-placeholder-ghost="false"
|
|
177
|
+
data-layout-source-stack=${P.source.parentId??""}
|
|
178
|
+
style=${`grid-column: ${N.col} / span ${N.width}; grid-row: ${N.row} / span ${N.height};`}
|
|
179
|
+
></div>
|
|
180
|
+
`;const ue=d.get(N.id);return ue?U`
|
|
181
|
+
<div
|
|
182
|
+
class="card-slot"
|
|
183
|
+
data-layout-card-id=${N.artifactID}
|
|
184
|
+
data-layout-node-id=${N.id}
|
|
185
|
+
layout-cols=${String(N.width)}
|
|
186
|
+
layout-rows=${String(N.height)}
|
|
187
|
+
style=${`grid-column: ${N.col} / span ${N.width}; grid-row: ${N.row} / span ${N.height};`}
|
|
188
|
+
>
|
|
189
|
+
${this.renderContent(ue,{isDragging:!1})}
|
|
190
|
+
</div>
|
|
191
|
+
`:null})}
|
|
192
|
+
</div>
|
|
193
|
+
`)}
|
|
194
|
+
</div>
|
|
195
|
+
${P?(()=>{const O=this.getPlaceholderPixelSize(a,i.activePlaceholderId,r,V),H=P.pointer.x??0,N=P.pointer.y??0,ce=P.grabOffset.x??0,ue=P.grabOffset.y??0;return U`
|
|
196
|
+
<div
|
|
197
|
+
class="drag-preview"
|
|
198
|
+
data-layout-preview-card-id=${P.nodeId}
|
|
199
|
+
style=${[`width: ${O.width}px;`,`height: ${O.height}px;`,`left: ${H-ce}px;`,`top: ${N-ue}px;`].join(" ")}
|
|
200
|
+
>
|
|
201
|
+
${this.renderDraggedPreview(P.nodeId)}
|
|
202
|
+
</div>
|
|
203
|
+
`})():null}
|
|
204
|
+
`,this)}ensureDragFrameLoop(){this.dragFrame!==0||this.dragController.status==="idle"||(this.lastDragFrameTime=performance.now(),this.dragFrame=requestAnimationFrame(this.runDragFrame))}stopDragFrameLoop(){this.dragFrame!==0&&(cancelAnimationFrame(this.dragFrame),this.dragFrame=0,this.scrollVelocityPxPerSec=0)}syncDragTargetForLatestPointer(){if(this.dragController.status==="idle")return;const n=this.getBoundingClientRect();if(this.dragController.status==="active"){const i=this.clampPointerToViewport(this.lastPointerX,this.lastPointerY,n);this.syncDragTarget(i.x,i.y,n);return}if(this.syncDragTarget(this.lastPointerX,this.lastPointerY,n),this.dragController.status==="pending")return;const r=this.clampPointerToViewport(this.lastPointerX,this.lastPointerY,n);(r.x!==this.lastPointerX||r.y!==this.lastPointerY)&&this.syncDragTarget(r.x,r.y,n)}syncDragTarget(n,r,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:ke({x:n,y:r}),viewport:{left:i.left,top:i.top,width:i.width,height:i.height},geometry:c,effectiveVelocity:Math.max(this.pointerVelocityPxPerSec,this.scrollVelocityPxPerSec)})}resetMotionTracking(n,r){this.pointerVelocityPxPerSec=0,this.scrollVelocityPxPerSec=0,this.motionSampleTime=performance.now(),this.motionSampleX=n,this.motionSampleY=r}clearMotionTracking(){this.pointerVelocityPxPerSec=0,this.scrollVelocityPxPerSec=0,this.motionSampleTime=0}updatePointerVelocity(n,r){this.samplePointerVelocityAt(performance.now(),n,r)}samplePointerVelocityAt(n,r,i){if(this.motionSampleTime===0){this.motionSampleTime=n,this.motionSampleX=r,this.motionSampleY=i,this.pointerVelocityPxPerSec=0;return}const s=n-this.motionSampleTime;if(s<100)return;const o=r-this.motionSampleX;this.pointerVelocityPxPerSec=Math.abs(o)/s*uf,this.motionSampleTime=n,this.motionSampleX=r,this.motionSampleY=i}clampPointerToViewport(n,r,i){return{x:Math.max(i.left,Math.min(i.left+i.width,n)),y:Math.max(i.top,Math.min(i.top+i.height,r))}}isPointerOutsideViewport(n,r,i){return n<i.left||n>i.left+i.width||r<i.top||r>i.top+i.height}getDragEdgeScrollDeltaPixels(n,r,i){var u;const s=r.left+xo,o=r.left+r.width-xo,a=((u=this.layoutGrid)==null?void 0:u.unit.x)??Dn,c=ex*a;if(n<s){const d=Math.max(0,Math.min(1,(s-n)/xo));return-(c*d**pp)*i}if(n>o){const d=Math.max(0,Math.min(1,(n-o)/xo));return c*d**pp*i}return 0}measureLayoutGeometry(n,r,i=0){const s=this.layoutGrid;if(!s)return[];const o=Mr(n),a=new Map(o.nodes.map(E=>[E.id,E.width])),c=s.toPixels(Te({y:Qe})).y??la,u=Ql(this),d=(this.layoutScroll.translate.x??0)+i,p=hf(o.nodes.length,s,u.height),y=u.offsetY+p,v=[];let A=d;for(const E of n){const I=a.get(E.id)??Pt,Z=s.toPixels(Te({x:I})).x??cr,P={left:A,top:y,width:Z,height:c};v.push({id:E.id,rect:P}),A+=Z+ge}return v}getPlaceholderPixelSize(n,r,i,s){if(!r)return s;for(const o of n.nodes)for(const a of o.cards)if(a.id===r)return{width:i.toPixels(Te({x:a.width})).x??s.width,height:i.toPixels(Te({y:a.height})).y??s.height};return s}renderDraggedPreview(n){const r=rh(this._layout,n);return r?this.renderContent(r,{isDragging:!0}):U``}shouldApplyTrackOffset(n,r){if(r)return!0;for(const i of n){if(i.type!=="stack")continue;if(i.children.some(o=>o.type==="drop-target")&&r!==i.id)return!0}return!1}computeDragTrackOffset(n,r,i,s,o,a){if(!n)return a;const c=s?o??this.getStableAnchorCardId(n,r,i):this.getStableAnchorNodeId(n,r,i);if(!c)return a;const u=s?pf(n,c,this.layoutGrid):ff(n,c,this.layoutGrid),d=s?pf(r,c,this.layoutGrid):ff(r,c,this.layoutGrid);return u===null||d===null?a:a+(u-d)}getStableAnchorCardId(n,r,i){const s=df(n),o=new Set(df(r));for(const a of s)if(a!==i&&o.has(a))return a;return null}getStableAnchorNodeId(n,r,i){const s=new Set(r.map(o=>o.id));for(const o of n)if(o.id!==i&&s.has(o.id))return o.id;return null}getStackChildAnchorCardId(n,r){const i=this._layout.find(o=>o.type==="stack"&&o.id===n);if(!i||i.type!=="stack")return null;const s=i.children.find(o=>o.type==="card"&&o.id!==r);return(s==null?void 0:s.id)??null}}function t2(t){const e=new Map;for(const n of t){if(n.type==="card"){e.set(n.id,n);continue}for(const r of n.children)if(r.type==="card")e.set(r.id,r);else for(const i of r.children)e.set(i.id,i)}return e}function n2(t,e){const n=t.findIndex(r=>r.type==="card"&&r.id===e);if(n!==-1)return{topLevelIndex:n};for(let r=0;r<t.length;r+=1){const i=t[r];if(!(!i||i.type!=="stack")&&i.children.some(s=>s.type==="card"&&s.id===e))return{topLevelIndex:r,sourceStackId:i.id}}return null}function df(t){const e=[];for(const n of t){if(n.type==="card"){e.push(n.id);continue}if(n.type==="stack"){const r=n.children.find(i=>i.type==="card");r&&e.push(r.id)}}return e}function pf(t,e,n){if(!n)return null;const r=Mr(t),i=new Map(r.nodes.map(o=>[o.id,o.width]));let s=0;for(const o of t){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)??Pt,c=n.toPixels(Te({x:a})).x??cr;s+=c+ge}return null}function ff(t,e,n){if(!n)return null;const r=Mr(t),i=new Map(r.nodes.map(o=>[o.id,o.width]));let s=0;for(const o of t){if(o.id===e)return s;const a=i.get(o.id)??Pt,c=n.toPixels(Te({x:a})).x??cr;s+=c+ge}return null}customElements.get("layout-view")||customElements.define("layout-view",e2);class r2 extends HTMLElement{constructor(){super(...arguments);b(this,"screenManager",We.resolve("ScreenManager"));b(this,"boundModel",null);b(this,"handleActiveScreenChanged",()=>{this.rebindModel(),this.render()});b(this,"handleModelChange",()=>{this.render()});b(this,"handleCloseArtifact",n=>{n instanceof my&&this.screenManager.activeScreen&&this.screenManager.activeScreen.removeArtifact(n.artifactID)});b(this,"handleScrollPositionChanged",n=>{const r=n;typeof r.scrollPosition=="number"&&Number.isFinite(r.scrollPosition)&&this.screenManager.activeScreen&&this.screenManager.activeScreen.setScrollPosition(r.scrollPosition)});b(this,"handleLayoutChanged",n=>{n instanceof _y&&this.screenManager.activeScreen&&this.screenManager.activeScreen.setLayout(n.layout)});b(this,"handleServerEvent",n=>{const r=n.event;if(r.type!=="viewer-focus"||!this.boundModel||r.screenID!==this.boundModel.id)return;const i=this.querySelector("layout-view");i&&i.focusArtifact(r.artifactID)})}connectedCallback(){this.screenManager.addEventListener("active-screen-changed",this.handleActiveScreenChanged),this.rebindModel(),this.render()}disconnectedCallback(){this.screenManager.removeEventListener("active-screen-changed",this.handleActiveScreenChanged),this.unbindModel()}rebindModel(){const n=this.screenManager.activeScreen;this.boundModel!==n&&(this.unbindModel(),this.boundModel=n,n&&(n.addEventListener("change",this.handleModelChange),n.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 n=this.screenManager.activeScreen;return n?new Map(n.artifacts):new Map}render(){const n=this.screenManager.activeScreen,r=(n==null?void 0:n.layout)??[],i=this.buildArtifactMap();if(r.length===0){Re(U`<p data-testid="empty-screen" class="empty">
|
|
205
|
+
No artifacts yet. Create one by asking for something.
|
|
206
|
+
</p>`,this);return}Re(U`
|
|
207
|
+
<layout-view
|
|
208
|
+
.layout=${r}
|
|
209
|
+
.renderContent=${(o,a)=>{const c=i.get(o.artifactID);return!c||!n?U``:U`<artifact-view
|
|
210
|
+
.artifact=${c}
|
|
211
|
+
.screen=${n}
|
|
212
|
+
.viewURL=${n.server.getViewURL(c)}
|
|
213
|
+
.contentURL=${n.server.getContentURL(c.id)}
|
|
214
|
+
.dragging=${a.isDragging}
|
|
215
|
+
></artifact-view>`}}
|
|
216
|
+
.scrollPosition=${(n==null?void 0:n.scrollPosition)??0}
|
|
217
|
+
@scroll=${this.handleScrollPositionChanged}
|
|
218
|
+
@layout-change=${this.handleLayoutChanged}
|
|
219
|
+
@close-artifact=${this.handleCloseArtifact}
|
|
220
|
+
></layout-view>
|
|
221
|
+
`,this)}}customElements.define("screen-view",r2);var xa,Qr,Ls,Yt,ky,Ey,Jc;class i2 extends HTMLElement{constructor(){super(...arguments);S(this,Yt);S(this,xa,We.resolve("ScreenManager"));S(this,Qr,We.resolve("ServerManager"));S(this,Ls,()=>{g(this,Yt,Jc).call(this)})}connectedCallback(){l(this,Qr).addEventListener("change",l(this,Ls)),g(this,Yt,Jc).call(this)}disconnectedCallback(){l(this,Qr).removeEventListener("change",l(this,Ls))}}xa=new WeakMap,Qr=new WeakMap,Ls=new WeakMap,Yt=new WeakSet,ky=function(n,r){l(this,xa).setActive(n,r)},Ey=function(){for(const n of l(this,Qr).servers.values())return n;return null},Jc=function(){const n=g(this,Yt,Ey).call(this),i=(n?[...n.screens.values()]:[]).slice().sort((o,a)=>o.name.localeCompare(a.name,void 0,{sensitivity:"base"})),s=i.length===0?U`<p class="empty">No screens yet. Hit + to create one.</p>`:U`
|
|
222
|
+
<ul class="tiles">
|
|
223
|
+
${i.map(o=>U`
|
|
224
|
+
<li>
|
|
225
|
+
<button
|
|
226
|
+
class="tile"
|
|
227
|
+
type="button"
|
|
228
|
+
material="glass"
|
|
229
|
+
@click=${()=>n&&g(this,Yt,ky).call(this,n.url,o.id)}
|
|
230
|
+
>
|
|
231
|
+
${o.name}
|
|
232
|
+
</button>
|
|
233
|
+
</li>
|
|
234
|
+
`)}
|
|
235
|
+
</ul>
|
|
236
|
+
`;Re(s,this)};customElements.get("home-screen")||customElements.define("home-screen",i2);const ec=new WeakMap,gf=Object.prototype.hasOwnProperty,s2=(()=>{const t=new Set;let e=HTMLElement.prototype;for(;e;){for(const n of Object.getOwnPropertyNames(e))t.add(n);if(e===Node.prototype)break;e=Object.getPrototypeOf(e)}return t})();function o2(t,e){if(t===Boolean)return e!==null;if(e!==null)return t===Number?Number(e):e}var Ms,Xc,rr,nt,Ct,ei,ir,ti,Ie,Yi,xy,$y,Ay,Qo;const Ln=class Ln extends HTMLElement{constructor(){var i;super();S(this,Ie);S(this,rr,new Map);S(this,nt,new Map);S(this,Ct,new Map);S(this,ei,!1);S(this,ir,!1);S(this,ti,!1);const n=g(i=Ln,Ms,Xc).call(i,this.constructor),r=this;for(const s of n.properties)gf.call(r,s)&&(l(this,Ct).set(s,r[s]),delete r[s])}static get observedAttributes(){var n;return g(n=Ln,Ms,Xc).call(n,this).observedAttributes}connected(){}disconnected(){}changed(n){}connectedCallback(){if(g(this,Ie,Ay).call(this),!l(this,ir))for(const n of g(this,Ie,Yi).call(this).properties)l(this,nt).has(n)||l(this,nt).set(n,void 0);this.dispatchEvent(new Event("reactive:connect")),this.connected(),g(this,Ie,Qo).call(this)}disconnectedCallback(){this.dispatchEvent(new Event("reactive:disconnect")),this.disconnected()}attributeChangedCallback(n,r,i){if(r===i)return;const s=g(this,Ie,Yi).call(this).byAttr.get(n);s&&(l(this,Ct).has(s.property)||(this[s.property]=o2(s.type,i)))}};Ms=new WeakSet,Xc=function(n){const r=ec.get(n);if(r)return r;const i=[...n.properties??[]],s=n.attributes??{},o=new Map,a=new Map;for(const u of i)if(s2.has(u))throw new Error(`Reactive property "${u}" collides with a built-in DOM property. Rename it to avoid shadowing the platform API.`);for(const[u,d]of Object.entries(s)){if(u.includes("-")&&d.property===void 0)throw new Error(`Attribute "${u}" must declare a "property" name because kebab-case cannot be a property.`);const p=d.property??u;if(!i.includes(p))throw new Error(`Attribute '${u}' references property '${p}', which isn't declared in \`static properties\`. Add it to \`properties\` to make it reactive.`);const y={attribute:u,property:p,type:d.type};o.set(u,y),a.set(p,y)}for(const u of i){const d=Object.getOwnPropertyDescriptor(n.prototype,u);if((d==null?void 0:d.get)!==void 0||(d==null?void 0:d.set)!==void 0)throw new Error(`Observed property "${u}" cannot define a custom getter/setter. Use changed() for side effects instead.`);d===void 0&&Object.defineProperty(n.prototype,u,{configurable:!0,enumerable:!0,get(){return l(this,rr).get(u)},set(p){g(this,Ie,xy).call(this,u,p)}})}const c={properties:i,observedAttributes:Object.keys(s),byAttr:o,byProp:a};return ec.set(n,c),c},rr=new WeakMap,nt=new WeakMap,Ct=new WeakMap,ei=new WeakMap,ir=new WeakMap,ti=new WeakMap,Ie=new WeakSet,Yi=function(){return ec.get(this.constructor)},xy=function(n,r){if(!l(this,ti)&&l(this,Ct).has(n))return;const i=l(this,rr).get(n);Object.is(i,r)||(l(this,nt).has(n)||l(this,nt).set(n,i),l(this,rr).set(n,r),l(this,Ct).delete(n),g(this,Ie,$y).call(this,n,r),this.isConnected&&g(this,Ie,Qo).call(this))},$y=function(n,r){const i=g(this,Ie,Yi).call(this).byProp.get(n);if(!i)return;const{attribute:s,type:o}=i;if(o===Boolean){const c=this.hasAttribute(s);r&&!c?this.setAttribute(s,""):!r&&c&&this.removeAttribute(s);return}if(r==null){this.hasAttribute(s)&&this.removeAttribute(s);return}const a=String(r);this.getAttribute(s)!==a&&this.setAttribute(s,a)},Ay=function(){const n=this,r=g(this,Ie,Yi).call(this);for(const i of r.properties){if(!gf.call(n,i))continue;const s=n[i];delete n[i],!(l(this,Ct).has(i)||l(this,rr).has(i))&&(n[i]=s)}k(this,ti,!0);try{for(const[i,s]of l(this,Ct))n[i]=s;l(this,Ct).clear()}finally{k(this,ti,!1)}},Qo=function(){l(this,ei)||!this.isConnected||l(this,ir)&&l(this,nt).size===0||(k(this,ei,!0),queueMicrotask(()=>{if(k(this,ei,!1),!this.isConnected||l(this,ir)&&l(this,nt).size===0)return;const n=new Map(l(this,nt));l(this,nt).clear(),k(this,ir,!0);try{this.changed(n)}catch(r){console.error(r)}this.isConnected&&l(this,nt).size>0&&g(this,Ie,Qo).call(this)}))},S(Ln,Ms),b(Ln,"properties"),b(Ln,"attributes");let ls=Ln;/**
|
|
237
|
+
* @license
|
|
238
|
+
* Copyright 2020 Google LLC
|
|
239
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
240
|
+
*/const a2=t=>t.strings===void 0;/**
|
|
241
|
+
* @license
|
|
242
|
+
* Copyright 2017 Google LLC
|
|
243
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
244
|
+
*/const ns=(t,e)=>{var r;const n=t._$AN;if(n===void 0)return!1;for(const i of n)(r=i._$AO)==null||r.call(i,e,!1),ns(i,e);return!0},ma=t=>{let e,n;do{if((e=t._$AM)===void 0)break;n=e._$AN,n.delete(t),t=e}while((n==null?void 0:n.size)===0)},Ty=t=>{for(let e;e=t._$AM;t=e){let n=e._$AN;if(n===void 0)e._$AN=n=new Set;else if(n.has(t))break;n.add(t),u2(e)}};function l2(t){this._$AN!==void 0?(ma(this),this._$AM=t,Ty(this)):this._$AM=t}function c2(t,e=!1,n=0){const r=this._$AH,i=this._$AN;if(i!==void 0&&i.size!==0)if(e)if(Array.isArray(r))for(let s=n;s<r.length;s++)ns(r[s],!1),ma(r[s]);else r!=null&&(ns(r,!1),ma(r));else ns(this,t)}const u2=t=>{t.type==Vv.CHILD&&(t._$AP??(t._$AP=c2),t._$AQ??(t._$AQ=l2))};class h2 extends Gv{constructor(){super(...arguments),this._$AN=void 0}_$AT(e,n,r){super._$AT(e,n,r),Ty(this),this.isConnected=e._$AU}_$AO(e,n=!0){var r,i;e!==this.isConnected&&(this.isConnected=e,e?(r=this.reconnected)==null||r.call(this):(i=this.disconnected)==null||i.call(this)),n&&(ns(this,e),ma(this))}setValue(e){if(a2(this._$Ct))this._$Ct._$AI(e,this);else{const n=[...this._$Ct._$AH];n[this._$Ci]=e,this._$Ct._$AI(n,this,0)}}disconnected(){}reconnected(){}}/**
|
|
245
|
+
* @license
|
|
246
|
+
* Copyright 2020 Google LLC
|
|
247
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
248
|
+
*/const Do=()=>new d2;class d2{}const tc=new WeakMap,Oo=th(class extends h2{render(t){return ae}update(t,[e]){var r;const n=e!==this.G;return n&&this.G!==void 0&&this.rt(void 0),(n||this.lt!==this.ct)&&(this.G=e,this.ht=(r=t.options)==null?void 0:r.host,this.rt(this.ct=t.element)),ae}rt(t){if(this.isConnected||(t=void 0),typeof this.G=="function"){const e=this.ht??globalThis;let n=tc.get(e);n===void 0&&(n=new WeakMap,tc.set(e,n)),n.get(this.G)!==void 0&&this.G.call(this.ht,void 0),n.set(this.G,t),t!==void 0&&this.G.call(this.ht,t)}else this.G.value=t}get lt(){var t,e;return typeof this.G=="function"?(t=tc.get(this.ht??globalThis))==null?void 0:t.get(this.G):(e=this.G)==null?void 0:e.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}});var Je,hn,ni,ri,Ns,sr,or,ie,Pe,Cy,Us,Fs,Qc,eu,$a,Aa,Ta,Ca,Ia,Pa,Ra,Zs,Hs,Ki,Iy,dt;class p2 extends ls{constructor(){super(...arguments);S(this,Pe);S(this,Je,We.resolve("ScreenManager"));S(this,hn,null);S(this,ni,new DisposableStack);S(this,ri,Do());S(this,Ns,Do());S(this,sr,Do());S(this,or,Do());S(this,ie,{kind:"none"});S(this,Us,()=>{g(this,Pe,Qc).call(this),l(this,dt).call(this)});S(this,Fs,()=>{l(this,dt).call(this)});S(this,$a,()=>{l(this,Je).clearActive()});S(this,Aa,n=>{l(this,ie).kind!=="none"&&(n.stopImmediatePropagation(),g(this,Pe,Ki).call(this))});S(this,Ta,()=>{var r;const n=l(this,Je).activeScreen;n&&((r=l(this,ri).value)==null||r.close(),k(this,ie,{kind:"rename",draft:n.name}),l(this,dt).call(this))});S(this,Ca,()=>{var n;l(this,Je).activeScreen&&((n=l(this,ri).value)==null||n.close(),k(this,ie,{kind:"delete",error:null}),l(this,dt).call(this))});S(this,Ia,n=>{if(l(this,ie).kind!=="rename")return;const r=n.target;r instanceof HTMLInputElement&&k(this,ie,{kind:"rename",draft:r.value})});S(this,Pa,n=>{if(n.preventDefault(),l(this,ie).kind!=="rename")return;const r=l(this,Je).activeScreen;if(!r)return;const i=l(this,ie).draft.trim();i.length>0&&i!==r.name&&r.rename(i),g(this,Pe,Ki).call(this)});S(this,Ra,async()=>{if(l(this,ie).kind!=="delete")return;const n=l(this,Je).activeScreen;if(n){k(this,ie,{kind:"delete",error:null});try{await n.remove(),l(this,Je).clearActive(),g(this,Pe,Ki).call(this)}catch(r){k(this,ie,{kind:"delete",error:r instanceof Error?r.message:"Failed to delete screen."}),l(this,dt).call(this)}}});S(this,Zs,()=>{g(this,Pe,Ki).call(this)});S(this,Hs,()=>{l(this,ie).kind!=="none"&&(k(this,ie,{kind:"none"}),l(this,dt).call(this))});S(this,dt,()=>{const n=U`
|
|
249
|
+
<button
|
|
250
|
+
icon-only
|
|
251
|
+
variant="ghost"
|
|
252
|
+
class="home"
|
|
253
|
+
type="button"
|
|
254
|
+
aria-label="Home"
|
|
255
|
+
@click=${l(this,$a)}
|
|
256
|
+
>
|
|
257
|
+
${GD({weight:"fill"})}
|
|
258
|
+
</button>
|
|
259
|
+
`;Re(U`${n}${g(this,Pe,Iy).call(this)}`,this);const r=l(this,Ns).value??null;l(this,sr).value&&(l(this,sr).value.anchor=r),l(this,or).value&&(l(this,or).value.anchor=r)})}connected(){l(this,Je).addEventListener("active-screen-changed",l(this,Us)),g(this,Pe,Qc).call(this),l(this,dt).call(this),g(this,Pe,Cy).call(this),l(this,ni).defer(()=>{l(this,Je).removeEventListener("active-screen-changed",l(this,Us)),g(this,Pe,eu).call(this)})}disconnected(){l(this,ni).dispose(),k(this,ni,new DisposableStack)}}Je=new WeakMap,hn=new WeakMap,ni=new WeakMap,ri=new WeakMap,Ns=new WeakMap,sr=new WeakMap,or=new WeakMap,ie=new WeakMap,Pe=new WeakSet,Cy=async function(){const n=await Qu(this);this.setAttribute("tone",n)},Us=new WeakMap,Fs=new WeakMap,Qc=function(){var r;const n=l(this,Je).activeScreen;l(this,hn)!==n&&(g(this,Pe,eu).call(this),k(this,hn,n),(r=l(this,hn))==null||r.addEventListener("change",l(this,Fs)))},eu=function(){var n;(n=l(this,hn))==null||n.removeEventListener("change",l(this,Fs)),k(this,hn,null)},$a=new WeakMap,Aa=new WeakMap,Ta=new WeakMap,Ca=new WeakMap,Ia=new WeakMap,Pa=new WeakMap,Ra=new WeakMap,Zs=new WeakMap,Hs=new WeakMap,Ki=function(){const n=l(this,ie).kind==="rename"?l(this,sr).value:l(this,ie).kind==="delete"?l(this,or).value:null;n&&(n.open=!1),k(this,ie,{kind:"none"}),l(this,dt).call(this)},Iy=function(){const n=l(this,Je).activeScreen;if(!n)return null;const r=l(this,ie).kind==="rename"?l(this,ie).draft:"",i=l(this,ie).kind==="delete"?l(this,ie).error:null;return U`
|
|
260
|
+
<span class="separator" aria-hidden="true">
|
|
261
|
+
${BD()}
|
|
262
|
+
</span>
|
|
263
|
+
<dropdown-menu ${Oo(l(this,ri))}>
|
|
264
|
+
<button
|
|
265
|
+
slot="trigger"
|
|
266
|
+
type="button"
|
|
267
|
+
variant="ghost"
|
|
268
|
+
aria-label=${`Screen actions for ${n.name}`}
|
|
269
|
+
?data-active=${l(this,ie).kind!=="none"}
|
|
270
|
+
@click=${l(this,Aa)}
|
|
271
|
+
${Oo(l(this,Ns))}
|
|
272
|
+
>
|
|
273
|
+
${n.name}
|
|
274
|
+
</button>
|
|
275
|
+
<dropdown-group>
|
|
276
|
+
<dropdown-item action @click=${l(this,Ta)}>
|
|
277
|
+
${WD()} Rename
|
|
278
|
+
</dropdown-item>
|
|
279
|
+
<dropdown-item action danger @click=${l(this,Ca)}>
|
|
280
|
+
${qD()} Delete
|
|
281
|
+
</dropdown-item>
|
|
282
|
+
</dropdown-group>
|
|
283
|
+
</dropdown-menu>
|
|
284
|
+
<ui-popover
|
|
285
|
+
class="rename-popover"
|
|
286
|
+
?open=${l(this,ie).kind==="rename"}
|
|
287
|
+
@close=${l(this,Hs)}
|
|
288
|
+
${Oo(l(this,sr))}
|
|
289
|
+
>
|
|
290
|
+
<form class="screen-form" @submit=${l(this,Pa)}>
|
|
291
|
+
<label class="field">
|
|
292
|
+
<span>Screen name</span>
|
|
293
|
+
<input
|
|
294
|
+
type="text"
|
|
295
|
+
.value=${r}
|
|
296
|
+
@input=${l(this,Ia)}
|
|
297
|
+
/>
|
|
298
|
+
</label>
|
|
299
|
+
<div class="actions">
|
|
300
|
+
<button type="button" @click=${l(this,Zs)}>Cancel</button>
|
|
301
|
+
<button type="submit" variant="primary">Save</button>
|
|
302
|
+
</div>
|
|
303
|
+
</form>
|
|
304
|
+
</ui-popover>
|
|
305
|
+
<ui-popover
|
|
306
|
+
class="delete-popover"
|
|
307
|
+
?open=${l(this,ie).kind==="delete"}
|
|
308
|
+
@close=${l(this,Hs)}
|
|
309
|
+
${Oo(l(this,or))}
|
|
310
|
+
>
|
|
311
|
+
<div class="screen-form">
|
|
312
|
+
<p class="confirm-text">Delete "${n.name}"?</p>
|
|
313
|
+
${i?U`<p class="error">${i}</p>`:ae}
|
|
314
|
+
<div class="actions">
|
|
315
|
+
<button type="button" @click=${l(this,Zs)}>Cancel</button>
|
|
316
|
+
<button
|
|
317
|
+
type="button"
|
|
318
|
+
variant="danger"
|
|
319
|
+
@click=${l(this,Ra)}
|
|
320
|
+
>
|
|
321
|
+
Delete
|
|
322
|
+
</button>
|
|
323
|
+
</div>
|
|
324
|
+
</div>
|
|
325
|
+
</ui-popover>
|
|
326
|
+
`},dt=new WeakMap;customElements.define("screen-breadcrumb",p2);var Da,Oa,ii,bn,Py,Ry,za,Dy;class f2 extends HTMLElement{constructor(){super(...arguments);S(this,bn);S(this,Da,We.resolve("ServerManager"));S(this,Oa,We.resolve("ScreenManager"));S(this,ii,!1);S(this,za,async()=>{if(l(this,ii))return;const n=g(this,bn,Ry).call(this);if(n){k(this,ii,!0);try{const r=await n.createScreen(g2(new Date));l(this,Oa).setActive(n.url,r.id)}catch{}finally{k(this,ii,!1)}}})}connectedCallback(){g(this,bn,Dy).call(this),g(this,bn,Py).call(this)}}Da=new WeakMap,Oa=new WeakMap,ii=new WeakMap,bn=new WeakSet,Py=async function(){const n=await Qu(this);this.setAttribute("tone",n)},Ry=function(){for(const n of l(this,Da).servers.values())return n;return null},za=new WeakMap,Dy=function(){Re(U`
|
|
327
|
+
<button
|
|
328
|
+
icon-only
|
|
329
|
+
variant="ghost"
|
|
330
|
+
class="new-screen"
|
|
331
|
+
type="button"
|
|
332
|
+
aria-label="New screen"
|
|
333
|
+
@click=${l(this,za)}
|
|
334
|
+
>
|
|
335
|
+
${VD({size:16,weight:"bold"})}
|
|
336
|
+
</button>
|
|
337
|
+
`,this)};function g2(t){const e=t.toLocaleDateString("en-US",{month:"long",day:"numeric",year:"numeric"}),n=12,r=t.getHours(),i=r%n===0?n:r%n,s=t.getMinutes().toString().padStart(2,"0"),o=r>=n?"pm":"am";return`${e} at ${i}:${s}${o}`}customElements.define("screen-create-button",f2);function m2(t,e){let n=null;const r=()=>e((n==null?void 0:n.messages)??[]),i=()=>{const o=t.getActiveClient();o!==n&&(n==null||n.removeEventListener("change",r),n=o,n&&(n.addEventListener("change",r),n.connect().catch(a=>{console.error("ACPClient.connect() failed",a)})),r())};t.addEventListener("change",i),i();const s=()=>{t.removeEventListener("change",i),n==null||n.removeEventListener("change",r),n=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:Oy,setPrototypeOf:mf,isFrozen:v2,getPrototypeOf:y2,getOwnPropertyDescriptor:b2}=Object;let{freeze:Ue,seal:st,create:ea}=Object,{apply:tu,construct:nu}=typeof Reflect<"u"&&Reflect;Ue||(Ue=function(e){return e});st||(st=function(e){return e});tu||(tu=function(e,n){for(var r=arguments.length,i=new Array(r>2?r-2:0),s=2;s<r;s++)i[s-2]=arguments[s];return e.apply(n,i)});nu||(nu=function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return new e(...r)});const zo=Fe(Array.prototype.forEach),w2=Fe(Array.prototype.lastIndexOf),vf=Fe(Array.prototype.pop),zi=Fe(Array.prototype.push),S2=Fe(Array.prototype.splice),ta=Fe(String.prototype.toLowerCase),nc=Fe(String.prototype.toString),rc=Fe(String.prototype.match),Li=Fe(String.prototype.replace),_2=Fe(String.prototype.indexOf),k2=Fe(String.prototype.trim),Ye=Fe(Object.prototype.hasOwnProperty),ze=Fe(RegExp.prototype.test),Mi=E2(TypeError);function Fe(t){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return tu(t,e,r)}}function E2(t){return function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return nu(t,n)}}function j(t,e){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:ta;mf&&mf(t,null);let r=e.length;for(;r--;){let i=e[r];if(typeof i=="string"){const s=n(i);s!==i&&(v2(e)||(e[r]=s),i=s)}t[i]=!0}return t}function x2(t){for(let e=0;e<t.length;e++)Ye(t,e)||(t[e]=null);return t}function _t(t){const e=ea(null);for(const[n,r]of Oy(t))Ye(t,n)&&(Array.isArray(r)?e[n]=x2(r):r&&typeof r=="object"&&r.constructor===Object?e[n]=_t(r):e[n]=r);return e}function Ni(t,e){for(;t!==null;){const r=b2(t,e);if(r){if(r.get)return Fe(r.get);if(typeof r.value=="function")return Fe(r.value)}t=y2(t)}function n(){return null}return n}const yf=Ue(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),ic=Ue(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),sc=Ue(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),$2=Ue(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),oc=Ue(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),A2=Ue(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),bf=Ue(["#text"]),wf=Ue(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),ac=Ue(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),Sf=Ue(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Lo=Ue(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),T2=st(/\{\{[\w\W]*|[\w\W]*\}\}/gm),C2=st(/<%[\w\W]*|[\w\W]*%>/gm),I2=st(/\$\{[\w\W]*/gm),P2=st(/^data-[\-\w.\u00B7-\uFFFF]+$/),R2=st(/^aria-[\-\w]+$/),zy=st(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),D2=st(/^(?:\w+script|data):/i),O2=st(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Ly=st(/^html$/i),z2=st(/^[a-z][.\w]*(-[.\w]+)+$/i);var _f=Object.freeze({__proto__:null,ARIA_ATTR:R2,ATTR_WHITESPACE:O2,CUSTOM_ELEMENT:z2,DATA_ATTR:P2,DOCTYPE_NAME:Ly,ERB_EXPR:C2,IS_ALLOWED_URI:zy,IS_SCRIPT_OR_DATA:D2,MUSTACHE_EXPR:T2,TMPLIT_EXPR:I2});const Ui={element:1,text:3,progressingInstruction:7,comment:8,document:9},L2=function(){return typeof window>"u"?null:window},M2=function(e,n){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let r=null;const i="data-tt-policy-suffix";n&&n.hasAttribute(i)&&(r=n.getAttribute(i));const s="dompurify"+(r?"#"+r:"");try{return e.createPolicy(s,{createHTML(o){return o},createScriptURL(o){return o}})}catch{return console.warn("TrustedTypes policy "+s+" could not be created."),null}},kf=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function My(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:L2();const e=M=>My(M);if(e.version="3.3.3",e.removed=[],!t||!t.document||t.document.nodeType!==Ui.document||!t.Element)return e.isSupported=!1,e;let{document:n}=t;const r=n,i=r.currentScript,{DocumentFragment:s,HTMLTemplateElement:o,Node:a,Element:c,NodeFilter:u,NamedNodeMap:d=t.NamedNodeMap||t.MozNamedAttrMap,HTMLFormElement:p,DOMParser:y,trustedTypes:v}=t,A=c.prototype,E=Ni(A,"cloneNode"),I=Ni(A,"remove"),Z=Ni(A,"nextSibling"),P=Ni(A,"childNodes"),V=Ni(A,"parentNode");if(typeof o=="function"){const M=n.createElement("template");M.content&&M.content.ownerDocument&&(n=M.content.ownerDocument)}let O,H="";const{implementation:N,createNodeIterator:ce,createDocumentFragment:ue,getElementsByTagName:xi}=n,{importNode:lo}=r;let xe=kf();e.isSupported=typeof Oy=="function"&&typeof V=="function"&&N&&N.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:xn,ERB_EXPR:vt,TMPLIT_EXPR:en,DATA_ATTR:rl,ARIA_ATTR:co,IS_SCRIPT_OR_DATA:eb,ATTR_WHITESPACE:gh,CUSTOM_ELEMENT:tb}=_f;let{IS_ALLOWED_URI:mh}=_f,Se=null;const vh=j({},[...yf,...ic,...sc,...oc,...bf]);let $e=null;const yh=j({},[...wf,...ac,...Sf,...Lo]);let me=Object.seal(ea(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}})),$i=null,uo=null;const tn=Object.seal(ea(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let bh=!0,il=!0,wh=!1,Sh=!0,br=!1,ho=!0,$n=!1,sl=!1,ol=!1,wr=!1,po=!1,fo=!1,_h=!0,kh=!1;const nb="user-content-";let al=!0,Ai=!1,Sr={},yt=null;const ll=j({},["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 Eh=null;const xh=j({},["audio","video","img","source","image","track"]);let cl=null;const $h=j({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),go="http://www.w3.org/1998/Math/MathML",mo="http://www.w3.org/2000/svg",Rt="http://www.w3.org/1999/xhtml";let _r=Rt,ul=!1,hl=null;const rb=j({},[go,mo,Rt],nc);let vo=j({},["mi","mo","mn","ms","mtext"]),yo=j({},["annotation-xml"]);const ib=j({},["title","style","font","a","script"]);let Ti=null;const sb=["application/xhtml+xml","text/html"],ob="text/html";let be=null,kr=null;const ab=n.createElement("form"),Ah=function(m){return m instanceof RegExp||m instanceof Function},dl=function(){let m=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(kr&&kr===m)){if((!m||typeof m!="object")&&(m={}),m=_t(m),Ti=sb.indexOf(m.PARSER_MEDIA_TYPE)===-1?ob:m.PARSER_MEDIA_TYPE,be=Ti==="application/xhtml+xml"?nc:ta,Se=Ye(m,"ALLOWED_TAGS")?j({},m.ALLOWED_TAGS,be):vh,$e=Ye(m,"ALLOWED_ATTR")?j({},m.ALLOWED_ATTR,be):yh,hl=Ye(m,"ALLOWED_NAMESPACES")?j({},m.ALLOWED_NAMESPACES,nc):rb,cl=Ye(m,"ADD_URI_SAFE_ATTR")?j(_t($h),m.ADD_URI_SAFE_ATTR,be):$h,Eh=Ye(m,"ADD_DATA_URI_TAGS")?j(_t(xh),m.ADD_DATA_URI_TAGS,be):xh,yt=Ye(m,"FORBID_CONTENTS")?j({},m.FORBID_CONTENTS,be):ll,$i=Ye(m,"FORBID_TAGS")?j({},m.FORBID_TAGS,be):_t({}),uo=Ye(m,"FORBID_ATTR")?j({},m.FORBID_ATTR,be):_t({}),Sr=Ye(m,"USE_PROFILES")?m.USE_PROFILES:!1,bh=m.ALLOW_ARIA_ATTR!==!1,il=m.ALLOW_DATA_ATTR!==!1,wh=m.ALLOW_UNKNOWN_PROTOCOLS||!1,Sh=m.ALLOW_SELF_CLOSE_IN_ATTR!==!1,br=m.SAFE_FOR_TEMPLATES||!1,ho=m.SAFE_FOR_XML!==!1,$n=m.WHOLE_DOCUMENT||!1,wr=m.RETURN_DOM||!1,po=m.RETURN_DOM_FRAGMENT||!1,fo=m.RETURN_TRUSTED_TYPE||!1,ol=m.FORCE_BODY||!1,_h=m.SANITIZE_DOM!==!1,kh=m.SANITIZE_NAMED_PROPS||!1,al=m.KEEP_CONTENT!==!1,Ai=m.IN_PLACE||!1,mh=m.ALLOWED_URI_REGEXP||zy,_r=m.NAMESPACE||Rt,vo=m.MATHML_TEXT_INTEGRATION_POINTS||vo,yo=m.HTML_INTEGRATION_POINTS||yo,me=m.CUSTOM_ELEMENT_HANDLING||{},m.CUSTOM_ELEMENT_HANDLING&&Ah(m.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(me.tagNameCheck=m.CUSTOM_ELEMENT_HANDLING.tagNameCheck),m.CUSTOM_ELEMENT_HANDLING&&Ah(m.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(me.attributeNameCheck=m.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),m.CUSTOM_ELEMENT_HANDLING&&typeof m.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(me.allowCustomizedBuiltInElements=m.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),br&&(il=!1),po&&(wr=!0),Sr&&(Se=j({},bf),$e=ea(null),Sr.html===!0&&(j(Se,yf),j($e,wf)),Sr.svg===!0&&(j(Se,ic),j($e,ac),j($e,Lo)),Sr.svgFilters===!0&&(j(Se,sc),j($e,ac),j($e,Lo)),Sr.mathMl===!0&&(j(Se,oc),j($e,Sf),j($e,Lo))),Ye(m,"ADD_TAGS")||(tn.tagCheck=null),Ye(m,"ADD_ATTR")||(tn.attributeCheck=null),m.ADD_TAGS&&(typeof m.ADD_TAGS=="function"?tn.tagCheck=m.ADD_TAGS:(Se===vh&&(Se=_t(Se)),j(Se,m.ADD_TAGS,be))),m.ADD_ATTR&&(typeof m.ADD_ATTR=="function"?tn.attributeCheck=m.ADD_ATTR:($e===yh&&($e=_t($e)),j($e,m.ADD_ATTR,be))),m.ADD_URI_SAFE_ATTR&&j(cl,m.ADD_URI_SAFE_ATTR,be),m.FORBID_CONTENTS&&(yt===ll&&(yt=_t(yt)),j(yt,m.FORBID_CONTENTS,be)),m.ADD_FORBID_CONTENTS&&(yt===ll&&(yt=_t(yt)),j(yt,m.ADD_FORBID_CONTENTS,be)),al&&(Se["#text"]=!0),$n&&j(Se,["html","head","body"]),Se.table&&(j(Se,["tbody"]),delete $i.tbody),m.TRUSTED_TYPES_POLICY){if(typeof m.TRUSTED_TYPES_POLICY.createHTML!="function")throw Mi('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof m.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Mi('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');O=m.TRUSTED_TYPES_POLICY,H=O.createHTML("")}else O===void 0&&(O=M2(v,i)),O!==null&&typeof H=="string"&&(H=O.createHTML(""));Ue&&Ue(m),kr=m}},Th=j({},[...ic,...sc,...$2]),Ch=j({},[...oc,...A2]),lb=function(m){let T=V(m);(!T||!T.tagName)&&(T={namespaceURI:_r,tagName:"template"});const R=ta(m.tagName),se=ta(T.tagName);return hl[m.namespaceURI]?m.namespaceURI===mo?T.namespaceURI===Rt?R==="svg":T.namespaceURI===go?R==="svg"&&(se==="annotation-xml"||vo[se]):!!Th[R]:m.namespaceURI===go?T.namespaceURI===Rt?R==="math":T.namespaceURI===mo?R==="math"&&yo[se]:!!Ch[R]:m.namespaceURI===Rt?T.namespaceURI===mo&&!yo[se]||T.namespaceURI===go&&!vo[se]?!1:!Ch[R]&&(ib[R]||!Th[R]):!!(Ti==="application/xhtml+xml"&&hl[m.namespaceURI]):!1},bt=function(m){zi(e.removed,{element:m});try{V(m).removeChild(m)}catch{I(m)}},An=function(m,T){try{zi(e.removed,{attribute:T.getAttributeNode(m),from:T})}catch{zi(e.removed,{attribute:null,from:T})}if(T.removeAttribute(m),m==="is")if(wr||po)try{bt(T)}catch{}else try{T.setAttribute(m,"")}catch{}},Ih=function(m){let T=null,R=null;if(ol)m="<remove></remove>"+m;else{const ve=rc(m,/^[\r\n\t ]+/);R=ve&&ve[0]}Ti==="application/xhtml+xml"&&_r===Rt&&(m='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+m+"</body></html>");const se=O?O.createHTML(m):m;if(_r===Rt)try{T=new y().parseFromString(se,Ti)}catch{}if(!T||!T.documentElement){T=N.createDocument(_r,"template",null);try{T.documentElement.innerHTML=ul?H:se}catch{}}const De=T.body||T.documentElement;return m&&R&&De.insertBefore(n.createTextNode(R),De.childNodes[0]||null),_r===Rt?xi.call(T,$n?"html":"body")[0]:$n?T.documentElement:De},Ph=function(m){return ce.call(m.ownerDocument||m,m,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},pl=function(m){return m instanceof p&&(typeof m.nodeName!="string"||typeof m.textContent!="string"||typeof m.removeChild!="function"||!(m.attributes instanceof d)||typeof m.removeAttribute!="function"||typeof m.setAttribute!="function"||typeof m.namespaceURI!="string"||typeof m.insertBefore!="function"||typeof m.hasChildNodes!="function")},Rh=function(m){return typeof a=="function"&&m instanceof a};function Dt(M,m,T){zo(M,R=>{R.call(e,m,T,kr)})}const Dh=function(m){let T=null;if(Dt(xe.beforeSanitizeElements,m,null),pl(m))return bt(m),!0;const R=be(m.nodeName);if(Dt(xe.uponSanitizeElement,m,{tagName:R,allowedTags:Se}),ho&&m.hasChildNodes()&&!Rh(m.firstElementChild)&&ze(/<[/\w!]/g,m.innerHTML)&&ze(/<[/\w!]/g,m.textContent)||m.nodeType===Ui.progressingInstruction||ho&&m.nodeType===Ui.comment&&ze(/<[/\w]/g,m.data))return bt(m),!0;if(!(tn.tagCheck instanceof Function&&tn.tagCheck(R))&&(!Se[R]||$i[R])){if(!$i[R]&&zh(R)&&(me.tagNameCheck instanceof RegExp&&ze(me.tagNameCheck,R)||me.tagNameCheck instanceof Function&&me.tagNameCheck(R)))return!1;if(al&&!yt[R]){const se=V(m)||m.parentNode,De=P(m)||m.childNodes;if(De&&se){const ve=De.length;for(let Ze=ve-1;Ze>=0;--Ze){const Ot=E(De[Ze],!0);Ot.__removalCount=(m.__removalCount||0)+1,se.insertBefore(Ot,Z(m))}}}return bt(m),!0}return m instanceof c&&!lb(m)||(R==="noscript"||R==="noembed"||R==="noframes")&&ze(/<\/no(script|embed|frames)/i,m.innerHTML)?(bt(m),!0):(br&&m.nodeType===Ui.text&&(T=m.textContent,zo([xn,vt,en],se=>{T=Li(T,se," ")}),m.textContent!==T&&(zi(e.removed,{element:m.cloneNode()}),m.textContent=T)),Dt(xe.afterSanitizeElements,m,null),!1)},Oh=function(m,T,R){if(uo[T]||_h&&(T==="id"||T==="name")&&(R in n||R in ab))return!1;if(!(il&&!uo[T]&&ze(rl,T))){if(!(bh&&ze(co,T))){if(!(tn.attributeCheck instanceof Function&&tn.attributeCheck(T,m))){if(!$e[T]||uo[T]){if(!(zh(m)&&(me.tagNameCheck instanceof RegExp&&ze(me.tagNameCheck,m)||me.tagNameCheck instanceof Function&&me.tagNameCheck(m))&&(me.attributeNameCheck instanceof RegExp&&ze(me.attributeNameCheck,T)||me.attributeNameCheck instanceof Function&&me.attributeNameCheck(T,m))||T==="is"&&me.allowCustomizedBuiltInElements&&(me.tagNameCheck instanceof RegExp&&ze(me.tagNameCheck,R)||me.tagNameCheck instanceof Function&&me.tagNameCheck(R))))return!1}else if(!cl[T]){if(!ze(mh,Li(R,gh,""))){if(!((T==="src"||T==="xlink:href"||T==="href")&&m!=="script"&&_2(R,"data:")===0&&Eh[m])){if(!(wh&&!ze(eb,Li(R,gh,"")))){if(R)return!1}}}}}}}return!0},zh=function(m){return m!=="annotation-xml"&&rc(m,tb)},Lh=function(m){Dt(xe.beforeSanitizeAttributes,m,null);const{attributes:T}=m;if(!T||pl(m))return;const R={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:$e,forceKeepAttr:void 0};let se=T.length;for(;se--;){const De=T[se],{name:ve,namespaceURI:Ze,value:Ot}=De,Er=be(ve),fl=Ot;let Ae=ve==="value"?fl:k2(fl);if(R.attrName=Er,R.attrValue=Ae,R.keepAttr=!0,R.forceKeepAttr=void 0,Dt(xe.uponSanitizeAttribute,m,R),Ae=R.attrValue,kh&&(Er==="id"||Er==="name")&&(An(ve,m),Ae=nb+Ae),ho&&ze(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,Ae)){An(ve,m);continue}if(Er==="attributename"&&rc(Ae,"href")){An(ve,m);continue}if(R.forceKeepAttr)continue;if(!R.keepAttr){An(ve,m);continue}if(!Sh&&ze(/\/>/i,Ae)){An(ve,m);continue}br&&zo([xn,vt,en],Nh=>{Ae=Li(Ae,Nh," ")});const Mh=be(m.nodeName);if(!Oh(Mh,Er,Ae)){An(ve,m);continue}if(O&&typeof v=="object"&&typeof v.getAttributeType=="function"&&!Ze)switch(v.getAttributeType(Mh,Er)){case"TrustedHTML":{Ae=O.createHTML(Ae);break}case"TrustedScriptURL":{Ae=O.createScriptURL(Ae);break}}if(Ae!==fl)try{Ze?m.setAttributeNS(Ze,ve,Ae):m.setAttribute(ve,Ae),pl(m)?bt(m):vf(e.removed)}catch{An(ve,m)}}Dt(xe.afterSanitizeAttributes,m,null)},cb=function M(m){let T=null;const R=Ph(m);for(Dt(xe.beforeSanitizeShadowDOM,m,null);T=R.nextNode();)Dt(xe.uponSanitizeShadowNode,T,null),Dh(T),Lh(T),T.content instanceof s&&M(T.content);Dt(xe.afterSanitizeShadowDOM,m,null)};return e.sanitize=function(M){let m=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},T=null,R=null,se=null,De=null;if(ul=!M,ul&&(M="<!-->"),typeof M!="string"&&!Rh(M))if(typeof M.toString=="function"){if(M=M.toString(),typeof M!="string")throw Mi("dirty is not a string, aborting")}else throw Mi("toString is not a function");if(!e.isSupported)return M;if(sl||dl(m),e.removed=[],typeof M=="string"&&(Ai=!1),Ai){if(M.nodeName){const Ot=be(M.nodeName);if(!Se[Ot]||$i[Ot])throw Mi("root node is forbidden and cannot be sanitized in-place")}}else if(M instanceof a)T=Ih("<!---->"),R=T.ownerDocument.importNode(M,!0),R.nodeType===Ui.element&&R.nodeName==="BODY"||R.nodeName==="HTML"?T=R:T.appendChild(R);else{if(!wr&&!br&&!$n&&M.indexOf("<")===-1)return O&&fo?O.createHTML(M):M;if(T=Ih(M),!T)return wr?null:fo?H:""}T&&ol&&bt(T.firstChild);const ve=Ph(Ai?M:T);for(;se=ve.nextNode();)Dh(se),Lh(se),se.content instanceof s&&cb(se.content);if(Ai)return M;if(wr){if(po)for(De=ue.call(T.ownerDocument);T.firstChild;)De.appendChild(T.firstChild);else De=T;return($e.shadowroot||$e.shadowrootmode)&&(De=lo.call(r,De,!0)),De}let Ze=$n?T.outerHTML:T.innerHTML;return $n&&Se["!doctype"]&&T.ownerDocument&&T.ownerDocument.doctype&&T.ownerDocument.doctype.name&&ze(Ly,T.ownerDocument.doctype.name)&&(Ze="<!DOCTYPE "+T.ownerDocument.doctype.name+`>
|
|
338
|
+
`+Ze),br&&zo([xn,vt,en],Ot=>{Ze=Li(Ze,Ot," ")}),O&&fo?O.createHTML(Ze):Ze},e.setConfig=function(){let M=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};dl(M),sl=!0},e.clearConfig=function(){kr=null,sl=!1},e.isValidAttribute=function(M,m,T){kr||dl({});const R=be(M),se=be(m);return Oh(R,se,T)},e.addHook=function(M,m){typeof m=="function"&&zi(xe[M],m)},e.removeHook=function(M,m){if(m!==void 0){const T=w2(xe[M],m);return T===-1?void 0:S2(xe[M],T,1)[0]}return vf(xe[M])},e.removeHooks=function(M){xe[M]=[]},e.removeAllHooks=function(){xe=kf()},e}var Ny=My();function ih(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var yr=ih();function Uy(t){yr=t}var zn={exec:()=>null};function q(t,e=""){let n=typeof t=="string"?t:t.source,r={replace:(i,s)=>{let o=typeof s=="string"?s:s.source;return o=o.replace(Ne.caret,"$1"),n=n.replace(i,o),r},getRegex:()=>new RegExp(n,e)};return r}var N2=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),Ne={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:t=>new RegExp(`^( {0,3}${t})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}#`),htmlBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}<(?:[a-z].*>|!--)`,"i"),blockquoteBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}>`)},U2=/^(?:[ \t]*(?:\n|$))+/,F2=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Z2=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,ao=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,H2=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,sh=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Fy=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Zy=q(Fy).replace(/bull/g,sh).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(),B2=q(Fy).replace(/bull/g,sh).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]+)*)/,j2=/^[^\n]+/,ah=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,V2=q(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",ah).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),G2=q(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,sh).getRegex(),el="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",lh=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,W2=q("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",lh).replace("tag",el).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Hy=q(oh).replace("hr",ao).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",el).getRegex(),q2=q(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Hy).getRegex(),ch={blockquote:q2,code:F2,def:V2,fences:Z2,heading:H2,hr:ao,html:W2,lheading:Zy,list:G2,newline:U2,paragraph:Hy,table:zn,text:j2},Ef=q("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",ao).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",el).getRegex(),Y2={...ch,lheading:B2,table:Ef,paragraph:q(oh).replace("hr",ao).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Ef).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",el).getRegex()},K2={...ch,html:q(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",lh).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:zn,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:q(oh).replace("hr",ao).replace("heading",` *#{1,6} *[^
|
|
339
|
+
]`).replace("lheading",Zy).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},J2=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,X2=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,By=/^( {2,}|\\)\n(?!\s*$)/,Q2=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Ei=/[\p{P}\p{S}]/u,tl=/[\s\p{P}\p{S}]/u,uh=/[^\s\p{P}\p{S}]/u,ez=q(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,tl).getRegex(),jy=/(?!~)[\p{P}\p{S}]/u,tz=/(?!~)[\s\p{P}\p{S}]/u,nz=/(?:[^\s\p{P}\p{S}]|~)/u,rz=q(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",N2?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Vy=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,iz=q(Vy,"u").replace(/punct/g,Ei).getRegex(),sz=q(Vy,"u").replace(/punct/g,jy).getRegex(),Gy="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",oz=q(Gy,"gu").replace(/notPunctSpace/g,uh).replace(/punctSpace/g,tl).replace(/punct/g,Ei).getRegex(),az=q(Gy,"gu").replace(/notPunctSpace/g,nz).replace(/punctSpace/g,tz).replace(/punct/g,jy).getRegex(),lz=q("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,uh).replace(/punctSpace/g,tl).replace(/punct/g,Ei).getRegex(),cz=q(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,Ei).getRegex(),uz="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",hz=q(uz,"gu").replace(/notPunctSpace/g,uh).replace(/punctSpace/g,tl).replace(/punct/g,Ei).getRegex(),dz=q(/\\(punct)/,"gu").replace(/punct/g,Ei).getRegex(),pz=q(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),fz=q(lh).replace("(?:-->|$)","-->").getRegex(),gz=q("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",fz).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),va=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,mz=q(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",va).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Wy=q(/^!?\[(label)\]\[(ref)\]/).replace("label",va).replace("ref",ah).getRegex(),qy=q(/^!?\[(ref)\](?:\[\])?/).replace("ref",ah).getRegex(),vz=q("reflink|nolink(?!\\()","g").replace("reflink",Wy).replace("nolink",qy).getRegex(),xf=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,hh={_backpedal:zn,anyPunctuation:dz,autolink:pz,blockSkip:rz,br:By,code:X2,del:zn,delLDelim:zn,delRDelim:zn,emStrongLDelim:iz,emStrongRDelimAst:oz,emStrongRDelimUnd:lz,escape:J2,link:mz,nolink:qy,punctuation:ez,reflink:Wy,reflinkSearch:vz,tag:gz,text:Q2,url:zn},yz={...hh,link:q(/^!?\[(label)\]\((.*?)\)/).replace("label",va).getRegex(),reflink:q(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",va).getRegex()},ru={...hh,emStrongRDelimAst:az,emStrongLDelim:sz,delLDelim:cz,delRDelim:hz,url:q(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",xf).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:q(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",xf).getRegex()},bz={...ru,br:q(By).replace("{2,}","*").getRegex(),text:q(ru.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Mo={normal:ch,gfm:Y2,pedantic:K2},Fi={normal:hh,gfm:ru,breaks:bz,pedantic:yz},wz={"&":"&","<":"<",">":">",'"':""","'":"'"},$f=t=>wz[t];function kt(t,e){if(e){if(Ne.escapeTest.test(t))return t.replace(Ne.escapeReplace,$f)}else if(Ne.escapeTestNoEncode.test(t))return t.replace(Ne.escapeReplaceNoEncode,$f);return t}function Af(t){try{t=encodeURI(t).replace(Ne.percentDecode,"%")}catch{return null}return t}function Tf(t,e){var s;let n=t.replace(Ne.findPipe,(o,a,c)=>{let u=!1,d=a;for(;--d>=0&&c[d]==="\\";)u=!u;return u?"|":" |"}),r=n.split(Ne.splitPipe),i=0;if(r[0].trim()||r.shift(),r.length>0&&!((s=r.at(-1))!=null&&s.trim())&&r.pop(),e)if(r.length>e)r.splice(e);else for(;r.length<e;)r.push("");for(;i<r.length;i++)r[i]=r[i].trim().replace(Ne.slashPipe,"|");return r}function Zi(t,e,n){let r=t.length;if(r===0)return"";let i=0;for(;i<r&&t.charAt(r-i-1)===e;)i++;return t.slice(0,r-i)}function Sz(t,e){if(t.indexOf(e[1])===-1)return-1;let n=0;for(let r=0;r<t.length;r++)if(t[r]==="\\")r++;else if(t[r]===e[0])n++;else if(t[r]===e[1]&&(n--,n<0))return r;return n>0?-2:-1}function _z(t,e=0){let n=e,r="";for(let i of t)if(i===" "){let s=4-n%4;r+=" ".repeat(s),n+=s}else r+=i,n++;return r}function Cf(t,e,n,r,i){let s=e.href,o=e.title||null,a=t[1].replace(i.other.outputLinkReplace,"$1");r.state.inLink=!0;let c={type:t[0].charAt(0)==="!"?"image":"link",raw:n,href:s,title:o,text:a,tokens:r.inlineTokens(a)};return r.state.inLink=!1,c}function kz(t,e,n){let r=t.match(n.other.indentCodeCompensation);if(r===null)return e;let i=r[1];return e.split(`
|
|
340
|
+
`).map(s=>{let o=s.match(n.other.beginningSpace);if(o===null)return s;let[a]=o;return a.length>=i.length?s.slice(i.length):s}).join(`
|
|
341
|
+
`)}var ya=class{constructor(t){b(this,"options");b(this,"rules");b(this,"lexer");this.options=t||yr}space(t){let e=this.rules.block.newline.exec(t);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(t){let e=this.rules.block.code.exec(t);if(e){let n=e[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:e[0],codeBlockStyle:"indented",text:this.options.pedantic?n:Zi(n,`
|
|
342
|
+
`)}}}fences(t){let e=this.rules.block.fences.exec(t);if(e){let n=e[0],r=kz(n,e[3]||"",this.rules);return{type:"code",raw:n,lang:e[2]?e[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):e[2],text:r}}}heading(t){let e=this.rules.block.heading.exec(t);if(e){let n=e[2].trim();if(this.rules.other.endingHash.test(n)){let r=Zi(n,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(n=r.trim())}return{type:"heading",raw:e[0],depth:e[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(t){let e=this.rules.block.hr.exec(t);if(e)return{type:"hr",raw:Zi(e[0],`
|
|
343
|
+
`)}}blockquote(t){let e=this.rules.block.blockquote.exec(t);if(e){let n=Zi(e[0],`
|
|
344
|
+
`).split(`
|
|
345
|
+
`),r="",i="",s=[];for(;n.length>0;){let o=!1,a=[],c;for(c=0;c<n.length;c++)if(this.rules.other.blockquoteStart.test(n[c]))a.push(n[c]),o=!0;else if(!o)a.push(n[c]);else break;n=n.slice(c);let u=a.join(`
|
|
346
|
+
`),d=u.replace(this.rules.other.blockquoteSetextReplace,`
|
|
347
|
+
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");r=r?`${r}
|
|
348
|
+
${u}`:u,i=i?`${i}
|
|
349
|
+
${d}`:d;let p=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(d,s,!0),this.lexer.state.top=p,n.length===0)break;let y=s.at(-1);if((y==null?void 0:y.type)==="code")break;if((y==null?void 0:y.type)==="blockquote"){let v=y,A=v.raw+`
|
|
350
|
+
`+n.join(`
|
|
351
|
+
`),E=this.blockquote(A);s[s.length-1]=E,r=r.substring(0,r.length-v.raw.length)+E.raw,i=i.substring(0,i.length-v.text.length)+E.text;break}else if((y==null?void 0:y.type)==="list"){let v=y,A=v.raw+`
|
|
352
|
+
`+n.join(`
|
|
353
|
+
`),E=this.list(A);s[s.length-1]=E,r=r.substring(0,r.length-y.raw.length)+E.raw,i=i.substring(0,i.length-v.raw.length)+E.raw,n=A.substring(s.at(-1).raw.length).split(`
|
|
354
|
+
`);continue}}return{type:"blockquote",raw:r,tokens:s,text:i}}}list(t){var n,r;let e=this.rules.block.list.exec(t);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(;t;){let d=!1,p="",y="";if(!(e=a.exec(t))||this.rules.block.hr.test(t))break;p=e[0],t=t.substring(p.length);let v=_z(e[2].split(`
|
|
355
|
+
`,1)[0],e[1].length),A=t.split(`
|
|
356
|
+
`,1)[0],E=!v.trim(),I=0;if(this.options.pedantic?(I=2,y=v.trimStart()):E?I=e[1].length+1:(I=v.search(this.rules.other.nonSpaceChar),I=I>4?1:I,y=v.slice(I),I+=e[1].length),E&&this.rules.other.blankLine.test(A)&&(p+=A+`
|
|
357
|
+
`,t=t.substring(A.length+1),d=!0),!d){let Z=this.rules.other.nextBulletRegex(I),P=this.rules.other.hrRegex(I),V=this.rules.other.fencesBeginRegex(I),O=this.rules.other.headingBeginRegex(I),H=this.rules.other.htmlBeginRegex(I),N=this.rules.other.blockquoteBeginRegex(I);for(;t;){let ce=t.split(`
|
|
358
|
+
`,1)[0],ue;if(A=ce,this.options.pedantic?(A=A.replace(this.rules.other.listReplaceNesting," "),ue=A):ue=A.replace(this.rules.other.tabCharGlobal," "),V.test(A)||O.test(A)||H.test(A)||N.test(A)||Z.test(A)||P.test(A))break;if(ue.search(this.rules.other.nonSpaceChar)>=I||!A.trim())y+=`
|
|
359
|
+
`+ue.slice(I);else{if(E||v.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||V.test(v)||O.test(v)||P.test(v))break;y+=`
|
|
360
|
+
`+A}E=!A.trim(),p+=ce+`
|
|
361
|
+
`,t=t.substring(ce.length+1),v=ue.slice(I)}}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(y),loose:!1,text:y,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 d of o.items){if(this.lexer.state.top=!1,d.tokens=this.lexer.blockTokens(d.text,[]),d.task){if(d.text=d.text.replace(this.rules.other.listReplaceTask,""),((n=d.tokens[0])==null?void 0:n.type)==="text"||((r=d.tokens[0])==null?void 0:r.type)==="paragraph"){d.tokens[0].raw=d.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),d.tokens[0].text=d.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let y=this.lexer.inlineQueue.length-1;y>=0;y--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[y].src)){this.lexer.inlineQueue[y].src=this.lexer.inlineQueue[y].src.replace(this.rules.other.listReplaceTask,"");break}}let p=this.rules.other.listTaskCheckbox.exec(d.raw);if(p){let y={type:"checkbox",raw:p[0]+" ",checked:p[0]!=="[ ]"};d.checked=y.checked,o.loose?d.tokens[0]&&["paragraph","text"].includes(d.tokens[0].type)&&"tokens"in d.tokens[0]&&d.tokens[0].tokens?(d.tokens[0].raw=y.raw+d.tokens[0].raw,d.tokens[0].text=y.raw+d.tokens[0].text,d.tokens[0].tokens.unshift(y)):d.tokens.unshift({type:"paragraph",raw:y.raw,text:y.raw,tokens:[y]}):d.tokens.unshift(y)}}if(!o.loose){let p=d.tokens.filter(v=>v.type==="space"),y=p.length>0&&p.some(v=>this.rules.other.anyLine.test(v.raw));o.loose=y}}if(o.loose)for(let d of o.items){d.loose=!0;for(let p of d.tokens)p.type==="text"&&(p.type="paragraph")}return o}}html(t){let e=this.rules.block.html.exec(t);if(e)return{type:"html",block:!0,raw:e[0],pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:e[0]}}def(t){let e=this.rules.block.def.exec(t);if(e){let n=e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),r=e[2]?e[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",i=e[3]?e[3].substring(1,e[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):e[3];return{type:"def",tag:n,raw:e[0],href:r,title:i}}}table(t){var o;let e=this.rules.block.table.exec(t);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;let n=Tf(e[1]),r=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),i=(o=e[3])!=null&&o.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
362
|
+
`):[],s={type:"table",raw:e[0],header:[],align:[],rows:[]};if(n.length===r.length){for(let a of r)this.rules.other.tableAlignRight.test(a)?s.align.push("right"):this.rules.other.tableAlignCenter.test(a)?s.align.push("center"):this.rules.other.tableAlignLeft.test(a)?s.align.push("left"):s.align.push(null);for(let a=0;a<n.length;a++)s.header.push({text:n[a],tokens:this.lexer.inline(n[a]),header:!0,align:s.align[a]});for(let a of i)s.rows.push(Tf(a,s.header.length).map((c,u)=>({text:c,tokens:this.lexer.inline(c),header:!1,align:s.align[u]})));return s}}lheading(t){let e=this.rules.block.lheading.exec(t);if(e){let n=e[1].trim();return{type:"heading",raw:e[0],depth:e[2].charAt(0)==="="?1:2,text:n,tokens:this.lexer.inline(n)}}}paragraph(t){let e=this.rules.block.paragraph.exec(t);if(e){let n=e[1].charAt(e[1].length-1)===`
|
|
363
|
+
`?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:n,tokens:this.lexer.inline(n)}}}text(t){let e=this.rules.block.text.exec(t);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(t){let e=this.rules.inline.escape.exec(t);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(t){let e=this.rules.inline.tag.exec(t);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(t){let e=this.rules.inline.link.exec(t);if(e){let n=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;let s=Zi(n.slice(0,-1),"\\");if((n.length-s.length)%2===0)return}else{let s=Sz(e[2],"()");if(s===-2)return;if(s>-1){let o=(e[0].indexOf("!")===0?5:4)+e[1].length+s;e[2]=e[2].substring(0,s),e[0]=e[0].substring(0,o).trim(),e[3]=""}}let r=e[2],i="";if(this.options.pedantic){let s=this.rules.other.pedanticHrefTitle.exec(r);s&&(r=s[1],i=s[3])}else i=e[3]?e[3].slice(1,-1):"";return r=r.trim(),this.rules.other.startAngleBracket.test(r)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?r=r.slice(1):r=r.slice(1,-1)),Cf(e,{href:r&&r.replace(this.rules.inline.anyPunctuation,"$1"),title:i&&i.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer,this.rules)}}reflink(t,e){let n;if((n=this.rules.inline.reflink.exec(t))||(n=this.rules.inline.nolink.exec(t))){let r=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),i=e[r.toLowerCase()];if(!i){let s=n[0].charAt(0);return{type:"text",raw:s,text:s}}return Cf(n,i,n[0],this.lexer,this.rules)}}emStrong(t,e,n=""){let r=this.rules.inline.emStrongLDelim.exec(t);if(!(!r||!r[1]&&!r[2]&&!r[3]&&!r[4]||r[4]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[3])||!n||this.rules.inline.punctuation.exec(n))){let i=[...r[0]].length-1,s,o,a=i,c=0,u=r[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(u.lastIndex=0,e=e.slice(-1*t.length+i);(r=u.exec(e))!=null;){if(s=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!s)continue;if(o=[...s].length,r[3]||r[4]){a+=o;continue}else if((r[5]||r[6])&&i%3&&!((i+o)%3)){c+=o;continue}if(a-=o,a>0)continue;o=Math.min(o,o+a+c);let d=[...r[0]][0].length,p=t.slice(0,i+r.index+d+o);if(Math.min(i,o)%2){let v=p.slice(1,-1);return{type:"em",raw:p,text:v,tokens:this.lexer.inlineTokens(v)}}let y=p.slice(2,-2);return{type:"strong",raw:p,text:y,tokens:this.lexer.inlineTokens(y)}}}}codespan(t){let e=this.rules.inline.code.exec(t);if(e){let n=e[2].replace(this.rules.other.newLineCharGlobal," "),r=this.rules.other.nonSpaceChar.test(n),i=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return r&&i&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:e[0],text:n}}}br(t){let e=this.rules.inline.br.exec(t);if(e)return{type:"br",raw:e[0]}}del(t,e,n=""){let r=this.rules.inline.delLDelim.exec(t);if(r&&(!r[1]||!n||this.rules.inline.punctuation.exec(n))){let i=[...r[0]].length-1,s,o,a=i,c=this.rules.inline.delRDelim;for(c.lastIndex=0,e=e.slice(-1*t.length+i);(r=c.exec(e))!=null;){if(s=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!s||(o=[...s].length,o!==i))continue;if(r[3]||r[4]){a+=o;continue}if(a-=o,a>0)continue;o=Math.min(o,o+a);let u=[...r[0]][0].length,d=t.slice(0,i+r.index+u+o),p=d.slice(i,-i);return{type:"del",raw:d,text:p,tokens:this.lexer.inlineTokens(p)}}}}autolink(t){let e=this.rules.inline.autolink.exec(t);if(e){let n,r;return e[2]==="@"?(n=e[1],r="mailto:"+n):(n=e[1],r=n),{type:"link",raw:e[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}url(t){var n;let e;if(e=this.rules.inline.url.exec(t)){let r,i;if(e[2]==="@")r=e[0],i="mailto:"+r;else{let s;do s=e[0],e[0]=((n=this.rules.inline._backpedal.exec(e[0]))==null?void 0:n[0])??"";while(s!==e[0]);r=e[0],e[1]==="www."?i="http://"+e[0]:i=e[0]}return{type:"link",raw:e[0],text:r,href:i,tokens:[{type:"text",raw:r,text:r}]}}}inlineText(t){let e=this.rules.inline.text.exec(t);if(e){let n=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:e[0],escaped:n}}}},pt=class iu{constructor(e){b(this,"tokens");b(this,"options");b(this,"state");b(this,"inlineQueue");b(this,"tokenizer");this.tokens=[],this.tokens.links=Object.create(null),this.options=e||yr,this.options.tokenizer=this.options.tokenizer||new ya,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let n={other:Ne,block:Mo.normal,inline:Fi.normal};this.options.pedantic?(n.block=Mo.pedantic,n.inline=Fi.pedantic):this.options.gfm&&(n.block=Mo.gfm,this.options.breaks?n.inline=Fi.breaks:n.inline=Fi.gfm),this.tokenizer.rules=n}static get rules(){return{block:Mo,inline:Fi}}static lex(e,n){return new iu(n).lex(e)}static lexInline(e,n){return new iu(n).inlineTokens(e)}lex(e){e=e.replace(Ne.carriageReturn,`
|
|
364
|
+
`),this.blockTokens(e,this.tokens);for(let n=0;n<this.inlineQueue.length;n++){let r=this.inlineQueue[n];this.inlineTokens(r.src,r.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,n=[],r=!1){var i,s,o;for(this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(Ne.tabCharGlobal," ").replace(Ne.spaceLine,""));e;){let a;if((s=(i=this.options.extensions)==null?void 0:i.block)!=null&&s.some(u=>(a=u.call({lexer:this},e,n))?(e=e.substring(a.raw.length),n.push(a),!0):!1))continue;if(a=this.tokenizer.space(e)){e=e.substring(a.raw.length);let u=n.at(-1);a.raw.length===1&&u!==void 0?u.raw+=`
|
|
365
|
+
`:n.push(a);continue}if(a=this.tokenizer.code(e)){e=e.substring(a.raw.length);let u=n.at(-1);(u==null?void 0:u.type)==="paragraph"||(u==null?void 0:u.type)==="text"?(u.raw+=(u.raw.endsWith(`
|
|
366
|
+
`)?"":`
|
|
367
|
+
`)+a.raw,u.text+=`
|
|
368
|
+
`+a.text,this.inlineQueue.at(-1).src=u.text):n.push(a);continue}if(a=this.tokenizer.fences(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.heading(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.hr(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.blockquote(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.list(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.html(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.def(e)){e=e.substring(a.raw.length);let u=n.at(-1);(u==null?void 0:u.type)==="paragraph"||(u==null?void 0:u.type)==="text"?(u.raw+=(u.raw.endsWith(`
|
|
369
|
+
`)?"":`
|
|
370
|
+
`)+a.raw,u.text+=`
|
|
371
|
+
`+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},n.push(a));continue}if(a=this.tokenizer.table(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.lheading(e)){e=e.substring(a.raw.length),n.push(a);continue}let c=e;if((o=this.options.extensions)!=null&&o.startBlock){let u=1/0,d=e.slice(1),p;this.options.extensions.startBlock.forEach(y=>{p=y.call({lexer:this},d),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=n.at(-1);r&&(u==null?void 0:u.type)==="paragraph"?(u.raw+=(u.raw.endsWith(`
|
|
372
|
+
`)?"":`
|
|
373
|
+
`)+a.raw,u.text+=`
|
|
374
|
+
`+a.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=u.text):n.push(a),r=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=n.at(-1);(u==null?void 0:u.type)==="text"?(u.raw+=(u.raw.endsWith(`
|
|
375
|
+
`)?"":`
|
|
376
|
+
`)+a.raw,u.text+=`
|
|
377
|
+
`+a.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=u.text):n.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,n}inline(e,n=[]){return this.inlineQueue.push({src:e,tokens:n}),n}inlineTokens(e,n=[]){var c,u,d,p,y;this.tokenizer.lexer=this;let r=e,i=null;if(this.tokens.links){let v=Object.keys(this.tokens.links);if(v.length>0)for(;(i=this.tokenizer.rules.inline.reflinkSearch.exec(r))!=null;)v.includes(i[0].slice(i[0].lastIndexOf("[")+1,-1))&&(r=r.slice(0,i.index)+"["+"a".repeat(i[0].length-2)+"]"+r.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(i=this.tokenizer.rules.inline.anyPunctuation.exec(r))!=null;)r=r.slice(0,i.index)+"++"+r.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let s;for(;(i=this.tokenizer.rules.inline.blockSkip.exec(r))!=null;)s=i[2]?i[2].length:0,r=r.slice(0,i.index+s)+"["+"a".repeat(i[0].length-s-2)+"]"+r.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);r=((u=(c=this.options.hooks)==null?void 0:c.emStrongMask)==null?void 0:u.call({lexer:this},r))??r;let o=!1,a="";for(;e;){o||(a=""),o=!1;let v;if((p=(d=this.options.extensions)==null?void 0:d.inline)!=null&&p.some(E=>(v=E.call({lexer:this},e,n))?(e=e.substring(v.raw.length),n.push(v),!0):!1))continue;if(v=this.tokenizer.escape(e)){e=e.substring(v.raw.length),n.push(v);continue}if(v=this.tokenizer.tag(e)){e=e.substring(v.raw.length),n.push(v);continue}if(v=this.tokenizer.link(e)){e=e.substring(v.raw.length),n.push(v);continue}if(v=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(v.raw.length);let E=n.at(-1);v.type==="text"&&(E==null?void 0:E.type)==="text"?(E.raw+=v.raw,E.text+=v.text):n.push(v);continue}if(v=this.tokenizer.emStrong(e,r,a)){e=e.substring(v.raw.length),n.push(v);continue}if(v=this.tokenizer.codespan(e)){e=e.substring(v.raw.length),n.push(v);continue}if(v=this.tokenizer.br(e)){e=e.substring(v.raw.length),n.push(v);continue}if(v=this.tokenizer.del(e,r,a)){e=e.substring(v.raw.length),n.push(v);continue}if(v=this.tokenizer.autolink(e)){e=e.substring(v.raw.length),n.push(v);continue}if(!this.state.inLink&&(v=this.tokenizer.url(e))){e=e.substring(v.raw.length),n.push(v);continue}let A=e;if((y=this.options.extensions)!=null&&y.startInline){let E=1/0,I=e.slice(1),Z;this.options.extensions.startInline.forEach(P=>{Z=P.call({lexer:this},I),typeof Z=="number"&&Z>=0&&(E=Math.min(E,Z))}),E<1/0&&E>=0&&(A=e.substring(0,E+1))}if(v=this.tokenizer.inlineText(A)){e=e.substring(v.raw.length),v.raw.slice(-1)!=="_"&&(a=v.raw.slice(-1)),o=!0;let E=n.at(-1);(E==null?void 0:E.type)==="text"?(E.raw+=v.raw,E.text+=v.text):n.push(v);continue}if(e){let E="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(E);break}else throw new Error(E)}}return n}},ba=class{constructor(t){b(this,"options");b(this,"parser");this.options=t||yr}space(t){return""}code({text:t,lang:e,escaped:n}){var s;let r=(s=(e||"").match(Ne.notSpaceStart))==null?void 0:s[0],i=t.replace(Ne.endingNewline,"")+`
|
|
378
|
+
`;return r?'<pre><code class="language-'+kt(r)+'">'+(n?i:kt(i,!0))+`</code></pre>
|
|
379
|
+
`:"<pre><code>"+(n?i:kt(i,!0))+`</code></pre>
|
|
380
|
+
`}blockquote({tokens:t}){return`<blockquote>
|
|
381
|
+
${this.parser.parse(t)}</blockquote>
|
|
382
|
+
`}html({text:t}){return t}def(t){return""}heading({tokens:t,depth:e}){return`<h${e}>${this.parser.parseInline(t)}</h${e}>
|
|
383
|
+
`}hr(t){return`<hr>
|
|
384
|
+
`}list(t){let e=t.ordered,n=t.start,r="";for(let o=0;o<t.items.length;o++){let a=t.items[o];r+=this.listitem(a)}let i=e?"ol":"ul",s=e&&n!==1?' start="'+n+'"':"";return"<"+i+s+`>
|
|
385
|
+
`+r+"</"+i+`>
|
|
386
|
+
`}listitem(t){return`<li>${this.parser.parse(t.tokens)}</li>
|
|
387
|
+
`}checkbox({checked:t}){return"<input "+(t?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:t}){return`<p>${this.parser.parseInline(t)}</p>
|
|
388
|
+
`}table(t){let e="",n="";for(let i=0;i<t.header.length;i++)n+=this.tablecell(t.header[i]);e+=this.tablerow({text:n});let r="";for(let i=0;i<t.rows.length;i++){let s=t.rows[i];n="";for(let o=0;o<s.length;o++)n+=this.tablecell(s[o]);r+=this.tablerow({text:n})}return r&&(r=`<tbody>${r}</tbody>`),`<table>
|
|
389
|
+
<thead>
|
|
390
|
+
`+e+`</thead>
|
|
391
|
+
`+r+`</table>
|
|
392
|
+
`}tablerow({text:t}){return`<tr>
|
|
393
|
+
${t}</tr>
|
|
394
|
+
`}tablecell(t){let e=this.parser.parseInline(t.tokens),n=t.header?"th":"td";return(t.align?`<${n} align="${t.align}">`:`<${n}>`)+e+`</${n}>
|
|
395
|
+
`}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${kt(t,!0)}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:e,tokens:n}){let r=this.parser.parseInline(n),i=Af(t);if(i===null)return r;t=i;let s='<a href="'+t+'"';return e&&(s+=' title="'+kt(e)+'"'),s+=">"+r+"</a>",s}image({href:t,title:e,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=Af(t);if(i===null)return kt(n);t=i;let s=`<img src="${t}" alt="${kt(n)}"`;return e&&(s+=` title="${kt(e)}"`),s+=">",s}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:kt(t.text)}},dh=class{strong({text:t}){return t}em({text:t}){return t}codespan({text:t}){return t}del({text:t}){return t}html({text:t}){return t}text({text:t}){return t}link({text:t}){return""+t}image({text:t}){return""+t}br(){return""}checkbox({raw:t}){return t}},ft=class su{constructor(e){b(this,"options");b(this,"renderer");b(this,"textRenderer");this.options=e||yr,this.options.renderer=this.options.renderer||new ba,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new dh}static parse(e,n){return new su(n).parse(e)}static parseInline(e,n){return new su(n).parseInline(e)}parse(e){var r,i;this.renderer.parser=this;let n="";for(let s=0;s<e.length;s++){let o=e[s];if((i=(r=this.options.extensions)==null?void 0:r.renderers)!=null&&i[o.type]){let c=o,u=this.options.extensions.renderers[c.type].call({parser:this},c);if(u!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(c.type)){n+=u||"";continue}}let a=o;switch(a.type){case"space":{n+=this.renderer.space(a);break}case"hr":{n+=this.renderer.hr(a);break}case"heading":{n+=this.renderer.heading(a);break}case"code":{n+=this.renderer.code(a);break}case"table":{n+=this.renderer.table(a);break}case"blockquote":{n+=this.renderer.blockquote(a);break}case"list":{n+=this.renderer.list(a);break}case"checkbox":{n+=this.renderer.checkbox(a);break}case"html":{n+=this.renderer.html(a);break}case"def":{n+=this.renderer.def(a);break}case"paragraph":{n+=this.renderer.paragraph(a);break}case"text":{n+=this.renderer.text(a);break}default:{let c='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(c),"";throw new Error(c)}}}return n}parseInline(e,n=this.renderer){var i,s;this.renderer.parser=this;let r="";for(let o=0;o<e.length;o++){let a=e[o];if((s=(i=this.options.extensions)==null?void 0:i.renderers)!=null&&s[a.type]){let u=this.options.extensions.renderers[a.type].call({parser:this},a);if(u!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(a.type)){r+=u||"";continue}}let c=a;switch(c.type){case"escape":{r+=n.text(c);break}case"html":{r+=n.html(c);break}case"link":{r+=n.link(c);break}case"image":{r+=n.image(c);break}case"checkbox":{r+=n.checkbox(c);break}case"strong":{r+=n.strong(c);break}case"em":{r+=n.em(c);break}case"codespan":{r+=n.codespan(c);break}case"br":{r+=n.br(c);break}case"del":{r+=n.del(c);break}case"text":{r+=n.text(c);break}default:{let u='Token with "'+c.type+'" type was not found.';if(this.options.silent)return console.error(u),"";throw new Error(u)}}}return r}},No,Ji=(No=class{constructor(t){b(this,"options");b(this,"block");this.options=t||yr}preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}emStrongMask(t){return t}provideLexer(){return this.block?pt.lex:pt.lexInline}provideParser(){return this.block?ft.parse:ft.parseInline}},b(No,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),b(No,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),No),Ez=class{constructor(...t){b(this,"defaults",ih());b(this,"options",this.setOptions);b(this,"parse",this.parseMarkdown(!0));b(this,"parseInline",this.parseMarkdown(!1));b(this,"Parser",ft);b(this,"Renderer",ba);b(this,"TextRenderer",dh);b(this,"Lexer",pt);b(this,"Tokenizer",ya);b(this,"Hooks",Ji);this.use(...t)}walkTokens(t,e){var r,i;let n=[];for(let s of t)switch(n=n.concat(e.call(this,s)),s.type){case"table":{let o=s;for(let a of o.header)n=n.concat(this.walkTokens(a.tokens,e));for(let a of o.rows)for(let c of a)n=n.concat(this.walkTokens(c.tokens,e));break}case"list":{let o=s;n=n.concat(this.walkTokens(o.items,e));break}default:{let o=s;(i=(r=this.defaults.extensions)==null?void 0:r.childTokens)!=null&&i[o.type]?this.defaults.extensions.childTokens[o.type].forEach(a=>{let c=o[a].flat(1/0);n=n.concat(this.walkTokens(c,e))}):o.tokens&&(n=n.concat(this.walkTokens(o.tokens,e)))}}return n}use(...t){let e=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach(n=>{let r={...n};if(r.async=this.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(i=>{if(!i.name)throw new Error("extension name required");if("renderer"in i){let s=e.renderers[i.name];s?e.renderers[i.name]=function(...o){let a=i.renderer.apply(this,o);return a===!1&&(a=s.apply(this,o)),a}:e.renderers[i.name]=i.renderer}if("tokenizer"in i){if(!i.level||i.level!=="block"&&i.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let s=e[i.level];s?s.unshift(i.tokenizer):e[i.level]=[i.tokenizer],i.start&&(i.level==="block"?e.startBlock?e.startBlock.push(i.start):e.startBlock=[i.start]:i.level==="inline"&&(e.startInline?e.startInline.push(i.start):e.startInline=[i.start]))}"childTokens"in i&&i.childTokens&&(e.childTokens[i.name]=i.childTokens)}),r.extensions=e),n.renderer){let i=this.defaults.renderer||new ba(this.defaults);for(let s in n.renderer){if(!(s in i))throw new Error(`renderer '${s}' does not exist`);if(["options","parser"].includes(s))continue;let o=s,a=n.renderer[o],c=i[o];i[o]=(...u)=>{let d=a.apply(i,u);return d===!1&&(d=c.apply(i,u)),d||""}}r.renderer=i}if(n.tokenizer){let i=this.defaults.tokenizer||new ya(this.defaults);for(let s in n.tokenizer){if(!(s in i))throw new Error(`tokenizer '${s}' does not exist`);if(["options","rules","lexer"].includes(s))continue;let o=s,a=n.tokenizer[o],c=i[o];i[o]=(...u)=>{let d=a.apply(i,u);return d===!1&&(d=c.apply(i,u)),d}}r.tokenizer=i}if(n.hooks){let i=this.defaults.hooks||new Ji;for(let s in n.hooks){if(!(s in i))throw new Error(`hook '${s}' does not exist`);if(["options","block"].includes(s))continue;let o=s,a=n.hooks[o],c=i[o];Ji.passThroughHooks.has(s)?i[o]=u=>{if(this.defaults.async&&Ji.passThroughHooksRespectAsync.has(s))return(async()=>{let p=await a.call(i,u);return c.call(i,p)})();let d=a.call(i,u);return c.call(i,d)}: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 d=a.apply(i,u);return d===!1&&(d=c.apply(i,u)),d}}r.hooks=i}if(n.walkTokens){let i=this.defaults.walkTokens,s=n.walkTokens;r.walkTokens=function(o){let a=[];return a.push(s.call(this,o)),i&&(a=a.concat(i.call(this,o))),a}}this.defaults={...this.defaults,...r}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,e){return pt.lex(t,e??this.defaults)}parser(t,e){return ft.parse(t,e??this.defaults)}parseMarkdown(t){return(e,n)=>{let r={...n},i={...this.defaults,...r},s=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return s(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof e>"u"||e===null)return s(new Error("marked(): input parameter is undefined or null"));if(typeof e!="string")return s(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected"));if(i.hooks&&(i.hooks.options=i,i.hooks.block=t),i.async)return(async()=>{let o=i.hooks?await i.hooks.preprocess(e):e,a=await(i.hooks?await i.hooks.provideLexer():t?pt.lex:pt.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():t?ft.parse:ft.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():t?pt.lex:pt.lexInline)(e,i);i.hooks&&(o=i.hooks.processAllTokens(o)),i.walkTokens&&this.walkTokens(o,i.walkTokens);let a=(i.hooks?i.hooks.provideParser():t?ft.parse:ft.parseInline)(o,i);return i.hooks&&(a=i.hooks.postprocess(a)),a}catch(o){return s(o)}}}onError(t,e){return n=>{if(n.message+=`
|
|
396
|
+
Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error occurred:</p><pre>"+kt(n.message+"",!0)+"</pre>";return e?Promise.resolve(r):r}if(e)return Promise.reject(n);throw n}}},pr=new Ez;function J(t,e){return pr.parse(t,e)}J.options=J.setOptions=function(t){return pr.setOptions(t),J.defaults=pr.defaults,Uy(J.defaults),J};J.getDefaults=ih;J.defaults=yr;J.use=function(...t){return pr.use(...t),J.defaults=pr.defaults,Uy(J.defaults),J};J.walkTokens=function(t,e){return pr.walkTokens(t,e)};J.parseInline=pr.parseInline;J.Parser=ft;J.parser=ft.parse;J.Renderer=ba;J.TextRenderer=dh;J.Lexer=pt;J.lexer=pt.lex;J.Tokenizer=ya;J.Hooks=Ji;J.parse=J;J.options;J.setOptions;J.use;J.walkTokens;J.parseInline;ft.parse;pt.lex;Ny.addHook("afterSanitizeAttributes",t=>{t.tagName==="A"&&(t.setAttribute("target","_blank"),t.setAttribute("rel","noopener noreferrer"))});function xz(t){const e=J.parse(t,{async:!1});return Ny.sanitize(e,{USE_PROFILES:{html:!0}})}const $z=8,If=new WeakMap;function Az(t){const e=If.get(t);if(e&&e.text===t.text)return e.html;const n=xz(t.text);return If.set(t,{text:t.text,html:n}),n}function Tz(t){return t.replace(/_/g," ")}function Cz(t){return U`
|
|
397
|
+
<div class="tool-call-header">
|
|
398
|
+
<span class="tool-call-title">${t.title}</span>
|
|
399
|
+
<span class="tool-call-meta">${t.toolKind} · ${Tz(t.status)}</span>
|
|
400
|
+
</div>
|
|
401
|
+
${t.text?U`<pre class="tool-call-text">${t.text}</pre>`:null}
|
|
402
|
+
`}function Pf(t){for(let e=t.length-1;e>=0;e-=1){const n=t[e];if(n&&n.kind==="user")return n.id}return null}var Gt,ar,La,Ma,Bs,ou;class Yy extends ls{constructor(){super(...arguments);S(this,Bs);b(this,"messages",[]);S(this,Gt,!0);S(this,ar,null);S(this,La,()=>{const n=l(this,ar);if(!n)return;const i=n.scrollHeight-n.clientHeight-n.scrollTop<=$z;i!==l(this,Gt)&&(k(this,Gt,i),this.toggleAttribute("data-pinned",i))});S(this,Ma,()=>{k(this,Gt,!0),this.toggleAttribute("data-pinned",!0),g(this,Bs,ou).call(this,!0)})}changed(n){let r=!1;if(n.has("messages")){const i=n.get("messages")??[],s=Pf(this.messages);r=s!==null&&s!==Pf(i),r&&k(this,Gt,!0)}Re(this.template(),this),l(this,ar)||k(this,ar,this.querySelector(".history-scroll")),this.toggleAttribute("data-pinned",l(this,Gt)),g(this,Bs,ou).call(this,r)}template(){return U`
|
|
403
|
+
<div class="history-scroll" @scroll=${l(this,La)}>
|
|
404
|
+
${this.messages.map(n=>{const r=n.kind==="assistant"?ND(Az(n)):n.kind==="tool_call"?Cz(n):n.text;return U`<div
|
|
405
|
+
class="message message-${n.kind}"
|
|
406
|
+
data-message-id=${n.id}
|
|
407
|
+
>${r}</div>`})}
|
|
408
|
+
</div>
|
|
409
|
+
<button
|
|
410
|
+
type="button"
|
|
411
|
+
class="history-jump"
|
|
412
|
+
aria-label="Jump to latest message"
|
|
413
|
+
@click=${l(this,Ma)}
|
|
414
|
+
>
|
|
415
|
+
${qv({size:16})}
|
|
416
|
+
</button>
|
|
417
|
+
`}}Gt=new WeakMap,ar=new WeakMap,La=new WeakMap,Ma=new WeakMap,Bs=new WeakSet,ou=function(n){requestAnimationFrame(()=>{const r=l(this,ar);r&&(!l(this,Gt)&&!n||(r.scrollTop=r.scrollHeight-r.clientHeight))})},b(Yy,"properties",["messages"]);customElements.define("message-history",Yy);var js,Vs,si,Gs,wn,lu,cu,Ws,qs;class au extends ls{constructor(){super(...arguments);S(this,wn);b(this,"placeholder","What do you want to do?");b(this,"open",!1);b(this,"messages",[]);S(this,js,We.resolve("ACPClientManager"));S(this,Vs,We.resolve("ShortcutService"));S(this,si,null);b(this,"handleTriggerActivate",()=>{this.open=!0});b(this,"handleKeydown",n=>{if(n.key!=="Enter"||n.shiftKey)return;const r=n.currentTarget,i=r.value.trim();if(n.preventDefault(),!i)return;r.value="";const s=l(this,js).getActiveClient();s&&s.sendMessage({text:i}).catch(o=>{console.error("ACPClient.sendMessage() failed",o)})});S(this,Gs,n=>{if(n.shortcut!=="focusCommandInput")return;if(!this.open){this.open=!0;return}const r=this.querySelector("textarea");if(r){if(document.activeElement===r){this.open=!1;return}r.focus()}});S(this,Ws,n=>{n.target instanceof Node&&(this.contains(n.target)||(this.open=!1))});S(this,qs,n=>{n.key==="Escape"&&(this.open=!1)})}connected(){this.setAttribute("material","paper"),this.setAttribute("tone","dark"),this.setAttribute("level","overlay");const n=new DisposableStack;k(this,si,n);const r=m2(l(this,js),i=>{this.messages=i});n.defer(()=>r.dispose()),l(this,Vs).addEventListener("shortcut-triggered",l(this,Gs)),n.defer(()=>l(this,Vs).removeEventListener("shortcut-triggered",l(this,Gs))),this.open&&g(this,wn,lu).call(this)}disconnected(){var n;(n=l(this,si))==null||n.dispose(),k(this,si,null),g(this,wn,cu).call(this)}changed(n){if(Re(this.template(),this),n.has("open"))if(this.open){g(this,wn,lu).call(this);const r=this.querySelector("textarea");r==null||r.focus()}else g(this,wn,cu).call(this)}template(){return this.open?U`
|
|
418
|
+
<message-history .messages=${this.messages}></message-history>
|
|
419
|
+
<textarea
|
|
420
|
+
class="input"
|
|
421
|
+
rows="1"
|
|
422
|
+
@keydown=${this.handleKeydown}
|
|
423
|
+
></textarea>
|
|
424
|
+
`:U`
|
|
425
|
+
<div
|
|
426
|
+
class="trigger"
|
|
427
|
+
tabindex="0"
|
|
428
|
+
role="button"
|
|
429
|
+
@click=${this.handleTriggerActivate}
|
|
430
|
+
@focus=${this.handleTriggerActivate}
|
|
431
|
+
>
|
|
432
|
+
<span class="label">${this.placeholder}</span>
|
|
433
|
+
<span class="kbd" aria-hidden="true">⌘K</span>
|
|
434
|
+
</div>
|
|
435
|
+
`}}js=new WeakMap,Vs=new WeakMap,si=new WeakMap,Gs=new WeakMap,wn=new WeakSet,lu=function(){document.addEventListener("mousedown",l(this,Ws)),document.addEventListener("keydown",l(this,qs))},cu=function(){document.removeEventListener("mousedown",l(this,Ws)),document.removeEventListener("keydown",l(this,qs))},Ws=new WeakMap,qs=new WeakMap,b(au,"properties",["placeholder","open","messages"]),b(au,"attributes",{placeholder:{type:String},open:{type:Boolean}});customElements.define("command-panel",au);class Ky extends Event{constructor(n){super("auth-submit",{bubbles:!0,composed:!0});b(this,"token");this.token=n}}class Iz extends HTMLElement{constructor(){super(...arguments);b(this,"_invalid",!1);b(this,"_tokenValue","")}set invalid(n){this._invalid=n,this.render()}get invalid(){return this._invalid}set tokenValue(n){this._tokenValue=n,this.render()}get tokenValue(){return this._tokenValue}connectedCallback(){this.render()}handleInput(n){const r=n.currentTarget;this._tokenValue=r.value}handleSubmit(n){n.preventDefault();const r=this._tokenValue.trim();r&&this.dispatchEvent(new Ky(r))}render(){Re(U`
|
|
436
|
+
<modal-overlay open>
|
|
437
|
+
<section class="auth-modal">
|
|
438
|
+
<form class="auth-form" @submit=${n=>this.handleSubmit(n)}>
|
|
439
|
+
<h2 class="auth-modal-title">Enter access token</h2>
|
|
440
|
+
<p class="auth-modal-copy">This Television server requires a token.</p>
|
|
441
|
+
<label class="settings-field">
|
|
442
|
+
<span>Token</span>
|
|
443
|
+
<input
|
|
444
|
+
class=${this.invalid?"auth-token-input-invalid":""}
|
|
445
|
+
type="password"
|
|
446
|
+
name="token"
|
|
447
|
+
.value=${this.tokenValue}
|
|
448
|
+
@input=${n=>this.handleInput(n)}
|
|
449
|
+
required
|
|
450
|
+
/>
|
|
451
|
+
</label>
|
|
452
|
+
<button type="submit" class="settings-submit-button">Connect</button>
|
|
453
|
+
</form>
|
|
454
|
+
</section>
|
|
455
|
+
</modal-overlay>
|
|
456
|
+
`,this)}}customElements.get("auth-modal")||customElements.define("auth-modal",Iz);class Pz extends HTMLElement{constructor(){super(...arguments);b(this,"runtimeServerURL",Pv());b(this,"electronMode",Rv());b(this,"serverManager",We.resolve("ServerManager"));b(this,"screenManager",We.resolve("ScreenManager"));b(this,"connectError",null);b(this,"handleServerManagerChange",()=>{this.render()});b(this,"handleActiveScreenChanged",()=>{this.render()})}connectedCallback(){this.serverManager.addEventListener("change",this.handleServerManagerChange),this.screenManager.addEventListener("active-screen-changed",this.handleActiveScreenChanged),this.addEventListener("auth-submit",n=>{var i;const r=n instanceof Ky?n.token:n instanceof CustomEvent&&typeof((i=n.detail)==null?void 0:i.token)=="string"?n.detail.token:null;r&&this.handleAuthSubmit(r)}),this.initializeConnection(),this.render()}disconnectedCallback(){this.serverManager.removeEventListener("change",this.handleServerManagerChange),this.screenManager.removeEventListener("active-screen-changed",this.handleActiveScreenChanged)}async initializeConnection(){if(this.electronMode){this.serverManager.connectConfiguredServers(this.runtimeServerURL,zc());return}if(this.serverManager.activeServer)return;const n=new Ac({url:this.runtimeServerURL,name:"Server",token:zc()});this.serverManager.add(n),this.serverManager.setActive(n);try{await n.connect(),this.connectError=null}catch(r){this.connectError=r instanceof Error&&!(r instanceof $c)?r.message:null}this.render()}async handleAuthSubmit(n){const r=this.serverManager.activeServer;if(r){this.connectError=null,r.token=n,this.updateTokenQueryParam(n);try{await r.connect()}catch(i){i instanceof $c||(this.connectError=i instanceof Error?i.message:String(i))}this.render()}}updateTokenQueryParam(n){const r=new URL(window.location.href);r.searchParams.set("token",n),window.history.replaceState({},"",`${r.pathname}${r.search}${r.hash}`)}render(){const n=this.serverManager.activeServer,r=(n==null?void 0:n.status)??null;if(r==="connecting"){Re(U`
|
|
457
|
+
<main class="auth-gate"><p>Connecting...</p></main>
|
|
458
|
+
`,this);return}if(r==="disconnected"){const o=n;if(!o)return;Re(U`
|
|
459
|
+
<main class="auth-gate">
|
|
460
|
+
<auth-modal
|
|
461
|
+
.invalid=${!!o.token}
|
|
462
|
+
.tokenValue=${o.token??""}
|
|
463
|
+
></auth-modal>
|
|
464
|
+
</main>
|
|
465
|
+
`,this);return}const s=this.screenManager.activeScreen?U`<screen-view></screen-view>`:U`<home-screen></home-screen>`;Re(U`
|
|
466
|
+
<main>
|
|
467
|
+
${this.connectError?U`<p data-testid="auth-error">${this.connectError}</p>`:U`
|
|
468
|
+
${s}
|
|
469
|
+
${r==="connected"?U`
|
|
470
|
+
<div class="chrome">
|
|
471
|
+
<div class="top-row electron-draggable">
|
|
472
|
+
<screen-breadcrumb></screen-breadcrumb>
|
|
473
|
+
<screen-create-button></screen-create-button>
|
|
474
|
+
</div>
|
|
475
|
+
<command-panel></command-panel>
|
|
476
|
+
</div>
|
|
477
|
+
`:null}
|
|
478
|
+
`}
|
|
479
|
+
</main>
|
|
480
|
+
`,this)}}customElements.get("television-app")||customElements.define("television-app",Pz);const ph=Rv(),nl=Pv(),Jy=new Tx(ph?"television-electron":"television-browser",Ax(nl)),Xy=new wC({localStore:Jy,localServerURL:nl}),Qy=new Ex({localStore:Jy,serverManager:Xy}),Rz=new rD({serverURL:nl,token:zc()??"",screenManager:Qy}),Dz=new cD;We.register("ServerManager",()=>Xy);We.register("ScreenManager",()=>Qy);We.register("ACPClientManager",()=>Rz);We.register("ShortcutService",()=>Dz);const fh=document.createElement("television-app");fh.runtimeServerURL=nl;fh.electronMode=ph;ph&&document.body.classList.add("electron");document.body.appendChild(fh);
|