@telepath-computer/television 0.1.43 → 0.1.45
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/views/markdown/index.html +1 -1
- package/dist/web/assets/gradient-textured-e-Dp94sOPT.jpg +0 -0
- package/dist/web/assets/index-DUJSe6yQ.css +1 -0
- package/dist/web/assets/index-PY30-wBa.js +474 -0
- package/dist/web/index.html +2 -2
- package/package.json +1 -1
- package/dist/web/assets/gradient-j-DX-EI0uV.jpg +0 -0
- package/dist/web/assets/index-DlPJZ0LB.js +0 -468
- package/dist/web/assets/index-SWEtdQRn.css +0 -1
|
@@ -0,0 +1,474 @@
|
|
|
1
|
+
var eb=Object.defineProperty;var Ph=t=>{throw TypeError(t)};var tb=(t,e,n)=>e in t?eb(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var b=(t,e,n)=>tb(t,typeof e!="symbol"?e+"":e,n),ll=(t,e,n)=>e.has(t)||Ph("Cannot "+n);var l=(t,e,n)=>(ll(t,e,"read from private field"),n?n.call(t):e.get(t)),_=(t,e,n)=>e.has(t)?Ph("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),x=(t,e,n,r)=>(ll(t,e,"write to private field"),r?r.call(t,n):e.set(t,n),n),m=(t,e,n)=>(ll(t,e,"access private method"),n);var Rh=(t,e,n,r)=>({set _(i){x(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 Pn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function nb(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 Dh=Object.prototype.toString,Sf=function(e){var n=Dh.call(e),r=n==="[object Arguments]";return r||(r=n!=="[object Array]"&&e!==null&&typeof e=="object"&&typeof e.length=="number"&&e.length>=0&&Dh.call(e.callee)==="[object Function]"),r},cl,Oh;function rb(){if(Oh)return cl;Oh=1;var t;if(!Object.keys){var e=Object.prototype.hasOwnProperty,n=Object.prototype.toString,r=Sf,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 $=v!==null&&typeof v=="object",k=n.call(v)==="[object Function]",I=r(v),B=$&&n.call(v)==="[object String]",P=[];if(!$&&!k&&!I)throw new TypeError("Object.keys called on a non-object");var K=o&&k;if(B&&v.length>0&&!e.call(v,0))for(var L=0;L<v.length;++L)P.push(String(L));if(I&&v.length>0)for(var Z=0;Z<v.length;++Z)P.push(String(Z));else for(var N in v)!(K&&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 cl=t,cl}var ib=Array.prototype.slice,sb=Sf,zh=Object.keys,Do=zh?function(e){return zh(e)}:rb(),Lh=Object.keys;Do.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 sb(r)?Lh(ib.call(r)):Lh(r)})}else Object.keys=Do;return Object.keys||Do};var ob=Do,Oo=Object.defineProperty||!1;if(Oo)try{Oo({},"a",{value:1})}catch{Oo=!1}var Bs=Oo,qt=SyntaxError,G=TypeError,ab=Object.getOwnPropertyDescriptor,zo=ab;if(zo)try{zo([],"length")}catch{zo=null}var si=zo,Mh=Bs,lb=qt,_r=G,Nh=si,kf=function(e,n,r){if(!e||typeof e!="object"&&typeof e!="function")throw new _r("`obj` must be an object or a function`");if(typeof n!="string"&&typeof n!="symbol")throw new _r("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new _r("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new _r("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new _r("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new _r("`loose`, if provided, must be a boolean");var i=arguments.length>3?arguments[3]:null,s=arguments.length>4?arguments[4]:null,o=arguments.length>5?arguments[5]:null,a=arguments.length>6?arguments[6]:!1,c=!!Nh&&Nh(e,n);if(Mh)Mh(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 lb("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},tc=Bs,xf=function(){return!!tc};xf.hasArrayLengthDefineBug=function(){if(!tc)return null;try{return tc([],"length",{value:1}).length!==1}catch{return!0}};var Pa=xf,cb=ob,ub=typeof Symbol=="function"&&typeof Symbol("foo")=="symbol",hb=Object.prototype.toString,db=Array.prototype.concat,Uh=kf,pb=function(t){return typeof t=="function"&&hb.call(t)==="[object Function]"},Ef=Pa(),fb=function(t,e,n,r){if(e in t){if(r===!0){if(t[e]===n)return}else if(!pb(r)||!r())return}Ef?Uh(t,e,n,!0):Uh(t,e,n)},$f=function(t,e){var n=arguments.length>2?arguments[2]:{},r=cb(e);ub&&(r=db.call(r,Object.getOwnPropertySymbols(e)));for(var i=0;i<r.length;i+=1)fb(t,r[i],e[r[i]],n[r[i]])};$f.supportsDescriptors=!!Ef;var hr=$f,Lo={exports:{}};typeof self<"u"?Lo.exports=self:typeof window<"u"?Lo.exports=window:Lo.exports=Function("return this")();var Af=Lo.exports,gb=Af,Tf=function(){return typeof Pn!="object"||!Pn||Pn.Math!==Math||Pn.Array!==Array?gb:Pn},mb=hr,vb=si,yb=Tf,bb=function(){var e=yb();if(mb.supportsDescriptors){var n=vb(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},wb=hr,_b=Af,Cf=Tf,Sb=bb,kb=Cf(),If=function(){return kb};wb(If,{getPolyfill:Cf,implementation:_b,shim:Sb});var nu=If,Yt=function(e){return!!e&&(typeof e=="function"||typeof e=="object")},ru=Object,Pf=Error,xb=EvalError,Eb=RangeError,iu=ReferenceError,$b=URIError,Ab=Math.abs,Tb=Math.floor,Cb=Math.max,Ib=Math.min,Pb=Math.pow,Rb=Math.round,su=Number.isNaN||function(e){return e!==e},Db=su,Ob=function(e){return Db(e)||e===0?e:e<0?-1:1},oi=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},Fh=typeof Symbol<"u"&&Symbol,zb=oi,ou=function(){return typeof Fh!="function"||typeof Symbol!="function"||typeof Fh("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:zb()},Rf=typeof Reflect<"u"&&Reflect.getPrototypeOf||null,Lb=ru,Df=Lb.getPrototypeOf||null,Mb="Function.prototype.bind called on incompatible ",Nb=Object.prototype.toString,Ub=Math.max,Fb="[object Function]",Zh=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},Zb=function(e,n){for(var r=[],i=n,s=0;i<e.length;i+=1,s+=1)r[s]=e[i];return r},Hb=function(t,e){for(var n="",r=0;r<t.length;r+=1)n+=t[r],r+1<t.length&&(n+=e);return n},Bb=function(e){var n=this;if(typeof n!="function"||Nb.apply(n)!==Fb)throw new TypeError(Mb+n);for(var r=Zb(arguments,1),i,s=function(){if(this instanceof i){var d=n.apply(this,Zh(r,arguments));return Object(d)===d?d:this}return n.apply(e,Zh(r,arguments))},o=Ub(0,n.length-r.length),a=[],c=0;c<o;c++)a[c]="$"+c;if(i=Function("binder","return function ("+Hb(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},Vb=Bb,Vs=Function.prototype.bind||Vb,au=Function.prototype.call,lu=Function.prototype.apply,jb=typeof Reflect<"u"&&Reflect&&Reflect.apply,Gb=Vs,Wb=lu,qb=au,Yb=jb,Of=Yb||Gb.call(qb,Wb),Kb=Vs,Jb=G,Xb=au,Qb=Of,Ra=function(e){if(e.length<1||typeof e[0]!="function")throw new Jb("a function is required");return Qb(Kb,Xb,e)},ew=Ra,Hh=si,zf;try{zf=[].__proto__===Array.prototype}catch(t){if(!t||typeof t!="object"||!("code"in t)||t.code!=="ERR_PROTO_ACCESS")throw t}var ul=!!zf&&Hh&&Hh(Object.prototype,"__proto__"),Lf=Object,Bh=Lf.getPrototypeOf,tw=ul&&typeof ul.get=="function"?ew([ul.get]):typeof Bh=="function"?function(e){return Bh(e==null?e:Lf(e))}:!1,Vh=Rf,jh=Df,Gh=tw,Mf=Vh?function(e){return Vh(e)}:jh?function(e){if(!e||typeof e!="object"&&typeof e!="function")throw new TypeError("getProto: not an object");return jh(e)}:Gh?function(e){return Gh(e)}:null,nw=Function.prototype.call,rw=Object.prototype.hasOwnProperty,iw=Vs,Kt=iw.call(nw,rw),j,sw=ru,ow=Pf,aw=xb,lw=Eb,cw=iu,Qr=qt,zr=G,uw=$b,hw=Ab,dw=Tb,pw=Cb,fw=Ib,gw=Pb,mw=Rb,vw=Ob,Nf=Function,hl=function(t){try{return Nf('"use strict"; return ('+t+").constructor;")()}catch{}},Ji=si,yw=Bs,dl=function(){throw new zr},bw=Ji?function(){try{return arguments.callee,dl}catch{try{return Ji(arguments,"callee").get}catch{return dl}}}():dl,Sr=ou(),Se=Mf,ww=Df,_w=Rf,Uf=lu,js=au,Er={},Sw=typeof Uint8Array>"u"||!Se?j:Se(Uint8Array),ir={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?j:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?j:ArrayBuffer,"%ArrayIteratorPrototype%":Sr&&Se?Se([][Symbol.iterator]()):j,"%AsyncFromSyncIteratorPrototype%":j,"%AsyncFunction%":Er,"%AsyncGenerator%":Er,"%AsyncGeneratorFunction%":Er,"%AsyncIteratorPrototype%":Er,"%Atomics%":typeof Atomics>"u"?j:Atomics,"%BigInt%":typeof BigInt>"u"?j:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?j:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?j:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?j:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":ow,"%eval%":eval,"%EvalError%":aw,"%Float16Array%":typeof Float16Array>"u"?j:Float16Array,"%Float32Array%":typeof Float32Array>"u"?j:Float32Array,"%Float64Array%":typeof Float64Array>"u"?j:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?j:FinalizationRegistry,"%Function%":Nf,"%GeneratorFunction%":Er,"%Int8Array%":typeof Int8Array>"u"?j:Int8Array,"%Int16Array%":typeof Int16Array>"u"?j:Int16Array,"%Int32Array%":typeof Int32Array>"u"?j:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":Sr&&Se?Se(Se([][Symbol.iterator]())):j,"%JSON%":typeof JSON=="object"?JSON:j,"%Map%":typeof Map>"u"?j:Map,"%MapIteratorPrototype%":typeof Map>"u"||!Sr||!Se?j:Se(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":sw,"%Object.getOwnPropertyDescriptor%":Ji,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?j:Promise,"%Proxy%":typeof Proxy>"u"?j:Proxy,"%RangeError%":lw,"%ReferenceError%":cw,"%Reflect%":typeof Reflect>"u"?j:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?j:Set,"%SetIteratorPrototype%":typeof Set>"u"||!Sr||!Se?j:Se(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?j:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":Sr&&Se?Se(""[Symbol.iterator]()):j,"%Symbol%":Sr?Symbol:j,"%SyntaxError%":Qr,"%ThrowTypeError%":bw,"%TypedArray%":Sw,"%TypeError%":zr,"%Uint8Array%":typeof Uint8Array>"u"?j:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?j:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?j:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?j:Uint32Array,"%URIError%":uw,"%WeakMap%":typeof WeakMap>"u"?j:WeakMap,"%WeakRef%":typeof WeakRef>"u"?j:WeakRef,"%WeakSet%":typeof WeakSet>"u"?j:WeakSet,"%Function.prototype.call%":js,"%Function.prototype.apply%":Uf,"%Object.defineProperty%":yw,"%Object.getPrototypeOf%":ww,"%Math.abs%":hw,"%Math.floor%":dw,"%Math.max%":pw,"%Math.min%":fw,"%Math.pow%":gw,"%Math.round%":mw,"%Math.sign%":vw,"%Reflect.getPrototypeOf%":_w};if(Se)try{null.error}catch(t){var kw=Se(Se(t));ir["%Error.prototype%"]=kw}var xw=function t(e){var n;if(e==="%AsyncFunction%")n=hl("async function () {}");else if(e==="%GeneratorFunction%")n=hl("function* () {}");else if(e==="%AsyncGeneratorFunction%")n=hl("async function* () {}");else if(e==="%AsyncGenerator%"){var r=t("%AsyncGeneratorFunction%");r&&(n=r.prototype)}else if(e==="%AsyncIteratorPrototype%"){var i=t("%AsyncGenerator%");i&&Se&&(n=Se(i.prototype))}return ir[e]=n,n},Wh={__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"]},Gs=Vs,qo=Kt,Ew=Gs.call(js,Array.prototype.concat),$w=Gs.call(Uf,Array.prototype.splice),qh=Gs.call(js,String.prototype.replace),Yo=Gs.call(js,String.prototype.slice),Aw=Gs.call(js,RegExp.prototype.exec),Tw=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,Cw=/\\(\\)?/g,Iw=function(e){var n=Yo(e,0,1),r=Yo(e,-1);if(n==="%"&&r!=="%")throw new Qr("invalid intrinsic syntax, expected closing `%`");if(r==="%"&&n!=="%")throw new Qr("invalid intrinsic syntax, expected opening `%`");var i=[];return qh(e,Tw,function(s,o,a,c){i[i.length]=a?qh(c,Cw,"$1"):o||s}),i},Pw=function(e,n){var r=e,i;if(qo(Wh,r)&&(i=Wh[r],r="%"+i[0]+"%"),qo(ir,r)){var s=ir[r];if(s===Er&&(s=xw(r)),typeof s>"u"&&!n)throw new zr("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:i,name:r,value:s}}throw new Qr("intrinsic "+e+" does not exist!")},st=function(e,n){if(typeof e!="string"||e.length===0)throw new zr("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof n!="boolean")throw new zr('"allowMissing" argument must be a boolean');if(Aw(/^%?[^%]*%?$/,e)===null)throw new Qr("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var r=Iw(e),i=r.length>0?r[0]:"",s=Pw("%"+i+"%",n),o=s.name,a=s.value,c=!1,u=s.alias;u&&(i=u[0],$w(r,Ew([0,1],u)));for(var d=1,p=!0;d<r.length;d+=1){var y=r[d],v=Yo(y,0,1),$=Yo(y,-1);if((v==='"'||v==="'"||v==="`"||$==='"'||$==="'"||$==="`")&&v!==$)throw new Qr("property names with quotes must have matching quotes");if((y==="constructor"||!p)&&(c=!0),i+="."+y,o="%"+i+"%",qo(ir,o))a=ir[o];else if(a!=null){if(!(y in a)){if(!n)throw new zr("base intrinsic for "+e+" exists, but the property is not available.");return}if(Ji&&d+1>=r.length){var k=Ji(a,y);p=!!k,p&&"get"in k&&!("originalValue"in k.get)?a=k.get:a=a[y]}else p=qo(a,y),a=a[y];p&&!c&&(ir[o]=a)}}return a},pl,Yh;function wn(){if(Yh)return pl;Yh=1;var t=st,e=Ra,n=e([t("%String.prototype.indexOf%")]);return pl=function(i,s){var o=t(i,!!s);return typeof o=="function"&&n(i,".prototype.")>-1?e([o]):o},pl}var fl,Kh;function cu(){if(Kh)return fl;Kh=1;var t=st,e=t("%Array%"),n=!e.isArray&&wn()("Object.prototype.toString");return fl=e.isArray||function(i){return n(i)==="[object Array]"},fl}var Rw=Pa,Jh=Bs,Ff=Rw.hasArrayLengthDefineBug(),Dw=Ff&&cu(),Ow=wn(),zw=Ow("Object.prototype.propertyIsEnumerable"),uu=function(e,n,r,i,s,o){if(!Jh){if(!e(o)||!o["[[Configurable]]"]||!o["[[Writable]]"]||s in i&&zw(i,s)!==!!o["[[Enumerable]]"])return!1;var a=o["[[Value]]"];return i[s]=a,n(i[s],a)}return Ff&&s==="length"&&"[[Value]]"in o&&Dw(i)&&i.length!==o["[[Value]]"]?(i.length=o["[[Value]]"],i.length===o["[[Value]]"]):(Jh(i,s,r(o)),!0)},Lw=G,Si=Kt,Mw={__proto__:null,"[[Configurable]]":!0,"[[Enumerable]]":!0,"[[Get]]":!0,"[[Set]]":!0,"[[Value]]":!0,"[[Writable]]":!0},ai=function(e){if(!e||typeof e!="object")return!1;for(var n in e)if(Si(e,n)&&!Mw[n])return!1;var r=Si(e,"[[Value]]")||Si(e,"[[Writable]]"),i=Si(e,"[[Get]]")||Si(e,"[[Set]]");if(r&&i)throw new Lw("Property Descriptors may not be both accessor and data descriptors");return!0},Zf=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},Nw=G,Uw=ai,Fw=Zf,Hf=function(e){if(typeof e<"u"&&!Uw(e))throw new Nw("Assertion failed: `Desc` must be a Property Descriptor");return Fw(e)},Zw=G,Xh=Kt,Hw=ai,Bf=function(e){if(typeof e>"u")return!1;if(!Hw(e))throw new Zw("Assertion failed: `Desc` must be a Property Descriptor");return!(!Xh(e,"[[Value]]")&&!Xh(e,"[[Writable]]"))},li=function(e){return typeof e=="string"||typeof e=="symbol"},Qh=su,Vf=function(e,n){return e===n?e===0?1/e===1/n:!0:Qh(e)&&Qh(n)},ed=G,Bw=Yt,Vw=uu,jw=Hf,Gw=Bf,Ww=li,qw=Vf,hu=function(e,n,r){if(!Bw(e))throw new ed("Assertion failed: Type(O) is not Object");if(!Ww(n))throw new ed("Assertion failed: P is not a Property Key");var i={"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Value]]":r,"[[Writable]]":!0};return Vw(Gw,qw,jw,e,n,i)},jf=Function.prototype.toString,Rr=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,nc,Mo;if(typeof Rr=="function"&&typeof Object.defineProperty=="function")try{nc=Object.defineProperty({},"length",{get:function(){throw Mo}}),Mo={},Rr(function(){throw 42},null,nc)}catch(t){t!==Mo&&(Rr=null)}else Rr=null;var Yw=/^\s*class\b/,rc=function(e){try{var n=jf.call(e);return Yw.test(n)}catch{return!1}},gl=function(e){try{return rc(e)?!1:(jf.call(e),!0)}catch{return!1}},No=Object.prototype.toString,Kw="[object Object]",Jw="[object Function]",Xw="[object GeneratorFunction]",Qw="[object HTMLAllCollection]",e0="[object HTML document.all class]",t0="[object HTMLCollection]",n0=typeof Symbol=="function"&&!!Symbol.toStringTag,r0=!(0 in[,]),ic=function(){return!1};if(typeof document=="object"){var i0=document.all;No.call(i0)===No.call(document.all)&&(ic=function(e){if((r0||!e)&&(typeof e>"u"||typeof e=="object"))try{var n=No.call(e);return(n===Qw||n===e0||n===t0||n===Kw)&&e("")==null}catch{}return!1})}var Gf=Rr?function(e){if(ic(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;try{Rr(e,null,nc)}catch(n){if(n!==Mo)return!1}return!rc(e)&&gl(e)}:function(e){if(ic(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;if(n0)return gl(e);if(rc(e))return!1;var n=No.call(e);return n!==Jw&&n!==Xw&&!/^\[object HTML/.test(n)?!1:gl(e)},s0=Gf,o0=function(e){return!!e},bt=Kt,po=G,a0=Yt,td=s0,ml=o0,l0=function(e){if(!a0(e))throw new po("ToPropertyDescriptor requires an object");var n={};if(bt(e,"enumerable")&&(n["[[Enumerable]]"]=ml(e.enumerable)),bt(e,"configurable")&&(n["[[Configurable]]"]=ml(e.configurable)),bt(e,"value")&&(n["[[Value]]"]=e.value),bt(e,"writable")&&(n["[[Writable]]"]=ml(e.writable)),bt(e,"get")){var r=e.get;if(typeof r<"u"&&!td(r))throw new po("getter must be a function");n["[[Get]]"]=r}if(bt(e,"set")){var i=e.set;if(typeof i<"u"&&!td(i))throw new po("setter must be a function");n["[[Set]]"]=i}if((bt(n,"[[Get]]")||bt(n,"[[Set]]"))&&(bt(n,"[[Value]]")||bt(n,"[[Writable]]")))throw new po("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute");return n},vl=G,c0=Yt,nd=ai,u0=uu,h0=Hf,d0=Bf,p0=li,f0=Vf,g0=l0,m0=function(e,n,r){if(!c0(e))throw new vl("Assertion failed: Type(O) is not Object");if(!p0(n))throw new vl("Assertion failed: P is not a Property Key");var i=nd(r)?r:g0(r);if(!nd(i))throw new vl("Assertion failed: Desc is not a valid Property Descriptor");return u0(d0,f0,h0,e,n,i)},rd=G,v0=Yt,y0=m0,b0=li,w0=function(e,n,r){if(!v0(e))throw new rd("Assertion failed: Type(O) is not Object");if(!b0(n))throw new rd("Assertion failed: P is not a Property Key");var i={"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Value]]":r,"[[Writable]]":!0};return y0(e,n,i)},_0=typeof Reflect<"u"&&Reflect.setPrototypeOf||null,S0=ru,k0=S0.setPrototypeOf||null,x0=Ra,id=si,E0=G,Wf={};try{Wf.__proto__=null}catch(t){if(!t||typeof t!="object"||!("code"in t)||t.code!=="ERR_PROTO_ACCESS")throw t}var $0=!("toString"in Wf),yl=id&&id(Object.prototype,"__proto__"),A0=$0&&(!!yl&&typeof yl.set=="function"&&x0([yl.set])||function(e,n){if(e==null)throw new E0("set Object.prototype.__proto__ called on null or undefined");return e.__proto__=n,n}),sd=_0,T0=k0,od=A0,C0=G,I0=sd?function(e,n){if(sd(e,n))return e;throw new C0("Reflect.setPrototypeOf: failed to set [[Prototype]]")}:T0||(od?function(e,n){return od(e,n),e}:null),ad=G,P0=Yt,ld=Mf,R0=function(e){if(!P0(e))throw new ad("Assertion failed: O must be an Object");if(!ld)throw new ad("This environment does not support fetching prototypes.");return ld(e)},D0=G,O0=I0,z0=Yt,L0=R0,M0=function(e,n){if(n!==null&&!z0(n))throw new D0("Assertion failed: V must be Object or Null");try{O0(e,n)}catch{return!1}return L0(e)===n},bl=hu,cd=w0,qf=M0,N0=Pa(),du=Pf;function Ws(t,e,n){var r=new du(n);return qf(r,Uo),delete r.constructor,cd(r,"error",t),cd(r,"suppressed",e),r}N0&&Object.defineProperty(Ws,"prototype",{writable:!1});var Uo=Ws.prototype;if(!bl(Uo,"constructor",Ws)||!bl(Uo,"message","")||!bl(Uo,"name","SuppressedError"))throw new du("unable to install SuppressedError.prototype properties; please report this!");qf(Ws.prototype,du.prototype);var U0=Ws,F0=U0,Yf=function(){return typeof SuppressedError=="function"?SuppressedError:F0},Z0=hr,ud=nu(),H0=Yf,B0=function(){var e=H0();return Z0(ud,{SuppressedError:e},{SuppressedError:function(){return ud.SuppressedError!==e}}),e};B0();var V0=G,j0=ai,G0=Zf,W0=function(e){if(typeof e<"u"&&!j0(e))throw new V0("Assertion failed: `Desc` must be a Property Descriptor");return G0(e)},q0=G,hd=Kt,Y0=ai,K0=function(e){if(typeof e>"u")return!1;if(!Y0(e))throw new q0("Assertion failed: `Desc` must be a Property Descriptor");return!(!hd(e,"[[Value]]")&&!hd(e,"[[Writable]]"))},dd=su,J0=function(e,n){return e===n?e===0?1/e===1/n:!0:dd(e)&&dd(n)},ci=Gf,X0=function(e){return!!e},wt=Kt,fo=G,Q0=Yt,pd=ci,wl=X0,e_=function(e){if(!Q0(e))throw new fo("ToPropertyDescriptor requires an object");var n={};if(wt(e,"enumerable")&&(n["[[Enumerable]]"]=wl(e.enumerable)),wt(e,"configurable")&&(n["[[Configurable]]"]=wl(e.configurable)),wt(e,"value")&&(n["[[Value]]"]=e.value),wt(e,"writable")&&(n["[[Writable]]"]=wl(e.writable)),wt(e,"get")){var r=e.get;if(typeof r<"u"&&!pd(r))throw new fo("getter must be a function");n["[[Get]]"]=r}if(wt(e,"set")){var i=e.set;if(typeof i<"u"&&!pd(i))throw new fo("setter must be a function");n["[[Set]]"]=i}if((wt(n,"[[Get]]")||wt(n,"[[Set]]"))&&(wt(n,"[[Value]]")||wt(n,"[[Writable]]")))throw new fo("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute");return n},_l=G,t_=Yt,fd=ai,n_=uu,r_=W0,i_=K0,s_=li,o_=J0,a_=e_,qs=function(e,n,r){if(!t_(e))throw new _l("Assertion failed: Type(O) is not Object");if(!s_(n))throw new _l("Assertion failed: P is not a Property Key");var i=fd(r)?r:a_(r);if(!fd(i))throw new _l("Assertion failed: Desc is not a valid Property Descriptor");return n_(i_,o_,r_,e,n,i)},l_=oi(),c_=l_?Symbol.dispose||Symbol("Symbol.dispose"):null,u_=oi,h_=c_,pu=function(){return u_()&&Symbol.dispose||h_},d_=ou,p_=qs,f_=pu,g_=function(){var e=f_();return d_()&&p_(Symbol,"dispose",{"[[Configurable]]":!1,"[[Enumerable]]":!1,"[[Writable]]":!1,"[[Value]]":e}),e},m_=oi(),v_=m_?Symbol.asyncDispose||Symbol("Symbol.asyncDispose"):null,y_=oi,b_=v_,fu=function(){return y_()&&Symbol.asyncDispose||b_},w_=ou,__=qs,S_=fu,k_=function(){var e=S_();return w_()&&__(Symbol,"asyncDispose",{"[[Configurable]]":!1,"[[Enumerable]]":!1,"[[Writable]]":!1,"[[Value]]":e}),e},x_=cu(),E_=st,$_=wn(),A_=G,T_=x_,C_=E_("%Reflect.apply%",!0)||$_("Function.prototype.apply"),Da=function(e,n){var r=arguments.length>2?arguments[2]:[];if(!T_(r))throw new A_("Assertion failed: optional `argumentsList`, if provided, must be a List");return C_(e,n,r)};const I_={},P_=Object.freeze(Object.defineProperty({__proto__:null,default:I_},Symbol.toStringTag,{value:"Module"})),R_=nb(P_);var gu=typeof Map=="function"&&Map.prototype,Sl=Object.getOwnPropertyDescriptor&&gu?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,Ko=gu&&Sl&&typeof Sl.get=="function"?Sl.get:null,gd=gu&&Map.prototype.forEach,mu=typeof Set=="function"&&Set.prototype,kl=Object.getOwnPropertyDescriptor&&mu?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,Jo=mu&&kl&&typeof kl.get=="function"?kl.get:null,md=mu&&Set.prototype.forEach,D_=typeof WeakMap=="function"&&WeakMap.prototype,ji=D_?WeakMap.prototype.has:null,O_=typeof WeakSet=="function"&&WeakSet.prototype,Gi=O_?WeakSet.prototype.has:null,z_=typeof WeakRef=="function"&&WeakRef.prototype,vd=z_?WeakRef.prototype.deref:null,L_=Boolean.prototype.valueOf,M_=Object.prototype.toString,N_=Function.prototype.toString,U_=String.prototype.match,vu=String.prototype.slice,hn=String.prototype.replace,F_=String.prototype.toUpperCase,yd=String.prototype.toLowerCase,Kf=RegExp.prototype.test,bd=Array.prototype.concat,Tt=Array.prototype.join,Z_=Array.prototype.slice,wd=Math.floor,sc=typeof BigInt=="function"?BigInt.prototype.valueOf:null,xl=Object.getOwnPropertySymbols,oc=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,ei=typeof Symbol=="function"&&typeof Symbol.iterator=="object",Wi=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===ei||!0)?Symbol.toStringTag:null,Jf=Object.prototype.propertyIsEnumerable,_d=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(t){return t.__proto__}:null);function Sd(t,e){if(t===1/0||t===-1/0||t!==t||t&&t>-1e3&&t<1e3||Kf.call(/e/,e))return e;var n=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof t=="number"){var r=t<0?-wd(-t):wd(t);if(r!==t){var i=String(r),s=vu.call(e,i.length+1);return hn.call(i,n,"$&_")+"."+hn.call(hn.call(s,/([0-9]{3})/g,"$&_"),/_$/,"")}}return hn.call(e,n,"$&_")}var ac=R_,kd=ac.custom,xd=eg(kd)?kd:null,Xf={__proto__:null,double:'"',single:"'"},H_={__proto__:null,double:/(["\\])/g,single:/(['\\])/g},ui=function t(e,n,r,i){var s=n||{};if(Lt(s,"quoteStyle")&&!Lt(Xf,s.quoteStyle))throw new TypeError('option "quoteStyle" must be "single" or "double"');if(Lt(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=Lt(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(Lt(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(Lt(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 ng(e,s);if(typeof e=="number"){if(e===0)return 1/0/e>0?"0":"-0";var c=String(e);return a?Sd(e,c):c}if(typeof e=="bigint"){var u=String(e)+"n";return a?Sd(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 lc(e)?"[Array]":"[Object]";var p=oS(s,r);if(typeof i>"u")i=[];else if(tg(i,e)>=0)return"[Circular]";function y(mt,Xt,Ka){if(Xt&&(i=Z_.call(i),i.push(Xt)),Ka){var ro={depth:s.depth};return Lt(s,"quoteStyle")&&(ro.quoteStyle=s.quoteStyle),t(mt,ro,r+1,i)}return t(mt,s,r+1,i)}if(typeof e=="function"&&!Ed(e)){var v=J_(e),$=go(e,y);return"[Function"+(v?": "+v:" (anonymous)")+"]"+($.length>0?" { "+Tt.call($,", ")+" }":"")}if(eg(e)){var k=ei?hn.call(String(e),/^(Symbol\(.*\))_[^)]*$/,"$1"):oc.call(e);return typeof e=="object"&&!ei?ki(k):k}if(rS(e)){for(var I="<"+yd.call(String(e.nodeName)),B=e.attributes||[],P=0;P<B.length;P++)I+=" "+B[P].name+"="+Qf(B_(B[P].value),"double",s);return I+=">",e.childNodes&&e.childNodes.length&&(I+="..."),I+="</"+yd.call(String(e.nodeName))+">",I}if(lc(e)){if(e.length===0)return"[]";var K=go(e,y);return p&&!sS(K)?"["+cc(K,p)+"]":"[ "+Tt.call(K,", ")+" ]"}if(j_(e)){var L=go(e,y);return!("cause"in Error.prototype)&&"cause"in e&&!Jf.call(e,"cause")?"{ ["+String(e)+"] "+Tt.call(bd.call("[cause]: "+y(e.cause),L),", ")+" }":L.length===0?"["+String(e)+"]":"{ ["+String(e)+"] "+Tt.call(L,", ")+" }"}if(typeof e=="object"&&o){if(xd&&typeof e[xd]=="function"&&ac)return ac(e,{depth:d-r});if(o!=="symbol"&&typeof e.inspect=="function")return e.inspect()}if(X_(e)){var Z=[];return gd&&gd.call(e,function(mt,Xt){Z.push(y(Xt,e,!0)+" => "+y(mt,e))}),$d("Map",Ko.call(e),Z,p)}if(tS(e)){var N=[];return md&&md.call(e,function(mt){N.push(y(mt,e))}),$d("Set",Jo.call(e),N,p)}if(Q_(e))return El("WeakMap");if(nS(e))return El("WeakSet");if(eS(e))return El("WeakRef");if(W_(e))return ki(y(Number(e)));if(Y_(e))return ki(y(sc.call(e)));if(q_(e))return ki(L_.call(e));if(G_(e))return ki(y(String(e)));if(typeof window<"u"&&e===window)return"{ [object Window] }";if(typeof globalThis<"u"&&e===globalThis||typeof Pn<"u"&&e===Pn)return"{ [object globalThis] }";if(!V_(e)&&!Ed(e)){var ce=go(e,y),ue=_d?_d(e)===Object.prototype:e instanceof Object||e.constructor===Object,yi=e instanceof Object?"":"null prototype",no=!ue&&Wi&&Object(e)===e&&Wi in e?vu.call(_n(e),8,-1):yi?"Object":"",Ee=ue||typeof e.constructor!="function"?"":e.constructor.name?e.constructor.name+" ":"",xn=Ee+(no||yi?"["+Tt.call(bd.call([],no||[],yi||[]),": ")+"] ":"");return ce.length===0?xn+"{}":p?xn+"{"+cc(ce,p)+"}":xn+"{ "+Tt.call(ce,", ")+" }"}return String(e)};function Qf(t,e,n){var r=n.quoteStyle||e,i=Xf[r];return i+t+i}function B_(t){return hn.call(String(t),/"/g,""")}function dr(t){return!Wi||!(typeof t=="object"&&(Wi in t||typeof t[Wi]<"u"))}function lc(t){return _n(t)==="[object Array]"&&dr(t)}function V_(t){return _n(t)==="[object Date]"&&dr(t)}function Ed(t){return _n(t)==="[object RegExp]"&&dr(t)}function j_(t){return _n(t)==="[object Error]"&&dr(t)}function G_(t){return _n(t)==="[object String]"&&dr(t)}function W_(t){return _n(t)==="[object Number]"&&dr(t)}function q_(t){return _n(t)==="[object Boolean]"&&dr(t)}function eg(t){if(ei)return t&&typeof t=="object"&&t instanceof Symbol;if(typeof t=="symbol")return!0;if(!t||typeof t!="object"||!oc)return!1;try{return oc.call(t),!0}catch{}return!1}function Y_(t){if(!t||typeof t!="object"||!sc)return!1;try{return sc.call(t),!0}catch{}return!1}var K_=Object.prototype.hasOwnProperty||function(t){return t in this};function Lt(t,e){return K_.call(t,e)}function _n(t){return M_.call(t)}function J_(t){if(t.name)return t.name;var e=U_.call(N_.call(t),/^function\s*([\w$]+)/);return e?e[1]:null}function tg(t,e){if(t.indexOf)return t.indexOf(e);for(var n=0,r=t.length;n<r;n++)if(t[n]===e)return n;return-1}function X_(t){if(!Ko||!t||typeof t!="object")return!1;try{Ko.call(t);try{Jo.call(t)}catch{return!0}return t instanceof Map}catch{}return!1}function Q_(t){if(!ji||!t||typeof t!="object")return!1;try{ji.call(t,ji);try{Gi.call(t,Gi)}catch{return!0}return t instanceof WeakMap}catch{}return!1}function eS(t){if(!vd||!t||typeof t!="object")return!1;try{return vd.call(t),!0}catch{}return!1}function tS(t){if(!Jo||!t||typeof t!="object")return!1;try{Jo.call(t);try{Ko.call(t)}catch{return!0}return t instanceof Set}catch{}return!1}function nS(t){if(!Gi||!t||typeof t!="object")return!1;try{Gi.call(t,Gi);try{ji.call(t,ji)}catch{return!0}return t instanceof WeakSet}catch{}return!1}function rS(t){return!t||typeof t!="object"?!1:typeof HTMLElement<"u"&&t instanceof HTMLElement?!0:typeof t.nodeName=="string"&&typeof t.getAttribute=="function"}function ng(t,e){if(t.length>e.maxStringLength){var n=t.length-e.maxStringLength,r="... "+n+" more character"+(n>1?"s":"");return ng(vu.call(t,0,e.maxStringLength),e)+r}var i=H_[e.quoteStyle||"single"];i.lastIndex=0;var s=hn.call(hn.call(t,i,"\\$1"),/[\x00-\x1f]/g,iS);return Qf(s,"single",e)}function iS(t){var e=t.charCodeAt(0),n={8:"b",9:"t",10:"n",12:"f",13:"r"}[e];return n?"\\"+n:"\\x"+(e<16?"0":"")+F_.call(e.toString(16))}function ki(t){return"Object("+t+")"}function El(t){return t+" { ? }"}function $d(t,e,n,r){var i=r?cc(n,r):Tt.call(n,", ");return t+" ("+e+") {"+i+"}"}function sS(t){for(var e=0;e<t.length;e++)if(tg(t[e],`
|
|
2
|
+
`)>=0)return!1;return!0}function oS(t,e){var n;if(t.indent===" ")n=" ";else if(typeof t.indent=="number"&&t.indent>0)n=Tt.call(Array(t.indent+1)," ");else return null;return{base:n,prev:Tt.call(Array(e+1),n)}}function cc(t,e){if(t.length===0)return"";var n=`
|
|
3
|
+
`+e.prev+e.base;return n+Tt.call(t,","+n)+`
|
|
4
|
+
`+e.prev}function go(t,e){var n=lc(t),r=[];if(n){r.length=t.length;for(var i=0;i<t.length;i++)r[i]=Lt(t,i)?e(t[i],t):""}var s=typeof xl=="function"?xl(t):[],o;if(ei){o={};for(var a=0;a<s.length;a++)o["$"+s[a]]=s[a]}for(var c in t)Lt(t,c)&&(n&&String(Number(c))===c&&c<t.length||ei&&o["$"+c]instanceof Symbol||(Kf.call(/[^\w$]/,c)?r.push(e(c,t)+": "+e(t[c],t)):r.push(c+": "+e(t[c],t))));if(typeof xl=="function")for(var u=0;u<s.length;u++)Jf.call(t,s[u])&&r.push("["+e(s[u])+"]: "+e(t[s[u]],t));return r}var aS=ui,lS=G,Oa=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},cS=function(t,e){if(t){var n=Oa(t,e);return n&&n.value}},uS=function(t,e,n){var r=Oa(t,e);r?r.value=n:t.next={key:e,next:t.next,value:n}},hS=function(t,e){return t?!!Oa(t,e):!1},dS=function(t,e){if(t)return Oa(t,e,!0)},pS=function(){var e,n={assert:function(r){if(!n.has(r))throw new lS("Side channel does not contain "+aS(r))},delete:function(r){var i=e&&e.next,s=dS(e,r);return s&&i&&i===s&&(e=void 0),!!s},get:function(r){return cS(e,r)},has:function(r){return hS(e,r)},set:function(r,i){e||(e={next:void 0}),uS(e,r,i)}};return n},fS=st,Ys=wn(),gS=ui,mS=G,Ad=fS("%Map%",!0),vS=Ys("Map.prototype.get",!0),yS=Ys("Map.prototype.set",!0),bS=Ys("Map.prototype.has",!0),wS=Ys("Map.prototype.delete",!0),_S=Ys("Map.prototype.size",!0),rg=!!Ad&&function(){var e,n={assert:function(r){if(!n.has(r))throw new mS("Side channel does not contain "+gS(r))},delete:function(r){if(e){var i=wS(e,r);return _S(e)===0&&(e=void 0),i}return!1},get:function(r){if(e)return vS(e,r)},has:function(r){return e?bS(e,r):!1},set:function(r,i){e||(e=new Ad),yS(e,r,i)}};return n},SS=st,za=wn(),kS=ui,mo=rg,xS=G,kr=SS("%WeakMap%",!0),ES=za("WeakMap.prototype.get",!0),$S=za("WeakMap.prototype.set",!0),AS=za("WeakMap.prototype.has",!0),TS=za("WeakMap.prototype.delete",!0),CS=kr?function(){var e,n,r={assert:function(i){if(!r.has(i))throw new xS("Side channel does not contain "+kS(i))},delete:function(i){if(kr&&i&&(typeof i=="object"||typeof i=="function")){if(e)return TS(e,i)}else if(mo&&n)return n.delete(i);return!1},get:function(i){return kr&&i&&(typeof i=="object"||typeof i=="function")&&e?ES(e,i):n&&n.get(i)},has:function(i){return kr&&i&&(typeof i=="object"||typeof i=="function")&&e?AS(e,i):!!n&&n.has(i)},set:function(i,s){kr&&i&&(typeof i=="object"||typeof i=="function")?(e||(e=new kr),$S(e,i,s)):mo&&(n||(n=mo()),n.set(i,s))}};return r}:mo,IS=G,PS=ui,RS=pS,DS=rg,OS=CS,zS=OS||DS||RS,LS=function(){var e,n={assert:function(r){if(!n.has(r))throw new IS("Side channel does not contain "+PS(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=zS()),e.set(r,i)}};return n},MS=Kt,xi=LS(),Dt=G,yu={assert:function(t,e){if(!t||typeof t!="object"&&typeof t!="function")throw new Dt("`O` is not an object");if(typeof e!="string")throw new Dt("`slot` must be a string");if(xi.assert(t),!yu.has(t,e))throw new Dt("`"+e+"` is not present on `O`")},get:function(t,e){if(!t||typeof t!="object"&&typeof t!="function")throw new Dt("`O` is not an object");if(typeof e!="string")throw new Dt("`slot` must be a string");var n=xi.get(t);return n&&n["$"+e]},has:function(t,e){if(!t||typeof t!="object"&&typeof t!="function")throw new Dt("`O` is not an object");if(typeof e!="string")throw new Dt("`slot` must be a string");var n=xi.get(t);return!!n&&MS(n,"$"+e)},set:function(t,e,n){if(!t||typeof t!="object"&&typeof t!="function")throw new Dt("`O` is not an object");if(typeof e!="string")throw new Dt("`slot` must be a string");var r=xi.get(t);r||(r={},xi.set(t,r)),r["$"+e]=n}};Object.freeze&&Object.freeze(yu);var bu=yu,ig=qt,dn=bu,Ks=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 ig('Assertion failed: `type` must be one of "normal", "break", "continue", "return", or "throw"');dn.set(this,"[[Type]]",e),dn.set(this,"[[Value]]",n)};Ks.prototype.type=function(){return dn.get(this,"[[Type]]")};Ks.prototype.value=function(){return dn.get(this,"[[Value]]")};Ks.prototype["?"]=function(){var e=dn.get(this,"[[Type]]"),n=dn.get(this,"[[Value]]");if(e==="throw")throw n;return n};Ks.prototype["!"]=function(){var e=dn.get(this,"[[Type]]");if(e!=="normal")throw new ig('Assertion failed: Completion Record is not of type "normal"');return dn.get(this,"[[Value]]")};var wu=Ks,NS=wu,_u=function(e){return new NS("normal",e)},$l,Td;function US(){if(Td)return $l;Td=1;var t=oi;return $l=function(){return t()&&!!Symbol.toStringTag},$l}var FS=st,Cd=FS("%Object.defineProperty%",!0),ZS=US()(),HS=Kt,BS=G,vo=ZS?Symbol.toStringTag:null,sg=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 BS("if provided, the `overrideIfSet` and `nonConfigurable` options must be booleans");vo&&(r||!HS(e,vo))&&(Cd?Cd(e,vo,{configurable:!i,enumerable:!1,value:n,writable:!1}):e[vo]=n)},og={exports:{}},VS=st,Id=kf,jS=Pa(),Pd=si,Rd=G,GS=VS("%Math.floor%"),WS=function(e,n){if(typeof e!="function")throw new Rd("`fn` is not a function");if(typeof n!="number"||n<0||n>4294967295||GS(n)!==n)throw new Rd("`length` must be a positive 32-bit integer");var r=arguments.length>2&&!!arguments[2],i=!0,s=!0;if("length"in e&&Pd){var o=Pd(e,"length");o&&!o.configurable&&(i=!1),o&&!o.writable&&(s=!1)}return(i||s||!r)&&(jS?Id(e,"length",n,!0,!0):Id(e,"length",n)),e},qS=Vs,YS=lu,KS=Of,JS=function(){return KS(qS,YS,arguments)};(function(t){var e=WS,n=Bs,r=Ra,i=JS;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})(og);var Su=og.exports,XS=function(e,n){for(var r=0;r<e.length;r+=1)if(!n(e[r],r,e))return!1;return!0},QS=Object,ek=function(e){return e&&typeof e=="object"&&(typeof e["[[ResourceValue]]"]>"u"||QS(e["[[ResourceValue]]"])===e["[[ResourceValue]]"])&&(e["[[Hint]]"]==="SYNC-DISPOSE"||e["[[Hint]]"]==="ASYNC-DISPOSE")&&(typeof e["[[DisposeMethod]]"]=="function"||typeof e["[[DisposeMethod]]"]>"u")},tk=Kt,nk=cu(),rk=XS,ik=ek,sk=function(e){return e&&typeof e=="object"&&tk(e,"[[DisposableResourceStack]]")&&nk(e["[[DisposableResourceStack]]"])&&(e["[[DisposableResourceStack]]"].length===0||rk(e["[[DisposableResourceStack]]"],ik))},ok=Yt,ak=function(e){if(e===null)return"Null";if(typeof e>"u")return"Undefined";if(ok(e))return"Object";if(typeof e=="number")return"Number";if(typeof e=="boolean")return"Boolean";if(typeof e=="string")return"String"},lk=ak,ku=function(e){return typeof e=="symbol"?"Symbol":typeof e=="bigint"?"BigInt":lk(e)},ck=G,uk=ui,hk=li,dk=function(e,n){if(!hk(n))throw new ck("Assertion failed: P is not a Property Key, got "+uk(n));return e[n]},Dd=G,pk=dk,fk=ci,gk=li,Od=ui,mk=function(e,n){if(!gk(n))throw new Dd("Assertion failed: P is not a Property Key");var r=pk(e,n);if(r!=null){if(!fk(r))throw new Dd(Od(n)+" is not a function: "+Od(r));return r}},uc={exports:{}},vk=st,yk=vk,zd=yk("%Reflect.construct%",!0),Xo=qs;try{Xo({},"",{"[[Get]]":function(){}})}catch{Xo=null}if(Xo&&zd){var Ld={},Md={};Xo(Md,"length",{"[[Get]]":function(){throw Ld},"[[Enumerable]]":!0}),uc.exports=function(e){try{zd(e,Md)}catch(n){return n===Ld}}}else uc.exports=function(e){return typeof e=="function"&&!!e.prototype};var bk=uc.exports,Al=G,Nd=ci,wk=bk,_k=function(e){if(!wk(e))throw new Al("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 Al("executor has already been called");n["[[Resolve]]"]=i,n["[[Reject]]"]=s});if(!Nd(n["[[Resolve]]"])||!Nd(n["[[Reject]]"]))throw new Al("executor must provide valid resolve and reject functions");return{"[[Promise]]":r,"[[Resolve]]":n["[[Resolve]]"],"[[Reject]]":n["[[Reject]]"]}},Ud=qt,Sk=G,Tl=Da,Fd=mk,kk=_k,xk=ku,Zd=pu(),Hd=fu(),Ek=function(e,n){if(xk(e)!=="Object")throw new Sk("`V` must be an Object");if(n!=="SYNC-DISPOSE"&&n!=="ASYNC-DISPOSE")throw new Ud("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");var r;if(n==="ASYNC-DISPOSE"&&Hd&&(r=Fd(e,Hd)),!r){if(!Zd)throw new Ud("`Symbol.dispose` is not supported");if(r=Fd(e,Zd),typeof r<"u")return function(){var i=this;if(n==="ASYNC-DISPOSE"){var s=kk(Promise);try{Tl(r,i),Tl(s["[[Resolve]]"],void 0,[void 0])}catch(o){s["[[Reject]]"](o)}return s["[[Promise]]"]}Tl(r,i)}}return r},$k=qt,Cl=G,Ak=ci,Tk=ku,Ck=Ek,Ik=function(e,n){if(n!=="SYNC-DISPOSE"&&n!=="ASYNC-DISPOSE")throw new $k("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");var r;if(arguments.length<3)if(e==null)e=void 0,r=void 0;else{if(typeof e<"u"&&Tk(e)!=="Object")throw new Cl("`V` must be an Object, or `null` or `undefined`");if(r=Ck(e,n),typeof r>"u")throw new Cl("dispose method must not be `undefined` on `V` when an object `V` is provided")}else if(r=arguments[2],!Ak(r))throw new Cl("`method`, when provided, must be a function");return{"[[ResourceValue]]":e,"[[Hint]]":n,"[[DisposeMethod]]":r}},Pk=qt,yo=G,Rk=sk,Bd=Ik,Dk=wn(),Ok=Dk("Array.prototype.push"),ag=function(e,n,r){if(!Rk(e))throw new yo("Assertion failed: `disposeCapability` must be a DisposeCapability Record");if(r!=="SYNC-DISPOSE"&&r!=="ASYNC-DISPOSE")throw new Pk("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 yo("Assertion failed: `method`, when present, must be a function");if(!e["[[DisposableResourceStack]]"])throw new yo("Assertion failed: `disposeCapability.[[DisposableResourceStack]]` must not be ~EMPTY~");var s;if(arguments.length<4){if(n==null&&r==="SYNC_DISPOSE")return"UNUSED";s=Bd(n,r)}else{if(typeof n<"u")throw new yo("Assertion failed: `V` must be undefined when `method` is present");s=Bd(void 0,r,i)}return Ok(e["[[DisposableResourceStack]]"],s),"UNUSED"},Il,Vd;function xu(){if(Vd)return Il;Vd=1;var t=st,e=Su,n=qt,r=t("%Promise.resolve%",!0),i=r&&e(r);return Il=function(o,a){if(!i)throw new n("This environment does not support Promises.");return i(o,a)},Il}var Pl,jd;function zk(){if(jd)return Pl;jd=1;var t=st,e=qt,n=t("%Promise%",!0),r=Da,i=xu(),s=ku;return Pl=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)},Pl}var Rl,Gd;function Lk(){if(Gd)return Rl;Gd=1;var t=wu;return Rl=function(n){return new t("throw",n)},Rl}var Mk=st,Dl=qt,Wd=G,Nk=Mk("%Promise%",!0),Uk=wn(),qd=Uk("Promise.prototype.then",!0),Fk=wu,Yd=zk(),Zk=_u,Hk=xu(),Kd=Lk(),Bk=Yf(),lg=function(e,n){if(!(n instanceof Fk))throw new Wd("`completion` must be a Completion Record");var r=e["[[DisposableResourceStack]]"];if(!r)throw new Wd("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 Dl("mixed hint stacks are not supported");for(var o=i==="ASYNC-DISPOSE"&&Hk(Nk,n),a=function(y){if(n.type()==="throw"){var v=n.value(),$=new Bk(y,v);n=Kd($)}else n=Kd(y)},c=i==="ASYNC-DISPOSE"&&function(v){return qd(o,function(){var $=Yd(v["[[ResourceValue]]"],v["[[Hint]]"],v["[[DisposeMethod]]"]);if(!$)throw new Dl("Assertion failed: non-`~ASYNC-DISPOSE~` resource returned a promise from Dispose");return qd($,Zk)},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=Yd(d["[[ResourceValue]]"],d["[[Hint]]"],d["[[DisposeMethod]]"]);if(p)throw new Dl("Assertion failed: `~SYNC-DISPOSE~` resource returned something from Dispose")}catch(y){a(y)}}return e["[[DisposableResourceStack]]"]=null,i==="ASYNC-DISPOSE"?o:n},cg=function(){var e=[];return{"[[DisposableResourceStack]]":e}},La=iu,Eu=G,Vk=Da,hi=hu,jk=qs,ug=ci,Gk=_u,Ve=bu,Wk=sg,hg=hr.supportsDescriptors,qk=Su,$u=ag,Yk=lg,dg=cg,Jd=pu(),nt=function t(){if(!(this instanceof t)||Ve.has(this,"[[DisposableState]]")||Ve.has(this,"[[DisposeCapability]]"))throw new Eu("can only be used with new");Ve.set(this,"[[DisposableState]]","PENDING"),Ve.set(this,"[[DisposeCapability]]",dg())},pg=function(){var e=this;return Ve.assert(e,"[[DisposableState]]"),Ve.get(e,"[[DisposableState]]")==="DISPOSED"},Js=qk(pg);hg?jk(nt.prototype,"disposed",{"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Get]]":pg}):nt.prototype.disposed=!1;var fg=function(e){Ve.set(e,"[[DisposableState]]","DISPOSED"),hg||(e.disposed=!0)};hi(nt.prototype,"dispose",function(){var e=this;if(!Js(e))return fg(e),Yk(Ve.get(e,"[[DisposeCapability]]"),Gk())["?"]()});hi(nt.prototype,"use",function(e){var n=this;if(Js(n))throw new La("a disposed stack can not use anything new");return $u(Ve.get(n,"[[DisposeCapability]]"),e,"SYNC-DISPOSE"),e});hi(nt.prototype,"adopt",function(e,n){var r=this;if(Js(r))throw new La("a disposed stack can not use anything new");if(!ug(n))throw new Eu("`onDispose` must be a function");var i=function(){return Vk(n,void 0,[e])};return $u(Ve.get(r,"[[DisposeCapability]]"),void 0,"SYNC-DISPOSE",i),e});hi(nt.prototype,"defer",function(e){var n=this;if(Js(n))throw new La("a disposed stack can not defer anything new");if(!ug(e))throw new Eu("`onDispose` must be a function");$u(Ve.get(n,"[[DisposeCapability]]"),void 0,"SYNC-DISPOSE",e)});hi(nt.prototype,"move",function(){var e=this;if(Js(e))throw new La("a disposed stack can not use anything new");var n=new nt;return Ve.set(n,"[[DisposeCapability]]",Ve.get(e,"[[DisposeCapability]]")),Ve.set(e,"[[DisposeCapability]]",dg()),fg(e),n});Jd&&hi(nt.prototype,Jd,nt.prototype.dispose);Wk(nt.prototype,"DisposableStack");var Kk=nt,Jk=Kk,Xk=function(){return typeof DisposableStack=="function"?DisposableStack:Jk},Qk=hr,ex=nu(),tx=Xk,nx=function(){var e=tx();return Qk(ex,{DisposableStack:e},{DisposableStack:!0}),e},rx=st,Ma=iu,Au=G,Xd=rx("%Promise%",!0),Tu=ag,ix=Da,di=hu,sx=qs,ox=lg,gg=ci,mg=cg,ax=_u,Qd=xu(),je=bu,lx=sg,vg=hr.supportsDescriptors,cx=Su,ux=wn(),hx=ux("Promise.prototype.then",!0),ep=fu(),rt=function t(){if(!(this instanceof t)||je.has(this,"[[AsyncDisposableState]]")||je.has(this,"[[DisposeCapability]]"))throw new Au("can only be used with new");je.set(this,"[[AsyncDisposableState]]","pending"),je.set(this,"[[DisposeCapability]]",mg())},yg=function(){var e=this;return je.assert(e,"[[AsyncDisposableState]]"),je.get(e,"[[AsyncDisposableState]]")==="disposed"},Xs=cx(yg);vg?sx(rt.prototype,"disposed",{"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Get]]":yg}):rt.prototype.disposed=!1;var bg=function(e){je.set(e,"[[AsyncDisposableState]]","disposed"),vg||(e.disposed=!0)};di(rt.prototype,"disposeAsync",function(){var e=this;return Xs(e)?Qd(Xd):(bg(e),hx(Qd(Xd,ox(je.get(e,"[[DisposeCapability]]"),ax())),function(n){return n["?"]()}))});di(rt.prototype,"use",function(e){var n=this;if(Xs(n))throw new Ma("a disposed stack can not use anything new");return Tu(je.get(n,"[[DisposeCapability]]"),e,"ASYNC-DISPOSE"),e});di(rt.prototype,"adopt",function(e,n){var r=this;if(Xs(r))throw new Ma("a disposed stack can not use anything new");if(!gg(n))throw new Au("`onDisposeAsync` must be a function");var i=function(){return ix(n,void 0,[e])};return i.value=e,Tu(je.get(r,"[[DisposeCapability]]"),void 0,"ASYNC-DISPOSE",i),e});di(rt.prototype,"defer",function(e){var n=this;if(Xs(n))throw new Ma("a disposed stack can not defer anything new");if(!gg(e))throw new Au("`onDispose` must be a function");Tu(je.get(n,"[[DisposeCapability]]"),void 0,"ASYNC-DISPOSE",e)});di(rt.prototype,"move",function(){var e=this;if(Xs(e))throw new Ma("a disposed stack can not use anything new");var n=new rt;return je.set(n,"[[DisposeCapability]]",je.get(e,"[[DisposeCapability]]")),je.set(e,"[[DisposeCapability]]",mg()),bg(e),n});ep&&di(rt.prototype,ep,rt.prototype.disposeAsync);lx(rt.prototype,"AsyncDisposableStack");var dx=rt,px=dx,fx=function(){return typeof AsyncDisposableStack=="function"?AsyncDisposableStack:px},gx=hr,mx=nu(),vx=fx,yx=function(){var e=vx();return gx(mx,{AsyncDisposableStack:e},{AsyncDisposableStack:!0}),e},bx=g_,wx=k_,_x=nx,Sx=yx,kx=function(){bx(),wx(),_x(),Sx()};kx();const tp=new WeakMap;function xx(t){return(typeof t=="object"||typeof t=="function")&&t!==null&&"then"in t&&typeof t.then=="function"}function xr(t){return typeof t=="string"?t:typeof t=="symbol"?t.description??t.toString():t.name||"(anonymous class)"}function np(){return new Error("register(Key, factory) requires a factory function. Wrap existing instances as () => instance.")}function Ex(){return new Error("register(Key, factory) does not accept async factories. Await setup before registering.")}class $x{constructor(){b(this,"entries",new Map);b(this,"constructionStack",[])}register(e,n){if(n===void 0){if(typeof e!="function")throw np();this.validateClassRegistration(e),this.storeFactory(e,()=>this.instantiateClass(e));return}if(typeof n!="function")throw np();if(n.constructor.name==="AsyncFunction")throw Ex();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=tp.get(e);if(n){if(e.length!==n.length)throw new Error(`${xr(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(`${xr(e)} cannot be registered with register(Class). Undecorated classes must have zero required constructor parameters. Use register(Key, () => value) instead.`)}instantiateClass(e){const n=tp.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(`${xr(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=>xr(i)).join(" -> ");throw new Error(`Circular dependency detected: ${r}`)}this.constructionStack.push(e.key);try{const r=e.factory();if(xx(r))throw new Error(`Factory for ${xr(e.key)} returned a Promise. Await setup before registering.`);if(typeof r!="object"||r===null)throw new Error(`Factory for ${xr(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 Ge=new $x,Ax=new Set(["target","currentTarget","eventPhase","defaultPrevented","isTrusted","timeStamp","srcElement","returnValue","cancelBubble","NONE","CAPTURING_PHASE","AT_TARGET","BUBBLING_PHASE","composedPath","stopPropagation","stopImmediatePropagation","preventDefault","initEvent"]);function Tx(t){for(const e of Object.keys(t))if(Ax.has(e))throw new Error(`Event payload key "${e}" is reserved; choose a different property name`)}function Cx(t,e){Tx(e);for(const n of Object.keys(e))Object.defineProperty(t,n,{value:e[n],writable:!0,enumerable:!0,configurable:!0})}function ft(){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}),Cx(this,c)}}return t}class gt extends globalThis.EventTarget{}function Ix(t,e,n){const r=t.dispose.bind(t);t.dispose=()=>{if(!e())return n(),r()}}function pi(t){var n;class e extends t{constructor(...s){super(...s);_(this,n,!1);Ix(this,()=>l(this,n),()=>{x(this,n,!0)})}[Symbol.dispose](){this.dispose()}get disposed(){return l(this,n)}}return n=new WeakMap,e}const Px=ft(),Rx=ft(),Fo=ft(),wg="0123456789ABCDEFGHJKMNPQRSTVWXYZ",Qo=32,Dx=16,_g=10,rp=0xffffffffffff;var Ln;(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"})(Ln||(Ln={}));class zi extends Error{constructor(e,n){super(`${n} (${e})`),this.name="ULIDError",this.code=e}}function Ox(t){const e=Math.floor(t()*Qo)%Qo;return wg.charAt(e)}function zx(t){const e=Lx(),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 zi(Ln.PRNGDetectFailure,"Failed to find a reliable PRNG")}function Lx(){return Ux()?self:typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:null}function Mx(t,e){let n="";for(;t>0;t--)n=Ox(e)+n;return n}function Nx(t,e=_g){if(isNaN(t))throw new zi(Ln.EncodeTimeValueMalformed,`Time must be a number: ${t}`);if(t>rp)throw new zi(Ln.EncodeTimeSizeExceeded,`Cannot encode a time larger than ${rp}: ${t}`);if(t<0)throw new zi(Ln.EncodeTimeNegative,`Time must be positive: ${t}`);if(Number.isInteger(t)===!1)throw new zi(Ln.EncodeTimeValueMalformed,`Time must be an integer: ${t}`);let n,r="";for(let i=e;i>0;i--)n=t%Qo,r=wg.charAt(n)+r,t=(t-n)/Qo;return r}function Ux(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}function Cu(t,e){const n=zx(),r=Date.now();return Nx(r,_g)+Mx(Dx,n)}const Ct=4,Xe=6,Sg=2,hc=2,Fx=Ct,Zx=Xe,Iu="auto",pn="auto",Rn=120,ip=75,ge=16,sr=Rn*Ct+ge*(Ct-1),ea=Rn*Xe+ge*(Xe-1),Hx=200,Bx=4,bo=150,Vx=10,sp=2,jx=4;function kg(t){return $g(t)}function xg(t,e){return $g(t.flatMap(n=>Tg(n,e)))}function Eg(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}Cg(r,"strip",e,n)}return{valid:e.length===0,errors:e}}function qi(t){const e=kg(t),n=Eg(e);if(!n.valid)throw new Error(`Invalid layout: ${n.errors.join("; ")}`);return{totalNodes:e.length,nodes:e.filter(r=>r.type!=="row").map(Yx)}}function $g(t){const e=[];for(const n of t){const r=Ag(n);for(const i of r){if(i.type==="row"){e.push(...i.children.map(Gt));continue}e.push(i)}}return e}function Ag(t){switch(t.type){case"card":return[Gt(t)];case"row":{const e=t.children.map(Gt);return e.length===0?[]:e.length===1?[e[0]]:[{...t,children:e}]}case"stack":{const e=[];for(const n of t.children){const r=Ag(n);for(const i of r){if(i.type==="stack"){e.push(...i.children.map(dc));continue}if(i.type==="row"){e.push({...i,children:i.children.map(Gt)});continue}e.push(Gt(i))}}return e.length===0?[]:e.length===1?[dc(e[0])]:[{...t,children:e}]}}}function Tg(t,e){switch(t.type){case"card":return t.artifactID===e?[]:[Gt(t)];case"row":{const n=t.children.filter(r=>r.artifactID!==e).map(Gt);return n.length===0?[]:n.length===1?[n[0]]:[{...t,children:n}]}case"stack":{const n=t.children.flatMap(r=>Tg(r,e).filter(s=>s.type!=="stack"));return n.length===0?[]:n.length===1?[dc(n[0])]:[{...t,children:n}]}}}function Cg(t,e,n,r){switch(t.type){case"card":Ig(t,e,n,r);return;case"row":Gx(t,e,n,r);return;case"stack":Wx(t,e,n,r);return}}function Ig(t,e,n,r){Pu(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),qx(t.width)||n.push(`Card ${t.id} width must be an integer in the range 2-4`),Pg(t.height)||n.push(`Card ${t.id} height must be an integer in the range 2-6 or "auto"`);const i=Dn(t.width);e==="row"&&i<Sg&&n.push(`Row child ${t.id} must be at least 2 columns wide`)}function Gx(t,e,n,r){if(Pu(t.id,n),e!=="stack"&&n.push(`Row ${t.id} may only appear inside a stack`),Pg(t.height,jx)||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}Ig(s,"row",n,r),i+=Dn(s.width)}i!==Ct&&n.push(`Row ${t.id} children must sum to 4 columns`)}function Wx(t,e,n,r){if(Pu(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(Cg(a,"stack",n,r),a.height===pn){s+=1;continue}i+=a.height}if(i>Xe&&n.push(`Stack ${t.id} exceeds the 6-row budget`),s===0)return;const o=Xe-i;if(o<s*hc||o%s!==0){n.push(`Stack ${t.id} has auto-height children that cannot resolve to whole height >= 2`);return}o/s<hc&&n.push(`Stack ${t.id} has auto-height children below the minimum row size`)}function Pu(t,e){(typeof t!="string"||t.length===0)&&e.push(`Node id must be a non-empty string: ${String(t)}`)}function qx(t){return t===Iu||Number.isInteger(t)&&t>=Sg&&t<=Fx}function Pg(t,e=Zx){return t===pn||Number.isInteger(t)&&t>=hc&&t<=e}function Dn(t){return t===Iu?Ct:t}function Yx(t){if(t.type==="card")return{id:t.id,type:"card",width:Dn(t.width),cards:[{id:t.id,artifactID:t.artifactID,col:1,row:1,width:Dn(t.width),height:Rg(t.height,Xe)}]};const e=Kx(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:Dn(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:Dn(c.width),height:o}),a+=Dn(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 Kx(t){let e=0,n=0;for(const i of t)i.height===pn?n+=1:e+=i.height;const r=n>0?(Xe-e)/n:0;return t.map(i=>Rg(i.height,r))}function Rg(t,e){return t===pn?e:t}function Gt(t){return{...t}}function dc(t){return t.type==="card"?Gt(t):{...t,children:t.children.map(Gt)}}function Dg(t,e={}){return{id:e.id??Cu(),type:"card",artifactID:t,width:e.width??Iu,height:e.height??pn}}function Og(t,e){return t.some(n=>zg(n,e))}function zg(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=>zg(n,e))}}function op(t){return t.layout.flatMap(Lg)}function Lg(t){switch(t.type){case"card":return[t.artifactID];case"row":return t.children.map(e=>e.artifactID);case"stack":return t.children.flatMap(Lg)}}const ee=ft(),Mg=ft(),Ei=ft(),Jx=ft();function Xx(t){class e extends Error{constructor(r,i){super(r),this.name=t,i&&Object.assign(this,i)}}return e}const Qx=Xx("RequestError"),eE=200,tE=300;class nE{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 rE(i);if(!i.ok||i.status<eE||i.status>=tE)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 Ol(r,r.statusText),r.status)}async requestText(e,n){const r=await this.request(e,n);if(!r.ok)throw this.createError(await Ol(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 Ol(i,i.statusText),i.status)}createError(e,n){const r={serverURL:this.serverURL};return n!==void 0&&(r.status=n),new Qx(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 rE(t){try{return await t.json()}catch{const e=await t.text().catch(()=>"");return e?{message:e}:{}}}async function Ol(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 Ng(t){return t.map(e=>`${e.name} (${e.id})`).join(", ")}var xt,da,Ug;class iE{constructor(e){_(this,da);_(this,xt);x(this,xt,e)}list(){return l(this,xt).requestJSON("GET","/screens")}async get(e={}){const n=await m(this,da,Ug).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,da=new WeakSet,Ug=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: ${Ng(n)}`)};var Ze,rs,pa,Fg;class sE{constructor(e,n){_(this,pa);_(this,Ze);_(this,rs);x(this,Ze,e),x(this,rs,n)}async create(e){const n=await m(this,pa,Fg).call(this,e.screenID);return l(this,Ze).requestJSON("POST",`/screens/${encodeURIComponent(n)}/artifact`,{type:e.type,title:e.title,externalFilePath:e.externalFilePath})}get(e){return l(this,Ze).requestJSON("GET",`/artifacts/${encodeURIComponent(e.artifactID)}`)}update(e){const n={};return e.title!==void 0&&(n.title=e.title),l(this,Ze).requestJSON("PATCH",`/artifacts/${encodeURIComponent(e.artifactID)}`,n)}edit(e){return l(this,Ze).requestJSON("POST",`/artifacts/${encodeURIComponent(e.artifactID)}/edit`)}commitPending(e){return l(this,Ze).requestJSON("POST",`/artifacts/${encodeURIComponent(e.artifactID)}/commit`)}abandonPending(e){return l(this,Ze).requestVoid("POST",`/artifacts/${encodeURIComponent(e.artifactID)}/abandon`)}remove(e){return l(this,Ze).requestJSON("DELETE",`/screens/${encodeURIComponent(e.screenID)}/artifacts/${encodeURIComponent(e.artifactID)}`)}getContent(e){return l(this,Ze).requestText("GET",`/artifacts/${encodeURIComponent(e.artifactID)}/content`)}putContent(e){return l(this,Ze).requestRawVoid("PUT",`/artifacts/${encodeURIComponent(e.artifactID)}/content`,e.content)}}Ze=new WeakMap,rs=new WeakMap,pa=new WeakSet,Fg=async function(e){if(e!==void 0)return e;const{screens:n}=await l(this,rs).list();if(n.length===1)return n[0].id;throw l(this,Ze).createError(`screenID is required when multiple screens exist. Available screens: ${Ng(n)}`)};var is;class oE{constructor(e){_(this,is);x(this,is,e)}async list(){const{views:e}=await l(this,is).requestJSON("GET","/views");return e}}is=new WeakMap;var tn;class aE{constructor(e,n={}){b(this,"screens");b(this,"artifacts");b(this,"views");_(this,tn);x(this,tn,new nE(e,n)),this.screens=new iE(l(this,tn)),this.artifacts=new sE(l(this,tn),this.screens),this.views=new oE(l(this,tn))}health(){return l(this,tn).requestJSON("GET","/health")}}tn=new WeakMap;const lE={focusCommandInput:{label:"Focus Command Input",trigger:{key:"k",meta:!0}}},cE=pi(gt);var Un,He,Fn,Le,nn,rn,X,$r,Zg,ss,Hg,Bg,Vg,jg,pc,fc,gc,Gg;class uE extends cE{constructor(n){var i;super();_(this,X);b(this,"id");b(this,"server");_(this,Un);_(this,He,new Map);_(this,Fn);_(this,Le);_(this,nn);_(this,rn,null);_(this,ss,n=>{if(this.disposed)return;const r=n.event;switch(r.type){case"screen-updated":r.screen.id===this.id&&m(this,X,Hg).call(this,r.screen);break;case"artifact-created":r.screenID===this.id&&m(this,X,Bg).call(this,r.artifact);break;case"artifact-updated":m(this,X,Vg).call(this,r.artifact);break;case"artifact-removed":r.screenID===this.id&&m(this,X,jg).call(this,r.artifactID);break;case"artifact-content-changed":l(this,He).has(r.artifactID)&&this.dispatchEvent(new Jx("artifact-content-changed",{artifactID:r.artifactID}));break}});this.id=n.screen.id,this.server=n.server,x(this,Un,n.localStore),x(this,Fn,n.screen.name),x(this,Le,structuredClone(n.screen.layout));const r=((i=l(this,Un).get().screens[this.id])==null?void 0:i.scrollPosition)??0;x(this,nn,Math.max(0,r)),this.server.addEventListener("server-event",l(this,ss)),m(this,X,Zg).call(this)}get name(){return l(this,Fn)}get layout(){return l(this,Le)}get scrollPosition(){return l(this,nn)}get artifacts(){return l(this,He)}setScrollPosition(n){m(this,X,$r).call(this);const r=Math.max(0,n);r!==l(this,nn)&&(x(this,nn,r),m(this,X,Gg).call(this),this.dispatchEvent(new ee("change")))}setLayout(n){m(this,X,$r).call(this);const r=kg(n);if(!Eg(r).valid)return;const s=m(this,X,fc).call(this);x(this,Le,r),x(this,rn,{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,rn))==null?void 0:o.layout)===r&&(x(this,rn,null),m(this,X,gc).call(this,s),this.dispatchEvent(new ee("change")))})}rename(n){m(this,X,$r).call(this),x(this,Fn,n),this.dispatchEvent(new ee("change")),this.server.client.screens.update({screenID:this.id,name:n}).catch(()=>{})}async remove(){m(this,X,$r).call(this),await this.server.client.screens.remove({screenID:this.id})}removeArtifact(n){if(m(this,X,$r).call(this),!l(this,He).has(n))return;const r=m(this,X,fc).call(this);m(this,X,pc).call(this,n),this.dispatchEvent(new ee("change")),this.server.client.artifacts.remove({artifactID:n,screenID:this.id}).catch(()=>{this.disposed||(m(this,X,gc).call(this,r),this.dispatchEvent(new ee("change")))})}dispose(){this.server.removeEventListener("server-event",l(this,ss))}}Un=new WeakMap,He=new WeakMap,Fn=new WeakMap,Le=new WeakMap,nn=new WeakMap,rn=new WeakMap,X=new WeakSet,$r=function(){if(this.disposed)throw new Error("ScreenModel is disposed")},Zg=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,He).set(r.id,r);this.dispatchEvent(new ee("change"))}catch{}},ss=new WeakMap,Hg=function(n){l(this,rn)&&x(this,rn,null),x(this,Fn,n.name),x(this,Le,structuredClone(n.layout)),this.dispatchEvent(new ee("change"))},Bg=function(n){Og(l(this,Le),n.id)||x(this,Le,[...l(this,Le),Dg(n.id)]),l(this,He).set(n.id,n),this.dispatchEvent(new ee("change"))},Vg=function(n){const r=l(this,He).get(n.id);r&&(l(this,He).set(n.id,{...r,...n}),this.dispatchEvent(new ee("change")))},jg=function(n){m(this,X,pc).call(this,n)&&this.dispatchEvent(new ee("change"))},pc=function(n){const r=l(this,He).delete(n),i=op({layout:l(this,Le)}).length,s=xg(l(this,Le),n),o=op({layout:s}).length;return x(this,Le,s),r||i!==o},fc=function(){return{layout:structuredClone(l(this,Le)),artifacts:new Map([...l(this,He).entries()].map(([n,r])=>[n,structuredClone(r)]))}},gc=function(n){x(this,Le,structuredClone(n.layout)),l(this,He).clear();for(const[r,i]of n.artifacts)l(this,He).set(r,structuredClone(i))},Gg=function(){const n=l(this,Un).get();l(this,Un).set({...n,screens:{...n.screens,[this.id]:{scrollPosition:l(this,nn)}}})};const hE=pi(gt);var Qe,Mt,at,os,as,ls,Mr,Zo;class dE extends hE{constructor(n){super();_(this,Mr);_(this,Qe);_(this,Mt);_(this,at,null);_(this,os,()=>{this.disposed||m(this,Mr,Zo).call(this)});_(this,as,()=>{this.disposed||m(this,Mr,Zo).call(this)});_(this,ls,n=>{var i;if(this.disposed)return;const r=n.event;r.type==="screen-removed"&&((i=l(this,at))==null?void 0:i.id)===r.screenID&&this.clearActive()});x(this,Qe,n.localStore),x(this,Mt,n.serverManager),l(this,Qe).addEventListener("change",l(this,os)),l(this,Mt).addEventListener("change",l(this,as)),l(this,Mt).addEventListener("server-event",l(this,ls)),m(this,Mr,Zo).call(this)}get activeScreen(){return l(this,at)}setActive(n,r){const i=l(this,Qe).get();i.activeServerURL===n&&i.activeScreenID===r||l(this,Qe).set({...i,activeServerURL:n,activeScreenID:r})}clearActive(){const n=l(this,Qe).get();n.activeScreenID!==null&&l(this,Qe).set({...n,activeScreenID:null})}dispose(){var n;l(this,Qe).removeEventListener("change",l(this,os)),l(this,Mt).removeEventListener("change",l(this,as)),l(this,Mt).removeEventListener("server-event",l(this,ls)),(n=l(this,at))==null||n.dispose(),x(this,at,null)}}Qe=new WeakMap,Mt=new WeakMap,at=new WeakMap,os=new WeakMap,as=new WeakMap,ls=new WeakMap,Mr=new WeakSet,Zo=function(){var c,u,d;const{activeServerURL:n,activeScreenID:r}=l(this,Qe).get(),i=n?l(this,Mt).servers.get(n)??null:null,s=i&&r?i.screens.get(r)??null:null,o=((c=l(this,at))==null?void 0:c.id)??null,a=(s==null?void 0:s.id)??null;o===a&&((u=l(this,at))==null?void 0:u.server)===i||((d=l(this,at))==null||d.dispose(),x(this,at,i&&s?new uE({screen:s,server:i,localStore:l(this,Qe)}):null),this.dispatchEvent(new Px("active-screen-changed")))};const pE="Local",fE="store-";function kt(t){return new URL(t).origin}function gE(t){return{servers:[{url:kt(t),name:pE}],activeServerURL:null,activeScreenID:null,screens:{}}}var Zn,Hn,Bn;class mE extends gt{constructor(n,r,i={}){super();_(this,Zn);_(this,Hn);_(this,Bn);x(this,Zn,`${fE}${n}`),x(this,Hn,i.storage??vE());const s=l(this,Hn).getItem(l(this,Zn));s===null?(x(this,Bn,r),l(this,Hn).setItem(l(this,Zn),JSON.stringify(r))):x(this,Bn,JSON.parse(s))}get(){return l(this,Bn)}set(n){x(this,Bn,n),l(this,Hn).setItem(l(this,Zn),JSON.stringify(n)),this.dispatchEvent(new ee("change"))}}Zn=new WeakMap,Hn=new WeakMap,Bn=new WeakMap;function vE(){const t=globalThis.localStorage;if(!t)throw new Error("LocalStore: no storage adapter supplied and window.localStorage is unavailable");return t}function E(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 Lr extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Wg extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}}const qg={};function fn(t){return qg}function Yg(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 mc(t,e){return typeof e=="bigint"?e.toString():e}function Ru(t){return{get value(){{const e=t();return Object.defineProperty(this,"value",{value:e}),e}}}}function Du(t){return t==null}function Ou(t){const e=t.startsWith("^")?1:0,n=t.endsWith("$")?t.length-1:t.length;return t.slice(e,n)}function yE(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 ap=Symbol("evaluating");function Q(t,e,n){let r;Object.defineProperty(t,e,{get(){if(r!==ap)return r===void 0&&(r=ap,r=n()),r},set(i){Object.defineProperty(t,e,{value:i})},configurable:!0})}function pr(t,e,n){Object.defineProperty(t,e,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Sn(...t){const e={};for(const n of t){const r=Object.getOwnPropertyDescriptors(n);Object.assign(e,r)}return Object.defineProperties({},e)}function lp(t){return JSON.stringify(t)}function bE(t){return t.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Kg="captureStackTrace"in Error?Error.captureStackTrace:(...t)=>{};function ta(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}const wE=Ru(()=>{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 ti(t){if(ta(t)===!1)return!1;const e=t.constructor;if(e===void 0||typeof e!="function")return!0;const n=e.prototype;return!(ta(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function Jg(t){return ti(t)?{...t}:Array.isArray(t)?[...t]:t}const _E=new Set(["string","number","symbol"]);function ni(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function kn(t,e,n){const r=new t._zod.constr(e??t._zod.def);return(!e||n!=null&&n.parent)&&(r._zod.parent=t),r}function O(t){const e=t;if(!e)return{};if(typeof e=="string")return{error:()=>e};if((e==null?void 0:e.message)!==void 0){if((e==null?void 0:e.error)!==void 0)throw new Error("Cannot specify both `message` and `error` params");e.error=e.message}return delete e.message,typeof e.error=="string"?{...e,error:()=>e.error}:e}function SE(t){return Object.keys(t).filter(e=>t[e]._zod.optin==="optional"&&t[e]._zod.optout==="optional")}const kE={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function xE(t,e){const n=t._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const s=Sn(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 pr(this,"shape",o),o},checks:[]});return kn(t,s)}function EE(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=Sn(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 pr(this,"shape",o),o},checks:[]});return kn(t,s)}function $E(t,e){if(!ti(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=Sn(t._zod.def,{get shape(){const s={...t._zod.def.shape,...e};return pr(this,"shape",s),s}});return kn(t,i)}function AE(t,e){if(!ti(e))throw new Error("Invalid input to safeExtend: expected a plain object");const n=Sn(t._zod.def,{get shape(){const r={...t._zod.def.shape,...e};return pr(this,"shape",r),r}});return kn(t,n)}function TE(t,e){const n=Sn(t._zod.def,{get shape(){const r={...t._zod.def.shape,...e._zod.def.shape};return pr(this,"shape",r),r},get catchall(){return e._zod.def.catchall},checks:[]});return kn(t,n)}function CE(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=Sn(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 pr(this,"shape",c),c},checks:[]});return kn(e,o)}function IE(t,e,n){const r=Sn(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 pr(this,"shape",s),s}});return kn(e,r)}function Dr(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 Or(t,e){return e.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(t),n})}function wo(t){return typeof t=="string"?t:t==null?void 0:t.message}function gn(t,e,n){var i,s,o,a,c,u;const r={...t,path:t.path??[]};if(!t.message){const d=wo((o=(s=(i=t.inst)==null?void 0:i._zod.def)==null?void 0:s.error)==null?void 0:o.call(s,t))??wo((a=e==null?void 0:e.error)==null?void 0:a.call(e,t))??wo((c=n.customError)==null?void 0:c.call(n,t))??wo((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 zu(t){return Array.isArray(t)?"array":typeof t=="string"?"string":"unknown"}function Xi(...t){const[e,n,r]=t;return typeof e=="string"?{message:e,code:"custom",input:n,inst:r}:{...e}}const Xg=(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,mc,2),Object.defineProperty(t,"toString",{value:()=>t.message,enumerable:!1})},Qg=E("$ZodError",Xg),em=E("$ZodError",Xg,{Parent:Error});function PE(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 RE(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 Lu=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 Lr;if(o.issues.length){const a=new((i==null?void 0:i.Err)??t)(o.issues.map(c=>gn(c,s,fn())));throw Kg(a,i==null?void 0:i.callee),a}return o.value},Mu=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=>gn(c,s,fn())));throw Kg(a,i==null?void 0:i.callee),a}return o.value},Na=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 Lr;return s.issues.length?{success:!1,error:new(t??Qg)(s.issues.map(o=>gn(o,i,fn())))}:{success:!0,data:s.value}},DE=Na(em),Ua=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=>gn(o,i,fn())))}:{success:!0,data:s.value}},OE=Ua(em),zE=t=>(e,n,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Lu(t)(e,n,i)},LE=t=>(e,n,r)=>Lu(t)(e,n,r),ME=t=>async(e,n,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Mu(t)(e,n,i)},NE=t=>async(e,n,r)=>Mu(t)(e,n,r),UE=t=>(e,n,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Na(t)(e,n,i)},FE=t=>(e,n,r)=>Na(t)(e,n,r),ZE=t=>async(e,n,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Ua(t)(e,n,i)},HE=t=>async(e,n,r)=>Ua(t)(e,n,r),BE=/^[cC][^\s-]{8,}$/,VE=/^[0-9a-z]+$/,jE=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,GE=/^[0-9a-vA-V]{20}$/,WE=/^[A-Za-z0-9]{27}$/,qE=/^[a-zA-Z0-9_-]{21}$/,YE=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,KE=/^([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})$/,cp=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)$/,JE=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,XE="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function QE(){return new RegExp(XE,"u")}const e$=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,t$=/^(([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}|:))$/,n$=/^((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])$/,r$=/^(([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])$/,i$=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,tm=/^[A-Za-z0-9_-]*$/,s$=/^\+[1-9]\d{6,14}$/,nm="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",o$=new RegExp(`^${nm}$`);function rm(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 a$(t){return new RegExp(`^${rm(t)}$`)}function l$(t){const e=rm({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(`^${nm}T(?:${r})$`)}const c$=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}$`)},u$=/^-?\d+$/,im=/^-?\d+(?:\.\d+)?$/,h$=/^(?:true|false)$/i,d$=/^[^A-Z]*$/,p$=/^[^a-z]*$/,We=E("$ZodCheck",(t,e)=>{var n;t._zod??(t._zod={}),t._zod.def=e,(n=t._zod).onattach??(n.onattach=[])}),sm={number:"number",bigint:"bigint",object:"date"},om=E("$ZodCheckLessThan",(t,e)=>{We.init(t,e);const n=sm[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})}}),am=E("$ZodCheckGreaterThan",(t,e)=>{We.init(t,e);const n=sm[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})}}),f$=E("$ZodCheckMultipleOf",(t,e)=>{We.init(t,e),t._zod.onattach.push(n=>{var r;(r=n._zod.bag).multipleOf??(r.multipleOf=e.value)}),t._zod.check=n=>{if(typeof n.value!=typeof e.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%e.value===BigInt(0):yE(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})}}),g$=E("$ZodCheckNumberFormat",(t,e)=>{var o;We.init(t,e),e.format=e.format||"float64";const n=(o=e.format)==null?void 0:o.includes("int"),r=n?"int":"number",[i,s]=kE[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=u$)}),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})}}),m$=E("$ZodCheckMaxLength",(t,e)=>{var n;We.init(t,e),(n=t._zod.def).when??(n.when=r=>{const i=r.value;return!Du(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=zu(i);r.issues.push({origin:o,code:"too_big",maximum:e.maximum,inclusive:!0,input:i,inst:t,continue:!e.abort})}}),v$=E("$ZodCheckMinLength",(t,e)=>{var n;We.init(t,e),(n=t._zod.def).when??(n.when=r=>{const i=r.value;return!Du(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=zu(i);r.issues.push({origin:o,code:"too_small",minimum:e.minimum,inclusive:!0,input:i,inst:t,continue:!e.abort})}}),y$=E("$ZodCheckLengthEquals",(t,e)=>{var n;We.init(t,e),(n=t._zod.def).when??(n.when=r=>{const i=r.value;return!Du(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=zu(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})}}),Fa=E("$ZodCheckStringFormat",(t,e)=>{var n,r;We.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=()=>{})}),b$=E("$ZodCheckRegex",(t,e)=>{Fa.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})}}),w$=E("$ZodCheckLowerCase",(t,e)=>{e.pattern??(e.pattern=d$),Fa.init(t,e)}),_$=E("$ZodCheckUpperCase",(t,e)=>{e.pattern??(e.pattern=p$),Fa.init(t,e)}),S$=E("$ZodCheckIncludes",(t,e)=>{We.init(t,e);const n=ni(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})}}),k$=E("$ZodCheckStartsWith",(t,e)=>{We.init(t,e);const n=new RegExp(`^${ni(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})}}),x$=E("$ZodCheckEndsWith",(t,e)=>{We.init(t,e);const n=new RegExp(`.*${ni(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})}}),E$=E("$ZodCheckOverwrite",(t,e)=>{We.init(t,e),t._zod.check=n=>{n.value=e.tx(n.value)}});class $${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 A$={major:4,minor:3,patch:6},de=E("$ZodType",(t,e)=>{var i;var n;t??(t={}),t._zod.def=e,t._zod.bag=t._zod.bag||{},t._zod.version=A$;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=Dr(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,$=y._zod.check(a);if($ instanceof Promise&&(u==null?void 0:u.async)===!1)throw new Lr;if(p||$ instanceof Promise)p=(p??Promise.resolve()).then(async()=>{await $,a.issues.length!==v&&(d||(d=Dr(a,v)))});else{if(a.issues.length===v)continue;d||(d=Dr(a,v))}}return p?p.then(()=>a):a},o=(a,c,u)=>{if(Dr(a))return a.aborted=!0,a;const d=s(c,r,u);if(d instanceof Promise){if(u.async===!1)throw new Lr;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 Lr;return u.then(d=>s(d,r,c))}return s(u,r,c)}}Q(t,"~standard",()=>({validate:s=>{var o;try{const a=DE(t,s);return a.success?{value:a.data}:{issues:(o=a.error)==null?void 0:o.issues}}catch{return OE(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}))}),Nu=E("$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()??c$(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=E("$ZodStringFormat",(t,e)=>{Fa.init(t,e),Nu.init(t,e)}),T$=E("$ZodGUID",(t,e)=>{e.pattern??(e.pattern=KE),le.init(t,e)}),C$=E("$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=cp(r))}else e.pattern??(e.pattern=cp());le.init(t,e)}),I$=E("$ZodEmail",(t,e)=>{e.pattern??(e.pattern=JE),le.init(t,e)}),P$=E("$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})}}}),R$=E("$ZodEmoji",(t,e)=>{e.pattern??(e.pattern=QE()),le.init(t,e)}),D$=E("$ZodNanoID",(t,e)=>{e.pattern??(e.pattern=qE),le.init(t,e)}),O$=E("$ZodCUID",(t,e)=>{e.pattern??(e.pattern=BE),le.init(t,e)}),z$=E("$ZodCUID2",(t,e)=>{e.pattern??(e.pattern=VE),le.init(t,e)}),L$=E("$ZodULID",(t,e)=>{e.pattern??(e.pattern=jE),le.init(t,e)}),M$=E("$ZodXID",(t,e)=>{e.pattern??(e.pattern=GE),le.init(t,e)}),N$=E("$ZodKSUID",(t,e)=>{e.pattern??(e.pattern=WE),le.init(t,e)}),U$=E("$ZodISODateTime",(t,e)=>{e.pattern??(e.pattern=l$(e)),le.init(t,e)}),F$=E("$ZodISODate",(t,e)=>{e.pattern??(e.pattern=o$),le.init(t,e)}),Z$=E("$ZodISOTime",(t,e)=>{e.pattern??(e.pattern=a$(e)),le.init(t,e)}),H$=E("$ZodISODuration",(t,e)=>{e.pattern??(e.pattern=YE),le.init(t,e)}),B$=E("$ZodIPv4",(t,e)=>{e.pattern??(e.pattern=e$),le.init(t,e),t._zod.bag.format="ipv4"}),V$=E("$ZodIPv6",(t,e)=>{e.pattern??(e.pattern=t$),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})}}}),j$=E("$ZodCIDRv4",(t,e)=>{e.pattern??(e.pattern=n$),le.init(t,e)}),G$=E("$ZodCIDRv6",(t,e)=>{e.pattern??(e.pattern=r$),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 lm(t){if(t==="")return!0;if(t.length%4!==0)return!1;try{return atob(t),!0}catch{return!1}}const W$=E("$ZodBase64",(t,e)=>{e.pattern??(e.pattern=i$),le.init(t,e),t._zod.bag.contentEncoding="base64",t._zod.check=n=>{lm(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:t,continue:!e.abort})}});function q$(t){if(!tm.test(t))return!1;const e=t.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=e.padEnd(Math.ceil(e.length/4)*4,"=");return lm(n)}const Y$=E("$ZodBase64URL",(t,e)=>{e.pattern??(e.pattern=tm),le.init(t,e),t._zod.bag.contentEncoding="base64url",t._zod.check=n=>{q$(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:t,continue:!e.abort})}}),K$=E("$ZodE164",(t,e)=>{e.pattern??(e.pattern=s$),le.init(t,e)});function J$(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 X$=E("$ZodJWT",(t,e)=>{le.init(t,e),t._zod.check=n=>{J$(n.value,e.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:t,continue:!e.abort})}}),cm=E("$ZodNumber",(t,e)=>{de.init(t,e),t._zod.pattern=t._zod.bag.pattern??im,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}}),Q$=E("$ZodNumberFormat",(t,e)=>{g$.init(t,e),cm.init(t,e)}),eA=E("$ZodBoolean",(t,e)=>{de.init(t,e),t._zod.pattern=h$,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}}),tA=E("$ZodUnknown",(t,e)=>{de.init(t,e),t._zod.parse=n=>n}),nA=E("$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 up(t,e,n){t.issues.length&&e.issues.push(...Or(n,t.issues)),e.value[n]=t.value}const rA=E("$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=>up(u,n,o))):up(c,n,o)}return s.length?Promise.all(s).then(()=>n):n}});function na(t,e,n,r,i){if(t.issues.length){if(i&&!(n in r))return;e.issues.push(...Or(n,t.issues))}t.value===void 0?n in r&&(e.value[n]=void 0):e.value[n]=t.value}function um(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=SE(t.shape);return{...t,keys:e,keySet:new Set(e),numKeys:e.length,optionalKeys:new Set(n)}}function hm(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=>na(v,n,p,e,d))):na(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 iA=E("$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=Ru(()=>um(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=ta,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],$=v._zod.optout==="optional",k=v._zod.run({value:u[y],issues:[]},c);k instanceof Promise?d.push(k.then(I=>na(I,a,y,u,$))):na(k,a,y,u,$)}return s?hm(d,u,a,c,r.value,t):d.length?Promise.all(d).then(()=>a):a}}),sA=E("$ZodObjectJIT",(t,e)=>{iA.init(t,e);const n=t._zod.parse,r=Ru(()=>um(e)),i=y=>{var K;const v=new $$(["shape","payload","ctx"]),$=r.value,k=L=>{const Z=lp(L);return`shape[${Z}]._zod.run({ value: input[${Z}], issues: [] }, ctx)`};v.write("const input = payload.value;");const I=Object.create(null);let B=0;for(const L of $.keys)I[L]=`key_${B++}`;v.write("const newResult = {};");for(const L of $.keys){const Z=I[L],N=lp(L),ce=y[L],ue=((K=ce==null?void 0:ce._zod)==null?void 0:K.optout)==="optional";v.write(`const ${Z} = ${k(L)};`),ue?v.write(`
|
|
7
|
+
if (${Z}.issues.length) {
|
|
8
|
+
if (${N} in input) {
|
|
9
|
+
payload.issues = payload.issues.concat(${Z}.issues.map(iss => ({
|
|
10
|
+
...iss,
|
|
11
|
+
path: iss.path ? [${N}, ...iss.path] : [${N}]
|
|
12
|
+
})));
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
if (${Z}.value === undefined) {
|
|
17
|
+
if (${N} in input) {
|
|
18
|
+
newResult[${N}] = undefined;
|
|
19
|
+
}
|
|
20
|
+
} else {
|
|
21
|
+
newResult[${N}] = ${Z}.value;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
`):v.write(`
|
|
25
|
+
if (${Z}.issues.length) {
|
|
26
|
+
payload.issues = payload.issues.concat(${Z}.issues.map(iss => ({
|
|
27
|
+
...iss,
|
|
28
|
+
path: iss.path ? [${N}, ...iss.path] : [${N}]
|
|
29
|
+
})));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (${Z}.value === undefined) {
|
|
33
|
+
if (${N} in input) {
|
|
34
|
+
newResult[${N}] = undefined;
|
|
35
|
+
}
|
|
36
|
+
} else {
|
|
37
|
+
newResult[${N}] = ${Z}.value;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
`)}v.write("payload.value = newResult;"),v.write("return payload;");const P=v.compile();return(L,Z)=>P(y,L,Z)};let s;const o=ta,a=!qg.jitless,u=a&&wE.value,d=e.catchall;let p;t._zod.parse=(y,v)=>{p??(p=r.value);const $=y.value;return o($)?a&&u&&(v==null?void 0:v.async)===!1&&v.jitless!==!0?(s||(s=i(e.shape)),y=s(y,v),d?hm([],$,y,v,p,t):y):n(y,v):(y.issues.push({expected:"object",code:"invalid_type",input:$,inst:t}),y)}});function hp(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=>!Dr(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=>gn(o,r,fn())))}),e)}const oA=E("$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=>Ou(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=>hp(c,i,t,s)):hp(a,i,t,s)}}),aA=E("$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])=>dp(n,c,u)):dp(n,s,o)}});function vc(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(ti(t)&&ti(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=vc(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=vc(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 dp(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}),Dr(t))return t;const o=vc(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 lA=E("$ZodRecord",(t,e)=>{de.init(t,e),t._zod.parse=(n,r)=>{const i=n.value;if(!ti(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(...Or(u,p.issues)),n.value[u]=p.value})):(d.issues.length&&n.issues.push(...Or(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"&&im.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=>gn(p,r,fn())),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(...Or(a,p.issues)),n.value[c.value]=p.value})):(d.issues.length&&n.issues.push(...Or(a,d.issues)),n.value[c.value]=d.value)}}return s.length?Promise.all(s).then(()=>n):n}}),cA=E("$ZodEnum",(t,e)=>{de.init(t,e);const n=Yg(e.entries),r=new Set(n);t._zod.values=r,t._zod.pattern=new RegExp(`^(${n.filter(i=>_E.has(typeof i)).map(i=>typeof i=="string"?ni(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}}),uA=E("$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"?ni(r):r?ni(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}}),hA=E("$ZodTransform",(t,e)=>{de.init(t,e),t._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Wg(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 Lr;return n.value=i,n}});function pp(t,e){return t.issues.length&&e===void 0?{issues:[],value:void 0}:t}const dm=E("$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(`^(${Ou(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=>pp(s,n.value)):pp(i,n.value)}return n.value===void 0?n:e.innerType._zod.run(n,r)}}),dA=E("$ZodExactOptional",(t,e)=>{dm.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)}),pA=E("$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(`^(${Ou(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)}),fA=E("$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=>fp(s,e)):fp(i,e)}});function fp(t,e){return t.value===void 0&&(t.value=e.defaultValue),t}const gA=E("$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))}),mA=E("$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=>gp(s,t)):gp(i,t)}});function gp(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 vA=E("$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=>gn(o,r,fn()))},input:n.value}),n.issues=[]),n)):(n.value=i.value,i.issues.length&&(n.value=e.catchValue({...n,error:{issues:i.issues.map(s=>gn(s,r,fn()))},input:n.value}),n.issues=[]),n)}}),yA=E("$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=>_o(o,e.in,r)):_o(s,e.in,r)}const i=e.in._zod.run(n,r);return i instanceof Promise?i.then(s=>_o(s,e.out,r)):_o(i,e.out,r)}});function _o(t,e,n){return t.issues.length?(t.aborted=!0,t):e._zod.run({value:t.value,issues:t.issues},n)}const bA=E("$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(mp):mp(i)}});function mp(t){return t.value=Object.freeze(t.value),t}const wA=E("$ZodCustom",(t,e)=>{We.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=>vp(s,n,r,t));vp(i,n,r,t)}});function vp(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(Xi(i))}}var yp;class _A{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 SA(){return new _A}(yp=globalThis).__zod_globalRegistry??(yp.__zod_globalRegistry=SA());const Li=globalThis.__zod_globalRegistry;function kA(t,e){return new t({type:"string",...O(e)})}function xA(t,e){return new t({type:"string",format:"email",check:"string_format",abort:!1,...O(e)})}function bp(t,e){return new t({type:"string",format:"guid",check:"string_format",abort:!1,...O(e)})}function EA(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,...O(e)})}function $A(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...O(e)})}function AA(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...O(e)})}function TA(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...O(e)})}function CA(t,e){return new t({type:"string",format:"url",check:"string_format",abort:!1,...O(e)})}function IA(t,e){return new t({type:"string",format:"emoji",check:"string_format",abort:!1,...O(e)})}function PA(t,e){return new t({type:"string",format:"nanoid",check:"string_format",abort:!1,...O(e)})}function RA(t,e){return new t({type:"string",format:"cuid",check:"string_format",abort:!1,...O(e)})}function DA(t,e){return new t({type:"string",format:"cuid2",check:"string_format",abort:!1,...O(e)})}function OA(t,e){return new t({type:"string",format:"ulid",check:"string_format",abort:!1,...O(e)})}function zA(t,e){return new t({type:"string",format:"xid",check:"string_format",abort:!1,...O(e)})}function LA(t,e){return new t({type:"string",format:"ksuid",check:"string_format",abort:!1,...O(e)})}function MA(t,e){return new t({type:"string",format:"ipv4",check:"string_format",abort:!1,...O(e)})}function NA(t,e){return new t({type:"string",format:"ipv6",check:"string_format",abort:!1,...O(e)})}function UA(t,e){return new t({type:"string",format:"cidrv4",check:"string_format",abort:!1,...O(e)})}function FA(t,e){return new t({type:"string",format:"cidrv6",check:"string_format",abort:!1,...O(e)})}function ZA(t,e){return new t({type:"string",format:"base64",check:"string_format",abort:!1,...O(e)})}function HA(t,e){return new t({type:"string",format:"base64url",check:"string_format",abort:!1,...O(e)})}function BA(t,e){return new t({type:"string",format:"e164",check:"string_format",abort:!1,...O(e)})}function VA(t,e){return new t({type:"string",format:"jwt",check:"string_format",abort:!1,...O(e)})}function jA(t,e){return new t({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...O(e)})}function GA(t,e){return new t({type:"string",format:"date",check:"string_format",...O(e)})}function WA(t,e){return new t({type:"string",format:"time",check:"string_format",precision:null,...O(e)})}function qA(t,e){return new t({type:"string",format:"duration",check:"string_format",...O(e)})}function YA(t,e){return new t({type:"number",checks:[],...O(e)})}function KA(t,e){return new t({type:"number",check:"number_format",abort:!1,format:"safeint",...O(e)})}function JA(t,e){return new t({type:"boolean",...O(e)})}function XA(t){return new t({type:"unknown"})}function QA(t,e){return new t({type:"never",...O(e)})}function wp(t,e){return new om({check:"less_than",...O(e),value:t,inclusive:!1})}function zl(t,e){return new om({check:"less_than",...O(e),value:t,inclusive:!0})}function _p(t,e){return new am({check:"greater_than",...O(e),value:t,inclusive:!1})}function Ll(t,e){return new am({check:"greater_than",...O(e),value:t,inclusive:!0})}function Sp(t,e){return new f$({check:"multiple_of",...O(e),value:t})}function pm(t,e){return new m$({check:"max_length",...O(e),maximum:t})}function ra(t,e){return new v$({check:"min_length",...O(e),minimum:t})}function fm(t,e){return new y$({check:"length_equals",...O(e),length:t})}function e1(t,e){return new b$({check:"string_format",format:"regex",...O(e),pattern:t})}function t1(t){return new w$({check:"string_format",format:"lowercase",...O(t)})}function n1(t){return new _$({check:"string_format",format:"uppercase",...O(t)})}function r1(t,e){return new S$({check:"string_format",format:"includes",...O(e),includes:t})}function i1(t,e){return new k$({check:"string_format",format:"starts_with",...O(e),prefix:t})}function s1(t,e){return new x$({check:"string_format",format:"ends_with",...O(e),suffix:t})}function fi(t){return new E$({check:"overwrite",tx:t})}function o1(t){return fi(e=>e.normalize(t))}function a1(){return fi(t=>t.trim())}function l1(){return fi(t=>t.toLowerCase())}function c1(){return fi(t=>t.toUpperCase())}function u1(){return fi(t=>bE(t))}function h1(t,e,n){return new t({type:"array",element:e,...O(n)})}function d1(t,e,n){return new t({type:"custom",check:"custom",fn:e,...O(n)})}function p1(t){const e=f1(n=>(n.addIssue=r=>{if(typeof r=="string")n.issues.push(Xi(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(Xi(i))}},t(n.value,n)));return e}function f1(t,e){const n=new We({check:"custom",...O(e)});return n._zod.check=t,n}function gm(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)??Li,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 $=o.schema,k=e.processors[i.type];if(!k)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);k(t,e,$,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"&&ze(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 mm(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 k;const p=t.target==="draft-2020-12"?"$defs":"definitions";if(t.external){const I=(k=t.external.registry.get(d[0]))==null?void 0:k.id,B=t.external.uri??(K=>K);if(I)return{ref:B(I)};const P=d[1].defId??d[1].schema.id??`schema${t.counter++}`;return d[1].defId=P,{defId:P,ref:`${B("__shared")}#/${p}/${P}`}}if(d[1]===n)return{ref:"#"};const v=`#/${p}/`,$=d[1].schema.id??`__schema${t.counter++}`;return{defId:$,ref:v+$}},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 $=p.schema;for(const k in $)delete $[k];$.$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 vm(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 k=t.seen.get(v),I=k.schema;if(I.$ref&&(t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0")?(p.allOf=p.allOf??[],p.allOf.push(I)):Object.assign(p,I),Object.assign(p,y),u._zod.parent===v)for(const P in p)P==="$ref"||P==="allOf"||P in y||delete p[P];if(I.$ref&&k.def)for(const P in p)P==="$ref"||P==="allOf"||P in k.def&&JSON.stringify(p[P])===JSON.stringify(k.def[P])&&delete p[P]}const $=u._zod.parent;if($&&$!==v){r($);const k=t.seen.get($);if(k!=null&&k.schema.$ref&&(p.$ref=k.schema.$ref,k.def))for(const I in p)I==="$ref"||I==="allOf"||I in k.def&&JSON.stringify(p[I])===JSON.stringify(k.def[I])&&delete p[I]}t.override({zodSchema: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:ia(e,"input",t.processors),output:ia(e,"output",t.processors)}},enumerable:!1,writable:!1}),u}catch{throw new Error("Error converting schema to JSON.")}}function ze(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 ze(r.element,n);if(r.type==="set")return ze(r.valueType,n);if(r.type==="lazy")return ze(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 ze(r.innerType,n);if(r.type==="intersection")return ze(r.left,n)||ze(r.right,n);if(r.type==="record"||r.type==="map")return ze(r.keyType,n)||ze(r.valueType,n);if(r.type==="pipe")return ze(r.in,n)||ze(r.out,n);if(r.type==="object"){for(const i in r.shape)if(ze(r.shape[i],n))return!0;return!1}if(r.type==="union"){for(const i of r.options)if(ze(i,n))return!0;return!1}if(r.type==="tuple"){for(const i of r.items)if(ze(i,n))return!0;return!!(r.rest&&ze(r.rest,n))}return!1}const g1=(t,e={})=>n=>{const r=gm({...n,processors:e});return ye(t,r),mm(r,t),vm(r,t)},ia=(t,e,n={})=>r=>{const{libraryOptions:i,target:s}=r??{},o=gm({...i??{},target:s,io:e,processors:n});return ye(t,o),mm(o,t),vm(o,t)},m1={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},v1=(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=m1[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}))])}},y1=(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)},b1=(t,e,n,r)=>{n.type="boolean"},w1=(t,e,n,r)=>{n.not={}},_1=(t,e,n,r)=>{},S1=(t,e,n,r)=>{const i=t._zod.def,s=Yg(i.entries);s.every(o=>typeof o=="number")&&(n.type="number"),s.every(o=>typeof o=="string")&&(n.type="string"),n.enum=s},k1=(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},x1=(t,e,n,r)=>{if(e.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},E1=(t,e,n,r)=>{if(e.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},$1=(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"]})},A1=(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)},T1=(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},C1=(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},I1=(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)}},P1=(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"}]},R1=(t,e,n,r)=>{const i=t._zod.def;ye(i.innerType,e,r);const s=e.seen.get(t);s.ref=i.innerType},D1=(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))},O1=(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)))},z1=(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},L1=(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},M1=(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},ym=(t,e,n,r)=>{const i=t._zod.def;ye(i.innerType,e,r);const s=e.seen.get(t);s.ref=i.innerType},N1=E("ZodISODateTime",(t,e)=>{U$.init(t,e),fe.init(t,e)});function U1(t){return jA(N1,t)}const F1=E("ZodISODate",(t,e)=>{F$.init(t,e),fe.init(t,e)});function Z1(t){return GA(F1,t)}const H1=E("ZodISOTime",(t,e)=>{Z$.init(t,e),fe.init(t,e)});function B1(t){return WA(H1,t)}const V1=E("ZodISODuration",(t,e)=>{H$.init(t,e),fe.init(t,e)});function j1(t){return qA(V1,t)}const bm=(t,e)=>{Qg.init(t,e),t.name="ZodError",Object.defineProperties(t,{format:{value:n=>RE(t,n)},flatten:{value:n=>PE(t,n)},addIssue:{value:n=>{t.issues.push(n),t.message=JSON.stringify(t.issues,mc,2)}},addIssues:{value:n=>{t.issues.push(...n),t.message=JSON.stringify(t.issues,mc,2)}},isEmpty:{get(){return t.issues.length===0}}})},kp=E("ZodError",bm),ot=E("ZodError",bm,{Parent:Error}),G1=Lu(ot),W1=Mu(ot),q1=Na(ot),Y1=Ua(ot),K1=zE(ot),J1=LE(ot),X1=ME(ot),Q1=NE(ot),eT=UE(ot),tT=FE(ot),nT=ZE(ot),rT=HE(ot),pe=E("ZodType",(t,e)=>(de.init(t,e),Object.assign(t["~standard"],{jsonSchema:{input:ia(t,"input"),output:ia(t,"output")}}),t.toJSONSchema=g1(t,{}),t.def=e,t.type=e.type,Object.defineProperty(t,"_def",{value:e}),t.check=(...n)=>t.clone(Sn(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)=>kn(t,n,r),t.brand=()=>t,t.register=(n,r)=>(n.add(t,r),t),t.parse=(n,r)=>G1(t,n,r,{callee:t.parse}),t.safeParse=(n,r)=>q1(t,n,r),t.parseAsync=async(n,r)=>W1(t,n,r,{callee:t.parseAsync}),t.safeParseAsync=async(n,r)=>Y1(t,n,r),t.spa=t.safeParseAsync,t.encode=(n,r)=>K1(t,n,r),t.decode=(n,r)=>J1(t,n,r),t.encodeAsync=async(n,r)=>X1(t,n,r),t.decodeAsync=async(n,r)=>Q1(t,n,r),t.safeEncode=(n,r)=>eT(t,n,r),t.safeDecode=(n,r)=>tT(t,n,r),t.safeEncodeAsync=async(n,r)=>nT(t,n,r),t.safeDecodeAsync=async(n,r)=>rT(t,n,r),t.refine=(n,r)=>t.check(qT(n,r)),t.superRefine=n=>t.check(YT(n)),t.overwrite=n=>t.check(fi(n)),t.optional=()=>$p(t),t.exactOptional=()=>zT(t),t.nullable=()=>Ap(t),t.nullish=()=>$p(Ap(t)),t.nonoptional=n=>ZT(t,n),t.array=()=>D(t),t.or=n=>H([t,n]),t.and=n=>Za(t,n),t.transform=n=>Tp(t,DT(n)),t.default=n=>NT(t,n),t.prefault=n=>FT(t,n),t.catch=n=>BT(t,n),t.pipe=n=>Tp(t,n),t.readonly=()=>GT(t),t.describe=n=>{const r=t.clone();return Li.add(r,{description:n}),r},Object.defineProperty(t,"description",{get(){var n;return(n=Li.get(t))==null?void 0:n.description},configurable:!0}),t.meta=(...n)=>{if(n.length===0)return Li.get(t);const r=t.clone();return Li.add(r,n[0]),r},t.isOptional=()=>t.safeParse(void 0).success,t.isNullable=()=>t.safeParse(null).success,t.apply=n=>n(t),t)),wm=E("_ZodString",(t,e)=>{Nu.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(r,i,s)=>v1(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(e1(...r)),t.includes=(...r)=>t.check(r1(...r)),t.startsWith=(...r)=>t.check(i1(...r)),t.endsWith=(...r)=>t.check(s1(...r)),t.min=(...r)=>t.check(ra(...r)),t.max=(...r)=>t.check(pm(...r)),t.length=(...r)=>t.check(fm(...r)),t.nonempty=(...r)=>t.check(ra(1,...r)),t.lowercase=r=>t.check(t1(r)),t.uppercase=r=>t.check(n1(r)),t.trim=()=>t.check(a1()),t.normalize=(...r)=>t.check(o1(...r)),t.toLowerCase=()=>t.check(l1()),t.toUpperCase=()=>t.check(c1()),t.slugify=()=>t.check(u1())}),iT=E("ZodString",(t,e)=>{Nu.init(t,e),wm.init(t,e),t.email=n=>t.check(xA(sT,n)),t.url=n=>t.check(CA(oT,n)),t.jwt=n=>t.check(VA(_T,n)),t.emoji=n=>t.check(IA(aT,n)),t.guid=n=>t.check(bp(xp,n)),t.uuid=n=>t.check(EA(So,n)),t.uuidv4=n=>t.check($A(So,n)),t.uuidv6=n=>t.check(AA(So,n)),t.uuidv7=n=>t.check(TA(So,n)),t.nanoid=n=>t.check(PA(lT,n)),t.guid=n=>t.check(bp(xp,n)),t.cuid=n=>t.check(RA(cT,n)),t.cuid2=n=>t.check(DA(uT,n)),t.ulid=n=>t.check(OA(hT,n)),t.base64=n=>t.check(ZA(yT,n)),t.base64url=n=>t.check(HA(bT,n)),t.xid=n=>t.check(zA(dT,n)),t.ksuid=n=>t.check(LA(pT,n)),t.ipv4=n=>t.check(MA(fT,n)),t.ipv6=n=>t.check(NA(gT,n)),t.cidrv4=n=>t.check(UA(mT,n)),t.cidrv6=n=>t.check(FA(vT,n)),t.e164=n=>t.check(BA(wT,n)),t.datetime=n=>t.check(U1(n)),t.date=n=>t.check(Z1(n)),t.time=n=>t.check(B1(n)),t.duration=n=>t.check(j1(n))});function h(t){return kA(iT,t)}const fe=E("ZodStringFormat",(t,e)=>{le.init(t,e),wm.init(t,e)}),sT=E("ZodEmail",(t,e)=>{I$.init(t,e),fe.init(t,e)}),xp=E("ZodGUID",(t,e)=>{T$.init(t,e),fe.init(t,e)}),So=E("ZodUUID",(t,e)=>{C$.init(t,e),fe.init(t,e)}),oT=E("ZodURL",(t,e)=>{P$.init(t,e),fe.init(t,e)}),aT=E("ZodEmoji",(t,e)=>{R$.init(t,e),fe.init(t,e)}),lT=E("ZodNanoID",(t,e)=>{D$.init(t,e),fe.init(t,e)}),cT=E("ZodCUID",(t,e)=>{O$.init(t,e),fe.init(t,e)}),uT=E("ZodCUID2",(t,e)=>{z$.init(t,e),fe.init(t,e)}),hT=E("ZodULID",(t,e)=>{L$.init(t,e),fe.init(t,e)}),dT=E("ZodXID",(t,e)=>{M$.init(t,e),fe.init(t,e)}),pT=E("ZodKSUID",(t,e)=>{N$.init(t,e),fe.init(t,e)}),fT=E("ZodIPv4",(t,e)=>{B$.init(t,e),fe.init(t,e)}),gT=E("ZodIPv6",(t,e)=>{V$.init(t,e),fe.init(t,e)}),mT=E("ZodCIDRv4",(t,e)=>{j$.init(t,e),fe.init(t,e)}),vT=E("ZodCIDRv6",(t,e)=>{G$.init(t,e),fe.init(t,e)}),yT=E("ZodBase64",(t,e)=>{W$.init(t,e),fe.init(t,e)}),bT=E("ZodBase64URL",(t,e)=>{Y$.init(t,e),fe.init(t,e)}),wT=E("ZodE164",(t,e)=>{K$.init(t,e),fe.init(t,e)}),_T=E("ZodJWT",(t,e)=>{X$.init(t,e),fe.init(t,e)}),_m=E("ZodNumber",(t,e)=>{cm.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(r,i,s)=>y1(t,r,i),t.gt=(r,i)=>t.check(_p(r,i)),t.gte=(r,i)=>t.check(Ll(r,i)),t.min=(r,i)=>t.check(Ll(r,i)),t.lt=(r,i)=>t.check(wp(r,i)),t.lte=(r,i)=>t.check(zl(r,i)),t.max=(r,i)=>t.check(zl(r,i)),t.int=r=>t.check(Ep(r)),t.safe=r=>t.check(Ep(r)),t.positive=r=>t.check(_p(0,r)),t.nonnegative=r=>t.check(Ll(0,r)),t.negative=r=>t.check(wp(0,r)),t.nonpositive=r=>t.check(zl(0,r)),t.multipleOf=(r,i)=>t.check(Sp(r,i)),t.step=(r,i)=>t.check(Sp(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 U(t){return YA(_m,t)}const ST=E("ZodNumberFormat",(t,e)=>{Q$.init(t,e),_m.init(t,e)});function Ep(t){return KA(ST,t)}const kT=E("ZodBoolean",(t,e)=>{eA.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(n,r,i)=>b1(t,n,r)});function xe(t){return JA(kT,t)}const xT=E("ZodUnknown",(t,e)=>{tA.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(n,r,i)=>_1()});function w(){return XA(xT)}const ET=E("ZodNever",(t,e)=>{nA.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(n,r,i)=>w1(t,n,r)});function $T(t){return QA(ET,t)}const AT=E("ZodArray",(t,e)=>{rA.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(n,r,i)=>$1(t,n,r,i),t.element=e.element,t.min=(n,r)=>t.check(ra(n,r)),t.nonempty=n=>t.check(ra(1,n)),t.max=(n,r)=>t.check(pm(n,r)),t.length=(n,r)=>t.check(fm(n,r)),t.unwrap=()=>t.element});function D(t,e){return h1(AT,t,e)}const Sm=E("ZodObject",(t,e)=>{sA.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(n,r,i)=>A1(t,n,r,i),Q(t,"shape",()=>e.shape),t.keyof=()=>sa(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:$T()}),t.strip=()=>t.clone({...t._zod.def,catchall:void 0}),t.extend=n=>$E(t,n),t.safeExtend=n=>AE(t,n),t.merge=n=>TE(t,n),t.pick=n=>xE(t,n),t.omit=n=>EE(t,n),t.partial=(...n)=>CE(xm,t,n[0]),t.required=(...n)=>IE(Em,t,n[0])});function km(t,e){const n={type:"object",shape:t??{},...O(e)};return new Sm(n)}function f(t,e){return new Sm({type:"object",shape:t,catchall:w(),...O(e)})}const TT=E("ZodUnion",(t,e)=>{oA.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(n,r,i)=>T1(t,n,r,i),t.options=e.options});function H(t,e){return new TT({type:"union",options:t,...O(e)})}const CT=E("ZodIntersection",(t,e)=>{aA.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(n,r,i)=>C1(t,n,r,i)});function Za(t,e){return new CT({type:"intersection",left:t,right:e})}const IT=E("ZodRecord",(t,e)=>{lA.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(n,r,i)=>I1(t,n,r,i),t.keyType=e.keyType,t.valueType=e.valueType});function S(t,e,n){return new IT({type:"record",keyType:t,valueType:e,...O(n)})}const yc=E("ZodEnum",(t,e)=>{cA.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(r,i,s)=>S1(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 yc({...e,checks:[],...O(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 yc({...e,checks:[],...O(i),entries:s})}});function sa(t,e){const n=Array.isArray(t)?Object.fromEntries(t.map(r=>[r,r])):t;return new yc({type:"enum",entries:n,...O(e)})}const PT=E("ZodLiteral",(t,e)=>{uA.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(n,r,i)=>k1(t,n,r),t.values=new Set(e.values),Object.defineProperty(t,"value",{get(){if(e.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return e.values[0]}})});function A(t,e){return new PT({type:"literal",values:Array.isArray(t)?t:[t],...O(e)})}const RT=E("ZodTransform",(t,e)=>{hA.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(n,r,i)=>E1(t,n),t._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Wg(t.constructor.name);n.addIssue=s=>{if(typeof s=="string")n.issues.push(Xi(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(Xi(o))}};const i=e.transform(n.value,n);return i instanceof Promise?i.then(s=>(n.value=s,n)):(n.value=i,n)}});function DT(t){return new RT({type:"transform",transform:t})}const xm=E("ZodOptional",(t,e)=>{dm.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(n,r,i)=>ym(t,n,r,i),t.unwrap=()=>t._zod.def.innerType});function $p(t){return new xm({type:"optional",innerType:t})}const OT=E("ZodExactOptional",(t,e)=>{dA.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(n,r,i)=>ym(t,n,r,i),t.unwrap=()=>t._zod.def.innerType});function zT(t){return new OT({type:"optional",innerType:t})}const LT=E("ZodNullable",(t,e)=>{pA.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(n,r,i)=>P1(t,n,r,i),t.unwrap=()=>t._zod.def.innerType});function Ap(t){return new LT({type:"nullable",innerType:t})}const MT=E("ZodDefault",(t,e)=>{fA.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(n,r,i)=>D1(t,n,r,i),t.unwrap=()=>t._zod.def.innerType,t.removeDefault=t.unwrap});function NT(t,e){return new MT({type:"default",innerType:t,get defaultValue(){return typeof e=="function"?e():Jg(e)}})}const UT=E("ZodPrefault",(t,e)=>{gA.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(n,r,i)=>O1(t,n,r,i),t.unwrap=()=>t._zod.def.innerType});function FT(t,e){return new UT({type:"prefault",innerType:t,get defaultValue(){return typeof e=="function"?e():Jg(e)}})}const Em=E("ZodNonOptional",(t,e)=>{mA.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(n,r,i)=>R1(t,n,r,i),t.unwrap=()=>t._zod.def.innerType});function ZT(t,e){return new Em({type:"nonoptional",innerType:t,...O(e)})}const HT=E("ZodCatch",(t,e)=>{vA.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(n,r,i)=>z1(t,n,r,i),t.unwrap=()=>t._zod.def.innerType,t.removeCatch=t.unwrap});function BT(t,e){return new HT({type:"catch",innerType:t,catchValue:typeof e=="function"?e:()=>e})}const VT=E("ZodPipe",(t,e)=>{yA.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(n,r,i)=>L1(t,n,r,i),t.in=e.in,t.out=e.out});function Tp(t,e){return new VT({type:"pipe",in:t,out:e})}const jT=E("ZodReadonly",(t,e)=>{bA.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(n,r,i)=>M1(t,n,r,i),t.unwrap=()=>t._zod.def.innerType});function GT(t){return new jT({type:"readonly",innerType:t})}const WT=E("ZodCustom",(t,e)=>{wA.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(n,r,i)=>x1(t,n)});function qT(t,e={}){return d1(WT,t,e)}function YT(t){return p1(t)}const KT=["text/markdown","text/html"],JT=["committed","pending"];km({id:h().min(1),type:sa(KT),title:h(),status:sa(JT),externalFilePath:h().optional()});km({name:h().min(1),description:h(),accepts:D(h().min(1)).min(1)});function Uu(t){return typeof t=="object"&&t!==null}function XT(t){return!Uu(t)||t.type!=="ready"?!1:!("id"in t)}function QT(t){return!(!Uu(t)||t.type!=="update-content"||typeof t.id!="string"||typeof t.content!="string")}function eC(t){return!Uu(t)||t.type!=="wheel"||typeof t.deltaX!="number"||typeof t.deltaY!="number"||typeof t.shiftKey!="boolean"?!1:!("id"in t)}function tC(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 nC(t,e){let n=null;for(const r of t.accepts){const i=tC(r,e);i!==null&&(n===null||i>n)&&(n=i)}return n}function rC(t,e){let n=-1,r=null;for(const i of e){const s=nC(i,t);s!==null&&(s>n||s===n&&r!==null&&i.id<r.id)&&(n=s,r=i)}return r}const iC=4401;class bc extends Error{constructor(e="Authentication required"){super(e),this.name="AuthError"}}class wc extends gt{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=kt(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 aE(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(sC(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=aC(p);y&&(this.applyServerEvent(y),this.dispatchEvent(new Mg("server-event",{serverURL:this.url,event:y})))}),r.addEventListener("close",p=>{if(this.connectAttempt===n){if(this.socket=null,oC(p)===iC){u(new bc);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=rC(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 Fo("screens-changed"));break;case"screen-updated":this.screens.set(n.screen.id,structuredClone(n.screen)),this.dispatchEvent(new Fo("screens-changed"));break;case"screen-removed":this.screens.delete(n.screenID),this.dispatchEvent(new Fo("screens-changed"));break;case"artifact-created":{const r=this.screens.get(n.screenID);r&&!Og(r.layout,n.artifact.id)&&(r.layout=[...r.layout,Dg(n.artifact.id)]);break}case"artifact-removed":{const r=this.screens.get(n.screenID);r&&(r.layout=xg(r.layout,n.artifactID));break}}}}function sC(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 oC(t){return typeof t=="object"&&t!==null&&"code"in t&&typeof t.code=="number"?t.code:null}function aC(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 lC extends gt{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?kt(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=kt(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 Mg("server-event",{serverURL:c.serverURL,event:c.event}))},a=()=>{this.dispatchEvent(new Fo("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=kt(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?kt(n.url):null;r.activeServerURL!==i&&this.localStore.set({...r,activeServerURL:i})}connectConfiguredServers(n,r){const i=this.localStore.get().servers,s=n?kt(n):null;for(const a of i){const c=kt(a.url),u=s!==null&&c===s,d=new wc({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=kt(n);this.remove(i);const s=this.localStore.get();this.localStore.set({...s,servers:[...s.servers.filter(a=>kt(a.url)!==i),{url:i,name:r}]});const o=new wc({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"},Ot={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"},cC=1,uC=f({_meta:S(h(),w()).nullish(),terminal:xe().optional().default(!1)}),hC=f({_meta:S(h(),w()).nullish(),label:h().nullish(),name:h(),optional:xe().optional().default(!1),secret:xe().optional().default(!0)}),dC=f({_meta:S(h(),w()).nullish(),description:h().nullish(),id:h(),name:h()}),pC=f({_meta:S(h(),w()).nullish(),description:h().nullish(),id:h(),link:h().nullish(),name:h(),vars:D(hC)}),fC=f({_meta:S(h(),w()).nullish(),args:D(h()).optional(),description:h().nullish(),env:S(h(),h()).optional(),id:h(),name:h()}),gC=H([pC.and(f({type:A("env_var")})),fC.and(f({type:A("terminal")})),dC]),mC=f({_meta:S(h(),w()).nullish(),methodId:h()}),vC=f({_meta:S(h(),w()).nullish()}),yC=f({_meta:S(h(),w()).nullish(),blob:h(),mimeType:h().nullish(),uri:h()}),bC=f({default:xe().nullish(),description:h().nullish(),title:h().nullish()}),wC=f({_meta:S(h(),w()).nullish()}),_C=f({_meta:S(h(),w()).nullish()}),SC=f({amount:U(),currency:h()}),kC=f({_meta:S(h(),w()).nullish(),terminalId:h()}),xC=f({_meta:S(h(),w()).nullish(),newText:h(),oldText:h().nullish(),path:h()}),EC=H([h(),U(),U(),xe(),D(h())]),$C=f({content:S(h(),EC).nullish()}),AC=H([$C.and(f({action:A("accept")})),f({action:A("decline")}),f({action:A("cancel")})]),TC=f({_meta:S(h(),w()).nullish()}),$m=h(),CC=f({_meta:S(h(),w()).nullish(),elicitationId:$m}),IC=f({_meta:S(h(),w()).nullish(),action:AC}),PC=A("object"),RC=A("string"),DC=f({_meta:S(h(),w()).nullish()}),OC=f({_meta:S(h(),w()).nullish(),form:TC.nullish(),url:DC.nullish()}),zC=f({elicitationId:$m,url:h().url()}),Am=f({const:h(),title:h()}),Tm=f({_meta:S(h(),w()).nullish(),name:h(),value:h()}),LC=H([A(-32700),A(-32600),A(-32601),A(-32602),A(-32603),A(-32800),A(-32e3),A(-32002),A(-32042),U().int().min(-2147483648,{message:"Invalid value: Expected int32 to be >= -2147483648"}).max(2147483647,{message:"Invalid value: Expected int32 to be <= 2147483647"})]),Cm=f({code:LC,data:w().optional(),message:h()}),Im=w(),Pm=w(),Rm=w(),MC=f({_meta:S(h(),w()).nullish(),readTextFile:xe().optional().default(!1),writeTextFile:xe().optional().default(!1)}),Dm=f({_meta:S(h(),w()).nullish(),name:h(),value:h()}),Om=f({_meta:S(h(),w()).nullish(),name:h(),title:h().nullish(),version:h()}),NC=f({default:U().nullish(),description:h().nullish(),maximum:U().nullish(),minimum:U().nullish(),title:h().nullish()}),UC=f({_meta:S(h(),w()).nullish()}),FC=f({_meta:S(h(),w()).nullish(),additionalDirectories:D(h()).optional(),cursor:h().nullish(),cwd:h().nullish()}),ZC=f({_meta:S(h(),w()).nullish()}),HC=f({_meta:S(h(),w()).nullish(),logout:ZC.nullish()}),BC=f({_meta:S(h(),w()).nullish()}),VC=f({_meta:S(h(),w()).nullish()}),jC=f({_meta:S(h(),w()).nullish(),http:xe().optional().default(!1),sse:xe().optional().default(!1)}),GC=f({_meta:S(h(),w()).nullish(),headers:D(Dm),name:h(),url:h()}),WC=f({_meta:S(h(),w()).nullish(),headers:D(Dm),name:h(),url:h()}),qC=f({_meta:S(h(),w()).nullish(),args:D(h()),command:h(),env:D(Tm),name:h()}),Ha=H([GC.and(f({type:A("http")})),WC.and(f({type:A("sse")})),qC]),Fu=h(),YC=f({_meta:S(h(),w()).nullish(),description:h().nullish(),modelId:Fu,name:h()}),KC=H([A("error"),A("warning"),A("information"),A("hint")]),JC=f({_meta:S(h(),w()).nullish()}),XC=f({_meta:S(h(),w()).nullish()}),QC=f({_meta:S(h(),w()).nullish()}),eI=f({_meta:S(h(),w()).nullish()}),tI=f({_meta:S(h(),w()).nullish()}),nI=f({_meta:S(h(),w()).nullish(),maxCount:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),rI=f({diff:h(),uri:h()}),iI=f({endLine:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),startLine:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),text:h()}),sI=f({_meta:S(h(),w()).nullish()}),oI=f({_meta:S(h(),w()).nullish()}),aI=f({languageId:h(),text:h(),uri:h()}),lI=f({_meta:S(h(),w()).nullish(),maxCount:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),cI=H([A("rejected"),A("ignored"),A("replaced"),A("cancelled")]),uI=f({excerpts:D(iI),uri:h()}),hI=f({_meta:S(h(),w()).nullish()}),dI=f({_meta:S(h(),w()).nullish()}),pI=f({name:h(),owner:h(),remoteUrl:h()}),fI=f({_meta:S(h(),w()).nullish()}),gI=f({_meta:S(h(),w()).nullish(),jump:sI.nullish(),rename:dI.nullish(),searchAndReplace:fI.nullish()}),mI=f({id:h(),isRegex:xe().nullish(),replace:h(),search:h(),uri:h()}),vI=H([A("automatic"),A("diagnostic"),A("manual")]),yI=f({_meta:S(h(),w()).nullish(),maxCount:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),bI=f({_meta:S(h(),w()).nullish(),diagnostics:JC.nullish(),editHistory:nI.nullish(),openFiles:oI.nullish(),recentFiles:lI.nullish(),relatedSnippets:hI.nullish(),userActions:yI.nullish()}),wI=f({_meta:S(h(),w()).nullish(),additionalDirectories:D(h()).optional(),cwd:h(),mcpServers:D(Ha)}),_I=f({default:U().nullish(),description:h().nullish(),maximum:U().nullish(),minimum:U().nullish(),title:h().nullish()}),zm=h(),SI=H([A("allow_once"),A("allow_always"),A("reject_once"),A("reject_always")]),kI=f({_meta:S(h(),w()).nullish(),kind:SI,name:h(),optionId:zm}),xI=H([A("high"),A("medium"),A("low")]),EI=H([A("pending"),A("in_progress"),A("completed")]),$I=f({_meta:S(h(),w()).nullish(),content:h(),priority:xI,status:EI}),AI=f({_meta:S(h(),w()).nullish(),entries:D($I)}),mn=f({character:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),line:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"})}),TI=f({id:h(),position:mn,uri:h()}),CI=f({id:h(),newName:h(),position:mn,uri:h()}),II=f({action:h(),position:mn,timestampMs:U(),uri:h()}),Lm=H([A("utf-16"),A("utf-32"),A("utf-8")]),PI=f({_meta:S(h(),w()).nullish(),auth:uC.optional().default({terminal:!1}),elicitation:OC.nullish(),fs:MC.optional().default({readTextFile:!1,writeTextFile:!1}),nes:gI.nullish(),positionEncodings:D(Lm).optional(),terminal:xe().optional().default(!1)}),RI=f({_meta:S(h(),w()).nullish(),audio:xe().optional().default(!1),embeddedContext:xe().optional().default(!1),image:xe().optional().default(!1)}),Mm=U().int().gte(0).lte(65535),DI=f({_meta:S(h(),w()).nullish(),clientCapabilities:PI.optional().default({auth:{terminal:!1},fs:{readTextFile:!1,writeTextFile:!1},terminal:!1}),clientInfo:Om.nullish(),protocolVersion:Mm}),gi=f({end:mn,start:mn}),OI=f({message:h(),range:gi,severity:KC,uri:h()}),zI=f({languageId:h(),lastFocusedMs:U().nullish(),uri:h(),visibleRange:gi.nullish()}),LI=f({_meta:S(h(),w()).nullish(),diagnostics:D(OI).nullish(),editHistory:D(rI).nullish(),openFiles:D(zI).nullish(),recentFiles:D(aI).nullish(),relatedSnippets:D(uI).nullish(),userActions:D(II).nullish()}),MI=f({newText:h(),range:gi}),NI=f({cursorPosition:mn.nullish(),edits:D(MI),id:h(),uri:h()}),UI=H([NI.and(f({kind:A("edit")})),TI.and(f({kind:A("jump")})),CI.and(f({kind:A("rename")})),mI.and(f({kind:A("searchAndReplace")}))]),FI=f({_meta:S(h(),w()).nullish(),content:h()}),ZI=f({_meta:S(h(),w()).nullish()}),or=H([U(),h()]).nullable();f({_meta:S(h(),w()).nullish(),requestId:or});const HI=sa(["assistant","user"]),Qs=f({_meta:S(h(),w()).nullish(),audience:D(HI).nullish(),lastModified:h().nullish(),priority:U().nullish()}),BI=f({_meta:S(h(),w()).nullish(),annotations:Qs.nullish(),data:h(),mimeType:h()}),VI=f({_meta:S(h(),w()).nullish(),annotations:Qs.nullish(),data:h(),mimeType:h(),uri:h().nullish()}),jI=f({_meta:S(h(),w()).nullish(),annotations:Qs.nullish(),description:h().nullish(),mimeType:h().nullish(),name:h(),size:U().nullish(),title:h().nullish(),uri:h()}),GI=f({_meta:S(h(),w()).nullish(),optionId:zm}),WI=H([f({outcome:A("cancelled")}),GI.and(f({outcome:A("selected")}))]),qI=f({_meta:S(h(),w()).nullish(),outcome:WI}),YI=f({_meta:S(h(),w()).nullish()}),KI=f({_meta:S(h(),w()).nullish()}),JI=f({currentValue:xe()}),XI=h(),Nm=h(),QI=H([A("mode"),A("model"),A("thought_level"),h()]),Zu=h(),Um=f({_meta:S(h(),w()).nullish(),description:h().nullish(),name:h(),value:Zu}),eP=f({_meta:S(h(),w()).nullish(),group:XI,name:h(),options:D(Um)}),tP=H([D(Um),D(eP)]),nP=f({currentValue:Zu,options:tP}),mi=Za(H([nP.and(f({type:A("select")})),JI.and(f({type:A("boolean")}))]),f({_meta:S(h(),w()).nullish(),category:QI.nullish(),description:h().nullish(),id:Nm,name:h()})),rP=f({_meta:S(h(),w()).nullish(),configOptions:D(mi)}),iP=f({_meta:S(h(),w()).nullish()}),Y=h(),sP=f({_meta:S(h(),w()).nullish(),id:h(),sessionId:Y}),oP=f({_meta:S(h(),w()).nullish(),sessionId:Y}),aP=f({_meta:S(h(),w()).nullish(),sessionId:Y}),lP=f({_meta:S(h(),w()).nullish(),sessionId:Y}),Fm=f({_meta:S(h(),w()).nullish(),args:D(h()).optional(),command:h(),cwd:h().nullish(),env:D(Tm).optional(),outputByteLimit:U().nullish(),sessionId:Y}),cP=f({_meta:S(h(),w()).nullish(),sessionId:Y,uri:h()}),uP=f({_meta:S(h(),w()).nullish(),position:mn,sessionId:Y,uri:h(),version:U(),visibleRange:gi}),hP=f({_meta:S(h(),w()).nullish(),languageId:h(),sessionId:Y,text:h(),uri:h(),version:U()}),dP=f({_meta:S(h(),w()).nullish(),sessionId:Y,uri:h()}),pP=f({_meta:S(h(),w()).nullish(),additionalDirectories:D(h()).optional(),cwd:h(),mcpServers:D(Ha).optional(),sessionId:Y}),Zm=f({_meta:S(h(),w()).nullish(),sessionId:Y,terminalId:h()}),fP=f({_meta:S(h(),w()).nullish(),additionalDirectories:D(h()).optional(),cwd:h(),mcpServers:D(Ha),sessionId:Y}),Hm=f({_meta:S(h(),w()).nullish(),limit:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),line:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:h(),sessionId:Y}),gP=f({_meta:S(h(),w()).nullish(),id:h(),reason:cI.nullish(),sessionId:Y}),Bm=f({_meta:S(h(),w()).nullish(),sessionId:Y,terminalId:h()}),mP=f({_meta:S(h(),w()).nullish(),additionalDirectories:D(h()).optional(),cwd:h(),mcpServers:D(Ha).optional(),sessionId:Y}),vP=f({_meta:S(h(),w()).nullish(),additionalDirectories:D(h()).optional(),cwd:h(),sessionId:Y,title:h().nullish(),updatedAt:h().nullish()}),yP=f({_meta:S(h(),w()).nullish(),nextCursor:h().nullish(),sessions:D(vP)}),bP=f({_meta:S(h(),w()).nullish(),title:h().nullish(),updatedAt:h().nullish()}),wP=f({_meta:S(h(),w()).nullish()}),Ba=h(),_P=f({_meta:S(h(),w()).nullish(),currentModeId:Ba}),SP=f({_meta:S(h(),w()).nullish(),description:h().nullish(),id:Ba,name:h()}),Va=f({_meta:S(h(),w()).nullish(),availableModes:D(SP),currentModeId:Ba}),ja=f({_meta:S(h(),w()).nullish(),availableModels:D(YC),currentModelId:Fu}),kP=f({_meta:S(h(),w()).nullish(),configOptions:D(mi).nullish(),models:ja.nullish(),modes:Va.nullish(),sessionId:Y}),xP=f({_meta:S(h(),w()).nullish(),configOptions:D(mi).nullish(),models:ja.nullish(),modes:Va.nullish()}),EP=f({_meta:S(h(),w()).nullish(),configOptions:D(mi).nullish(),models:ja.nullish(),modes:Va.nullish(),sessionId:Y}),$P=f({_meta:S(h(),w()).nullish(),configOptions:D(mi).nullish(),models:ja.nullish(),modes:Va.nullish()}),AP=f({_meta:S(h(),w()).nullish()}),TP=f({_meta:S(h(),w()).nullish(),additionalDirectories:YI.nullish(),close:KI.nullish(),fork:iP.nullish(),list:wP.nullish(),resume:AP.nullish()}),CP=Za(H([f({type:A("boolean"),value:xe()}),f({value:Zu})]),f({_meta:S(h(),w()).nullish(),configId:Nm,sessionId:Y})),IP=f({_meta:S(h(),w()).nullish(),configOptions:D(mi)}),PP=f({_meta:S(h(),w()).nullish(),modeId:Ba,sessionId:Y}),RP=f({_meta:S(h(),w()).nullish()}),DP=f({_meta:S(h(),w()).nullish(),modelId:Fu,sessionId:Y}),OP=f({_meta:S(h(),w()).nullish()}),zP=f({_meta:S(h(),w()).nullish(),sessionId:Y}),LP=H([A("end_turn"),A("max_tokens"),A("max_turn_requests"),A("refusal"),A("cancelled")]),MP=H([A("email"),A("uri"),A("date"),A("date-time")]),NP=f({default:h().nullish(),description:h().nullish(),enum:D(h()).nullish(),format:MP.nullish(),maxLength:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),minLength:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),oneOf:D(Am).nullish(),pattern:h().nullish(),title:h().nullish()}),UP=f({_meta:S(h(),w()).nullish(),context:LI.nullish(),position:mn,selection:gi.nullish(),sessionId:Y,triggerKind:vI,uri:h(),version:U()}),FP=f({_meta:S(h(),w()).nullish(),suggestions:D(UI)}),ZP=f({_meta:S(h(),w()).nullish(),terminalId:h()}),HP=f({_meta:S(h(),w()).nullish(),exitCode:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:h().nullish()}),Vm=f({_meta:S(h(),w()).nullish(),sessionId:Y,terminalId:h()}),BP=f({_meta:S(h(),w()).nullish(),exitStatus:HP.nullish(),output:h(),truncated:xe()}),VP=f({_meta:S(h(),w()).nullish(),annotations:Qs.nullish(),text:h()}),jP=f({range:gi.nullish(),text:h()}),GP=f({_meta:S(h(),w()).nullish(),contentChanges:D(jP),sessionId:Y,uri:h(),version:U()});f({method:h(),params:H([oP,hP,GP,cP,dP,uP,sP,gP,Im]).nullish()});const WP=H([A("full"),A("incremental")]),qP=f({_meta:S(h(),w()).nullish(),syncKind:WP}),YP=f({_meta:S(h(),w()).nullish(),didChange:qP.nullish(),didClose:XC.nullish(),didFocus:QC.nullish(),didOpen:eI.nullish(),didSave:tI.nullish()}),KP=f({_meta:S(h(),w()).nullish(),document:YP.nullish()}),JP=f({_meta:S(h(),w()).nullish(),context:bI.nullish(),events:KP.nullish()}),XP=f({_meta:S(h(),w()).nullish(),auth:HC.optional().default({}),loadSession:xe().optional().default(!1),mcpCapabilities:jC.optional().default({http:!1,sse:!1}),nes:JP.nullish(),positionEncoding:Lm.nullish(),promptCapabilities:RI.optional().default({audio:!1,embeddedContext:!1,image:!1}),sessionCapabilities:TP.optional().default({})}),QP=f({_meta:S(h(),w()).nullish(),agentCapabilities:XP.optional().default({auth:{},loadSession:!1,mcpCapabilities:{http:!1,sse:!1},promptCapabilities:{audio:!1,embeddedContext:!1,image:!1},sessionCapabilities:{}}),agentInfo:Om.nullish(),authMethods:D(gC).optional().default([]),protocolVersion:Mm}),eR=f({_meta:S(h(),w()).nullish(),mimeType:h().nullish(),text:h(),uri:h()}),tR=H([eR,yC]),nR=f({_meta:S(h(),w()).nullish(),annotations:Qs.nullish(),resource:tR}),Hu=H([VP.and(f({type:A("text")})),VI.and(f({type:A("image")})),BI.and(f({type:A("audio")})),jI.and(f({type:A("resource_link")})),nR.and(f({type:A("resource")}))]),rR=f({_meta:S(h(),w()).nullish(),content:Hu}),Ml=f({_meta:S(h(),w()).nullish(),content:Hu,messageId:h().nullish()}),iR=f({_meta:S(h(),w()).nullish(),messageId:h().nullish(),prompt:D(Hu),sessionId:Y}),sR=f({anyOf:D(Am)}),jm=H([rR.and(f({type:A("content")})),xC.and(f({type:A("diff")})),ZP.and(f({type:A("terminal")}))]),Gm=h(),Wm=f({_meta:S(h(),w()).nullish(),line:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:h()}),qm=H([A("pending"),A("in_progress"),A("completed"),A("failed")]),Ym=H([A("read"),A("edit"),A("delete"),A("move"),A("search"),A("execute"),A("think"),A("fetch"),A("switch_mode"),A("other")]),oR=f({_meta:S(h(),w()).nullish(),content:D(jm).optional(),kind:Ym.optional(),locations:D(Wm).optional(),rawInput:w().optional(),rawOutput:w().optional(),status:qm.optional(),title:h(),toolCallId:Gm}),Km=f({_meta:S(h(),w()).nullish(),content:D(jm).nullish(),kind:Ym.nullish(),locations:D(Wm).nullish(),rawInput:w().optional(),rawOutput:w().optional(),status:qm.nullish(),title:h().nullish(),toolCallId:Gm}),Jm=f({_meta:S(h(),w()).nullish(),options:D(kI),sessionId:Y,toolCall:Km}),aR=f({_meta:S(h(),w()).nullish(),hint:h()}),lR=aR,cR=f({_meta:S(h(),w()).nullish(),description:h(),input:lR.nullish(),name:h()}),uR=f({_meta:S(h(),w()).nullish(),availableCommands:D(cR)}),hR=f({enum:D(h()),type:RC}),dR=H([hR,sR]),pR=f({default:D(h()).nullish(),description:h().nullish(),items:dR,maxItems:U().nullish(),minItems:U().nullish(),title:h().nullish()}),fR=H([NP.and(f({type:A("string")})),_I.and(f({type:A("number")})),NC.and(f({type:A("integer")})),bC.and(f({type:A("boolean")})),pR.and(f({type:A("array")}))]),gR=f({description:h().nullish(),properties:S(h(),fR).optional().default({}),required:D(h()).nullish(),title:h().nullish(),type:PC.optional().default("object")}),mR=f({requestedSchema:gR}),vR=Za(H([mR.and(f({mode:A("form")})),zC.and(f({mode:A("url")}))]),f({_meta:S(h(),w()).nullish(),message:h(),sessionId:Y})),yR=f({cachedReadTokens:U().nullish(),cachedWriteTokens:U().nullish(),inputTokens:U(),outputTokens:U(),thoughtTokens:U().nullish(),totalTokens:U()}),bR=f({_meta:S(h(),w()).nullish(),stopReason:LP,usage:yR.nullish(),userMessageId:h().nullish()});H([f({id:or,result:H([QP,vC,VC,EP,xP,yP,kP,$P,_C,RP,IP,bR,OP,zP,FP,wC,Rm])}),f({error:Cm,id:or})]);const wR=f({_meta:S(h(),w()).nullish(),cost:SC.nullish(),size:U(),used:U()}),_R=H([Ml.and(f({sessionUpdate:A("user_message_chunk")})),Ml.and(f({sessionUpdate:A("agent_message_chunk")})),Ml.and(f({sessionUpdate:A("agent_thought_chunk")})),oR.and(f({sessionUpdate:A("tool_call")})),Km.and(f({sessionUpdate:A("tool_call_update")})),AI.and(f({sessionUpdate:A("plan")})),uR.and(f({sessionUpdate:A("available_commands_update")})),_P.and(f({sessionUpdate:A("current_mode_update")})),rP.and(f({sessionUpdate:A("config_option_update")})),bP.and(f({sessionUpdate:A("session_info_update")})),wR.and(f({sessionUpdate:A("usage_update")}))]),Xm=f({_meta:S(h(),w()).nullish(),sessionId:Y,update:_R});f({method:h(),params:H([Xm,CC,Im]).nullish()});const Qm=f({_meta:S(h(),w()).nullish(),sessionId:Y,terminalId:h()}),SR=f({_meta:S(h(),w()).nullish(),exitCode:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:h().nullish()}),kR=f({name:h(),uri:h()}),xR=f({_meta:S(h(),w()).nullish(),repository:pI.nullish(),workspaceFolders:D(kR).nullish(),workspaceUri:h().nullish()});f({id:or,method:h(),params:H([DI,mC,BC,wI,fP,FC,pP,mP,lP,PP,CP,iR,DP,xR,UP,aP,Pm]).nullish()});const ev=f({_meta:S(h(),w()).nullish(),content:h(),path:h(),sessionId:Y});f({id:or,method:h(),params:H([ev,Hm,Jm,Fm,Vm,Bm,Qm,Zm,vR,Pm]).nullish()});const ER=f({_meta:S(h(),w()).nullish()});H([f({id:or,result:H([ER,FI,qI,kC,BP,ZI,SR,UC,IC,Rm])}),f({error:Cm,id:or})]);var q;class $R{constructor(e,n){_(this,q);const r=e(this),i=async(o,a)=>{var c,u,d,p,y,v,$;switch(o){case Ot.fs_write_text_file:{const k=ev.parse(a);return(c=r.writeTextFile)==null?void 0:c.call(r,k)}case Ot.fs_read_text_file:{const k=Hm.parse(a);return(u=r.readTextFile)==null?void 0:u.call(r,k)}case Ot.session_request_permission:{const k=Jm.parse(a);return r.requestPermission(k)}case Ot.terminal_create:{const k=Fm.parse(a);return(d=r.createTerminal)==null?void 0:d.call(r,k)}case Ot.terminal_output:{const k=Vm.parse(a);return(p=r.terminalOutput)==null?void 0:p.call(r,k)}case Ot.terminal_release:{const k=Bm.parse(a);return await((y=r.releaseTerminal)==null?void 0:y.call(r,k))??{}}case Ot.terminal_wait_for_exit:{const k=Qm.parse(a);return(v=r.waitForTerminalExit)==null?void 0:v.call(r,k)}case Ot.terminal_kill:{const k=Zm.parse(a);return await(($=r.killTerminal)==null?void 0:$.call(r,k))??{}}default:if(r.extMethod)return r.extMethod(o,a);throw we.methodNotFound(o)}},s=async(o,a)=>{switch(o){case Ot.session_update:{const c=Xm.parse(a);return r.sessionUpdate(c)}default:if(r.extNotification)return r.extNotification(o,a);throw we.methodNotFound(o)}};x(this,q,new AR(i,s,n))}async initialize(e){return await l(this,q).sendRequest(oe.initialize,e)}async newSession(e){return await l(this,q).sendRequest(oe.session_new,e)}async loadSession(e){return await l(this,q).sendRequest(oe.session_load,e)??{}}async unstable_forkSession(e){return await l(this,q).sendRequest(oe.session_fork,e)}async listSessions(e){return await l(this,q).sendRequest(oe.session_list,e)}async unstable_resumeSession(e){return await l(this,q).sendRequest(oe.session_resume,e)}async unstable_closeSession(e){return await l(this,q).sendRequest(oe.session_close,e)}async setSessionMode(e){return await l(this,q).sendRequest(oe.session_set_mode,e)??{}}async unstable_setSessionModel(e){return await l(this,q).sendRequest(oe.session_set_model,e)??{}}async setSessionConfigOption(e){return await l(this,q).sendRequest(oe.session_set_config_option,e)}async authenticate(e){return await l(this,q).sendRequest(oe.authenticate,e)??{}}async unstable_logout(e){return await l(this,q).sendRequest(oe.logout,e)??{}}async prompt(e){return await l(this,q).sendRequest(oe.session_prompt,e)}async cancel(e){return await l(this,q).sendNotification(oe.session_cancel,e)}async unstable_startNes(e){return await l(this,q).sendRequest(oe.nes_start,e)}async unstable_suggestNes(e){return await l(this,q).sendRequest(oe.nes_suggest,e)}async unstable_closeNes(e){return await l(this,q).sendRequest(oe.nes_close,e)??{}}async unstable_didOpenDocument(e){return await l(this,q).sendNotification(oe.document_did_open,e)}async unstable_didChangeDocument(e){return await l(this,q).sendNotification(oe.document_did_change,e)}async unstable_didCloseDocument(e){return await l(this,q).sendNotification(oe.document_did_close,e)}async unstable_didSaveDocument(e){return await l(this,q).sendNotification(oe.document_did_save,e)}async unstable_didFocusDocument(e){return await l(this,q).sendNotification(oe.document_did_focus,e)}async unstable_acceptNes(e){return await l(this,q).sendNotification(oe.nes_accept,e)}async unstable_rejectNes(e){return await l(this,q).sendNotification(oe.nes_reject,e)}async extMethod(e,n){return await l(this,q).sendRequest(e,n)}async extNotification(e,n){return await l(this,q).sendNotification(e,n)}get signal(){return l(this,q).signal}get closed(){return l(this,q).closed}}q=new WeakMap;var sn,fa,cs,us,Nr,Ur,Et,hs,he,tv,_c,nv,rv,iv,sv,Sc,Mi;class AR{constructor(e,n,r){_(this,he);_(this,sn,new Map);_(this,fa,0);_(this,cs);_(this,us);_(this,Nr);_(this,Ur,Promise.resolve());_(this,Et,new AbortController);_(this,hs);x(this,cs,e),x(this,us,n),x(this,Nr,r),x(this,hs,new Promise(i=>{l(this,Et).signal.addEventListener("abort",()=>i())})),m(this,he,tv).call(this)}get signal(){return l(this,Et).signal}get closed(){return l(this,hs)}async sendRequest(e,n){m(this,he,Sc).call(this);const r=Rh(this,fa)._++,i=new Promise((s,o)=>{l(this,sn).set(r,{resolve:s,reject:o})});return await m(this,he,Mi).call(this,{jsonrpc:"2.0",id:r,method:e,params:n}),i}async sendNotification(e,n){m(this,he,Sc).call(this),await m(this,he,Mi).call(this,{jsonrpc:"2.0",method:e,params:n})}}sn=new WeakMap,fa=new WeakMap,cs=new WeakMap,us=new WeakMap,Nr=new WeakMap,Ur=new WeakMap,Et=new WeakMap,hs=new WeakMap,he=new WeakSet,tv=async function(){let e;try{const n=l(this,Nr).readable.getReader();try{for(;!l(this,Et).signal.aborted;){const{value:r,done:i}=await n.read();if(i)break;if(r)try{m(this,he,nv).call(this,r)}catch(s){console.error("Unexpected error during message processing:",r,s),"id"in r&&r.id!==void 0&&m(this,he,Mi).call(this,{jsonrpc:"2.0",id:r.id,error:{code:-32700,message:"Parse error"}})}}}finally{n.releaseLock()}}catch(n){e=n}finally{m(this,he,_c).call(this,e)}},_c=function(e){if(l(this,Et).signal.aborted)return;const n=e??new Error("ACP connection closed");for(const r of l(this,sn).values())r.reject(n);l(this,sn).clear(),l(this,Et).abort(n)},nv=async function(e){if("method"in e&&"id"in e){const n=await m(this,he,rv).call(this,e.method,e.params);"error"in n&&console.error("Error handling request",e,n.error),await m(this,he,Mi).call(this,{jsonrpc:"2.0",id:e.id,...n})}else if("method"in e){const n=await m(this,he,iv).call(this,e.method,e.params);"error"in n&&console.error("Error handling notification",e,n.error)}else"id"in e?m(this,he,sv).call(this,e):console.error("Invalid message",{message:e})},rv=async function(e,n){try{return{result:await l(this,cs).call(this,e,n)??null}}catch(r){if(r instanceof we)return r.toResult();if(r instanceof kp)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()}}},iv=async function(e,n){try{return await l(this,us).call(this,e,n),{result:null}}catch(r){if(r instanceof we)return r.toResult();if(r instanceof kp)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()}}},sv=function(e){const n=l(this,sn).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,sn).delete(e.id)}else console.error("Got response to unknown request",e.id)},Sc=function(){if(l(this,Et).signal.aborted)throw l(this,Et).signal.reason??new Error("ACP connection closed")},Mi=async function(e){return x(this,Ur,l(this,Ur).then(async()=>{const n=l(this,Nr).writable.getWriter();try{await n.write(e)}finally{n.releaseLock()}}).catch(n=>{m(this,he,_c).call(this,n)})),l(this,Ur)};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 TR=/^Sender \(untrusted metadata\):\n```json\n[\s\S]*?\n```\n\n?/,CR=/^\[[^\n]*Working directory:[^\n]*\]\n\n?/,IR=/\[Television screen context\][\s\S]*?\[\/Television screen context\]\n*/,PR=/\[\[\s*(?:reply_to_current|reply_to\s*:\s*[^\]\n]+|audio_as_voice)\s*\]\]\s*/gi,RR="single_session",DR={name:"television-acp-client",version:"0.0.0"},ov="agent:main:television",OR=pi(gt);var te,Nt,Fr,Ut,Vn,jn,on,Zr,$t,lt,an,Gn,Ft,ln,ds,Zt,ct,ga,Ht,C,av,lv,kc,cv,uv,hv,dv,pv,fv,gv,Cn,Ar,Tr,qe,mv,Cr,xc,Ec,Ho,vv,ps,fs,$c,Ir,yv,bv;class zR extends OR{constructor(n){super();_(this,C);_(this,te,LR());_(this,Nt,null);_(this,Fr,null);_(this,Ut,null);_(this,Vn,null);_(this,jn,null);_(this,on,null);_(this,Zr,1);_(this,$t,null);_(this,lt,null);_(this,an,!1);_(this,Gn,!1);_(this,Ft,null);_(this,ln,new Set);_(this,ds);_(this,Zt);_(this,ct);_(this,ga,n=>{m(this,C,lv).call(this,n)});_(this,Ht,null);_(this,ps,()=>{m(this,C,Ir).call(this,"ACP bridge websocket closed")});_(this,fs,()=>{m(this,C,Ir).call(this,"ACP bridge websocket error")});x(this,Zt,n),x(this,ct,n.sessionMode??RR),x(this,ds,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"){m(this,C,qe).call(this,{lifecycle:{status:"connecting"}}),l(this,Fr)??x(this,Fr,m(this,C,av).call(this));try{await l(this,Fr),await m(this,C,kc).call(this)}catch(n){throw m(this,C,Ir).call(this,ko(n)),n}}}dispose(){m(this,C,$c).call(this),m(this,C,qe).call(this,{lifecycle:{status:"disposed"},run:{status:"idle",stopReason:null,canCancel:!1,error: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");m(this,C,Ar).call(this,{id:m(this,C,Cr).call(this,"user"),kind:"user",text:r,status:"final"}),m(this,C,qe).call(this,{run:{status:"running",stopReason:null,canCancel:!0,error:null}});try{const i=await m(this,C,Ho).call(this).prompt({sessionId:m(this,C,Ec).call(this),prompt:[{type:"text",text:m(this,C,mv).call(this,r)}]});m(this,C,Cn).call(this,i.stopReason==="cancelled"?"cancelled":"final"),m(this,C,qe).call(this,{run:{status:i.stopReason==="cancelled"?"cancelled":"completed",stopReason:i.stopReason,canCancel:!1,error:null}})}catch(i){throw m(this,C,bv).call(this)||(m(this,C,Cn).call(this,"error"),m(this,C,qe).call(this,{run:{status:"error",stopReason:null,canCancel:!1,error:ko(i)}})),i}}async cancel(){if(await this.connect(),!l(this,te).run.canCancel||l(this,te).run.status!=="running")throw new Error("No active cancellable run");m(this,C,qe).call(this,{run:{...l(this,te).run,status:"cancelling"}}),await m(this,C,Ho).call(this).cancel({sessionId:m(this,C,Ec).call(this)})}setScreenContext(n){var s,o,a;const r={screenID:n.screenID,screenName:n.screenName};if(((s=l(this,lt))==null?void 0:s.screenID)===r.screenID&&((o=l(this,lt))==null?void 0:o.screenName)===r.screenName)return;const i=((a=l(this,lt))==null?void 0:a.screenID)??null;if(x(this,lt,r),l(this,ct)==="single_session"){(!l(this,on)||i!==r.screenID)&&x(this,an,!0);return}l(this,on)!==Cp(l(this,ct),r.screenID,l(this,Zt).clientGUID??"default-client")&&(x(this,Ut,null),x(this,Vn,null),l(this,Nt)&&l(this,te).run.status==="idle"&&m(this,C,kc).call(this).catch(c=>{m(this,C,Ir).call(this,ko(c))}))}}te=new WeakMap,Nt=new WeakMap,Fr=new WeakMap,Ut=new WeakMap,Vn=new WeakMap,jn=new WeakMap,on=new WeakMap,Zr=new WeakMap,$t=new WeakMap,lt=new WeakMap,an=new WeakMap,Gn=new WeakMap,Ft=new WeakMap,ln=new WeakMap,ds=new WeakMap,Zt=new WeakMap,ct=new WeakMap,ga=new WeakMap,Ht=new WeakMap,C=new WeakSet,av=async function(){try{m(this,C,qe).call(this,{lifecycle:{status:"connecting"}});const{stream:n,socket:r}=await UR({serverURL:l(this,Zt).serverURL,token:l(this,Zt).token,createSocket:l(this,ds),onDisconnect:l(this,ga)});x(this,Ht,r),r.addEventListener("close",l(this,ps)),r.addEventListener("error",l(this,fs)),x(this,Nt,new $R(i=>({connection:i,sessionUpdate:async s=>{await m(this,C,uv).call(this,s)},requestPermission:async s=>m(this,C,hv).call(this,s)}),n)),await l(this,Nt).initialize({protocolVersion:cC,clientCapabilities:{},clientInfo:DR})}catch(n){throw n}},lv=function(n){m(this,C,Ir).call(this,ko(n))},kc=async function(){const n=m(this,C,vv).call(this);if(l(this,Ut)&&l(this,Vn)===n){await l(this,Ut);return}x(this,Vn,n),x(this,Ut,m(this,C,cv).call(this,n)),await l(this,Ut)},cv=async function(n){const r=m(this,C,Ho).call(this);m(this,C,yv).call(this);let i,s=!1;try{x(this,Gn,!0),x(this,Ft,null),await r.loadSession({sessionId:n,cwd:"/",mcpServers:[],_meta:{sessionKey:n}}),i=n,s=l(this,te).messageOrder.length>0}catch{i=(await r.newSession({cwd:"/",mcpServers:[],_meta:{sessionKey:n}})).sessionId,s=!1}finally{x(this,Gn,!1),x(this,Ft,null),m(this,C,Cn).call(this,"final")}await r.setSessionConfigOption({sessionId:i,configId:"verbose_level",value:"full"}),x(this,jn,i),x(this,on,n),s?(l(this,ln).add(n),l(this,ct)==="single_session"&&x(this,an,!1)):(l(this,ln).delete(n),x(this,an,l(this,ct)==="single_session")),m(this,C,qe).call(this,{lifecycle:{status:"ready"}})},uv=async function(n){const r=n.update;switch(r.sessionUpdate){case"user_message_chunk":r.content.type==="text"&&m(this,C,gv).call(this,r.content.text);return;case"agent_message_chunk":r.content.type==="text"&&m(this,C,dv).call(this,r.content.text);return;case"tool_call":m(this,C,pv).call(this,r);return;case"tool_call_update":m(this,C,fv).call(this,r);return;case"agent_thought_chunk":return;default:return}},hv=async function(n){return{outcome:{outcome:"cancelled"}}},dv=function(n){x(this,Ft,null);const r=MR(n);if(!r)return;if(!l(this,$t)){const s={id:m(this,C,Cr).call(this,"assistant"),kind:"assistant",text:r,status:"streaming"};x(this,$t,s.id),m(this,C,Ar).call(this,s);return}const i=l(this,te).messagesById[l(this,$t)];if(!i||i.kind!=="assistant")throw new Error("Open assistant message invariant violated");m(this,C,Tr).call(this,{...i,text:`${i.text}${r}`,status:"streaming"})},pv=function(n){m(this,C,Cn).call(this,"final");const r=m(this,C,xc).call(this,n.toolCallId),i={id:(r==null?void 0:r.id)??m(this,C,Cr).call(this,"tool"),kind:"tool_call",toolCallId:n.toolCallId,title:n.title,toolKind:n.kind??"other",status:n.status==="failed"?"failed":n.status==="completed"?"completed":"in_progress",text:(r==null?void 0:r.text)??"",locations:n.locations??(r==null?void 0:r.locations)};if(r){m(this,C,Tr).call(this,i);return}m(this,C,Ar).call(this,i)},fv=function(n){const r=m(this,C,xc).call(this,n.toolCallId),i=(r==null?void 0:r.text)??"",s=NR(n.content),o=s?`${i}${s}`:i,a={id:(r==null?void 0:r.id)??m(this,C,Cr).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){m(this,C,Tr).call(this,a);return}m(this,C,Ar).call(this,a)},gv=function(n){if(m(this,C,Cn).call(this,"final"),!n)return;const r=l(this,Gn)?l(this,Ft):null;if(!r){const s=Ip(n);if(!s)return;const o={id:m(this,C,Cr).call(this,"user"),kind:"user",text:s,status:"final"};m(this,C,Ar).call(this,o),l(this,Gn)&&x(this,Ft,o.id);return}const i=l(this,te).messagesById[r];if(!i||i.kind!=="user")throw new Error("Replay user message invariant violated");m(this,C,Tr).call(this,{...i,text:Ip(`${i.text}${n}`)})},Cn=function(n){if(!l(this,$t))return;const r=l(this,te).messagesById[l(this,$t)];(r==null?void 0:r.kind)==="assistant"&&m(this,C,Tr).call(this,{...r,status:n}),x(this,$t,null)},Ar=function(n){m(this,C,qe).call(this,{messagesById:{...l(this,te).messagesById,[n.id]:n},messageOrder:[...l(this,te).messageOrder,n.id]})},Tr=function(n){m(this,C,qe).call(this,{messagesById:{...l(this,te).messagesById,[n.id]:n}})},qe=function(n){const r={...l(this,te),...n};x(this,te,{...r,sendDisabled:r.lifecycle.status!=="ready"||r.run.status==="running"||r.run.status==="cancelling",cancelDisabled:!(r.run.status==="running"||r.run.status==="cancelling")||!r.run.canCancel}),this.dispatchEvent(new ee("change"))},mv=function(n){const r=l(this,on);return!l(this,lt)||!r||!(l(this,ct)==="single_session"?l(this,an)||!l(this,ln).has(r):!l(this,ln).has(r))?n:(x(this,an,!1),l(this,ln).add(r),["[Television screen context]","This chat session is coming from a Television client in the screen below.",`screen_id: ${l(this,lt).screenID}`,`screen_name: ${l(this,lt).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
|
+
`))},Cr=function(n){const r=`${n}-${l(this,Zr)}`;return x(this,Zr,l(this,Zr)+1),r},xc=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},Ec=function(){if(!l(this,jn))throw new Error("ACP session is not ready");return l(this,jn)},Ho=function(){if(!l(this,Nt))throw new Error("ACP connection is not ready");return l(this,Nt)},vv=function(){var r;if(l(this,ct)==="single_session")return`${ov}-${(l(this,Zt).clientGUID??"default-client").toLowerCase()}`;const n=(r=l(this,lt))==null?void 0:r.screenID;if(!n)throw new Error("Screen context is required for per-screen session mode");return Cp(l(this,ct),n,l(this,Zt).clientGUID??"default-client")},ps=new WeakMap,fs=new WeakMap,$c=function(){x(this,Nt,null),x(this,Fr,null),x(this,Ut,null),x(this,Vn,null),x(this,jn,null),x(this,on,null),l(this,Ht)&&(l(this,Ht).removeEventListener("close",l(this,ps)),l(this,Ht).removeEventListener("error",l(this,fs)),l(this,Ht).close(),x(this,Ht,null))},Ir=function(n){this.disposed||l(this,te).lifecycle.status==="disconnected"||(m(this,C,Cn).call(this,"error"),m(this,C,$c).call(this),m(this,C,qe).call(this,{lifecycle:{status:"disconnected",...n?{error:n}:{}},run:{status:"idle",stopReason:null,canCancel:!1,error:null}}))},yv=function(){x(this,$t,null),x(this,Ft,null),x(this,Zr,1),m(this,C,qe).call(this,{run:{status:"idle",stopReason:null,canCancel:!1,error:null},messagesById:{},messageOrder:[]})},bv=function(){return l(this,te).lifecycle.status==="disconnected"};function LR(){return{lifecycle:{status:"connecting"},run:{status:"idle",stopReason:null,canCancel:!1,error:null},messagesById:{},messageOrder:[],sendDisabled:!0,cancelDisabled:!0}}function Cp(t,e,n){return t==="single_session"?`${ov}-${n.toLowerCase()}`:`agent:main:television-${n.toLowerCase()}-${e.toLowerCase()}`}function wv(t){return t.replace(/^(?:\s*\n)+/,"")}function Ip(t){let e=t;return e=e.replace(TR,""),e=e.replace(CR,""),e=e.replace(IR,""),e=wv(e),e}function MR(t){let e=t;return e=e.replace(PR,""),e=wv(e),e}function NR(t){return!t||t.length===0?"":t.flatMap(e=>e.type==="content"&&e.content.type==="text"?[e.content.text]:[]).join("")}async function UR(t){const e=t.createSocket(ZR(t.serverURL,t.token));let n=!1,r,i;const s=new Promise((c,u)=>{r=c,i=u}),o=new ReadableStream({start(c){let u=!1;const d=()=>{e.send(JSON.stringify({type:"acp-bridge-connect"}))},p=$=>{const k=FR($);if(!k)return;let I;try{I=JSON.parse(k)}catch(B){const P=B instanceof Error?B:new Error(String(B));i(P),c.error(P);return}switch(I.type){case"acp-bridge-status":if(I.status==="ready"){n||(n=!0,r());return}if(I.status==="error"||I.status==="exited"){const B=new Error(I.error??`ACP bridge ${I.status}`);n||i(B),c.error(B)}return;case"acp-bridge-message":c.enqueue(I.message);return}},y=()=>{var k;if(u)return;u=!0;const $=new Error("ACP bridge websocket closed");n||i($),(k=t.onDisconnect)==null||k.call(t,$),c.close()},v=()=>{var k;if(u)return;u=!0;const $=new Error("ACP bridge websocket error");n||i($),(k=t.onDisconnect)==null||k.call(t,$),c.error($)};e.addEventListener("open",d),e.addEventListener("message",p),e.addEventListener("close",y),e.addEventListener("error",v)}}),a=new WritableStream({async write(c){await s,e.send(JSON.stringify({type:"acp-bridge-message",message:c}))},close(){e.close()},abort(){e.close()}});return await s,{stream:{readable:o,writable:a},socket:e}}function FR(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 ZR(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 ko(t){return t instanceof Error?t.message:String(t)}const Pp="television.acpClientGUID",HR=pi(gt);class BR extends HR{constructor(n){super();b(this,"screenManager");b(this,"clients",new Map);b(this,"options");b(this,"sessionMode");b(this,"clientGUID");b(this,"activeClient",null);b(this,"handleActiveScreenChanged",()=>{this.syncActiveClient()});this.screenManager=n.screenManager,this.sessionMode=n.sessionMode??"single_session",this.options={serverURL:n.serverURL,token:n.token,...n.createSocket?{createSocket:n.createSocket}:{},...n.sessionMode?{sessionMode:n.sessionMode}:{}},this.clientGUID=n.clientGUID??VR(n.storage??window.localStorage),this.screenManager.addEventListener("active-screen-changed",this.handleActiveScreenChanged),this.syncActiveClient()}getActiveClient(){return this.activeClient}dispose(){this.screenManager.removeEventListener("active-screen-changed",this.handleActiveScreenChanged);for(const n of this.clients.values())n.dispose();this.clients.clear(),this.activeClient=null}syncActiveClient(){const n=this.screenManager.activeScreen,r=n?this.getClientForScreen(n):null;this.activeClient!==r&&(this.activeClient=r,this.dispatchEvent(new ee("change")))}getClientForScreen(n){const r=this.sessionMode==="single_session"?"single_session":n.id;let i=this.clients.get(r);return i||(i=new zR({...this.options,sessionMode:this.sessionMode,clientGUID:this.clientGUID}),this.clients.set(r,i)),i.setScreenContext({screenID:n.id,screenName:n.name}),i}}function VR(t){const e=t.getItem(Pp);if(e)return e;const n=Cu().toLowerCase();return t.setItem(Pp,n),n}var gs;class jR extends gt{constructor(){super();_(this,gs,n=>{const r=GR(n);r!==null&&(n.preventDefault(),this.dispatchEvent(new Rx("shortcut-triggered",{shortcut:r})))});document.addEventListener("keydown",l(this,gs))}dispose(){document.removeEventListener("keydown",l(this,gs))}}gs=new WeakMap;function GR(t){for(const[e,n]of Object.entries(lE))if(WR(t,n.trigger))return e;return null}function WR(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 qR="serverURL",YR="token",KR="mode",JR="electron";function _v(t=window.location.search,e=window.location.origin){const r=new URLSearchParams(t).get(qR);return r?new URL(r).origin:new URL(e).origin}function Ac(t=window.location.search){return new URLSearchParams(t).get(YR)}function Sv(t=window.location.search){return new URLSearchParams(t).get(KR)===JR}/**
|
|
44
|
+
* @license
|
|
45
|
+
* Copyright 2017 Google LLC
|
|
46
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
47
|
+
*/const Yi=globalThis,Rp=t=>t,oa=Yi.trustedTypes,Dp=oa?oa.createPolicy("lit-html",{createHTML:t=>t}):void 0,kv="$lit$",en=`lit$${Math.random().toFixed(9).slice(2)}$`,xv="?"+en,XR=`<${xv}>`,ar=document,Qi=()=>ar.createComment(""),es=t=>t===null||typeof t!="object"&&typeof t!="function",Bu=Array.isArray,QR=t=>Bu(t)||typeof(t==null?void 0:t[Symbol.iterator])=="function",Nl=`[
|
|
48
|
+
\f\r]`,$i=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Op=/-->/g,zp=/>/g,An=RegExp(`>|${Nl}(?:([^\\s"'>=/]+)(${Nl}*=${Nl}*(?:[^
|
|
49
|
+
\f\r"'\`<>=]|("|')|))|$)`,"g"),Lp=/'/g,Mp=/"/g,Ev=/^(?:script|style|textarea|title)$/i,eD=t=>(e,...n)=>({_$litType$:t,strings:e,values:n}),F=eD(1),ri=Symbol.for("lit-noChange"),ae=Symbol.for("lit-nothing"),Np=new WeakMap,Mn=ar.createTreeWalker(ar,129);function $v(t,e){if(!Bu(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return Dp!==void 0?Dp.createHTML(e):e}const tD=(t,e)=>{const n=t.length-1,r=[];let i,s=e===2?"<svg>":e===3?"<math>":"",o=$i;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===$i?d[1]==="!--"?o=Op:d[1]!==void 0?o=zp:d[2]!==void 0?(Ev.test(d[2])&&(i=RegExp("</"+d[2],"g")),o=An):d[3]!==void 0&&(o=An):o===An?d[0]===">"?(o=i??$i,p=-1):d[1]===void 0?p=-2:(p=o.lastIndex-d[2].length,u=d[1],o=d[3]===void 0?An:d[3]==='"'?Mp:Lp):o===Mp||o===Lp?o=An:o===Op||o===zp?o=$i:(o=An,i=void 0);const v=o===An&&t[a+1].startsWith("/>")?" ":"";s+=o===$i?c+XR:p>=0?(r.push(u),c.slice(0,p)+kv+c.slice(p)+en+v):c+en+(p===-2?a:v)}return[$v(t,s+(t[n]||"<?>")+(e===2?"</svg>":e===3?"</math>":"")),r]};class ts{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]=tD(e,n);if(this.el=ts.createElement(u,r),Mn.currentNode=this.el.content,n===2||n===3){const p=this.el.content.firstChild;p.replaceWith(...p.childNodes)}for(;(i=Mn.nextNode())!==null&&c.length<a;){if(i.nodeType===1){if(i.hasAttributes())for(const p of i.getAttributeNames())if(p.endsWith(kv)){const y=d[o++],v=i.getAttribute(p).split(en),$=/([.?@])?(.*)/.exec(y);c.push({type:1,index:s,name:$[2],strings:v,ctor:$[1]==="."?rD:$[1]==="?"?iD:$[1]==="@"?sD:Ga}),i.removeAttribute(p)}else p.startsWith(en)&&(c.push({type:6,index:s}),i.removeAttribute(p));if(Ev.test(i.tagName)){const p=i.textContent.split(en),y=p.length-1;if(y>0){i.textContent=oa?oa.emptyScript:"";for(let v=0;v<y;v++)i.append(p[v],Qi()),Mn.nextNode(),c.push({type:2,index:++s});i.append(p[y],Qi())}}}else if(i.nodeType===8)if(i.data===xv)c.push({type:2,index:s});else{let p=-1;for(;(p=i.data.indexOf(en,p+1))!==-1;)c.push({type:7,index:s}),p+=en.length-1}s++}}static createElement(e,n){const r=ar.createElement("template");return r.innerHTML=e,r}}function ii(t,e,n=t,r){var o,a;if(e===ri)return e;let i=r!==void 0?(o=n._$Co)==null?void 0:o[r]:n._$Cl;const s=es(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=ii(t,i._$AS(t,e.values),i,r)),e}class nD{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)??ar).importNode(n,!0);Mn.currentNode=i;let s=Mn.nextNode(),o=0,a=0,c=r[0];for(;c!==void 0;){if(o===c.index){let u;c.type===2?u=new Vu(s,s.nextSibling,this,e):c.type===1?u=new c.ctor(s,c.name,c.strings,this,e):c.type===6&&(u=new oD(s,this,e)),this._$AV.push(u),c=r[++a]}o!==(c==null?void 0:c.index)&&(s=Mn.nextNode(),o++)}return Mn.currentNode=ar,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 Vu=class Av{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=ii(this,e,n),es(e)?e===ae||e==null||e===""?(this._$AH!==ae&&this._$AR(),this._$AH=ae):e!==this._$AH&&e!==ri&&this._(e):e._$litType$!==void 0?this.$(e):e.nodeType!==void 0?this.T(e):QR(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&&es(this._$AH)?this._$AA.nextSibling.data=e:this.T(ar.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=ts.createElement($v(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 nD(i,this),a=o.u(this.options);o.p(n),this.T(a),this._$AH=o}}_$AC(e){let n=Np.get(e.strings);return n===void 0&&Np.set(e.strings,n=new ts(e)),n}k(e){Bu(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 Av(this.O(Qi()),this.O(Qi()),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=Rp(e).nextSibling;Rp(e).remove(),e=i}}setConnected(e){var n;this._$AM===void 0&&(this._$Cv=e,(n=this._$AP)==null||n.call(this,e))}},Ga=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=ii(this,e,n,0),o=!es(e)||e!==this._$AH&&e!==ri,o&&(this._$AH=e);else{const a=e;let c,u;for(e=s[0],c=0;c<s.length-1;c++)u=ii(this,a[r+c],n,c),u===ri&&(u=this._$AH[c]),o||(o=!es(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??"")}},rD=class extends Ga{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===ae?void 0:e}},iD=class extends Ga{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==ae)}},sD=class extends Ga{constructor(e,n,r,i,s){super(e,n,r,i,s),this.type=5}_$AI(e,n=this){if((e=ii(this,e,n,0)??ae)===ri)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 oD{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){ii(this,e)}}const Ul=Yi.litHtmlPolyfillSupport;Ul==null||Ul(ts,Vu),(Yi.litHtmlVersions??(Yi.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 Vu(e.insertBefore(Qi(),null),null,void 0,{})),i._$AI(t),i},aD=.5,Up=.1,Fp=8,lD=4,Tv=3,Cv=3,cD=4,Nn=255,Iv=.2126,Pv=.7152,Rv=.0722;async function ju(t){const e=uD(t);if(!e)return"light";try{return await pD(t,e)>=aD?"light":"dark"}catch{return"light"}}function uD(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(hD(o))return s}return null}function hD(t){return t.backgroundImage&&t.backgroundImage!=="none"?!0:dD(t.backgroundColor)>0}function dD(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===cD?parseFloat(n[Tv]):n.length===Cv?1:0}async function pD(t,e){const n=t.getBoundingClientRect(),r=e.getBoundingClientRect(),i={x:xo((n.left-r.left)/r.width),y:xo((n.top-r.top)/r.height),width:xo(n.width/r.width),height:xo(n.height/r.height)},s=window.getComputedStyle(e),o=fD(s.backgroundImage);return o?mD({url:o,surfaceWidth:r.width,surfaceHeight:r.height,region:i}):vD(s.backgroundColor)}function fD(t){const e=t.match(/url\(\s*["']?([^"')]+)["']?\s*\)/);return e?e[1]:null}const Zp=new Map;function gD(t){let e=Zp.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}),Zp.set(t,e),e)}async function mD(t){const e=await gD(t.url),n=Math.max(Fp,Math.ceil(t.surfaceWidth*Up)),r=Math.max(Fp,Math.ceil(t.surfaceHeight*Up)),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)),$=Math.max(1,Math.min(n-y,Math.floor(t.region.width*n))),k=Math.max(1,Math.min(r-v,Math.floor(t.region.height*r))),I=s.getImageData(y,v,$,k).data;let B=0,P=0;for(let K=0;K<I.length;K+=lD){const L=I[K]/Nn,Z=I[K+1]/Nn,N=I[K+2]/Nn,ce=I[K+Tv]/Nn;B+=ce*(Iv*L+Pv*Z+Rv*N),P+=1}return P>0?B/P:1}function vD(t){const e=t.match(/rgba?\(([^)]+)\)/);if(!e)return 1;const n=e[1].split(/[\s,/]+/).filter(Boolean).map(parseFloat);if(n.length<Cv)return 1;const r=n[0]/Nn,i=n[1]/Nn,s=n[2]/Nn;return Iv*r+Pv*i+Rv*s}function xo(t){return t<0?0:t>1?1:t}const Fl=new WeakSet,Hp=new WeakSet;function Dv(t){if(Hp.has(t))return;Hp.add(t);for(const n of t.querySelectorAll('button[variant="ghost"]'))Zl(n);if(typeof MutationObserver!="function")return;new MutationObserver(n=>{for(const r of n)if(r.type==="childList")for(const i of r.addedNodes)yD(i,Zl);else r.type==="attributes"&&r.target instanceof HTMLButtonElement&&r.target.getAttribute("variant")==="ghost"&&Zl(r.target)}).observe(t,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["variant"]})}function yD(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 Zl(t){if(Fl.has(t))return;Fl.add(t);const e=await ju(t);if(t.getAttribute("variant")!=="ghost"){Fl.delete(t);return}t.setAttribute("tone",e)}const bD="*,*: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)}',Gu=new CSSStyleSheet;Gu.replaceSync(bD);try{document.adoptedStyleSheets=[...document.adoptedStyleSheets,Gu]}catch{}Dv(document);function Ov(t){try{t.adoptedStyleSheets=[...t.adoptedStyleSheets,Gu]}catch{}Dv(t)}/**
|
|
50
|
+
* @license
|
|
51
|
+
* Copyright 2017 Google LLC
|
|
52
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
53
|
+
*/const zv={CHILD:2},Wu=t=>(...e)=>({_$litDirective$:t,values:e});class Lv{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 aa=class extends Lv{constructor(e){if(super(e),this.it=ae,e.type!==zv.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===ri)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:[]}}};aa.directiveName="unsafeHTML",aa.resultType=1;const wD=Wu(aa);/**
|
|
58
|
+
* @license
|
|
59
|
+
* Copyright 2017 Google LLC
|
|
60
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
61
|
+
*/class Tc extends aa{}Tc.directiveName="unsafeSVG",Tc.resultType=2;const _D=Wu(Tc),SD={size:16,color:"currentColor",weight:"regular"};function kD(t){return typeof t=="string"?{regular:t}:t}function Jt(t,e="0 0 256 256"){const n=kD(t);return r=>{const{size:i,color:s,weight:o}={...SD,...r},a=n[o]??n.regular;return F`<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
|
+
>${_D(a)}</svg>`}}const xD=Jt('<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"/>'),Mv=Jt('<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"/>'),ED=Jt('<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"/>'),Nv=Jt('<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"/>'),$D=Jt('<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"/>'),AD=Jt('<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"/>'),TD=Jt({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"/>'}),CD=Jt({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"/>'}),ID=Jt({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 Uv extends Event{constructor(n){super("dropdown-item-select",{bubbles:!0,composed:!0});b(this,"value");this.value=n}}class PD extends Event{constructor(n){super("select",{bubbles:!0,composed:!0});b(this,"value");this.value=n}}var Ke,ut,cn,Wn,ne,ms,z,Zv,Ni,Hv,Bv,Cc,Vv,Ui,In,qn,vs,ys,bs,ma,jv,Gv,Ic,Fi,Wv,Pc,zt;class Fv extends HTMLElement{constructor(){super();_(this,z);_(this,Ke,!1);_(this,ut,null);_(this,cn,null);_(this,Wn);_(this,ne,null);_(this,ms,new MutationObserver(n=>m(this,z,jv).call(this,n)));_(this,qn,()=>{m(this,z,Ui).call(this,!l(this,Ke))});_(this,vs,n=>{n.key!=="Enter"&&n.key!==" "||(n.preventDefault(),l(this,qn).call(this))});_(this,ys,n=>{l(this,Ke)&&(n.composedPath().includes(this)||m(this,z,Ui).call(this,!1))});_(this,bs,n=>{n instanceof Uv&&(n.stopPropagation(),x(this,Ke,!1),m(this,z,Ni).call(this,n.value),m(this,z,zt).call(this),this.dispatchEvent(new PD(n.value)))});_(this,ma,()=>{m(this,z,Ic).call(this)});x(this,Wn,this.attachShadow({mode:"open"})),Ov(l(this,Wn))}connectedCallback(){this.addEventListener("dropdown-item-select",l(this,bs)),document.addEventListener("click",l(this,ys),!0),m(this,z,Zv).call(this),l(this,ms).observe(this,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["selected","value","slot"]}),m(this,z,zt).call(this)}disconnectedCallback(){this.removeEventListener("dropdown-item-select",l(this,bs)),document.removeEventListener("click",l(this,ys),!0),l(this,ms).disconnect(),m(this,z,Pc).call(this)}attributeChangedCallback(n){if(n==="open"){m(this,z,Ui).call(this,this.hasAttribute("open"));return}m(this,z,zt).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,ut)}set value(n){n===null?(m(this,z,In).call(this,null,null),m(this,z,Hv).call(this)):m(this,z,Ni).call(this,n),m(this,z,zt).call(this)}close(){m(this,z,Ui).call(this,!1)}}Ke=new WeakMap,ut=new WeakMap,cn=new WeakMap,Wn=new WeakMap,ne=new WeakMap,ms=new WeakMap,z=new WeakSet,Zv=function(){var r;const n=this.querySelector("dropdown-item[selected]");n&&m(this,z,In).call(this,n.value,((r=n.textContent)==null?void 0:r.trim())??null)},Ni=function(n){var r;for(const i of l(this,z,Cc))i.value===n?(m(this,z,In).call(this,n,((r=i.textContent)==null?void 0:r.trim())??null),i.hasAttribute("selected")||i.setAttribute("selected","")):i.hasAttribute("selected")&&i.removeAttribute("selected")},Hv=function(){const n=this.querySelectorAll("dropdown-item[selected]");for(const r of n)r.removeAttribute("selected")},Bv=function(n){for(const r of l(this,z,Cc))if(r.value===n)return r;return null},Cc=function(){return this.querySelectorAll("dropdown-item")},Vv=function(){return l(this,cn)??this.title},Ui=function(n){l(this,Ke)!==n&&(x(this,Ke,n),m(this,z,zt).call(this))},In=function(n,r){x(this,ut,n),x(this,cn,r)},qn=new WeakMap,vs=new WeakMap,ys=new WeakMap,bs=new WeakMap,ma=new WeakMap,jv=function(n){n.every(i=>i.target instanceof Element?i.target.closest('[slot="trigger"]')!==null:!1)||m(this,z,Gv).call(this)},Gv=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,ut)!==s||l(this,cn)!==o;m(this,z,In).call(this,s,o),m(this,z,Ni).call(this,s),a?m(this,z,zt).call(this):m(this,z,Fi).call(this);return}if(l(this,ut)!==null){const s=m(this,z,Bv).call(this,l(this,ut));if(s){const o=((i=s.textContent)==null?void 0:i.trim())??null,a=l(this,cn)!==o;m(this,z,In).call(this,l(this,ut),o),m(this,z,Ni).call(this,l(this,ut)),a?m(this,z,zt).call(this):m(this,z,Fi).call(this);return}}if(l(this,ut)!==null||l(this,cn)!==null){m(this,z,In).call(this,null,null),m(this,z,zt).call(this);return}m(this,z,Fi).call(this)},Ic=function(){const n=l(this,Wn).querySelector('slot[name="trigger"]'),r=n instanceof HTMLSlotElement?n.assignedElements()[0]??null:null;l(this,ne)!==r&&(m(this,z,Pc).call(this),x(this,ne,r),l(this,ne)&&(l(this,ne).addEventListener("click",l(this,qn)),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,vs))))),m(this,z,Fi).call(this)},Fi=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"))},Wv=function(){return this.placement==="top"?$D:Nv},Pc=function(){l(this,ne)&&(l(this,ne).removeEventListener("click",l(this,qn)),l(this,ne).removeEventListener("keydown",l(this,vs)),l(this,ne).removeAttribute("data-dropdown-trigger"),l(this,ne).removeAttribute("aria-haspopup"),l(this,ne).removeAttribute("aria-expanded"),x(this,ne,null))},zt=function(){this.toggleAttribute("open",l(this,Ke)),Re(F`
|
|
69
|
+
<slot name="trigger" @slotchange=${l(this,ma)}>
|
|
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,qn)}
|
|
77
|
+
>
|
|
78
|
+
<span class="trigger-label" part="trigger-label">${l(this,z,Vv)}</span>
|
|
79
|
+
<span class="trigger-icon" part="trigger-icon" aria-hidden="true">
|
|
80
|
+
${l(this,z,Wv).call(this,{size:16})}
|
|
81
|
+
</span>
|
|
82
|
+
</button>
|
|
83
|
+
</slot>
|
|
84
|
+
${l(this,Ke)?F`
|
|
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,Wn)),queueMicrotask(()=>m(this,z,Ic).call(this))},b(Fv,"observedAttributes",["title","placement","open"]);class RD extends HTMLElement{}class DD extends HTMLElement{}class OD extends HTMLElement{}var ur,Rc,Yv,ws,_s;class qv extends HTMLElement{constructor(){super(...arguments);_(this,ur);_(this,ws,()=>{this.action||m(this,ur,Yv).call(this)});_(this,_s,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,ws)),this.addEventListener("keydown",l(this,_s)),m(this,ur,Rc).call(this)}disconnectedCallback(){this.removeEventListener("click",l(this,ws)),this.removeEventListener("keydown",l(this,_s))}attributeChangedCallback(){m(this,ur,Rc).call(this)}get value(){return this.getAttribute("value")??""}get selected(){return this.hasAttribute("selected")}get action(){return this.hasAttribute("action")}}ur=new WeakSet,Rc=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")},Yv=function(){this.dispatchEvent(new Uv(this.value))},ws=new WeakMap,_s=new WeakMap,b(qv,"observedAttributes",["action","selected","value"]);customElements.get("dropdown-menu")||customElements.define("dropdown-menu",Fv);customElements.get("dropdown-group")||customElements.define("dropdown-group",RD);customElements.get("dropdown-label")||customElements.define("dropdown-label",DD);customElements.get("dropdown-divider")||customElements.define("dropdown-divider",OD);customElements.get("dropdown-item")||customElements.define("dropdown-item",qv);class zD extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}var Ss,vn,Dc,va,ks,Oc;class Kv extends HTMLElement{constructor(){super();_(this,vn);_(this,Ss);_(this,va,n=>{n.target===n.currentTarget&&m(this,vn,Dc).call(this)});_(this,ks,n=>{this.open&&n.key==="Escape"&&m(this,vn,Dc).call(this)});x(this,Ss,this.attachShadow({mode:"open"}))}connectedCallback(){document.addEventListener("keydown",l(this,ks)),m(this,vn,Oc).call(this)}disconnectedCallback(){document.removeEventListener("keydown",l(this,ks))}attributeChangedCallback(){m(this,vn,Oc).call(this)}get open(){return this.hasAttribute("open")}}Ss=new WeakMap,vn=new WeakSet,Dc=function(){this.dispatchEvent(new zD)},va=new WeakMap,ks=new WeakMap,Oc=function(){Re(F`
|
|
96
|
+
${this.open?F`
|
|
97
|
+
<div class="backdrop" part="backdrop" @click=${l(this,va)}>
|
|
98
|
+
<slot></slot>
|
|
99
|
+
</div>
|
|
100
|
+
`:null}
|
|
101
|
+
`,l(this,Ss))},b(Kv,"observedAttributes",["open"]);customElements.get("modal-overlay")||customElements.define("modal-overlay",Kv);class LD extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}class MD extends HTMLElement{}var xs,Es,zc;class Jv extends HTMLElement{constructor(){super();_(this,Es);_(this,xs);x(this,xs,this.attachShadow({mode:"open"}))}connectedCallback(){m(this,Es,zc).call(this)}attributeChangedCallback(){m(this,Es,zc).call(this)}get closable(){return this.hasAttribute("closable")}}xs=new WeakMap,Es=new WeakSet,zc=function(){const n=this.querySelector("panel-page");Re(F`
|
|
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?F`
|
|
106
|
+
<button
|
|
107
|
+
type="button"
|
|
108
|
+
class="title-button"
|
|
109
|
+
part="button close-button"
|
|
110
|
+
aria-label="Close"
|
|
111
|
+
@click=${()=>this.dispatchEvent(new LD)}
|
|
112
|
+
>
|
|
113
|
+
<span class="close-icon" part="icon close-icon">${Mv({size:16})}</span>
|
|
114
|
+
</button>
|
|
115
|
+
`:null}
|
|
116
|
+
</header>
|
|
117
|
+
<slot></slot>
|
|
118
|
+
</section>
|
|
119
|
+
`,l(this,xs))},b(Jv,"observedAttributes",["closable"]);customElements.get("panel-view")||customElements.define("panel-view",Jv);customElements.get("panel-page")||customElements.define("panel-page",MD);class ND extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}const Bp='a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])',Hl=4;var Be,Bt,Yn,et,$s,Hr,re,Qv,ey,Lc,As,Ts,Kn,ty,Mc,ny,ry,Bo,Vo;class Xv extends HTMLElement{constructor(){super();_(this,re);_(this,Be,!1);_(this,Bt,null);_(this,Yn);_(this,et,null);_(this,$s,"bottom-start");_(this,Hr,!1);_(this,As,n=>{l(this,Be)&&(l(this,Hr)||n.composedPath().includes(this)||(this.open=!1))});_(this,Ts,n=>{if(l(this,Be)){if(n.key==="Escape"){n.preventDefault(),this.open=!1;return}n.key==="Tab"&&m(this,re,ty).call(this,n)}});_(this,Kn,()=>{l(this,Be)&&m(this,re,Bo).call(this)});x(this,Yn,this.attachShadow({mode:"open"})),Ov(l(this,Yn))}connectedCallback(){this.hasAttribute("tone")||this.setAttribute("tone","light"),m(this,re,Vo).call(this)}disconnectedCallback(){m(this,re,Lc).call(this)}attributeChangedCallback(n){n==="open"&&m(this,re,Qv).call(this,this.hasAttribute("open"))}get open(){return l(this,Be)}set open(n){this.toggleAttribute("open",n)}get anchor(){return l(this,Bt)}set anchor(n){l(this,Bt)!==n&&(x(this,Bt,n),l(this,Be)&&m(this,re,Bo).call(this))}}Be=new WeakMap,Bt=new WeakMap,Yn=new WeakMap,et=new WeakMap,$s=new WeakMap,Hr=new WeakMap,re=new WeakSet,Qv=function(n){var r;l(this,Be)!==n&&(x(this,Be,n),n?(x(this,Hr,!0),setTimeout(()=>{x(this,Hr,!1)},0),m(this,re,Vo).call(this),m(this,re,ey).call(this),queueMicrotask(()=>{l(this,Be)&&(m(this,re,Bo).call(this),m(this,re,ry).call(this))})):(m(this,re,Lc).call(this),m(this,re,Vo).call(this),(r=l(this,Bt))==null||r.focus(),this.dispatchEvent(new ND)))},ey=function(){document.addEventListener("click",l(this,As)),document.addEventListener("keydown",l(this,Ts),!0),window.addEventListener("resize",l(this,Kn)),window.addEventListener("scroll",l(this,Kn),!0)},Lc=function(){document.removeEventListener("click",l(this,As)),document.removeEventListener("keydown",l(this,Ts),!0),window.removeEventListener("resize",l(this,Kn)),window.removeEventListener("scroll",l(this,Kn),!0)},As=new WeakMap,Ts=new WeakMap,Kn=new WeakMap,ty=function(n){const r=m(this,re,Mc).call(this);if(r.length===0){n.preventDefault();return}const i=r[0],s=r[r.length-1],o=m(this,re,ny).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())},Mc=function(){if(!l(this,et))return[];const n=l(this,et).querySelector("slot");if(!(n instanceof HTMLSlotElement))return[];const r=[];for(const i of n.assignedElements({flatten:!0}))if(i instanceof HTMLElement){i.matches(Bp)&&r.push(i);for(const s of i.querySelectorAll(Bp))r.push(s)}return r},ny=function(){var r;let n=document.activeElement;for(;n&&((r=n.shadowRoot)!=null&&r.activeElement);)n=n.shadowRoot.activeElement;return n},ry=function(){var r;const n=m(this,re,Mc).call(this);n.length>0?n[0].focus():(r=l(this,et))==null||r.focus()},Bo=function(){if(!l(this,Be)||!l(this,Bt)||!l(this,et))return;const n=l(this,Bt).getBoundingClientRect(),r=l(this,et).getBoundingClientRect(),s=window.innerHeight-n.bottom,o=r.height+Hl,a=s<o&&n.top>o?"top-start":"bottom-start";x(this,$s,a);const c=a==="bottom-start"?n.bottom+Hl:n.top-r.height-Hl,u=n.left;l(this,et).style.top=`${c}px`,l(this,et).style.left=`${u}px`,l(this,et).setAttribute("data-placement",a)},Vo=function(){this.toggleAttribute("open",l(this,Be)),Re(l(this,Be)?F`<div
|
|
120
|
+
class="panel"
|
|
121
|
+
part="panel"
|
|
122
|
+
data-placement=${l(this,$s)}
|
|
123
|
+
tabindex="-1"
|
|
124
|
+
role="dialog"
|
|
125
|
+
material="paper"
|
|
126
|
+
level="1"
|
|
127
|
+
>
|
|
128
|
+
<slot></slot>
|
|
129
|
+
</div>`:ae,l(this,Yn)),x(this,et,l(this,Yn).querySelector(".panel"))},b(Xv,"observedAttributes",["open"]);customElements.get("ui-popover")||customElements.define("ui-popover",Xv);const UD=ft(),FD="No handler registered for update-content",ZD="handleUpdateContent: handler already registered";function HD(t){return t instanceof Error&&typeof t.message=="string"?t.message:String(t)}const BD=pi(gt);var Br,Vr,jr,Jn,Xn,Cs,Ce,Nc,iy,sy,Zi,Uc,_f;let VD=(_f=class extends BD{constructor(n){super();_(this,Ce);_(this,Br);_(this,Vr);_(this,jr);_(this,Jn,null);_(this,Xn,null);_(this,Cs,!1);x(this,Br,n);const r=n.ownerDocument.defaultView;if(!r)throw new Error("ArtifactView: iframe has no owner window");x(this,Vr,r),x(this,jr,i=>m(this,Ce,iy).call(this,i)),l(this,Vr).addEventListener("message",l(this,jr))}get content(){return l(this,Xn)}set content(n){m(this,Ce,Uc).call(this),x(this,Xn,n),l(this,Cs)&&m(this,Ce,Nc).call(this,n)}handleUpdateContent(n){if(m(this,Ce,Uc).call(this),l(this,Jn)!==null)throw new Error(ZD);x(this,Jn,n)}dispose(){l(this,Vr).removeEventListener("message",l(this,jr)),x(this,Jn,null)}},Br=new WeakMap,Vr=new WeakMap,jr=new WeakMap,Jn=new WeakMap,Xn=new WeakMap,Cs=new WeakMap,Ce=new WeakSet,Nc=function(n){const r={type:"content-updated",content:n};m(this,Ce,Zi).call(this,r)},iy=function(n){if(this.disposed||n.source!==l(this,Br).contentWindow)return;const r=n.data;if(XT(r)){x(this,Cs,!0),this.dispatchEvent(new UD("ready")),l(this,Xn)!==null&&m(this,Ce,Nc).call(this,l(this,Xn));return}if(QT(r)){m(this,Ce,sy).call(this,r);return}},sy=async function(n){const r=l(this,Jn);if(r===null){m(this,Ce,Zi).call(this,{type:"response",id:n.id,error:{message:FD}});return}try{await r(n.content)}catch(i){if(this.disposed)return;m(this,Ce,Zi).call(this,{type:"response",id:n.id,error:{message:HD(i)}});return}this.disposed||m(this,Ce,Zi).call(this,{type:"response",id:n.id,result:{}})},Zi=function(n){const r=l(this,Br).contentWindow;r&&r.postMessage(n,"*")},Uc=function(){if(this.disposed)throw new Error("ArtifactView is disposed")},_f);function jD(t=window){t.parent!==t&&(t.addEventListener("wheel",e=>{const n=e;t.parent.postMessage({type:"wheel",deltaX:n.deltaX,deltaY:n.deltaY,shiftKey:n.shiftKey},"*"),n.preventDefault()},{passive:!1}),t.addEventListener("message",e=>{const n=e.data;if(n!==null&&typeof n=="object"&&n.type==="scroll"){const r=n,i=typeof r.deltaX=="number"?r.deltaX:0,s=typeof r.deltaY=="number"?r.deltaY:0;t.scrollBy(i,s)}}))}function GD(){return`(${jD.toString()})(window);`}async function WD(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=GD(),r.head.appendChild(s);const o=new Blob([`<!DOCTYPE html>
|
|
130
|
+
${r.documentElement.outerHTML}`],{type:"text/html"});return URL.createObjectURL(o)}const oy=ft();class qD 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 oy("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 VD(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 WD(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"?F`
|
|
131
|
+
<div class="artifact-content artifact-placeholder">
|
|
132
|
+
<em>Failed to load content</em>
|
|
133
|
+
</div>
|
|
134
|
+
`:this._viewURL!==null||this._directRender?F`
|
|
135
|
+
<iframe
|
|
136
|
+
class="artifact-frame artifact-content"
|
|
137
|
+
src=${this._blobURL??"about:blank"}
|
|
138
|
+
sandbox="allow-scripts"
|
|
139
|
+
></iframe>
|
|
140
|
+
`:F`
|
|
141
|
+
<div class="artifact-content artifact-placeholder">
|
|
142
|
+
<em>Artifact unavailable</em>
|
|
143
|
+
</div>
|
|
144
|
+
`}template(){const n=this._artifact;return F`
|
|
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">${xD({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
|
+
${Mv({size:16})}
|
|
159
|
+
</button>
|
|
160
|
+
</footer>
|
|
161
|
+
`}render(){this._artifact&&(this.setAttribute("type",this._artifact.type),Re(this.template(),this))}}customElements.define("artifact-view",qD);const ke=t=>({type:"px",...t}),Te=t=>({type:"unit",...t}),Eo=2,YD=2;class KD{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??sr,r=this._viewport.y??ea,i=this._gap.x??ge,s=this._gap.y??ge,o=sr+i*YD,a=n<=o,c=a?n-i*Eo:Math.min(sr,n-i*Eo),u=a?r-s*Eo:Math.min(ea,r-s*Eo),d=(c-i*(Ct-1))/Ct,p=(u-s*(Xe-1))/Xe,y=this.basis.x??0,v=this.basis.y??0,$=this.min.x??0,k=this.min.y??0;this._unit=ke(a?{x:Math.max($,d),y:Math.max(k,p)}:{x:Math.max($,Math.min(y,d)),y:Math.max(k,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 lr=1e-4,jt=1e-6,JD=40,XD=24;function ay(t,e){return Math.max(0,t-e*2)}function ly(t){const e=[0];for(const n of t)e.push((e[e.length-1]??0)+n);return e}function cy(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 uy(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+lr)break;r=a,i+=1}return Math.max(1,i)}function QD(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+lr)break;r=a,i+=1}return Math.max(1,i)}function e2(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+lr)break;n=o,r+=1}return Math.max(1,r)}function qu(t,e){if(t.length===0)return 0;const n=e2(t,e);return Math.max(0,t.length-n)}function Vp(t,e,n){if(t.length===0)return 0;const r=uy(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 Fc(t,e,n){const r=t[e]??0;return n-r}function Pr(t,e,n,r,i){if(t.length===0)return 0;const s=qu(t,i),o=e[s]??0,a=Math.max(0,Math.min(o,n));let c=0;for(let Z=0;Z<s;Z+=1){const N=e[Z]??0,ce=e[Z+1]??N;if(a>=N&&a<=ce+lr){c=Z;break}c=Z+1}const u=Math.min(c+1,s),d=e[c]??0,p=e[u]??d,y=Math.max(p-d,lr),v=u===c?0:(a-d)/y,$=cy(t),k=Vp(t,c,i),I=Vp(t,u,i),B=(r-k)/2,P=(r-I)/2,K=Fc($,c,B),L=Fc($,u,P);return K+(L-K)*v}function jp(t,e,n,r,i){const s=qu(t,r),o=e[s]??0;let a=0,c=o;for(let u=0;u<JD;u+=1){const d=(a+c)/2;Pr(t,e,d,n,r)>i?a=d:c=d}return(a+c)/2}function Gp(t,e,n){const r=cy(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 Fc(r,i,c)}function t2(t,e,n){const r=uy(t,e,n);return[e,Math.min(t.length-1,e+r-1)]}function n2(t,e,n){const r=QD(t,e,n);return[Math.max(0,e-r+1),e]}function r2(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)<=jt||(e.add(i),n.push(r))}return n}function i2(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=ay(r,i),o=ly(e),a=qu(n,s),c=o[a]??0,u=[];for(let d=0;d<=a;d+=1){const p=t2(n,d,s),y=Gp(n,p,r),v=jp(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=n2(n,d,s),y=`${p[0]}:${p[1]}`;if(u.some(k=>`${k.nodeRange[0]}:${k.nodeRange[1]}`===y))continue;const v=Gp(n,p,r),$=jp(n,o,r,s,v);u.push({nodeRange:p,anchor:Math.max(0,Math.min(c,$))})}return u.sort((d,p)=>Math.abs(d.anchor-p.anchor)>jt?d.anchor-p.anchor:d.nodeRange[0]!==p.nodeRange[0]?d.nodeRange[0]-p.nodeRange[0]:d.nodeRange[1]-p.nodeRange[1]),{viewspans:r2(u),minScroll:0,maxScroll:c}}function s2(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+jt<r){r=o,n=s;continue}Math.abs(o-r)<=jt&&s<n&&(n=s)}return n}function o2(t,e,n){return n<=0?0:Math.max(0,Math.min(n-1,t+e))}function Ai(t,e,n){return Math.max(e,Math.min(n,t))}class a2 extends gt{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:Pr(this.nodeWidthsPx,this.boundaryCols,this._scroll,this.viewportWidthPx,this.framedViewportWidthPx)})}set scroll(n){const r=Ai(n.x??this._scroll,this.minScroll,this.maxScroll);Math.abs(r-this._scroll)<=jt||(this._scroll=r,this.activeViewspanIndex=null,this.dispatchEvent(new Ei("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=i2({nodeCols:r,nodeWidthsPx:i,viewportWidthPx:s,gapPx:o});this.nodeWidthsPx=i,this.boundaryCols=ly(r),this.viewportWidthPx=s,this.framedViewportWidthPx=ay(s,o),this.viewspans=a.viewspans,this.minScroll=a.minScroll,this.maxScroll=a.maxScroll,this.activeViewspanIndex=null;const c=Ai(this._scroll,this.minScroll,this.maxScroll);Math.abs(c-this._scroll)>jt&&(this._scroll=c,this.dispatchEvent(new Ei("layout-scroll",{scroll:this.scroll})))}step(n){var a;if(this.viewspans.length===0)return;const r=this.activeViewspanIndex??s2(this.viewspans,this._scroll),i=o2(r,n,this.viewspans.length),s=((a=this.viewspans[i])==null?void 0:a.anchor)??this._scroll,o=Ai(s,this.minScroll,this.maxScroll);this.activeViewspanIndex=i,!(Math.abs(o-this._scroll)<=jt)&&(this._scroll=o,this.dispatchEvent(new Ei("layout-scroll",{scroll:this.scroll})))}wheel(n){const r=Ai(this._scroll+(n.x??0),this.minScroll,this.maxScroll);this.activeViewspanIndex=null,!(Math.abs(r-this._scroll)<=jt)&&(this._scroll=r,this.dispatchEvent(new Ei("layout-scroll",{scroll:this.scroll})))}wheelPixels(n){const r=n.x??0;if(Math.abs(r)<=lr)return;this.activeViewspanIndex=null;const i=Pr(this.nodeWidthsPx,this.boundaryCols,this._scroll,this.viewportWidthPx,this.framedViewportWidthPx),s=i-r,o=Pr(this.nodeWidthsPx,this.boundaryCols,this.maxScroll,this.viewportWidthPx,this.framedViewportWidthPx),a=Pr(this.nodeWidthsPx,this.boundaryCols,this.minScroll,this.viewportWidthPx,this.framedViewportWidthPx),c=Math.max(o,Math.min(a,s));if(Math.abs(c-i)<=lr)return;let u=this.minScroll,d=this.maxScroll;for(let y=0;y<XD;y+=1){const v=(u+d)/2;Pr(this.nodeWidthsPx,this.boundaryCols,v,this.viewportWidthPx,this.framedViewportWidthPx)>c?u=v:d=v}const p=Ai((u+d)/2,this.minScroll,this.maxScroll);Math.abs(p-this._scroll)<=jt||(this._scroll=p,this.dispatchEvent(new Ei("layout-scroll",{scroll:this.scroll})))}}const Bl={"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}},l2=["stack-above","stack-below","reorder-before","reorder-after"];function Vl(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 Tn(t,e,n){return t>=n.left&&t<n.left+n.width&&e>=n.top&&e<n.top+n.height}function Yu(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 Zc(t){return t.height===Xe||t.height===pn?{...t,height:pn}:t}function Hc(t){return t.height===pn?{...t,height:Xe}:t}function c2(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"?Hc(d):d}else c[i]={...s,children:a};const u=Math.max(0,Math.min(r,c.length));return c.splice(u,0,Hc(o)),c}const u2=ft(),h2=ft(),d2=50;function p2(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 eo(t){return{id:t.id,type:"drop-target",width:t.width,height:t.height}}function Wp(t){return t.map(g2)}function f2(t){return t.type==="drop-target"?{id:t.id,type:"card",artifactID:t.id,width:t.width,height:t.height}:t}function g2(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(f2)}:t}function hy(t,e){return t.find(r=>r.type==="card"&&r.id===e)??null}function qp(t,e){return t.find(r=>r.type==="stack"&&r.id===e)??null}function m2(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 v2(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=hy(r,e.nodeId);if(!a)return null;const c=Zc(a),u=Zc(o),d=eo(c),p=n.position==="above"?[d,u]:[u,d];return i[s]={id:o.id,type:"stack",children:p},i}function jl(t,e){return t.parentStackId?b2(t,e):y2(t,e)}function y2(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,eo(r)),i}if(n.type==="stack"){const r=m2(t,e);return r?v2(r,t,n,e)??[...e]:[...e]}return[...e]}function b2(t,e){const n=t.hitTarget;switch(n.type){case"stack-child-reorder":return w2(t,e,n.position);case"stack-child-extract":return _2(t,e,n.toIndex);case"stack-child-noop":return S2(t,e);default:return[...e]}}function w2(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=eo(a),d=n==="above"?[u,...c]:[...c,u],p=[...e];return p[r]={...i,children:d},p}function _2(t,e,n){if(!t.parentStackId)return[...e];const r=c2(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]=eo(s),o}function S2(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]=eo(s),o[n]={...r,children:a},o}function k2(t,e){return e.find(r=>r.type==="stack"&&r.id===t.id)?t.id:Cu()}function x2(t,e,n){if(t.type==="drop-target"){const r=Yu(e,n);if(!r)throw new Error(`finalize: missing dragged card ${n}`);return Zc(r)}return t}function E2(t,e,n){const r=t.children.map(s=>x2(s,e,n));return{id:k2(t,e),type:"stack",children:r}}function $2(t,e,n){if(t.type==="drop-target"){const r=Yu(e,n);if(!r)throw new Error(`finalize: missing dragged card ${n}`);return hy(e,n)!==null?r:Hc(r)}return t.type==="card"||t.type==="row"?t:E2(t,e,n)}function A2(t,e,n){return t.map(r=>$2(r,e,n))}function T2(t,e){return JSON.stringify(t)===JSON.stringify(e)}const C2=pi(gt);class I2 extends C2{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)>=Bx&&(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=jl(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&&p2(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=jl(this.active,n),s=A2(i,n,this.active.nodeId);T2(s,n)||(r=s)}catch{r=null}this.reset(),r&&this.dispatchEvent(new h2("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=jl(this.active,this.active.baseLayout);this.dispatchEvent(new u2("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&&Tn(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&&Tn(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=qp(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=qp(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,$,k;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)<=d2;for(const I of o){const B=I.rect;if(!Tn(n,r,B))continue;const P=this.resolveTopLevelTargetForCard(n,r,I,I.logicalIndex,c);if(P)return P;if(!c&&(($=this.active)!=null&&$.hitTarget))return this.active.hitTarget}const u=this.getNearestTargetableZone(n,o);if(!u)return{type:"reorder",index:((k=this.active)==null?void 0:k.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(!Tn(n,r,p.rect))continue;const y=Vl(p.rect,Bl["reorder-before"]);if(Tn(n,r,y))return p.logicalIndex;const v=Vl(p.rect,Bl["reorder-after"]);if(Tn(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 l2){if(!o&&(c==="stack-above"||c==="stack-below"))continue;const u=Bl[c],d=Vl(a,u);if(Tn(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 Yp=60,P2=80,Kp=.5,Jp=10;class R2{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>=Yp&&(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>=Kp&&d>=p*Jp?this.classifyHorizontal(n,u):(this.lastWheelGestureAt=n,{type:"scroll-native"}):this.activeGestureType==="horizontal-filmstrip"?!c&&o&&p>0&&p>=d*Jp?(this.activeGestureType="vertical-artifact",this.lastWheelGestureAt=n,{type:"scroll-native"}):this.classifyHorizontal(n,u):d<Kp?(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)+P2;return this.awaitingFreshWheelGesture&&r<Yp&&!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 D2=2,Xp=1e3,$o=1e-4;function Qp(t,e,n){if(t===0)return 0;const r=e.toPixels(Te({y:Xe})).y??0;return(n-r)/D2}function Gl(t){const e=t.clientWidth>0?t.clientWidth:sr,n=t.clientHeight>0?t.clientHeight:ea;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 O2 extends Event{constructor(n){super("scroll",{bubbles:!0,composed:!0});b(this,"scrollPosition");this.scrollPosition=n}}class dy extends Event{constructor(n){super("layout-change",{bubbles:!0,composed:!0});b(this,"layout");this.layout=n}}class z2 extends HTMLElement{constructor(){super();b(this,"_layout",[]);b(this,"_scrollPosition",0);b(this,"layoutGrid",null);b(this,"layoutScroll",new a2(Te({x:0})));b(this,"scrollModelKey","");b(this,"resizeObserver",null);b(this,"renderPending",!1);b(this,"animateNextRender",!0);b(this,"wheelGesture",new R2);b(this,"dragController",new I2);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",()=>F``);b(this,"onDragControllerChange",()=>{this.dragController.status==="idle"&&(this.dragState=null,this.dragTrackOffsetXPx=0,this.previousProjectedLayoutForOffset=null),this.scheduleRender()});b(this,"onDragControllerDrag",n=>{const r=Wp(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)<$o||(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)||!eC(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=M2(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)/Xp;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>$o?Math.abs(o)/r:0,Math.abs(o)>$o&&(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)<$o||(this.animateNextRender=!1,this.syncScrollModel(),this.layoutScroll.scroll=Te({x:n}))}get scrollPosition(){return this._scrollPosition}connectedCallback(){this.hasAttribute("tabindex")||(this.tabIndex=0),this.focus(),this.addEventListener("keydown",this.handleKeyDown),this.addEventListener("wheel",this.handleWheel,{passive:!1}),this.addEventListener("pointerdown",this.handlePointerDown),window.addEventListener("message",this.handleWindowMessage),typeof ResizeObserver<"u"&&(this.resizeObserver=new ResizeObserver(()=>this.render()),this.resizeObserver.observe(this)),this.render()}disconnectedCallback(){var n;this.removeEventListener("keydown",this.handleKeyDown),this.removeEventListener("wheel",this.handleWheel),this.removeEventListener("pointerdown",this.handlePointerDown),window.removeEventListener("message",this.handleWindowMessage),(n=this.resizeObserver)==null||n.disconnect(),this.resizeObserver=null,this.wheelGesture.reset(),this.detachDragListeners(),this.dragController.removeEventListener("change",this.onDragControllerChange),this.dragController.removeEventListener("drag",this.onDragControllerDrag),this.dragController.removeEventListener("drop",this.onDragControllerDrop),this.layoutScroll.removeEventListener("layout-scroll",this.onLayoutScrollInternal),this.dragController.dispose(),this.stopDragFrameLoop()}scheduleRender(){this.renderPending||(this.renderPending=!0,queueMicrotask(()=>{this.renderPending=!1,this.render()}))}createGrid(n,r){return new KD({basis:ke({x:Rn,y:Rn}),min:ke({x:ip,y:ip}),viewport:ke({x:n,y:r}),gap:ke({x:ge,y:ge})})}syncScrollModel(){const n=Gl(this),i=qi(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 O2(n))}emitLayoutChanged(){this.dispatchEvent(new dy([...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:Wp(this.dragState.projectedLayout),activePlaceholderId:this.dragState.nodeId,placeholdersById:n}}render(){const n=Gl(this),r=this.createGrid(n.width,n.height);this.layoutGrid=r;const i=this.getDisplayModel(),s=i.layout,o=this.dragController.status==="active",a=qi(s),c=a.nodes.map(L=>L.width),u=`${n.width}x${n.height}:${c.join(",")}`;!o&&u!==this.scrollModelKey&&(this.scrollModelKey=u,this.layoutScroll.rebuild({grid:r,nodeWidths:c.map(L=>Te({x:L}))}),this._scrollPosition=this.layoutScroll.scroll.x??this._scrollPosition);const d=L2(s),p=r.unit.x??Rn,y=r.unit.y??Rn,v=o?this.dragTrackOffsetXPx:0,$=(this.layoutScroll.translate.x??0)+v,k=Qp(a.nodes.length,r,n.height),I=this.animateNextRender&&!o,B=[`transform: translate(${$}px, ${k}px);`,`transition-duration: ${I?Hx: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,K={width:(P==null?void 0:P.size.x)??0,height:(P==null?void 0:P.size.y)??0};Re(F`
|
|
162
|
+
<div class="track" style=${B}>
|
|
163
|
+
${a.nodes.map((L,Z)=>F`
|
|
164
|
+
<div
|
|
165
|
+
class="node"
|
|
166
|
+
layout-node=${String(Z)}
|
|
167
|
+
data-layout-node-id=${L.id}
|
|
168
|
+
data-layout-placeholder=${String(i.activePlaceholderId===L.id)}
|
|
169
|
+
layout-node-cols=${String(L.width)}
|
|
170
|
+
style=${`grid-template-columns: repeat(${L.width}, var(--layout-unit-x)); width: ${r.toPixels(Te({x:L.width})).x}px;`}
|
|
171
|
+
>
|
|
172
|
+
${L.cards.map(N=>{const ce=i.placeholdersById.get(N.id);if(P&&ce)return F`
|
|
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?F`
|
|
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 L=this.getPlaceholderPixelSize(a,i.activePlaceholderId,r,K),Z=P.pointer.x??0,N=P.pointer.y??0,ce=P.grabOffset.x??0,ue=P.grabOffset.y??0;return F`
|
|
196
|
+
<div
|
|
197
|
+
class="drag-preview"
|
|
198
|
+
data-layout-preview-card-id=${P.nodeId}
|
|
199
|
+
style=${[`width: ${L.width}px;`,`height: ${L.height}px;`,`left: ${Z-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*Xp,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+bo,o=r.left+r.width-bo,a=((u=this.layoutGrid)==null?void 0:u.unit.x)??Rn,c=Vx*a;if(n<s){const d=Math.max(0,Math.min(1,(s-n)/bo));return-(c*d**sp)*i}if(n>o){const d=Math.max(0,Math.min(1,(n-o)/bo));return c*d**sp*i}return 0}measureLayoutGeometry(n,r,i=0){const s=this.layoutGrid;if(!s)return[];const o=qi(n),a=new Map(o.nodes.map(k=>[k.id,k.width])),c=s.toPixels(Te({y:Xe})).y??ea,u=Gl(this),d=(this.layoutScroll.translate.x??0)+i,p=Qp(o.nodes.length,s,u.height),y=u.offsetY+p,v=[];let $=d;for(const k of n){const I=a.get(k.id)??Ct,B=s.toPixels(Te({x:I})).x??sr,P={left:$,top:y,width:B,height:c};v.push({id:k.id,rect:P}),$+=B+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=Yu(this._layout,n);return r?this.renderContent(r,{isDragging:!0}):F``}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?tf(n,c,this.layoutGrid):nf(n,c,this.layoutGrid),d=s?tf(r,c,this.layoutGrid):nf(r,c,this.layoutGrid);return u===null||d===null?a:a+(u-d)}getStableAnchorCardId(n,r,i){const s=ef(n),o=new Set(ef(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 L2(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 M2(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 ef(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 tf(t,e,n){if(!n)return null;const r=qi(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)??Ct,c=n.toPixels(Te({x:a})).x??sr;s+=c+ge}return null}function nf(t,e,n){if(!n)return null;const r=qi(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)??Ct,c=n.toPixels(Te({x:a})).x??sr;s+=c+ge}return null}customElements.get("layout-view")||customElements.define("layout-view",z2);class N2 extends HTMLElement{constructor(){super(...arguments);b(this,"screenManager",Ge.resolve("ScreenManager"));b(this,"boundModel",null);b(this,"handleActiveScreenChanged",()=>{this.rebindModel(),this.render()});b(this,"handleModelChange",()=>{this.render()});b(this,"handleCloseArtifact",n=>{n instanceof oy&&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 dy&&this.screenManager.activeScreen&&this.screenManager.activeScreen.setLayout(n.layout)})}connectedCallback(){this.screenManager.addEventListener("active-screen-changed",this.handleActiveScreenChanged),this.rebindModel(),this.render()}disconnectedCallback(){this.screenManager.removeEventListener("active-screen-changed",this.handleActiveScreenChanged),this.unbindModel()}rebindModel(){const n=this.screenManager.activeScreen;this.boundModel!==n&&(this.unbindModel(),this.boundModel=n,n&&n.addEventListener("change",this.handleModelChange))}unbindModel(){this.boundModel&&(this.boundModel.removeEventListener("change",this.handleModelChange),this.boundModel=null)}buildArtifactMap(){const n=this.screenManager.activeScreen;return n?new Map(n.artifacts):new Map}render(){const n=this.screenManager.activeScreen,r=(n==null?void 0:n.layout)??[],i=this.buildArtifactMap();if(r.length===0){Re(F`<p data-testid="empty-screen" class="empty">
|
|
205
|
+
No artifacts yet. Create one by asking for something.
|
|
206
|
+
</p>`,this);return}Re(F`
|
|
207
|
+
<layout-view
|
|
208
|
+
.layout=${r}
|
|
209
|
+
.renderContent=${(o,a)=>{const c=i.get(o.artifactID);return!c||!n?F``:F`<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",N2);var ya,Gr,Is,Wt,py,fy,Bc;class U2 extends HTMLElement{constructor(){super(...arguments);_(this,Wt);_(this,ya,Ge.resolve("ScreenManager"));_(this,Gr,Ge.resolve("ServerManager"));_(this,Is,()=>{m(this,Wt,Bc).call(this)})}connectedCallback(){l(this,Gr).addEventListener("change",l(this,Is)),m(this,Wt,Bc).call(this)}disconnectedCallback(){l(this,Gr).removeEventListener("change",l(this,Is))}}ya=new WeakMap,Gr=new WeakMap,Is=new WeakMap,Wt=new WeakSet,py=function(n,r){l(this,ya).setActive(n,r)},fy=function(){for(const n of l(this,Gr).servers.values())return n;return null},Bc=function(){const n=m(this,Wt,fy).call(this),i=(n?[...n.screens.values()]:[]).slice().sort((o,a)=>o.name.localeCompare(a.name,void 0,{sensitivity:"base"})),s=i.length===0?F`<p class="empty">No screens yet. Hit + to create one.</p>`:F`
|
|
222
|
+
<ul class="tiles">
|
|
223
|
+
${i.map(o=>F`
|
|
224
|
+
<li>
|
|
225
|
+
<button
|
|
226
|
+
class="tile"
|
|
227
|
+
type="button"
|
|
228
|
+
material="glass"
|
|
229
|
+
@click=${()=>n&&m(this,Wt,py).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",U2);const Wl=new WeakMap,rf=Object.prototype.hasOwnProperty,F2=(()=>{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 Z2(t,e){if(t===Boolean)return e!==null;if(e!==null)return t===Number?Number(e):e}var Ps,Vc,Qn,tt,At,Wr,er,qr,Ie,Hi,gy,my,vy,jo;const zn=class zn extends HTMLElement{constructor(){var i;super();_(this,Ie);_(this,Qn,new Map);_(this,tt,new Map);_(this,At,new Map);_(this,Wr,!1);_(this,er,!1);_(this,qr,!1);const n=m(i=zn,Ps,Vc).call(i,this.constructor),r=this;for(const s of n.properties)rf.call(r,s)&&(l(this,At).set(s,r[s]),delete r[s])}static get observedAttributes(){var n;return m(n=zn,Ps,Vc).call(n,this).observedAttributes}connected(){}disconnected(){}changed(n){}connectedCallback(){if(m(this,Ie,vy).call(this),!l(this,er))for(const n of m(this,Ie,Hi).call(this).properties)l(this,tt).has(n)||l(this,tt).set(n,void 0);this.dispatchEvent(new Event("reactive:connect")),this.connected(),m(this,Ie,jo).call(this)}disconnectedCallback(){this.dispatchEvent(new Event("reactive:disconnect")),this.disconnected()}attributeChangedCallback(n,r,i){if(r===i)return;const s=m(this,Ie,Hi).call(this).byAttr.get(n);s&&(l(this,At).has(s.property)||(this[s.property]=Z2(s.type,i)))}};Ps=new WeakSet,Vc=function(n){const r=Wl.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(F2.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,Qn).get(u)},set(p){m(this,Ie,gy).call(this,u,p)}})}const c={properties:i,observedAttributes:Object.keys(s),byAttr:o,byProp:a};return Wl.set(n,c),c},Qn=new WeakMap,tt=new WeakMap,At=new WeakMap,Wr=new WeakMap,er=new WeakMap,qr=new WeakMap,Ie=new WeakSet,Hi=function(){return Wl.get(this.constructor)},gy=function(n,r){if(!l(this,qr)&&l(this,At).has(n))return;const i=l(this,Qn).get(n);Object.is(i,r)||(l(this,tt).has(n)||l(this,tt).set(n,i),l(this,Qn).set(n,r),l(this,At).delete(n),m(this,Ie,my).call(this,n,r),this.isConnected&&m(this,Ie,jo).call(this))},my=function(n,r){const i=m(this,Ie,Hi).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)},vy=function(){const n=this,r=m(this,Ie,Hi).call(this);for(const i of r.properties){if(!rf.call(n,i))continue;const s=n[i];delete n[i],!(l(this,At).has(i)||l(this,Qn).has(i))&&(n[i]=s)}x(this,qr,!0);try{for(const[i,s]of l(this,At))n[i]=s;l(this,At).clear()}finally{x(this,qr,!1)}},jo=function(){l(this,Wr)||!this.isConnected||l(this,er)&&l(this,tt).size===0||(x(this,Wr,!0),queueMicrotask(()=>{if(x(this,Wr,!1),!this.isConnected||l(this,er)&&l(this,tt).size===0)return;const n=new Map(l(this,tt));l(this,tt).clear(),x(this,er,!0);try{this.changed(n)}catch(r){console.error(r)}this.isConnected&&l(this,tt).size>0&&m(this,Ie,jo).call(this)}))},_(zn,Ps),b(zn,"properties"),b(zn,"attributes");let ns=zn;/**
|
|
237
|
+
* @license
|
|
238
|
+
* Copyright 2020 Google LLC
|
|
239
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
240
|
+
*/const H2=t=>t.strings===void 0;/**
|
|
241
|
+
* @license
|
|
242
|
+
* Copyright 2017 Google LLC
|
|
243
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
244
|
+
*/const Ki=(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),Ki(i,e);return!0},la=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)},yy=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),j2(e)}};function B2(t){this._$AN!==void 0?(la(this),this._$AM=t,yy(this)):this._$AM=t}function V2(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++)Ki(r[s],!1),la(r[s]);else r!=null&&(Ki(r,!1),la(r));else Ki(this,t)}const j2=t=>{t.type==zv.CHILD&&(t._$AP??(t._$AP=V2),t._$AQ??(t._$AQ=B2))};class G2 extends Lv{constructor(){super(...arguments),this._$AN=void 0}_$AT(e,n,r){super._$AT(e,n,r),yy(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&&(Ki(this,e),la(this))}setValue(e){if(H2(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 Ao=()=>new W2;class W2{}const ql=new WeakMap,To=Wu(class extends G2{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=ql.get(e);n===void 0&&(n=new WeakMap,ql.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=ql.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,un,Yr,Kr,Rs,tr,nr,ie,Pe,by,Ds,Os,jc,Gc,ba,wa,_a,Sa,ka,xa,Ea,zs,Ls,Bi,wy,ht;class q2 extends ns{constructor(){super(...arguments);_(this,Pe);_(this,Je,Ge.resolve("ScreenManager"));_(this,un,null);_(this,Yr,new DisposableStack);_(this,Kr,Ao());_(this,Rs,Ao());_(this,tr,Ao());_(this,nr,Ao());_(this,ie,{kind:"none"});_(this,Ds,()=>{m(this,Pe,jc).call(this),l(this,ht).call(this)});_(this,Os,()=>{l(this,ht).call(this)});_(this,ba,()=>{l(this,Je).clearActive()});_(this,wa,n=>{l(this,ie).kind!=="none"&&(n.stopImmediatePropagation(),m(this,Pe,Bi).call(this))});_(this,_a,()=>{var r;const n=l(this,Je).activeScreen;n&&((r=l(this,Kr).value)==null||r.close(),x(this,ie,{kind:"rename",draft:n.name}),l(this,ht).call(this))});_(this,Sa,()=>{var n;l(this,Je).activeScreen&&((n=l(this,Kr).value)==null||n.close(),x(this,ie,{kind:"delete",error:null}),l(this,ht).call(this))});_(this,ka,n=>{if(l(this,ie).kind!=="rename")return;const r=n.target;r instanceof HTMLInputElement&&x(this,ie,{kind:"rename",draft:r.value})});_(this,xa,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),m(this,Pe,Bi).call(this)});_(this,Ea,async()=>{if(l(this,ie).kind!=="delete")return;const n=l(this,Je).activeScreen;if(n){x(this,ie,{kind:"delete",error:null});try{await n.remove(),l(this,Je).clearActive(),m(this,Pe,Bi).call(this)}catch(r){x(this,ie,{kind:"delete",error:r instanceof Error?r.message:"Failed to delete screen."}),l(this,ht).call(this)}}});_(this,zs,()=>{m(this,Pe,Bi).call(this)});_(this,Ls,()=>{l(this,ie).kind!=="none"&&(x(this,ie,{kind:"none"}),l(this,ht).call(this))});_(this,ht,()=>{const n=F`
|
|
249
|
+
<button
|
|
250
|
+
icon-only
|
|
251
|
+
variant="ghost"
|
|
252
|
+
class="home"
|
|
253
|
+
type="button"
|
|
254
|
+
aria-label="Home"
|
|
255
|
+
@click=${l(this,ba)}
|
|
256
|
+
>
|
|
257
|
+
${TD({weight:"fill"})}
|
|
258
|
+
</button>
|
|
259
|
+
`;Re(F`${n}${m(this,Pe,wy).call(this)}`,this);const r=l(this,Rs).value??null;l(this,tr).value&&(l(this,tr).value.anchor=r),l(this,nr).value&&(l(this,nr).value.anchor=r)})}connected(){l(this,Je).addEventListener("active-screen-changed",l(this,Ds)),m(this,Pe,jc).call(this),l(this,ht).call(this),m(this,Pe,by).call(this),l(this,Yr).defer(()=>{l(this,Je).removeEventListener("active-screen-changed",l(this,Ds)),m(this,Pe,Gc).call(this)})}disconnected(){l(this,Yr).dispose(),x(this,Yr,new DisposableStack)}}Je=new WeakMap,un=new WeakMap,Yr=new WeakMap,Kr=new WeakMap,Rs=new WeakMap,tr=new WeakMap,nr=new WeakMap,ie=new WeakMap,Pe=new WeakSet,by=async function(){const n=await ju(this);this.setAttribute("tone",n)},Ds=new WeakMap,Os=new WeakMap,jc=function(){var r;const n=l(this,Je).activeScreen;l(this,un)!==n&&(m(this,Pe,Gc).call(this),x(this,un,n),(r=l(this,un))==null||r.addEventListener("change",l(this,Os)))},Gc=function(){var n;(n=l(this,un))==null||n.removeEventListener("change",l(this,Os)),x(this,un,null)},ba=new WeakMap,wa=new WeakMap,_a=new WeakMap,Sa=new WeakMap,ka=new WeakMap,xa=new WeakMap,Ea=new WeakMap,zs=new WeakMap,Ls=new WeakMap,Bi=function(){const n=l(this,ie).kind==="rename"?l(this,tr).value:l(this,ie).kind==="delete"?l(this,nr).value:null;n&&(n.open=!1),x(this,ie,{kind:"none"}),l(this,ht).call(this)},wy=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 F`
|
|
260
|
+
<span class="separator" aria-hidden="true">
|
|
261
|
+
${ED()}
|
|
262
|
+
</span>
|
|
263
|
+
<dropdown-menu ${To(l(this,Kr))}>
|
|
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,wa)}
|
|
271
|
+
${To(l(this,Rs))}
|
|
272
|
+
>
|
|
273
|
+
${n.name}
|
|
274
|
+
</button>
|
|
275
|
+
<dropdown-group>
|
|
276
|
+
<dropdown-item action @click=${l(this,_a)}>
|
|
277
|
+
${CD()} Rename
|
|
278
|
+
</dropdown-item>
|
|
279
|
+
<dropdown-item action danger @click=${l(this,Sa)}>
|
|
280
|
+
${ID()} 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,Ls)}
|
|
288
|
+
${To(l(this,tr))}
|
|
289
|
+
>
|
|
290
|
+
<form class="screen-form" @submit=${l(this,xa)}>
|
|
291
|
+
<label class="field">
|
|
292
|
+
<span>Screen name</span>
|
|
293
|
+
<input
|
|
294
|
+
type="text"
|
|
295
|
+
.value=${r}
|
|
296
|
+
@input=${l(this,ka)}
|
|
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,Ls)}
|
|
309
|
+
${To(l(this,nr))}
|
|
310
|
+
>
|
|
311
|
+
<div class="screen-form">
|
|
312
|
+
<p class="confirm-text">Delete "${n.name}"?</p>
|
|
313
|
+
${i?F`<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,Ea)}
|
|
320
|
+
>
|
|
321
|
+
Delete
|
|
322
|
+
</button>
|
|
323
|
+
</div>
|
|
324
|
+
</div>
|
|
325
|
+
</ui-popover>
|
|
326
|
+
`},ht=new WeakMap;customElements.define("screen-breadcrumb",q2);var $a,Aa,Jr,yn,_y,Sy,Ta,ky;class Y2 extends HTMLElement{constructor(){super(...arguments);_(this,yn);_(this,$a,Ge.resolve("ServerManager"));_(this,Aa,Ge.resolve("ScreenManager"));_(this,Jr,!1);_(this,Ta,async()=>{if(l(this,Jr))return;const n=m(this,yn,Sy).call(this);if(n){x(this,Jr,!0);try{const r=await n.createScreen(K2(new Date));l(this,Aa).setActive(n.url,r.id)}catch{}finally{x(this,Jr,!1)}}})}connectedCallback(){m(this,yn,ky).call(this),m(this,yn,_y).call(this)}}$a=new WeakMap,Aa=new WeakMap,Jr=new WeakMap,yn=new WeakSet,_y=async function(){const n=await ju(this);this.setAttribute("tone",n)},Sy=function(){for(const n of l(this,$a).servers.values())return n;return null},Ta=new WeakMap,ky=function(){Re(F`
|
|
327
|
+
<button
|
|
328
|
+
icon-only
|
|
329
|
+
variant="ghost"
|
|
330
|
+
class="new-screen"
|
|
331
|
+
type="button"
|
|
332
|
+
aria-label="New screen"
|
|
333
|
+
@click=${l(this,Ta)}
|
|
334
|
+
>
|
|
335
|
+
${AD({size:16,weight:"bold"})}
|
|
336
|
+
</button>
|
|
337
|
+
`,this)};function K2(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",Y2);function J2(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:xy,setPrototypeOf:sf,isFrozen:X2,getPrototypeOf:Q2,getOwnPropertyDescriptor:eO}=Object;let{freeze:Ne,seal:it,create:Go}=Object,{apply:Wc,construct:qc}=typeof Reflect<"u"&&Reflect;Ne||(Ne=function(e){return e});it||(it=function(e){return e});Wc||(Wc=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)});qc||(qc=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 Co=Ue(Array.prototype.forEach),tO=Ue(Array.prototype.lastIndexOf),of=Ue(Array.prototype.pop),Ti=Ue(Array.prototype.push),nO=Ue(Array.prototype.splice),Wo=Ue(String.prototype.toLowerCase),Yl=Ue(String.prototype.toString),Kl=Ue(String.prototype.match),Ci=Ue(String.prototype.replace),rO=Ue(String.prototype.indexOf),iO=Ue(String.prototype.trim),Ye=Ue(Object.prototype.hasOwnProperty),Oe=Ue(RegExp.prototype.test),Ii=sO(TypeError);function Ue(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 Wc(t,e,r)}}function sO(t){return function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return qc(t,n)}}function V(t,e){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Wo;sf&&sf(t,null);let r=e.length;for(;r--;){let i=e[r];if(typeof i=="string"){const s=n(i);s!==i&&(X2(e)||(e[r]=s),i=s)}t[i]=!0}return t}function oO(t){for(let e=0;e<t.length;e++)Ye(t,e)||(t[e]=null);return t}function _t(t){const e=Go(null);for(const[n,r]of xy(t))Ye(t,n)&&(Array.isArray(r)?e[n]=oO(r):r&&typeof r=="object"&&r.constructor===Object?e[n]=_t(r):e[n]=r);return e}function Pi(t,e){for(;t!==null;){const r=eO(t,e);if(r){if(r.get)return Ue(r.get);if(typeof r.value=="function")return Ue(r.value)}t=Q2(t)}function n(){return null}return n}const af=Ne(["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"]),Jl=Ne(["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"]),Xl=Ne(["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"]),aO=Ne(["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"]),Ql=Ne(["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"]),lO=Ne(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),lf=Ne(["#text"]),cf=Ne(["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"]),ec=Ne(["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"]),uf=Ne(["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"]),Io=Ne(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),cO=it(/\{\{[\w\W]*|[\w\W]*\}\}/gm),uO=it(/<%[\w\W]*|[\w\W]*%>/gm),hO=it(/\$\{[\w\W]*/gm),dO=it(/^data-[\-\w.\u00B7-\uFFFF]+$/),pO=it(/^aria-[\-\w]+$/),Ey=it(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),fO=it(/^(?:\w+script|data):/i),gO=it(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),$y=it(/^html$/i),mO=it(/^[a-z][.\w]*(-[.\w]+)+$/i);var hf=Object.freeze({__proto__:null,ARIA_ATTR:pO,ATTR_WHITESPACE:gO,CUSTOM_ELEMENT:mO,DATA_ATTR:dO,DOCTYPE_NAME:$y,ERB_EXPR:uO,IS_ALLOWED_URI:Ey,IS_SCRIPT_OR_DATA:fO,MUSTACHE_EXPR:cO,TMPLIT_EXPR:hO});const Ri={element:1,text:3,progressingInstruction:7,comment:8,document:9},vO=function(){return typeof window>"u"?null:window},yO=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}},df=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Ay(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:vO();const e=M=>Ay(M);if(e.version="3.3.3",e.removed=[],!t||!t.document||t.document.nodeType!==Ri.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,$=c.prototype,k=Pi($,"cloneNode"),I=Pi($,"remove"),B=Pi($,"nextSibling"),P=Pi($,"childNodes"),K=Pi($,"parentNode");if(typeof o=="function"){const M=n.createElement("template");M.content&&M.content.ownerDocument&&(n=M.content.ownerDocument)}let L,Z="";const{implementation:N,createNodeIterator:ce,createDocumentFragment:ue,getElementsByTagName:yi}=n,{importNode:no}=r;let Ee=df();e.isSupported=typeof xy=="function"&&typeof K=="function"&&N&&N.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:xn,ERB_EXPR:mt,TMPLIT_EXPR:Xt,DATA_ATTR:Ka,ARIA_ATTR:ro,IS_SCRIPT_OR_DATA:Vy,ATTR_WHITESPACE:ah,CUSTOM_ELEMENT:jy}=hf;let{IS_ALLOWED_URI:lh}=hf,_e=null;const ch=V({},[...af,...Jl,...Xl,...Ql,...lf]);let $e=null;const uh=V({},[...cf,...ec,...uf,...Io]);let me=Object.seal(Go(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}})),bi=null,io=null;const Qt=Object.seal(Go(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let hh=!0,Ja=!0,dh=!1,ph=!0,gr=!1,so=!0,En=!1,Xa=!1,Qa=!1,mr=!1,oo=!1,ao=!1,fh=!0,gh=!1;const Gy="user-content-";let el=!0,wi=!1,vr={},vt=null;const tl=V({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let mh=null;const vh=V({},["audio","video","img","source","image","track"]);let nl=null;const yh=V({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),lo="http://www.w3.org/1998/Math/MathML",co="http://www.w3.org/2000/svg",It="http://www.w3.org/1999/xhtml";let yr=It,rl=!1,il=null;const Wy=V({},[lo,co,It],Yl);let uo=V({},["mi","mo","mn","ms","mtext"]),ho=V({},["annotation-xml"]);const qy=V({},["title","style","font","a","script"]);let _i=null;const Yy=["application/xhtml+xml","text/html"],Ky="text/html";let be=null,br=null;const Jy=n.createElement("form"),bh=function(g){return g instanceof RegExp||g instanceof Function},sl=function(){let g=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(br&&br===g)){if((!g||typeof g!="object")&&(g={}),g=_t(g),_i=Yy.indexOf(g.PARSER_MEDIA_TYPE)===-1?Ky:g.PARSER_MEDIA_TYPE,be=_i==="application/xhtml+xml"?Yl:Wo,_e=Ye(g,"ALLOWED_TAGS")?V({},g.ALLOWED_TAGS,be):ch,$e=Ye(g,"ALLOWED_ATTR")?V({},g.ALLOWED_ATTR,be):uh,il=Ye(g,"ALLOWED_NAMESPACES")?V({},g.ALLOWED_NAMESPACES,Yl):Wy,nl=Ye(g,"ADD_URI_SAFE_ATTR")?V(_t(yh),g.ADD_URI_SAFE_ATTR,be):yh,mh=Ye(g,"ADD_DATA_URI_TAGS")?V(_t(vh),g.ADD_DATA_URI_TAGS,be):vh,vt=Ye(g,"FORBID_CONTENTS")?V({},g.FORBID_CONTENTS,be):tl,bi=Ye(g,"FORBID_TAGS")?V({},g.FORBID_TAGS,be):_t({}),io=Ye(g,"FORBID_ATTR")?V({},g.FORBID_ATTR,be):_t({}),vr=Ye(g,"USE_PROFILES")?g.USE_PROFILES:!1,hh=g.ALLOW_ARIA_ATTR!==!1,Ja=g.ALLOW_DATA_ATTR!==!1,dh=g.ALLOW_UNKNOWN_PROTOCOLS||!1,ph=g.ALLOW_SELF_CLOSE_IN_ATTR!==!1,gr=g.SAFE_FOR_TEMPLATES||!1,so=g.SAFE_FOR_XML!==!1,En=g.WHOLE_DOCUMENT||!1,mr=g.RETURN_DOM||!1,oo=g.RETURN_DOM_FRAGMENT||!1,ao=g.RETURN_TRUSTED_TYPE||!1,Qa=g.FORCE_BODY||!1,fh=g.SANITIZE_DOM!==!1,gh=g.SANITIZE_NAMED_PROPS||!1,el=g.KEEP_CONTENT!==!1,wi=g.IN_PLACE||!1,lh=g.ALLOWED_URI_REGEXP||Ey,yr=g.NAMESPACE||It,uo=g.MATHML_TEXT_INTEGRATION_POINTS||uo,ho=g.HTML_INTEGRATION_POINTS||ho,me=g.CUSTOM_ELEMENT_HANDLING||{},g.CUSTOM_ELEMENT_HANDLING&&bh(g.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(me.tagNameCheck=g.CUSTOM_ELEMENT_HANDLING.tagNameCheck),g.CUSTOM_ELEMENT_HANDLING&&bh(g.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(me.attributeNameCheck=g.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),g.CUSTOM_ELEMENT_HANDLING&&typeof g.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(me.allowCustomizedBuiltInElements=g.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),gr&&(Ja=!1),oo&&(mr=!0),vr&&(_e=V({},lf),$e=Go(null),vr.html===!0&&(V(_e,af),V($e,cf)),vr.svg===!0&&(V(_e,Jl),V($e,ec),V($e,Io)),vr.svgFilters===!0&&(V(_e,Xl),V($e,ec),V($e,Io)),vr.mathMl===!0&&(V(_e,Ql),V($e,uf),V($e,Io))),Ye(g,"ADD_TAGS")||(Qt.tagCheck=null),Ye(g,"ADD_ATTR")||(Qt.attributeCheck=null),g.ADD_TAGS&&(typeof g.ADD_TAGS=="function"?Qt.tagCheck=g.ADD_TAGS:(_e===ch&&(_e=_t(_e)),V(_e,g.ADD_TAGS,be))),g.ADD_ATTR&&(typeof g.ADD_ATTR=="function"?Qt.attributeCheck=g.ADD_ATTR:($e===uh&&($e=_t($e)),V($e,g.ADD_ATTR,be))),g.ADD_URI_SAFE_ATTR&&V(nl,g.ADD_URI_SAFE_ATTR,be),g.FORBID_CONTENTS&&(vt===tl&&(vt=_t(vt)),V(vt,g.FORBID_CONTENTS,be)),g.ADD_FORBID_CONTENTS&&(vt===tl&&(vt=_t(vt)),V(vt,g.ADD_FORBID_CONTENTS,be)),el&&(_e["#text"]=!0),En&&V(_e,["html","head","body"]),_e.table&&(V(_e,["tbody"]),delete bi.tbody),g.TRUSTED_TYPES_POLICY){if(typeof g.TRUSTED_TYPES_POLICY.createHTML!="function")throw Ii('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof g.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Ii('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');L=g.TRUSTED_TYPES_POLICY,Z=L.createHTML("")}else L===void 0&&(L=yO(v,i)),L!==null&&typeof Z=="string"&&(Z=L.createHTML(""));Ne&&Ne(g),br=g}},wh=V({},[...Jl,...Xl,...aO]),_h=V({},[...Ql,...lO]),Xy=function(g){let T=K(g);(!T||!T.tagName)&&(T={namespaceURI:yr,tagName:"template"});const R=Wo(g.tagName),se=Wo(T.tagName);return il[g.namespaceURI]?g.namespaceURI===co?T.namespaceURI===It?R==="svg":T.namespaceURI===lo?R==="svg"&&(se==="annotation-xml"||uo[se]):!!wh[R]:g.namespaceURI===lo?T.namespaceURI===It?R==="math":T.namespaceURI===co?R==="math"&&ho[se]:!!_h[R]:g.namespaceURI===It?T.namespaceURI===co&&!ho[se]||T.namespaceURI===lo&&!uo[se]?!1:!_h[R]&&(qy[R]||!wh[R]):!!(_i==="application/xhtml+xml"&&il[g.namespaceURI]):!1},yt=function(g){Ti(e.removed,{element:g});try{K(g).removeChild(g)}catch{I(g)}},$n=function(g,T){try{Ti(e.removed,{attribute:T.getAttributeNode(g),from:T})}catch{Ti(e.removed,{attribute:null,from:T})}if(T.removeAttribute(g),g==="is")if(mr||oo)try{yt(T)}catch{}else try{T.setAttribute(g,"")}catch{}},Sh=function(g){let T=null,R=null;if(Qa)g="<remove></remove>"+g;else{const ve=Kl(g,/^[\r\n\t ]+/);R=ve&&ve[0]}_i==="application/xhtml+xml"&&yr===It&&(g='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+g+"</body></html>");const se=L?L.createHTML(g):g;if(yr===It)try{T=new y().parseFromString(se,_i)}catch{}if(!T||!T.documentElement){T=N.createDocument(yr,"template",null);try{T.documentElement.innerHTML=rl?Z:se}catch{}}const De=T.body||T.documentElement;return g&&R&&De.insertBefore(n.createTextNode(R),De.childNodes[0]||null),yr===It?yi.call(T,En?"html":"body")[0]:En?T.documentElement:De},kh=function(g){return ce.call(g.ownerDocument||g,g,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},ol=function(g){return g instanceof p&&(typeof g.nodeName!="string"||typeof g.textContent!="string"||typeof g.removeChild!="function"||!(g.attributes instanceof d)||typeof g.removeAttribute!="function"||typeof g.setAttribute!="function"||typeof g.namespaceURI!="string"||typeof g.insertBefore!="function"||typeof g.hasChildNodes!="function")},xh=function(g){return typeof a=="function"&&g instanceof a};function Pt(M,g,T){Co(M,R=>{R.call(e,g,T,br)})}const Eh=function(g){let T=null;if(Pt(Ee.beforeSanitizeElements,g,null),ol(g))return yt(g),!0;const R=be(g.nodeName);if(Pt(Ee.uponSanitizeElement,g,{tagName:R,allowedTags:_e}),so&&g.hasChildNodes()&&!xh(g.firstElementChild)&&Oe(/<[/\w!]/g,g.innerHTML)&&Oe(/<[/\w!]/g,g.textContent)||g.nodeType===Ri.progressingInstruction||so&&g.nodeType===Ri.comment&&Oe(/<[/\w]/g,g.data))return yt(g),!0;if(!(Qt.tagCheck instanceof Function&&Qt.tagCheck(R))&&(!_e[R]||bi[R])){if(!bi[R]&&Ah(R)&&(me.tagNameCheck instanceof RegExp&&Oe(me.tagNameCheck,R)||me.tagNameCheck instanceof Function&&me.tagNameCheck(R)))return!1;if(el&&!vt[R]){const se=K(g)||g.parentNode,De=P(g)||g.childNodes;if(De&&se){const ve=De.length;for(let Fe=ve-1;Fe>=0;--Fe){const Rt=k(De[Fe],!0);Rt.__removalCount=(g.__removalCount||0)+1,se.insertBefore(Rt,B(g))}}}return yt(g),!0}return g instanceof c&&!Xy(g)||(R==="noscript"||R==="noembed"||R==="noframes")&&Oe(/<\/no(script|embed|frames)/i,g.innerHTML)?(yt(g),!0):(gr&&g.nodeType===Ri.text&&(T=g.textContent,Co([xn,mt,Xt],se=>{T=Ci(T,se," ")}),g.textContent!==T&&(Ti(e.removed,{element:g.cloneNode()}),g.textContent=T)),Pt(Ee.afterSanitizeElements,g,null),!1)},$h=function(g,T,R){if(io[T]||fh&&(T==="id"||T==="name")&&(R in n||R in Jy))return!1;if(!(Ja&&!io[T]&&Oe(Ka,T))){if(!(hh&&Oe(ro,T))){if(!(Qt.attributeCheck instanceof Function&&Qt.attributeCheck(T,g))){if(!$e[T]||io[T]){if(!(Ah(g)&&(me.tagNameCheck instanceof RegExp&&Oe(me.tagNameCheck,g)||me.tagNameCheck instanceof Function&&me.tagNameCheck(g))&&(me.attributeNameCheck instanceof RegExp&&Oe(me.attributeNameCheck,T)||me.attributeNameCheck instanceof Function&&me.attributeNameCheck(T,g))||T==="is"&&me.allowCustomizedBuiltInElements&&(me.tagNameCheck instanceof RegExp&&Oe(me.tagNameCheck,R)||me.tagNameCheck instanceof Function&&me.tagNameCheck(R))))return!1}else if(!nl[T]){if(!Oe(lh,Ci(R,ah,""))){if(!((T==="src"||T==="xlink:href"||T==="href")&&g!=="script"&&rO(R,"data:")===0&&mh[g])){if(!(dh&&!Oe(Vy,Ci(R,ah,"")))){if(R)return!1}}}}}}}return!0},Ah=function(g){return g!=="annotation-xml"&&Kl(g,jy)},Th=function(g){Pt(Ee.beforeSanitizeAttributes,g,null);const{attributes:T}=g;if(!T||ol(g))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:Fe,value:Rt}=De,wr=be(ve),al=Rt;let Ae=ve==="value"?al:iO(al);if(R.attrName=wr,R.attrValue=Ae,R.keepAttr=!0,R.forceKeepAttr=void 0,Pt(Ee.uponSanitizeAttribute,g,R),Ae=R.attrValue,gh&&(wr==="id"||wr==="name")&&($n(ve,g),Ae=Gy+Ae),so&&Oe(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,Ae)){$n(ve,g);continue}if(wr==="attributename"&&Kl(Ae,"href")){$n(ve,g);continue}if(R.forceKeepAttr)continue;if(!R.keepAttr){$n(ve,g);continue}if(!ph&&Oe(/\/>/i,Ae)){$n(ve,g);continue}gr&&Co([xn,mt,Xt],Ih=>{Ae=Ci(Ae,Ih," ")});const Ch=be(g.nodeName);if(!$h(Ch,wr,Ae)){$n(ve,g);continue}if(L&&typeof v=="object"&&typeof v.getAttributeType=="function"&&!Fe)switch(v.getAttributeType(Ch,wr)){case"TrustedHTML":{Ae=L.createHTML(Ae);break}case"TrustedScriptURL":{Ae=L.createScriptURL(Ae);break}}if(Ae!==al)try{Fe?g.setAttributeNS(Fe,ve,Ae):g.setAttribute(ve,Ae),ol(g)?yt(g):of(e.removed)}catch{$n(ve,g)}}Pt(Ee.afterSanitizeAttributes,g,null)},Qy=function M(g){let T=null;const R=kh(g);for(Pt(Ee.beforeSanitizeShadowDOM,g,null);T=R.nextNode();)Pt(Ee.uponSanitizeShadowNode,T,null),Eh(T),Th(T),T.content instanceof s&&M(T.content);Pt(Ee.afterSanitizeShadowDOM,g,null)};return e.sanitize=function(M){let g=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},T=null,R=null,se=null,De=null;if(rl=!M,rl&&(M="<!-->"),typeof M!="string"&&!xh(M))if(typeof M.toString=="function"){if(M=M.toString(),typeof M!="string")throw Ii("dirty is not a string, aborting")}else throw Ii("toString is not a function");if(!e.isSupported)return M;if(Xa||sl(g),e.removed=[],typeof M=="string"&&(wi=!1),wi){if(M.nodeName){const Rt=be(M.nodeName);if(!_e[Rt]||bi[Rt])throw Ii("root node is forbidden and cannot be sanitized in-place")}}else if(M instanceof a)T=Sh("<!---->"),R=T.ownerDocument.importNode(M,!0),R.nodeType===Ri.element&&R.nodeName==="BODY"||R.nodeName==="HTML"?T=R:T.appendChild(R);else{if(!mr&&!gr&&!En&&M.indexOf("<")===-1)return L&&ao?L.createHTML(M):M;if(T=Sh(M),!T)return mr?null:ao?Z:""}T&&Qa&&yt(T.firstChild);const ve=kh(wi?M:T);for(;se=ve.nextNode();)Eh(se),Th(se),se.content instanceof s&&Qy(se.content);if(wi)return M;if(mr){if(oo)for(De=ue.call(T.ownerDocument);T.firstChild;)De.appendChild(T.firstChild);else De=T;return($e.shadowroot||$e.shadowrootmode)&&(De=no.call(r,De,!0)),De}let Fe=En?T.outerHTML:T.innerHTML;return En&&_e["!doctype"]&&T.ownerDocument&&T.ownerDocument.doctype&&T.ownerDocument.doctype.name&&Oe($y,T.ownerDocument.doctype.name)&&(Fe="<!DOCTYPE "+T.ownerDocument.doctype.name+`>
|
|
338
|
+
`+Fe),gr&&Co([xn,mt,Xt],Rt=>{Fe=Ci(Fe,Rt," ")}),L&&ao?L.createHTML(Fe):Fe},e.setConfig=function(){let M=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};sl(M),Xa=!0},e.clearConfig=function(){br=null,Xa=!1},e.isValidAttribute=function(M,g,T){br||sl({});const R=be(M),se=be(g);return $h(R,se,T)},e.addHook=function(M,g){typeof g=="function"&&Ti(Ee[M],g)},e.removeHook=function(M,g){if(g!==void 0){const T=tO(Ee[M],g);return T===-1?void 0:nO(Ee[M],T,1)[0]}return of(Ee[M])},e.removeHooks=function(M){Ee[M]=[]},e.removeAllHooks=function(){Ee=df()},e}var Ty=Ay();function Ku(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var fr=Ku();function Cy(t){fr=t}var On={exec:()=>null};function W(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(Me.caret,"$1"),n=n.replace(i,o),r},getRegex:()=>new RegExp(n,e)};return r}var bO=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),Me={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)}}>`)},wO=/^(?:[ \t]*(?:\n|$))+/,_O=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,SO=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,to=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,kO=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Ju=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Iy=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Py=W(Iy).replace(/bull/g,Ju).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(),xO=W(Iy).replace(/bull/g,Ju).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(),Xu=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,EO=/^[^\n]+/,Qu=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,$O=W(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Qu).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),AO=W(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Ju).getRegex(),Wa="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",eh=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,TO=W("^ {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",eh).replace("tag",Wa).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Ry=W(Xu).replace("hr",to).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",Wa).getRegex(),CO=W(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Ry).getRegex(),th={blockquote:CO,code:_O,def:$O,fences:SO,heading:kO,hr:to,html:TO,lheading:Py,list:AO,newline:wO,paragraph:Ry,table:On,text:EO},pf=W("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",to).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",Wa).getRegex(),IO={...th,lheading:xO,table:pf,paragraph:W(Xu).replace("hr",to).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",pf).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",Wa).getRegex()},PO={...th,html:W(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",eh).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:On,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:W(Xu).replace("hr",to).replace("heading",` *#{1,6} *[^
|
|
339
|
+
]`).replace("lheading",Py).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},RO=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,DO=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Dy=/^( {2,}|\\)\n(?!\s*$)/,OO=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,vi=/[\p{P}\p{S}]/u,qa=/[\s\p{P}\p{S}]/u,nh=/[^\s\p{P}\p{S}]/u,zO=W(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,qa).getRegex(),Oy=/(?!~)[\p{P}\p{S}]/u,LO=/(?!~)[\s\p{P}\p{S}]/u,MO=/(?:[^\s\p{P}\p{S}]|~)/u,NO=W(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",bO?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),zy=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,UO=W(zy,"u").replace(/punct/g,vi).getRegex(),FO=W(zy,"u").replace(/punct/g,Oy).getRegex(),Ly="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",ZO=W(Ly,"gu").replace(/notPunctSpace/g,nh).replace(/punctSpace/g,qa).replace(/punct/g,vi).getRegex(),HO=W(Ly,"gu").replace(/notPunctSpace/g,MO).replace(/punctSpace/g,LO).replace(/punct/g,Oy).getRegex(),BO=W("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,nh).replace(/punctSpace/g,qa).replace(/punct/g,vi).getRegex(),VO=W(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,vi).getRegex(),jO="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",GO=W(jO,"gu").replace(/notPunctSpace/g,nh).replace(/punctSpace/g,qa).replace(/punct/g,vi).getRegex(),WO=W(/\\(punct)/,"gu").replace(/punct/g,vi).getRegex(),qO=W(/^<(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(),YO=W(eh).replace("(?:-->|$)","-->").getRegex(),KO=W("^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",YO).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),ca=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,JO=W(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",ca).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),My=W(/^!?\[(label)\]\[(ref)\]/).replace("label",ca).replace("ref",Qu).getRegex(),Ny=W(/^!?\[(ref)\](?:\[\])?/).replace("ref",Qu).getRegex(),XO=W("reflink|nolink(?!\\()","g").replace("reflink",My).replace("nolink",Ny).getRegex(),ff=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,rh={_backpedal:On,anyPunctuation:WO,autolink:qO,blockSkip:NO,br:Dy,code:DO,del:On,delLDelim:On,delRDelim:On,emStrongLDelim:UO,emStrongRDelimAst:ZO,emStrongRDelimUnd:BO,escape:RO,link:JO,nolink:Ny,punctuation:zO,reflink:My,reflinkSearch:XO,tag:KO,text:OO,url:On},QO={...rh,link:W(/^!?\[(label)\]\((.*?)\)/).replace("label",ca).getRegex(),reflink:W(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",ca).getRegex()},Yc={...rh,emStrongRDelimAst:HO,emStrongLDelim:FO,delLDelim:VO,delRDelim:GO,url:W(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",ff).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:W(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",ff).getRegex()},ez={...Yc,br:W(Dy).replace("{2,}","*").getRegex(),text:W(Yc.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Po={normal:th,gfm:IO,pedantic:PO},Di={normal:rh,gfm:Yc,breaks:ez,pedantic:QO},tz={"&":"&","<":"<",">":">",'"':""","'":"'"},gf=t=>tz[t];function St(t,e){if(e){if(Me.escapeTest.test(t))return t.replace(Me.escapeReplace,gf)}else if(Me.escapeTestNoEncode.test(t))return t.replace(Me.escapeReplaceNoEncode,gf);return t}function mf(t){try{t=encodeURI(t).replace(Me.percentDecode,"%")}catch{return null}return t}function vf(t,e){var s;let n=t.replace(Me.findPipe,(o,a,c)=>{let u=!1,d=a;for(;--d>=0&&c[d]==="\\";)u=!u;return u?"|":" |"}),r=n.split(Me.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(Me.slashPipe,"|");return r}function Oi(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 nz(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 rz(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 yf(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 iz(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 ua=class{constructor(t){b(this,"options");b(this,"rules");b(this,"lexer");this.options=t||fr}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:Oi(n,`
|
|
342
|
+
`)}}}fences(t){let e=this.rules.block.fences.exec(t);if(e){let n=e[0],r=iz(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=Oi(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:Oi(e[0],`
|
|
343
|
+
`)}}blockquote(t){let e=this.rules.block.blockquote.exec(t);if(e){let n=Oi(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,$=v.raw+`
|
|
350
|
+
`+n.join(`
|
|
351
|
+
`),k=this.blockquote($);s[s.length-1]=k,r=r.substring(0,r.length-v.raw.length)+k.raw,i=i.substring(0,i.length-v.text.length)+k.text;break}else if((y==null?void 0:y.type)==="list"){let v=y,$=v.raw+`
|
|
352
|
+
`+n.join(`
|
|
353
|
+
`),k=this.list($);s[s.length-1]=k,r=r.substring(0,r.length-y.raw.length)+k.raw,i=i.substring(0,i.length-v.raw.length)+k.raw,n=$.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=rz(e[2].split(`
|
|
355
|
+
`,1)[0],e[1].length),$=t.split(`
|
|
356
|
+
`,1)[0],k=!v.trim(),I=0;if(this.options.pedantic?(I=2,y=v.trimStart()):k?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),k&&this.rules.other.blankLine.test($)&&(p+=$+`
|
|
357
|
+
`,t=t.substring($.length+1),d=!0),!d){let B=this.rules.other.nextBulletRegex(I),P=this.rules.other.hrRegex(I),K=this.rules.other.fencesBeginRegex(I),L=this.rules.other.headingBeginRegex(I),Z=this.rules.other.htmlBeginRegex(I),N=this.rules.other.blockquoteBeginRegex(I);for(;t;){let ce=t.split(`
|
|
358
|
+
`,1)[0],ue;if($=ce,this.options.pedantic?($=$.replace(this.rules.other.listReplaceNesting," "),ue=$):ue=$.replace(this.rules.other.tabCharGlobal," "),K.test($)||L.test($)||Z.test($)||N.test($)||B.test($)||P.test($))break;if(ue.search(this.rules.other.nonSpaceChar)>=I||!$.trim())y+=`
|
|
359
|
+
`+ue.slice(I);else{if(k||v.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||K.test(v)||L.test(v)||P.test(v))break;y+=`
|
|
360
|
+
`+$}k=!$.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=vf(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(vf(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=Oi(n.slice(0,-1),"\\");if((n.length-s.length)%2===0)return}else{let s=nz(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)),yf(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 yf(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}}}},dt=class Kc{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||fr,this.options.tokenizer=this.options.tokenizer||new ua,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:Me,block:Po.normal,inline:Di.normal};this.options.pedantic?(n.block=Po.pedantic,n.inline=Di.pedantic):this.options.gfm&&(n.block=Po.gfm,this.options.breaks?n.inline=Di.breaks:n.inline=Di.gfm),this.tokenizer.rules=n}static get rules(){return{block:Po,inline:Di}}static lex(e,n){return new Kc(n).lex(e)}static lexInline(e,n){return new Kc(n).inlineTokens(e)}lex(e){e=e.replace(Me.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(Me.tabCharGlobal," ").replace(Me.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(k=>(v=k.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 k=n.at(-1);v.type==="text"&&(k==null?void 0:k.type)==="text"?(k.raw+=v.raw,k.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 $=e;if((y=this.options.extensions)!=null&&y.startInline){let k=1/0,I=e.slice(1),B;this.options.extensions.startInline.forEach(P=>{B=P.call({lexer:this},I),typeof B=="number"&&B>=0&&(k=Math.min(k,B))}),k<1/0&&k>=0&&($=e.substring(0,k+1))}if(v=this.tokenizer.inlineText($)){e=e.substring(v.raw.length),v.raw.slice(-1)!=="_"&&(a=v.raw.slice(-1)),o=!0;let k=n.at(-1);(k==null?void 0:k.type)==="text"?(k.raw+=v.raw,k.text+=v.text):n.push(v);continue}if(e){let k="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(k);break}else throw new Error(k)}}return n}},ha=class{constructor(t){b(this,"options");b(this,"parser");this.options=t||fr}space(t){return""}code({text:t,lang:e,escaped:n}){var s;let r=(s=(e||"").match(Me.notSpaceStart))==null?void 0:s[0],i=t.replace(Me.endingNewline,"")+`
|
|
378
|
+
`;return r?'<pre><code class="language-'+St(r)+'">'+(n?i:St(i,!0))+`</code></pre>
|
|
379
|
+
`:"<pre><code>"+(n?i:St(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>${St(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=mf(t);if(i===null)return r;t=i;let s='<a href="'+t+'"';return e&&(s+=' title="'+St(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=mf(t);if(i===null)return St(n);t=i;let s=`<img src="${t}" alt="${St(n)}"`;return e&&(s+=` title="${St(e)}"`),s+=">",s}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:St(t.text)}},ih=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}},pt=class Jc{constructor(e){b(this,"options");b(this,"renderer");b(this,"textRenderer");this.options=e||fr,this.options.renderer=this.options.renderer||new ha,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new ih}static parse(e,n){return new Jc(n).parse(e)}static parseInline(e,n){return new Jc(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}},Ro,Vi=(Ro=class{constructor(t){b(this,"options");b(this,"block");this.options=t||fr}preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}emStrongMask(t){return t}provideLexer(){return this.block?dt.lex:dt.lexInline}provideParser(){return this.block?pt.parse:pt.parseInline}},b(Ro,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),b(Ro,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),Ro),sz=class{constructor(...t){b(this,"defaults",Ku());b(this,"options",this.setOptions);b(this,"parse",this.parseMarkdown(!0));b(this,"parseInline",this.parseMarkdown(!1));b(this,"Parser",pt);b(this,"Renderer",ha);b(this,"TextRenderer",ih);b(this,"Lexer",dt);b(this,"Tokenizer",ua);b(this,"Hooks",Vi);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 ha(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 ua(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 Vi;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];Vi.passThroughHooks.has(s)?i[o]=u=>{if(this.defaults.async&&Vi.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 dt.lex(t,e??this.defaults)}parser(t,e){return pt.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?dt.lex:dt.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?pt.parse:pt.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?dt.lex:dt.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?pt.parse:pt.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>"+St(n.message+"",!0)+"</pre>";return e?Promise.resolve(r):r}if(e)return Promise.reject(n);throw n}}},cr=new sz;function J(t,e){return cr.parse(t,e)}J.options=J.setOptions=function(t){return cr.setOptions(t),J.defaults=cr.defaults,Cy(J.defaults),J};J.getDefaults=Ku;J.defaults=fr;J.use=function(...t){return cr.use(...t),J.defaults=cr.defaults,Cy(J.defaults),J};J.walkTokens=function(t,e){return cr.walkTokens(t,e)};J.parseInline=cr.parseInline;J.Parser=pt;J.parser=pt.parse;J.Renderer=ha;J.TextRenderer=ih;J.Lexer=dt;J.lexer=dt.lex;J.Tokenizer=ua;J.Hooks=Vi;J.parse=J;J.options;J.setOptions;J.use;J.walkTokens;J.parseInline;pt.parse;dt.lex;Ty.addHook("afterSanitizeAttributes",t=>{t.tagName==="A"&&(t.setAttribute("target","_blank"),t.setAttribute("rel","noopener noreferrer"))});function oz(t){const e=J.parse(t,{async:!1});return Ty.sanitize(e,{USE_PROFILES:{html:!0}})}const az=8,bf=new WeakMap;function lz(t){const e=bf.get(t);if(e&&e.text===t.text)return e.html;const n=oz(t.text);return bf.set(t,{text:t.text,html:n}),n}function wf(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 Vt,rr,Ca,Ia,Ms,Xc;class Uy extends ns{constructor(){super(...arguments);_(this,Ms);b(this,"messages",[]);_(this,Vt,!0);_(this,rr,null);_(this,Ca,()=>{const n=l(this,rr);if(!n)return;const i=n.scrollHeight-n.clientHeight-n.scrollTop<=az;i!==l(this,Vt)&&(x(this,Vt,i),this.toggleAttribute("data-pinned",i))});_(this,Ia,()=>{x(this,Vt,!0),this.toggleAttribute("data-pinned",!0),m(this,Ms,Xc).call(this,!0)})}changed(n){let r=!1;if(n.has("messages")){const i=n.get("messages")??[],s=wf(this.messages);r=s!==null&&s!==wf(i),r&&x(this,Vt,!0)}Re(this.template(),this),l(this,rr)||x(this,rr,this.querySelector(".history-scroll")),this.toggleAttribute("data-pinned",l(this,Vt)),m(this,Ms,Xc).call(this,r)}template(){const n=this.messages.filter(r=>r.kind==="user"||r.kind==="assistant");return F`
|
|
397
|
+
<div class="history-scroll" @scroll=${l(this,Ca)}>
|
|
398
|
+
${n.map(r=>{const i=r.kind==="assistant"?wD(lz(r)):r.text;return F`<div
|
|
399
|
+
class="message message-${r.kind}"
|
|
400
|
+
data-message-id=${r.id}
|
|
401
|
+
>${i}</div>`})}
|
|
402
|
+
</div>
|
|
403
|
+
<button
|
|
404
|
+
type="button"
|
|
405
|
+
class="history-jump"
|
|
406
|
+
aria-label="Jump to latest message"
|
|
407
|
+
@click=${l(this,Ia)}
|
|
408
|
+
>
|
|
409
|
+
${Nv({size:16})}
|
|
410
|
+
</button>
|
|
411
|
+
`}}Vt=new WeakMap,rr=new WeakMap,Ca=new WeakMap,Ia=new WeakMap,Ms=new WeakSet,Xc=function(n){requestAnimationFrame(()=>{const r=l(this,rr);r&&(!l(this,Vt)&&!n||(r.scrollTop=r.scrollHeight-r.clientHeight))})},b(Uy,"properties",["messages"]);customElements.define("message-history",Uy);var Ns,Us,Xr,Fs,bn,eu,tu,Zs,Hs;class Qc extends ns{constructor(){super(...arguments);_(this,bn);b(this,"placeholder","What do you want to do?");b(this,"open",!1);b(this,"messages",[]);_(this,Ns,Ge.resolve("ACPClientManager"));_(this,Us,Ge.resolve("ShortcutService"));_(this,Xr,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,Ns).getActiveClient();s&&s.sendMessage({text:i}).catch(o=>{console.error("ACPClient.sendMessage() failed",o)})});_(this,Fs,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()}});_(this,Zs,n=>{n.target instanceof Node&&(this.contains(n.target)||(this.open=!1))});_(this,Hs,n=>{n.key==="Escape"&&(this.open=!1)})}connected(){this.setAttribute("material","paper"),this.setAttribute("tone","dark"),this.setAttribute("level","overlay");const n=new DisposableStack;x(this,Xr,n);const r=J2(l(this,Ns),i=>{this.messages=i});n.defer(()=>r.dispose()),l(this,Us).addEventListener("shortcut-triggered",l(this,Fs)),n.defer(()=>l(this,Us).removeEventListener("shortcut-triggered",l(this,Fs))),this.open&&m(this,bn,eu).call(this)}disconnected(){var n;(n=l(this,Xr))==null||n.dispose(),x(this,Xr,null),m(this,bn,tu).call(this)}changed(n){if(Re(this.template(),this),n.has("open"))if(this.open){m(this,bn,eu).call(this);const r=this.querySelector("textarea");r==null||r.focus()}else m(this,bn,tu).call(this)}template(){return this.open?F`
|
|
412
|
+
<message-history .messages=${this.messages}></message-history>
|
|
413
|
+
<textarea
|
|
414
|
+
class="input"
|
|
415
|
+
rows="1"
|
|
416
|
+
@keydown=${this.handleKeydown}
|
|
417
|
+
></textarea>
|
|
418
|
+
`:F`
|
|
419
|
+
<div
|
|
420
|
+
class="trigger"
|
|
421
|
+
tabindex="0"
|
|
422
|
+
role="button"
|
|
423
|
+
@click=${this.handleTriggerActivate}
|
|
424
|
+
@focus=${this.handleTriggerActivate}
|
|
425
|
+
>
|
|
426
|
+
<span class="label">${this.placeholder}</span>
|
|
427
|
+
<span class="kbd" aria-hidden="true">⌘K</span>
|
|
428
|
+
</div>
|
|
429
|
+
`}}Ns=new WeakMap,Us=new WeakMap,Xr=new WeakMap,Fs=new WeakMap,bn=new WeakSet,eu=function(){document.addEventListener("mousedown",l(this,Zs)),document.addEventListener("keydown",l(this,Hs))},tu=function(){document.removeEventListener("mousedown",l(this,Zs)),document.removeEventListener("keydown",l(this,Hs))},Zs=new WeakMap,Hs=new WeakMap,b(Qc,"properties",["placeholder","open","messages"]),b(Qc,"attributes",{placeholder:{type:String},open:{type:Boolean}});customElements.define("command-panel",Qc);class Fy extends Event{constructor(n){super("auth-submit",{bubbles:!0,composed:!0});b(this,"token");this.token=n}}class cz 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 Fy(r))}render(){Re(F`
|
|
430
|
+
<modal-overlay open>
|
|
431
|
+
<section class="auth-modal">
|
|
432
|
+
<form class="auth-form" @submit=${n=>this.handleSubmit(n)}>
|
|
433
|
+
<h2 class="auth-modal-title">Enter access token</h2>
|
|
434
|
+
<p class="auth-modal-copy">This Television server requires a token.</p>
|
|
435
|
+
<label class="settings-field">
|
|
436
|
+
<span>Token</span>
|
|
437
|
+
<input
|
|
438
|
+
class=${this.invalid?"auth-token-input-invalid":""}
|
|
439
|
+
type="password"
|
|
440
|
+
name="token"
|
|
441
|
+
.value=${this.tokenValue}
|
|
442
|
+
@input=${n=>this.handleInput(n)}
|
|
443
|
+
required
|
|
444
|
+
/>
|
|
445
|
+
</label>
|
|
446
|
+
<button type="submit" class="settings-submit-button">Connect</button>
|
|
447
|
+
</form>
|
|
448
|
+
</section>
|
|
449
|
+
</modal-overlay>
|
|
450
|
+
`,this)}}customElements.get("auth-modal")||customElements.define("auth-modal",cz);class uz extends HTMLElement{constructor(){super(...arguments);b(this,"runtimeServerURL",_v());b(this,"electronMode",Sv());b(this,"serverManager",Ge.resolve("ServerManager"));b(this,"screenManager",Ge.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 Fy?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,Ac());return}if(this.serverManager.activeServer)return;const n=new wc({url:this.runtimeServerURL,name:"Server",token:Ac()});this.serverManager.add(n),this.serverManager.setActive(n);try{await n.connect(),this.connectError=null}catch(r){this.connectError=r instanceof Error&&!(r instanceof bc)?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 bc||(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(F`
|
|
451
|
+
<main class="auth-gate"><p>Connecting...</p></main>
|
|
452
|
+
`,this);return}if(r==="disconnected"){const o=n;if(!o)return;Re(F`
|
|
453
|
+
<main class="auth-gate">
|
|
454
|
+
<auth-modal
|
|
455
|
+
.invalid=${!!o.token}
|
|
456
|
+
.tokenValue=${o.token??""}
|
|
457
|
+
></auth-modal>
|
|
458
|
+
</main>
|
|
459
|
+
`,this);return}const s=this.screenManager.activeScreen?F`<screen-view></screen-view>`:F`<home-screen></home-screen>`;Re(F`
|
|
460
|
+
<main>
|
|
461
|
+
${this.connectError?F`<p data-testid="auth-error">${this.connectError}</p>`:F`
|
|
462
|
+
${s}
|
|
463
|
+
${r==="connected"?F`
|
|
464
|
+
<div class="chrome">
|
|
465
|
+
<div class="top-row electron-draggable">
|
|
466
|
+
<screen-breadcrumb></screen-breadcrumb>
|
|
467
|
+
<screen-create-button></screen-create-button>
|
|
468
|
+
</div>
|
|
469
|
+
<command-panel></command-panel>
|
|
470
|
+
</div>
|
|
471
|
+
`:null}
|
|
472
|
+
`}
|
|
473
|
+
</main>
|
|
474
|
+
`,this)}}customElements.get("television-app")||customElements.define("television-app",uz);const sh=Sv(),Ya=_v(),Zy=new mE(sh?"television-electron":"television-browser",gE(Ya)),Hy=new lC({localStore:Zy,localServerURL:Ya}),By=new dE({localStore:Zy,serverManager:Hy}),hz=new BR({serverURL:Ya,token:Ac()??"",screenManager:By}),dz=new jR;Ge.register("ServerManager",()=>Hy);Ge.register("ScreenManager",()=>By);Ge.register("ACPClientManager",()=>hz);Ge.register("ShortcutService",()=>dz);const oh=document.createElement("television-app");oh.runtimeServerURL=Ya;oh.electronMode=sh;sh&&document.body.classList.add("electron");document.body.appendChild(oh);
|