@telepath-computer/television 0.1.33 → 0.1.35
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/browser/assets/Hind-Variable-C47b_dt9.woff2 +0 -0
- package/dist/browser/assets/index-CfQyq4ej.css +1 -0
- package/dist/browser/assets/index-DCRTjgkN.js +520 -0
- package/dist/browser/index.html +2 -2
- package/dist/cli.cjs +4 -4
- package/package.json +1 -1
- package/skill/SKILL.md +2 -2
- package/dist/browser/assets/Supreme-Variable-D6OPM70K.woff2 +0 -0
- package/dist/browser/assets/Supreme-VariableItalic-BM_OJs3z.woff2 +0 -0
- package/dist/browser/assets/index-C0YgLV2m.css +0 -1
- package/dist/browser/assets/index-DNHsk-aL.js +0 -552
|
@@ -1,552 +0,0 @@
|
|
|
1
|
-
var xv=Object.defineProperty;var Su=t=>{throw TypeError(t)};var Cv=(t,e,n)=>e in t?xv(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var v=(t,e,n)=>Cv(t,typeof e!="symbol"?e+"":e,n),fa=(t,e,n)=>e.has(t)||Su("Cannot "+n);var h=(t,e,n)=>(fa(t,e,"read from private field"),n?n.call(t):e.get(t)),x=(t,e,n)=>e.has(t)?Su("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),$=(t,e,n,r)=>(fa(t,e,"write to private field"),r?r.call(t,n):e.set(t,n),n),b=(t,e,n)=>(fa(t,e,"access private method"),n);var ku=(t,e,n,r)=>({set _(s){$(t,e,s,n)},get _(){return h(t,e,r)}});(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const i of s)if(i.type==="childList")for(const o of i.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(s){const i={};return s.integrity&&(i.integrity=s.integrity),s.referrerPolicy&&(i.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?i.credentials="include":s.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(s){if(s.ep)return;s.ep=!0;const i=n(s);fetch(s.href,i)}})();var Sn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Tv(t){if(t.__esModule)return t;var e=t.default;if(typeof e=="function"){var n=function r(){return this instanceof r?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach(function(r){var s=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(n,r,s.get?s:{enumerable:!0,get:function(){return t[r]}})}),n}var Eu=Object.prototype.toString,cf=function(e){var n=Eu.call(e),r=n==="[object Arguments]";return r||(r=n!=="[object Array]"&&e!==null&&typeof e=="object"&&typeof e.length=="number"&&e.length>=0&&Eu.call(e.callee)==="[object Function]"),r},pa,$u;function Iv(){if($u)return pa;$u=1;var t;if(!Object.keys){var e=Object.prototype.hasOwnProperty,n=Object.prototype.toString,r=cf,s=Object.prototype.propertyIsEnumerable,i=!s.call({toString:null},"toString"),o=s.call(function(){},"prototype"),a=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],l=function(y){var m=y.constructor;return m&&m.prototype===y},c={$applicationCache:!0,$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$onmozfullscreenchange:!0,$onmozfullscreenerror:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},d=function(){if(typeof window>"u")return!1;for(var y in window)try{if(!c["$"+y]&&e.call(window,y)&&window[y]!==null&&typeof window[y]=="object")try{l(window[y])}catch{return!0}}catch{return!0}return!1}(),f=function(y){if(typeof window>"u"||!d)return l(y);try{return l(y)}catch{return!1}};t=function(m){var E=m!==null&&typeof m=="object",k=n.call(m)==="[object Function]",I=r(m),V=E&&n.call(m)==="[object String]",N=[];if(!E&&!k&&!I)throw new TypeError("Object.keys called on a non-object");var j=o&&k;if(V&&m.length>0&&!e.call(m,0))for(var F=0;F<m.length;++F)N.push(String(F));if(I&&m.length>0)for(var L=0;L<m.length;++L)N.push(String(L));else for(var J in m)!(j&&J==="prototype")&&e.call(m,J)&&N.push(String(J));if(i)for(var G=f(m),he=0;he<a.length;++he)!(G&&a[he]==="constructor")&&e.call(m,a[he])&&N.push(a[he]);return N}}return pa=t,pa}var Pv=Array.prototype.slice,Rv=cf,Au=Object.keys,qi=Au?function(e){return Au(e)}:Iv(),xu=Object.keys;qi.shim=function(){if(Object.keys){var e=function(){var n=Object.keys(arguments);return n&&n.length===arguments.length}(1,2);e||(Object.keys=function(r){return Rv(r)?xu(Pv.call(r)):xu(r)})}else Object.keys=qi;return Object.keys||qi};var Dv=qi,Yi=Object.defineProperty||!1;if(Yi)try{Yi({},"a",{value:1})}catch{Yi=!1}var ai=Yi,Zt=SyntaxError,H=TypeError,Ov=Object.getOwnPropertyDescriptor,Ki=Ov;if(Ki)try{Ki([],"length")}catch{Ki=null}var Nr=Ki,Cu=ai,zv=Zt,rr=H,Tu=Nr,uf=function(e,n,r){if(!e||typeof e!="object"&&typeof e!="function")throw new rr("`obj` must be an object or a function`");if(typeof n!="string"&&typeof n!="symbol")throw new rr("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new rr("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new rr("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new rr("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new rr("`loose`, if provided, must be a boolean");var s=arguments.length>3?arguments[3]:null,i=arguments.length>4?arguments[4]:null,o=arguments.length>5?arguments[5]:null,a=arguments.length>6?arguments[6]:!1,l=!!Tu&&Tu(e,n);if(Cu)Cu(e,n,{configurable:o===null&&l?l.configurable:!o,enumerable:s===null&&l?l.enumerable:!s,value:r,writable:i===null&&l?l.writable:!i});else if(a||!s&&!i&&!o)e[n]=r;else throw new zv("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},tl=ai,hf=function(){return!!tl};hf.hasArrayLengthDefineBug=function(){if(!tl)return null;try{return tl([],"length",{value:1}).length!==1}catch{return!0}};var Lo=hf,Lv=Dv,Mv=typeof Symbol=="function"&&typeof Symbol("foo")=="symbol",Nv=Object.prototype.toString,Uv=Array.prototype.concat,Iu=uf,Fv=function(t){return typeof t=="function"&&Nv.call(t)==="[object Function]"},df=Lo(),Zv=function(t,e,n,r){if(e in t){if(r===!0){if(t[e]===n)return}else if(!Fv(r)||!r())return}df?Iu(t,e,n,!0):Iu(t,e,n)},ff=function(t,e){var n=arguments.length>2?arguments[2]:{},r=Lv(e);Mv&&(r=Uv.call(r,Object.getOwnPropertySymbols(e)));for(var s=0;s<r.length;s+=1)Zv(t,r[s],e[r[s]],n[r[s]])};ff.supportsDescriptors=!!df;var Gn=ff,Ji={exports:{}};typeof self<"u"?Ji.exports=self:typeof window<"u"?Ji.exports=window:Ji.exports=Function("return this")();var pf=Ji.exports,jv=pf,gf=function(){return typeof Sn!="object"||!Sn||Sn.Math!==Math||Sn.Array!==Array?jv:Sn},Wv=Gn,Bv=Nr,Vv=gf,Hv=function(){var e=Vv();if(Wv.supportsDescriptors){var n=Bv(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},Gv=Gn,qv=pf,mf=gf,Yv=Hv,Kv=mf(),vf=function(){return Kv};Gv(vf,{getPolyfill:mf,implementation:qv,shim:Yv});var Yl=vf,jt=function(e){return!!e&&(typeof e=="function"||typeof e=="object")},Kl=Object,yf=Error,Jv=EvalError,Xv=RangeError,Jl=ReferenceError,Qv=URIError,ey=Math.abs,ty=Math.floor,ny=Math.max,ry=Math.min,sy=Math.pow,iy=Math.round,Xl=Number.isNaN||function(e){return e!==e},oy=Xl,ay=function(e){return oy(e)||e===0?e:e<0?-1:1},Ur=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var e={},n=Symbol("test"),r=Object(n);if(typeof n=="string"||Object.prototype.toString.call(n)!=="[object Symbol]"||Object.prototype.toString.call(r)!=="[object Symbol]")return!1;var s=42;e[n]=s;for(var i in e)return!1;if(typeof Object.keys=="function"&&Object.keys(e).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(e).length!==0)return!1;var o=Object.getOwnPropertySymbols(e);if(o.length!==1||o[0]!==n||!Object.prototype.propertyIsEnumerable.call(e,n))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var a=Object.getOwnPropertyDescriptor(e,n);if(a.value!==s||a.enumerable!==!0)return!1}return!0},Pu=typeof Symbol<"u"&&Symbol,ly=Ur,Ql=function(){return typeof Pu!="function"||typeof Symbol!="function"||typeof Pu("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:ly()},bf=typeof Reflect<"u"&&Reflect.getPrototypeOf||null,cy=Kl,wf=cy.getPrototypeOf||null,uy="Function.prototype.bind called on incompatible ",hy=Object.prototype.toString,dy=Math.max,fy="[object Function]",Ru=function(e,n){for(var r=[],s=0;s<e.length;s+=1)r[s]=e[s];for(var i=0;i<n.length;i+=1)r[i+e.length]=n[i];return r},py=function(e,n){for(var r=[],s=n,i=0;s<e.length;s+=1,i+=1)r[i]=e[s];return r},gy=function(t,e){for(var n="",r=0;r<t.length;r+=1)n+=t[r],r+1<t.length&&(n+=e);return n},my=function(e){var n=this;if(typeof n!="function"||hy.apply(n)!==fy)throw new TypeError(uy+n);for(var r=py(arguments,1),s,i=function(){if(this instanceof s){var d=n.apply(this,Ru(r,arguments));return Object(d)===d?d:this}return n.apply(e,Ru(r,arguments))},o=dy(0,n.length-r.length),a=[],l=0;l<o;l++)a[l]="$"+l;if(s=Function("binder","return function ("+gy(a,",")+"){ return binder.apply(this,arguments); }")(i),n.prototype){var c=function(){};c.prototype=n.prototype,s.prototype=new c,c.prototype=null}return s},vy=my,li=Function.prototype.bind||vy,ec=Function.prototype.call,tc=Function.prototype.apply,yy=typeof Reflect<"u"&&Reflect&&Reflect.apply,by=li,wy=tc,_y=ec,Sy=yy,_f=Sy||by.call(_y,wy),ky=li,Ey=H,$y=ec,Ay=_f,Mo=function(e){if(e.length<1||typeof e[0]!="function")throw new Ey("a function is required");return Ay(ky,$y,e)},xy=Mo,Du=Nr,Sf;try{Sf=[].__proto__===Array.prototype}catch(t){if(!t||typeof t!="object"||!("code"in t)||t.code!=="ERR_PROTO_ACCESS")throw t}var ga=!!Sf&&Du&&Du(Object.prototype,"__proto__"),kf=Object,Ou=kf.getPrototypeOf,Cy=ga&&typeof ga.get=="function"?xy([ga.get]):typeof Ou=="function"?function(e){return Ou(e==null?e:kf(e))}:!1,zu=bf,Lu=wf,Mu=Cy,Ef=zu?function(e){return zu(e)}:Lu?function(e){if(!e||typeof e!="object"&&typeof e!="function")throw new TypeError("getProto: not an object");return Lu(e)}:Mu?function(e){return Mu(e)}:null,Ty=Function.prototype.call,Iy=Object.prototype.hasOwnProperty,Py=li,Wt=Py.call(Ty,Iy),B,Ry=Kl,Dy=yf,Oy=Jv,zy=Xv,Ly=Jl,Rr=Zt,br=H,My=Qv,Ny=ey,Uy=ty,Fy=ny,Zy=ry,jy=sy,Wy=iy,By=ay,$f=Function,ma=function(t){try{return $f('"use strict"; return ('+t+").constructor;")()}catch{}},xs=Nr,Vy=ai,va=function(){throw new br},Hy=xs?function(){try{return arguments.callee,va}catch{try{return xs(arguments,"callee").get}catch{return va}}}():va,sr=Ql(),_e=Ef,Gy=wf,qy=bf,Af=tc,ci=ec,ar={},Yy=typeof Uint8Array>"u"||!_e?B:_e(Uint8Array),Zn={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?B:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?B:ArrayBuffer,"%ArrayIteratorPrototype%":sr&&_e?_e([][Symbol.iterator]()):B,"%AsyncFromSyncIteratorPrototype%":B,"%AsyncFunction%":ar,"%AsyncGenerator%":ar,"%AsyncGeneratorFunction%":ar,"%AsyncIteratorPrototype%":ar,"%Atomics%":typeof Atomics>"u"?B:Atomics,"%BigInt%":typeof BigInt>"u"?B:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?B:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?B:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?B:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Dy,"%eval%":eval,"%EvalError%":Oy,"%Float16Array%":typeof Float16Array>"u"?B:Float16Array,"%Float32Array%":typeof Float32Array>"u"?B:Float32Array,"%Float64Array%":typeof Float64Array>"u"?B:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?B:FinalizationRegistry,"%Function%":$f,"%GeneratorFunction%":ar,"%Int8Array%":typeof Int8Array>"u"?B:Int8Array,"%Int16Array%":typeof Int16Array>"u"?B:Int16Array,"%Int32Array%":typeof Int32Array>"u"?B:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":sr&&_e?_e(_e([][Symbol.iterator]())):B,"%JSON%":typeof JSON=="object"?JSON:B,"%Map%":typeof Map>"u"?B:Map,"%MapIteratorPrototype%":typeof Map>"u"||!sr||!_e?B:_e(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Ry,"%Object.getOwnPropertyDescriptor%":xs,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?B:Promise,"%Proxy%":typeof Proxy>"u"?B:Proxy,"%RangeError%":zy,"%ReferenceError%":Ly,"%Reflect%":typeof Reflect>"u"?B:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?B:Set,"%SetIteratorPrototype%":typeof Set>"u"||!sr||!_e?B:_e(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?B:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":sr&&_e?_e(""[Symbol.iterator]()):B,"%Symbol%":sr?Symbol:B,"%SyntaxError%":Rr,"%ThrowTypeError%":Hy,"%TypedArray%":Yy,"%TypeError%":br,"%Uint8Array%":typeof Uint8Array>"u"?B:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?B:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?B:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?B:Uint32Array,"%URIError%":My,"%WeakMap%":typeof WeakMap>"u"?B:WeakMap,"%WeakRef%":typeof WeakRef>"u"?B:WeakRef,"%WeakSet%":typeof WeakSet>"u"?B:WeakSet,"%Function.prototype.call%":ci,"%Function.prototype.apply%":Af,"%Object.defineProperty%":Vy,"%Object.getPrototypeOf%":Gy,"%Math.abs%":Ny,"%Math.floor%":Uy,"%Math.max%":Fy,"%Math.min%":Zy,"%Math.pow%":jy,"%Math.round%":Wy,"%Math.sign%":By,"%Reflect.getPrototypeOf%":qy};if(_e)try{null.error}catch(t){var Ky=_e(_e(t));Zn["%Error.prototype%"]=Ky}var Jy=function t(e){var n;if(e==="%AsyncFunction%")n=ma("async function () {}");else if(e==="%GeneratorFunction%")n=ma("function* () {}");else if(e==="%AsyncGeneratorFunction%")n=ma("async function* () {}");else if(e==="%AsyncGenerator%"){var r=t("%AsyncGeneratorFunction%");r&&(n=r.prototype)}else if(e==="%AsyncIteratorPrototype%"){var s=t("%AsyncGenerator%");s&&_e&&(n=_e(s.prototype))}return Zn[e]=n,n},Nu={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},ui=li,co=Wt,Xy=ui.call(ci,Array.prototype.concat),Qy=ui.call(Af,Array.prototype.splice),Uu=ui.call(ci,String.prototype.replace),uo=ui.call(ci,String.prototype.slice),eb=ui.call(ci,RegExp.prototype.exec),tb=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,nb=/\\(\\)?/g,rb=function(e){var n=uo(e,0,1),r=uo(e,-1);if(n==="%"&&r!=="%")throw new Rr("invalid intrinsic syntax, expected closing `%`");if(r==="%"&&n!=="%")throw new Rr("invalid intrinsic syntax, expected opening `%`");var s=[];return Uu(e,tb,function(i,o,a,l){s[s.length]=a?Uu(l,nb,"$1"):o||i}),s},sb=function(e,n){var r=e,s;if(co(Nu,r)&&(s=Nu[r],r="%"+s[0]+"%"),co(Zn,r)){var i=Zn[r];if(i===ar&&(i=Jy(r)),typeof i>"u"&&!n)throw new br("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:s,name:r,value:i}}throw new Rr("intrinsic "+e+" does not exist!")},tt=function(e,n){if(typeof e!="string"||e.length===0)throw new br("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof n!="boolean")throw new br('"allowMissing" argument must be a boolean');if(eb(/^%?[^%]*%?$/,e)===null)throw new Rr("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var r=rb(e),s=r.length>0?r[0]:"",i=sb("%"+s+"%",n),o=i.name,a=i.value,l=!1,c=i.alias;c&&(s=c[0],Qy(r,Xy([0,1],c)));for(var d=1,f=!0;d<r.length;d+=1){var y=r[d],m=uo(y,0,1),E=uo(y,-1);if((m==='"'||m==="'"||m==="`"||E==='"'||E==="'"||E==="`")&&m!==E)throw new Rr("property names with quotes must have matching quotes");if((y==="constructor"||!f)&&(l=!0),s+="."+y,o="%"+s+"%",co(Zn,o))a=Zn[o];else if(a!=null){if(!(y in a)){if(!n)throw new br("base intrinsic for "+e+" exists, but the property is not available.");return}if(xs&&d+1>=r.length){var k=xs(a,y);f=!!k,f&&"get"in k&&!("originalValue"in k.get)?a=k.get:a=a[y]}else f=co(a,y),a=a[y];f&&!l&&(Zn[o]=a)}}return a},ya,Fu;function hn(){if(Fu)return ya;Fu=1;var t=tt,e=Mo,n=e([t("%String.prototype.indexOf%")]);return ya=function(s,i){var o=t(s,!!i);return typeof o=="function"&&n(s,".prototype.")>-1?e([o]):o},ya}var ba,Zu;function nc(){if(Zu)return ba;Zu=1;var t=tt,e=t("%Array%"),n=!e.isArray&&hn()("Object.prototype.toString");return ba=e.isArray||function(s){return n(s)==="[object Array]"},ba}var ib=Lo,ju=ai,xf=ib.hasArrayLengthDefineBug(),ob=xf&&nc(),ab=hn(),lb=ab("Object.prototype.propertyIsEnumerable"),rc=function(e,n,r,s,i,o){if(!ju){if(!e(o)||!o["[[Configurable]]"]||!o["[[Writable]]"]||i in s&&lb(s,i)!==!!o["[[Enumerable]]"])return!1;var a=o["[[Value]]"];return s[i]=a,n(s[i],a)}return xf&&i==="length"&&"[[Value]]"in o&&ob(s)&&s.length!==o["[[Value]]"]?(s.length=o["[[Value]]"],s.length===o["[[Value]]"]):(ju(s,i,r(o)),!0)},cb=H,ts=Wt,ub={__proto__:null,"[[Configurable]]":!0,"[[Enumerable]]":!0,"[[Get]]":!0,"[[Set]]":!0,"[[Value]]":!0,"[[Writable]]":!0},Fr=function(e){if(!e||typeof e!="object")return!1;for(var n in e)if(ts(e,n)&&!ub[n])return!1;var r=ts(e,"[[Value]]")||ts(e,"[[Writable]]"),s=ts(e,"[[Get]]")||ts(e,"[[Set]]");if(r&&s)throw new cb("Property Descriptors may not be both accessor and data descriptors");return!0},Cf=function(e){if(typeof e>"u")return e;var n={};return"[[Value]]"in e&&(n.value=e["[[Value]]"]),"[[Writable]]"in e&&(n.writable=!!e["[[Writable]]"]),"[[Get]]"in e&&(n.get=e["[[Get]]"]),"[[Set]]"in e&&(n.set=e["[[Set]]"]),"[[Enumerable]]"in e&&(n.enumerable=!!e["[[Enumerable]]"]),"[[Configurable]]"in e&&(n.configurable=!!e["[[Configurable]]"]),n},hb=H,db=Fr,fb=Cf,Tf=function(e){if(typeof e<"u"&&!db(e))throw new hb("Assertion failed: `Desc` must be a Property Descriptor");return fb(e)},pb=H,Wu=Wt,gb=Fr,If=function(e){if(typeof e>"u")return!1;if(!gb(e))throw new pb("Assertion failed: `Desc` must be a Property Descriptor");return!(!Wu(e,"[[Value]]")&&!Wu(e,"[[Writable]]"))},Zr=function(e){return typeof e=="string"||typeof e=="symbol"},Bu=Xl,Pf=function(e,n){return e===n?e===0?1/e===1/n:!0:Bu(e)&&Bu(n)},Vu=H,mb=jt,vb=rc,yb=Tf,bb=If,wb=Zr,_b=Pf,sc=function(e,n,r){if(!mb(e))throw new Vu("Assertion failed: Type(O) is not Object");if(!wb(n))throw new Vu("Assertion failed: P is not a Property Key");var s={"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Value]]":r,"[[Writable]]":!0};return vb(bb,_b,yb,e,n,s)},Rf=Function.prototype.toString,gr=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,nl,Xi;if(typeof gr=="function"&&typeof Object.defineProperty=="function")try{nl=Object.defineProperty({},"length",{get:function(){throw Xi}}),Xi={},gr(function(){throw 42},null,nl)}catch(t){t!==Xi&&(gr=null)}else gr=null;var Sb=/^\s*class\b/,rl=function(e){try{var n=Rf.call(e);return Sb.test(n)}catch{return!1}},wa=function(e){try{return rl(e)?!1:(Rf.call(e),!0)}catch{return!1}},Qi=Object.prototype.toString,kb="[object Object]",Eb="[object Function]",$b="[object GeneratorFunction]",Ab="[object HTMLAllCollection]",xb="[object HTML document.all class]",Cb="[object HTMLCollection]",Tb=typeof Symbol=="function"&&!!Symbol.toStringTag,Ib=!(0 in[,]),sl=function(){return!1};if(typeof document=="object"){var Pb=document.all;Qi.call(Pb)===Qi.call(document.all)&&(sl=function(e){if((Ib||!e)&&(typeof e>"u"||typeof e=="object"))try{var n=Qi.call(e);return(n===Ab||n===xb||n===Cb||n===kb)&&e("")==null}catch{}return!1})}var Df=gr?function(e){if(sl(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;try{gr(e,null,nl)}catch(n){if(n!==Xi)return!1}return!rl(e)&&wa(e)}:function(e){if(sl(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;if(Tb)return wa(e);if(rl(e))return!1;var n=Qi.call(e);return n!==Eb&&n!==$b&&!/^\[object HTML/.test(n)?!1:wa(e)},Rb=Df,Db=function(e){return!!e},ft=Wt,Ii=H,Ob=jt,Hu=Rb,_a=Db,zb=function(e){if(!Ob(e))throw new Ii("ToPropertyDescriptor requires an object");var n={};if(ft(e,"enumerable")&&(n["[[Enumerable]]"]=_a(e.enumerable)),ft(e,"configurable")&&(n["[[Configurable]]"]=_a(e.configurable)),ft(e,"value")&&(n["[[Value]]"]=e.value),ft(e,"writable")&&(n["[[Writable]]"]=_a(e.writable)),ft(e,"get")){var r=e.get;if(typeof r<"u"&&!Hu(r))throw new Ii("getter must be a function");n["[[Get]]"]=r}if(ft(e,"set")){var s=e.set;if(typeof s<"u"&&!Hu(s))throw new Ii("setter must be a function");n["[[Set]]"]=s}if((ft(n,"[[Get]]")||ft(n,"[[Set]]"))&&(ft(n,"[[Value]]")||ft(n,"[[Writable]]")))throw new Ii("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute");return n},Sa=H,Lb=jt,Gu=Fr,Mb=rc,Nb=Tf,Ub=If,Fb=Zr,Zb=Pf,jb=zb,Wb=function(e,n,r){if(!Lb(e))throw new Sa("Assertion failed: Type(O) is not Object");if(!Fb(n))throw new Sa("Assertion failed: P is not a Property Key");var s=Gu(r)?r:jb(r);if(!Gu(s))throw new Sa("Assertion failed: Desc is not a valid Property Descriptor");return Mb(Ub,Zb,Nb,e,n,s)},qu=H,Bb=jt,Vb=Wb,Hb=Zr,Gb=function(e,n,r){if(!Bb(e))throw new qu("Assertion failed: Type(O) is not Object");if(!Hb(n))throw new qu("Assertion failed: P is not a Property Key");var s={"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Value]]":r,"[[Writable]]":!0};return Vb(e,n,s)},qb=typeof Reflect<"u"&&Reflect.setPrototypeOf||null,Yb=Kl,Kb=Yb.setPrototypeOf||null,Jb=Mo,Yu=Nr,Xb=H,Of={};try{Of.__proto__=null}catch(t){if(!t||typeof t!="object"||!("code"in t)||t.code!=="ERR_PROTO_ACCESS")throw t}var Qb=!("toString"in Of),ka=Yu&&Yu(Object.prototype,"__proto__"),ew=Qb&&(!!ka&&typeof ka.set=="function"&&Jb([ka.set])||function(e,n){if(e==null)throw new Xb("set Object.prototype.__proto__ called on null or undefined");return e.__proto__=n,n}),Ku=qb,tw=Kb,Ju=ew,nw=H,rw=Ku?function(e,n){if(Ku(e,n))return e;throw new nw("Reflect.setPrototypeOf: failed to set [[Prototype]]")}:tw||(Ju?function(e,n){return Ju(e,n),e}:null),Xu=H,sw=jt,Qu=Ef,iw=function(e){if(!sw(e))throw new Xu("Assertion failed: O must be an Object");if(!Qu)throw new Xu("This environment does not support fetching prototypes.");return Qu(e)},ow=H,aw=rw,lw=jt,cw=iw,uw=function(e,n){if(n!==null&&!lw(n))throw new ow("Assertion failed: V must be Object or Null");try{aw(e,n)}catch{return!1}return cw(e)===n},Ea=sc,eh=Gb,zf=uw,hw=Lo(),ic=yf;function hi(t,e,n){var r=new ic(n);return zf(r,eo),delete r.constructor,eh(r,"error",t),eh(r,"suppressed",e),r}hw&&Object.defineProperty(hi,"prototype",{writable:!1});var eo=hi.prototype;if(!Ea(eo,"constructor",hi)||!Ea(eo,"message","")||!Ea(eo,"name","SuppressedError"))throw new ic("unable to install SuppressedError.prototype properties; please report this!");zf(hi.prototype,ic.prototype);var dw=hi,fw=dw,Lf=function(){return typeof SuppressedError=="function"?SuppressedError:fw},pw=Gn,th=Yl(),gw=Lf,mw=function(){var e=gw();return pw(th,{SuppressedError:e},{SuppressedError:function(){return th.SuppressedError!==e}}),e};mw();var vw=H,yw=Fr,bw=Cf,ww=function(e){if(typeof e<"u"&&!yw(e))throw new vw("Assertion failed: `Desc` must be a Property Descriptor");return bw(e)},_w=H,nh=Wt,Sw=Fr,kw=function(e){if(typeof e>"u")return!1;if(!Sw(e))throw new _w("Assertion failed: `Desc` must be a Property Descriptor");return!(!nh(e,"[[Value]]")&&!nh(e,"[[Writable]]"))},rh=Xl,Ew=function(e,n){return e===n?e===0?1/e===1/n:!0:rh(e)&&rh(n)},jr=Df,$w=function(e){return!!e},pt=Wt,Pi=H,Aw=jt,sh=jr,$a=$w,xw=function(e){if(!Aw(e))throw new Pi("ToPropertyDescriptor requires an object");var n={};if(pt(e,"enumerable")&&(n["[[Enumerable]]"]=$a(e.enumerable)),pt(e,"configurable")&&(n["[[Configurable]]"]=$a(e.configurable)),pt(e,"value")&&(n["[[Value]]"]=e.value),pt(e,"writable")&&(n["[[Writable]]"]=$a(e.writable)),pt(e,"get")){var r=e.get;if(typeof r<"u"&&!sh(r))throw new Pi("getter must be a function");n["[[Get]]"]=r}if(pt(e,"set")){var s=e.set;if(typeof s<"u"&&!sh(s))throw new Pi("setter must be a function");n["[[Set]]"]=s}if((pt(n,"[[Get]]")||pt(n,"[[Set]]"))&&(pt(n,"[[Value]]")||pt(n,"[[Writable]]")))throw new Pi("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute");return n},Aa=H,Cw=jt,ih=Fr,Tw=rc,Iw=ww,Pw=kw,Rw=Zr,Dw=Ew,Ow=xw,di=function(e,n,r){if(!Cw(e))throw new Aa("Assertion failed: Type(O) is not Object");if(!Rw(n))throw new Aa("Assertion failed: P is not a Property Key");var s=ih(r)?r:Ow(r);if(!ih(s))throw new Aa("Assertion failed: Desc is not a valid Property Descriptor");return Tw(Pw,Dw,Iw,e,n,s)},zw=Ur(),Lw=zw?Symbol.dispose||Symbol("Symbol.dispose"):null,Mw=Ur,Nw=Lw,oc=function(){return Mw()&&Symbol.dispose||Nw},Uw=Ql,Fw=di,Zw=oc,jw=function(){var e=Zw();return Uw()&&Fw(Symbol,"dispose",{"[[Configurable]]":!1,"[[Enumerable]]":!1,"[[Writable]]":!1,"[[Value]]":e}),e},Ww=Ur(),Bw=Ww?Symbol.asyncDispose||Symbol("Symbol.asyncDispose"):null,Vw=Ur,Hw=Bw,ac=function(){return Vw()&&Symbol.asyncDispose||Hw},Gw=Ql,qw=di,Yw=ac,Kw=function(){var e=Yw();return Gw()&&qw(Symbol,"asyncDispose",{"[[Configurable]]":!1,"[[Enumerable]]":!1,"[[Writable]]":!1,"[[Value]]":e}),e},Jw=nc(),Xw=tt,Qw=hn(),e_=H,t_=Jw,n_=Xw("%Reflect.apply%",!0)||Qw("Function.prototype.apply"),No=function(e,n){var r=arguments.length>2?arguments[2]:[];if(!t_(r))throw new e_("Assertion failed: optional `argumentsList`, if provided, must be a List");return n_(e,n,r)};const r_={},s_=Object.freeze(Object.defineProperty({__proto__:null,default:r_},Symbol.toStringTag,{value:"Module"})),i_=Tv(s_);var lc=typeof Map=="function"&&Map.prototype,xa=Object.getOwnPropertyDescriptor&&lc?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,ho=lc&&xa&&typeof xa.get=="function"?xa.get:null,oh=lc&&Map.prototype.forEach,cc=typeof Set=="function"&&Set.prototype,Ca=Object.getOwnPropertyDescriptor&&cc?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,fo=cc&&Ca&&typeof Ca.get=="function"?Ca.get:null,ah=cc&&Set.prototype.forEach,o_=typeof WeakMap=="function"&&WeakMap.prototype,Ss=o_?WeakMap.prototype.has:null,a_=typeof WeakSet=="function"&&WeakSet.prototype,ks=a_?WeakSet.prototype.has:null,l_=typeof WeakRef=="function"&&WeakRef.prototype,lh=l_?WeakRef.prototype.deref:null,c_=Boolean.prototype.valueOf,u_=Object.prototype.toString,h_=Function.prototype.toString,d_=String.prototype.match,uc=String.prototype.slice,tn=String.prototype.replace,f_=String.prototype.toUpperCase,ch=String.prototype.toLowerCase,Mf=RegExp.prototype.test,uh=Array.prototype.concat,_t=Array.prototype.join,p_=Array.prototype.slice,hh=Math.floor,il=typeof BigInt=="function"?BigInt.prototype.valueOf:null,Ta=Object.getOwnPropertySymbols,ol=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,Dr=typeof Symbol=="function"&&typeof Symbol.iterator=="object",Es=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===Dr||!0)?Symbol.toStringTag:null,Nf=Object.prototype.propertyIsEnumerable,dh=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(t){return t.__proto__}:null);function fh(t,e){if(t===1/0||t===-1/0||t!==t||t&&t>-1e3&&t<1e3||Mf.call(/e/,e))return e;var n=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof t=="number"){var r=t<0?-hh(-t):hh(t);if(r!==t){var s=String(r),i=uc.call(e,s.length+1);return tn.call(s,n,"$&_")+"."+tn.call(tn.call(i,/([0-9]{3})/g,"$&_"),/_$/,"")}}return tn.call(e,n,"$&_")}var al=i_,ph=al.custom,gh=Zf(ph)?ph:null,Uf={__proto__:null,double:'"',single:"'"},g_={__proto__:null,double:/(["\\])/g,single:/(['\\])/g},Wr=function t(e,n,r,s){var i=n||{};if(It(i,"quoteStyle")&&!It(Uf,i.quoteStyle))throw new TypeError('option "quoteStyle" must be "single" or "double"');if(It(i,"maxStringLength")&&(typeof i.maxStringLength=="number"?i.maxStringLength<0&&i.maxStringLength!==1/0:i.maxStringLength!==null))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var o=It(i,"customInspect")?i.customInspect:!0;if(typeof o!="boolean"&&o!=="symbol")throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(It(i,"indent")&&i.indent!==null&&i.indent!==" "&&!(parseInt(i.indent,10)===i.indent&&i.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(It(i,"numericSeparator")&&typeof i.numericSeparator!="boolean")throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var a=i.numericSeparator;if(typeof e>"u")return"undefined";if(e===null)return"null";if(typeof e=="boolean")return e?"true":"false";if(typeof e=="string")return Wf(e,i);if(typeof e=="number"){if(e===0)return 1/0/e>0?"0":"-0";var l=String(e);return a?fh(e,l):l}if(typeof e=="bigint"){var c=String(e)+"n";return a?fh(e,c):c}var d=typeof i.depth>"u"?5:i.depth;if(typeof r>"u"&&(r=0),r>=d&&d>0&&typeof e=="object")return ll(e)?"[Array]":"[Object]";var f=D_(i,r);if(typeof s>"u")s=[];else if(jf(s,e)>=0)return"[Circular]";function y(ut,Bt,ta){if(Bt&&(s=p_.call(s),s.push(Bt)),ta){var _i={depth:i.depth};return It(i,"quoteStyle")&&(_i.quoteStyle=i.quoteStyle),t(ut,_i,r+1,s)}return t(ut,i,r+1,s)}if(typeof e=="function"&&!mh(e)){var m=E_(e),E=Ri(e,y);return"[Function"+(m?": "+m:" (anonymous)")+"]"+(E.length>0?" { "+_t.call(E,", ")+" }":"")}if(Zf(e)){var k=Dr?tn.call(String(e),/^(Symbol\(.*\))_[^)]*$/,"$1"):ol.call(e);return typeof e=="object"&&!Dr?ns(k):k}if(I_(e)){for(var I="<"+ch.call(String(e.nodeName)),V=e.attributes||[],N=0;N<V.length;N++)I+=" "+V[N].name+"="+Ff(m_(V[N].value),"double",i);return I+=">",e.childNodes&&e.childNodes.length&&(I+="..."),I+="</"+ch.call(String(e.nodeName))+">",I}if(ll(e)){if(e.length===0)return"[]";var j=Ri(e,y);return f&&!R_(j)?"["+cl(j,f)+"]":"[ "+_t.call(j,", ")+" ]"}if(y_(e)){var F=Ri(e,y);return!("cause"in Error.prototype)&&"cause"in e&&!Nf.call(e,"cause")?"{ ["+String(e)+"] "+_t.call(uh.call("[cause]: "+y(e.cause),F),", ")+" }":F.length===0?"["+String(e)+"]":"{ ["+String(e)+"] "+_t.call(F,", ")+" }"}if(typeof e=="object"&&o){if(gh&&typeof e[gh]=="function"&&al)return al(e,{depth:d-r});if(o!=="symbol"&&typeof e.inspect=="function")return e.inspect()}if($_(e)){var L=[];return oh&&oh.call(e,function(ut,Bt){L.push(y(Bt,e,!0)+" => "+y(ut,e))}),vh("Map",ho.call(e),L,f)}if(C_(e)){var J=[];return ah&&ah.call(e,function(ut){J.push(y(ut,e))}),vh("Set",fo.call(e),J,f)}if(A_(e))return Ia("WeakMap");if(T_(e))return Ia("WeakSet");if(x_(e))return Ia("WeakRef");if(w_(e))return ns(y(Number(e)));if(S_(e))return ns(y(il.call(e)));if(__(e))return ns(c_.call(e));if(b_(e))return ns(y(String(e)));if(typeof window<"u"&&e===window)return"{ [object Window] }";if(typeof globalThis<"u"&&e===globalThis||typeof Sn<"u"&&e===Sn)return"{ [object globalThis] }";if(!v_(e)&&!mh(e)){var G=Ri(e,y),he=dh?dh(e)===Object.prototype:e instanceof Object||e.constructor===Object,ct=e instanceof Object?"":"null prototype",wi=!he&&Es&&Object(e)===e&&Es in e?uc.call(dn(e),8,-1):ct?"Object":"",Ee=he||typeof e.constructor!="function"?"":e.constructor.name?e.constructor.name+" ":"",gn=Ee+(wi||ct?"["+_t.call(uh.call([],wi||[],ct||[]),": ")+"] ":"");return G.length===0?gn+"{}":f?gn+"{"+cl(G,f)+"}":gn+"{ "+_t.call(G,", ")+" }"}return String(e)};function Ff(t,e,n){var r=n.quoteStyle||e,s=Uf[r];return s+t+s}function m_(t){return tn.call(String(t),/"/g,""")}function qn(t){return!Es||!(typeof t=="object"&&(Es in t||typeof t[Es]<"u"))}function ll(t){return dn(t)==="[object Array]"&&qn(t)}function v_(t){return dn(t)==="[object Date]"&&qn(t)}function mh(t){return dn(t)==="[object RegExp]"&&qn(t)}function y_(t){return dn(t)==="[object Error]"&&qn(t)}function b_(t){return dn(t)==="[object String]"&&qn(t)}function w_(t){return dn(t)==="[object Number]"&&qn(t)}function __(t){return dn(t)==="[object Boolean]"&&qn(t)}function Zf(t){if(Dr)return t&&typeof t=="object"&&t instanceof Symbol;if(typeof t=="symbol")return!0;if(!t||typeof t!="object"||!ol)return!1;try{return ol.call(t),!0}catch{}return!1}function S_(t){if(!t||typeof t!="object"||!il)return!1;try{return il.call(t),!0}catch{}return!1}var k_=Object.prototype.hasOwnProperty||function(t){return t in this};function It(t,e){return k_.call(t,e)}function dn(t){return u_.call(t)}function E_(t){if(t.name)return t.name;var e=d_.call(h_.call(t),/^function\s*([\w$]+)/);return e?e[1]:null}function jf(t,e){if(t.indexOf)return t.indexOf(e);for(var n=0,r=t.length;n<r;n++)if(t[n]===e)return n;return-1}function $_(t){if(!ho||!t||typeof t!="object")return!1;try{ho.call(t);try{fo.call(t)}catch{return!0}return t instanceof Map}catch{}return!1}function A_(t){if(!Ss||!t||typeof t!="object")return!1;try{Ss.call(t,Ss);try{ks.call(t,ks)}catch{return!0}return t instanceof WeakMap}catch{}return!1}function x_(t){if(!lh||!t||typeof t!="object")return!1;try{return lh.call(t),!0}catch{}return!1}function C_(t){if(!fo||!t||typeof t!="object")return!1;try{fo.call(t);try{ho.call(t)}catch{return!0}return t instanceof Set}catch{}return!1}function T_(t){if(!ks||!t||typeof t!="object")return!1;try{ks.call(t,ks);try{Ss.call(t,Ss)}catch{return!0}return t instanceof WeakSet}catch{}return!1}function I_(t){return!t||typeof t!="object"?!1:typeof HTMLElement<"u"&&t instanceof HTMLElement?!0:typeof t.nodeName=="string"&&typeof t.getAttribute=="function"}function Wf(t,e){if(t.length>e.maxStringLength){var n=t.length-e.maxStringLength,r="... "+n+" more character"+(n>1?"s":"");return Wf(uc.call(t,0,e.maxStringLength),e)+r}var s=g_[e.quoteStyle||"single"];s.lastIndex=0;var i=tn.call(tn.call(t,s,"\\$1"),/[\x00-\x1f]/g,P_);return Ff(i,"single",e)}function P_(t){var e=t.charCodeAt(0),n={8:"b",9:"t",10:"n",12:"f",13:"r"}[e];return n?"\\"+n:"\\x"+(e<16?"0":"")+f_.call(e.toString(16))}function ns(t){return"Object("+t+")"}function Ia(t){return t+" { ? }"}function vh(t,e,n,r){var s=r?cl(n,r):_t.call(n,", ");return t+" ("+e+") {"+s+"}"}function R_(t){for(var e=0;e<t.length;e++)if(jf(t[e],`
|
|
2
|
-
`)>=0)return!1;return!0}function D_(t,e){var n;if(t.indent===" ")n=" ";else if(typeof t.indent=="number"&&t.indent>0)n=_t.call(Array(t.indent+1)," ");else return null;return{base:n,prev:_t.call(Array(e+1),n)}}function cl(t,e){if(t.length===0)return"";var n=`
|
|
3
|
-
`+e.prev+e.base;return n+_t.call(t,","+n)+`
|
|
4
|
-
`+e.prev}function Ri(t,e){var n=ll(t),r=[];if(n){r.length=t.length;for(var s=0;s<t.length;s++)r[s]=It(t,s)?e(t[s],t):""}var i=typeof Ta=="function"?Ta(t):[],o;if(Dr){o={};for(var a=0;a<i.length;a++)o["$"+i[a]]=i[a]}for(var l in t)It(t,l)&&(n&&String(Number(l))===l&&l<t.length||Dr&&o["$"+l]instanceof Symbol||(Mf.call(/[^\w$]/,l)?r.push(e(l,t)+": "+e(t[l],t)):r.push(l+": "+e(t[l],t))));if(typeof Ta=="function")for(var c=0;c<i.length;c++)Nf.call(t,i[c])&&r.push("["+e(i[c])+"]: "+e(t[i[c]],t));return r}var O_=Wr,z_=H,Uo=function(t,e,n){for(var r=t,s;(s=r.next)!=null;r=s)if(s.key===e)return r.next=s.next,n||(s.next=t.next,t.next=s),s},L_=function(t,e){if(t){var n=Uo(t,e);return n&&n.value}},M_=function(t,e,n){var r=Uo(t,e);r?r.value=n:t.next={key:e,next:t.next,value:n}},N_=function(t,e){return t?!!Uo(t,e):!1},U_=function(t,e){if(t)return Uo(t,e,!0)},F_=function(){var e,n={assert:function(r){if(!n.has(r))throw new z_("Side channel does not contain "+O_(r))},delete:function(r){var s=e&&e.next,i=U_(e,r);return i&&s&&s===i&&(e=void 0),!!i},get:function(r){return L_(e,r)},has:function(r){return N_(e,r)},set:function(r,s){e||(e={next:void 0}),M_(e,r,s)}};return n},Z_=tt,fi=hn(),j_=Wr,W_=H,yh=Z_("%Map%",!0),B_=fi("Map.prototype.get",!0),V_=fi("Map.prototype.set",!0),H_=fi("Map.prototype.has",!0),G_=fi("Map.prototype.delete",!0),q_=fi("Map.prototype.size",!0),Bf=!!yh&&function(){var e,n={assert:function(r){if(!n.has(r))throw new W_("Side channel does not contain "+j_(r))},delete:function(r){if(e){var s=G_(e,r);return q_(e)===0&&(e=void 0),s}return!1},get:function(r){if(e)return B_(e,r)},has:function(r){return e?H_(e,r):!1},set:function(r,s){e||(e=new yh),V_(e,r,s)}};return n},Y_=tt,Fo=hn(),K_=Wr,Di=Bf,J_=H,ir=Y_("%WeakMap%",!0),X_=Fo("WeakMap.prototype.get",!0),Q_=Fo("WeakMap.prototype.set",!0),eS=Fo("WeakMap.prototype.has",!0),tS=Fo("WeakMap.prototype.delete",!0),nS=ir?function(){var e,n,r={assert:function(s){if(!r.has(s))throw new J_("Side channel does not contain "+K_(s))},delete:function(s){if(ir&&s&&(typeof s=="object"||typeof s=="function")){if(e)return tS(e,s)}else if(Di&&n)return n.delete(s);return!1},get:function(s){return ir&&s&&(typeof s=="object"||typeof s=="function")&&e?X_(e,s):n&&n.get(s)},has:function(s){return ir&&s&&(typeof s=="object"||typeof s=="function")&&e?eS(e,s):!!n&&n.has(s)},set:function(s,i){ir&&s&&(typeof s=="object"||typeof s=="function")?(e||(e=new ir),Q_(e,s,i)):Di&&(n||(n=Di()),n.set(s,i))}};return r}:Di,rS=H,sS=Wr,iS=F_,oS=Bf,aS=nS,lS=aS||oS||iS,cS=function(){var e,n={assert:function(r){if(!n.has(r))throw new rS("Side channel does not contain "+sS(r))},delete:function(r){return!!e&&e.delete(r)},get:function(r){return e&&e.get(r)},has:function(r){return!!e&&e.has(r)},set:function(r,s){e||(e=lS()),e.set(r,s)}};return n},uS=Wt,rs=cS(),xt=H,hc={assert:function(t,e){if(!t||typeof t!="object"&&typeof t!="function")throw new xt("`O` is not an object");if(typeof e!="string")throw new xt("`slot` must be a string");if(rs.assert(t),!hc.has(t,e))throw new xt("`"+e+"` is not present on `O`")},get:function(t,e){if(!t||typeof t!="object"&&typeof t!="function")throw new xt("`O` is not an object");if(typeof e!="string")throw new xt("`slot` must be a string");var n=rs.get(t);return n&&n["$"+e]},has:function(t,e){if(!t||typeof t!="object"&&typeof t!="function")throw new xt("`O` is not an object");if(typeof e!="string")throw new xt("`slot` must be a string");var n=rs.get(t);return!!n&&uS(n,"$"+e)},set:function(t,e,n){if(!t||typeof t!="object"&&typeof t!="function")throw new xt("`O` is not an object");if(typeof e!="string")throw new xt("`slot` must be a string");var r=rs.get(t);r||(r={},rs.set(t,r)),r["$"+e]=n}};Object.freeze&&Object.freeze(hc);var dc=hc,Vf=Zt,sn=dc,pi=function t(e,n){if(!(this instanceof t))return new t(e,n);if(e!=="normal"&&e!=="break"&&e!=="continue"&&e!=="return"&&e!=="throw")throw new Vf('Assertion failed: `type` must be one of "normal", "break", "continue", "return", or "throw"');sn.set(this,"[[Type]]",e),sn.set(this,"[[Value]]",n)};pi.prototype.type=function(){return sn.get(this,"[[Type]]")};pi.prototype.value=function(){return sn.get(this,"[[Value]]")};pi.prototype["?"]=function(){var e=sn.get(this,"[[Type]]"),n=sn.get(this,"[[Value]]");if(e==="throw")throw n;return n};pi.prototype["!"]=function(){var e=sn.get(this,"[[Type]]");if(e!=="normal")throw new Vf('Assertion failed: Completion Record is not of type "normal"');return sn.get(this,"[[Value]]")};var fc=pi,hS=fc,pc=function(e){return new hS("normal",e)},Pa,bh;function dS(){if(bh)return Pa;bh=1;var t=Ur;return Pa=function(){return t()&&!!Symbol.toStringTag},Pa}var fS=tt,wh=fS("%Object.defineProperty%",!0),pS=dS()(),gS=Wt,mS=H,Oi=pS?Symbol.toStringTag:null,Hf=function(e,n){var r=arguments.length>2&&!!arguments[2]&&arguments[2].force,s=arguments.length>2&&!!arguments[2]&&arguments[2].nonConfigurable;if(typeof r<"u"&&typeof r!="boolean"||typeof s<"u"&&typeof s!="boolean")throw new mS("if provided, the `overrideIfSet` and `nonConfigurable` options must be booleans");Oi&&(r||!gS(e,Oi))&&(wh?wh(e,Oi,{configurable:!s,enumerable:!1,value:n,writable:!1}):e[Oi]=n)},Gf={exports:{}},vS=tt,_h=uf,yS=Lo(),Sh=Nr,kh=H,bS=vS("%Math.floor%"),wS=function(e,n){if(typeof e!="function")throw new kh("`fn` is not a function");if(typeof n!="number"||n<0||n>4294967295||bS(n)!==n)throw new kh("`length` must be a positive 32-bit integer");var r=arguments.length>2&&!!arguments[2],s=!0,i=!0;if("length"in e&&Sh){var o=Sh(e,"length");o&&!o.configurable&&(s=!1),o&&!o.writable&&(i=!1)}return(s||i||!r)&&(yS?_h(e,"length",n,!0,!0):_h(e,"length",n)),e},_S=li,SS=tc,kS=_f,ES=function(){return kS(_S,SS,arguments)};(function(t){var e=wS,n=ai,r=Mo,s=ES;t.exports=function(o){var a=r(arguments),l=1+o.length-(arguments.length-1);return e(a,l>0?l:0,!0)},n?n(t.exports,"apply",{value:s}):t.exports.apply=s})(Gf);var gc=Gf.exports,$S=function(e,n){for(var r=0;r<e.length;r+=1)if(!n(e[r],r,e))return!1;return!0},AS=Object,xS=function(e){return e&&typeof e=="object"&&(typeof e["[[ResourceValue]]"]>"u"||AS(e["[[ResourceValue]]"])===e["[[ResourceValue]]"])&&(e["[[Hint]]"]==="SYNC-DISPOSE"||e["[[Hint]]"]==="ASYNC-DISPOSE")&&(typeof e["[[DisposeMethod]]"]=="function"||typeof e["[[DisposeMethod]]"]>"u")},CS=Wt,TS=nc(),IS=$S,PS=xS,RS=function(e){return e&&typeof e=="object"&&CS(e,"[[DisposableResourceStack]]")&&TS(e["[[DisposableResourceStack]]"])&&(e["[[DisposableResourceStack]]"].length===0||IS(e["[[DisposableResourceStack]]"],PS))},DS=jt,OS=function(e){if(e===null)return"Null";if(typeof e>"u")return"Undefined";if(DS(e))return"Object";if(typeof e=="number")return"Number";if(typeof e=="boolean")return"Boolean";if(typeof e=="string")return"String"},zS=OS,mc=function(e){return typeof e=="symbol"?"Symbol":typeof e=="bigint"?"BigInt":zS(e)},LS=H,MS=Wr,NS=Zr,US=function(e,n){if(!NS(n))throw new LS("Assertion failed: P is not a Property Key, got "+MS(n));return e[n]},Eh=H,FS=US,ZS=jr,jS=Zr,$h=Wr,WS=function(e,n){if(!jS(n))throw new Eh("Assertion failed: P is not a Property Key");var r=FS(e,n);if(r!=null){if(!ZS(r))throw new Eh($h(n)+" is not a function: "+$h(r));return r}},ul={exports:{}},BS=tt,VS=BS,Ah=VS("%Reflect.construct%",!0),po=di;try{po({},"",{"[[Get]]":function(){}})}catch{po=null}if(po&&Ah){var xh={},Ch={};po(Ch,"length",{"[[Get]]":function(){throw xh},"[[Enumerable]]":!0}),ul.exports=function(e){try{Ah(e,Ch)}catch(n){return n===xh}}}else ul.exports=function(e){return typeof e=="function"&&!!e.prototype};var HS=ul.exports,Ra=H,Th=jr,GS=HS,qS=function(e){if(!GS(e))throw new Ra("C must be a constructor");var n={"[[Resolve]]":void 0,"[[Reject]]":void 0},r=new e(function(s,i){if(typeof n["[[Resolve]]"]<"u"||typeof n["[[Reject]]"]<"u")throw new Ra("executor has already been called");n["[[Resolve]]"]=s,n["[[Reject]]"]=i});if(!Th(n["[[Resolve]]"])||!Th(n["[[Reject]]"]))throw new Ra("executor must provide valid resolve and reject functions");return{"[[Promise]]":r,"[[Resolve]]":n["[[Resolve]]"],"[[Reject]]":n["[[Reject]]"]}},Ih=Zt,YS=H,Da=No,Ph=WS,KS=qS,JS=mc,Rh=oc(),Dh=ac(),XS=function(e,n){if(JS(e)!=="Object")throw new YS("`V` must be an Object");if(n!=="SYNC-DISPOSE"&&n!=="ASYNC-DISPOSE")throw new Ih("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");var r;if(n==="ASYNC-DISPOSE"&&Dh&&(r=Ph(e,Dh)),!r){if(!Rh)throw new Ih("`Symbol.dispose` is not supported");if(r=Ph(e,Rh),typeof r<"u")return function(){var s=this;if(n==="ASYNC-DISPOSE"){var i=KS(Promise);try{Da(r,s),Da(i["[[Resolve]]"],void 0,[void 0])}catch(o){i["[[Reject]]"](o)}return i["[[Promise]]"]}Da(r,s)}}return r},QS=Zt,Oa=H,ek=jr,tk=mc,nk=XS,rk=function(e,n){if(n!=="SYNC-DISPOSE"&&n!=="ASYNC-DISPOSE")throw new QS("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");var r;if(arguments.length<3)if(e==null)e=void 0,r=void 0;else{if(typeof e<"u"&&tk(e)!=="Object")throw new Oa("`V` must be an Object, or `null` or `undefined`");if(r=nk(e,n),typeof r>"u")throw new Oa("dispose method must not be `undefined` on `V` when an object `V` is provided")}else if(r=arguments[2],!ek(r))throw new Oa("`method`, when provided, must be a function");return{"[[ResourceValue]]":e,"[[Hint]]":n,"[[DisposeMethod]]":r}},sk=Zt,zi=H,ik=RS,Oh=rk,ok=hn(),ak=ok("Array.prototype.push"),qf=function(e,n,r){if(!ik(e))throw new zi("Assertion failed: `disposeCapability` must be a DisposeCapability Record");if(r!=="SYNC-DISPOSE"&&r!=="ASYNC-DISPOSE")throw new sk("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");var s=arguments.length>3?arguments[3]:void 0;if(arguments.length>3&&typeof s!="function")throw new zi("Assertion failed: `method`, when present, must be a function");if(!e["[[DisposableResourceStack]]"])throw new zi("Assertion failed: `disposeCapability.[[DisposableResourceStack]]` must not be ~EMPTY~");var i;if(arguments.length<4){if(n==null&&r==="SYNC_DISPOSE")return"UNUSED";i=Oh(n,r)}else{if(typeof n<"u")throw new zi("Assertion failed: `V` must be undefined when `method` is present");i=Oh(void 0,r,s)}return ak(e["[[DisposableResourceStack]]"],i),"UNUSED"},za,zh;function vc(){if(zh)return za;zh=1;var t=tt,e=gc,n=Zt,r=t("%Promise.resolve%",!0),s=r&&e(r);return za=function(o,a){if(!s)throw new n("This environment does not support Promises.");return s(o,a)},za}var La,Lh;function lk(){if(Lh)return La;Lh=1;var t=tt,e=Zt,n=t("%Promise%",!0),r=No,s=vc(),i=mc;return La=function(a,l,c){if(typeof a<"u"&&i(a)!=="Object")throw new e("Assertion failed: `V` must be `undefined` or an Object");if(l!=="SYNC-DISPOSE"&&l!=="ASYNC-DISPOSE")throw new e("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");if(typeof c<"u"&&typeof c!="function")throw new e("Assertion failed: `method` must be `undefined` or a function");var d=typeof c>"u"?c:r(c,a);if(l==="ASYNC-DISPOSE")return s(n,d)},La}var Ma,Mh;function ck(){if(Mh)return Ma;Mh=1;var t=fc;return Ma=function(n){return new t("throw",n)},Ma}var uk=tt,Na=Zt,Nh=H,hk=uk("%Promise%",!0),dk=hn(),Uh=dk("Promise.prototype.then",!0),fk=fc,Fh=lk(),pk=pc,gk=vc(),Zh=ck(),mk=Lf(),Yf=function(e,n){if(!(n instanceof fk))throw new Nh("`completion` must be a Completion Record");var r=e["[[DisposableResourceStack]]"];if(!r)throw new Nh("Assertion failed: `disposeCapability.[[DisposableResourceStack]]` must not be ~EMPTY~");for(var s,i=r.length-1;i>=0;i-=1)if(!s)s=r[i]["[[Hint]]"];else if(s!==r[i]["[[Hint]]"])throw new Na("mixed hint stacks are not supported");for(var o=s==="ASYNC-DISPOSE"&&gk(hk,n),a=function(y){if(n.type()==="throw"){var m=n.value(),E=new mk(y,m);n=Zh(E)}else n=Zh(y)},l=s==="ASYNC-DISPOSE"&&function(m){return Uh(o,function(){var E=Fh(m["[[ResourceValue]]"],m["[[Hint]]"],m["[[DisposeMethod]]"]);if(!E)throw new Na("Assertion failed: non-`~ASYNC-DISPOSE~` resource returned a promise from Dispose");return Uh(E,pk)},a)},c=r.length-1;c>=0;c-=1)if(s==="ASYNC-DISPOSE")o=l(r[c]);else{var d=r[c];try{var f=Fh(d["[[ResourceValue]]"],d["[[Hint]]"],d["[[DisposeMethod]]"]);if(f)throw new Na("Assertion failed: `~SYNC-DISPOSE~` resource returned something from Dispose")}catch(y){a(y)}}return e["[[DisposableResourceStack]]"]=null,s==="ASYNC-DISPOSE"?o:n},Kf=function(){var e=[];return{"[[DisposableResourceStack]]":e}},Zo=Jl,yc=H,vk=No,Br=sc,yk=di,Jf=jr,bk=pc,je=dc,wk=Hf,Xf=Gn.supportsDescriptors,_k=gc,bc=qf,Sk=Yf,Qf=Kf,jh=oc(),Xe=function t(){if(!(this instanceof t)||je.has(this,"[[DisposableState]]")||je.has(this,"[[DisposeCapability]]"))throw new yc("can only be used with new");je.set(this,"[[DisposableState]]","PENDING"),je.set(this,"[[DisposeCapability]]",Qf())},ep=function(){var e=this;return je.assert(e,"[[DisposableState]]"),je.get(e,"[[DisposableState]]")==="DISPOSED"},gi=_k(ep);Xf?yk(Xe.prototype,"disposed",{"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Get]]":ep}):Xe.prototype.disposed=!1;var tp=function(e){je.set(e,"[[DisposableState]]","DISPOSED"),Xf||(e.disposed=!0)};Br(Xe.prototype,"dispose",function(){var e=this;if(!gi(e))return tp(e),Sk(je.get(e,"[[DisposeCapability]]"),bk())["?"]()});Br(Xe.prototype,"use",function(e){var n=this;if(gi(n))throw new Zo("a disposed stack can not use anything new");return bc(je.get(n,"[[DisposeCapability]]"),e,"SYNC-DISPOSE"),e});Br(Xe.prototype,"adopt",function(e,n){var r=this;if(gi(r))throw new Zo("a disposed stack can not use anything new");if(!Jf(n))throw new yc("`onDispose` must be a function");var s=function(){return vk(n,void 0,[e])};return bc(je.get(r,"[[DisposeCapability]]"),void 0,"SYNC-DISPOSE",s),e});Br(Xe.prototype,"defer",function(e){var n=this;if(gi(n))throw new Zo("a disposed stack can not defer anything new");if(!Jf(e))throw new yc("`onDispose` must be a function");bc(je.get(n,"[[DisposeCapability]]"),void 0,"SYNC-DISPOSE",e)});Br(Xe.prototype,"move",function(){var e=this;if(gi(e))throw new Zo("a disposed stack can not use anything new");var n=new Xe;return je.set(n,"[[DisposeCapability]]",je.get(e,"[[DisposeCapability]]")),je.set(e,"[[DisposeCapability]]",Qf()),tp(e),n});jh&&Br(Xe.prototype,jh,Xe.prototype.dispose);wk(Xe.prototype,"DisposableStack");var kk=Xe,Ek=kk,$k=function(){return typeof DisposableStack=="function"?DisposableStack:Ek},Ak=Gn,xk=Yl(),Ck=$k,Tk=function(){var e=Ck();return Ak(xk,{DisposableStack:e},{DisposableStack:!0}),e},Ik=tt,jo=Jl,wc=H,Wh=Ik("%Promise%",!0),_c=qf,Pk=No,Vr=sc,Rk=di,Dk=Yf,np=jr,rp=Kf,Ok=pc,Bh=vc(),We=dc,zk=Hf,sp=Gn.supportsDescriptors,Lk=gc,Mk=hn(),Nk=Mk("Promise.prototype.then",!0),Vh=ac(),Qe=function t(){if(!(this instanceof t)||We.has(this,"[[AsyncDisposableState]]")||We.has(this,"[[DisposeCapability]]"))throw new wc("can only be used with new");We.set(this,"[[AsyncDisposableState]]","pending"),We.set(this,"[[DisposeCapability]]",rp())},ip=function(){var e=this;return We.assert(e,"[[AsyncDisposableState]]"),We.get(e,"[[AsyncDisposableState]]")==="disposed"},mi=Lk(ip);sp?Rk(Qe.prototype,"disposed",{"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Get]]":ip}):Qe.prototype.disposed=!1;var op=function(e){We.set(e,"[[AsyncDisposableState]]","disposed"),sp||(e.disposed=!0)};Vr(Qe.prototype,"disposeAsync",function(){var e=this;return mi(e)?Bh(Wh):(op(e),Nk(Bh(Wh,Dk(We.get(e,"[[DisposeCapability]]"),Ok())),function(n){return n["?"]()}))});Vr(Qe.prototype,"use",function(e){var n=this;if(mi(n))throw new jo("a disposed stack can not use anything new");return _c(We.get(n,"[[DisposeCapability]]"),e,"ASYNC-DISPOSE"),e});Vr(Qe.prototype,"adopt",function(e,n){var r=this;if(mi(r))throw new jo("a disposed stack can not use anything new");if(!np(n))throw new wc("`onDisposeAsync` must be a function");var s=function(){return Pk(n,void 0,[e])};return s.value=e,_c(We.get(r,"[[DisposeCapability]]"),void 0,"ASYNC-DISPOSE",s),e});Vr(Qe.prototype,"defer",function(e){var n=this;if(mi(n))throw new jo("a disposed stack can not defer anything new");if(!np(e))throw new wc("`onDispose` must be a function");_c(We.get(n,"[[DisposeCapability]]"),void 0,"ASYNC-DISPOSE",e)});Vr(Qe.prototype,"move",function(){var e=this;if(mi(e))throw new jo("a disposed stack can not use anything new");var n=new Qe;return We.set(n,"[[DisposeCapability]]",We.get(e,"[[DisposeCapability]]")),We.set(e,"[[DisposeCapability]]",rp()),op(e),n});Vh&&Vr(Qe.prototype,Vh,Qe.prototype.disposeAsync);zk(Qe.prototype,"AsyncDisposableStack");var Uk=Qe,Fk=Uk,Zk=function(){return typeof AsyncDisposableStack=="function"?AsyncDisposableStack:Fk},jk=Gn,Wk=Yl(),Bk=Zk,Vk=function(){var e=Bk();return jk(Wk,{AsyncDisposableStack:e},{AsyncDisposableStack:!0}),e},Hk=jw,Gk=Kw,qk=Tk,Yk=Vk,Kk=function(){Hk(),Gk(),qk(),Yk()};Kk();const Hh=new WeakMap;function Jk(t){return(typeof t=="object"||typeof t=="function")&&t!==null&&"then"in t&&typeof t.then=="function"}function or(t){return typeof t=="string"?t:typeof t=="symbol"?t.description??t.toString():t.name||"(anonymous class)"}function Gh(){return new Error("register(Key, factory) requires a factory function. Wrap existing instances as () => instance.")}function Xk(){return new Error("register(Key, factory) does not accept async factories. Await setup before registering.")}class Qk{constructor(){v(this,"entries",new Map);v(this,"constructionStack",[])}register(e,n){if(n===void 0){if(typeof e!="function")throw Gh();this.validateClassRegistration(e),this.storeFactory(e,()=>this.instantiateClass(e));return}if(typeof n!="function")throw Gh();if(n.constructor.name==="AsyncFunction")throw Xk();this.storeFactory(e,n)}has(e){var n;return((n=this.entries.get(e))==null?void 0:n.factory)!==void 0}resolve(e){return this.resolveAny(e)}storeFactory(e,n){const r=this.getOrCreateEntry(e);r.factory=n,r.instance=void 0,r.error=void 0}validateClassRegistration(e){const n=Hh.get(e);if(n){if(e.length!==n.length)throw new Error(`${or(e)} cannot be registered with register(Class). @injectable(...) declared ${n.length} dependencies but constructor arity is ${e.length}. Use register(Key, () => value) instead.`);return}if(e.length!==0)throw new Error(`${or(e)} cannot be registered with register(Class). Undecorated classes must have zero required constructor parameters. Use register(Key, () => value) instead.`)}instantiateClass(e){const n=Hh.get(e);if(!n)return new e;const r=n.map(s=>this.resolveAny(s));return new e(...r)}resolveAny(e){return this.getOrCreateEntry(e).proxy}getOrCreateEntry(e){let n=this.entries.get(e);return n||(n={key:e},n.proxy=this.createProxy(n),this.entries.set(e,n),n)}createProxy(e){return new Proxy({},{get:(n,r)=>{if(r==="then")return;const s=this.getInstance(e),i=Reflect.get(s,r,s);return typeof i=="function"?i.bind(s):i},set:(n,r,s)=>{const i=this.getInstance(e);return Reflect.set(i,r,s,i)},has:(n,r)=>{const s=this.getInstance(e);return r in s}})}getInstance(e){if(e.instance)return e.instance;if(e.error)throw e.error;if(!e.factory)throw new Error(`${or(e.key)} was resolved but never registered`);const n=this.constructionStack.indexOf(e.key);if(n!==-1){const r=[...this.constructionStack.slice(n),e.key].map(s=>or(s)).join(" -> ");throw new Error(`Circular dependency detected: ${r}`)}this.constructionStack.push(e.key);try{const r=e.factory();if(Jk(r))throw new Error(`Factory for ${or(e.key)} returned a Promise. Await setup before registering.`);if(typeof r!="object"||r===null)throw new Error(`Factory for ${or(e.key)} returned a non-object value. Wrap primitives in an object.`);return e.instance=r,r}catch(r){throw e.error=r,r}finally{this.constructionStack.pop()}}}const Ye=new Qk,eE=new Set(["target","currentTarget","eventPhase","defaultPrevented","isTrusted","timeStamp","srcElement","returnValue","cancelBubble","NONE","CAPTURING_PHASE","AT_TARGET","BUBBLING_PHASE","composedPath","stopPropagation","stopImmediatePropagation","preventDefault","initEvent"]);function tE(t){for(const e of Object.keys(t))if(eE.has(e))throw new Error(`Event payload key "${e}" is reserved; choose a different property name`)}function nE(t,e){tE(e);for(const n of Object.keys(e))Object.defineProperty(t,n,{value:e[n],writable:!0,enumerable:!0,configurable:!0})}function Be(){class t extends Event{constructor(n,r){const{type:s,bubbles:i,cancelable:o,composed:a,...l}=r??{};if(s!==void 0)throw new Error('Do not pass "type" in init; use the constructor argument instead');super(n,{bubbles:i,cancelable:o,composed:a}),nE(this,l)}}return t}class kt extends globalThis.EventTarget{}function rE(t,e,n){const r=t.dispose.bind(t);t.dispose=()=>{if(!e())return n(),r()}}function Hr(t){var n;class e extends t{constructor(...i){super(...i);x(this,n,!1);rE(this,()=>h(this,n),()=>{$(this,n,!0)})}[Symbol.dispose](){this.dispose()}get disposed(){return h(this,n)}}return n=new WeakMap,e}const sE=Be(),to=Be(),ap="0123456789ABCDEFGHJKMNPQRSTVWXYZ",go=32,iE=16,lp=10,qh=0xffffffffffff;var An;(function(t){t.Base32IncorrectEncoding="B32_ENC_INVALID",t.DecodeTimeInvalidCharacter="DEC_TIME_CHAR",t.DecodeTimeValueMalformed="DEC_TIME_MALFORMED",t.EncodeTimeNegative="ENC_TIME_NEG",t.EncodeTimeSizeExceeded="ENC_TIME_SIZE_EXCEED",t.EncodeTimeValueMalformed="ENC_TIME_MALFORMED",t.PRNGDetectFailure="PRNG_DETECT",t.ULIDInvalid="ULID_INVALID",t.Unexpected="UNEXPECTED",t.UUIDInvalid="UUID_INVALID"})(An||(An={}));class ps extends Error{constructor(e,n){super(`${n} (${e})`),this.name="ULIDError",this.code=e}}function oE(t){const e=Math.floor(t()*go)%go;return ap.charAt(e)}function aE(t){const e=lE(),n=e&&(e.crypto||e.msCrypto)||null;if(typeof(n==null?void 0:n.getRandomValues)=="function")return()=>{const r=new Uint8Array(1);return n.getRandomValues(r),r[0]/256};if(typeof(n==null?void 0:n.randomBytes)=="function")return()=>n.randomBytes(1).readUInt8()/256;throw new ps(An.PRNGDetectFailure,"Failed to find a reliable PRNG")}function lE(){return hE()?self:typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:null}function cE(t,e){let n="";for(;t>0;t--)n=oE(e)+n;return n}function uE(t,e=lp){if(isNaN(t))throw new ps(An.EncodeTimeValueMalformed,`Time must be a number: ${t}`);if(t>qh)throw new ps(An.EncodeTimeSizeExceeded,`Cannot encode a time larger than ${qh}: ${t}`);if(t<0)throw new ps(An.EncodeTimeNegative,`Time must be positive: ${t}`);if(Number.isInteger(t)===!1)throw new ps(An.EncodeTimeValueMalformed,`Time must be an integer: ${t}`);let n,r="";for(let s=e;s>0;s--)n=t%go,r=ap.charAt(n)+r,t=(t-n)/go;return r}function hE(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}function Sc(t,e){const n=aE(),r=Date.now();return uE(r,lp)+cE(iE,n)}const St=4,Ke=6,cp=2,hl=2,dE=St,fE=Ke,kc="auto",on="auto",kn=120,Yh=75,de=16,nn=kn*St+de*(St-1),mr=kn*Ke+de*(Ke-1),pE=200,gE=4,Li=150,mE=10,Kh=2,vE=4;function up(t){return fp(t)}function hp(t,e){return fp(t.flatMap(n=>gp(n,e)))}function dp(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}mp(r,"strip",e,n)}return{valid:e.length===0,errors:e}}function $s(t){const e=up(t),n=dp(e);if(!n.valid)throw new Error(`Invalid layout: ${n.errors.join("; ")}`);return{totalNodes:e.length,nodes:e.filter(r=>r.type!=="row").map(_E)}}function fp(t){const e=[];for(const n of t){const r=pp(n);for(const s of r){if(s.type==="row"){e.push(...s.children.map(Ft));continue}e.push(s)}}return e}function pp(t){switch(t.type){case"card":return[Ft(t)];case"row":{const e=t.children.map(Ft);return e.length===0?[]:e.length===1?[e[0]]:[{...t,children:e}]}case"stack":{const e=[];for(const n of t.children){const r=pp(n);for(const s of r){if(s.type==="stack"){e.push(...s.children.map(dl));continue}if(s.type==="row"){e.push({...s,children:s.children.map(Ft)});continue}e.push(Ft(s))}}return e.length===0?[]:e.length===1?[dl(e[0])]:[{...t,children:e}]}}}function gp(t,e){switch(t.type){case"card":return t.artifactID===e?[]:[Ft(t)];case"row":{const n=t.children.filter(r=>r.artifactID!==e).map(Ft);return n.length===0?[]:n.length===1?[n[0]]:[{...t,children:n}]}case"stack":{const n=t.children.flatMap(r=>gp(r,e).filter(i=>i.type!=="stack"));return n.length===0?[]:n.length===1?[dl(n[0])]:[{...t,children:n}]}}}function mp(t,e,n,r){switch(t.type){case"card":vp(t,e,n,r);return;case"row":yE(t,e,n,r);return;case"stack":bE(t,e,n,r);return}}function vp(t,e,n,r){Ec(t.id,n),typeof t.artifactID!="string"||t.artifactID.length===0?n.push(`Card ${t.id} is missing artifactID`):r.has(t.artifactID)?n.push(`Duplicate artifactID in layout: ${t.artifactID}`):r.add(t.artifactID),wE(t.width)||n.push(`Card ${t.id} width must be an integer in the range 2-4`),yp(t.height)||n.push(`Card ${t.id} height must be an integer in the range 2-6 or "auto"`);const s=En(t.width);e==="row"&&s<cp&&n.push(`Row child ${t.id} must be at least 2 columns wide`)}function yE(t,e,n,r){if(Ec(t.id,n),e!=="stack"&&n.push(`Row ${t.id} may only appear inside a stack`),yp(t.height,vE)||n.push(`Row ${t.id} height must be an integer in the range 2-4 or "auto"`),!Array.isArray(t.children)||t.children.length===0){n.push(`Row ${t.id} must contain card nodes`);return}let s=0;for(const i of t.children){if(i.type!=="card"){n.push(`Row ${t.id} must contain only card nodes`);continue}vp(i,"row",n,r),s+=En(i.width)}s!==St&&n.push(`Row ${t.id} children must sum to 4 columns`)}function bE(t,e,n,r){if(Ec(t.id,n),e!=="strip"&&n.push(`Invalid nested stack at ${t.id}; stack children cannot contain another nested stack`),!Array.isArray(t.children)||t.children.length===0){n.push(`Stack ${t.id} must contain at least one child`);return}let s=0,i=0;for(const a of t.children){if(a.type==="stack"){n.push(`Stack ${t.id} cannot contain another nested stack`);continue}if(mp(a,"stack",n,r),a.height===on){i+=1;continue}s+=a.height}if(s>Ke&&n.push(`Stack ${t.id} exceeds the 6-row budget`),i===0)return;const o=Ke-s;if(o<i*hl||o%i!==0){n.push(`Stack ${t.id} has auto-height children that cannot resolve to whole height >= 2`);return}o/i<hl&&n.push(`Stack ${t.id} has auto-height children below the minimum row size`)}function Ec(t,e){(typeof t!="string"||t.length===0)&&e.push(`Node id must be a non-empty string: ${String(t)}`)}function wE(t){return t===kc||Number.isInteger(t)&&t>=cp&&t<=dE}function yp(t,e=fE){return t===on||Number.isInteger(t)&&t>=hl&&t<=e}function En(t){return t===kc?St:t}function _E(t){if(t.type==="card")return{id:t.id,type:"card",width:En(t.width),cards:[{id:t.id,artifactID:t.artifactID,col:1,row:1,width:En(t.width),height:bp(t.height,Ke)}]};const e=SE(t.children),n=[];let r=1;for(let s=0;s<t.children.length;s+=1){const i=t.children[s],o=e[s];if(i.type==="card")n.push({id:i.id,artifactID:i.artifactID,col:1,row:r,width:En(i.width),height:o});else{let a=1;for(const l of i.children)n.push({id:l.id,artifactID:l.artifactID,col:a,row:r,width:En(l.width),height:o}),a+=En(l.width)}r+=o}return{id:t.id,type:"stack",width:n.reduce((s,i)=>Math.max(s,i.col+i.width-1),1),cards:n}}function SE(t){let e=0,n=0;for(const s of t)s.height===on?n+=1:e+=s.height;const r=n>0?(Ke-e)/n:0;return t.map(s=>bp(s.height,r))}function bp(t,e){return t===on?e:t}function Ft(t){return{...t}}function dl(t){return t.type==="card"?Ft(t):{...t,children:t.children.map(Ft)}}function wp(t,e={}){return{id:e.id??Sc(),type:"card",artifactID:t,width:e.width??kc,height:e.height??on}}function _p(t,e){return t.some(n=>Sp(n,e))}function Sp(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=>Sp(n,e))}}function Jh(t){return t.layout.flatMap(kp)}function kp(t){switch(t.type){case"card":return[t.artifactID];case"row":return t.children.map(e=>e.artifactID);case"stack":return t.children.flatMap(kp)}}const te=Be(),Ep=Be(),ss=Be(),kE=Be();function EE(t){class e extends Error{constructor(r,s){super(r),this.name=t,s&&Object.assign(this,s)}}return e}const $E=EE("RequestError"),AE=200,xE=300;class CE{constructor(e,n){v(this,"serverURL");v(this,"token");this.serverURL=e.replace(/\/$/,""),this.token=n.token}async requestJSON(e,n,r){const s=await this.request(e,n,r!==void 0?JSON.stringify(r):void 0,r!==void 0?{"content-type":"application/json"}:void 0),i=await TE(s);if(!s.ok||s.status<AE||s.status>=xE)throw this.createError(typeof i.error=="string"?i.error:s.statusText,s.status);return i}async requestVoid(e,n){const r=await this.request(e,n);if(!r.ok)throw this.createError(await Ua(r,r.statusText),r.status)}async requestText(e,n){const r=await this.request(e,n);if(!r.ok)throw this.createError(await Ua(r,r.statusText),r.status);return r.text()}async requestRawVoid(e,n,r){const s=await this.request(e,n,r,{"content-type":"text/plain"});if(!s.ok)throw this.createError(await Ua(s,s.statusText),s.status)}createError(e,n){const r={serverURL:this.serverURL};return n!==void 0&&(r.status=n),new $E(e,r)}async request(e,n,r,s){const i=`${this.serverURL}${n}`;try{return await fetch(i,{method:e,headers:this.buildHeaders(s),body:r})}catch(o){throw this.createError(o instanceof Error?o.message:"Failed to reach server")}}buildHeaders(e){const n={...e??{}};return this.token&&(n.Authorization=`Bearer ${this.token}`),Object.keys(n).length>0?n:void 0}}async function TE(t){try{return await t.json()}catch{const e=await t.text().catch(()=>"");return e?{message:e}:{}}}async function Ua(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 $p(t){return t.map(e=>`${e.name} (${e.id})`).join(", ")}var vt,Ao,Ap;class IE{constructor(e){x(this,Ao);x(this,vt);$(this,vt,e)}list(){return h(this,vt).requestJSON("GET","/screens")}async get(e={}){const n=await b(this,Ao,Ap).call(this,e.screenID);return h(this,vt).requestJSON("GET",`/screens/${encodeURIComponent(n)}`)}create(e){const n={name:e.name};return e.id!==void 0&&(n.id=e.id),h(this,vt).requestJSON("POST","/screens",n)}update(e){const n={};return e.name!==void 0&&(n.name=e.name),e.layout!==void 0&&(n.layout=e.layout),h(this,vt).requestJSON("PATCH",`/screens/${encodeURIComponent(e.screenID)}`,n)}remove(e){return h(this,vt).requestJSON("DELETE",`/screens/${encodeURIComponent(e.screenID)}`)}}vt=new WeakMap,Ao=new WeakSet,Ap=async function(e){if(e!==void 0)return e;const{screens:n}=await this.list();if(n.length===1)return n[0].id;throw h(this,vt).createError(`screenID is required when multiple screens exist. Available screens: ${$p(n)}`)};var Ue,zs,xo,xp;class PE{constructor(e,n){x(this,xo);x(this,Ue);x(this,zs);$(this,Ue,e),$(this,zs,n)}async create(e){const n=await b(this,xo,xp).call(this,e.screenID);return h(this,Ue).requestJSON("POST",`/screens/${encodeURIComponent(n)}/artifact`,{type:e.type,title:e.title,externalFilePath:e.externalFilePath})}get(e){return h(this,Ue).requestJSON("GET",`/artifacts/${encodeURIComponent(e.artifactID)}`)}update(e){const n={};return e.title!==void 0&&(n.title=e.title),h(this,Ue).requestJSON("PATCH",`/artifacts/${encodeURIComponent(e.artifactID)}`,n)}edit(e){return h(this,Ue).requestJSON("POST",`/artifacts/${encodeURIComponent(e.artifactID)}/edit`)}commitPending(e){return h(this,Ue).requestJSON("POST",`/artifacts/${encodeURIComponent(e.artifactID)}/commit`)}abandonPending(e){return h(this,Ue).requestVoid("POST",`/artifacts/${encodeURIComponent(e.artifactID)}/abandon`)}remove(e){return h(this,Ue).requestJSON("DELETE",`/screens/${encodeURIComponent(e.screenID)}/artifacts/${encodeURIComponent(e.artifactID)}`)}getContent(e){return h(this,Ue).requestText("GET",`/artifacts/${encodeURIComponent(e.artifactID)}/content`)}putContent(e){return h(this,Ue).requestRawVoid("PUT",`/artifacts/${encodeURIComponent(e.artifactID)}/content`,e.content)}}Ue=new WeakMap,zs=new WeakMap,xo=new WeakSet,xp=async function(e){if(e!==void 0)return e;const{screens:n}=await h(this,zs).list();if(n.length===1)return n[0].id;throw h(this,Ue).createError(`screenID is required when multiple screens exist. Available screens: ${$p(n)}`)};var Ls;class RE{constructor(e){x(this,Ls);$(this,Ls,e)}async list(){const{views:e}=await h(this,Ls).requestJSON("GET","/views");return e}}Ls=new WeakMap;var Gt;class DE{constructor(e,n={}){v(this,"screens");v(this,"artifacts");v(this,"views");x(this,Gt);$(this,Gt,new CE(e,n)),this.screens=new IE(h(this,Gt)),this.artifacts=new PE(h(this,Gt),this.screens),this.views=new RE(h(this,Gt))}health(){return h(this,Gt).requestJSON("GET","/health")}}Gt=new WeakMap;const OE=Hr(kt);var Cn,Fe,Tn,Oe,qt,Yt,Q,lr,Cp,Ms,Tp,Ip,Pp,Rp,fl,pl,gl,Dp;class zE extends OE{constructor(n){var s;super();x(this,Q);v(this,"id");v(this,"server");x(this,Cn);x(this,Fe,new Map);x(this,Tn);x(this,Oe);x(this,qt);x(this,Yt,null);x(this,Ms,n=>{if(this.disposed)return;const r=n.event;switch(r.type){case"screen-updated":r.screen.id===this.id&&b(this,Q,Tp).call(this,r.screen);break;case"artifact-created":r.screenID===this.id&&b(this,Q,Ip).call(this,r.artifact);break;case"artifact-updated":b(this,Q,Pp).call(this,r.artifact);break;case"artifact-removed":r.screenID===this.id&&b(this,Q,Rp).call(this,r.artifactID);break;case"artifact-content-changed":h(this,Fe).has(r.artifactID)&&this.dispatchEvent(new kE("artifact-content-changed",{artifactID:r.artifactID}));break}});this.id=n.screen.id,this.server=n.server,$(this,Cn,n.localStore),$(this,Tn,n.screen.name),$(this,Oe,structuredClone(n.screen.layout));const r=((s=h(this,Cn).get().screens[this.id])==null?void 0:s.scrollPosition)??0;$(this,qt,Math.max(0,r)),this.server.addEventListener("server-event",h(this,Ms)),b(this,Q,Cp).call(this)}get name(){return h(this,Tn)}get layout(){return h(this,Oe)}get scrollPosition(){return h(this,qt)}get artifacts(){return h(this,Fe)}setScrollPosition(n){b(this,Q,lr).call(this);const r=Math.max(0,n);r!==h(this,qt)&&($(this,qt,r),b(this,Q,Dp).call(this),this.dispatchEvent(new te("change")))}setLayout(n){b(this,Q,lr).call(this);const r=up(n);if(!dp(r).valid)return;const i=b(this,Q,pl).call(this);$(this,Oe,r),$(this,Yt,{layout:r,snapshot:i}),this.dispatchEvent(new te("change")),this.server.client.screens.update({screenID:this.id,layout:r.map(o=>structuredClone(o))}).catch(()=>{var o;this.disposed||((o=h(this,Yt))==null?void 0:o.layout)===r&&($(this,Yt,null),b(this,Q,gl).call(this,i),this.dispatchEvent(new te("change")))})}rename(n){b(this,Q,lr).call(this),$(this,Tn,n),this.dispatchEvent(new te("change")),this.server.client.screens.update({screenID:this.id,name:n}).catch(()=>{})}async remove(){b(this,Q,lr).call(this),await this.server.client.screens.remove({screenID:this.id})}removeArtifact(n){if(b(this,Q,lr).call(this),!h(this,Fe).has(n))return;const r=b(this,Q,pl).call(this);b(this,Q,fl).call(this,n),this.dispatchEvent(new te("change")),this.server.client.artifacts.remove({artifactID:n,screenID:this.id}).catch(()=>{this.disposed||(b(this,Q,gl).call(this,r),this.dispatchEvent(new te("change")))})}dispose(){this.server.removeEventListener("server-event",h(this,Ms))}}Cn=new WeakMap,Fe=new WeakMap,Tn=new WeakMap,Oe=new WeakMap,qt=new WeakMap,Yt=new WeakMap,Q=new WeakSet,lr=function(){if(this.disposed)throw new Error("ScreenModel is disposed")},Cp=async function(){try{const n=await this.server.client.screens.get({screenID:this.id});if(this.disposed)return;for(const r of n.artifacts)h(this,Fe).set(r.id,r);this.dispatchEvent(new te("change"))}catch{}},Ms=new WeakMap,Tp=function(n){h(this,Yt)&&$(this,Yt,null),$(this,Tn,n.name),$(this,Oe,structuredClone(n.layout)),this.dispatchEvent(new te("change"))},Ip=function(n){_p(h(this,Oe),n.id)||$(this,Oe,[...h(this,Oe),wp(n.id)]),h(this,Fe).set(n.id,n),this.dispatchEvent(new te("change"))},Pp=function(n){const r=h(this,Fe).get(n.id);r&&(h(this,Fe).set(n.id,{...r,...n}),this.dispatchEvent(new te("change")))},Rp=function(n){b(this,Q,fl).call(this,n)&&this.dispatchEvent(new te("change"))},fl=function(n){const r=h(this,Fe).delete(n),s=Jh({layout:h(this,Oe)}).length,i=hp(h(this,Oe),n),o=Jh({layout:i}).length;return $(this,Oe,i),r||s!==o},pl=function(){return{layout:structuredClone(h(this,Oe)),artifacts:new Map([...h(this,Fe).entries()].map(([n,r])=>[n,structuredClone(r)]))}},gl=function(n){$(this,Oe,structuredClone(n.layout)),h(this,Fe).clear();for(const[r,s]of n.artifacts)h(this,Fe).set(r,structuredClone(s))},Dp=function(){const n=h(this,Cn).get();h(this,Cn).set({...n,screens:{...n.screens,[this.id]:{scrollPosition:h(this,qt)}}})};const LE=Hr(kt);var Ze,yt,rt,Ns,Us,Fs,rn,no,Op;class ME extends LE{constructor(n){super();x(this,rn);x(this,Ze);x(this,yt);x(this,rt,null);x(this,Ns,()=>{this.disposed||b(this,rn,no).call(this)});x(this,Us,()=>{this.disposed||b(this,rn,no).call(this)});x(this,Fs,n=>{var s;if(this.disposed)return;const r=n.event;r.type==="screen-removed"&&((s=h(this,rt))==null?void 0:s.id)===r.screenID&&this.clearActive()});$(this,Ze,n.localStore),$(this,yt,n.serverManager),h(this,Ze).addEventListener("change",h(this,Ns)),h(this,yt).addEventListener("change",h(this,Us)),h(this,yt).addEventListener("server-event",h(this,Fs)),b(this,rn,no).call(this)}get activeScreen(){return h(this,rt)}setActive(n,r){const s=h(this,Ze).get();s.activeServerURL===n&&s.activeScreenID===r||h(this,Ze).set({...s,activeServerURL:n,activeScreenID:r})}clearActive(){const n=h(this,Ze).get();n.activeServerURL===null&&n.activeScreenID===null||h(this,Ze).set({...n,activeServerURL:null,activeScreenID:null})}dispose(){var n;h(this,Ze).removeEventListener("change",h(this,Ns)),h(this,yt).removeEventListener("change",h(this,Us)),h(this,yt).removeEventListener("server-event",h(this,Fs)),(n=h(this,rt))==null||n.dispose(),$(this,rt,null)}}Ze=new WeakMap,yt=new WeakMap,rt=new WeakMap,Ns=new WeakMap,Us=new WeakMap,Fs=new WeakMap,rn=new WeakSet,no=function(){var l,c,d;const{activeServerURL:n,activeScreenID:r}=h(this,Ze).get();let s=n?h(this,yt).servers.get(n)??null:null,i=s&&r?s.screens.get(r)??null:null;if(!i){const f=b(this,rn,Op).call(this);if(f){s=f.server,i=f.screen,h(this,Ze).set({...h(this,Ze).get(),activeServerURL:f.server.url,activeScreenID:f.screen.id});return}}const o=((l=h(this,rt))==null?void 0:l.id)??null,a=(i==null?void 0:i.id)??null;o===a&&((c=h(this,rt))==null?void 0:c.server)===s||((d=h(this,rt))==null||d.dispose(),$(this,rt,s&&i?new zE({screen:i,server:s,localStore:h(this,Ze)}):null),this.dispatchEvent(new sE("active-screen-changed")))},Op=function(){for(const n of h(this,yt).servers.values()){const r=n.screens.values().next().value;if(r)return{server:n,screen:r}}return null};const NE="Local",UE="store-";function Pt(t){return new URL(t).origin}function FE(t){return{servers:[{url:Pt(t),name:NE}],activeServerURL:null,activeScreenID:null,screens:{}}}var In,Pn,Rn;class ZE extends kt{constructor(n,r,s={}){super();x(this,In);x(this,Pn);x(this,Rn);$(this,In,`${UE}${n}`),$(this,Pn,s.storage??jE());const i=h(this,Pn).getItem(h(this,In));i===null?($(this,Rn,r),h(this,Pn).setItem(h(this,In),JSON.stringify(r))):$(this,Rn,JSON.parse(i))}get(){return h(this,Rn)}set(n){$(this,Rn,n),h(this,Pn).setItem(h(this,In),JSON.stringify(n)),this.dispatchEvent(new te("change"))}}In=new WeakMap,Pn=new WeakMap,Rn=new WeakMap;function jE(){const t=globalThis.localStorage;if(!t)throw new Error("LocalStore: no storage adapter supplied and window.localStorage is unavailable");return t}function S(t,e,n){function r(a,l){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:l,constr:o,traits:new Set},enumerable:!1}),a._zod.traits.has(t))return;a._zod.traits.add(t),e(a,l);const c=o.prototype,d=Object.keys(c);for(let f=0;f<d.length;f++){const y=d[f];y in a||(a[y]=c[y].bind(a))}}const s=(n==null?void 0:n.Parent)??Object;class i extends s{}Object.defineProperty(i,"name",{value:t});function o(a){var l;const c=n!=null&&n.Parent?new i:this;r(c,a),(l=c._zod).deferred??(l.deferred=[]);for(const d of c._zod.deferred)d();return c}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:a=>{var l,c;return n!=null&&n.Parent&&a instanceof n.Parent?!0:(c=(l=a==null?void 0:a._zod)==null?void 0:l.traits)==null?void 0:c.has(t)}}),Object.defineProperty(o,"name",{value:t}),o}class wr extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class zp extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}}const Lp={};function an(t){return Lp}function Mp(t){const e=Object.values(t).filter(r=>typeof r=="number");return Object.entries(t).filter(([r,s])=>e.indexOf(+r)===-1).map(([r,s])=>s)}function ml(t,e){return typeof e=="bigint"?e.toString():e}function $c(t){return{get value(){{const e=t();return Object.defineProperty(this,"value",{value:e}),e}}}}function Ac(t){return t==null}function xc(t){const e=t.startsWith("^")?1:0,n=t.endsWith("$")?t.length-1:t.length;return t.slice(e,n)}function WE(t,e){const n=(t.toString().split(".")[1]||"").length,r=e.toString();let s=(r.split(".")[1]||"").length;if(s===0&&/\d?e-\d?/.test(r)){const l=r.match(/\d?e-(\d?)/);l!=null&&l[1]&&(s=Number.parseInt(l[1]))}const i=n>s?n:s,o=Number.parseInt(t.toFixed(i).replace(".","")),a=Number.parseInt(e.toFixed(i).replace(".",""));return o%a/10**i}const Xh=Symbol("evaluating");function ee(t,e,n){let r;Object.defineProperty(t,e,{get(){if(r!==Xh)return r===void 0&&(r=Xh,r=n()),r},set(s){Object.defineProperty(t,e,{value:s})},configurable:!0})}function Yn(t,e,n){Object.defineProperty(t,e,{value:n,writable:!0,enumerable:!0,configurable:!0})}function fn(...t){const e={};for(const n of t){const r=Object.getOwnPropertyDescriptors(n);Object.assign(e,r)}return Object.defineProperties({},e)}function Qh(t){return JSON.stringify(t)}function BE(t){return t.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Np="captureStackTrace"in Error?Error.captureStackTrace:(...t)=>{};function mo(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}const VE=$c(()=>{var t;if(typeof navigator<"u"&&((t=navigator==null?void 0:navigator.userAgent)!=null&&t.includes("Cloudflare")))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function Or(t){if(mo(t)===!1)return!1;const e=t.constructor;if(e===void 0||typeof e!="function")return!0;const n=e.prototype;return!(mo(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function Up(t){return Or(t)?{...t}:Array.isArray(t)?[...t]:t}const HE=new Set(["string","number","symbol"]);function zr(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function pn(t,e,n){const r=new t._zod.constr(e??t._zod.def);return(!e||n!=null&&n.parent)&&(r._zod.parent=t),r}function D(t){const e=t;if(!e)return{};if(typeof e=="string")return{error:()=>e};if((e==null?void 0:e.message)!==void 0){if((e==null?void 0:e.error)!==void 0)throw new Error("Cannot specify both `message` and `error` params");e.error=e.message}return delete e.message,typeof e.error=="string"?{...e,error:()=>e.error}:e}function GE(t){return Object.keys(t).filter(e=>t[e]._zod.optin==="optional"&&t[e]._zod.optout==="optional")}const qE={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function YE(t,e){const n=t._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const i=fn(t._zod.def,{get shape(){const o={};for(const a in e){if(!(a in n.shape))throw new Error(`Unrecognized key: "${a}"`);e[a]&&(o[a]=n.shape[a])}return Yn(this,"shape",o),o},checks:[]});return pn(t,i)}function KE(t,e){const n=t._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const i=fn(t._zod.def,{get shape(){const o={...t._zod.def.shape};for(const a in e){if(!(a in n.shape))throw new Error(`Unrecognized key: "${a}"`);e[a]&&delete o[a]}return Yn(this,"shape",o),o},checks:[]});return pn(t,i)}function JE(t,e){if(!Or(e))throw new Error("Invalid input to extend: expected a plain object");const n=t._zod.def.checks;if(n&&n.length>0){const i=t._zod.def.shape;for(const o in e)if(Object.getOwnPropertyDescriptor(i,o)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const s=fn(t._zod.def,{get shape(){const i={...t._zod.def.shape,...e};return Yn(this,"shape",i),i}});return pn(t,s)}function XE(t,e){if(!Or(e))throw new Error("Invalid input to safeExtend: expected a plain object");const n=fn(t._zod.def,{get shape(){const r={...t._zod.def.shape,...e};return Yn(this,"shape",r),r}});return pn(t,n)}function QE(t,e){const n=fn(t._zod.def,{get shape(){const r={...t._zod.def.shape,...e._zod.def.shape};return Yn(this,"shape",r),r},get catchall(){return e._zod.def.catchall},checks:[]});return pn(t,n)}function e0(t,e,n){const s=e._zod.def.checks;if(s&&s.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const o=fn(e._zod.def,{get shape(){const a=e._zod.def.shape,l={...a};if(n)for(const c in n){if(!(c in a))throw new Error(`Unrecognized key: "${c}"`);n[c]&&(l[c]=t?new t({type:"optional",innerType:a[c]}):a[c])}else for(const c in a)l[c]=t?new t({type:"optional",innerType:a[c]}):a[c];return Yn(this,"shape",l),l},checks:[]});return pn(e,o)}function t0(t,e,n){const r=fn(e._zod.def,{get shape(){const s=e._zod.def.shape,i={...s};if(n)for(const o in n){if(!(o in i))throw new Error(`Unrecognized key: "${o}"`);n[o]&&(i[o]=new t({type:"nonoptional",innerType:s[o]}))}else for(const o in s)i[o]=new t({type:"nonoptional",innerType:s[o]});return Yn(this,"shape",i),i}});return pn(e,r)}function vr(t,e=0){var n;if(t.aborted===!0)return!0;for(let r=e;r<t.issues.length;r++)if(((n=t.issues[r])==null?void 0:n.continue)!==!0)return!0;return!1}function yr(t,e){return e.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(t),n})}function Mi(t){return typeof t=="string"?t:t==null?void 0:t.message}function ln(t,e,n){var s,i,o,a,l,c;const r={...t,path:t.path??[]};if(!t.message){const d=Mi((o=(i=(s=t.inst)==null?void 0:s._zod.def)==null?void 0:i.error)==null?void 0:o.call(i,t))??Mi((a=e==null?void 0:e.error)==null?void 0:a.call(e,t))??Mi((l=n.customError)==null?void 0:l.call(n,t))??Mi((c=n.localeError)==null?void 0:c.call(n,t))??"Invalid input";r.message=d}return delete r.inst,delete r.continue,e!=null&&e.reportInput||delete r.input,r}function Cc(t){return Array.isArray(t)?"array":typeof t=="string"?"string":"unknown"}function Cs(...t){const[e,n,r]=t;return typeof e=="string"?{message:e,code:"custom",input:n,inst:r}:{...e}}const Fp=(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,ml,2),Object.defineProperty(t,"toString",{value:()=>t.message,enumerable:!1})},Zp=S("$ZodError",Fp),jp=S("$ZodError",Fp,{Parent:Error});function n0(t,e=n=>n.message){const n={},r=[];for(const s of t.issues)s.path.length>0?(n[s.path[0]]=n[s.path[0]]||[],n[s.path[0]].push(e(s))):r.push(e(s));return{formErrors:r,fieldErrors:n}}function r0(t,e=n=>n.message){const n={_errors:[]},r=s=>{for(const i of s.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(o=>r({issues:o}));else if(i.code==="invalid_key")r({issues:i.issues});else if(i.code==="invalid_element")r({issues:i.issues});else if(i.path.length===0)n._errors.push(e(i));else{let o=n,a=0;for(;a<i.path.length;){const l=i.path[a];a===i.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(e(i))):o[l]=o[l]||{_errors:[]},o=o[l],a++}}};return r(t),n}const Tc=t=>(e,n,r,s)=>{const i=r?Object.assign(r,{async:!1}):{async:!1},o=e._zod.run({value:n,issues:[]},i);if(o instanceof Promise)throw new wr;if(o.issues.length){const a=new((s==null?void 0:s.Err)??t)(o.issues.map(l=>ln(l,i,an())));throw Np(a,s==null?void 0:s.callee),a}return o.value},Ic=t=>async(e,n,r,s)=>{const i=r?Object.assign(r,{async:!0}):{async:!0};let o=e._zod.run({value:n,issues:[]},i);if(o instanceof Promise&&(o=await o),o.issues.length){const a=new((s==null?void 0:s.Err)??t)(o.issues.map(l=>ln(l,i,an())));throw Np(a,s==null?void 0:s.callee),a}return o.value},Wo=t=>(e,n,r)=>{const s=r?{...r,async:!1}:{async:!1},i=e._zod.run({value:n,issues:[]},s);if(i instanceof Promise)throw new wr;return i.issues.length?{success:!1,error:new(t??Zp)(i.issues.map(o=>ln(o,s,an())))}:{success:!0,data:i.value}},s0=Wo(jp),Bo=t=>async(e,n,r)=>{const s=r?Object.assign(r,{async:!0}):{async:!0};let i=e._zod.run({value:n,issues:[]},s);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new t(i.issues.map(o=>ln(o,s,an())))}:{success:!0,data:i.value}},i0=Bo(jp),o0=t=>(e,n,r)=>{const s=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Tc(t)(e,n,s)},a0=t=>(e,n,r)=>Tc(t)(e,n,r),l0=t=>async(e,n,r)=>{const s=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Ic(t)(e,n,s)},c0=t=>async(e,n,r)=>Ic(t)(e,n,r),u0=t=>(e,n,r)=>{const s=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Wo(t)(e,n,s)},h0=t=>(e,n,r)=>Wo(t)(e,n,r),d0=t=>async(e,n,r)=>{const s=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Bo(t)(e,n,s)},f0=t=>async(e,n,r)=>Bo(t)(e,n,r),p0=/^[cC][^\s-]{8,}$/,g0=/^[0-9a-z]+$/,m0=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,v0=/^[0-9a-vA-V]{20}$/,y0=/^[A-Za-z0-9]{27}$/,b0=/^[a-zA-Z0-9_-]{21}$/,w0=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,_0=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,ed=t=>t?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${t}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,S0=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,k0="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function E0(){return new RegExp(k0,"u")}const $0=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,A0=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,x0=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,C0=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,T0=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Wp=/^[A-Za-z0-9_-]*$/,I0=/^\+[1-9]\d{6,14}$/,Bp="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",P0=new RegExp(`^${Bp}$`);function Vp(t){const e="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof t.precision=="number"?t.precision===-1?`${e}`:t.precision===0?`${e}:[0-5]\\d`:`${e}:[0-5]\\d\\.\\d{${t.precision}}`:`${e}(?::[0-5]\\d(?:\\.\\d+)?)?`}function R0(t){return new RegExp(`^${Vp(t)}$`)}function D0(t){const e=Vp({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(`^${Bp}T(?:${r})$`)}const O0=t=>{const e=t?`[\\s\\S]{${(t==null?void 0:t.minimum)??0},${(t==null?void 0:t.maximum)??""}}`:"[\\s\\S]*";return new RegExp(`^${e}$`)},z0=/^-?\d+$/,Hp=/^-?\d+(?:\.\d+)?$/,L0=/^(?:true|false)$/i,M0=/^[^A-Z]*$/,N0=/^[^a-z]*$/,Ve=S("$ZodCheck",(t,e)=>{var n;t._zod??(t._zod={}),t._zod.def=e,(n=t._zod).onattach??(n.onattach=[])}),Gp={number:"number",bigint:"bigint",object:"date"},qp=S("$ZodCheckLessThan",(t,e)=>{Ve.init(t,e);const n=Gp[typeof e.value];t._zod.onattach.push(r=>{const s=r._zod.bag,i=(e.inclusive?s.maximum:s.exclusiveMaximum)??Number.POSITIVE_INFINITY;e.value<i&&(e.inclusive?s.maximum=e.value:s.exclusiveMaximum=e.value)}),t._zod.check=r=>{(e.inclusive?r.value<=e.value:r.value<e.value)||r.issues.push({origin:n,code:"too_big",maximum:typeof e.value=="object"?e.value.getTime():e.value,input:r.value,inclusive:e.inclusive,inst:t,continue:!e.abort})}}),Yp=S("$ZodCheckGreaterThan",(t,e)=>{Ve.init(t,e);const n=Gp[typeof e.value];t._zod.onattach.push(r=>{const s=r._zod.bag,i=(e.inclusive?s.minimum:s.exclusiveMinimum)??Number.NEGATIVE_INFINITY;e.value>i&&(e.inclusive?s.minimum=e.value:s.exclusiveMinimum=e.value)}),t._zod.check=r=>{(e.inclusive?r.value>=e.value:r.value>e.value)||r.issues.push({origin:n,code:"too_small",minimum:typeof e.value=="object"?e.value.getTime():e.value,input:r.value,inclusive:e.inclusive,inst:t,continue:!e.abort})}}),U0=S("$ZodCheckMultipleOf",(t,e)=>{Ve.init(t,e),t._zod.onattach.push(n=>{var r;(r=n._zod.bag).multipleOf??(r.multipleOf=e.value)}),t._zod.check=n=>{if(typeof n.value!=typeof e.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%e.value===BigInt(0):WE(n.value,e.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:e.value,input:n.value,inst:t,continue:!e.abort})}}),F0=S("$ZodCheckNumberFormat",(t,e)=>{var o;Ve.init(t,e),e.format=e.format||"float64";const n=(o=e.format)==null?void 0:o.includes("int"),r=n?"int":"number",[s,i]=qE[e.format];t._zod.onattach.push(a=>{const l=a._zod.bag;l.format=e.format,l.minimum=s,l.maximum=i,n&&(l.pattern=z0)}),t._zod.check=a=>{const l=a.value;if(n){if(!Number.isInteger(l)){a.issues.push({expected:r,format:e.format,code:"invalid_type",continue:!1,input:l,inst:t});return}if(!Number.isSafeInteger(l)){l>0?a.issues.push({input:l,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:r,inclusive:!0,continue:!e.abort}):a.issues.push({input:l,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:r,inclusive:!0,continue:!e.abort});return}}l<s&&a.issues.push({origin:"number",input:l,code:"too_small",minimum:s,inclusive:!0,inst:t,continue:!e.abort}),l>i&&a.issues.push({origin:"number",input:l,code:"too_big",maximum:i,inclusive:!0,inst:t,continue:!e.abort})}}),Z0=S("$ZodCheckMaxLength",(t,e)=>{var n;Ve.init(t,e),(n=t._zod.def).when??(n.when=r=>{const s=r.value;return!Ac(s)&&s.length!==void 0}),t._zod.onattach.push(r=>{const s=r._zod.bag.maximum??Number.POSITIVE_INFINITY;e.maximum<s&&(r._zod.bag.maximum=e.maximum)}),t._zod.check=r=>{const s=r.value;if(s.length<=e.maximum)return;const o=Cc(s);r.issues.push({origin:o,code:"too_big",maximum:e.maximum,inclusive:!0,input:s,inst:t,continue:!e.abort})}}),j0=S("$ZodCheckMinLength",(t,e)=>{var n;Ve.init(t,e),(n=t._zod.def).when??(n.when=r=>{const s=r.value;return!Ac(s)&&s.length!==void 0}),t._zod.onattach.push(r=>{const s=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;e.minimum>s&&(r._zod.bag.minimum=e.minimum)}),t._zod.check=r=>{const s=r.value;if(s.length>=e.minimum)return;const o=Cc(s);r.issues.push({origin:o,code:"too_small",minimum:e.minimum,inclusive:!0,input:s,inst:t,continue:!e.abort})}}),W0=S("$ZodCheckLengthEquals",(t,e)=>{var n;Ve.init(t,e),(n=t._zod.def).when??(n.when=r=>{const s=r.value;return!Ac(s)&&s.length!==void 0}),t._zod.onattach.push(r=>{const s=r._zod.bag;s.minimum=e.length,s.maximum=e.length,s.length=e.length}),t._zod.check=r=>{const s=r.value,i=s.length;if(i===e.length)return;const o=Cc(s),a=i>e.length;r.issues.push({origin:o,...a?{code:"too_big",maximum:e.length}:{code:"too_small",minimum:e.length},inclusive:!0,exact:!0,input:r.value,inst:t,continue:!e.abort})}}),Vo=S("$ZodCheckStringFormat",(t,e)=>{var n,r;Ve.init(t,e),t._zod.onattach.push(s=>{const i=s._zod.bag;i.format=e.format,e.pattern&&(i.patterns??(i.patterns=new Set),i.patterns.add(e.pattern))}),e.pattern?(n=t._zod).check??(n.check=s=>{e.pattern.lastIndex=0,!e.pattern.test(s.value)&&s.issues.push({origin:"string",code:"invalid_format",format:e.format,input:s.value,...e.pattern?{pattern:e.pattern.toString()}:{},inst:t,continue:!e.abort})}):(r=t._zod).check??(r.check=()=>{})}),B0=S("$ZodCheckRegex",(t,e)=>{Vo.init(t,e),t._zod.check=n=>{e.pattern.lastIndex=0,!e.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:e.pattern.toString(),inst:t,continue:!e.abort})}}),V0=S("$ZodCheckLowerCase",(t,e)=>{e.pattern??(e.pattern=M0),Vo.init(t,e)}),H0=S("$ZodCheckUpperCase",(t,e)=>{e.pattern??(e.pattern=N0),Vo.init(t,e)}),G0=S("$ZodCheckIncludes",(t,e)=>{Ve.init(t,e);const n=zr(e.includes),r=new RegExp(typeof e.position=="number"?`^.{${e.position}}${n}`:n);e.pattern=r,t._zod.onattach.push(s=>{const i=s._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(r)}),t._zod.check=s=>{s.value.includes(e.includes,e.position)||s.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:e.includes,input:s.value,inst:t,continue:!e.abort})}}),q0=S("$ZodCheckStartsWith",(t,e)=>{Ve.init(t,e);const n=new RegExp(`^${zr(e.prefix)}.*`);e.pattern??(e.pattern=n),t._zod.onattach.push(r=>{const s=r._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(n)}),t._zod.check=r=>{r.value.startsWith(e.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:e.prefix,input:r.value,inst:t,continue:!e.abort})}}),Y0=S("$ZodCheckEndsWith",(t,e)=>{Ve.init(t,e);const n=new RegExp(`.*${zr(e.suffix)}$`);e.pattern??(e.pattern=n),t._zod.onattach.push(r=>{const s=r._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(n)}),t._zod.check=r=>{r.value.endsWith(e.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:e.suffix,input:r.value,inst:t,continue:!e.abort})}}),K0=S("$ZodCheckOverwrite",(t,e)=>{Ve.init(t,e),t._zod.check=n=>{n.value=e.tx(n.value)}});class J0{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if(typeof e=="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}const r=e.split(`
|
|
5
|
-
`).filter(o=>o),s=Math.min(...r.map(o=>o.length-o.trimStart().length)),i=r.map(o=>o.slice(s)).map(o=>" ".repeat(this.indent*2)+o);for(const o of i)this.content.push(o)}compile(){const e=Function,n=this==null?void 0:this.args,s=[...((this==null?void 0:this.content)??[""]).map(i=>` ${i}`)];return new e(...n,s.join(`
|
|
6
|
-
`))}}const X0={major:4,minor:3,patch:6},le=S("$ZodType",(t,e)=>{var s;var n;t??(t={}),t._zod.def=e,t._zod.bag=t._zod.bag||{},t._zod.version=X0;const r=[...t._zod.def.checks??[]];t._zod.traits.has("$ZodCheck")&&r.unshift(t);for(const i of r)for(const o of i._zod.onattach)o(t);if(r.length===0)(n=t._zod).deferred??(n.deferred=[]),(s=t._zod.deferred)==null||s.push(()=>{t._zod.run=t._zod.parse});else{const i=(a,l,c)=>{let d=vr(a),f;for(const y of l){if(y._zod.def.when){if(!y._zod.def.when(a))continue}else if(d)continue;const m=a.issues.length,E=y._zod.check(a);if(E instanceof Promise&&(c==null?void 0:c.async)===!1)throw new wr;if(f||E instanceof Promise)f=(f??Promise.resolve()).then(async()=>{await E,a.issues.length!==m&&(d||(d=vr(a,m)))});else{if(a.issues.length===m)continue;d||(d=vr(a,m))}}return f?f.then(()=>a):a},o=(a,l,c)=>{if(vr(a))return a.aborted=!0,a;const d=i(l,r,c);if(d instanceof Promise){if(c.async===!1)throw new wr;return d.then(f=>t._zod.parse(f,c))}return t._zod.parse(d,c)};t._zod.run=(a,l)=>{if(l.skipChecks)return t._zod.parse(a,l);if(l.direction==="backward"){const d=t._zod.parse({value:a.value,issues:[]},{...l,skipChecks:!0});return d instanceof Promise?d.then(f=>o(f,a,l)):o(d,a,l)}const c=t._zod.parse(a,l);if(c instanceof Promise){if(l.async===!1)throw new wr;return c.then(d=>i(d,r,l))}return i(c,r,l)}}ee(t,"~standard",()=>({validate:i=>{var o;try{const a=s0(t,i);return a.success?{value:a.data}:{issues:(o=a.error)==null?void 0:o.issues}}catch{return i0(t,i).then(l=>{var c;return l.success?{value:l.data}:{issues:(c=l.error)==null?void 0:c.issues}})}},vendor:"zod",version:1}))}),Pc=S("$ZodString",(t,e)=>{var n;le.init(t,e),t._zod.pattern=[...((n=t==null?void 0:t._zod.bag)==null?void 0:n.patterns)??[]].pop()??O0(t._zod.bag),t._zod.parse=(r,s)=>{if(e.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:t}),r}}),oe=S("$ZodStringFormat",(t,e)=>{Vo.init(t,e),Pc.init(t,e)}),Q0=S("$ZodGUID",(t,e)=>{e.pattern??(e.pattern=_0),oe.init(t,e)}),e$=S("$ZodUUID",(t,e)=>{if(e.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[e.version];if(r===void 0)throw new Error(`Invalid UUID version: "${e.version}"`);e.pattern??(e.pattern=ed(r))}else e.pattern??(e.pattern=ed());oe.init(t,e)}),t$=S("$ZodEmail",(t,e)=>{e.pattern??(e.pattern=S0),oe.init(t,e)}),n$=S("$ZodURL",(t,e)=>{oe.init(t,e),t._zod.check=n=>{try{const r=n.value.trim(),s=new URL(r);e.hostname&&(e.hostname.lastIndex=0,e.hostname.test(s.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:e.hostname.source,input:n.value,inst:t,continue:!e.abort})),e.protocol&&(e.protocol.lastIndex=0,e.protocol.test(s.protocol.endsWith(":")?s.protocol.slice(0,-1):s.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:e.protocol.source,input:n.value,inst:t,continue:!e.abort})),e.normalize?n.value=s.href:n.value=r;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:t,continue:!e.abort})}}}),r$=S("$ZodEmoji",(t,e)=>{e.pattern??(e.pattern=E0()),oe.init(t,e)}),s$=S("$ZodNanoID",(t,e)=>{e.pattern??(e.pattern=b0),oe.init(t,e)}),i$=S("$ZodCUID",(t,e)=>{e.pattern??(e.pattern=p0),oe.init(t,e)}),o$=S("$ZodCUID2",(t,e)=>{e.pattern??(e.pattern=g0),oe.init(t,e)}),a$=S("$ZodULID",(t,e)=>{e.pattern??(e.pattern=m0),oe.init(t,e)}),l$=S("$ZodXID",(t,e)=>{e.pattern??(e.pattern=v0),oe.init(t,e)}),c$=S("$ZodKSUID",(t,e)=>{e.pattern??(e.pattern=y0),oe.init(t,e)}),u$=S("$ZodISODateTime",(t,e)=>{e.pattern??(e.pattern=D0(e)),oe.init(t,e)}),h$=S("$ZodISODate",(t,e)=>{e.pattern??(e.pattern=P0),oe.init(t,e)}),d$=S("$ZodISOTime",(t,e)=>{e.pattern??(e.pattern=R0(e)),oe.init(t,e)}),f$=S("$ZodISODuration",(t,e)=>{e.pattern??(e.pattern=w0),oe.init(t,e)}),p$=S("$ZodIPv4",(t,e)=>{e.pattern??(e.pattern=$0),oe.init(t,e),t._zod.bag.format="ipv4"}),g$=S("$ZodIPv6",(t,e)=>{e.pattern??(e.pattern=A0),oe.init(t,e),t._zod.bag.format="ipv6",t._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:t,continue:!e.abort})}}}),m$=S("$ZodCIDRv4",(t,e)=>{e.pattern??(e.pattern=x0),oe.init(t,e)}),v$=S("$ZodCIDRv6",(t,e)=>{e.pattern??(e.pattern=C0),oe.init(t,e),t._zod.check=n=>{const r=n.value.split("/");try{if(r.length!==2)throw new Error;const[s,i]=r;if(!i)throw new Error;const o=Number(i);if(`${o}`!==i)throw new Error;if(o<0||o>128)throw new Error;new URL(`http://[${s}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:t,continue:!e.abort})}}});function Kp(t){if(t==="")return!0;if(t.length%4!==0)return!1;try{return atob(t),!0}catch{return!1}}const y$=S("$ZodBase64",(t,e)=>{e.pattern??(e.pattern=T0),oe.init(t,e),t._zod.bag.contentEncoding="base64",t._zod.check=n=>{Kp(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:t,continue:!e.abort})}});function b$(t){if(!Wp.test(t))return!1;const e=t.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=e.padEnd(Math.ceil(e.length/4)*4,"=");return Kp(n)}const w$=S("$ZodBase64URL",(t,e)=>{e.pattern??(e.pattern=Wp),oe.init(t,e),t._zod.bag.contentEncoding="base64url",t._zod.check=n=>{b$(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:t,continue:!e.abort})}}),_$=S("$ZodE164",(t,e)=>{e.pattern??(e.pattern=I0),oe.init(t,e)});function S$(t,e=null){try{const n=t.split(".");if(n.length!==3)return!1;const[r]=n;if(!r)return!1;const s=JSON.parse(atob(r));return!("typ"in s&&(s==null?void 0:s.typ)!=="JWT"||!s.alg||e&&(!("alg"in s)||s.alg!==e))}catch{return!1}}const k$=S("$ZodJWT",(t,e)=>{oe.init(t,e),t._zod.check=n=>{S$(n.value,e.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:t,continue:!e.abort})}}),Jp=S("$ZodNumber",(t,e)=>{le.init(t,e),t._zod.pattern=t._zod.bag.pattern??Hp,t._zod.parse=(n,r)=>{if(e.coerce)try{n.value=Number(n.value)}catch{}const s=n.value;if(typeof s=="number"&&!Number.isNaN(s)&&Number.isFinite(s))return n;const i=typeof s=="number"?Number.isNaN(s)?"NaN":Number.isFinite(s)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:s,inst:t,...i?{received:i}:{}}),n}}),E$=S("$ZodNumberFormat",(t,e)=>{F0.init(t,e),Jp.init(t,e)}),$$=S("$ZodBoolean",(t,e)=>{le.init(t,e),t._zod.pattern=L0,t._zod.parse=(n,r)=>{if(e.coerce)try{n.value=!!n.value}catch{}const s=n.value;return typeof s=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:s,inst:t}),n}}),A$=S("$ZodUnknown",(t,e)=>{le.init(t,e),t._zod.parse=n=>n}),x$=S("$ZodNever",(t,e)=>{le.init(t,e),t._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:t}),n)});function td(t,e,n){t.issues.length&&e.issues.push(...yr(n,t.issues)),e.value[n]=t.value}const C$=S("$ZodArray",(t,e)=>{le.init(t,e),t._zod.parse=(n,r)=>{const s=n.value;if(!Array.isArray(s))return n.issues.push({expected:"array",code:"invalid_type",input:s,inst:t}),n;n.value=Array(s.length);const i=[];for(let o=0;o<s.length;o++){const a=s[o],l=e.element._zod.run({value:a,issues:[]},r);l instanceof Promise?i.push(l.then(c=>td(c,n,o))):td(l,n,o)}return i.length?Promise.all(i).then(()=>n):n}});function vo(t,e,n,r,s){if(t.issues.length){if(s&&!(n in r))return;e.issues.push(...yr(n,t.issues))}t.value===void 0?n in r&&(e.value[n]=void 0):e.value[n]=t.value}function Xp(t){var r,s,i,o;const e=Object.keys(t.shape);for(const a of e)if(!((o=(i=(s=(r=t.shape)==null?void 0:r[a])==null?void 0:s._zod)==null?void 0:i.traits)!=null&&o.has("$ZodType")))throw new Error(`Invalid element at key "${a}": expected a Zod schema`);const n=GE(t.shape);return{...t,keys:e,keySet:new Set(e),numKeys:e.length,optionalKeys:new Set(n)}}function Qp(t,e,n,r,s,i){const o=[],a=s.keySet,l=s.catchall._zod,c=l.def.type,d=l.optout==="optional";for(const f in e){if(a.has(f))continue;if(c==="never"){o.push(f);continue}const y=l.run({value:e[f],issues:[]},r);y instanceof Promise?t.push(y.then(m=>vo(m,n,f,e,d))):vo(y,n,f,e,d)}return o.length&&n.issues.push({code:"unrecognized_keys",keys:o,input:e,inst:i}),t.length?Promise.all(t).then(()=>n):n}const T$=S("$ZodObject",(t,e)=>{le.init(t,e);const n=Object.getOwnPropertyDescriptor(e,"shape");if(!(n!=null&&n.get)){const a=e.shape;Object.defineProperty(e,"shape",{get:()=>{const l={...a};return Object.defineProperty(e,"shape",{value:l}),l}})}const r=$c(()=>Xp(e));ee(t._zod,"propValues",()=>{const a=e.shape,l={};for(const c in a){const d=a[c]._zod;if(d.values){l[c]??(l[c]=new Set);for(const f of d.values)l[c].add(f)}}return l});const s=mo,i=e.catchall;let o;t._zod.parse=(a,l)=>{o??(o=r.value);const c=a.value;if(!s(c))return a.issues.push({expected:"object",code:"invalid_type",input:c,inst:t}),a;a.value={};const d=[],f=o.shape;for(const y of o.keys){const m=f[y],E=m._zod.optout==="optional",k=m._zod.run({value:c[y],issues:[]},l);k instanceof Promise?d.push(k.then(I=>vo(I,a,y,c,E))):vo(k,a,y,c,E)}return i?Qp(d,c,a,l,r.value,t):d.length?Promise.all(d).then(()=>a):a}}),I$=S("$ZodObjectJIT",(t,e)=>{T$.init(t,e);const n=t._zod.parse,r=$c(()=>Xp(e)),s=y=>{var j;const m=new J0(["shape","payload","ctx"]),E=r.value,k=F=>{const L=Qh(F);return`shape[${L}]._zod.run({ value: input[${L}], issues: [] }, ctx)`};m.write("const input = payload.value;");const I=Object.create(null);let V=0;for(const F of E.keys)I[F]=`key_${V++}`;m.write("const newResult = {};");for(const F of E.keys){const L=I[F],J=Qh(F),G=y[F],he=((j=G==null?void 0:G._zod)==null?void 0:j.optout)==="optional";m.write(`const ${L} = ${k(F)};`),he?m.write(`
|
|
7
|
-
if (${L}.issues.length) {
|
|
8
|
-
if (${J} in input) {
|
|
9
|
-
payload.issues = payload.issues.concat(${L}.issues.map(iss => ({
|
|
10
|
-
...iss,
|
|
11
|
-
path: iss.path ? [${J}, ...iss.path] : [${J}]
|
|
12
|
-
})));
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
if (${L}.value === undefined) {
|
|
17
|
-
if (${J} in input) {
|
|
18
|
-
newResult[${J}] = undefined;
|
|
19
|
-
}
|
|
20
|
-
} else {
|
|
21
|
-
newResult[${J}] = ${L}.value;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
`):m.write(`
|
|
25
|
-
if (${L}.issues.length) {
|
|
26
|
-
payload.issues = payload.issues.concat(${L}.issues.map(iss => ({
|
|
27
|
-
...iss,
|
|
28
|
-
path: iss.path ? [${J}, ...iss.path] : [${J}]
|
|
29
|
-
})));
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if (${L}.value === undefined) {
|
|
33
|
-
if (${J} in input) {
|
|
34
|
-
newResult[${J}] = undefined;
|
|
35
|
-
}
|
|
36
|
-
} else {
|
|
37
|
-
newResult[${J}] = ${L}.value;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
`)}m.write("payload.value = newResult;"),m.write("return payload;");const N=m.compile();return(F,L)=>N(y,F,L)};let i;const o=mo,a=!Lp.jitless,c=a&&VE.value,d=e.catchall;let f;t._zod.parse=(y,m)=>{f??(f=r.value);const E=y.value;return o(E)?a&&c&&(m==null?void 0:m.async)===!1&&m.jitless!==!0?(i||(i=s(e.shape)),y=i(y,m),d?Qp([],E,y,m,f,t):y):n(y,m):(y.issues.push({expected:"object",code:"invalid_type",input:E,inst:t}),y)}});function nd(t,e,n,r){for(const i of t)if(i.issues.length===0)return e.value=i.value,e;const s=t.filter(i=>!vr(i));return s.length===1?(e.value=s[0].value,s[0]):(e.issues.push({code:"invalid_union",input:e.value,inst:n,errors:t.map(i=>i.issues.map(o=>ln(o,r,an())))}),e)}const P$=S("$ZodUnion",(t,e)=>{le.init(t,e),ee(t._zod,"optin",()=>e.options.some(s=>s._zod.optin==="optional")?"optional":void 0),ee(t._zod,"optout",()=>e.options.some(s=>s._zod.optout==="optional")?"optional":void 0),ee(t._zod,"values",()=>{if(e.options.every(s=>s._zod.values))return new Set(e.options.flatMap(s=>Array.from(s._zod.values)))}),ee(t._zod,"pattern",()=>{if(e.options.every(s=>s._zod.pattern)){const s=e.options.map(i=>i._zod.pattern);return new RegExp(`^(${s.map(i=>xc(i.source)).join("|")})$`)}});const n=e.options.length===1,r=e.options[0]._zod.run;t._zod.parse=(s,i)=>{if(n)return r(s,i);let o=!1;const a=[];for(const l of e.options){const c=l._zod.run({value:s.value,issues:[]},i);if(c instanceof Promise)a.push(c),o=!0;else{if(c.issues.length===0)return c;a.push(c)}}return o?Promise.all(a).then(l=>nd(l,s,t,i)):nd(a,s,t,i)}}),R$=S("$ZodIntersection",(t,e)=>{le.init(t,e),t._zod.parse=(n,r)=>{const s=n.value,i=e.left._zod.run({value:s,issues:[]},r),o=e.right._zod.run({value:s,issues:[]},r);return i instanceof Promise||o instanceof Promise?Promise.all([i,o]).then(([l,c])=>rd(n,l,c)):rd(n,i,o)}});function vl(t,e){if(t===e)return{valid:!0,data:t};if(t instanceof Date&&e instanceof Date&&+t==+e)return{valid:!0,data:t};if(Or(t)&&Or(e)){const n=Object.keys(e),r=Object.keys(t).filter(i=>n.indexOf(i)!==-1),s={...t,...e};for(const i of r){const o=vl(t[i],e[i]);if(!o.valid)return{valid:!1,mergeErrorPath:[i,...o.mergeErrorPath]};s[i]=o.data}return{valid:!0,data:s}}if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<t.length;r++){const s=t[r],i=e[r],o=vl(s,i);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function rd(t,e,n){const r=new Map;let s;for(const a of e.issues)if(a.code==="unrecognized_keys"){s??(s=a);for(const l of a.keys)r.has(l)||r.set(l,{}),r.get(l).l=!0}else t.issues.push(a);for(const a of n.issues)if(a.code==="unrecognized_keys")for(const l of a.keys)r.has(l)||r.set(l,{}),r.get(l).r=!0;else t.issues.push(a);const i=[...r].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(i.length&&s&&t.issues.push({...s,keys:i}),vr(t))return t;const o=vl(e.value,n.value);if(!o.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return t.value=o.data,t}const D$=S("$ZodRecord",(t,e)=>{le.init(t,e),t._zod.parse=(n,r)=>{const s=n.value;if(!Or(s))return n.issues.push({expected:"record",code:"invalid_type",input:s,inst:t}),n;const i=[],o=e.keyType._zod.values;if(o){n.value={};const a=new Set;for(const c of o)if(typeof c=="string"||typeof c=="number"||typeof c=="symbol"){a.add(typeof c=="number"?c.toString():c);const d=e.valueType._zod.run({value:s[c],issues:[]},r);d instanceof Promise?i.push(d.then(f=>{f.issues.length&&n.issues.push(...yr(c,f.issues)),n.value[c]=f.value})):(d.issues.length&&n.issues.push(...yr(c,d.issues)),n.value[c]=d.value)}let l;for(const c in s)a.has(c)||(l=l??[],l.push(c));l&&l.length>0&&n.issues.push({code:"unrecognized_keys",input:s,inst:t,keys:l})}else{n.value={};for(const a of Reflect.ownKeys(s)){if(a==="__proto__")continue;let l=e.keyType._zod.run({value:a,issues:[]},r);if(l instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof a=="string"&&Hp.test(a)&&l.issues.length){const f=e.keyType._zod.run({value:Number(a),issues:[]},r);if(f instanceof Promise)throw new Error("Async schemas not supported in object keys currently");f.issues.length===0&&(l=f)}if(l.issues.length){e.mode==="loose"?n.value[a]=s[a]:n.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map(f=>ln(f,r,an())),input:a,path:[a],inst:t});continue}const d=e.valueType._zod.run({value:s[a],issues:[]},r);d instanceof Promise?i.push(d.then(f=>{f.issues.length&&n.issues.push(...yr(a,f.issues)),n.value[l.value]=f.value})):(d.issues.length&&n.issues.push(...yr(a,d.issues)),n.value[l.value]=d.value)}}return i.length?Promise.all(i).then(()=>n):n}}),O$=S("$ZodEnum",(t,e)=>{le.init(t,e);const n=Mp(e.entries),r=new Set(n);t._zod.values=r,t._zod.pattern=new RegExp(`^(${n.filter(s=>HE.has(typeof s)).map(s=>typeof s=="string"?zr(s):s.toString()).join("|")})$`),t._zod.parse=(s,i)=>{const o=s.value;return r.has(o)||s.issues.push({code:"invalid_value",values:n,input:o,inst:t}),s}}),z$=S("$ZodLiteral",(t,e)=>{if(le.init(t,e),e.values.length===0)throw new Error("Cannot create literal schema with no valid values");const n=new Set(e.values);t._zod.values=n,t._zod.pattern=new RegExp(`^(${e.values.map(r=>typeof r=="string"?zr(r):r?zr(r.toString()):String(r)).join("|")})$`),t._zod.parse=(r,s)=>{const i=r.value;return n.has(i)||r.issues.push({code:"invalid_value",values:e.values,input:i,inst:t}),r}}),L$=S("$ZodTransform",(t,e)=>{le.init(t,e),t._zod.parse=(n,r)=>{if(r.direction==="backward")throw new zp(t.constructor.name);const s=e.transform(n.value,n);if(r.async)return(s instanceof Promise?s:Promise.resolve(s)).then(o=>(n.value=o,n));if(s instanceof Promise)throw new wr;return n.value=s,n}});function sd(t,e){return t.issues.length&&e===void 0?{issues:[],value:void 0}:t}const eg=S("$ZodOptional",(t,e)=>{le.init(t,e),t._zod.optin="optional",t._zod.optout="optional",ee(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,void 0]):void 0),ee(t._zod,"pattern",()=>{const n=e.innerType._zod.pattern;return n?new RegExp(`^(${xc(n.source)})?$`):void 0}),t._zod.parse=(n,r)=>{if(e.innerType._zod.optin==="optional"){const s=e.innerType._zod.run(n,r);return s instanceof Promise?s.then(i=>sd(i,n.value)):sd(s,n.value)}return n.value===void 0?n:e.innerType._zod.run(n,r)}}),M$=S("$ZodExactOptional",(t,e)=>{eg.init(t,e),ee(t._zod,"values",()=>e.innerType._zod.values),ee(t._zod,"pattern",()=>e.innerType._zod.pattern),t._zod.parse=(n,r)=>e.innerType._zod.run(n,r)}),N$=S("$ZodNullable",(t,e)=>{le.init(t,e),ee(t._zod,"optin",()=>e.innerType._zod.optin),ee(t._zod,"optout",()=>e.innerType._zod.optout),ee(t._zod,"pattern",()=>{const n=e.innerType._zod.pattern;return n?new RegExp(`^(${xc(n.source)}|null)$`):void 0}),ee(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,null]):void 0),t._zod.parse=(n,r)=>n.value===null?n:e.innerType._zod.run(n,r)}),U$=S("$ZodDefault",(t,e)=>{le.init(t,e),t._zod.optin="optional",ee(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(n,r)=>{if(r.direction==="backward")return e.innerType._zod.run(n,r);if(n.value===void 0)return n.value=e.defaultValue,n;const s=e.innerType._zod.run(n,r);return s instanceof Promise?s.then(i=>id(i,e)):id(s,e)}});function id(t,e){return t.value===void 0&&(t.value=e.defaultValue),t}const F$=S("$ZodPrefault",(t,e)=>{le.init(t,e),t._zod.optin="optional",ee(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(n,r)=>(r.direction==="backward"||n.value===void 0&&(n.value=e.defaultValue),e.innerType._zod.run(n,r))}),Z$=S("$ZodNonOptional",(t,e)=>{le.init(t,e),ee(t._zod,"values",()=>{const n=e.innerType._zod.values;return n?new Set([...n].filter(r=>r!==void 0)):void 0}),t._zod.parse=(n,r)=>{const s=e.innerType._zod.run(n,r);return s instanceof Promise?s.then(i=>od(i,t)):od(s,t)}});function od(t,e){return!t.issues.length&&t.value===void 0&&t.issues.push({code:"invalid_type",expected:"nonoptional",input:t.value,inst:e}),t}const j$=S("$ZodCatch",(t,e)=>{le.init(t,e),ee(t._zod,"optin",()=>e.innerType._zod.optin),ee(t._zod,"optout",()=>e.innerType._zod.optout),ee(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(n,r)=>{if(r.direction==="backward")return e.innerType._zod.run(n,r);const s=e.innerType._zod.run(n,r);return s instanceof Promise?s.then(i=>(n.value=i.value,i.issues.length&&(n.value=e.catchValue({...n,error:{issues:i.issues.map(o=>ln(o,r,an()))},input:n.value}),n.issues=[]),n)):(n.value=s.value,s.issues.length&&(n.value=e.catchValue({...n,error:{issues:s.issues.map(i=>ln(i,r,an()))},input:n.value}),n.issues=[]),n)}}),W$=S("$ZodPipe",(t,e)=>{le.init(t,e),ee(t._zod,"values",()=>e.in._zod.values),ee(t._zod,"optin",()=>e.in._zod.optin),ee(t._zod,"optout",()=>e.out._zod.optout),ee(t._zod,"propValues",()=>e.in._zod.propValues),t._zod.parse=(n,r)=>{if(r.direction==="backward"){const i=e.out._zod.run(n,r);return i instanceof Promise?i.then(o=>Ni(o,e.in,r)):Ni(i,e.in,r)}const s=e.in._zod.run(n,r);return s instanceof Promise?s.then(i=>Ni(i,e.out,r)):Ni(s,e.out,r)}});function Ni(t,e,n){return t.issues.length?(t.aborted=!0,t):e._zod.run({value:t.value,issues:t.issues},n)}const B$=S("$ZodReadonly",(t,e)=>{le.init(t,e),ee(t._zod,"propValues",()=>e.innerType._zod.propValues),ee(t._zod,"values",()=>e.innerType._zod.values),ee(t._zod,"optin",()=>{var n,r;return(r=(n=e.innerType)==null?void 0:n._zod)==null?void 0:r.optin}),ee(t._zod,"optout",()=>{var n,r;return(r=(n=e.innerType)==null?void 0:n._zod)==null?void 0:r.optout}),t._zod.parse=(n,r)=>{if(r.direction==="backward")return e.innerType._zod.run(n,r);const s=e.innerType._zod.run(n,r);return s instanceof Promise?s.then(ad):ad(s)}});function ad(t){return t.value=Object.freeze(t.value),t}const V$=S("$ZodCustom",(t,e)=>{Ve.init(t,e),le.init(t,e),t._zod.parse=(n,r)=>n,t._zod.check=n=>{const r=n.value,s=e.fn(r);if(s instanceof Promise)return s.then(i=>ld(i,n,r,t));ld(s,n,r,t)}});function ld(t,e,n,r){if(!t){const s={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(s.params=r._zod.def.params),e.issues.push(Cs(s))}}var cd;class H${constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...n){const r=n[0];return this._map.set(e,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){const n=this._map.get(e);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(e),this}get(e){const n=e._zod.parent;if(n){const r={...this.get(n)??{}};delete r.id;const s={...r,...this._map.get(e)};return Object.keys(s).length?s:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function G$(){return new H$}(cd=globalThis).__zod_globalRegistry??(cd.__zod_globalRegistry=G$());const gs=globalThis.__zod_globalRegistry;function q$(t,e){return new t({type:"string",...D(e)})}function Y$(t,e){return new t({type:"string",format:"email",check:"string_format",abort:!1,...D(e)})}function ud(t,e){return new t({type:"string",format:"guid",check:"string_format",abort:!1,...D(e)})}function K$(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,...D(e)})}function J$(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...D(e)})}function X$(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...D(e)})}function Q$(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...D(e)})}function eA(t,e){return new t({type:"string",format:"url",check:"string_format",abort:!1,...D(e)})}function tA(t,e){return new t({type:"string",format:"emoji",check:"string_format",abort:!1,...D(e)})}function nA(t,e){return new t({type:"string",format:"nanoid",check:"string_format",abort:!1,...D(e)})}function rA(t,e){return new t({type:"string",format:"cuid",check:"string_format",abort:!1,...D(e)})}function sA(t,e){return new t({type:"string",format:"cuid2",check:"string_format",abort:!1,...D(e)})}function iA(t,e){return new t({type:"string",format:"ulid",check:"string_format",abort:!1,...D(e)})}function oA(t,e){return new t({type:"string",format:"xid",check:"string_format",abort:!1,...D(e)})}function aA(t,e){return new t({type:"string",format:"ksuid",check:"string_format",abort:!1,...D(e)})}function lA(t,e){return new t({type:"string",format:"ipv4",check:"string_format",abort:!1,...D(e)})}function cA(t,e){return new t({type:"string",format:"ipv6",check:"string_format",abort:!1,...D(e)})}function uA(t,e){return new t({type:"string",format:"cidrv4",check:"string_format",abort:!1,...D(e)})}function hA(t,e){return new t({type:"string",format:"cidrv6",check:"string_format",abort:!1,...D(e)})}function dA(t,e){return new t({type:"string",format:"base64",check:"string_format",abort:!1,...D(e)})}function fA(t,e){return new t({type:"string",format:"base64url",check:"string_format",abort:!1,...D(e)})}function pA(t,e){return new t({type:"string",format:"e164",check:"string_format",abort:!1,...D(e)})}function gA(t,e){return new t({type:"string",format:"jwt",check:"string_format",abort:!1,...D(e)})}function mA(t,e){return new t({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...D(e)})}function vA(t,e){return new t({type:"string",format:"date",check:"string_format",...D(e)})}function yA(t,e){return new t({type:"string",format:"time",check:"string_format",precision:null,...D(e)})}function bA(t,e){return new t({type:"string",format:"duration",check:"string_format",...D(e)})}function wA(t,e){return new t({type:"number",checks:[],...D(e)})}function _A(t,e){return new t({type:"number",check:"number_format",abort:!1,format:"safeint",...D(e)})}function SA(t,e){return new t({type:"boolean",...D(e)})}function kA(t){return new t({type:"unknown"})}function EA(t,e){return new t({type:"never",...D(e)})}function hd(t,e){return new qp({check:"less_than",...D(e),value:t,inclusive:!1})}function Fa(t,e){return new qp({check:"less_than",...D(e),value:t,inclusive:!0})}function dd(t,e){return new Yp({check:"greater_than",...D(e),value:t,inclusive:!1})}function Za(t,e){return new Yp({check:"greater_than",...D(e),value:t,inclusive:!0})}function fd(t,e){return new U0({check:"multiple_of",...D(e),value:t})}function tg(t,e){return new Z0({check:"max_length",...D(e),maximum:t})}function yo(t,e){return new j0({check:"min_length",...D(e),minimum:t})}function ng(t,e){return new W0({check:"length_equals",...D(e),length:t})}function $A(t,e){return new B0({check:"string_format",format:"regex",...D(e),pattern:t})}function AA(t){return new V0({check:"string_format",format:"lowercase",...D(t)})}function xA(t){return new H0({check:"string_format",format:"uppercase",...D(t)})}function CA(t,e){return new G0({check:"string_format",format:"includes",...D(e),includes:t})}function TA(t,e){return new q0({check:"string_format",format:"starts_with",...D(e),prefix:t})}function IA(t,e){return new Y0({check:"string_format",format:"ends_with",...D(e),suffix:t})}function Gr(t){return new K0({check:"overwrite",tx:t})}function PA(t){return Gr(e=>e.normalize(t))}function RA(){return Gr(t=>t.trim())}function DA(){return Gr(t=>t.toLowerCase())}function OA(){return Gr(t=>t.toUpperCase())}function zA(){return Gr(t=>BE(t))}function LA(t,e,n){return new t({type:"array",element:e,...D(n)})}function MA(t,e,n){return new t({type:"custom",check:"custom",fn:e,...D(n)})}function NA(t){const e=UA(n=>(n.addIssue=r=>{if(typeof r=="string")n.issues.push(Cs(r,n.value,e._zod.def));else{const s=r;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),s.input??(s.input=n.value),s.inst??(s.inst=e),s.continue??(s.continue=!e._zod.def.abort),n.issues.push(Cs(s))}},t(n.value,n)));return e}function UA(t,e){const n=new Ve({check:"custom",...D(e)});return n._zod.check=t,n}function rg(t){let e=(t==null?void 0:t.target)??"draft-2020-12";return e==="draft-4"&&(e="draft-04"),e==="draft-7"&&(e="draft-07"),{processors:t.processors??{},metadataRegistry:(t==null?void 0:t.metadata)??gs,target:e,unrepresentable:(t==null?void 0:t.unrepresentable)??"throw",override:(t==null?void 0:t.override)??(()=>{}),io:(t==null?void 0:t.io)??"output",counter:0,seen:new Map,cycles:(t==null?void 0:t.cycles)??"ref",reused:(t==null?void 0:t.reused)??"inline",external:(t==null?void 0:t.external)??void 0}}function me(t,e,n={path:[],schemaPath:[]}){var d,f;var r;const s=t._zod.def,i=e.seen.get(t);if(i)return i.count++,n.schemaPath.includes(t)&&(i.cycle=n.path),i.schema;const o={schema:{},count:1,cycle:void 0,path:n.path};e.seen.set(t,o);const a=(f=(d=t._zod).toJSONSchema)==null?void 0:f.call(d);if(a)o.schema=a;else{const y={...n,schemaPath:[...n.schemaPath,t],path:n.path};if(t._zod.processJSONSchema)t._zod.processJSONSchema(e,o.schema,y);else{const E=o.schema,k=e.processors[s.type];if(!k)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${s.type}`);k(t,e,E,y)}const m=t._zod.parent;m&&(o.ref||(o.ref=m),me(m,e,y),e.seen.get(m).isParent=!0)}const l=e.metadataRegistry.get(t);return l&&Object.assign(o.schema,l),e.io==="input"&&De(t)&&(delete o.schema.examples,delete o.schema.default),e.io==="input"&&o.schema._prefault&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,e.seen.get(t).schema}function sg(t,e){var o,a,l,c;const n=t.seen.get(e);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=new Map;for(const d of t.seen.entries()){const f=(o=t.metadataRegistry.get(d[0]))==null?void 0:o.id;if(f){const y=r.get(f);if(y&&y!==d[0])throw new Error(`Duplicate schema id "${f}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(f,d[0])}}const s=d=>{var k;const f=t.target==="draft-2020-12"?"$defs":"definitions";if(t.external){const I=(k=t.external.registry.get(d[0]))==null?void 0:k.id,V=t.external.uri??(j=>j);if(I)return{ref:V(I)};const N=d[1].defId??d[1].schema.id??`schema${t.counter++}`;return d[1].defId=N,{defId:N,ref:`${V("__shared")}#/${f}/${N}`}}if(d[1]===n)return{ref:"#"};const m=`#/${f}/`,E=d[1].schema.id??`__schema${t.counter++}`;return{defId:E,ref:m+E}},i=d=>{if(d[1].schema.$ref)return;const f=d[1],{ref:y,defId:m}=s(d);f.def={...f.schema},m&&(f.defId=m);const E=f.schema;for(const k in E)delete E[k];E.$ref=y};if(t.cycles==="throw")for(const d of t.seen.entries()){const f=d[1];if(f.cycle)throw new Error(`Cycle detected: #/${(a=f.cycle)==null?void 0:a.join("/")}/<root>
|
|
41
|
-
|
|
42
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const d of t.seen.entries()){const f=d[1];if(e===d[0]){i(d);continue}if(t.external){const m=(l=t.external.registry.get(d[0]))==null?void 0:l.id;if(e!==d[0]&&m){i(d);continue}}if((c=t.metadataRegistry.get(d[0]))==null?void 0:c.id){i(d);continue}if(f.cycle){i(d);continue}if(f.count>1&&t.reused==="ref"){i(d);continue}}}function ig(t,e){var o,a,l;const n=t.seen.get(e);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=c=>{const d=t.seen.get(c);if(d.ref===null)return;const f=d.def??d.schema,y={...f},m=d.ref;if(d.ref=null,m){r(m);const k=t.seen.get(m),I=k.schema;if(I.$ref&&(t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0")?(f.allOf=f.allOf??[],f.allOf.push(I)):Object.assign(f,I),Object.assign(f,y),c._zod.parent===m)for(const N in f)N==="$ref"||N==="allOf"||N in y||delete f[N];if(I.$ref&&k.def)for(const N in f)N==="$ref"||N==="allOf"||N in k.def&&JSON.stringify(f[N])===JSON.stringify(k.def[N])&&delete f[N]}const E=c._zod.parent;if(E&&E!==m){r(E);const k=t.seen.get(E);if(k!=null&&k.schema.$ref&&(f.$ref=k.schema.$ref,k.def))for(const I in f)I==="$ref"||I==="allOf"||I in k.def&&JSON.stringify(f[I])===JSON.stringify(k.def[I])&&delete f[I]}t.override({zodSchema:c,jsonSchema:f,path:d.path??[]})};for(const c of[...t.seen.entries()].reverse())r(c[0]);const s={};if(t.target==="draft-2020-12"?s.$schema="https://json-schema.org/draft/2020-12/schema":t.target==="draft-07"?s.$schema="http://json-schema.org/draft-07/schema#":t.target==="draft-04"?s.$schema="http://json-schema.org/draft-04/schema#":t.target,(o=t.external)!=null&&o.uri){const c=(a=t.external.registry.get(e))==null?void 0:a.id;if(!c)throw new Error("Schema is missing an `id` property");s.$id=t.external.uri(c)}Object.assign(s,n.def??n.schema);const i=((l=t.external)==null?void 0:l.defs)??{};for(const c of t.seen.entries()){const d=c[1];d.def&&d.defId&&(i[d.defId]=d.def)}t.external||Object.keys(i).length>0&&(t.target==="draft-2020-12"?s.$defs=i:s.definitions=i);try{const c=JSON.parse(JSON.stringify(s));return Object.defineProperty(c,"~standard",{value:{...e["~standard"],jsonSchema:{input:bo(e,"input",t.processors),output:bo(e,"output",t.processors)}},enumerable:!1,writable:!1}),c}catch{throw new Error("Error converting schema to JSON.")}}function De(t,e){const n=e??{seen:new Set};if(n.seen.has(t))return!1;n.seen.add(t);const r=t._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return De(r.element,n);if(r.type==="set")return De(r.valueType,n);if(r.type==="lazy")return De(r.getter(),n);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault")return De(r.innerType,n);if(r.type==="intersection")return De(r.left,n)||De(r.right,n);if(r.type==="record"||r.type==="map")return De(r.keyType,n)||De(r.valueType,n);if(r.type==="pipe")return De(r.in,n)||De(r.out,n);if(r.type==="object"){for(const s in r.shape)if(De(r.shape[s],n))return!0;return!1}if(r.type==="union"){for(const s of r.options)if(De(s,n))return!0;return!1}if(r.type==="tuple"){for(const s of r.items)if(De(s,n))return!0;return!!(r.rest&&De(r.rest,n))}return!1}const FA=(t,e={})=>n=>{const r=rg({...n,processors:e});return me(t,r),sg(r,t),ig(r,t)},bo=(t,e,n={})=>r=>{const{libraryOptions:s,target:i}=r??{},o=rg({...s??{},target:i,io:e,processors:n});return me(t,o),sg(o,t),ig(o,t)},ZA={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},jA=(t,e,n,r)=>{const s=n;s.type="string";const{minimum:i,maximum:o,format:a,patterns:l,contentEncoding:c}=t._zod.bag;if(typeof i=="number"&&(s.minLength=i),typeof o=="number"&&(s.maxLength=o),a&&(s.format=ZA[a]??a,s.format===""&&delete s.format,a==="time"&&delete s.format),c&&(s.contentEncoding=c),l&&l.size>0){const d=[...l];d.length===1?s.pattern=d[0].source:d.length>1&&(s.allOf=[...d.map(f=>({...e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"?{type:"string"}:{},pattern:f.source}))])}},WA=(t,e,n,r)=>{const s=n,{minimum:i,maximum:o,format:a,multipleOf:l,exclusiveMaximum:c,exclusiveMinimum:d}=t._zod.bag;typeof a=="string"&&a.includes("int")?s.type="integer":s.type="number",typeof d=="number"&&(e.target==="draft-04"||e.target==="openapi-3.0"?(s.minimum=d,s.exclusiveMinimum=!0):s.exclusiveMinimum=d),typeof i=="number"&&(s.minimum=i,typeof d=="number"&&e.target!=="draft-04"&&(d>=i?delete s.minimum:delete s.exclusiveMinimum)),typeof c=="number"&&(e.target==="draft-04"||e.target==="openapi-3.0"?(s.maximum=c,s.exclusiveMaximum=!0):s.exclusiveMaximum=c),typeof o=="number"&&(s.maximum=o,typeof c=="number"&&e.target!=="draft-04"&&(c<=o?delete s.maximum:delete s.exclusiveMaximum)),typeof l=="number"&&(s.multipleOf=l)},BA=(t,e,n,r)=>{n.type="boolean"},VA=(t,e,n,r)=>{n.not={}},HA=(t,e,n,r)=>{},GA=(t,e,n,r)=>{const s=t._zod.def,i=Mp(s.entries);i.every(o=>typeof o=="number")&&(n.type="number"),i.every(o=>typeof o=="string")&&(n.type="string"),n.enum=i},qA=(t,e,n,r)=>{const s=t._zod.def,i=[];for(const o of s.values)if(o===void 0){if(e.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof o=="bigint"){if(e.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");i.push(Number(o))}else i.push(o);if(i.length!==0)if(i.length===1){const o=i[0];n.type=o===null?"null":typeof o,e.target==="draft-04"||e.target==="openapi-3.0"?n.enum=[o]:n.const=o}else i.every(o=>typeof o=="number")&&(n.type="number"),i.every(o=>typeof o=="string")&&(n.type="string"),i.every(o=>typeof o=="boolean")&&(n.type="boolean"),i.every(o=>o===null)&&(n.type="null"),n.enum=i},YA=(t,e,n,r)=>{if(e.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},KA=(t,e,n,r)=>{if(e.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},JA=(t,e,n,r)=>{const s=n,i=t._zod.def,{minimum:o,maximum:a}=t._zod.bag;typeof o=="number"&&(s.minItems=o),typeof a=="number"&&(s.maxItems=a),s.type="array",s.items=me(i.element,e,{...r,path:[...r.path,"items"]})},XA=(t,e,n,r)=>{var c;const s=n,i=t._zod.def;s.type="object",s.properties={};const o=i.shape;for(const d in o)s.properties[d]=me(o[d],e,{...r,path:[...r.path,"properties",d]});const a=new Set(Object.keys(o)),l=new Set([...a].filter(d=>{const f=i.shape[d]._zod;return e.io==="input"?f.optin===void 0:f.optout===void 0}));l.size>0&&(s.required=Array.from(l)),((c=i.catchall)==null?void 0:c._zod.def.type)==="never"?s.additionalProperties=!1:i.catchall?i.catchall&&(s.additionalProperties=me(i.catchall,e,{...r,path:[...r.path,"additionalProperties"]})):e.io==="output"&&(s.additionalProperties=!1)},QA=(t,e,n,r)=>{const s=t._zod.def,i=s.inclusive===!1,o=s.options.map((a,l)=>me(a,e,{...r,path:[...r.path,i?"oneOf":"anyOf",l]}));i?n.oneOf=o:n.anyOf=o},ex=(t,e,n,r)=>{const s=t._zod.def,i=me(s.left,e,{...r,path:[...r.path,"allOf",0]}),o=me(s.right,e,{...r,path:[...r.path,"allOf",1]}),a=c=>"allOf"in c&&Object.keys(c).length===1,l=[...a(i)?i.allOf:[i],...a(o)?o.allOf:[o]];n.allOf=l},tx=(t,e,n,r)=>{const s=n,i=t._zod.def;s.type="object";const o=i.keyType,a=o._zod.bag,l=a==null?void 0:a.patterns;if(i.mode==="loose"&&l&&l.size>0){const d=me(i.valueType,e,{...r,path:[...r.path,"patternProperties","*"]});s.patternProperties={};for(const f of l)s.patternProperties[f.source]=d}else(e.target==="draft-07"||e.target==="draft-2020-12")&&(s.propertyNames=me(i.keyType,e,{...r,path:[...r.path,"propertyNames"]})),s.additionalProperties=me(i.valueType,e,{...r,path:[...r.path,"additionalProperties"]});const c=o._zod.values;if(c){const d=[...c].filter(f=>typeof f=="string"||typeof f=="number");d.length>0&&(s.required=d)}},nx=(t,e,n,r)=>{const s=t._zod.def,i=me(s.innerType,e,r),o=e.seen.get(t);e.target==="openapi-3.0"?(o.ref=s.innerType,n.nullable=!0):n.anyOf=[i,{type:"null"}]},rx=(t,e,n,r)=>{const s=t._zod.def;me(s.innerType,e,r);const i=e.seen.get(t);i.ref=s.innerType},sx=(t,e,n,r)=>{const s=t._zod.def;me(s.innerType,e,r);const i=e.seen.get(t);i.ref=s.innerType,n.default=JSON.parse(JSON.stringify(s.defaultValue))},ix=(t,e,n,r)=>{const s=t._zod.def;me(s.innerType,e,r);const i=e.seen.get(t);i.ref=s.innerType,e.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(s.defaultValue)))},ox=(t,e,n,r)=>{const s=t._zod.def;me(s.innerType,e,r);const i=e.seen.get(t);i.ref=s.innerType;let o;try{o=s.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=o},ax=(t,e,n,r)=>{const s=t._zod.def,i=e.io==="input"?s.in._zod.def.type==="transform"?s.out:s.in:s.out;me(i,e,r);const o=e.seen.get(t);o.ref=i},lx=(t,e,n,r)=>{const s=t._zod.def;me(s.innerType,e,r);const i=e.seen.get(t);i.ref=s.innerType,n.readOnly=!0},og=(t,e,n,r)=>{const s=t._zod.def;me(s.innerType,e,r);const i=e.seen.get(t);i.ref=s.innerType},cx=S("ZodISODateTime",(t,e)=>{u$.init(t,e),ue.init(t,e)});function ux(t){return mA(cx,t)}const hx=S("ZodISODate",(t,e)=>{h$.init(t,e),ue.init(t,e)});function dx(t){return vA(hx,t)}const fx=S("ZodISOTime",(t,e)=>{d$.init(t,e),ue.init(t,e)});function px(t){return yA(fx,t)}const gx=S("ZodISODuration",(t,e)=>{f$.init(t,e),ue.init(t,e)});function mx(t){return bA(gx,t)}const ag=(t,e)=>{Zp.init(t,e),t.name="ZodError",Object.defineProperties(t,{format:{value:n=>r0(t,n)},flatten:{value:n=>n0(t,n)},addIssue:{value:n=>{t.issues.push(n),t.message=JSON.stringify(t.issues,ml,2)}},addIssues:{value:n=>{t.issues.push(...n),t.message=JSON.stringify(t.issues,ml,2)}},isEmpty:{get(){return t.issues.length===0}}})},pd=S("ZodError",ag),nt=S("ZodError",ag,{Parent:Error}),vx=Tc(nt),yx=Ic(nt),bx=Wo(nt),wx=Bo(nt),_x=o0(nt),Sx=a0(nt),kx=l0(nt),Ex=c0(nt),$x=u0(nt),Ax=h0(nt),xx=d0(nt),Cx=f0(nt),ce=S("ZodType",(t,e)=>(le.init(t,e),Object.assign(t["~standard"],{jsonSchema:{input:bo(t,"input"),output:bo(t,"output")}}),t.toJSONSchema=FA(t,{}),t.def=e,t.type=e.type,Object.defineProperty(t,"_def",{value:e}),t.check=(...n)=>t.clone(fn(e,{checks:[...e.checks??[],...n.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0}),t.with=t.check,t.clone=(n,r)=>pn(t,n,r),t.brand=()=>t,t.register=(n,r)=>(n.add(t,r),t),t.parse=(n,r)=>vx(t,n,r,{callee:t.parse}),t.safeParse=(n,r)=>bx(t,n,r),t.parseAsync=async(n,r)=>yx(t,n,r,{callee:t.parseAsync}),t.safeParseAsync=async(n,r)=>wx(t,n,r),t.spa=t.safeParseAsync,t.encode=(n,r)=>_x(t,n,r),t.decode=(n,r)=>Sx(t,n,r),t.encodeAsync=async(n,r)=>kx(t,n,r),t.decodeAsync=async(n,r)=>Ex(t,n,r),t.safeEncode=(n,r)=>$x(t,n,r),t.safeDecode=(n,r)=>Ax(t,n,r),t.safeEncodeAsync=async(n,r)=>xx(t,n,r),t.safeDecodeAsync=async(n,r)=>Cx(t,n,r),t.refine=(n,r)=>t.check(bC(n,r)),t.superRefine=n=>t.check(wC(n)),t.overwrite=n=>t.check(Gr(n)),t.optional=()=>vd(t),t.exactOptional=()=>oC(t),t.nullable=()=>yd(t),t.nullish=()=>vd(yd(t)),t.nonoptional=n=>dC(t,n),t.array=()=>R(t),t.or=n=>Z([t,n]),t.and=n=>Ho(t,n),t.transform=n=>bd(t,sC(n)),t.default=n=>cC(t,n),t.prefault=n=>hC(t,n),t.catch=n=>pC(t,n),t.pipe=n=>bd(t,n),t.readonly=()=>vC(t),t.describe=n=>{const r=t.clone();return gs.add(r,{description:n}),r},Object.defineProperty(t,"description",{get(){var n;return(n=gs.get(t))==null?void 0:n.description},configurable:!0}),t.meta=(...n)=>{if(n.length===0)return gs.get(t);const r=t.clone();return gs.add(r,n[0]),r},t.isOptional=()=>t.safeParse(void 0).success,t.isNullable=()=>t.safeParse(null).success,t.apply=n=>n(t),t)),lg=S("_ZodString",(t,e)=>{Pc.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(r,s,i)=>jA(t,r,s);const n=t._zod.bag;t.format=n.format??null,t.minLength=n.minimum??null,t.maxLength=n.maximum??null,t.regex=(...r)=>t.check($A(...r)),t.includes=(...r)=>t.check(CA(...r)),t.startsWith=(...r)=>t.check(TA(...r)),t.endsWith=(...r)=>t.check(IA(...r)),t.min=(...r)=>t.check(yo(...r)),t.max=(...r)=>t.check(tg(...r)),t.length=(...r)=>t.check(ng(...r)),t.nonempty=(...r)=>t.check(yo(1,...r)),t.lowercase=r=>t.check(AA(r)),t.uppercase=r=>t.check(xA(r)),t.trim=()=>t.check(RA()),t.normalize=(...r)=>t.check(PA(...r)),t.toLowerCase=()=>t.check(DA()),t.toUpperCase=()=>t.check(OA()),t.slugify=()=>t.check(zA())}),Tx=S("ZodString",(t,e)=>{Pc.init(t,e),lg.init(t,e),t.email=n=>t.check(Y$(Ix,n)),t.url=n=>t.check(eA(Px,n)),t.jwt=n=>t.check(gA(Hx,n)),t.emoji=n=>t.check(tA(Rx,n)),t.guid=n=>t.check(ud(gd,n)),t.uuid=n=>t.check(K$(Ui,n)),t.uuidv4=n=>t.check(J$(Ui,n)),t.uuidv6=n=>t.check(X$(Ui,n)),t.uuidv7=n=>t.check(Q$(Ui,n)),t.nanoid=n=>t.check(nA(Dx,n)),t.guid=n=>t.check(ud(gd,n)),t.cuid=n=>t.check(rA(Ox,n)),t.cuid2=n=>t.check(sA(zx,n)),t.ulid=n=>t.check(iA(Lx,n)),t.base64=n=>t.check(dA(Wx,n)),t.base64url=n=>t.check(fA(Bx,n)),t.xid=n=>t.check(oA(Mx,n)),t.ksuid=n=>t.check(aA(Nx,n)),t.ipv4=n=>t.check(lA(Ux,n)),t.ipv6=n=>t.check(cA(Fx,n)),t.cidrv4=n=>t.check(uA(Zx,n)),t.cidrv6=n=>t.check(hA(jx,n)),t.e164=n=>t.check(pA(Vx,n)),t.datetime=n=>t.check(ux(n)),t.date=n=>t.check(dx(n)),t.time=n=>t.check(px(n)),t.duration=n=>t.check(mx(n))});function u(t){return q$(Tx,t)}const ue=S("ZodStringFormat",(t,e)=>{oe.init(t,e),lg.init(t,e)}),Ix=S("ZodEmail",(t,e)=>{t$.init(t,e),ue.init(t,e)}),gd=S("ZodGUID",(t,e)=>{Q0.init(t,e),ue.init(t,e)}),Ui=S("ZodUUID",(t,e)=>{e$.init(t,e),ue.init(t,e)}),Px=S("ZodURL",(t,e)=>{n$.init(t,e),ue.init(t,e)}),Rx=S("ZodEmoji",(t,e)=>{r$.init(t,e),ue.init(t,e)}),Dx=S("ZodNanoID",(t,e)=>{s$.init(t,e),ue.init(t,e)}),Ox=S("ZodCUID",(t,e)=>{i$.init(t,e),ue.init(t,e)}),zx=S("ZodCUID2",(t,e)=>{o$.init(t,e),ue.init(t,e)}),Lx=S("ZodULID",(t,e)=>{a$.init(t,e),ue.init(t,e)}),Mx=S("ZodXID",(t,e)=>{l$.init(t,e),ue.init(t,e)}),Nx=S("ZodKSUID",(t,e)=>{c$.init(t,e),ue.init(t,e)}),Ux=S("ZodIPv4",(t,e)=>{p$.init(t,e),ue.init(t,e)}),Fx=S("ZodIPv6",(t,e)=>{g$.init(t,e),ue.init(t,e)}),Zx=S("ZodCIDRv4",(t,e)=>{m$.init(t,e),ue.init(t,e)}),jx=S("ZodCIDRv6",(t,e)=>{v$.init(t,e),ue.init(t,e)}),Wx=S("ZodBase64",(t,e)=>{y$.init(t,e),ue.init(t,e)}),Bx=S("ZodBase64URL",(t,e)=>{w$.init(t,e),ue.init(t,e)}),Vx=S("ZodE164",(t,e)=>{_$.init(t,e),ue.init(t,e)}),Hx=S("ZodJWT",(t,e)=>{k$.init(t,e),ue.init(t,e)}),cg=S("ZodNumber",(t,e)=>{Jp.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(r,s,i)=>WA(t,r,s),t.gt=(r,s)=>t.check(dd(r,s)),t.gte=(r,s)=>t.check(Za(r,s)),t.min=(r,s)=>t.check(Za(r,s)),t.lt=(r,s)=>t.check(hd(r,s)),t.lte=(r,s)=>t.check(Fa(r,s)),t.max=(r,s)=>t.check(Fa(r,s)),t.int=r=>t.check(md(r)),t.safe=r=>t.check(md(r)),t.positive=r=>t.check(dd(0,r)),t.nonnegative=r=>t.check(Za(0,r)),t.negative=r=>t.check(hd(0,r)),t.nonpositive=r=>t.check(Fa(0,r)),t.multipleOf=(r,s)=>t.check(fd(r,s)),t.step=(r,s)=>t.check(fd(r,s)),t.finite=()=>t;const n=t._zod.bag;t.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,t.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,t.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),t.isFinite=!0,t.format=n.format??null});function U(t){return wA(cg,t)}const Gx=S("ZodNumberFormat",(t,e)=>{E$.init(t,e),cg.init(t,e)});function md(t){return _A(Gx,t)}const qx=S("ZodBoolean",(t,e)=>{$$.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>BA(t,n,r)});function ke(t){return SA(qx,t)}const Yx=S("ZodUnknown",(t,e)=>{A$.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>HA()});function w(){return kA(Yx)}const Kx=S("ZodNever",(t,e)=>{x$.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>VA(t,n,r)});function Jx(t){return EA(Kx,t)}const Xx=S("ZodArray",(t,e)=>{C$.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>JA(t,n,r,s),t.element=e.element,t.min=(n,r)=>t.check(yo(n,r)),t.nonempty=n=>t.check(yo(1,n)),t.max=(n,r)=>t.check(tg(n,r)),t.length=(n,r)=>t.check(ng(n,r)),t.unwrap=()=>t.element});function R(t,e){return LA(Xx,t,e)}const ug=S("ZodObject",(t,e)=>{I$.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>XA(t,n,r,s),ee(t,"shape",()=>e.shape),t.keyof=()=>wo(Object.keys(t._zod.def.shape)),t.catchall=n=>t.clone({...t._zod.def,catchall:n}),t.passthrough=()=>t.clone({...t._zod.def,catchall:w()}),t.loose=()=>t.clone({...t._zod.def,catchall:w()}),t.strict=()=>t.clone({...t._zod.def,catchall:Jx()}),t.strip=()=>t.clone({...t._zod.def,catchall:void 0}),t.extend=n=>JE(t,n),t.safeExtend=n=>XE(t,n),t.merge=n=>QE(t,n),t.pick=n=>YE(t,n),t.omit=n=>KE(t,n),t.partial=(...n)=>e0(dg,t,n[0]),t.required=(...n)=>t0(fg,t,n[0])});function hg(t,e){const n={type:"object",shape:t??{},...D(e)};return new ug(n)}function p(t,e){return new ug({type:"object",shape:t,catchall:w(),...D(e)})}const Qx=S("ZodUnion",(t,e)=>{P$.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>QA(t,n,r,s),t.options=e.options});function Z(t,e){return new Qx({type:"union",options:t,...D(e)})}const eC=S("ZodIntersection",(t,e)=>{R$.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>ex(t,n,r,s)});function Ho(t,e){return new eC({type:"intersection",left:t,right:e})}const tC=S("ZodRecord",(t,e)=>{D$.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>tx(t,n,r,s),t.keyType=e.keyType,t.valueType=e.valueType});function _(t,e,n){return new tC({type:"record",keyType:t,valueType:e,...D(n)})}const yl=S("ZodEnum",(t,e)=>{O$.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(r,s,i)=>GA(t,r,s),t.enum=e.entries,t.options=Object.values(e.entries);const n=new Set(Object.keys(e.entries));t.extract=(r,s)=>{const i={};for(const o of r)if(n.has(o))i[o]=e.entries[o];else throw new Error(`Key ${o} not found in enum`);return new yl({...e,checks:[],...D(s),entries:i})},t.exclude=(r,s)=>{const i={...e.entries};for(const o of r)if(n.has(o))delete i[o];else throw new Error(`Key ${o} not found in enum`);return new yl({...e,checks:[],...D(s),entries:i})}});function wo(t,e){const n=Array.isArray(t)?Object.fromEntries(t.map(r=>[r,r])):t;return new yl({type:"enum",entries:n,...D(e)})}const nC=S("ZodLiteral",(t,e)=>{z$.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>qA(t,n,r),t.values=new Set(e.values),Object.defineProperty(t,"value",{get(){if(e.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return e.values[0]}})});function A(t,e){return new nC({type:"literal",values:Array.isArray(t)?t:[t],...D(e)})}const rC=S("ZodTransform",(t,e)=>{L$.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>KA(t,n),t._zod.parse=(n,r)=>{if(r.direction==="backward")throw new zp(t.constructor.name);n.addIssue=i=>{if(typeof i=="string")n.issues.push(Cs(i,n.value,e));else{const o=i;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=n.value),o.inst??(o.inst=t),n.issues.push(Cs(o))}};const s=e.transform(n.value,n);return s instanceof Promise?s.then(i=>(n.value=i,n)):(n.value=s,n)}});function sC(t){return new rC({type:"transform",transform:t})}const dg=S("ZodOptional",(t,e)=>{eg.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>og(t,n,r,s),t.unwrap=()=>t._zod.def.innerType});function vd(t){return new dg({type:"optional",innerType:t})}const iC=S("ZodExactOptional",(t,e)=>{M$.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>og(t,n,r,s),t.unwrap=()=>t._zod.def.innerType});function oC(t){return new iC({type:"optional",innerType:t})}const aC=S("ZodNullable",(t,e)=>{N$.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>nx(t,n,r,s),t.unwrap=()=>t._zod.def.innerType});function yd(t){return new aC({type:"nullable",innerType:t})}const lC=S("ZodDefault",(t,e)=>{U$.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>sx(t,n,r,s),t.unwrap=()=>t._zod.def.innerType,t.removeDefault=t.unwrap});function cC(t,e){return new lC({type:"default",innerType:t,get defaultValue(){return typeof e=="function"?e():Up(e)}})}const uC=S("ZodPrefault",(t,e)=>{F$.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>ix(t,n,r,s),t.unwrap=()=>t._zod.def.innerType});function hC(t,e){return new uC({type:"prefault",innerType:t,get defaultValue(){return typeof e=="function"?e():Up(e)}})}const fg=S("ZodNonOptional",(t,e)=>{Z$.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>rx(t,n,r,s),t.unwrap=()=>t._zod.def.innerType});function dC(t,e){return new fg({type:"nonoptional",innerType:t,...D(e)})}const fC=S("ZodCatch",(t,e)=>{j$.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>ox(t,n,r,s),t.unwrap=()=>t._zod.def.innerType,t.removeCatch=t.unwrap});function pC(t,e){return new fC({type:"catch",innerType:t,catchValue:typeof e=="function"?e:()=>e})}const gC=S("ZodPipe",(t,e)=>{W$.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>ax(t,n,r,s),t.in=e.in,t.out=e.out});function bd(t,e){return new gC({type:"pipe",in:t,out:e})}const mC=S("ZodReadonly",(t,e)=>{B$.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>lx(t,n,r,s),t.unwrap=()=>t._zod.def.innerType});function vC(t){return new mC({type:"readonly",innerType:t})}const yC=S("ZodCustom",(t,e)=>{V$.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>YA(t,n)});function bC(t,e={}){return MA(yC,t,e)}function wC(t){return NA(t)}const _C=["text/markdown","text/html"],SC=["committed","pending"];hg({id:u().min(1),type:wo(_C),title:u(),status:wo(SC),externalFilePath:u().optional()});hg({name:u().min(1),description:u(),accepts:R(u().min(1)).min(1)});function Rc(t){return typeof t=="object"&&t!==null}function kC(t){return!Rc(t)||t.type!=="ready"?!1:!("id"in t)}function EC(t){return!(!Rc(t)||t.type!=="update-content"||typeof t.id!="string"||typeof t.content!="string")}function $C(t){return!Rc(t)||t.type!=="wheel"||typeof t.deltaX!="number"||typeof t.deltaY!="number"||typeof t.shiftKey!="boolean"?!1:!("id"in t)}function AC(t,e){if(t===e)return 2;if(t==="*/*")return 0;const n=t.indexOf("/");if(n>0&&t.slice(n+1)==="*"){const r=t.slice(0,n),s=e.indexOf("/");if(s>0&&e.slice(0,s)===r)return 1}return null}function xC(t,e){let n=null;for(const r of t.accepts){const s=AC(r,e);s!==null&&(n===null||s>n)&&(n=s)}return n}function CC(t,e){let n=-1,r=null;for(const s of e){const i=xC(s,t);i!==null&&(i>n||i===n&&r!==null&&s.id<r.id)&&(n=i,r=s)}return r}const TC=4401;class bl extends Error{constructor(e="Authentication required"){super(e),this.name="AuthError"}}class wl extends kt{constructor(n){super();v(this,"url");v(this,"name");v(this,"token");v(this,"status","disconnected");v(this,"screens",new Map);v(this,"views",[]);v(this,"client");v(this,"createSocket");v(this,"createClient");v(this,"socket",null);v(this,"connectAttempt",0);this.url=Pt(n.url),this.name=n.name,this.token=n.token??null,this.createSocket=n.createSocket??(r=>new WebSocket(r)),this.createClient=n.createClient??((r,s)=>new DE(r,{token:s??void 0})),this.client=this.createClient(this.url,this.token)}async connect(){var s;this.connectAttempt+=1;const n=this.connectAttempt;(s=this.socket)==null||s.close(),this.client=this.createClient(this.url,this.token),this.status="connecting",this.dispatchEvent(new te("change"));const r=this.createSocket(IC(this.url,this.token));return this.socket=r,await new Promise((i,o)=>{let a=!1;const l=()=>{a||this.connectAttempt!==n||(a=!0,this.status="connected",this.dispatchEvent(new te("change")),i())},c=f=>{a||this.connectAttempt!==n||(a=!0,this.status="disconnected",this.dispatchEvent(new te("change")),o(f))},d=async()=>{try{const[{screens:f},y]=await Promise.all([this.client.screens.list(),this.client.views.list()]);this.screens=new Map(f.map(m=>[m.id,structuredClone(m)])),this.views=y,this.dispatchEvent(new te("change")),l()}catch(f){c(f instanceof Error?f:new Error(String(f)))}};r.addEventListener("open",()=>{d()}),r.addEventListener("message",f=>{const y=RC(f);y&&(this.applyServerEvent(y),this.dispatchEvent(new Ep("server-event",{serverURL:this.url,event:y})))}),r.addEventListener("close",f=>{if(this.connectAttempt===n){if(this.socket=null,PC(f)===TC){c(new bl);return}if(!a){c(new Error("Connection closed before initialization"));return}this.status="disconnected",this.dispatchEvent(new te("change"))}}),r.addEventListener("error",()=>{c(new Error("WebSocket connection failed"))})})}disconnect(){var n;this.connectAttempt+=1,(n=this.socket)==null||n.close(),this.socket=null,this.status="disconnected",this.dispatchEvent(new te("change"))}getViewURL(n){const r=CC(n.type,this.views);if(!r)return null;const s=`${this.url}/views/${encodeURIComponent(r.id)}/`;return this.token===null?s:`${s}?token=${encodeURIComponent(this.token)}`}getContentURL(n){const r=`${this.url}/artifacts/${encodeURIComponent(n)}/content`;return this.token===null?r:`${r}?token=${encodeURIComponent(this.token)}`}async createScreen(n){const{screen:r}=await this.client.screens.create({name:n});return this.screens.set(r.id,structuredClone(r)),r}applyServerEvent(n){switch(n.type){case"screen-created":this.screens.set(n.screen.id,structuredClone(n.screen)),this.dispatchEvent(new to("screens-changed"));break;case"screen-updated":this.screens.set(n.screen.id,structuredClone(n.screen)),this.dispatchEvent(new to("screens-changed"));break;case"screen-removed":this.screens.delete(n.screenID),this.dispatchEvent(new to("screens-changed"));break;case"artifact-created":{const r=this.screens.get(n.screenID);r&&!_p(r.layout,n.artifact.id)&&(r.layout=[...r.layout,wp(n.artifact.id)]);break}case"artifact-removed":{const r=this.screens.get(n.screenID);r&&(r.layout=hp(r.layout,n.artifactID));break}}}}function IC(t,e){const n=new URL(t);return n.protocol=n.protocol==="https:"?"wss:":"ws:",n.pathname="/events",n.search="",e&&n.searchParams.set("token",e),n.hash="",n.toString()}function PC(t){return typeof t=="object"&&t!==null&&"code"in t&&typeof t.code=="number"?t.code:null}function RC(t){const e=typeof t=="string"?t:typeof t=="object"&&t!==null&&"data"in t&&typeof t.data=="string"?t.data:"";if(!e)return null;try{return JSON.parse(e)}catch{return null}}class DC extends kt{constructor(n){super();v(this,"servers",new Map);v(this,"localServerURL");v(this,"localStore");v(this,"createSocket");v(this,"lastActiveServerURL");v(this,"serverListeners",new Map);v(this,"handleLocalStoreChange",()=>{const n=this.localStore.get().activeServerURL;n!==this.lastActiveServerURL&&(this.lastActiveServerURL=n,this.dispatchEvent(new te("change")))});this.localStore=n.localStore,this.localServerURL=n.localServerURL?Pt(n.localServerURL):null,this.createSocket=n.createSocket??(r=>new WebSocket(r)),this.lastActiveServerURL=this.localStore.get().activeServerURL,this.localStore.addEventListener("change",this.handleLocalStoreChange)}get activeServer(){const n=this.localStore.get().activeServerURL;return n===null?null:this.servers.get(n)??null}add(n){const r=Pt(n.url);this.servers.get(r)&&this.remove(r),this.servers.set(r,n);const i=()=>{this.dispatchEvent(new te("change"))},o=l=>{this.dispatchEvent(new Ep("server-event",{serverURL:l.serverURL,event:l.event}))},a=()=>{this.dispatchEvent(new to("screens-changed"))};n.addEventListener("change",i),n.addEventListener("server-event",o),n.addEventListener("screens-changed",a),this.serverListeners.set(r,{onServerChange:i,onServerEvent:o,onScreensChanged:a}),this.dispatchEvent(new te("change"))}remove(n){const r=Pt(n);if(this.localServerURL&&r===this.localServerURL)return;const s=this.servers.get(r);if(!s)return;const i=this.serverListeners.get(r);i&&(s.removeEventListener("change",i.onServerChange),s.removeEventListener("server-event",i.onServerEvent),s.removeEventListener("screens-changed",i.onScreensChanged),this.serverListeners.delete(r)),s.disconnect(),this.servers.delete(r);const o=this.localStore.get(),a=o.activeServerURL===r;this.localStore.set({...o,servers:o.servers.filter(l=>l.url!==r),activeServerURL:a?null:o.activeServerURL}),this.dispatchEvent(new te("change"))}setActive(n){const r=this.localStore.get(),s=n?Pt(n.url):null;r.activeServerURL!==s&&this.localStore.set({...r,activeServerURL:s})}connectConfiguredServers(n){const r=this.localStore.get().servers;for(const i of r){const o=new wl({url:i.url,name:i.name,createSocket:this.createSocket});this.add(o),o.connect().catch(()=>{})}const s=n?this.servers.get(Pt(n))??null:null;this.setActive(s??this.servers.values().next().value??null)}addServer(n,r){const s=Pt(n);this.remove(s);const i=this.localStore.get();this.localStore.set({...i,servers:[...i.servers.filter(a=>Pt(a.url)!==s),{url:s,name:r}]});const o=new wl({url:s,name:r,createSocket:this.createSocket});this.add(o),this.setActive(o),o.connect().catch(()=>{})}removeServer(n){this.remove(n)}}const ie={authenticate:"authenticate",document_did_change:"document/didChange",document_did_close:"document/didClose",document_did_focus:"document/didFocus",document_did_open:"document/didOpen",document_did_save:"document/didSave",initialize:"initialize",logout:"logout",nes_accept:"nes/accept",nes_close:"nes/close",nes_reject:"nes/reject",nes_start:"nes/start",nes_suggest:"nes/suggest",session_cancel:"session/cancel",session_close:"session/close",session_fork:"session/fork",session_list:"session/list",session_load:"session/load",session_new:"session/new",session_prompt:"session/prompt",session_resume:"session/resume",session_set_config_option:"session/set_config_option",session_set_mode:"session/set_mode",session_set_model:"session/set_model"},Ct={fs_read_text_file:"fs/read_text_file",fs_write_text_file:"fs/write_text_file",session_request_permission:"session/request_permission",session_update:"session/update",terminal_create:"terminal/create",terminal_kill:"terminal/kill",terminal_output:"terminal/output",terminal_release:"terminal/release",terminal_wait_for_exit:"terminal/wait_for_exit"},OC=1,zC=p({_meta:_(u(),w()).nullish(),terminal:ke().optional().default(!1)}),LC=p({_meta:_(u(),w()).nullish(),label:u().nullish(),name:u(),optional:ke().optional().default(!1),secret:ke().optional().default(!0)}),MC=p({_meta:_(u(),w()).nullish(),description:u().nullish(),id:u(),name:u()}),NC=p({_meta:_(u(),w()).nullish(),description:u().nullish(),id:u(),link:u().nullish(),name:u(),vars:R(LC)}),UC=p({_meta:_(u(),w()).nullish(),args:R(u()).optional(),description:u().nullish(),env:_(u(),u()).optional(),id:u(),name:u()}),FC=Z([NC.and(p({type:A("env_var")})),UC.and(p({type:A("terminal")})),MC]),ZC=p({_meta:_(u(),w()).nullish(),methodId:u()}),jC=p({_meta:_(u(),w()).nullish()}),WC=p({_meta:_(u(),w()).nullish(),blob:u(),mimeType:u().nullish(),uri:u()}),BC=p({default:ke().nullish(),description:u().nullish(),title:u().nullish()}),VC=p({_meta:_(u(),w()).nullish()}),HC=p({_meta:_(u(),w()).nullish()}),GC=p({amount:U(),currency:u()}),qC=p({_meta:_(u(),w()).nullish(),terminalId:u()}),YC=p({_meta:_(u(),w()).nullish(),newText:u(),oldText:u().nullish(),path:u()}),KC=Z([u(),U(),U(),ke(),R(u())]),JC=p({content:_(u(),KC).nullish()}),XC=Z([JC.and(p({action:A("accept")})),p({action:A("decline")}),p({action:A("cancel")})]),QC=p({_meta:_(u(),w()).nullish()}),pg=u(),eT=p({_meta:_(u(),w()).nullish(),elicitationId:pg}),tT=p({_meta:_(u(),w()).nullish(),action:XC}),nT=A("object"),rT=A("string"),sT=p({_meta:_(u(),w()).nullish()}),iT=p({_meta:_(u(),w()).nullish(),form:QC.nullish(),url:sT.nullish()}),oT=p({elicitationId:pg,url:u().url()}),gg=p({const:u(),title:u()}),mg=p({_meta:_(u(),w()).nullish(),name:u(),value:u()}),aT=Z([A(-32700),A(-32600),A(-32601),A(-32602),A(-32603),A(-32800),A(-32e3),A(-32002),A(-32042),U().int().min(-2147483648,{message:"Invalid value: Expected int32 to be >= -2147483648"}).max(2147483647,{message:"Invalid value: Expected int32 to be <= 2147483647"})]),vg=p({code:aT,data:w().optional(),message:u()}),yg=w(),bg=w(),wg=w(),lT=p({_meta:_(u(),w()).nullish(),readTextFile:ke().optional().default(!1),writeTextFile:ke().optional().default(!1)}),_g=p({_meta:_(u(),w()).nullish(),name:u(),value:u()}),Sg=p({_meta:_(u(),w()).nullish(),name:u(),title:u().nullish(),version:u()}),cT=p({default:U().nullish(),description:u().nullish(),maximum:U().nullish(),minimum:U().nullish(),title:u().nullish()}),uT=p({_meta:_(u(),w()).nullish()}),hT=p({_meta:_(u(),w()).nullish(),additionalDirectories:R(u()).optional(),cursor:u().nullish(),cwd:u().nullish()}),dT=p({_meta:_(u(),w()).nullish()}),fT=p({_meta:_(u(),w()).nullish(),logout:dT.nullish()}),pT=p({_meta:_(u(),w()).nullish()}),gT=p({_meta:_(u(),w()).nullish()}),mT=p({_meta:_(u(),w()).nullish(),http:ke().optional().default(!1),sse:ke().optional().default(!1)}),vT=p({_meta:_(u(),w()).nullish(),headers:R(_g),name:u(),url:u()}),yT=p({_meta:_(u(),w()).nullish(),headers:R(_g),name:u(),url:u()}),bT=p({_meta:_(u(),w()).nullish(),args:R(u()),command:u(),env:R(mg),name:u()}),Go=Z([vT.and(p({type:A("http")})),yT.and(p({type:A("sse")})),bT]),Dc=u(),wT=p({_meta:_(u(),w()).nullish(),description:u().nullish(),modelId:Dc,name:u()}),_T=Z([A("error"),A("warning"),A("information"),A("hint")]),ST=p({_meta:_(u(),w()).nullish()}),kT=p({_meta:_(u(),w()).nullish()}),ET=p({_meta:_(u(),w()).nullish()}),$T=p({_meta:_(u(),w()).nullish()}),AT=p({_meta:_(u(),w()).nullish()}),xT=p({_meta:_(u(),w()).nullish(),maxCount:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),CT=p({diff:u(),uri:u()}),TT=p({endLine:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),startLine:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),text:u()}),IT=p({_meta:_(u(),w()).nullish()}),PT=p({_meta:_(u(),w()).nullish()}),RT=p({languageId:u(),text:u(),uri:u()}),DT=p({_meta:_(u(),w()).nullish(),maxCount:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),OT=Z([A("rejected"),A("ignored"),A("replaced"),A("cancelled")]),zT=p({excerpts:R(TT),uri:u()}),LT=p({_meta:_(u(),w()).nullish()}),MT=p({_meta:_(u(),w()).nullish()}),NT=p({name:u(),owner:u(),remoteUrl:u()}),UT=p({_meta:_(u(),w()).nullish()}),FT=p({_meta:_(u(),w()).nullish(),jump:IT.nullish(),rename:MT.nullish(),searchAndReplace:UT.nullish()}),ZT=p({id:u(),isRegex:ke().nullish(),replace:u(),search:u(),uri:u()}),jT=Z([A("automatic"),A("diagnostic"),A("manual")]),WT=p({_meta:_(u(),w()).nullish(),maxCount:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),BT=p({_meta:_(u(),w()).nullish(),diagnostics:ST.nullish(),editHistory:xT.nullish(),openFiles:PT.nullish(),recentFiles:DT.nullish(),relatedSnippets:LT.nullish(),userActions:WT.nullish()}),VT=p({_meta:_(u(),w()).nullish(),additionalDirectories:R(u()).optional(),cwd:u(),mcpServers:R(Go)}),HT=p({default:U().nullish(),description:u().nullish(),maximum:U().nullish(),minimum:U().nullish(),title:u().nullish()}),kg=u(),GT=Z([A("allow_once"),A("allow_always"),A("reject_once"),A("reject_always")]),qT=p({_meta:_(u(),w()).nullish(),kind:GT,name:u(),optionId:kg}),YT=Z([A("high"),A("medium"),A("low")]),KT=Z([A("pending"),A("in_progress"),A("completed")]),JT=p({_meta:_(u(),w()).nullish(),content:u(),priority:YT,status:KT}),XT=p({_meta:_(u(),w()).nullish(),entries:R(JT)}),cn=p({character:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),line:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"})}),QT=p({id:u(),position:cn,uri:u()}),eI=p({id:u(),newName:u(),position:cn,uri:u()}),tI=p({action:u(),position:cn,timestampMs:U(),uri:u()}),Eg=Z([A("utf-16"),A("utf-32"),A("utf-8")]),nI=p({_meta:_(u(),w()).nullish(),auth:zC.optional().default({terminal:!1}),elicitation:iT.nullish(),fs:lT.optional().default({readTextFile:!1,writeTextFile:!1}),nes:FT.nullish(),positionEncodings:R(Eg).optional(),terminal:ke().optional().default(!1)}),rI=p({_meta:_(u(),w()).nullish(),audio:ke().optional().default(!1),embeddedContext:ke().optional().default(!1),image:ke().optional().default(!1)}),$g=U().int().gte(0).lte(65535),sI=p({_meta:_(u(),w()).nullish(),clientCapabilities:nI.optional().default({auth:{terminal:!1},fs:{readTextFile:!1,writeTextFile:!1},terminal:!1}),clientInfo:Sg.nullish(),protocolVersion:$g}),qr=p({end:cn,start:cn}),iI=p({message:u(),range:qr,severity:_T,uri:u()}),oI=p({languageId:u(),lastFocusedMs:U().nullish(),uri:u(),visibleRange:qr.nullish()}),aI=p({_meta:_(u(),w()).nullish(),diagnostics:R(iI).nullish(),editHistory:R(CT).nullish(),openFiles:R(oI).nullish(),recentFiles:R(RT).nullish(),relatedSnippets:R(zT).nullish(),userActions:R(tI).nullish()}),lI=p({newText:u(),range:qr}),cI=p({cursorPosition:cn.nullish(),edits:R(lI),id:u(),uri:u()}),uI=Z([cI.and(p({kind:A("edit")})),QT.and(p({kind:A("jump")})),eI.and(p({kind:A("rename")})),ZT.and(p({kind:A("searchAndReplace")}))]),hI=p({_meta:_(u(),w()).nullish(),content:u()}),dI=p({_meta:_(u(),w()).nullish()}),jn=Z([U(),u()]).nullable();p({_meta:_(u(),w()).nullish(),requestId:jn});const fI=wo(["assistant","user"]),vi=p({_meta:_(u(),w()).nullish(),audience:R(fI).nullish(),lastModified:u().nullish(),priority:U().nullish()}),pI=p({_meta:_(u(),w()).nullish(),annotations:vi.nullish(),data:u(),mimeType:u()}),gI=p({_meta:_(u(),w()).nullish(),annotations:vi.nullish(),data:u(),mimeType:u(),uri:u().nullish()}),mI=p({_meta:_(u(),w()).nullish(),annotations:vi.nullish(),description:u().nullish(),mimeType:u().nullish(),name:u(),size:U().nullish(),title:u().nullish(),uri:u()}),vI=p({_meta:_(u(),w()).nullish(),optionId:kg}),yI=Z([p({outcome:A("cancelled")}),vI.and(p({outcome:A("selected")}))]),bI=p({_meta:_(u(),w()).nullish(),outcome:yI}),wI=p({_meta:_(u(),w()).nullish()}),_I=p({_meta:_(u(),w()).nullish()}),SI=p({currentValue:ke()}),kI=u(),Ag=u(),EI=Z([A("mode"),A("model"),A("thought_level"),u()]),Oc=u(),xg=p({_meta:_(u(),w()).nullish(),description:u().nullish(),name:u(),value:Oc}),$I=p({_meta:_(u(),w()).nullish(),group:kI,name:u(),options:R(xg)}),AI=Z([R(xg),R($I)]),xI=p({currentValue:Oc,options:AI}),Yr=Ho(Z([xI.and(p({type:A("select")})),SI.and(p({type:A("boolean")}))]),p({_meta:_(u(),w()).nullish(),category:EI.nullish(),description:u().nullish(),id:Ag,name:u()})),CI=p({_meta:_(u(),w()).nullish(),configOptions:R(Yr)}),TI=p({_meta:_(u(),w()).nullish()}),K=u(),II=p({_meta:_(u(),w()).nullish(),id:u(),sessionId:K}),PI=p({_meta:_(u(),w()).nullish(),sessionId:K}),RI=p({_meta:_(u(),w()).nullish(),sessionId:K}),DI=p({_meta:_(u(),w()).nullish(),sessionId:K}),Cg=p({_meta:_(u(),w()).nullish(),args:R(u()).optional(),command:u(),cwd:u().nullish(),env:R(mg).optional(),outputByteLimit:U().nullish(),sessionId:K}),OI=p({_meta:_(u(),w()).nullish(),sessionId:K,uri:u()}),zI=p({_meta:_(u(),w()).nullish(),position:cn,sessionId:K,uri:u(),version:U(),visibleRange:qr}),LI=p({_meta:_(u(),w()).nullish(),languageId:u(),sessionId:K,text:u(),uri:u(),version:U()}),MI=p({_meta:_(u(),w()).nullish(),sessionId:K,uri:u()}),NI=p({_meta:_(u(),w()).nullish(),additionalDirectories:R(u()).optional(),cwd:u(),mcpServers:R(Go).optional(),sessionId:K}),Tg=p({_meta:_(u(),w()).nullish(),sessionId:K,terminalId:u()}),UI=p({_meta:_(u(),w()).nullish(),additionalDirectories:R(u()).optional(),cwd:u(),mcpServers:R(Go),sessionId:K}),Ig=p({_meta:_(u(),w()).nullish(),limit:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),line:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:u(),sessionId:K}),FI=p({_meta:_(u(),w()).nullish(),id:u(),reason:OT.nullish(),sessionId:K}),Pg=p({_meta:_(u(),w()).nullish(),sessionId:K,terminalId:u()}),ZI=p({_meta:_(u(),w()).nullish(),additionalDirectories:R(u()).optional(),cwd:u(),mcpServers:R(Go).optional(),sessionId:K}),jI=p({_meta:_(u(),w()).nullish(),additionalDirectories:R(u()).optional(),cwd:u(),sessionId:K,title:u().nullish(),updatedAt:u().nullish()}),WI=p({_meta:_(u(),w()).nullish(),nextCursor:u().nullish(),sessions:R(jI)}),BI=p({_meta:_(u(),w()).nullish(),title:u().nullish(),updatedAt:u().nullish()}),VI=p({_meta:_(u(),w()).nullish()}),qo=u(),HI=p({_meta:_(u(),w()).nullish(),currentModeId:qo}),GI=p({_meta:_(u(),w()).nullish(),description:u().nullish(),id:qo,name:u()}),Yo=p({_meta:_(u(),w()).nullish(),availableModes:R(GI),currentModeId:qo}),Ko=p({_meta:_(u(),w()).nullish(),availableModels:R(wT),currentModelId:Dc}),qI=p({_meta:_(u(),w()).nullish(),configOptions:R(Yr).nullish(),models:Ko.nullish(),modes:Yo.nullish(),sessionId:K}),YI=p({_meta:_(u(),w()).nullish(),configOptions:R(Yr).nullish(),models:Ko.nullish(),modes:Yo.nullish()}),KI=p({_meta:_(u(),w()).nullish(),configOptions:R(Yr).nullish(),models:Ko.nullish(),modes:Yo.nullish(),sessionId:K}),JI=p({_meta:_(u(),w()).nullish(),configOptions:R(Yr).nullish(),models:Ko.nullish(),modes:Yo.nullish()}),XI=p({_meta:_(u(),w()).nullish()}),QI=p({_meta:_(u(),w()).nullish(),additionalDirectories:wI.nullish(),close:_I.nullish(),fork:TI.nullish(),list:VI.nullish(),resume:XI.nullish()}),eP=Ho(Z([p({type:A("boolean"),value:ke()}),p({value:Oc})]),p({_meta:_(u(),w()).nullish(),configId:Ag,sessionId:K})),tP=p({_meta:_(u(),w()).nullish(),configOptions:R(Yr)}),nP=p({_meta:_(u(),w()).nullish(),modeId:qo,sessionId:K}),rP=p({_meta:_(u(),w()).nullish()}),sP=p({_meta:_(u(),w()).nullish(),modelId:Dc,sessionId:K}),iP=p({_meta:_(u(),w()).nullish()}),oP=p({_meta:_(u(),w()).nullish(),sessionId:K}),aP=Z([A("end_turn"),A("max_tokens"),A("max_turn_requests"),A("refusal"),A("cancelled")]),lP=Z([A("email"),A("uri"),A("date"),A("date-time")]),cP=p({default:u().nullish(),description:u().nullish(),enum:R(u()).nullish(),format:lP.nullish(),maxLength:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),minLength:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),oneOf:R(gg).nullish(),pattern:u().nullish(),title:u().nullish()}),uP=p({_meta:_(u(),w()).nullish(),context:aI.nullish(),position:cn,selection:qr.nullish(),sessionId:K,triggerKind:jT,uri:u(),version:U()}),hP=p({_meta:_(u(),w()).nullish(),suggestions:R(uI)}),dP=p({_meta:_(u(),w()).nullish(),terminalId:u()}),fP=p({_meta:_(u(),w()).nullish(),exitCode:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:u().nullish()}),Rg=p({_meta:_(u(),w()).nullish(),sessionId:K,terminalId:u()}),pP=p({_meta:_(u(),w()).nullish(),exitStatus:fP.nullish(),output:u(),truncated:ke()}),gP=p({_meta:_(u(),w()).nullish(),annotations:vi.nullish(),text:u()}),mP=p({range:qr.nullish(),text:u()}),vP=p({_meta:_(u(),w()).nullish(),contentChanges:R(mP),sessionId:K,uri:u(),version:U()});p({method:u(),params:Z([PI,LI,vP,OI,MI,zI,II,FI,yg]).nullish()});const yP=Z([A("full"),A("incremental")]),bP=p({_meta:_(u(),w()).nullish(),syncKind:yP}),wP=p({_meta:_(u(),w()).nullish(),didChange:bP.nullish(),didClose:kT.nullish(),didFocus:ET.nullish(),didOpen:$T.nullish(),didSave:AT.nullish()}),_P=p({_meta:_(u(),w()).nullish(),document:wP.nullish()}),SP=p({_meta:_(u(),w()).nullish(),context:BT.nullish(),events:_P.nullish()}),kP=p({_meta:_(u(),w()).nullish(),auth:fT.optional().default({}),loadSession:ke().optional().default(!1),mcpCapabilities:mT.optional().default({http:!1,sse:!1}),nes:SP.nullish(),positionEncoding:Eg.nullish(),promptCapabilities:rI.optional().default({audio:!1,embeddedContext:!1,image:!1}),sessionCapabilities:QI.optional().default({})}),EP=p({_meta:_(u(),w()).nullish(),agentCapabilities:kP.optional().default({auth:{},loadSession:!1,mcpCapabilities:{http:!1,sse:!1},promptCapabilities:{audio:!1,embeddedContext:!1,image:!1},sessionCapabilities:{}}),agentInfo:Sg.nullish(),authMethods:R(FC).optional().default([]),protocolVersion:$g}),$P=p({_meta:_(u(),w()).nullish(),mimeType:u().nullish(),text:u(),uri:u()}),AP=Z([$P,WC]),xP=p({_meta:_(u(),w()).nullish(),annotations:vi.nullish(),resource:AP}),zc=Z([gP.and(p({type:A("text")})),gI.and(p({type:A("image")})),pI.and(p({type:A("audio")})),mI.and(p({type:A("resource_link")})),xP.and(p({type:A("resource")}))]),CP=p({_meta:_(u(),w()).nullish(),content:zc}),ja=p({_meta:_(u(),w()).nullish(),content:zc,messageId:u().nullish()}),TP=p({_meta:_(u(),w()).nullish(),messageId:u().nullish(),prompt:R(zc),sessionId:K}),IP=p({anyOf:R(gg)}),Dg=Z([CP.and(p({type:A("content")})),YC.and(p({type:A("diff")})),dP.and(p({type:A("terminal")}))]),Og=u(),zg=p({_meta:_(u(),w()).nullish(),line:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:u()}),Lg=Z([A("pending"),A("in_progress"),A("completed"),A("failed")]),Mg=Z([A("read"),A("edit"),A("delete"),A("move"),A("search"),A("execute"),A("think"),A("fetch"),A("switch_mode"),A("other")]),PP=p({_meta:_(u(),w()).nullish(),content:R(Dg).optional(),kind:Mg.optional(),locations:R(zg).optional(),rawInput:w().optional(),rawOutput:w().optional(),status:Lg.optional(),title:u(),toolCallId:Og}),Ng=p({_meta:_(u(),w()).nullish(),content:R(Dg).nullish(),kind:Mg.nullish(),locations:R(zg).nullish(),rawInput:w().optional(),rawOutput:w().optional(),status:Lg.nullish(),title:u().nullish(),toolCallId:Og}),Ug=p({_meta:_(u(),w()).nullish(),options:R(qT),sessionId:K,toolCall:Ng}),RP=p({_meta:_(u(),w()).nullish(),hint:u()}),DP=RP,OP=p({_meta:_(u(),w()).nullish(),description:u(),input:DP.nullish(),name:u()}),zP=p({_meta:_(u(),w()).nullish(),availableCommands:R(OP)}),LP=p({enum:R(u()),type:rT}),MP=Z([LP,IP]),NP=p({default:R(u()).nullish(),description:u().nullish(),items:MP,maxItems:U().nullish(),minItems:U().nullish(),title:u().nullish()}),UP=Z([cP.and(p({type:A("string")})),HT.and(p({type:A("number")})),cT.and(p({type:A("integer")})),BC.and(p({type:A("boolean")})),NP.and(p({type:A("array")}))]),FP=p({description:u().nullish(),properties:_(u(),UP).optional().default({}),required:R(u()).nullish(),title:u().nullish(),type:nT.optional().default("object")}),ZP=p({requestedSchema:FP}),jP=Ho(Z([ZP.and(p({mode:A("form")})),oT.and(p({mode:A("url")}))]),p({_meta:_(u(),w()).nullish(),message:u(),sessionId:K})),WP=p({cachedReadTokens:U().nullish(),cachedWriteTokens:U().nullish(),inputTokens:U(),outputTokens:U(),thoughtTokens:U().nullish(),totalTokens:U()}),BP=p({_meta:_(u(),w()).nullish(),stopReason:aP,usage:WP.nullish(),userMessageId:u().nullish()});Z([p({id:jn,result:Z([EP,jC,gT,KI,YI,WI,qI,JI,HC,rP,tP,BP,iP,oP,hP,VC,wg])}),p({error:vg,id:jn})]);const VP=p({_meta:_(u(),w()).nullish(),cost:GC.nullish(),size:U(),used:U()}),HP=Z([ja.and(p({sessionUpdate:A("user_message_chunk")})),ja.and(p({sessionUpdate:A("agent_message_chunk")})),ja.and(p({sessionUpdate:A("agent_thought_chunk")})),PP.and(p({sessionUpdate:A("tool_call")})),Ng.and(p({sessionUpdate:A("tool_call_update")})),XT.and(p({sessionUpdate:A("plan")})),zP.and(p({sessionUpdate:A("available_commands_update")})),HI.and(p({sessionUpdate:A("current_mode_update")})),CI.and(p({sessionUpdate:A("config_option_update")})),BI.and(p({sessionUpdate:A("session_info_update")})),VP.and(p({sessionUpdate:A("usage_update")}))]),Fg=p({_meta:_(u(),w()).nullish(),sessionId:K,update:HP});p({method:u(),params:Z([Fg,eT,yg]).nullish()});const Zg=p({_meta:_(u(),w()).nullish(),sessionId:K,terminalId:u()}),GP=p({_meta:_(u(),w()).nullish(),exitCode:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:u().nullish()}),qP=p({name:u(),uri:u()}),YP=p({_meta:_(u(),w()).nullish(),repository:NT.nullish(),workspaceFolders:R(qP).nullish(),workspaceUri:u().nullish()});p({id:jn,method:u(),params:Z([sI,ZC,pT,VT,UI,hT,NI,ZI,DI,nP,eP,TP,sP,YP,uP,RI,bg]).nullish()});const jg=p({_meta:_(u(),w()).nullish(),content:u(),path:u(),sessionId:K});p({id:jn,method:u(),params:Z([jg,Ig,Ug,Cg,Rg,Pg,Zg,Tg,jP,bg]).nullish()});const KP=p({_meta:_(u(),w()).nullish()});Z([p({id:jn,result:Z([KP,hI,bI,qC,pP,dI,GP,uT,tT,wg])}),p({error:vg,id:jn})]);var Y;class JP{constructor(e,n){x(this,Y);const r=e(this),s=async(o,a)=>{var l,c,d,f,y,m,E;switch(o){case Ct.fs_write_text_file:{const k=jg.parse(a);return(l=r.writeTextFile)==null?void 0:l.call(r,k)}case Ct.fs_read_text_file:{const k=Ig.parse(a);return(c=r.readTextFile)==null?void 0:c.call(r,k)}case Ct.session_request_permission:{const k=Ug.parse(a);return r.requestPermission(k)}case Ct.terminal_create:{const k=Cg.parse(a);return(d=r.createTerminal)==null?void 0:d.call(r,k)}case Ct.terminal_output:{const k=Rg.parse(a);return(f=r.terminalOutput)==null?void 0:f.call(r,k)}case Ct.terminal_release:{const k=Pg.parse(a);return await((y=r.releaseTerminal)==null?void 0:y.call(r,k))??{}}case Ct.terminal_wait_for_exit:{const k=Zg.parse(a);return(m=r.waitForTerminalExit)==null?void 0:m.call(r,k)}case Ct.terminal_kill:{const k=Tg.parse(a);return await((E=r.killTerminal)==null?void 0:E.call(r,k))??{}}default:if(r.extMethod)return r.extMethod(o,a);throw ye.methodNotFound(o)}},i=async(o,a)=>{switch(o){case Ct.session_update:{const l=Fg.parse(a);return r.sessionUpdate(l)}default:if(r.extNotification)return r.extNotification(o,a);throw ye.methodNotFound(o)}};$(this,Y,new XP(s,i,n))}async initialize(e){return await h(this,Y).sendRequest(ie.initialize,e)}async newSession(e){return await h(this,Y).sendRequest(ie.session_new,e)}async loadSession(e){return await h(this,Y).sendRequest(ie.session_load,e)??{}}async unstable_forkSession(e){return await h(this,Y).sendRequest(ie.session_fork,e)}async listSessions(e){return await h(this,Y).sendRequest(ie.session_list,e)}async unstable_resumeSession(e){return await h(this,Y).sendRequest(ie.session_resume,e)}async unstable_closeSession(e){return await h(this,Y).sendRequest(ie.session_close,e)}async setSessionMode(e){return await h(this,Y).sendRequest(ie.session_set_mode,e)??{}}async unstable_setSessionModel(e){return await h(this,Y).sendRequest(ie.session_set_model,e)??{}}async setSessionConfigOption(e){return await h(this,Y).sendRequest(ie.session_set_config_option,e)}async authenticate(e){return await h(this,Y).sendRequest(ie.authenticate,e)??{}}async unstable_logout(e){return await h(this,Y).sendRequest(ie.logout,e)??{}}async prompt(e){return await h(this,Y).sendRequest(ie.session_prompt,e)}async cancel(e){return await h(this,Y).sendNotification(ie.session_cancel,e)}async unstable_startNes(e){return await h(this,Y).sendRequest(ie.nes_start,e)}async unstable_suggestNes(e){return await h(this,Y).sendRequest(ie.nes_suggest,e)}async unstable_closeNes(e){return await h(this,Y).sendRequest(ie.nes_close,e)??{}}async unstable_didOpenDocument(e){return await h(this,Y).sendNotification(ie.document_did_open,e)}async unstable_didChangeDocument(e){return await h(this,Y).sendNotification(ie.document_did_change,e)}async unstable_didCloseDocument(e){return await h(this,Y).sendNotification(ie.document_did_close,e)}async unstable_didSaveDocument(e){return await h(this,Y).sendNotification(ie.document_did_save,e)}async unstable_didFocusDocument(e){return await h(this,Y).sendNotification(ie.document_did_focus,e)}async unstable_acceptNes(e){return await h(this,Y).sendNotification(ie.nes_accept,e)}async unstable_rejectNes(e){return await h(this,Y).sendNotification(ie.nes_reject,e)}async extMethod(e,n){return await h(this,Y).sendRequest(e,n)}async extNotification(e,n){return await h(this,Y).sendNotification(e,n)}get signal(){return h(this,Y).signal}get closed(){return h(this,Y).closed}}Y=new WeakMap;var Kt,Co,Zs,js,_r,Sr,bt,Ws,ae,Wg,_l,Bg,Vg,Hg,Gg,Sl,ms;class XP{constructor(e,n,r){x(this,ae);x(this,Kt,new Map);x(this,Co,0);x(this,Zs);x(this,js);x(this,_r);x(this,Sr,Promise.resolve());x(this,bt,new AbortController);x(this,Ws);$(this,Zs,e),$(this,js,n),$(this,_r,r),$(this,Ws,new Promise(s=>{h(this,bt).signal.addEventListener("abort",()=>s())})),b(this,ae,Wg).call(this)}get signal(){return h(this,bt).signal}get closed(){return h(this,Ws)}async sendRequest(e,n){b(this,ae,Sl).call(this);const r=ku(this,Co)._++,s=new Promise((i,o)=>{h(this,Kt).set(r,{resolve:i,reject:o})});return await b(this,ae,ms).call(this,{jsonrpc:"2.0",id:r,method:e,params:n}),s}async sendNotification(e,n){b(this,ae,Sl).call(this),await b(this,ae,ms).call(this,{jsonrpc:"2.0",method:e,params:n})}}Kt=new WeakMap,Co=new WeakMap,Zs=new WeakMap,js=new WeakMap,_r=new WeakMap,Sr=new WeakMap,bt=new WeakMap,Ws=new WeakMap,ae=new WeakSet,Wg=async function(){let e;try{const n=h(this,_r).readable.getReader();try{for(;!h(this,bt).signal.aborted;){const{value:r,done:s}=await n.read();if(s)break;if(r)try{b(this,ae,Bg).call(this,r)}catch(i){console.error("Unexpected error during message processing:",r,i),"id"in r&&r.id!==void 0&&b(this,ae,ms).call(this,{jsonrpc:"2.0",id:r.id,error:{code:-32700,message:"Parse error"}})}}}finally{n.releaseLock()}}catch(n){e=n}finally{b(this,ae,_l).call(this,e)}},_l=function(e){if(h(this,bt).signal.aborted)return;const n=e??new Error("ACP connection closed");for(const r of h(this,Kt).values())r.reject(n);h(this,Kt).clear(),h(this,bt).abort(n)},Bg=async function(e){if("method"in e&&"id"in e){const n=await b(this,ae,Vg).call(this,e.method,e.params);"error"in n&&console.error("Error handling request",e,n.error),await b(this,ae,ms).call(this,{jsonrpc:"2.0",id:e.id,...n})}else if("method"in e){const n=await b(this,ae,Hg).call(this,e.method,e.params);"error"in n&&console.error("Error handling notification",e,n.error)}else"id"in e?b(this,ae,Gg).call(this,e):console.error("Invalid message",{message:e})},Vg=async function(e,n){try{return{result:await h(this,Zs).call(this,e,n)??null}}catch(r){if(r instanceof ye)return r.toResult();if(r instanceof pd)return ye.invalidParams(r.format()).toResult();let s;(r instanceof Error||typeof r=="object"&&r!=null&&"message"in r&&typeof r.message=="string")&&(s=r.message);try{return ye.internalError(s?JSON.parse(s):{}).toResult()}catch{return ye.internalError({details:s}).toResult()}}},Hg=async function(e,n){try{return await h(this,js).call(this,e,n),{result:null}}catch(r){if(r instanceof ye)return r.toResult();if(r instanceof pd)return ye.invalidParams(r.format()).toResult();let s;(r instanceof Error||typeof r=="object"&&r!=null&&"message"in r&&typeof r.message=="string")&&(s=r.message);try{return ye.internalError(s?JSON.parse(s):{}).toResult()}catch{return ye.internalError({details:s}).toResult()}}},Gg=function(e){const n=h(this,Kt).get(e.id);if(n){if("result"in e)n.resolve(e.result);else if("error"in e){const{code:r,message:s,data:i}=e.error;n.reject(new ye(r,s,i))}h(this,Kt).delete(e.id)}else console.error("Got response to unknown request",e.id)},Sl=function(){if(h(this,bt).signal.aborted)throw h(this,bt).signal.reason??new Error("ACP connection closed")},ms=async function(e){return $(this,Sr,h(this,Sr).then(async()=>{const n=h(this,_r).writable.getWriter();try{await n.write(e)}finally{n.releaseLock()}}).catch(n=>{b(this,ae,_l).call(this,n)})),h(this,Sr)};class ye extends Error{constructor(n,r,s){super(r);v(this,"code");v(this,"data");this.code=n,this.name="RequestError",this.data=s}static parseError(n,r){return new ye(-32700,`Parse error${r?`: ${r}`:""}`,n)}static invalidRequest(n,r){return new ye(-32600,`Invalid request${r?`: ${r}`:""}`,n)}static methodNotFound(n){return new ye(-32601,`"Method not found": ${n}`,{method:n})}static invalidParams(n,r){return new ye(-32602,`Invalid params${r?`: ${r}`:""}`,n)}static internalError(n,r){return new ye(-32603,`Internal error${r?`: ${r}`:""}`,n)}static authRequired(n,r){return new ye(-32e3,`Authentication required${r?`: ${r}`:""}`,n)}static resourceNotFound(n){return new ye(-32002,`Resource not found${n?`: ${n}`:""}`,n&&{uri:n})}toResult(){return{error:{code:this.code,message:this.message,data:this.data}}}toErrorResponse(){return{code:this.code,message:this.message,data:this.data}}}const QP=/^Sender \(untrusted metadata\):\n```json\n[\s\S]*?\n```\n\n?/,e1=/^\[[^\n]*Working directory:[^\n]*\]\n\n?/,t1=/\[Television screen context\][\s\S]*?\[\/Television screen context\]\n*/,n1=/\[\[\s*(?:reply_to_current|reply_to\s*:\s*[^\]\n]+|audio_as_voice)\s*\]\]\s*/gi,r1="single_session",s1={name:"television-acp-client",version:"0.0.0"},qg="agent:main:television",i1=Hr(kt);var re,Rt,kr,Dt,Dn,On,Jt,Er,wt,st,Xt,zn,Ot,Qt,Bs,zt,it,To,Lt,T,Yg,Kg,kl,Jg,Xg,Qg,em,tm,nm,rm,wn,cr,ur,He,sm,hr,El,$l,ro,im,Vs,Hs,Al,dr,om,am;class o1 extends i1{constructor(n){super();x(this,T);x(this,re,a1());x(this,Rt,null);x(this,kr,null);x(this,Dt,null);x(this,Dn,null);x(this,On,null);x(this,Jt,null);x(this,Er,1);x(this,wt,null);x(this,st,null);x(this,Xt,!1);x(this,zn,!1);x(this,Ot,null);x(this,Qt,new Set);x(this,Bs);x(this,zt);x(this,it);x(this,To,n=>{b(this,T,Kg).call(this,n)});x(this,Lt,null);x(this,Vs,()=>{b(this,T,dr).call(this,"ACP bridge websocket closed")});x(this,Hs,()=>{b(this,T,dr).call(this,"ACP bridge websocket error")});$(this,zt,n),$(this,it,n.sessionMode??r1),$(this,Bs,n.createSocket??(r=>new WebSocket(r)))}getState(){return h(this,re)}async connect(){if(this.disposed)throw new Error("ACPClient has been disposed");if(h(this,re).lifecycle.status!=="ready"){b(this,T,He).call(this,{lifecycle:{status:"connecting"}}),h(this,kr)??$(this,kr,b(this,T,Yg).call(this));try{await h(this,kr),await b(this,T,kl).call(this)}catch(n){throw b(this,T,dr).call(this,Fi(n)),n}}}dispose(){b(this,T,Al).call(this),b(this,T,He).call(this,{lifecycle:{status:"disposed"},run:{status:"idle",stopReason:null,canCancel:!1,error:null}})}async sendMessage(n){if(await this.connect(),h(this,re).lifecycle.status!=="ready"||h(this,re).run.status==="running"||h(this,re).run.status==="cancelling")throw new Error("ACPClient is not ready to send a new message");const r=n.text.trim();if(!r)throw new Error("Cannot send an empty message");b(this,T,cr).call(this,{id:b(this,T,hr).call(this,"user"),kind:"user",text:r,status:"final"}),b(this,T,He).call(this,{run:{status:"running",stopReason:null,canCancel:!0,error:null}});try{const s=await b(this,T,ro).call(this).prompt({sessionId:b(this,T,$l).call(this),prompt:[{type:"text",text:b(this,T,sm).call(this,r)}]});b(this,T,wn).call(this,s.stopReason==="cancelled"?"cancelled":"final"),b(this,T,He).call(this,{run:{status:s.stopReason==="cancelled"?"cancelled":"completed",stopReason:s.stopReason,canCancel:!1,error:null}})}catch(s){throw b(this,T,am).call(this)||(b(this,T,wn).call(this,"error"),b(this,T,He).call(this,{run:{status:"error",stopReason:null,canCancel:!1,error:Fi(s)}})),s}}async cancel(){if(await this.connect(),!h(this,re).run.canCancel||h(this,re).run.status!=="running")throw new Error("No active cancellable run");b(this,T,He).call(this,{run:{...h(this,re).run,status:"cancelling"}}),await b(this,T,ro).call(this).cancel({sessionId:b(this,T,$l).call(this)})}setScreenContext(n){var i,o,a;const r={screenID:n.screenID,screenName:n.screenName};if(((i=h(this,st))==null?void 0:i.screenID)===r.screenID&&((o=h(this,st))==null?void 0:o.screenName)===r.screenName)return;const s=((a=h(this,st))==null?void 0:a.screenID)??null;if($(this,st,r),h(this,it)==="single_session"){(!h(this,Jt)||s!==r.screenID)&&$(this,Xt,!0);return}h(this,Jt)!==wd(h(this,it),r.screenID,h(this,zt).clientGUID??"default-client")&&($(this,Dt,null),$(this,Dn,null),h(this,Rt)&&h(this,re).run.status==="idle"&&b(this,T,kl).call(this).catch(l=>{b(this,T,dr).call(this,Fi(l))}))}}re=new WeakMap,Rt=new WeakMap,kr=new WeakMap,Dt=new WeakMap,Dn=new WeakMap,On=new WeakMap,Jt=new WeakMap,Er=new WeakMap,wt=new WeakMap,st=new WeakMap,Xt=new WeakMap,zn=new WeakMap,Ot=new WeakMap,Qt=new WeakMap,Bs=new WeakMap,zt=new WeakMap,it=new WeakMap,To=new WeakMap,Lt=new WeakMap,T=new WeakSet,Yg=async function(){try{b(this,T,He).call(this,{lifecycle:{status:"connecting"}});const{stream:n,socket:r}=await u1({serverURL:h(this,zt).serverURL,token:h(this,zt).token,createSocket:h(this,Bs),onDisconnect:h(this,To)});$(this,Lt,r),r.addEventListener("close",h(this,Vs)),r.addEventListener("error",h(this,Hs)),$(this,Rt,new JP(s=>({connection:s,sessionUpdate:async i=>{await b(this,T,Xg).call(this,i)},requestPermission:async i=>b(this,T,Qg).call(this,i)}),n)),await h(this,Rt).initialize({protocolVersion:OC,clientCapabilities:{},clientInfo:s1})}catch(n){throw n}},Kg=function(n){b(this,T,dr).call(this,Fi(n))},kl=async function(){const n=b(this,T,im).call(this);if(h(this,Dt)&&h(this,Dn)===n){await h(this,Dt);return}$(this,Dn,n),$(this,Dt,b(this,T,Jg).call(this,n)),await h(this,Dt)},Jg=async function(n){const r=b(this,T,ro).call(this);b(this,T,om).call(this);let s,i=!1;try{$(this,zn,!0),$(this,Ot,null),await r.loadSession({sessionId:n,cwd:"/",mcpServers:[],_meta:{sessionKey:n}}),s=n,i=h(this,re).messageOrder.length>0}catch{s=(await r.newSession({cwd:"/",mcpServers:[],_meta:{sessionKey:n}})).sessionId,i=!1}finally{$(this,zn,!1),$(this,Ot,null),b(this,T,wn).call(this,"final")}await r.setSessionConfigOption({sessionId:s,configId:"verbose_level",value:"full"}),$(this,On,s),$(this,Jt,n),i?(h(this,Qt).add(n),h(this,it)==="single_session"&&$(this,Xt,!1)):(h(this,Qt).delete(n),$(this,Xt,h(this,it)==="single_session")),b(this,T,He).call(this,{lifecycle:{status:"ready"}})},Xg=async function(n){const r=n.update;switch(r.sessionUpdate){case"user_message_chunk":r.content.type==="text"&&b(this,T,rm).call(this,r.content.text);return;case"agent_message_chunk":r.content.type==="text"&&b(this,T,em).call(this,r.content.text);return;case"tool_call":b(this,T,tm).call(this,r);return;case"tool_call_update":b(this,T,nm).call(this,r);return;case"agent_thought_chunk":return;default:return}},Qg=async function(n){return{outcome:{outcome:"cancelled"}}},em=function(n){$(this,Ot,null);const r=l1(n);if(!r)return;if(!h(this,wt)){const i={id:b(this,T,hr).call(this,"assistant"),kind:"assistant",text:r,status:"streaming"};$(this,wt,i.id),b(this,T,cr).call(this,i);return}const s=h(this,re).messagesById[h(this,wt)];if(!s||s.kind!=="assistant")throw new Error("Open assistant message invariant violated");b(this,T,ur).call(this,{...s,text:`${s.text}${r}`,status:"streaming"})},tm=function(n){b(this,T,wn).call(this,"final");const r=b(this,T,El).call(this,n.toolCallId),s={id:(r==null?void 0:r.id)??b(this,T,hr).call(this,"tool"),kind:"tool_call",toolCallId:n.toolCallId,title:n.title,toolKind:n.kind??"other",status:n.status==="failed"?"failed":n.status==="completed"?"completed":"in_progress",text:(r==null?void 0:r.text)??"",locations:n.locations??(r==null?void 0:r.locations)};if(r){b(this,T,ur).call(this,s);return}b(this,T,cr).call(this,s)},nm=function(n){const r=b(this,T,El).call(this,n.toolCallId),s=(r==null?void 0:r.text)??"",i=c1(n.content),o=i?`${s}${i}`:s,a={id:(r==null?void 0:r.id)??b(this,T,hr).call(this,"tool"),kind:"tool_call",toolCallId:n.toolCallId,title:(r==null?void 0:r.title)??n.toolCallId,toolKind:(r==null?void 0:r.toolKind)??"other",status:n.status==="failed"?"failed":n.status==="completed"?"completed":"in_progress",text:o,locations:n.locations??(r==null?void 0:r.locations)};if(r){b(this,T,ur).call(this,a);return}b(this,T,cr).call(this,a)},rm=function(n){if(b(this,T,wn).call(this,"final"),!n)return;const r=h(this,zn)?h(this,Ot):null;if(!r){const i=_d(n);if(!i)return;const o={id:b(this,T,hr).call(this,"user"),kind:"user",text:i,status:"final"};b(this,T,cr).call(this,o),h(this,zn)&&$(this,Ot,o.id);return}const s=h(this,re).messagesById[r];if(!s||s.kind!=="user")throw new Error("Replay user message invariant violated");b(this,T,ur).call(this,{...s,text:_d(`${s.text}${n}`)})},wn=function(n){if(!h(this,wt))return;const r=h(this,re).messagesById[h(this,wt)];(r==null?void 0:r.kind)==="assistant"&&b(this,T,ur).call(this,{...r,status:n}),$(this,wt,null)},cr=function(n){b(this,T,He).call(this,{messagesById:{...h(this,re).messagesById,[n.id]:n},messageOrder:[...h(this,re).messageOrder,n.id]})},ur=function(n){b(this,T,He).call(this,{messagesById:{...h(this,re).messagesById,[n.id]:n}})},He=function(n){const r={...h(this,re),...n};$(this,re,{...r,sendDisabled:r.lifecycle.status!=="ready"||r.run.status==="running"||r.run.status==="cancelling",cancelDisabled:!(r.run.status==="running"||r.run.status==="cancelling")||!r.run.canCancel}),this.dispatchEvent(new te("change"))},sm=function(n){const r=h(this,Jt);return!h(this,st)||!r||!(h(this,it)==="single_session"?h(this,Xt)||!h(this,Qt).has(r):!h(this,Qt).has(r))?n:($(this,Xt,!1),h(this,Qt).add(r),["[Television screen context]","This chat session is coming from a Television client in the screen below.",`screen_id: ${h(this,st).screenID}`,`screen_name: ${h(this,st).screenName??""}`,"When the user asks to inspect or change Television state with the tv CLI, use this screen ID with the --screen argument.","[/Television screen context]","",n].join(`
|
|
43
|
-
`))},hr=function(n){const r=`${n}-${h(this,Er)}`;return $(this,Er,h(this,Er)+1),r},El=function(n){for(const r of h(this,re).messageOrder){const s=h(this,re).messagesById[r];if((s==null?void 0:s.kind)==="tool_call"&&s.toolCallId===n)return s}return null},$l=function(){if(!h(this,On))throw new Error("ACP session is not ready");return h(this,On)},ro=function(){if(!h(this,Rt))throw new Error("ACP connection is not ready");return h(this,Rt)},im=function(){var r;if(h(this,it)==="single_session")return`${qg}-${(h(this,zt).clientGUID??"default-client").toLowerCase()}`;const n=(r=h(this,st))==null?void 0:r.screenID;if(!n)throw new Error("Screen context is required for per-screen session mode");return wd(h(this,it),n,h(this,zt).clientGUID??"default-client")},Vs=new WeakMap,Hs=new WeakMap,Al=function(){$(this,Rt,null),$(this,kr,null),$(this,Dt,null),$(this,Dn,null),$(this,On,null),$(this,Jt,null),h(this,Lt)&&(h(this,Lt).removeEventListener("close",h(this,Vs)),h(this,Lt).removeEventListener("error",h(this,Hs)),h(this,Lt).close(),$(this,Lt,null))},dr=function(n){this.disposed||h(this,re).lifecycle.status==="disconnected"||(b(this,T,wn).call(this,"error"),b(this,T,Al).call(this),b(this,T,He).call(this,{lifecycle:{status:"disconnected",...n?{error:n}:{}},run:{status:"idle",stopReason:null,canCancel:!1,error:null}}))},om=function(){$(this,wt,null),$(this,Ot,null),$(this,Er,1),b(this,T,He).call(this,{run:{status:"idle",stopReason:null,canCancel:!1,error:null},messagesById:{},messageOrder:[]})},am=function(){return h(this,re).lifecycle.status==="disconnected"};function a1(){return{lifecycle:{status:"connecting"},run:{status:"idle",stopReason:null,canCancel:!1,error:null},messagesById:{},messageOrder:[],sendDisabled:!0,cancelDisabled:!0}}function wd(t,e,n){return t==="single_session"?`${qg}-${n.toLowerCase()}`:`agent:main:television-${n.toLowerCase()}-${e.toLowerCase()}`}function lm(t){return t.replace(/^(?:\s*\n)+/,"")}function _d(t){let e=t;return e=e.replace(QP,""),e=e.replace(e1,""),e=e.replace(t1,""),e=lm(e),e}function l1(t){let e=t;return e=e.replace(n1,""),e=lm(e),e}function c1(t){return!t||t.length===0?"":t.flatMap(e=>e.type==="content"&&e.content.type==="text"?[e.content.text]:[]).join("")}async function u1(t){const e=t.createSocket(d1(t.serverURL,t.token));let n=!1,r,s;const i=new Promise((l,c)=>{r=l,s=c}),o=new ReadableStream({start(l){let c=!1;const d=()=>{e.send(JSON.stringify({type:"acp-bridge-connect"}))},f=E=>{const k=h1(E);if(!k)return;let I;try{I=JSON.parse(k)}catch(V){const N=V instanceof Error?V:new Error(String(V));s(N),l.error(N);return}switch(I.type){case"acp-bridge-status":if(I.status==="ready"){n||(n=!0,r());return}if(I.status==="error"||I.status==="exited"){const V=new Error(I.error??`ACP bridge ${I.status}`);n||s(V),l.error(V)}return;case"acp-bridge-message":l.enqueue(I.message);return}},y=()=>{var k;if(c)return;c=!0;const E=new Error("ACP bridge websocket closed");n||s(E),(k=t.onDisconnect)==null||k.call(t,E),l.close()},m=()=>{var k;if(c)return;c=!0;const E=new Error("ACP bridge websocket error");n||s(E),(k=t.onDisconnect)==null||k.call(t,E),l.error(E)};e.addEventListener("open",d),e.addEventListener("message",f),e.addEventListener("close",y),e.addEventListener("error",m)}}),a=new WritableStream({async write(l){await i,e.send(JSON.stringify({type:"acp-bridge-message",message:l}))},close(){e.close()},abort(){e.close()}});return await i,{stream:{readable:o,writable:a},socket:e}}function h1(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 d1(t,e){const n=new URL(t);return n.protocol=n.protocol==="https:"?"wss:":"ws:",n.pathname="/acp",n.search="",n.searchParams.set("token",e),n.hash="",n.toString()}function Fi(t){return t instanceof Error?t.message:String(t)}const Sd="television.acpClientGUID",f1=Hr(kt);class p1 extends f1{constructor(n){super();v(this,"screenManager");v(this,"clients",new Map);v(this,"options");v(this,"sessionMode");v(this,"clientGUID");v(this,"activeClient",null);v(this,"handleActiveScreenChanged",()=>{this.syncActiveClient()});this.screenManager=n.screenManager,this.sessionMode=n.sessionMode??"single_session",this.options={serverURL:n.serverURL,token:n.token,...n.createSocket?{createSocket:n.createSocket}:{},...n.sessionMode?{sessionMode:n.sessionMode}:{}},this.clientGUID=n.clientGUID??g1(n.storage??window.localStorage),this.screenManager.addEventListener("active-screen-changed",this.handleActiveScreenChanged),this.syncActiveClient()}getActiveClient(){return this.activeClient}dispose(){this.screenManager.removeEventListener("active-screen-changed",this.handleActiveScreenChanged);for(const n of this.clients.values())n.dispose();this.clients.clear(),this.activeClient=null}syncActiveClient(){const n=this.screenManager.activeScreen,r=n?this.getClientForScreen(n):null;this.activeClient!==r&&(this.activeClient=r,this.dispatchEvent(new te("change")))}getClientForScreen(n){const r=this.sessionMode==="single_session"?"single_session":n.id;let s=this.clients.get(r);return s||(s=new o1({...this.options,sessionMode:this.sessionMode,clientGUID:this.clientGUID}),this.clients.set(r,s)),s.setScreenContext({screenID:n.id,screenName:n.name}),s}}function g1(t){const e=t.getItem(Sd);if(e)return e;const n=Sc().toLowerCase();return t.setItem(Sd,n),n}const m1="serverURL",v1="token",y1="mode",b1="electron";function cm(t=window.location.search,e=window.location.origin){const r=new URLSearchParams(t).get(m1);return r?new URL(r).origin:new URL(e).origin}function um(t=window.location.search){return new URLSearchParams(t).get(v1)}function hm(t=window.location.search){return new URLSearchParams(t).get(y1)===b1}/**
|
|
44
|
-
* @license
|
|
45
|
-
* Copyright 2017 Google LLC
|
|
46
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
47
|
-
*/const As=globalThis,kd=t=>t,_o=As.trustedTypes,Ed=_o?_o.createPolicy("lit-html",{createHTML:t=>t}):void 0,dm="$lit$",Ht=`lit$${Math.random().toFixed(9).slice(2)}$`,fm="?"+Ht,w1=`<${fm}>`,Wn=document,Ts=()=>Wn.createComment(""),Is=t=>t===null||typeof t!="object"&&typeof t!="function",Lc=Array.isArray,_1=t=>Lc(t)||typeof(t==null?void 0:t[Symbol.iterator])=="function",Wa=`[
|
|
48
|
-
\f\r]`,is=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,$d=/-->/g,Ad=/>/g,yn=RegExp(`>|${Wa}(?:([^\\s"'>=/]+)(${Wa}*=${Wa}*(?:[^
|
|
49
|
-
\f\r"'\`<>=]|("|')|))|$)`,"g"),xd=/'/g,Cd=/"/g,pm=/^(?:script|style|textarea|title)$/i,S1=t=>(e,...n)=>({_$litType$:t,strings:e,values:n}),M=S1(1),Lr=Symbol.for("lit-noChange"),ge=Symbol.for("lit-nothing"),Td=new WeakMap,xn=Wn.createTreeWalker(Wn,129);function gm(t,e){if(!Lc(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return Ed!==void 0?Ed.createHTML(e):e}const k1=(t,e)=>{const n=t.length-1,r=[];let s,i=e===2?"<svg>":e===3?"<math>":"",o=is;for(let a=0;a<n;a++){const l=t[a];let c,d,f=-1,y=0;for(;y<l.length&&(o.lastIndex=y,d=o.exec(l),d!==null);)y=o.lastIndex,o===is?d[1]==="!--"?o=$d:d[1]!==void 0?o=Ad:d[2]!==void 0?(pm.test(d[2])&&(s=RegExp("</"+d[2],"g")),o=yn):d[3]!==void 0&&(o=yn):o===yn?d[0]===">"?(o=s??is,f=-1):d[1]===void 0?f=-2:(f=o.lastIndex-d[2].length,c=d[1],o=d[3]===void 0?yn:d[3]==='"'?Cd:xd):o===Cd||o===xd?o=yn:o===$d||o===Ad?o=is:(o=yn,s=void 0);const m=o===yn&&t[a+1].startsWith("/>")?" ":"";i+=o===is?l+w1:f>=0?(r.push(c),l.slice(0,f)+dm+l.slice(f)+Ht+m):l+Ht+(f===-2?a:m)}return[gm(t,i+(t[n]||"<?>")+(e===2?"</svg>":e===3?"</math>":"")),r]};class Ps{constructor({strings:e,_$litType$:n},r){let s;this.parts=[];let i=0,o=0;const a=e.length-1,l=this.parts,[c,d]=k1(e,n);if(this.el=Ps.createElement(c,r),xn.currentNode=this.el.content,n===2||n===3){const f=this.el.content.firstChild;f.replaceWith(...f.childNodes)}for(;(s=xn.nextNode())!==null&&l.length<a;){if(s.nodeType===1){if(s.hasAttributes())for(const f of s.getAttributeNames())if(f.endsWith(dm)){const y=d[o++],m=s.getAttribute(f).split(Ht),E=/([.?@])?(.*)/.exec(y);l.push({type:1,index:i,name:E[2],strings:m,ctor:E[1]==="."?$1:E[1]==="?"?A1:E[1]==="@"?x1:Jo}),s.removeAttribute(f)}else f.startsWith(Ht)&&(l.push({type:6,index:i}),s.removeAttribute(f));if(pm.test(s.tagName)){const f=s.textContent.split(Ht),y=f.length-1;if(y>0){s.textContent=_o?_o.emptyScript:"";for(let m=0;m<y;m++)s.append(f[m],Ts()),xn.nextNode(),l.push({type:2,index:++i});s.append(f[y],Ts())}}}else if(s.nodeType===8)if(s.data===fm)l.push({type:2,index:i});else{let f=-1;for(;(f=s.data.indexOf(Ht,f+1))!==-1;)l.push({type:7,index:i}),f+=Ht.length-1}i++}}static createElement(e,n){const r=Wn.createElement("template");return r.innerHTML=e,r}}function Mr(t,e,n=t,r){var o,a;if(e===Lr)return e;let s=r!==void 0?(o=n._$Co)==null?void 0:o[r]:n._$Cl;const i=Is(e)?void 0:e._$litDirective$;return(s==null?void 0:s.constructor)!==i&&((a=s==null?void 0:s._$AO)==null||a.call(s,!1),i===void 0?s=void 0:(s=new i(t),s._$AT(t,n,r)),r!==void 0?(n._$Co??(n._$Co=[]))[r]=s:n._$Cl=s),s!==void 0&&(e=Mr(t,s._$AS(t,e.values),s,r)),e}class E1{constructor(e,n){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=n}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){const{el:{content:n},parts:r}=this._$AD,s=((e==null?void 0:e.creationScope)??Wn).importNode(n,!0);xn.currentNode=s;let i=xn.nextNode(),o=0,a=0,l=r[0];for(;l!==void 0;){if(o===l.index){let c;l.type===2?c=new Mc(i,i.nextSibling,this,e):l.type===1?c=new l.ctor(i,l.name,l.strings,this,e):l.type===6&&(c=new C1(i,this,e)),this._$AV.push(c),l=r[++a]}o!==(l==null?void 0:l.index)&&(i=xn.nextNode(),o++)}return xn.currentNode=Wn,s}p(e){let n=0;for(const r of this._$AV)r!==void 0&&(r.strings!==void 0?(r._$AI(e,r,n),n+=r.strings.length-2):r._$AI(e[n])),n++}}let Mc=class mm{get _$AU(){var e;return((e=this._$AM)==null?void 0:e._$AU)??this._$Cv}constructor(e,n,r,s){this.type=2,this._$AH=ge,this._$AN=void 0,this._$AA=e,this._$AB=n,this._$AM=r,this.options=s,this._$Cv=(s==null?void 0:s.isConnected)??!0}get parentNode(){let e=this._$AA.parentNode;const n=this._$AM;return n!==void 0&&(e==null?void 0:e.nodeType)===11&&(e=n.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,n=this){e=Mr(this,e,n),Is(e)?e===ge||e==null||e===""?(this._$AH!==ge&&this._$AR(),this._$AH=ge):e!==this._$AH&&e!==Lr&&this._(e):e._$litType$!==void 0?this.$(e):e.nodeType!==void 0?this.T(e):_1(e)?this.k(e):this._(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==ge&&Is(this._$AH)?this._$AA.nextSibling.data=e:this.T(Wn.createTextNode(e)),this._$AH=e}$(e){var i;const{values:n,_$litType$:r}=e,s=typeof r=="number"?this._$AC(e):(r.el===void 0&&(r.el=Ps.createElement(gm(r.h,r.h[0]),this.options)),r);if(((i=this._$AH)==null?void 0:i._$AD)===s)this._$AH.p(n);else{const o=new E1(s,this),a=o.u(this.options);o.p(n),this.T(a),this._$AH=o}}_$AC(e){let n=Td.get(e.strings);return n===void 0&&Td.set(e.strings,n=new Ps(e)),n}k(e){Lc(this._$AH)||(this._$AH=[],this._$AR());const n=this._$AH;let r,s=0;for(const i of e)s===n.length?n.push(r=new mm(this.O(Ts()),this.O(Ts()),this,this.options)):r=n[s],r._$AI(i),s++;s<n.length&&(this._$AR(r&&r._$AB.nextSibling,s),n.length=s)}_$AR(e=this._$AA.nextSibling,n){var r;for((r=this._$AP)==null?void 0:r.call(this,!1,!0,n);e!==this._$AB;){const s=kd(e).nextSibling;kd(e).remove(),e=s}}setConnected(e){var n;this._$AM===void 0&&(this._$Cv=e,(n=this._$AP)==null||n.call(this,e))}},Jo=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,n,r,s,i){this.type=1,this._$AH=ge,this._$AN=void 0,this.element=e,this.name=n,this._$AM=s,this.options=i,r.length>2||r[0]!==""||r[1]!==""?(this._$AH=Array(r.length-1).fill(new String),this.strings=r):this._$AH=ge}_$AI(e,n=this,r,s){const i=this.strings;let o=!1;if(i===void 0)e=Mr(this,e,n,0),o=!Is(e)||e!==this._$AH&&e!==Lr,o&&(this._$AH=e);else{const a=e;let l,c;for(e=i[0],l=0;l<i.length-1;l++)c=Mr(this,a[r+l],n,l),c===Lr&&(c=this._$AH[l]),o||(o=!Is(c)||c!==this._$AH[l]),c===ge?e=ge:e!==ge&&(e+=(c??"")+i[l+1]),this._$AH[l]=c}o&&!s&&this.j(e)}j(e){e===ge?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}},$1=class extends Jo{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===ge?void 0:e}},A1=class extends Jo{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==ge)}},x1=class extends Jo{constructor(e,n,r,s,i){super(e,n,r,s,i),this.type=5}_$AI(e,n=this){if((e=Mr(this,e,n,0)??ge)===Lr)return;const r=this._$AH,s=e===ge&&r!==ge||e.capture!==r.capture||e.once!==r.once||e.passive!==r.passive,i=e!==ge&&(r===ge||s);s&&this.element.removeEventListener(this.name,this,r),i&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){var n;typeof this._$AH=="function"?this._$AH.call(((n=this.options)==null?void 0:n.host)??this.element,e):this._$AH.handleEvent(e)}};class C1{constructor(e,n,r){this.element=e,this.type=6,this._$AN=void 0,this._$AM=n,this.options=r}get _$AU(){return this._$AM._$AU}_$AI(e){Mr(this,e)}}const Ba=As.litHtmlPolyfillSupport;Ba==null||Ba(Ps,Mc),(As.litHtmlVersions??(As.litHtmlVersions=[])).push("3.3.2");const be=(t,e,n)=>{const r=e;let s=r._$litPart$;return s===void 0&&(r._$litPart$=s=new Mc(e.insertBefore(Ts(),null),null,void 0,{})),s._$AI(t),s};/**
|
|
50
|
-
* @license
|
|
51
|
-
* Copyright 2017 Google LLC
|
|
52
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
53
|
-
*/const T1={CHILD:2},vm=t=>(...e)=>({_$litDirective$:t,values:e});class I1{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
|
-
*/class So extends I1{constructor(e){if(super(e),this.it=ge,e.type!==T1.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(e){if(e===ge||e==null)return this._t=void 0,this.it=e;if(e===Lr)return e;if(typeof e!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(e===this.it)return this._t;this.it=e;const n=[e];return n.raw=n,this._t={_$litType$:this.constructor.resultType,strings:n,values:[]}}}So.directiveName="unsafeHTML",So.resultType=1;const P1=vm(So);/**
|
|
58
|
-
* @license
|
|
59
|
-
* Copyright 2017 Google LLC
|
|
60
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
61
|
-
*/class xl extends So{}xl.directiveName="unsafeSVG",xl.resultType=2;const R1=vm(xl),D1={size:16,color:"currentColor",weight:"regular"};function O1(t){return typeof t=="string"?{regular:t}:t}function Kr(t,e="0 0 256 256"){const n=O1(t);return r=>{const{size:s,color:i,weight:o}={...D1,...r},a=n[o]??n.regular;return M`<svg
|
|
62
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
63
|
-
data-ui-icon=""
|
|
64
|
-
width="${s}"
|
|
65
|
-
height="${s}"
|
|
66
|
-
viewBox="${e}"
|
|
67
|
-
fill="${i}"
|
|
68
|
-
>${R1(a)}</svg>`}}const z1=Kr('<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"/>'),ym=Kr('<path d="M205.66,194.34a8,8,0,0,1-11.32,11.32L128,139.31,61.66,205.66a8,8,0,0,1-11.32-11.32L116.69,128,50.34,61.66A8,8,0,0,1,61.66,50.34L128,116.69l66.34-66.35a8,8,0,0,1,11.32,11.32L139.31,128Z"/>'),L1=Kr('<path d="M216,56V200a16,16,0,0,1-16,16H56a16,16,0,0,1-16-16V56A16,16,0,0,1,56,40H200A16,16,0,0,1,216,56Z"/>'),M1=Kr({regular:'<path d="M231.87,114l-168-95.89A16,16,0,0,0,40.92,37.34L71.55,128,40.92,218.67A16,16,0,0,0,56,240a16.15,16.15,0,0,0,7.93-2.1l167.92-96.05a16,16,0,0,0,.05-27.89ZM56,224a.56.56,0,0,0,0-.12L85.74,136H144a8,8,0,0,0,0-16H85.74L56.06,32.16A.46.46,0,0,0,56,32l168,95.83Z"/>',bold:'<path d="M233.86,110.48,65.8,14.58A20,20,0,0,0,37.15,38.64L67.33,128,37.15,217.36A20,20,0,0,0,56,244a20.1,20.1,0,0,0,9.81-2.58l.09-.06,168-96.07a20,20,0,0,0,0-34.81ZM63.19,215.26,88.61,140H144a12,12,0,0,0,0-24H88.61L63.18,40.72l152.76,87.17Z"/>'}),Cl=Kr('<path d="M213.66,101.66l-80,80a8,8,0,0,1-11.32,0l-80-80A8,8,0,0,1,53.66,90.34L128,164.69l74.34-74.35a8,8,0,0,1,11.32,11.32Z"/>'),N1=Kr('<path d="M128,80a48,48,0,1,0,48,48A48.05,48.05,0,0,0,128,80Zm0,80a32,32,0,1,1,32-32A32,32,0,0,1,128,160Zm88-29.84q.06-2.16,0-4.32l14.92-18.64a8,8,0,0,0,1.48-7.06,107.21,107.21,0,0,0-10.88-26.25,8,8,0,0,0-6-3.93l-23.72-2.64q-1.48-1.56-3-3L186,40.54a8,8,0,0,0-3.94-6,107.71,107.71,0,0,0-26.25-10.87,8,8,0,0,0-7.06,1.49L130.16,40Q128,40,125.84,40L107.2,25.11a8,8,0,0,0-7.06-1.48A107.6,107.6,0,0,0,73.89,34.51a8,8,0,0,0-3.93,6L67.32,64.27q-1.56,1.49-3,3L40.54,70a8,8,0,0,0-6,3.94,107.71,107.71,0,0,0-10.87,26.25,8,8,0,0,0,1.49,7.06L40,125.84Q40,128,40,130.16L25.11,148.8a8,8,0,0,0-1.48,7.06,107.21,107.21,0,0,0,10.88,26.25,8,8,0,0,0,6,3.93l23.72,2.64q1.49,1.56,3,3L70,215.46a8,8,0,0,0,3.94,6,107.71,107.71,0,0,0,26.25,10.87,8,8,0,0,0,7.06-1.49L125.84,216q2.16.06,4.32,0l18.64,14.92a8,8,0,0,0,7.06,1.48,107.21,107.21,0,0,0,26.25-10.88,8,8,0,0,0,3.93-6l2.64-23.72q1.56-1.48,3-3L215.46,186a8,8,0,0,0,6-3.94,107.71,107.71,0,0,0,10.87-26.25,8,8,0,0,0-1.49-7.06Zm-16.1-6.5a73.93,73.93,0,0,1,0,8.68,8,8,0,0,0,1.74,5.48l14.19,17.73a91.57,91.57,0,0,1-6.23,15L187,173.11a8,8,0,0,0-5.1,2.64,74.11,74.11,0,0,1-6.14,6.14,8,8,0,0,0-2.64,5.1l-2.51,22.58a91.32,91.32,0,0,1-15,6.23l-17.74-14.19a8,8,0,0,0-5-1.75h-.48a73.93,73.93,0,0,1-8.68,0,8,8,0,0,0-5.48,1.74L100.45,215.8a91.57,91.57,0,0,1-15-6.23L82.89,187a8,8,0,0,0-2.64-5.1,74.11,74.11,0,0,1-6.14-6.14,8,8,0,0,0-5.1-2.64L46.43,170.6a91.32,91.32,0,0,1-6.23-15l14.19-17.74a8,8,0,0,0,1.74-5.48,73.93,73.93,0,0,1,0-8.68,8,8,0,0,0-1.74-5.48L40.2,100.45a91.57,91.57,0,0,1,6.23-15L69,82.89a8,8,0,0,0,5.1-2.64,74.11,74.11,0,0,1,6.14-6.14A8,8,0,0,0,82.89,69L85.4,46.43a91.32,91.32,0,0,1,15-6.23l17.74,14.19a8,8,0,0,0,5.48,1.74,73.93,73.93,0,0,1,8.68,0,8,8,0,0,0,5.48-1.74L155.55,40.2a91.57,91.57,0,0,1,15,6.23L173.11,69a8,8,0,0,0,2.64,5.1,74.11,74.11,0,0,1,6.14,6.14,8,8,0,0,0,5.1,2.64l22.58,2.51a91.32,91.32,0,0,1,6.23,15l-14.19,17.74A8,8,0,0,0,199.87,123.66Z"/>');class bm extends Event{constructor(n){super("dropdown-item-select",{bubbles:!0,composed:!0});v(this,"value");this.value=n}}class U1 extends Event{constructor(n){super("select",{bubbles:!0,composed:!0});v(this,"value");this.value=n}}var Je,ot,en,$r,ne,Gs,z,_m,vs,Sm,km,Tl,Il,so,_n,Ln,qs,Ys,Ks,Io,Em,$m,Pl,ys,Rl,Tt;class wm extends HTMLElement{constructor(){super();x(this,z);x(this,Je,!1);x(this,ot,null);x(this,en,null);x(this,$r);x(this,ne,null);x(this,Gs,new MutationObserver(n=>b(this,z,Em).call(this,n)));x(this,Ln,()=>{b(this,z,so).call(this,!h(this,Je))});x(this,qs,n=>{n.key!=="Enter"&&n.key!==" "||(n.preventDefault(),h(this,Ln).call(this))});x(this,Ys,n=>{h(this,Je)&&(n.composedPath().includes(this)||b(this,z,so).call(this,!1))});x(this,Ks,n=>{n instanceof bm&&(n.stopPropagation(),$(this,Je,!1),b(this,z,vs).call(this,n.value),b(this,z,Tt).call(this),this.dispatchEvent(new U1(n.value)))});x(this,Io,()=>{b(this,z,Pl).call(this)});$(this,$r,this.attachShadow({mode:"open"}))}connectedCallback(){this.addEventListener("dropdown-item-select",h(this,Ks)),document.addEventListener("click",h(this,Ys),!0),b(this,z,_m).call(this),h(this,Gs).observe(this,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["selected","value","slot"]}),b(this,z,Tt).call(this)}disconnectedCallback(){this.removeEventListener("dropdown-item-select",h(this,Ks)),document.removeEventListener("click",h(this,Ys),!0),h(this,Gs).disconnect(),b(this,z,Rl).call(this)}attributeChangedCallback(){b(this,z,Tt).call(this)}get title(){return this.getAttribute("title")??""}get value(){return h(this,ot)}set value(n){n===null?(b(this,z,_n).call(this,null,null),b(this,z,Sm).call(this)):b(this,z,vs).call(this,n),b(this,z,Tt).call(this)}close(){b(this,z,so).call(this,!1)}}Je=new WeakMap,ot=new WeakMap,en=new WeakMap,$r=new WeakMap,ne=new WeakMap,Gs=new WeakMap,z=new WeakSet,_m=function(){var r;const n=this.querySelector("dropdown-item[selected]");n&&b(this,z,_n).call(this,n.value,((r=n.textContent)==null?void 0:r.trim())??null)},vs=function(n){var r;for(const s of h(this,z,Tl))s.value===n?(b(this,z,_n).call(this,n,((r=s.textContent)==null?void 0:r.trim())??null),s.hasAttribute("selected")||s.setAttribute("selected","")):s.hasAttribute("selected")&&s.removeAttribute("selected")},Sm=function(){const n=this.querySelectorAll("dropdown-item[selected]");for(const r of n)r.removeAttribute("selected")},km=function(n){for(const r of h(this,z,Tl))if(r.value===n)return r;return null},Tl=function(){return this.querySelectorAll("dropdown-item")},Il=function(){return h(this,en)??this.title},so=function(n){h(this,Je)!==n&&($(this,Je,n),b(this,z,Tt).call(this))},_n=function(n,r){$(this,ot,n),$(this,en,r)},Ln=new WeakMap,qs=new WeakMap,Ys=new WeakMap,Ks=new WeakMap,Io=new WeakMap,Em=function(n){n.every(s=>s.target instanceof Element?s.target.closest('[slot="trigger"]')!==null:!1)||b(this,z,$m).call(this)},$m=function(){var r,s;const n=this.querySelector("dropdown-item[selected]");if(n){const i=n.value,o=((r=n.textContent)==null?void 0:r.trim())??null,a=h(this,ot)!==i||h(this,en)!==o;b(this,z,_n).call(this,i,o),b(this,z,vs).call(this,i),a?b(this,z,Tt).call(this):b(this,z,ys).call(this);return}if(h(this,ot)!==null){const i=b(this,z,km).call(this,h(this,ot));if(i){const o=((s=i.textContent)==null?void 0:s.trim())??null,a=h(this,en)!==o;b(this,z,_n).call(this,h(this,ot),o),b(this,z,vs).call(this,h(this,ot)),a?b(this,z,Tt).call(this):b(this,z,ys).call(this);return}}if(h(this,ot)!==null||h(this,en)!==null){b(this,z,_n).call(this,null,null),b(this,z,Tt).call(this);return}b(this,z,ys).call(this)},Pl=function(){const n=h(this,$r).querySelector('slot[name="trigger"]'),r=n instanceof HTMLSlotElement?n.assignedElements()[0]??null:null;h(this,ne)!==r&&(b(this,z,Rl).call(this),$(this,ne,r),h(this,ne)&&(h(this,ne).addEventListener("click",h(this,Ln)),h(this,ne)instanceof HTMLButtonElement?h(this,ne).hasAttribute("type")||(h(this,ne).type="button"):(h(this,ne).hasAttribute("role")||h(this,ne).setAttribute("role","button"),h(this,ne).hasAttribute("tabindex")||(h(this,ne).tabIndex=0),h(this,ne).addEventListener("keydown",h(this,qs))))),b(this,z,ys).call(this)},ys=function(){h(this,ne)&&(h(this,ne).setAttribute("data-dropdown-trigger",""),h(this,ne).setAttribute("aria-haspopup","listbox"),h(this,ne).setAttribute("aria-expanded",h(this,Je)?"true":"false"),be(M`
|
|
69
|
-
<span class="trigger-label" data-dropdown-trigger-label>${h(this,z,Il)}</span>
|
|
70
|
-
<span class="trigger-icon" data-dropdown-trigger-icon aria-hidden="true">
|
|
71
|
-
${Cl({size:16})}
|
|
72
|
-
</span>
|
|
73
|
-
`,h(this,ne)))},Rl=function(){h(this,ne)&&(h(this,ne).removeEventListener("click",h(this,Ln)),h(this,ne).removeEventListener("keydown",h(this,qs)),h(this,ne).removeAttribute("data-dropdown-trigger"),h(this,ne).removeAttribute("aria-haspopup"),h(this,ne).removeAttribute("aria-expanded"),$(this,ne,null))},Tt=function(){this.toggleAttribute("open",h(this,Je)),be(M`
|
|
74
|
-
<slot name="trigger" @slotchange=${h(this,Io)}>
|
|
75
|
-
<button
|
|
76
|
-
class="fallback-trigger"
|
|
77
|
-
part="trigger"
|
|
78
|
-
type="button"
|
|
79
|
-
aria-haspopup="listbox"
|
|
80
|
-
aria-expanded=${h(this,Je)?"true":"false"}
|
|
81
|
-
@click=${h(this,Ln)}
|
|
82
|
-
>
|
|
83
|
-
<span class="trigger-label" part="trigger-label">${h(this,z,Il)}</span>
|
|
84
|
-
<span class="trigger-icon" part="trigger-icon" aria-hidden="true">
|
|
85
|
-
${Cl({size:16})}
|
|
86
|
-
</span>
|
|
87
|
-
</button>
|
|
88
|
-
</slot>
|
|
89
|
-
${h(this,Je)?M`
|
|
90
|
-
<div class="panel" part="panel" role="listbox">
|
|
91
|
-
<slot></slot>
|
|
92
|
-
</div>
|
|
93
|
-
`:null}
|
|
94
|
-
`,h(this,$r)),queueMicrotask(()=>b(this,z,Pl).call(this))},v(wm,"observedAttributes",["title"]);class F1 extends HTMLElement{}class Z1 extends HTMLElement{}class j1 extends HTMLElement{}var Hn,Dl,xm,Js,Xs;class Am extends HTMLElement{constructor(){super(...arguments);x(this,Hn);x(this,Js,()=>{this.action||b(this,Hn,xm).call(this)});x(this,Xs,n=>{n.key!=="Enter"&&n.key!==" "||(n.preventDefault(),this.click())})}connectedCallback(){this.hasAttribute("role")||this.setAttribute("role","option"),this.hasAttribute("tabindex")||(this.tabIndex=0),this.addEventListener("click",h(this,Js)),this.addEventListener("keydown",h(this,Xs)),b(this,Hn,Dl).call(this)}disconnectedCallback(){this.removeEventListener("click",h(this,Js)),this.removeEventListener("keydown",h(this,Xs))}attributeChangedCallback(){b(this,Hn,Dl).call(this)}get value(){return this.getAttribute("value")??""}get selected(){return this.hasAttribute("selected")}get action(){return this.hasAttribute("action")}}Hn=new WeakSet,Dl=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")},xm=function(){this.dispatchEvent(new bm(this.value))},Js=new WeakMap,Xs=new WeakMap,v(Am,"observedAttributes",["action","selected","value"]);customElements.get("dropdown-menu")||customElements.define("dropdown-menu",wm);customElements.get("dropdown-group")||customElements.define("dropdown-group",F1);customElements.get("dropdown-label")||customElements.define("dropdown-label",Z1);customElements.get("dropdown-divider")||customElements.define("dropdown-divider",j1);customElements.get("dropdown-item")||customElements.define("dropdown-item",Am);class W1 extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}var Qs,un,Ol,Po,ei,zl;class Cm extends HTMLElement{constructor(){super();x(this,un);x(this,Qs);x(this,Po,n=>{n.target===n.currentTarget&&b(this,un,Ol).call(this)});x(this,ei,n=>{this.open&&n.key==="Escape"&&b(this,un,Ol).call(this)});$(this,Qs,this.attachShadow({mode:"open"}))}connectedCallback(){document.addEventListener("keydown",h(this,ei)),b(this,un,zl).call(this)}disconnectedCallback(){document.removeEventListener("keydown",h(this,ei))}attributeChangedCallback(){b(this,un,zl).call(this)}get open(){return this.hasAttribute("open")}}Qs=new WeakMap,un=new WeakSet,Ol=function(){this.dispatchEvent(new W1)},Po=new WeakMap,ei=new WeakMap,zl=function(){be(M`
|
|
95
|
-
${this.open?M`
|
|
96
|
-
<div class="backdrop" part="backdrop" @click=${h(this,Po)}>
|
|
97
|
-
<slot></slot>
|
|
98
|
-
</div>
|
|
99
|
-
`:null}
|
|
100
|
-
`,h(this,Qs))},v(Cm,"observedAttributes",["open"]);customElements.get("modal-overlay")||customElements.define("modal-overlay",Cm);class Tm extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}class B1 extends HTMLElement{}var ti,ni,Ll;class Im extends HTMLElement{constructor(){super();x(this,ni);x(this,ti);$(this,ti,this.attachShadow({mode:"open"}))}connectedCallback(){b(this,ni,Ll).call(this)}attributeChangedCallback(){b(this,ni,Ll).call(this)}get closable(){return this.hasAttribute("closable")}}ti=new WeakMap,ni=new WeakSet,Ll=function(){const n=this.querySelector("panel-page");be(M`
|
|
101
|
-
<section class="panel" part="panel">
|
|
102
|
-
<header class="title-bar" part="header">
|
|
103
|
-
<h2 class="title" part="title">${(n==null?void 0:n.getAttribute("title"))??""}</h2>
|
|
104
|
-
${this.closable?M`
|
|
105
|
-
<button
|
|
106
|
-
type="button"
|
|
107
|
-
class="title-button"
|
|
108
|
-
part="button close-button"
|
|
109
|
-
aria-label="Close"
|
|
110
|
-
@click=${()=>this.dispatchEvent(new Tm)}
|
|
111
|
-
>
|
|
112
|
-
<span class="close-icon" part="icon close-icon">${ym({size:16})}</span>
|
|
113
|
-
</button>
|
|
114
|
-
`:null}
|
|
115
|
-
</header>
|
|
116
|
-
<slot></slot>
|
|
117
|
-
</section>
|
|
118
|
-
`,h(this,ti))},v(Im,"observedAttributes",["closable"]);customElements.get("panel-view")||customElements.define("panel-view",Im);customElements.get("panel-page")||customElements.define("panel-page",B1);const V1=Be(),H1="No handler registered for update-content",G1="handleUpdateContent: handler already registered";function q1(t){return t instanceof Error&&typeof t.message=="string"?t.message:String(t)}const Y1=Hr(kt);var Ar,xr,Cr,Mn,Nn,ri,Te,Ml,Pm,Rm,bs,Nl,lf;let K1=(lf=class extends Y1{constructor(n){super();x(this,Te);x(this,Ar);x(this,xr);x(this,Cr);x(this,Mn,null);x(this,Nn,null);x(this,ri,!1);$(this,Ar,n);const r=n.ownerDocument.defaultView;if(!r)throw new Error("ArtifactView: iframe has no owner window");$(this,xr,r),$(this,Cr,s=>b(this,Te,Pm).call(this,s)),h(this,xr).addEventListener("message",h(this,Cr))}get content(){return h(this,Nn)}set content(n){b(this,Te,Nl).call(this),$(this,Nn,n),h(this,ri)&&b(this,Te,Ml).call(this,n)}handleUpdateContent(n){if(b(this,Te,Nl).call(this),h(this,Mn)!==null)throw new Error(G1);$(this,Mn,n)}dispose(){h(this,xr).removeEventListener("message",h(this,Cr)),$(this,Mn,null)}},Ar=new WeakMap,xr=new WeakMap,Cr=new WeakMap,Mn=new WeakMap,Nn=new WeakMap,ri=new WeakMap,Te=new WeakSet,Ml=function(n){const r={type:"content-updated",content:n};b(this,Te,bs).call(this,r)},Pm=function(n){if(this.disposed||n.source!==h(this,Ar).contentWindow)return;const r=n.data;if(kC(r)){$(this,ri,!0),this.dispatchEvent(new V1("ready")),h(this,Nn)!==null&&b(this,Te,Ml).call(this,h(this,Nn));return}if(EC(r)){b(this,Te,Rm).call(this,r);return}},Rm=async function(n){const r=h(this,Mn);if(r===null){b(this,Te,bs).call(this,{type:"response",id:n.id,error:{message:H1}});return}try{await r(n.content)}catch(s){if(this.disposed)return;b(this,Te,bs).call(this,{type:"response",id:n.id,error:{message:q1(s)}});return}this.disposed||b(this,Te,bs).call(this,{type:"response",id:n.id,result:{}})},bs=function(n){const r=h(this,Ar).contentWindow;r&&r.postMessage(n,"*")},Nl=function(){if(this.disposed)throw new Error("ArtifactView is disposed")},lf);function J1(t=window){t.parent!==t&&(t.addEventListener("wheel",e=>{const n=e;t.parent.postMessage({type:"wheel",deltaX:n.deltaX,deltaY:n.deltaY,shiftKey:n.shiftKey},"*"),n.preventDefault()},{passive:!1}),t.addEventListener("message",e=>{const n=e.data;if(n!==null&&typeof n=="object"&&n.type==="scroll"){const r=n,s=typeof r.deltaX=="number"?r.deltaX:0,i=typeof r.deltaY=="number"?r.deltaY:0;t.scrollBy(s,i)}}))}function X1(){return`(${J1.toString()})(window);`}async function Q1(t){const e=await fetch(t);if(!e.ok)throw new Error(`Failed to fetch artifact content: ${e.status}`);const n=await e.text(),r=new DOMParser().parseFromString(n,"text/html"),s=r.createElement("base");s.href=t,r.head.insertBefore(s,r.head.firstChild);const i=r.createElement("script");i.textContent=X1(),r.head.appendChild(i);const o=new Blob([`<!DOCTYPE html>
|
|
119
|
-
${r.documentElement.outerHTML}`],{type:"text/html"});return URL.createObjectURL(o)}const Dm=Be();class eR extends HTMLElement{constructor(){super(...arguments);v(this,"_artifact",null);v(this,"_viewURL",null);v(this,"_contentURL",null);v(this,"_screen",null);v(this,"_subscribedScreen",null);v(this,"_activeView",null);v(this,"_contentState",{kind:"idle"});v(this,"_fetchSequence",0);v(this,"_blobSequence",0);v(this,"_mountedViewURL",null);v(this,"_directRender",!1);v(this,"_blobURL",null);v(this,"handleScreenContentChanged",n=>{!this._artifact||n.artifactID!==this._artifact.id||this._activeView!==null&&this.refetchContent()})}set artifact(n){const r=this._artifact;this._artifact=n,this.render(),r!==null&&r!==n&&this.syncView()}get artifact(){return this._artifact}set viewURL(n){this._viewURL!==n&&(this._viewURL=n,this.syncView())}get viewURL(){return this._viewURL}set contentURL(n){this._contentURL!==n&&(this._contentURL=n,this.syncView())}get contentURL(){return this._contentURL}set screen(n){this._screen!==n&&(this._screen=n,this.syncScreenSubscription())}get screen(){return this._screen}set dragging(n){n?this.setAttribute("dragging","true"):this.removeAttribute("dragging")}get dragging(){return this.getAttribute("dragging")==="true"}get activeView(){return this._activeView}connectedCallback(){this.render(),this.syncView(),this.syncScreenSubscription()}disconnectedCallback(){this.teardownView(),this.unsubscribeFromScreen()}handleClose(){this._artifact&&this.dispatchEvent(new Dm("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 K1(r),this._activeView.handleUpdateContent(async s=>{await this.saveContent(s)}),this.loadBlobFrame(this._viewURL),this.startContentFetch();return}this._activeView!==null&&this.startContentFetch();return}if(this._contentURL!==null){this.teardownView(),this._directRender=!0,this._contentState={kind:"idle"},this.render(),((n=this._artifact)==null?void 0:n.status)==="committed"&&this.loadBlobFrame(this._contentURL);return}this.teardownView(),this._contentState={kind:"idle"},this.render()}}async saveContent(n){const r=this._screen,s=this._artifact;if(!r||!s)throw new Error("artifact-view: cannot save without a screen and artifact");await r.server.client.artifacts.putContent({artifactID:s.id,content:n})}syncScreenSubscription(){if(!this.isConnected){this.unsubscribeFromScreen();return}this._subscribedScreen!==this._screen&&(this.unsubscribeFromScreen(),this._screen!==null&&(this._screen.addEventListener("artifact-content-changed",this.handleScreenContentChanged),this._subscribedScreen=this._screen))}unsubscribeFromScreen(){this._subscribedScreen!==null&&(this._subscribedScreen.removeEventListener("artifact-content-changed",this.handleScreenContentChanged),this._subscribedScreen=null)}startContentFetch(){this._fetchSequence+=1;const n=this._fetchSequence,r=this._contentURL,s=this._activeView;if(!s||r===null){this._contentState={kind:"error"},this.render();return}this._contentState={kind:"loading"},(async()=>{try{const i=await fetch(r);if(n!==this._fetchSequence)return;if(!i.ok){this._contentState={kind:"error"},this.teardownView(),this.render();return}const o=await i.text();if(n!==this._fetchSequence||this._activeView!==s)return;this._activeView.content=o,this._contentState={kind:"ready"}}catch{if(n!==this._fetchSequence)return;this._contentState={kind:"error"},this.teardownView(),this.render()}})()}refetchContent(){this._fetchSequence+=1;const n=this._fetchSequence,r=this._contentURL,s=this._activeView;!s||r===null||(async()=>{try{const i=await fetch(r);if(n!==this._fetchSequence||!i.ok)return;const o=await i.text();if(n!==this._fetchSequence||this._activeView!==s)return;this._activeView.content=o}catch{}})()}loadBlobFrame(n){this._blobSequence+=1;const r=this._blobSequence;(async()=>{try{const s=await Q1(n);if(r!==this._blobSequence){URL.revokeObjectURL(s);return}this._blobURL=s,this.render();const i=this.querySelector("iframe.artifact-frame");i&&(i.src=s)}catch{if(r!==this._blobSequence)return;this._contentState={kind:"error"},this.teardownView(),this.render()}})()}teardownView(){this._activeView!==null&&(this._activeView.dispose(),this._activeView=null),this._blobURL!==null&&(URL.revokeObjectURL(this._blobURL),this._blobURL=null),this._mountedViewURL=null,this._directRender=!1,this._fetchSequence+=1,this._blobSequence+=1}contentTemplate(){return this._contentState.kind==="error"?M`
|
|
120
|
-
<div class="artifact-content artifact-placeholder">
|
|
121
|
-
<em>Failed to load content</em>
|
|
122
|
-
</div>
|
|
123
|
-
`:this._viewURL!==null||this._directRender?M`
|
|
124
|
-
<iframe
|
|
125
|
-
class="artifact-frame artifact-content"
|
|
126
|
-
src=${this._blobURL??"about:blank"}
|
|
127
|
-
sandbox="allow-scripts"
|
|
128
|
-
></iframe>
|
|
129
|
-
`:M`
|
|
130
|
-
<div class="artifact-content artifact-placeholder">
|
|
131
|
-
<em>Artifact unavailable</em>
|
|
132
|
-
</div>
|
|
133
|
-
`}template(){const n=this._artifact;return M`
|
|
134
|
-
${this.contentTemplate()}
|
|
135
|
-
<footer class="artifact-title-bar" drag-handle>
|
|
136
|
-
<div class="artifact-title-group">
|
|
137
|
-
<span class="artifact-title-icon">${z1({size:16})}</span>
|
|
138
|
-
<span class="artifact-title">${n.title}</span>
|
|
139
|
-
</div>
|
|
140
|
-
<button
|
|
141
|
-
class="artifact-close-btn"
|
|
142
|
-
@click=${()=>this.handleClose()}
|
|
143
|
-
aria-label="Close"
|
|
144
|
-
>
|
|
145
|
-
${ym({size:16})}
|
|
146
|
-
</button>
|
|
147
|
-
</footer>
|
|
148
|
-
`}render(){this._artifact&&(this.setAttribute("type",this._artifact.type),be(this.template(),this))}}customElements.define("artifact-view",eR);const Se=t=>({type:"px",...t}),Ce=t=>({type:"unit",...t}),Zi=2,tR=2;class nR{constructor(e){v(this,"basis");v(this,"min");v(this,"_gap");v(this,"_viewport");v(this,"_unit");this.basis=e.basis,this.min=e.min,this._viewport=e.viewport,this._gap=e.gap??Se({x:de,y:de});const n=this._viewport.x??nn,r=this._viewport.y??mr,s=this._gap.x??de,i=this._gap.y??de,o=nn+s*tR,a=n<=o,l=a?n-s*Zi:Math.min(nn,n-s*Zi),c=a?r-i*Zi:Math.min(mr,r-i*Zi),d=(l-s*(St-1))/St,f=(c-i*(Ke-1))/Ke,y=this.basis.x??0,m=this.basis.y??0,E=this.min.x??0,k=this.min.y??0;this._unit=Se(a?{x:Math.max(E,d),y:Math.max(k,f)}:{x:Math.max(E,Math.min(y,d)),y:Math.max(k,Math.min(m,f))})}get unit(){return this._unit}get viewport(){return this._viewport}get gap(){return this._gap}toUnits(e){return Ce({x:e.x==null?void 0:e.x/(this._unit.x??1),y:e.y==null?void 0:e.y/(this._unit.y??1)})}toPixels(e){const n=this._unit.x??0,r=this._unit.y??0,s=this._gap.x??de,i=this._gap.y??de,o=e.x==null?void 0:e.x*n+Math.max(0,e.x-1)*s,a=e.y==null?void 0:e.y*r+Math.max(0,e.y-1)*i;return Se({x:o,y:a})}}const Bn=1e-4,Ut=1e-6,rR=40,sR=24;function Om(t,e){return Math.max(0,t-e*2)}function zm(t){const e=[0];for(const n of t)e.push((e[e.length-1]??0)+n);return e}function Lm(t){const e=[0];for(let n=0;n<t.length;n+=1){const r=e[n]??0;e.push(r+t[n]+de)}return e}function Mm(t,e,n){if(e<0||e>=t.length)return 0;let r=0,s=0;for(let i=e;i<t.length;i+=1){const o=t[i],a=s===0?o:r+de+o;if(a>n+Bn)break;r=a,s+=1}return Math.max(1,s)}function iR(t,e,n){if(e<0||e>=t.length)return 0;let r=0,s=0;for(let i=e;i>=0;i-=1){const o=t[i],a=s===0?o:r+de+o;if(a>n+Bn)break;r=a,s+=1}return Math.max(1,s)}function oR(t,e){if(t.length===0)return 0;let n=0,r=0;for(let s=t.length-1;s>=0;s-=1){const i=t[s],o=r===0?i:n+de+i;if(o>e+Bn)break;n=o,r+=1}return Math.max(1,r)}function Nc(t,e){if(t.length===0)return 0;const n=oR(t,e);return Math.max(0,t.length-n)}function Id(t,e,n){if(t.length===0)return 0;const r=Mm(t,e,n),s=Math.min(t.length,e+r);if(s<=e)return 0;const i=t.slice(e,s);return i.reduce((o,a)=>o+a,0)+Math.max(0,i.length-1)*de}function Ul(t,e,n){const r=t[e]??0;return n-r}function fr(t,e,n,r,s){if(t.length===0)return 0;const i=Nc(t,s),o=e[i]??0,a=Math.max(0,Math.min(o,n));let l=0;for(let L=0;L<i;L+=1){const J=e[L]??0,G=e[L+1]??J;if(a>=J&&a<=G+Bn){l=L;break}l=L+1}const c=Math.min(l+1,i),d=e[l]??0,f=e[c]??d,y=Math.max(f-d,Bn),m=c===l?0:(a-d)/y,E=Lm(t),k=Id(t,l,s),I=Id(t,c,s),V=(r-k)/2,N=(r-I)/2,j=Ul(E,l,V),F=Ul(E,c,N);return j+(F-j)*m}function Pd(t,e,n,r,s){const i=Nc(t,r),o=e[i]??0;let a=0,l=o;for(let c=0;c<rR;c+=1){const d=(a+l)/2;fr(t,e,d,n,r)>s?a=d:l=d}return(a+l)/2}function Rd(t,e,n){const r=Lm(t),[s,i]=e,o=t.slice(s,i+1),a=o.reduce((c,d)=>c+d,0)+Math.max(0,o.length-1)*de,l=(n-a)/2;return Ul(r,s,l)}function aR(t,e,n){const r=Mm(t,e,n);return[e,Math.min(t.length-1,e+r-1)]}function lR(t,e,n){const r=iR(t,e,n);return[Math.max(0,e-r+1),e]}function cR(t){const e=new Set,n=[];for(const r of t){const s=`${r.nodeRange[0]}:${r.nodeRange[1]}`;if(e.has(s))continue;const i=n[n.length-1];i&&Math.abs(i.anchor-r.anchor)<=Ut||(e.add(s),n.push(r))}return n}function uR(t){const{nodeCols:e,nodeWidthsPx:n,viewportWidthPx:r}=t;if(e.length===0||n.length===0)return{viewspans:[],minScroll:0,maxScroll:0};const s=t.gapPx??de,i=Om(r,s),o=zm(e),a=Nc(n,i),l=o[a]??0,c=[];for(let d=0;d<=a;d+=1){const f=aR(n,d,i),y=Rd(n,f,r),m=Pd(n,o,r,i,y);c.push({nodeRange:f,anchor:Math.max(0,Math.min(l,m))})}for(let d=n.length-1;d>=0;d-=1){const f=lR(n,d,i),y=`${f[0]}:${f[1]}`;if(c.some(k=>`${k.nodeRange[0]}:${k.nodeRange[1]}`===y))continue;const m=Rd(n,f,r),E=Pd(n,o,r,i,m);c.push({nodeRange:f,anchor:Math.max(0,Math.min(l,E))})}return c.sort((d,f)=>Math.abs(d.anchor-f.anchor)>Ut?d.anchor-f.anchor:d.nodeRange[0]!==f.nodeRange[0]?d.nodeRange[0]-f.nodeRange[0]:d.nodeRange[1]-f.nodeRange[1]),{viewspans:cR(c),minScroll:0,maxScroll:l}}function hR(t,e){var s;let n=0,r=Number.POSITIVE_INFINITY;for(let i=0;i<t.length;i+=1){const o=Math.abs((((s=t[i])==null?void 0:s.anchor)??0)-e);if(o+Ut<r){r=o,n=i;continue}Math.abs(o-r)<=Ut&&i<n&&(n=i)}return n}function dR(t,e,n){return n<=0?0:Math.max(0,Math.min(n-1,t+e))}function os(t,e,n){return Math.max(e,Math.min(n,t))}class fR extends kt{constructor(n){super();v(this,"_scroll",0);v(this,"minScroll",0);v(this,"maxScroll",0);v(this,"viewspans",[]);v(this,"activeViewspanIndex",null);v(this,"nodeWidthsPx",[]);v(this,"boundaryCols",[0]);v(this,"viewportWidthPx",0);v(this,"framedViewportWidthPx",0);this._scroll=(n==null?void 0:n.x)??0}get scroll(){return Ce({x:this._scroll})}get translate(){return Se({x:fr(this.nodeWidthsPx,this.boundaryCols,this._scroll,this.viewportWidthPx,this.framedViewportWidthPx)})}set scroll(n){const r=os(n.x??this._scroll,this.minScroll,this.maxScroll);Math.abs(r-this._scroll)<=Ut||(this._scroll=r,this.activeViewspanIndex=null,this.dispatchEvent(new ss("layout-scroll",{scroll:this.scroll})))}rebuild(n){const r=n.nodeWidths.map(c=>Math.max(0,c.x??0)),s=r.map(c=>n.grid.toPixels(Ce({x:c})).x??0),i=n.grid.viewport.x??0,o=n.grid.gap.x??de,a=uR({nodeCols:r,nodeWidthsPx:s,viewportWidthPx:i,gapPx:o});this.nodeWidthsPx=s,this.boundaryCols=zm(r),this.viewportWidthPx=i,this.framedViewportWidthPx=Om(i,o),this.viewspans=a.viewspans,this.minScroll=a.minScroll,this.maxScroll=a.maxScroll,this.activeViewspanIndex=null;const l=os(this._scroll,this.minScroll,this.maxScroll);Math.abs(l-this._scroll)>Ut&&(this._scroll=l,this.dispatchEvent(new ss("layout-scroll",{scroll:this.scroll})))}step(n){var a;if(this.viewspans.length===0)return;const r=this.activeViewspanIndex??hR(this.viewspans,this._scroll),s=dR(r,n,this.viewspans.length),i=((a=this.viewspans[s])==null?void 0:a.anchor)??this._scroll,o=os(i,this.minScroll,this.maxScroll);this.activeViewspanIndex=s,!(Math.abs(o-this._scroll)<=Ut)&&(this._scroll=o,this.dispatchEvent(new ss("layout-scroll",{scroll:this.scroll})))}wheel(n){const r=os(this._scroll+(n.x??0),this.minScroll,this.maxScroll);this.activeViewspanIndex=null,!(Math.abs(r-this._scroll)<=Ut)&&(this._scroll=r,this.dispatchEvent(new ss("layout-scroll",{scroll:this.scroll})))}wheelPixels(n){const r=n.x??0;if(Math.abs(r)<=Bn)return;this.activeViewspanIndex=null;const s=fr(this.nodeWidthsPx,this.boundaryCols,this._scroll,this.viewportWidthPx,this.framedViewportWidthPx),i=s-r,o=fr(this.nodeWidthsPx,this.boundaryCols,this.maxScroll,this.viewportWidthPx,this.framedViewportWidthPx),a=fr(this.nodeWidthsPx,this.boundaryCols,this.minScroll,this.viewportWidthPx,this.framedViewportWidthPx),l=Math.max(o,Math.min(a,i));if(Math.abs(l-s)<=Bn)return;let c=this.minScroll,d=this.maxScroll;for(let y=0;y<sR;y+=1){const m=(c+d)/2;fr(this.nodeWidthsPx,this.boundaryCols,m,this.viewportWidthPx,this.framedViewportWidthPx)>l?c=m:d=m}const f=os((c+d)/2,this.minScroll,this.maxScroll);Math.abs(f-this._scroll)<=Ut||(this._scroll=f,this.dispatchEvent(new ss("layout-scroll",{scroll:this.scroll})))}}const Va={"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}},pR=["stack-above","stack-below","reorder-before","reorder-after"];function Ha(t,e){return{left:t.left+t.width*e.left,top:t.top+t.height*e.top,width:t.width*e.width,height:t.height*e.height}}function bn(t,e,n){return t>=n.left&&t<n.left+n.width&&e>=n.top&&e<n.top+n.height}function Uc(t,e){for(const n of t){if(n.type==="card"&&n.id===e)return n;if(n.type==="stack")for(const r of n.children){if(r.type==="card"&&r.id===e)return r;if(r.type==="row"){for(const s of r.children)if(s.id===e)return s}}}return null}function Fl(t){return t.height===Ke||t.height===on?{...t,height:on}:t}function Zl(t){return t.height===on?{...t,height:Ke}:t}function gR(t,e,n,r){const s=t.findIndex(d=>d.type==="stack"&&d.id===e);if(s===-1)return t;const i=t[s];if(!i||i.type!=="stack")return t;const o=i.children.find(d=>d.type==="card"&&d.id===n);if(!o||o.type!=="card")return t;const a=i.children.filter(d=>d.id!==n);if(a.length===i.children.length||a.length<1)return t;const l=[...t];if(a.length===1){const[d]=a;l[s]=d.type==="card"?Zl(d):d}else l[s]={...i,children:a};const c=Math.max(0,Math.min(r,l.length));return l.splice(c,0,Zl(o)),l}const mR=Be(),vR=Be(),yR=50;function bR(t,e){if(t.type!==e.type)return!1;switch(t.type){case"reorder":return e.index===t.index;case"stack":return e.targetCardId===t.targetCardId&&e.position===t.position;case"stack-child-noop":return!0;case"stack-child-extract":return e.toIndex===t.toIndex;case"stack-child-reorder":return e.position===t.position;default:return!1}}function yi(t){return{id:t.id,type:"drop-target",width:t.width,height:t.height}}function Dd(t){return t.map(_R)}function wR(t){return t.type==="drop-target"?{id:t.id,type:"card",artifactID:t.id,width:t.width,height:t.height}:t}function _R(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(wR)}:t}function Nm(t,e){return t.find(r=>r.type==="card"&&r.id===e)??null}function Od(t,e){return t.find(r=>r.type==="stack"&&r.id===e)??null}function SR(t,e){const n=[...e],r=n.findIndex(a=>a.type==="card"&&a.id===t.nodeId);if(r===-1)return null;const s=n[r];if(!s||s.type!=="card")return null;n.splice(r,1);const i=Math.max(0,Math.min(t.lastReorderIndex,n.length));n.splice(i,0,s);const o=n.findIndex(a=>a.type==="card"&&a.id===t.nodeId);return o===-1?null:{base:n,visualDraggedIndex:o}}function kR(t,e,n,r){const s=[...t.base];s.splice(t.visualDraggedIndex,1);const i=s.findIndex(y=>y.type==="card"&&y.id===n.targetCardId),o=i===-1?null:s[i];if(!o||o.type!=="card")return null;const a=Nm(r,e.nodeId);if(!a)return null;const l=Fl(a),c=Fl(o),d=yi(l),f=n.position==="above"?[d,c]:[c,d];return s[i]={id:o.id,type:"stack",children:f},s}function Ga(t,e){return t.parentStackId?$R(t,e):ER(t,e)}function ER(t,e){const n=t.hitTarget;if(n.type==="reorder"){const r=e[t.sourceIndex];if(!r||r.type!=="card")return[...e];const s=[...e];return s.splice(t.sourceIndex,1),s.splice(n.index,0,yi(r)),s}if(n.type==="stack"){const r=SR(t,e);return r?kR(r,t,n,e)??[...e]:[...e]}return[...e]}function $R(t,e){const n=t.hitTarget;switch(n.type){case"stack-child-reorder":return AR(t,e,n.position);case"stack-child-extract":return xR(t,e,n.toIndex);case"stack-child-noop":return CR(t,e);default:return[...e]}}function AR(t,e,n){const r=e.findIndex(y=>y.type==="stack"&&y.id===t.parentStackId);if(r===-1)return[...e];const s=e[r];if(!s||s.type!=="stack")return[...e];if(!s.children.every(y=>y.type==="card"))return[...e];const i=s.children,o=i.findIndex(y=>y.id===t.nodeId);if(o===-1)return[...e];const a=i[o],l=i.filter(y=>y.id!==t.nodeId),c=yi(a),d=n==="above"?[c,...l]:[...l,c],f=[...e];return f[r]={...s,children:d},f}function xR(t,e,n){if(!t.parentStackId)return[...e];const r=gR(e,t.parentStackId,t.nodeId,n);if(r===e)return[...e];const s=r.findIndex(a=>a.type==="card"&&a.id===t.nodeId);if(s===-1)return[...e];const i=r[s];if(!i||i.type!=="card")return[...e];const o=[...r];return o[s]=yi(i),o}function CR(t,e){const n=e.findIndex(l=>l.type==="stack"&&l.id===t.parentStackId);if(n===-1)return[...e];const r=e[n];if(!r||r.type!=="stack")return[...e];const s=r.children.findIndex(l=>l.type==="card"&&l.id===t.nodeId);if(s===-1)return[...e];const i=r.children[s];if(!i||i.type!=="card")return[...e];const o=[...e],a=[...r.children];return a[s]=yi(i),o[n]={...r,children:a},o}function TR(t,e){return e.find(r=>r.type==="stack"&&r.id===t.id)?t.id:Sc()}function IR(t,e,n){if(t.type==="drop-target"){const r=Uc(e,n);if(!r)throw new Error(`finalize: missing dragged card ${n}`);return Fl(r)}return t}function PR(t,e,n){const r=t.children.map(i=>IR(i,e,n));return{id:TR(t,e),type:"stack",children:r}}function RR(t,e,n){if(t.type==="drop-target"){const r=Uc(e,n);if(!r)throw new Error(`finalize: missing dragged card ${n}`);return Nm(e,n)!==null?r:Zl(r)}return t.type==="card"||t.type==="row"?t:PR(t,e,n)}function DR(t,e,n){return t.map(r=>RR(r,e,n))}function OR(t,e){return JSON.stringify(t)===JSON.stringify(e)}const zR=Hr(kt);class LR extends zR{constructor(n={}){super();v(this,"pending",null);v(this,"active",null)}start(n){if(this.pending||this.active)return;const r=n.pointer.x??0,s=n.pointer.y??0;this.pending={startX:r,startY:s,grabOffsetX:n.grabOffset.x??0,grabOffsetY:n.grabOffset.y??0,nodeId:n.nodeId,sourceIndex:n.source.index,parentStackId:n.source.parentId,width:n.size.x??0,height:n.size.y??0,baseLayout:n.layout}}update(n){const r=n.pointer.x??0,s=n.pointer.y??0,i=this.pending;if(i){const c=r-i.startX,d=s-i.startY;Math.hypot(c,d)>=gE&&(this.pending=null,this.active={...i,pointerX:r,pointerY:s,hitTarget:{type:"reorder",index:i.sourceIndex},lastReorderIndex:i.sourceIndex},this.emitDrag(),this.dispatchEvent(new te("change")));return}if(!this.active)return;const o=Ga(this.active,this.active.baseLayout),a=this.getHitTargetForPointer(r,s,n,o),l=a.type==="reorder"?a.index:this.active.lastReorderIndex;this.active.pointerX===r&&this.active.pointerY===s&&bR(this.active.hitTarget,a)&&this.active.lastReorderIndex===l||(this.active={...this.active,pointerX:r,pointerY:s,hitTarget:a,lastReorderIndex:l},this.emitDrag(),this.dispatchEvent(new te("change")))}drop(){if(this.pending){this.cancel();return}if(!this.active)return;const n=this.active.baseLayout;let r=null;try{const s=Ga(this.active,n),i=DR(s,n,this.active.nodeId);OR(i,n)||(r=i)}catch{r=null}this.reset(),r&&this.dispatchEvent(new vR("drop",{layout:r})),this.dispatchEvent(new te("change"))}cancel(){!this.pending&&!this.active||(this.reset(),this.dispatchEvent(new te("change")))}dispose(){this.reset()}get status(){return this.active?"active":this.pending?"pending":"idle"}reset(){this.pending=null,this.active=null}emitDrag(){if(!this.active)return;const n=Ga(this.active,this.active.baseLayout);this.dispatchEvent(new mR("drag",{nodeId:this.active.nodeId,source:{index:this.active.sourceIndex,parentId:this.active.parentStackId},grabOffset:Se({x:this.active.grabOffsetX,y:this.active.grabOffsetY}),pointer:Se({x:this.active.pointerX,y:this.active.pointerY}),size:Se({x:this.active.width,y:this.active.height}),projectedLayout:n}))}getHitTargetForPointer(n,r,s,i){return this.active?this.isPointerInsideDragBounds(n,r,s.viewport)?this.active.parentStackId?this.getStackChildHitTarget(n,r,s,i):this.getTopLevelCardHitTarget(n,r,s,i):{type:"reorder",index:this.active.sourceIndex}:{type:"reorder",index:0}}getStackChildHitTarget(n,r,s,i){var c;if(!((c=this.active)!=null&&c.parentStackId))return{type:"stack-child-noop"};const o=this.getSourceStackInteractionRect(s.geometry);if(o&&bn(n,r,o)){const d=o.top+o.height/2;return{type:"stack-child-reorder",position:r<d?"above":"below"}}const a=this.getSourceRemainingSiblingRect(s.geometry);if(a&&bn(n,r,a)){const d=a.top+a.height/2;return{type:"stack-child-reorder",position:r<d?"above":"below"}}return{type:"stack-child-extract",toIndex:this.getTopLevelReorderIndexForPointer(n,r,s,i)}}getSourceRemainingSiblingRect(n){var i,o;if(!((i=this.active)!=null&&i.parentStackId))return;const r=Od(this.active.baseLayout,this.active.parentStackId);if(!r)return;const s=r.children.find(a=>{var l;return a.type==="card"&&a.id!==((l=this.active)==null?void 0:l.nodeId)});if(s)return(o=n.find(a=>a.id===s.id))==null?void 0:o.rect}getSourceStackInteractionRect(n){var o;if(!((o=this.active)!=null&&o.parentStackId))return;const r=n.find(a=>{var l;return a.id===((l=this.active)==null?void 0:l.parentStackId)});if(r)return this.active.sourceStackRect=r.rect,r.rect;const s=Od(this.active.baseLayout,this.active.parentStackId);if(!s)return this.active.sourceStackRect;const i=s.children.find(a=>{var l;return a.type==="card"&&a.id!==((l=this.active)==null?void 0:l.nodeId)});if(i){const a=n.find(l=>l.id===i.id);if(a)return a.rect}return this.active.sourceStackRect}getTopLevelCardHitTarget(n,r,s,i){var m,E,k;const o=this.getTopLevelZoneNodes(s.geometry,i);if(o.length===0)return{type:"reorder",index:((m=this.active)==null?void 0:m.sourceIndex)??0};const l=(s.effectiveVelocity??0)<=yR;for(const I of o){const V=I.rect;if(!bn(n,r,V))continue;const N=this.resolveTopLevelTargetForCard(n,r,I,I.logicalIndex,l);if(N)return N;if(!l&&((E=this.active)!=null&&E.hitTarget))return this.active.hitTarget}const c=this.getNearestTargetableZone(n,o);if(!c)return{type:"reorder",index:((k=this.active)==null?void 0:k.sourceIndex)??0};const d=Math.max(c.rect.left,Math.min(c.rect.left+c.rect.width,n)),f=this.resolveTopLevelTargetForCard(d,r,c,c.logicalIndex,l);if(f)return f;const y=c.rect.left+c.rect.width/2;return{type:"reorder",index:n<y?c.logicalIndex:c.logicalIndex+1}}getTopLevelReorderIndexForPointer(n,r,s,i){var c,d;const o=this.getTopLevelZoneNodes(s.geometry,i);if(o.length===0)return((c=this.active)==null?void 0:c.sourceIndex)??0;for(const f of o){if(!bn(n,r,f.rect))continue;const y=Ha(f.rect,Va["reorder-before"]);if(bn(n,r,y))return f.logicalIndex;const m=Ha(f.rect,Va["reorder-after"]);if(bn(n,r,m))return f.logicalIndex+1}const a=this.getNearestTargetableZone(n,o);if(!a)return((d=this.active)==null?void 0:d.sourceIndex)??0;const l=a.rect.left+a.rect.width/2;return n<l?a.logicalIndex:a.logicalIndex+1}getTopLevelZoneNodes(n,r){const s=new Map(r.map(a=>[a.id,a])),i=[];let o=0;for(const a of n){const l=s.get(a.id);l&&l.type!=="drop-target"&&(l.type==="card"||l.type==="stack")&&(i.push({id:l.id,rect:a.rect,logicalIndex:o}),o+=1)}return i}resolveTopLevelTargetForCard(n,r,s,i,o){const a=s.rect;for(const l of pR){if(!o&&(l==="stack-above"||l==="stack-below"))continue;const c=Va[l],d=Ha(a,c);if(bn(n,r,d))return l==="stack-above"?{type:"stack",targetCardId:s.id,position:"above"}:l==="stack-below"?{type:"stack",targetCardId:s.id,position:"below"}:l==="reorder-before"?{type:"reorder",index:i}:{type:"reorder",index:i+1}}return null}getNearestTargetableZone(n,r){let s=null,i=Number.POSITIVE_INFINITY;for(const o of r){const a=o.rect.left,l=o.rect.left+o.rect.width,c=n<a?a-n:n>l?n-l:0;c<i&&(i=c,s=o)}return s}isPointerInsideDragBounds(n,r,s){return n>=s.left&&n<=s.left+s.width&&r>=s.top&&r<=s.top+s.height}}const zd=60,MR=80,Ld=.5,Md=10;class NR{constructor(){v(this,"awaitingFreshWheelGesture",!1);v(this,"lastWheelEventAt",Number.NEGATIVE_INFINITY);v(this,"lastWheelDeltaX",0);v(this,"activeGestureType","none");v(this,"lastWheelGestureAt",Number.NEGATIVE_INFINITY)}markKeyboardNavigation(e){this.awaitingFreshWheelGesture=!0,this.lastWheelEventAt=e,this.activeGestureType="none"}reset(){this.awaitingFreshWheelGesture=!1,this.lastWheelEventAt=Number.NEGATIVE_INFINITY,this.lastWheelDeltaX=0,this.activeGestureType="none",this.lastWheelGestureAt=Number.NEGATIVE_INFINITY}decide(e){const{now:n,shiftKey:r,deltaX:s,deltaY:i,overArtifactContent:o}=e;n-this.lastWheelGestureAt>=zd&&(this.activeGestureType="none");const l=r&&i!==0,c=l?i:s,d=Math.abs(c),f=Math.abs(i);return this.activeGestureType==="vertical-artifact"&&o?d>=Ld&&d>=f*Md?this.classifyHorizontal(n,c):(this.lastWheelGestureAt=n,{type:"scroll-native"}):this.activeGestureType==="horizontal-filmstrip"?!l&&o&&f>0&&f>=d*Md?(this.activeGestureType="vertical-artifact",this.lastWheelGestureAt=n,{type:"scroll-native"}):this.classifyHorizontal(n,c):d<Ld?(o&&(this.activeGestureType="vertical-artifact"),this.lastWheelGestureAt=n,{type:"scroll-native"}):l||d>f?this.classifyHorizontal(n,c):f>d?(o&&(this.activeGestureType="vertical-artifact"),this.lastWheelGestureAt=n,{type:"scroll-native"}):o?(this.activeGestureType="vertical-artifact",this.lastWheelGestureAt=n,{type:"scroll-native"}):this.classifyHorizontal(n,c)}classifyHorizontal(e,n){const r=e-this.lastWheelEventAt,s=Math.sign(this.lastWheelDeltaX),i=Math.sign(n),o=s!==0&&i!==0&&s!==i,a=s!==0&&Math.abs(n)>=Math.abs(this.lastWheelDeltaX)+MR;return this.awaitingFreshWheelGesture&&r<zd&&!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 UR=2,Nd=1e3,ji=1e-4;function Ud(t,e,n){if(t===0)return 0;const r=e.toPixels(Ce({y:Ke})).y??0;return(n-r)/UR}class FR extends Event{constructor(n){super("scroll",{bubbles:!0,composed:!0});v(this,"scrollPosition");this.scrollPosition=n}}class Um extends Event{constructor(n){super("layout-change",{bubbles:!0,composed:!0});v(this,"layout");this.layout=n}}class ZR extends HTMLElement{constructor(){super();v(this,"_layout",[]);v(this,"_scrollPosition",0);v(this,"layoutGrid",null);v(this,"layoutScroll",new fR(Ce({x:0})));v(this,"scrollModelKey","");v(this,"resizeObserver",null);v(this,"renderPending",!1);v(this,"animateNextRender",!0);v(this,"wheelGesture",new NR);v(this,"dragController",new LR);v(this,"dragState",null);v(this,"activeDragPointerId",null);v(this,"dragListenersAttached",!1);v(this,"dragFrame",0);v(this,"lastDragFrameTime",0);v(this,"lastPointerX",0);v(this,"lastPointerY",0);v(this,"pointerVelocityPxPerSec",0);v(this,"scrollVelocityPxPerSec",0);v(this,"motionSampleTime",0);v(this,"motionSampleX",0);v(this,"motionSampleY",0);v(this,"dragTrackOffsetXPx",0);v(this,"previousProjectedLayoutForOffset",null);v(this,"renderContent",()=>M``);v(this,"onDragControllerChange",()=>{this.dragController.status==="idle"&&(this.dragState=null,this.dragTrackOffsetXPx=0,this.previousProjectedLayoutForOffset=null),this.scheduleRender()});v(this,"onDragControllerDrag",n=>{const r=Dd(n.projectedLayout),s=this.shouldApplyTrackOffset(n.projectedLayout,n.source.parentId),i=n.source.parentId?this.getStackChildAnchorCardId(n.source.parentId,n.nodeId):null;this.dragTrackOffsetXPx=s?this.computeDragTrackOffset(this.previousProjectedLayoutForOffset,r,n.nodeId,n.source.parentId,i,this.dragTrackOffsetXPx):0,this.previousProjectedLayoutForOffset=r,this.dragState={nodeId:n.nodeId,source:n.source,grabOffset:n.grabOffset,pointer:n.pointer,size:n.size,projectedLayout:n.projectedLayout},this.scheduleRender()});v(this,"onDragControllerDrop",n=>{this.dragState=null,this.dragTrackOffsetXPx=0,this.previousProjectedLayoutForOffset=null,this.commitLayout(n.layout)});v(this,"onLayoutScrollInternal",n=>{const s=n.scroll.x??0;Math.abs(s-this._scrollPosition)<ji||(this._scrollPosition=s,this.emitScrollPositionChanged(s),this.scheduleRender())});v(this,"handleKeyDown",n=>{if(n.key==="Escape"&&this.dragController.status!=="idle"){n.preventDefault(),this.stopDragFrameLoop(),this.releaseActiveDragPointerCapture(),this.dragController.cancel(),this.detachDragListeners();return}this.dragController.status==="idle"&&(n.key==="ArrowRight"?(n.preventDefault(),this.wheelGesture.markKeyboardNavigation(Date.now()),this.shiftWindow(1)):n.key==="ArrowLeft"&&(n.preventDefault(),this.wheelGesture.markKeyboardNavigation(Date.now()),this.shiftWindow(-1)))});v(this,"handleWheel",n=>{if(this._layout.length===0)return;const r=this.wheelGesture.decide({now:Date.now(),shiftKey:n.shiftKey,deltaX:n.deltaX,deltaY:n.deltaY,overArtifactContent:!1});r.type==="scroll-horizontal"&&(n.preventDefault(),this.applyHorizontalWheel(r.horizontalDelta))});v(this,"handleWindowMessage",n=>{var o;if(this._layout.length===0)return;const r=this.findManagedArtifactFrame(n.source);if(!r||!this.isTrustedArtifactFrameMessage(n,r)||!$C(n.data))return;const s=this.wheelGesture.decide({now:Date.now(),shiftKey:n.data.shiftKey,deltaX:n.data.deltaX,deltaY:n.data.deltaY,overArtifactContent:!0});if(s.type==="scroll-horizontal"){this.applyHorizontalWheel(s.horizontalDelta);return}if(s.type!=="scroll-native")return;const i={type:"scroll",deltaX:0,deltaY:n.data.deltaY};(o=r.contentWindow)==null||o.postMessage(i,this.getArtifactFrameTargetOrigin(r))});v(this,"handlePointerDown",n=>{if(n.button!==0||this.dragController.status!=="idle")return;const r=n.target;if(!(r instanceof Element)||!r.closest("[drag-handle]")||r.closest("button, input, textarea, select, a, [role='button']"))return;const s=r.closest(".card-slot");if(!s)return;const i=s.getAttribute("data-layout-node-id");if(!i)return;const o=WR(this._layout,i);if(!o)return;const a=s.getBoundingClientRect();this.lastPointerX=n.clientX,this.lastPointerY=n.clientY,this.resetMotionTracking(n.clientX,n.clientY),this.focus(),this.dragController.start({nodeId:i,source:{index:o.topLevelIndex,parentId:o.sourceStackId},pointer:Se({x:n.clientX,y:n.clientY}),grabOffset:Se({x:n.clientX-a.left,y:n.clientY-a.top}),size:Se({x:a.width,y:a.height}),layout:this._layout}),this.attachDragListeners(),this.activeDragPointerId=n.pointerId;try{this.setPointerCapture(n.pointerId)}catch{}n.preventDefault()});v(this,"handleWindowPointerMove",n=>{this.lastPointerX=n.clientX,this.lastPointerY=n.clientY,this.updatePointerVelocity(n.clientX,n.clientY),this.syncDragTargetForLatestPointer(),this.ensureDragFrameLoop()});v(this,"handleWindowPointerUp",n=>{this.stopDragFrameLoop(),this.releasePointerCaptureForEvent(n.pointerId),this.dragController.drop(),this.clearMotionTracking(),this.detachDragListeners()});v(this,"handleWindowPointerCancel",n=>{this.stopDragFrameLoop(),this.releasePointerCaptureForEvent(n.pointerId),this.dragController.cancel(),this.clearMotionTracking(),this.detachDragListeners()});v(this,"handleWindowBlur",()=>{this.releaseActiveDragPointerCapture(),this.stopDragFrameLoop(),this.dragController.cancel(),this.clearMotionTracking(),this.detachDragListeners()});v(this,"runDragFrame",n=>{if(this.dragController.status==="idle"){this.dragFrame=0;return}const r=Math.max(0,n-this.lastDragFrameTime)/Nd;this.lastDragFrameTime=n,this.samplePointerVelocityAt(n,this.lastPointerX,this.lastPointerY);const s=this.getBoundingClientRect(),i=this.clampPointerToViewport(this.lastPointerX,this.lastPointerY,s),o=this.getDragEdgeScrollDeltaPixels(i.x,s,r);this.scrollVelocityPxPerSec=r>ji?Math.abs(o)/r:0,Math.abs(o)>ji&&(this.animateNextRender=!1,this.layoutScroll.wheelPixels(Se({x:o}))),this.dragController.status==="active"&&this.syncDragTarget(i.x,i.y,s),this.dragFrame=requestAnimationFrame(this.runDragFrame)});this.dragController.addEventListener("change",this.onDragControllerChange),this.dragController.addEventListener("drag",this.onDragControllerDrag),this.dragController.addEventListener("drop",this.onDragControllerDrop),this.layoutScroll.addEventListener("layout-scroll",this.onLayoutScrollInternal)}set layout(n){this._layout=[...n],this.stopDragFrameLoop(),this.dragController.cancel(),this.scrollModelKey="",this.syncScrollModel(),this.layoutScroll.scroll=Ce({x:this._scrollPosition}),this.scheduleRender()}get layout(){return this._layout}commitLayout(n){this.layout=n,this.emitLayoutChanged()}set scrollPosition(n){Math.abs(n-this._scrollPosition)<ji||(this.animateNextRender=!1,this.syncScrollModel(),this.layoutScroll.scroll=Ce({x:n}))}get scrollPosition(){return this._scrollPosition}connectedCallback(){this.hasAttribute("tabindex")||(this.tabIndex=0),this.focus(),this.addEventListener("keydown",this.handleKeyDown),this.addEventListener("wheel",this.handleWheel,{passive:!1}),this.addEventListener("pointerdown",this.handlePointerDown),window.addEventListener("message",this.handleWindowMessage),typeof ResizeObserver<"u"&&(this.resizeObserver=new ResizeObserver(()=>this.render()),this.resizeObserver.observe(this)),this.render()}disconnectedCallback(){var n;this.removeEventListener("keydown",this.handleKeyDown),this.removeEventListener("wheel",this.handleWheel),this.removeEventListener("pointerdown",this.handlePointerDown),window.removeEventListener("message",this.handleWindowMessage),(n=this.resizeObserver)==null||n.disconnect(),this.resizeObserver=null,this.wheelGesture.reset(),this.detachDragListeners(),this.dragController.removeEventListener("change",this.onDragControllerChange),this.dragController.removeEventListener("drag",this.onDragControllerDrag),this.dragController.removeEventListener("drop",this.onDragControllerDrop),this.layoutScroll.removeEventListener("layout-scroll",this.onLayoutScrollInternal),this.dragController.dispose(),this.stopDragFrameLoop()}scheduleRender(){this.renderPending||(this.renderPending=!0,queueMicrotask(()=>{this.renderPending=!1,this.render()}))}createGrid(n,r){return new nR({basis:Se({x:kn,y:kn}),min:Se({x:Yh,y:Yh}),viewport:Se({x:n,y:r}),gap:Se({x:de,y:de})})}syncScrollModel(){const n=this.clientWidth>0?this.clientWidth:nn,r=this.clientHeight>0?this.clientHeight:mr,i=$s(this._layout).nodes.map(a=>a.width),o=`${n}x${r}:${i.join(",")}`;o===this.scrollModelKey&&this.layoutGrid||(this.scrollModelKey=o,this.layoutGrid=this.createGrid(n,r),this.layoutScroll.rebuild({grid:this.layoutGrid,nodeWidths:i.map(a=>Ce({x:a}))}))}emitScrollPositionChanged(n){this.dispatchEvent(new FR(n))}emitLayoutChanged(){this.dispatchEvent(new Um([...this._layout]))}shiftWindow(n){this.syncScrollModel(),this.animateNextRender=!0,this.layoutScroll.step(n)}applyHorizontalWheel(n){this.syncScrollModel();const r=this.layoutGrid;if(!r)return;this.animateNextRender=!1;const s=r.toUnits(Se({x:n}));this.layoutScroll.wheel(Ce({x:s.x??0}))}findManagedArtifactFrame(n){if(!n)return null;const r=this.querySelectorAll("iframe.artifact-frame");for(const s of r)if(s.contentWindow===n)return s;return null}isTrustedArtifactFrameMessage(n,r){if(n.origin==="null")return!0;const s=this.getArtifactFrameOrigin(r);return s===null||n.origin===s}getArtifactFrameTargetOrigin(n){const r=n.getAttribute("sandbox")??"";return new Set(r.split(/\s+/).filter(Boolean)).has("allow-same-origin")?this.getArtifactFrameOrigin(n)??"*":"*"}getArtifactFrameOrigin(n){const r=n.getAttribute("src")??n.src;if(!r)return null;try{return new URL(r,window.location.href).origin}catch{return null}}releaseActiveDragPointerCapture(){this.activeDragPointerId!==null&&this.releasePointerCaptureForEvent(this.activeDragPointerId)}releasePointerCaptureForEvent(n){try{this.hasPointerCapture(n)&&this.releasePointerCapture(n)}catch{}}attachDragListeners(){this.dragListenersAttached||(window.addEventListener("pointermove",this.handleWindowPointerMove),window.addEventListener("pointerup",this.handleWindowPointerUp),window.addEventListener("pointercancel",this.handleWindowPointerCancel),this.addEventListener("pointermove",this.handleWindowPointerMove),this.addEventListener("pointerup",this.handleWindowPointerUp),this.addEventListener("pointercancel",this.handleWindowPointerCancel),window.addEventListener("blur",this.handleWindowBlur),this.dragListenersAttached=!0)}detachDragListeners(){this.dragListenersAttached&&(window.removeEventListener("pointermove",this.handleWindowPointerMove),window.removeEventListener("pointerup",this.handleWindowPointerUp),window.removeEventListener("pointercancel",this.handleWindowPointerCancel),this.removeEventListener("pointermove",this.handleWindowPointerMove),this.removeEventListener("pointerup",this.handleWindowPointerUp),this.removeEventListener("pointercancel",this.handleWindowPointerCancel),window.removeEventListener("blur",this.handleWindowBlur),this.dragListenersAttached=!1,this.activeDragPointerId=null)}getDisplayModel(){if(this.dragController.status!=="active"||!this.dragState)return{layout:this._layout,activePlaceholderId:null,placeholdersById:new Map};const n=new Map;return n.set(this.dragState.nodeId,{id:this.dragState.nodeId,sourceCardId:this.dragState.nodeId}),{layout:Dd(this.dragState.projectedLayout),activePlaceholderId:this.dragState.nodeId,placeholdersById:n}}render(){const n=this.clientWidth>0?this.clientWidth:nn,r=this.clientHeight>0?this.clientHeight:mr,s=this.createGrid(n,r);this.layoutGrid=s;const i=this.getDisplayModel(),o=i.layout,a=this.dragController.status==="active",l=$s(o),c=l.nodes.map(L=>L.width),d=`${n}x${r}:${c.join(",")}`;!a&&d!==this.scrollModelKey&&(this.scrollModelKey=d,this.layoutScroll.rebuild({grid:s,nodeWidths:c.map(L=>Ce({x:L}))}),this._scrollPosition=this.layoutScroll.scroll.x??this._scrollPosition);const f=jR(o),y=s.unit.x??kn,m=s.unit.y??kn,E=a?this.dragTrackOffsetXPx:0,k=(this.layoutScroll.translate.x??0)+E,I=Ud(l.nodes.length,s,r),V=this.animateNextRender&&!a,N=[`transform: translate(${k}px, ${I}px);`,`transition-duration: ${V?pE:0}ms;`,`pointer-events: ${a?"none":"auto"};`].join(" ");this.animateNextRender=!0,this.style.setProperty("--layout-unit-x",`${y}px`),this.style.setProperty("--layout-unit-y",`${m}px`),this.style.setProperty("--layout-gap",`${de}px`);const j=this.dragState,F={width:(j==null?void 0:j.size.x)??0,height:(j==null?void 0:j.size.y)??0};be(M`
|
|
149
|
-
<div class="track" style=${N}>
|
|
150
|
-
${l.nodes.map((L,J)=>M`
|
|
151
|
-
<div
|
|
152
|
-
class="node"
|
|
153
|
-
layout-node=${String(J)}
|
|
154
|
-
data-layout-node-id=${L.id}
|
|
155
|
-
data-layout-placeholder=${String(i.activePlaceholderId===L.id)}
|
|
156
|
-
layout-node-cols=${String(L.width)}
|
|
157
|
-
style=${`grid-template-columns: repeat(${L.width}, var(--layout-unit-x)); width: ${s.toPixels(Ce({x:L.width})).x}px;`}
|
|
158
|
-
>
|
|
159
|
-
${L.cards.map(G=>{const he=i.placeholdersById.get(G.id);if(j&&he)return M`
|
|
160
|
-
<div
|
|
161
|
-
class="card-slot card-placeholder"
|
|
162
|
-
data-layout-placeholder-for=${j.nodeId}
|
|
163
|
-
data-layout-placeholder-ghost="false"
|
|
164
|
-
data-layout-source-stack=${j.source.parentId??""}
|
|
165
|
-
style=${`grid-column: ${G.col} / span ${G.width}; grid-row: ${G.row} / span ${G.height};`}
|
|
166
|
-
></div>
|
|
167
|
-
`;const ct=f.get(G.id);return ct?M`
|
|
168
|
-
<div
|
|
169
|
-
class="card-slot"
|
|
170
|
-
data-layout-card-id=${G.artifactID}
|
|
171
|
-
data-layout-node-id=${G.id}
|
|
172
|
-
layout-cols=${String(G.width)}
|
|
173
|
-
layout-rows=${String(G.height)}
|
|
174
|
-
style=${`grid-column: ${G.col} / span ${G.width}; grid-row: ${G.row} / span ${G.height};`}
|
|
175
|
-
>
|
|
176
|
-
${this.renderContent(ct,{isDragging:!1})}
|
|
177
|
-
</div>
|
|
178
|
-
`:null})}
|
|
179
|
-
</div>
|
|
180
|
-
`)}
|
|
181
|
-
</div>
|
|
182
|
-
${j?(()=>{const L=this.getPlaceholderPixelSize(l,i.activePlaceholderId,s,F),J=j.pointer.x??0,G=j.pointer.y??0,he=j.grabOffset.x??0,ct=j.grabOffset.y??0;return M`
|
|
183
|
-
<div
|
|
184
|
-
class="drag-preview"
|
|
185
|
-
data-layout-preview-card-id=${j.nodeId}
|
|
186
|
-
style=${[`width: ${L.width}px;`,`height: ${L.height}px;`,`left: ${J-he}px;`,`top: ${G-ct}px;`].join(" ")}
|
|
187
|
-
>
|
|
188
|
-
${this.renderDraggedPreview(j.nodeId)}
|
|
189
|
-
</div>
|
|
190
|
-
`})():null}
|
|
191
|
-
`,this)}ensureDragFrameLoop(){this.dragFrame!==0||this.dragController.status==="idle"||(this.lastDragFrameTime=performance.now(),this.dragFrame=requestAnimationFrame(this.runDragFrame))}stopDragFrameLoop(){this.dragFrame!==0&&(cancelAnimationFrame(this.dragFrame),this.dragFrame=0,this.scrollVelocityPxPerSec=0)}syncDragTargetForLatestPointer(){if(this.dragController.status==="idle")return;const n=this.getBoundingClientRect();if(this.dragController.status==="active"){const s=this.clampPointerToViewport(this.lastPointerX,this.lastPointerY,n);this.syncDragTarget(s.x,s.y,n);return}if(this.syncDragTarget(this.lastPointerX,this.lastPointerY,n),this.dragController.status==="pending")return;const r=this.clampPointerToViewport(this.lastPointerX,this.lastPointerY,n);(r.x!==this.lastPointerX||r.y!==this.lastPointerY)&&this.syncDragTarget(r.x,r.y,n)}syncDragTarget(n,r,s=this.getBoundingClientRect()){if(this.dragController.status==="idle")return;const i=this.getDisplayModel(),o=new Set(i.placeholdersById.keys()),a=this.dragController.status==="active"?this.dragTrackOffsetXPx:0,l=this.measureLayoutGeometry(i.layout,o,a);this.dragController.update({pointer:Se({x:n,y:r}),viewport:{left:s.left,top:s.top,width:s.width,height:s.height},geometry:l,effectiveVelocity:Math.max(this.pointerVelocityPxPerSec,this.scrollVelocityPxPerSec)})}resetMotionTracking(n,r){this.pointerVelocityPxPerSec=0,this.scrollVelocityPxPerSec=0,this.motionSampleTime=performance.now(),this.motionSampleX=n,this.motionSampleY=r}clearMotionTracking(){this.pointerVelocityPxPerSec=0,this.scrollVelocityPxPerSec=0,this.motionSampleTime=0}updatePointerVelocity(n,r){this.samplePointerVelocityAt(performance.now(),n,r)}samplePointerVelocityAt(n,r,s){if(this.motionSampleTime===0){this.motionSampleTime=n,this.motionSampleX=r,this.motionSampleY=s,this.pointerVelocityPxPerSec=0;return}const i=n-this.motionSampleTime;if(i<100)return;const o=r-this.motionSampleX;this.pointerVelocityPxPerSec=Math.abs(o)/i*Nd,this.motionSampleTime=n,this.motionSampleX=r,this.motionSampleY=s}clampPointerToViewport(n,r,s){return{x:Math.max(s.left,Math.min(s.left+s.width,n)),y:Math.max(s.top,Math.min(s.top+s.height,r))}}isPointerOutsideViewport(n,r,s){return n<s.left||n>s.left+s.width||r<s.top||r>s.top+s.height}getDragEdgeScrollDeltaPixels(n,r,s){var c;const i=r.left+Li,o=r.left+r.width-Li,a=((c=this.layoutGrid)==null?void 0:c.unit.x)??kn,l=mE*a;if(n<i){const d=Math.max(0,Math.min(1,(i-n)/Li));return-(l*d**Kh)*s}if(n>o){const d=Math.max(0,Math.min(1,(n-o)/Li));return l*d**Kh*s}return 0}measureLayoutGeometry(n,r,s=0){const i=this.layoutGrid;if(!i)return[];const o=$s(n),a=new Map(o.nodes.map(E=>[E.id,E.width])),l=i.toPixels(Ce({y:Ke})).y??mr,c=this.clientHeight>0?this.clientHeight:mr,d=(this.layoutScroll.translate.x??0)+s,f=Ud(o.nodes.length,i,c),y=[];let m=d;for(const E of n){const k=a.get(E.id)??St,I=i.toPixels(Ce({x:k})).x??nn,V={left:m,top:f,width:I,height:l};y.push({id:E.id,rect:V}),m+=I+de}return y}getPlaceholderPixelSize(n,r,s,i){if(!r)return i;for(const o of n.nodes)for(const a of o.cards)if(a.id===r)return{width:s.toPixels(Ce({x:a.width})).x??i.width,height:s.toPixels(Ce({y:a.height})).y??i.height};return i}renderDraggedPreview(n){const r=Uc(this._layout,n);return r?this.renderContent(r,{isDragging:!0}):M``}shouldApplyTrackOffset(n,r){if(r)return!0;for(const s of n){if(s.type!=="stack")continue;if(s.children.some(o=>o.type==="drop-target")&&r!==s.id)return!0}return!1}computeDragTrackOffset(n,r,s,i,o,a){if(!n)return a;const l=i?o??this.getStableAnchorCardId(n,r,s):this.getStableAnchorNodeId(n,r,s);if(!l)return a;const c=i?Zd(n,l,this.layoutGrid):jd(n,l,this.layoutGrid),d=i?Zd(r,l,this.layoutGrid):jd(r,l,this.layoutGrid);return c===null||d===null?a:a+(c-d)}getStableAnchorCardId(n,r,s){const i=Fd(n),o=new Set(Fd(r));for(const a of i)if(a!==s&&o.has(a))return a;return null}getStableAnchorNodeId(n,r,s){const i=new Set(r.map(o=>o.id));for(const o of n)if(o.id!==s&&i.has(o.id))return o.id;return null}getStackChildAnchorCardId(n,r){const s=this._layout.find(o=>o.type==="stack"&&o.id===n);if(!s||s.type!=="stack")return null;const i=s.children.find(o=>o.type==="card"&&o.id!==r);return(i==null?void 0:i.id)??null}}function jR(t){const e=new Map;for(const n of t){if(n.type==="card"){e.set(n.id,n);continue}for(const r of n.children)if(r.type==="card")e.set(r.id,r);else for(const s of r.children)e.set(s.id,s)}return e}function WR(t,e){const n=t.findIndex(r=>r.type==="card"&&r.id===e);if(n!==-1)return{topLevelIndex:n};for(let r=0;r<t.length;r+=1){const s=t[r];if(!(!s||s.type!=="stack")&&s.children.some(i=>i.type==="card"&&i.id===e))return{topLevelIndex:r,sourceStackId:s.id}}return null}function Fd(t){const e=[];for(const n of t){if(n.type==="card"){e.push(n.id);continue}if(n.type==="stack"){const r=n.children.find(s=>s.type==="card");r&&e.push(r.id)}}return e}function Zd(t,e,n){if(!n)return null;const r=$s(t),s=new Map(r.nodes.map(o=>[o.id,o.width]));let i=0;for(const o of t){if(o.type==="card"&&o.id===e||o.type==="stack"&&o.children.some(c=>c.type==="card"&&c.id===e))return i;const a=s.get(o.id)??St,l=n.toPixels(Ce({x:a})).x??nn;i+=l+de}return null}function jd(t,e,n){if(!n)return null;const r=$s(t),s=new Map(r.nodes.map(o=>[o.id,o.width]));let i=0;for(const o of t){if(o.id===e)return i;const a=s.get(o.id)??St,l=n.toPixels(Ce({x:a})).x??nn;i+=l+de}return null}customElements.get("layout-view")||customElements.define("layout-view",ZR);class BR extends HTMLElement{constructor(){super(...arguments);v(this,"screenManager",Ye.resolve("ScreenManager"));v(this,"boundModel",null);v(this,"handleActiveScreenChanged",()=>{this.rebindModel(),this.render()});v(this,"handleModelChange",()=>{this.render()});v(this,"handleCloseArtifact",n=>{n instanceof Dm&&this.screenManager.activeScreen&&this.screenManager.activeScreen.removeArtifact(n.artifactID)});v(this,"handleScrollPositionChanged",n=>{const r=n;typeof r.scrollPosition=="number"&&Number.isFinite(r.scrollPosition)&&this.screenManager.activeScreen&&this.screenManager.activeScreen.setScrollPosition(r.scrollPosition)});v(this,"handleLayoutChanged",n=>{n instanceof Um&&this.screenManager.activeScreen&&this.screenManager.activeScreen.setLayout(n.layout)})}connectedCallback(){this.screenManager.addEventListener("active-screen-changed",this.handleActiveScreenChanged),this.rebindModel(),this.render()}disconnectedCallback(){this.screenManager.removeEventListener("active-screen-changed",this.handleActiveScreenChanged),this.unbindModel()}rebindModel(){const n=this.screenManager.activeScreen;this.boundModel!==n&&(this.unbindModel(),this.boundModel=n,n&&n.addEventListener("change",this.handleModelChange))}unbindModel(){this.boundModel&&(this.boundModel.removeEventListener("change",this.handleModelChange),this.boundModel=null)}buildArtifactMap(){const n=this.screenManager.activeScreen;return n?new Map(n.artifacts):new Map}render(){const n=this.screenManager.activeScreen,r=(n==null?void 0:n.layout)??[],s=this.buildArtifactMap();if(r.length===0){be(M`<p data-testid="empty-screen">No artifacts yet.</p>`,this);return}be(M`
|
|
192
|
-
<layout-view
|
|
193
|
-
.layout=${r}
|
|
194
|
-
.renderContent=${(o,a)=>{const l=s.get(o.artifactID);return!l||!n?M``:M`<artifact-view
|
|
195
|
-
.artifact=${l}
|
|
196
|
-
.screen=${n}
|
|
197
|
-
.viewURL=${n.server.getViewURL(l)}
|
|
198
|
-
.contentURL=${n.server.getContentURL(l.id)}
|
|
199
|
-
.dragging=${a.isDragging}
|
|
200
|
-
></artifact-view>`}}
|
|
201
|
-
.scrollPosition=${(n==null?void 0:n.scrollPosition)??0}
|
|
202
|
-
@scroll=${this.handleScrollPositionChanged}
|
|
203
|
-
@layout-change=${this.handleLayoutChanged}
|
|
204
|
-
@close-artifact=${this.handleCloseArtifact}
|
|
205
|
-
></layout-view>
|
|
206
|
-
`,this)}}customElements.define("screen-view",BR);const qa=Be();class VR extends HTMLElement{constructor(){super(...arguments);v(this,"screenManager",Ye.resolve("ScreenManager"));v(this,"serverManager",Ye.resolve("ServerManager"));v(this,"handleChange",()=>{this.render()})}connectedCallback(){this.render(),this.screenManager.addEventListener("active-screen-changed",this.handleChange),this.serverManager.addEventListener("change",this.handleChange),this.serverManager.addEventListener("screens-changed",this.handleChange)}disconnectedCallback(){this.screenManager.removeEventListener("active-screen-changed",this.handleChange),this.serverManager.removeEventListener("change",this.handleChange),this.serverManager.removeEventListener("screens-changed",this.handleChange)}handleSelect(n){const r=n.value;for(const[s,i]of this.serverManager.servers)if(i.screens.has(r)){this.screenManager.setActive(s,r);return}}closeDropdown(){var n;(n=this.querySelector("dropdown-menu"))==null||n.close()}handleEditScreen(){this.screenManager.activeScreen&&(this.closeDropdown(),this.dispatchEvent(new qa("edit-screen",{bubbles:!0,composed:!0})))}handleCreateScreen(n){this.closeDropdown(),this.dispatchEvent(new qa("create-screen",{serverURL:n,bubbles:!0,composed:!0}))}handleDeleteScreen(){this.screenManager.activeScreen&&(this.closeDropdown(),this.dispatchEvent(new qa("delete-screen",{bubbles:!0,composed:!0})))}render(){const n=this.screenManager.activeScreen,r=(n==null?void 0:n.name)??"No screens",s=(n==null?void 0:n.id)??null,i=[...this.serverManager.servers.values()].map(o=>({url:o.url,name:o.name,sortedScreens:[...o.screens.values()].sort((a,l)=>a.name.localeCompare(l.name,void 0,{sensitivity:"base"}))}));be(M`
|
|
207
|
-
<dropdown-menu
|
|
208
|
-
title=${r}
|
|
209
|
-
@select=${o=>this.handleSelect(o)}
|
|
210
|
-
>
|
|
211
|
-
<button
|
|
212
|
-
slot="trigger"
|
|
213
|
-
trigger
|
|
214
|
-
type="button"
|
|
215
|
-
aria-label="Choose screen"
|
|
216
|
-
></button>
|
|
217
|
-
${i.map(o=>M`
|
|
218
|
-
<dropdown-group>
|
|
219
|
-
<dropdown-label>${o.name}</dropdown-label>
|
|
220
|
-
${o.sortedScreens.map(a=>this.renderScreenItem(a,s,(n==null?void 0:n.name)??null))}
|
|
221
|
-
<dropdown-item
|
|
222
|
-
action
|
|
223
|
-
@click=${()=>this.handleCreateScreen(o.url)}
|
|
224
|
-
>
|
|
225
|
-
+ New screen
|
|
226
|
-
</dropdown-item>
|
|
227
|
-
</dropdown-group>
|
|
228
|
-
`)}
|
|
229
|
-
${n?M`
|
|
230
|
-
<dropdown-divider></dropdown-divider>
|
|
231
|
-
<dropdown-group>
|
|
232
|
-
<dropdown-item
|
|
233
|
-
action
|
|
234
|
-
@click=${()=>this.handleEditScreen()}
|
|
235
|
-
>
|
|
236
|
-
Edit screen...
|
|
237
|
-
</dropdown-item>
|
|
238
|
-
<dropdown-item
|
|
239
|
-
action
|
|
240
|
-
danger
|
|
241
|
-
@click=${()=>this.handleDeleteScreen()}
|
|
242
|
-
>
|
|
243
|
-
Delete screen...
|
|
244
|
-
</dropdown-item>
|
|
245
|
-
</dropdown-group>
|
|
246
|
-
`:null}
|
|
247
|
-
</dropdown-menu>
|
|
248
|
-
`,this)}renderScreenItem(n,r,s){const i=n.id===r,o=i?s??n.name:n.name;return M`
|
|
249
|
-
<dropdown-item value=${n.id} ?selected=${i}>
|
|
250
|
-
${o}
|
|
251
|
-
</dropdown-item>
|
|
252
|
-
`}}customElements.define("screen-picker",VR);const Wd=new WeakMap,Bd=new WeakSet,Fm=new WeakMap,Zm=new WeakMap,Wi=new WeakSet,jm=t=>t;function Wm(t,e){return t===Boolean?e===null?!1:e!=="false":e===null?null:t===Number?Number(e):t===Object?JSON.parse(e):e}function HR(t,e){return e==null?null:t===Boolean?e?"":"false":t===Object?JSON.stringify(e):String(e)}function GR(t){const e=new Map;if(!t)return e;if(Array.isArray(t)){for(const n of t)e.set(n,{attribute:!1});return e}for(const[n,r]of Object.entries(t))e.set(n,{type:r.type,attribute:r.attribute??!1});return e}function Rs(t){let e=Wd.get(t);return e||(e={constructing:!0,syncingFromAttribute:null,syncingToAttribute:null,values:new Map},Wd.set(t,e)),e}function Fc(t){return Zm.get(t)??new Map}function Bm(t,e){var n;return((n=Fm.get(t))==null?void 0:n.has(e))??!1}function Ds(t){return typeof t.attribute=="string"?t.attribute:null}function qR(t,e){for(const[n,r]of Fc(t))if(Ds(r)===e)return{prop:n,config:r};return null}function io(t){if(Bd.has(t))return;const e=GR(t.observedProperties);Zm.set(t,e);const n=new Set;Fm.set(t,n);for(const[r,s]of e){if(Ds(s)&&!s.type)throw new Error(`Observed property "${r}" requires a "type" when "attribute" is set.`);const o=Object.getOwnPropertyDescriptor(t.prototype,r);if(o!=null&&o.get||o!=null&&o.set)throw new Error(`Observed property "${r}" cannot define a custom getter/setter. Use propertyChangedCallback for side effects instead.`);o||(n.add(r),Object.defineProperty(t.prototype,r,{enumerable:!0,configurable:!0,get(){return Rs(this).values.get(r)},set(a){const l=Rs(this),c=l.values.get(r);if(Object.is(c,a))return;l.values.set(r,a);const d=Ds(s);if(d&&l.syncingFromAttribute!==d&&l.syncingToAttribute!==d){const f=HR(s.type,a);l.syncingToAttribute=d;try{const y=this;f===null?y.removeAttribute(d):y.setAttribute(d,f)}finally{l.syncingToAttribute=null}}(!l.constructing||l.syncingFromAttribute!==null||c!==void 0)&&this.propertyChangedCallback(r,c,a)}}))}Bd.add(t)}function YR(t,e){io(e);const n=Rs(t),r=jm(t),s=Fc(e);for(const[i,o]of s){if(!Bm(e,i))continue;const a=Object.prototype.hasOwnProperty.call(t,i),l=a?r[i]:void 0;a&&delete r[i];const c=Ds(o);if(c&&t.hasAttribute(c)){const d=Wm(o.type,t.getAttribute(c));n.syncingFromAttribute=c;try{r[i]=d}finally{n.syncingFromAttribute=null}continue}a&&(r[i]=l)}n.constructing=!1}class Os extends globalThis.HTMLElement{static get observedAttributes(){const e=this;return io(e),KR(e),[...Fc(e).values()].map(n=>Ds(n)).filter(n=>!!n)}constructor(){super();const e=this.constructor;io(e),Rs(this),queueMicrotask(()=>YR(this,e))}attributeChangedCallback(e,n,r){const s=this.constructor;io(s);const i=qR(s,e);if(!i||!Bm(s,i.prop))return;const o=Rs(this);if(o.syncingToAttribute===e)return;const a=jm(this);Object.prototype.hasOwnProperty.call(this,i.prop)&&delete a[i.prop],o.syncingFromAttribute=e;try{a[i.prop]=Wm(i.config.type,r)}finally{o.syncingFromAttribute=null}}propertyChangedCallback(e,n,r){}}v(Os,"observedProperties");function KR(t){if(Wi.has(t))return;const e=Object.getOwnPropertyDescriptor(t.prototype,"attributeChangedCallback");if(!e||typeof e.value!="function"){Wi.add(t);return}const n=e.value;if(n===Os.prototype.attributeChangedCallback){Wi.add(t);return}Object.defineProperty(t.prototype,"attributeChangedCallback",{configurable:!0,writable:!0,value(r,s,i){Os.prototype.attributeChangedCallback.call(this,r,s,i),n.call(this,r,s,i)}}),Wi.add(t)}/*! @license DOMPurify 3.3.3 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.3.3/LICENSE */const{entries:Vm,setPrototypeOf:Vd,isFrozen:JR,getPrototypeOf:XR,getOwnPropertyDescriptor:QR}=Object;let{freeze:Le,seal:et,create:oo}=Object,{apply:jl,construct:Wl}=typeof Reflect<"u"&&Reflect;Le||(Le=function(e){return e});et||(et=function(e){return e});jl||(jl=function(e,n){for(var r=arguments.length,s=new Array(r>2?r-2:0),i=2;i<r;i++)s[i-2]=arguments[i];return e.apply(n,s)});Wl||(Wl=function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),s=1;s<n;s++)r[s-1]=arguments[s];return new e(...r)});const Bi=Me(Array.prototype.forEach),eD=Me(Array.prototype.lastIndexOf),Hd=Me(Array.prototype.pop),as=Me(Array.prototype.push),tD=Me(Array.prototype.splice),ao=Me(String.prototype.toLowerCase),Ya=Me(String.prototype.toString),Ka=Me(String.prototype.match),ls=Me(String.prototype.replace),nD=Me(String.prototype.indexOf),rD=Me(String.prototype.trim),Ge=Me(Object.prototype.hasOwnProperty),Re=Me(RegExp.prototype.test),cs=sD(TypeError);function Me(t){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var n=arguments.length,r=new Array(n>1?n-1:0),s=1;s<n;s++)r[s-1]=arguments[s];return jl(t,e,r)}}function sD(t){return function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return Wl(t,n)}}function W(t,e){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:ao;Vd&&Vd(t,null);let r=e.length;for(;r--;){let s=e[r];if(typeof s=="string"){const i=n(s);i!==s&&(JR(e)||(e[r]=i),s=i)}t[s]=!0}return t}function iD(t){for(let e=0;e<t.length;e++)Ge(t,e)||(t[e]=null);return t}function gt(t){const e=oo(null);for(const[n,r]of Vm(t))Ge(t,n)&&(Array.isArray(r)?e[n]=iD(r):r&&typeof r=="object"&&r.constructor===Object?e[n]=gt(r):e[n]=r);return e}function us(t,e){for(;t!==null;){const r=QR(t,e);if(r){if(r.get)return Me(r.get);if(typeof r.value=="function")return Me(r.value)}t=XR(t)}function n(){return null}return n}const Gd=Le(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Ja=Le(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Xa=Le(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),oD=Le(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Qa=Le(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),aD=Le(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),qd=Le(["#text"]),Yd=Le(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),el=Le(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),Kd=Le(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Vi=Le(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),lD=et(/\{\{[\w\W]*|[\w\W]*\}\}/gm),cD=et(/<%[\w\W]*|[\w\W]*%>/gm),uD=et(/\$\{[\w\W]*/gm),hD=et(/^data-[\-\w.\u00B7-\uFFFF]+$/),dD=et(/^aria-[\-\w]+$/),Hm=et(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),fD=et(/^(?:\w+script|data):/i),pD=et(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Gm=et(/^html$/i),gD=et(/^[a-z][.\w]*(-[.\w]+)+$/i);var Jd=Object.freeze({__proto__:null,ARIA_ATTR:dD,ATTR_WHITESPACE:pD,CUSTOM_ELEMENT:gD,DATA_ATTR:hD,DOCTYPE_NAME:Gm,ERB_EXPR:cD,IS_ALLOWED_URI:Hm,IS_SCRIPT_OR_DATA:fD,MUSTACHE_EXPR:lD,TMPLIT_EXPR:uD});const hs={element:1,text:3,progressingInstruction:7,comment:8,document:9},mD=function(){return typeof window>"u"?null:window},vD=function(e,n){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let r=null;const s="data-tt-policy-suffix";n&&n.hasAttribute(s)&&(r=n.getAttribute(s));const i="dompurify"+(r?"#"+r:"");try{return e.createPolicy(i,{createHTML(o){return o},createScriptURL(o){return o}})}catch{return console.warn("TrustedTypes policy "+i+" could not be created."),null}},Xd=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function qm(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:mD();const e=O=>qm(O);if(e.version="3.3.3",e.removed=[],!t||!t.document||t.document.nodeType!==hs.document||!t.Element)return e.isSupported=!1,e;let{document:n}=t;const r=n,s=r.currentScript,{DocumentFragment:i,HTMLTemplateElement:o,Node:a,Element:l,NodeFilter:c,NamedNodeMap:d=t.NamedNodeMap||t.MozNamedAttrMap,HTMLFormElement:f,DOMParser:y,trustedTypes:m}=t,E=l.prototype,k=us(E,"cloneNode"),I=us(E,"remove"),V=us(E,"nextSibling"),N=us(E,"childNodes"),j=us(E,"parentNode");if(typeof o=="function"){const O=n.createElement("template");O.content&&O.content.ownerDocument&&(n=O.content.ownerDocument)}let F,L="";const{implementation:J,createNodeIterator:G,createDocumentFragment:he,getElementsByTagName:ct}=n,{importNode:wi}=r;let Ee=Xd();e.isSupported=typeof Vm=="function"&&typeof j=="function"&&J&&J.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:gn,ERB_EXPR:ut,TMPLIT_EXPR:Bt,DATA_ATTR:ta,ARIA_ATTR:_i,IS_SCRIPT_OR_DATA:vv,ATTR_WHITESPACE:Xc,CUSTOM_ELEMENT:yv}=Jd;let{IS_ALLOWED_URI:Qc}=Jd,we=null;const eu=W({},[...Gd,...Ja,...Xa,...Qa,...qd]);let $e=null;const tu=W({},[...Yd,...el,...Kd,...Vi]);let fe=Object.seal(oo(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Xr=null,Si=null;const Vt=Object.seal(oo(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let nu=!0,na=!0,ru=!1,su=!0,Jn=!1,ki=!0,mn=!1,ra=!1,sa=!1,Xn=!1,Ei=!1,$i=!1,iu=!0,ou=!1;const bv="user-content-";let ia=!0,Qr=!1,Qn={},ht=null;const oa=W({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let au=null;const lu=W({},["audio","video","img","source","image","track"]);let aa=null;const cu=W({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Ai="http://www.w3.org/1998/Math/MathML",xi="http://www.w3.org/2000/svg",Et="http://www.w3.org/1999/xhtml";let er=Et,la=!1,ca=null;const wv=W({},[Ai,xi,Et],Ya);let Ci=W({},["mi","mo","mn","ms","mtext"]),Ti=W({},["annotation-xml"]);const _v=W({},["title","style","font","a","script"]);let es=null;const Sv=["application/xhtml+xml","text/html"],kv="text/html";let ve=null,tr=null;const Ev=n.createElement("form"),uu=function(g){return g instanceof RegExp||g instanceof Function},ua=function(){let g=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(tr&&tr===g)){if((!g||typeof g!="object")&&(g={}),g=gt(g),es=Sv.indexOf(g.PARSER_MEDIA_TYPE)===-1?kv:g.PARSER_MEDIA_TYPE,ve=es==="application/xhtml+xml"?Ya:ao,we=Ge(g,"ALLOWED_TAGS")?W({},g.ALLOWED_TAGS,ve):eu,$e=Ge(g,"ALLOWED_ATTR")?W({},g.ALLOWED_ATTR,ve):tu,ca=Ge(g,"ALLOWED_NAMESPACES")?W({},g.ALLOWED_NAMESPACES,Ya):wv,aa=Ge(g,"ADD_URI_SAFE_ATTR")?W(gt(cu),g.ADD_URI_SAFE_ATTR,ve):cu,au=Ge(g,"ADD_DATA_URI_TAGS")?W(gt(lu),g.ADD_DATA_URI_TAGS,ve):lu,ht=Ge(g,"FORBID_CONTENTS")?W({},g.FORBID_CONTENTS,ve):oa,Xr=Ge(g,"FORBID_TAGS")?W({},g.FORBID_TAGS,ve):gt({}),Si=Ge(g,"FORBID_ATTR")?W({},g.FORBID_ATTR,ve):gt({}),Qn=Ge(g,"USE_PROFILES")?g.USE_PROFILES:!1,nu=g.ALLOW_ARIA_ATTR!==!1,na=g.ALLOW_DATA_ATTR!==!1,ru=g.ALLOW_UNKNOWN_PROTOCOLS||!1,su=g.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Jn=g.SAFE_FOR_TEMPLATES||!1,ki=g.SAFE_FOR_XML!==!1,mn=g.WHOLE_DOCUMENT||!1,Xn=g.RETURN_DOM||!1,Ei=g.RETURN_DOM_FRAGMENT||!1,$i=g.RETURN_TRUSTED_TYPE||!1,sa=g.FORCE_BODY||!1,iu=g.SANITIZE_DOM!==!1,ou=g.SANITIZE_NAMED_PROPS||!1,ia=g.KEEP_CONTENT!==!1,Qr=g.IN_PLACE||!1,Qc=g.ALLOWED_URI_REGEXP||Hm,er=g.NAMESPACE||Et,Ci=g.MATHML_TEXT_INTEGRATION_POINTS||Ci,Ti=g.HTML_INTEGRATION_POINTS||Ti,fe=g.CUSTOM_ELEMENT_HANDLING||{},g.CUSTOM_ELEMENT_HANDLING&&uu(g.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(fe.tagNameCheck=g.CUSTOM_ELEMENT_HANDLING.tagNameCheck),g.CUSTOM_ELEMENT_HANDLING&&uu(g.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(fe.attributeNameCheck=g.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),g.CUSTOM_ELEMENT_HANDLING&&typeof g.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(fe.allowCustomizedBuiltInElements=g.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Jn&&(na=!1),Ei&&(Xn=!0),Qn&&(we=W({},qd),$e=oo(null),Qn.html===!0&&(W(we,Gd),W($e,Yd)),Qn.svg===!0&&(W(we,Ja),W($e,el),W($e,Vi)),Qn.svgFilters===!0&&(W(we,Xa),W($e,el),W($e,Vi)),Qn.mathMl===!0&&(W(we,Qa),W($e,Kd),W($e,Vi))),Ge(g,"ADD_TAGS")||(Vt.tagCheck=null),Ge(g,"ADD_ATTR")||(Vt.attributeCheck=null),g.ADD_TAGS&&(typeof g.ADD_TAGS=="function"?Vt.tagCheck=g.ADD_TAGS:(we===eu&&(we=gt(we)),W(we,g.ADD_TAGS,ve))),g.ADD_ATTR&&(typeof g.ADD_ATTR=="function"?Vt.attributeCheck=g.ADD_ATTR:($e===tu&&($e=gt($e)),W($e,g.ADD_ATTR,ve))),g.ADD_URI_SAFE_ATTR&&W(aa,g.ADD_URI_SAFE_ATTR,ve),g.FORBID_CONTENTS&&(ht===oa&&(ht=gt(ht)),W(ht,g.FORBID_CONTENTS,ve)),g.ADD_FORBID_CONTENTS&&(ht===oa&&(ht=gt(ht)),W(ht,g.ADD_FORBID_CONTENTS,ve)),ia&&(we["#text"]=!0),mn&&W(we,["html","head","body"]),we.table&&(W(we,["tbody"]),delete Xr.tbody),g.TRUSTED_TYPES_POLICY){if(typeof g.TRUSTED_TYPES_POLICY.createHTML!="function")throw cs('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof g.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw cs('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');F=g.TRUSTED_TYPES_POLICY,L=F.createHTML("")}else F===void 0&&(F=vD(m,s)),F!==null&&typeof L=="string"&&(L=F.createHTML(""));Le&&Le(g),tr=g}},hu=W({},[...Ja,...Xa,...oD]),du=W({},[...Qa,...aD]),$v=function(g){let C=j(g);(!C||!C.tagName)&&(C={namespaceURI:er,tagName:"template"});const P=ao(g.tagName),se=ao(C.tagName);return ca[g.namespaceURI]?g.namespaceURI===xi?C.namespaceURI===Et?P==="svg":C.namespaceURI===Ai?P==="svg"&&(se==="annotation-xml"||Ci[se]):!!hu[P]:g.namespaceURI===Ai?C.namespaceURI===Et?P==="math":C.namespaceURI===xi?P==="math"&&Ti[se]:!!du[P]:g.namespaceURI===Et?C.namespaceURI===xi&&!Ti[se]||C.namespaceURI===Ai&&!Ci[se]?!1:!du[P]&&(_v[P]||!hu[P]):!!(es==="application/xhtml+xml"&&ca[g.namespaceURI]):!1},dt=function(g){as(e.removed,{element:g});try{j(g).removeChild(g)}catch{I(g)}},vn=function(g,C){try{as(e.removed,{attribute:C.getAttributeNode(g),from:C})}catch{as(e.removed,{attribute:null,from:C})}if(C.removeAttribute(g),g==="is")if(Xn||Ei)try{dt(C)}catch{}else try{C.setAttribute(g,"")}catch{}},fu=function(g){let C=null,P=null;if(sa)g="<remove></remove>"+g;else{const pe=Ka(g,/^[\r\n\t ]+/);P=pe&&pe[0]}es==="application/xhtml+xml"&&er===Et&&(g='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+g+"</body></html>");const se=F?F.createHTML(g):g;if(er===Et)try{C=new y().parseFromString(se,es)}catch{}if(!C||!C.documentElement){C=J.createDocument(er,"template",null);try{C.documentElement.innerHTML=la?L:se}catch{}}const Ie=C.body||C.documentElement;return g&&P&&Ie.insertBefore(n.createTextNode(P),Ie.childNodes[0]||null),er===Et?ct.call(C,mn?"html":"body")[0]:mn?C.documentElement:Ie},pu=function(g){return G.call(g.ownerDocument||g,g,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},ha=function(g){return g instanceof f&&(typeof g.nodeName!="string"||typeof g.textContent!="string"||typeof g.removeChild!="function"||!(g.attributes instanceof d)||typeof g.removeAttribute!="function"||typeof g.setAttribute!="function"||typeof g.namespaceURI!="string"||typeof g.insertBefore!="function"||typeof g.hasChildNodes!="function")},gu=function(g){return typeof a=="function"&&g instanceof a};function $t(O,g,C){Bi(O,P=>{P.call(e,g,C,tr)})}const mu=function(g){let C=null;if($t(Ee.beforeSanitizeElements,g,null),ha(g))return dt(g),!0;const P=ve(g.nodeName);if($t(Ee.uponSanitizeElement,g,{tagName:P,allowedTags:we}),ki&&g.hasChildNodes()&&!gu(g.firstElementChild)&&Re(/<[/\w!]/g,g.innerHTML)&&Re(/<[/\w!]/g,g.textContent)||g.nodeType===hs.progressingInstruction||ki&&g.nodeType===hs.comment&&Re(/<[/\w]/g,g.data))return dt(g),!0;if(!(Vt.tagCheck instanceof Function&&Vt.tagCheck(P))&&(!we[P]||Xr[P])){if(!Xr[P]&&yu(P)&&(fe.tagNameCheck instanceof RegExp&&Re(fe.tagNameCheck,P)||fe.tagNameCheck instanceof Function&&fe.tagNameCheck(P)))return!1;if(ia&&!ht[P]){const se=j(g)||g.parentNode,Ie=N(g)||g.childNodes;if(Ie&&se){const pe=Ie.length;for(let Ne=pe-1;Ne>=0;--Ne){const At=k(Ie[Ne],!0);At.__removalCount=(g.__removalCount||0)+1,se.insertBefore(At,V(g))}}}return dt(g),!0}return g instanceof l&&!$v(g)||(P==="noscript"||P==="noembed"||P==="noframes")&&Re(/<\/no(script|embed|frames)/i,g.innerHTML)?(dt(g),!0):(Jn&&g.nodeType===hs.text&&(C=g.textContent,Bi([gn,ut,Bt],se=>{C=ls(C,se," ")}),g.textContent!==C&&(as(e.removed,{element:g.cloneNode()}),g.textContent=C)),$t(Ee.afterSanitizeElements,g,null),!1)},vu=function(g,C,P){if(Si[C]||iu&&(C==="id"||C==="name")&&(P in n||P in Ev))return!1;if(!(na&&!Si[C]&&Re(ta,C))){if(!(nu&&Re(_i,C))){if(!(Vt.attributeCheck instanceof Function&&Vt.attributeCheck(C,g))){if(!$e[C]||Si[C]){if(!(yu(g)&&(fe.tagNameCheck instanceof RegExp&&Re(fe.tagNameCheck,g)||fe.tagNameCheck instanceof Function&&fe.tagNameCheck(g))&&(fe.attributeNameCheck instanceof RegExp&&Re(fe.attributeNameCheck,C)||fe.attributeNameCheck instanceof Function&&fe.attributeNameCheck(C,g))||C==="is"&&fe.allowCustomizedBuiltInElements&&(fe.tagNameCheck instanceof RegExp&&Re(fe.tagNameCheck,P)||fe.tagNameCheck instanceof Function&&fe.tagNameCheck(P))))return!1}else if(!aa[C]){if(!Re(Qc,ls(P,Xc,""))){if(!((C==="src"||C==="xlink:href"||C==="href")&&g!=="script"&&nD(P,"data:")===0&&au[g])){if(!(ru&&!Re(vv,ls(P,Xc,"")))){if(P)return!1}}}}}}}return!0},yu=function(g){return g!=="annotation-xml"&&Ka(g,yv)},bu=function(g){$t(Ee.beforeSanitizeAttributes,g,null);const{attributes:C}=g;if(!C||ha(g))return;const P={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:$e,forceKeepAttr:void 0};let se=C.length;for(;se--;){const Ie=C[se],{name:pe,namespaceURI:Ne,value:At}=Ie,nr=ve(pe),da=At;let Ae=pe==="value"?da:rD(da);if(P.attrName=nr,P.attrValue=Ae,P.keepAttr=!0,P.forceKeepAttr=void 0,$t(Ee.uponSanitizeAttribute,g,P),Ae=P.attrValue,ou&&(nr==="id"||nr==="name")&&(vn(pe,g),Ae=bv+Ae),ki&&Re(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,Ae)){vn(pe,g);continue}if(nr==="attributename"&&Ka(Ae,"href")){vn(pe,g);continue}if(P.forceKeepAttr)continue;if(!P.keepAttr){vn(pe,g);continue}if(!su&&Re(/\/>/i,Ae)){vn(pe,g);continue}Jn&&Bi([gn,ut,Bt],_u=>{Ae=ls(Ae,_u," ")});const wu=ve(g.nodeName);if(!vu(wu,nr,Ae)){vn(pe,g);continue}if(F&&typeof m=="object"&&typeof m.getAttributeType=="function"&&!Ne)switch(m.getAttributeType(wu,nr)){case"TrustedHTML":{Ae=F.createHTML(Ae);break}case"TrustedScriptURL":{Ae=F.createScriptURL(Ae);break}}if(Ae!==da)try{Ne?g.setAttributeNS(Ne,pe,Ae):g.setAttribute(pe,Ae),ha(g)?dt(g):Hd(e.removed)}catch{vn(pe,g)}}$t(Ee.afterSanitizeAttributes,g,null)},Av=function O(g){let C=null;const P=pu(g);for($t(Ee.beforeSanitizeShadowDOM,g,null);C=P.nextNode();)$t(Ee.uponSanitizeShadowNode,C,null),mu(C),bu(C),C.content instanceof i&&O(C.content);$t(Ee.afterSanitizeShadowDOM,g,null)};return e.sanitize=function(O){let g=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},C=null,P=null,se=null,Ie=null;if(la=!O,la&&(O="<!-->"),typeof O!="string"&&!gu(O))if(typeof O.toString=="function"){if(O=O.toString(),typeof O!="string")throw cs("dirty is not a string, aborting")}else throw cs("toString is not a function");if(!e.isSupported)return O;if(ra||ua(g),e.removed=[],typeof O=="string"&&(Qr=!1),Qr){if(O.nodeName){const At=ve(O.nodeName);if(!we[At]||Xr[At])throw cs("root node is forbidden and cannot be sanitized in-place")}}else if(O instanceof a)C=fu("<!---->"),P=C.ownerDocument.importNode(O,!0),P.nodeType===hs.element&&P.nodeName==="BODY"||P.nodeName==="HTML"?C=P:C.appendChild(P);else{if(!Xn&&!Jn&&!mn&&O.indexOf("<")===-1)return F&&$i?F.createHTML(O):O;if(C=fu(O),!C)return Xn?null:$i?L:""}C&&sa&&dt(C.firstChild);const pe=pu(Qr?O:C);for(;se=pe.nextNode();)mu(se),bu(se),se.content instanceof i&&Av(se.content);if(Qr)return O;if(Xn){if(Ei)for(Ie=he.call(C.ownerDocument);C.firstChild;)Ie.appendChild(C.firstChild);else Ie=C;return($e.shadowroot||$e.shadowrootmode)&&(Ie=wi.call(r,Ie,!0)),Ie}let Ne=mn?C.outerHTML:C.innerHTML;return mn&&we["!doctype"]&&C.ownerDocument&&C.ownerDocument.doctype&&C.ownerDocument.doctype.name&&Re(Gm,C.ownerDocument.doctype.name)&&(Ne="<!DOCTYPE "+C.ownerDocument.doctype.name+`>
|
|
253
|
-
`+Ne),Jn&&Bi([gn,ut,Bt],At=>{Ne=ls(Ne,At," ")}),F&&$i?F.createHTML(Ne):Ne},e.setConfig=function(){let O=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};ua(O),ra=!0},e.clearConfig=function(){tr=null,ra=!1},e.isValidAttribute=function(O,g,C){tr||ua({});const P=ve(O),se=ve(g);return vu(P,se,C)},e.addHook=function(O,g){typeof g=="function"&&as(Ee[O],g)},e.removeHook=function(O,g){if(g!==void 0){const C=eD(Ee[O],g);return C===-1?void 0:tD(Ee[O],C,1)[0]}return Hd(Ee[O])},e.removeHooks=function(O){Ee[O]=[]},e.removeAllHooks=function(){Ee=Xd()},e}var Ym=qm();function Zc(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Kn=Zc();function Km(t){Kn=t}var $n={exec:()=>null};function q(t,e=""){let n=typeof t=="string"?t:t.source,r={replace:(s,i)=>{let o=typeof i=="string"?i:i.source;return o=o.replace(ze.caret,"$1"),n=n.replace(s,o),r},getRegex:()=>new RegExp(n,e)};return r}var yD=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),ze={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:t=>new RegExp(`^( {0,3}${t})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}#`),htmlBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}<(?:[a-z].*>|!--)`,"i"),blockquoteBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}>`)},bD=/^(?:[ \t]*(?:\n|$))+/,wD=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,_D=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,bi=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,SD=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,jc=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Jm=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Xm=q(Jm).replace(/bull/g,jc).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),kD=q(Jm).replace(/bull/g,jc).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(),Wc=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,ED=/^[^\n]+/,Bc=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,$D=q(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Bc).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),AD=q(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,jc).getRegex(),Xo="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",Vc=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,xD=q("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",Vc).replace("tag",Xo).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Qm=q(Wc).replace("hr",bi).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Xo).getRegex(),CD=q(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Qm).getRegex(),Hc={blockquote:CD,code:wD,def:$D,fences:_D,heading:SD,hr:bi,html:xD,lheading:Xm,list:AD,newline:bD,paragraph:Qm,table:$n,text:ED},Qd=q("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",bi).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Xo).getRegex(),TD={...Hc,lheading:kD,table:Qd,paragraph:q(Wc).replace("hr",bi).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Qd).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Xo).getRegex()},ID={...Hc,html:q(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Vc).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:$n,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:q(Wc).replace("hr",bi).replace("heading",` *#{1,6} *[^
|
|
254
|
-
]`).replace("lheading",Xm).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},PD=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,RD=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,ev=/^( {2,}|\\)\n(?!\s*$)/,DD=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Jr=/[\p{P}\p{S}]/u,Qo=/[\s\p{P}\p{S}]/u,Gc=/[^\s\p{P}\p{S}]/u,OD=q(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Qo).getRegex(),tv=/(?!~)[\p{P}\p{S}]/u,zD=/(?!~)[\s\p{P}\p{S}]/u,LD=/(?:[^\s\p{P}\p{S}]|~)/u,MD=q(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",yD?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),nv=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,ND=q(nv,"u").replace(/punct/g,Jr).getRegex(),UD=q(nv,"u").replace(/punct/g,tv).getRegex(),rv="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",FD=q(rv,"gu").replace(/notPunctSpace/g,Gc).replace(/punctSpace/g,Qo).replace(/punct/g,Jr).getRegex(),ZD=q(rv,"gu").replace(/notPunctSpace/g,LD).replace(/punctSpace/g,zD).replace(/punct/g,tv).getRegex(),jD=q("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Gc).replace(/punctSpace/g,Qo).replace(/punct/g,Jr).getRegex(),WD=q(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,Jr).getRegex(),BD="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",VD=q(BD,"gu").replace(/notPunctSpace/g,Gc).replace(/punctSpace/g,Qo).replace(/punct/g,Jr).getRegex(),HD=q(/\\(punct)/,"gu").replace(/punct/g,Jr).getRegex(),GD=q(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),qD=q(Vc).replace("(?:-->|$)","-->").getRegex(),YD=q("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",qD).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),ko=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,KD=q(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",ko).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),sv=q(/^!?\[(label)\]\[(ref)\]/).replace("label",ko).replace("ref",Bc).getRegex(),iv=q(/^!?\[(ref)\](?:\[\])?/).replace("ref",Bc).getRegex(),JD=q("reflink|nolink(?!\\()","g").replace("reflink",sv).replace("nolink",iv).getRegex(),ef=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,qc={_backpedal:$n,anyPunctuation:HD,autolink:GD,blockSkip:MD,br:ev,code:RD,del:$n,delLDelim:$n,delRDelim:$n,emStrongLDelim:ND,emStrongRDelimAst:FD,emStrongRDelimUnd:jD,escape:PD,link:KD,nolink:iv,punctuation:OD,reflink:sv,reflinkSearch:JD,tag:YD,text:DD,url:$n},XD={...qc,link:q(/^!?\[(label)\]\((.*?)\)/).replace("label",ko).getRegex(),reflink:q(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",ko).getRegex()},Bl={...qc,emStrongRDelimAst:ZD,emStrongLDelim:UD,delLDelim:WD,delRDelim:VD,url:q(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",ef).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:q(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",ef).getRegex()},QD={...Bl,br:q(ev).replace("{2,}","*").getRegex(),text:q(Bl.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Hi={normal:Hc,gfm:TD,pedantic:ID},ds={normal:qc,gfm:Bl,breaks:QD,pedantic:XD},eO={"&":"&","<":"<",">":">",'"':""","'":"'"},tf=t=>eO[t];function mt(t,e){if(e){if(ze.escapeTest.test(t))return t.replace(ze.escapeReplace,tf)}else if(ze.escapeTestNoEncode.test(t))return t.replace(ze.escapeReplaceNoEncode,tf);return t}function nf(t){try{t=encodeURI(t).replace(ze.percentDecode,"%")}catch{return null}return t}function rf(t,e){var i;let n=t.replace(ze.findPipe,(o,a,l)=>{let c=!1,d=a;for(;--d>=0&&l[d]==="\\";)c=!c;return c?"|":" |"}),r=n.split(ze.splitPipe),s=0;if(r[0].trim()||r.shift(),r.length>0&&!((i=r.at(-1))!=null&&i.trim())&&r.pop(),e)if(r.length>e)r.splice(e);else for(;r.length<e;)r.push("");for(;s<r.length;s++)r[s]=r[s].trim().replace(ze.slashPipe,"|");return r}function fs(t,e,n){let r=t.length;if(r===0)return"";let s=0;for(;s<r&&t.charAt(r-s-1)===e;)s++;return t.slice(0,r-s)}function tO(t,e){if(t.indexOf(e[1])===-1)return-1;let n=0;for(let r=0;r<t.length;r++)if(t[r]==="\\")r++;else if(t[r]===e[0])n++;else if(t[r]===e[1]&&(n--,n<0))return r;return n>0?-2:-1}function nO(t,e=0){let n=e,r="";for(let s of t)if(s===" "){let i=4-n%4;r+=" ".repeat(i),n+=i}else r+=s,n++;return r}function sf(t,e,n,r,s){let i=e.href,o=e.title||null,a=t[1].replace(s.other.outputLinkReplace,"$1");r.state.inLink=!0;let l={type:t[0].charAt(0)==="!"?"image":"link",raw:n,href:i,title:o,text:a,tokens:r.inlineTokens(a)};return r.state.inLink=!1,l}function rO(t,e,n){let r=t.match(n.other.indentCodeCompensation);if(r===null)return e;let s=r[1];return e.split(`
|
|
255
|
-
`).map(i=>{let o=i.match(n.other.beginningSpace);if(o===null)return i;let[a]=o;return a.length>=s.length?i.slice(s.length):i}).join(`
|
|
256
|
-
`)}var Eo=class{constructor(t){v(this,"options");v(this,"rules");v(this,"lexer");this.options=t||Kn}space(t){let e=this.rules.block.newline.exec(t);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(t){let e=this.rules.block.code.exec(t);if(e){let n=e[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:e[0],codeBlockStyle:"indented",text:this.options.pedantic?n:fs(n,`
|
|
257
|
-
`)}}}fences(t){let e=this.rules.block.fences.exec(t);if(e){let n=e[0],r=rO(n,e[3]||"",this.rules);return{type:"code",raw:n,lang:e[2]?e[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):e[2],text:r}}}heading(t){let e=this.rules.block.heading.exec(t);if(e){let n=e[2].trim();if(this.rules.other.endingHash.test(n)){let r=fs(n,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(n=r.trim())}return{type:"heading",raw:e[0],depth:e[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(t){let e=this.rules.block.hr.exec(t);if(e)return{type:"hr",raw:fs(e[0],`
|
|
258
|
-
`)}}blockquote(t){let e=this.rules.block.blockquote.exec(t);if(e){let n=fs(e[0],`
|
|
259
|
-
`).split(`
|
|
260
|
-
`),r="",s="",i=[];for(;n.length>0;){let o=!1,a=[],l;for(l=0;l<n.length;l++)if(this.rules.other.blockquoteStart.test(n[l]))a.push(n[l]),o=!0;else if(!o)a.push(n[l]);else break;n=n.slice(l);let c=a.join(`
|
|
261
|
-
`),d=c.replace(this.rules.other.blockquoteSetextReplace,`
|
|
262
|
-
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");r=r?`${r}
|
|
263
|
-
${c}`:c,s=s?`${s}
|
|
264
|
-
${d}`:d;let f=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(d,i,!0),this.lexer.state.top=f,n.length===0)break;let y=i.at(-1);if((y==null?void 0:y.type)==="code")break;if((y==null?void 0:y.type)==="blockquote"){let m=y,E=m.raw+`
|
|
265
|
-
`+n.join(`
|
|
266
|
-
`),k=this.blockquote(E);i[i.length-1]=k,r=r.substring(0,r.length-m.raw.length)+k.raw,s=s.substring(0,s.length-m.text.length)+k.text;break}else if((y==null?void 0:y.type)==="list"){let m=y,E=m.raw+`
|
|
267
|
-
`+n.join(`
|
|
268
|
-
`),k=this.list(E);i[i.length-1]=k,r=r.substring(0,r.length-y.raw.length)+k.raw,s=s.substring(0,s.length-m.raw.length)+k.raw,n=E.substring(i.at(-1).raw.length).split(`
|
|
269
|
-
`);continue}}return{type:"blockquote",raw:r,tokens:i,text:s}}}list(t){var n,r;let e=this.rules.block.list.exec(t);if(e){let s=e[1].trim(),i=s.length>1,o={type:"list",raw:"",ordered:i,start:i?+s.slice(0,-1):"",loose:!1,items:[]};s=i?`\\d{1,9}\\${s.slice(-1)}`:`\\${s}`,this.options.pedantic&&(s=i?s:"[*+-]");let a=this.rules.other.listItemRegex(s),l=!1;for(;t;){let d=!1,f="",y="";if(!(e=a.exec(t))||this.rules.block.hr.test(t))break;f=e[0],t=t.substring(f.length);let m=nO(e[2].split(`
|
|
270
|
-
`,1)[0],e[1].length),E=t.split(`
|
|
271
|
-
`,1)[0],k=!m.trim(),I=0;if(this.options.pedantic?(I=2,y=m.trimStart()):k?I=e[1].length+1:(I=m.search(this.rules.other.nonSpaceChar),I=I>4?1:I,y=m.slice(I),I+=e[1].length),k&&this.rules.other.blankLine.test(E)&&(f+=E+`
|
|
272
|
-
`,t=t.substring(E.length+1),d=!0),!d){let V=this.rules.other.nextBulletRegex(I),N=this.rules.other.hrRegex(I),j=this.rules.other.fencesBeginRegex(I),F=this.rules.other.headingBeginRegex(I),L=this.rules.other.htmlBeginRegex(I),J=this.rules.other.blockquoteBeginRegex(I);for(;t;){let G=t.split(`
|
|
273
|
-
`,1)[0],he;if(E=G,this.options.pedantic?(E=E.replace(this.rules.other.listReplaceNesting," "),he=E):he=E.replace(this.rules.other.tabCharGlobal," "),j.test(E)||F.test(E)||L.test(E)||J.test(E)||V.test(E)||N.test(E))break;if(he.search(this.rules.other.nonSpaceChar)>=I||!E.trim())y+=`
|
|
274
|
-
`+he.slice(I);else{if(k||m.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||j.test(m)||F.test(m)||N.test(m))break;y+=`
|
|
275
|
-
`+E}k=!E.trim(),f+=G+`
|
|
276
|
-
`,t=t.substring(G.length+1),m=he.slice(I)}}o.loose||(l?o.loose=!0:this.rules.other.doubleBlankLine.test(f)&&(l=!0)),o.items.push({type:"list_item",raw:f,task:!!this.options.gfm&&this.rules.other.listIsTask.test(y),loose:!1,text:y,tokens:[]}),o.raw+=f}let c=o.items.at(-1);if(c)c.raw=c.raw.trimEnd(),c.text=c.text.trimEnd();else return;o.raw=o.raw.trimEnd();for(let d of o.items){if(this.lexer.state.top=!1,d.tokens=this.lexer.blockTokens(d.text,[]),d.task){if(d.text=d.text.replace(this.rules.other.listReplaceTask,""),((n=d.tokens[0])==null?void 0:n.type)==="text"||((r=d.tokens[0])==null?void 0:r.type)==="paragraph"){d.tokens[0].raw=d.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),d.tokens[0].text=d.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let y=this.lexer.inlineQueue.length-1;y>=0;y--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[y].src)){this.lexer.inlineQueue[y].src=this.lexer.inlineQueue[y].src.replace(this.rules.other.listReplaceTask,"");break}}let f=this.rules.other.listTaskCheckbox.exec(d.raw);if(f){let y={type:"checkbox",raw:f[0]+" ",checked:f[0]!=="[ ]"};d.checked=y.checked,o.loose?d.tokens[0]&&["paragraph","text"].includes(d.tokens[0].type)&&"tokens"in d.tokens[0]&&d.tokens[0].tokens?(d.tokens[0].raw=y.raw+d.tokens[0].raw,d.tokens[0].text=y.raw+d.tokens[0].text,d.tokens[0].tokens.unshift(y)):d.tokens.unshift({type:"paragraph",raw:y.raw,text:y.raw,tokens:[y]}):d.tokens.unshift(y)}}if(!o.loose){let f=d.tokens.filter(m=>m.type==="space"),y=f.length>0&&f.some(m=>this.rules.other.anyLine.test(m.raw));o.loose=y}}if(o.loose)for(let d of o.items){d.loose=!0;for(let f of d.tokens)f.type==="text"&&(f.type="paragraph")}return o}}html(t){let e=this.rules.block.html.exec(t);if(e)return{type:"html",block:!0,raw:e[0],pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:e[0]}}def(t){let e=this.rules.block.def.exec(t);if(e){let n=e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),r=e[2]?e[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",s=e[3]?e[3].substring(1,e[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):e[3];return{type:"def",tag:n,raw:e[0],href:r,title:s}}}table(t){var o;let e=this.rules.block.table.exec(t);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;let n=rf(e[1]),r=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),s=(o=e[3])!=null&&o.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
277
|
-
`):[],i={type:"table",raw:e[0],header:[],align:[],rows:[]};if(n.length===r.length){for(let a of r)this.rules.other.tableAlignRight.test(a)?i.align.push("right"):this.rules.other.tableAlignCenter.test(a)?i.align.push("center"):this.rules.other.tableAlignLeft.test(a)?i.align.push("left"):i.align.push(null);for(let a=0;a<n.length;a++)i.header.push({text:n[a],tokens:this.lexer.inline(n[a]),header:!0,align:i.align[a]});for(let a of s)i.rows.push(rf(a,i.header.length).map((l,c)=>({text:l,tokens:this.lexer.inline(l),header:!1,align:i.align[c]})));return i}}lheading(t){let e=this.rules.block.lheading.exec(t);if(e){let n=e[1].trim();return{type:"heading",raw:e[0],depth:e[2].charAt(0)==="="?1:2,text:n,tokens:this.lexer.inline(n)}}}paragraph(t){let e=this.rules.block.paragraph.exec(t);if(e){let n=e[1].charAt(e[1].length-1)===`
|
|
278
|
-
`?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:n,tokens:this.lexer.inline(n)}}}text(t){let e=this.rules.block.text.exec(t);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(t){let e=this.rules.inline.escape.exec(t);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(t){let e=this.rules.inline.tag.exec(t);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(t){let e=this.rules.inline.link.exec(t);if(e){let n=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;let i=fs(n.slice(0,-1),"\\");if((n.length-i.length)%2===0)return}else{let i=tO(e[2],"()");if(i===-2)return;if(i>-1){let o=(e[0].indexOf("!")===0?5:4)+e[1].length+i;e[2]=e[2].substring(0,i),e[0]=e[0].substring(0,o).trim(),e[3]=""}}let r=e[2],s="";if(this.options.pedantic){let i=this.rules.other.pedanticHrefTitle.exec(r);i&&(r=i[1],s=i[3])}else s=e[3]?e[3].slice(1,-1):"";return r=r.trim(),this.rules.other.startAngleBracket.test(r)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?r=r.slice(1):r=r.slice(1,-1)),sf(e,{href:r&&r.replace(this.rules.inline.anyPunctuation,"$1"),title:s&&s.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer,this.rules)}}reflink(t,e){let n;if((n=this.rules.inline.reflink.exec(t))||(n=this.rules.inline.nolink.exec(t))){let r=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),s=e[r.toLowerCase()];if(!s){let i=n[0].charAt(0);return{type:"text",raw:i,text:i}}return sf(n,s,n[0],this.lexer,this.rules)}}emStrong(t,e,n=""){let r=this.rules.inline.emStrongLDelim.exec(t);if(!(!r||!r[1]&&!r[2]&&!r[3]&&!r[4]||r[4]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[3])||!n||this.rules.inline.punctuation.exec(n))){let s=[...r[0]].length-1,i,o,a=s,l=0,c=r[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,e=e.slice(-1*t.length+s);(r=c.exec(e))!=null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i)continue;if(o=[...i].length,r[3]||r[4]){a+=o;continue}else if((r[5]||r[6])&&s%3&&!((s+o)%3)){l+=o;continue}if(a-=o,a>0)continue;o=Math.min(o,o+a+l);let d=[...r[0]][0].length,f=t.slice(0,s+r.index+d+o);if(Math.min(s,o)%2){let m=f.slice(1,-1);return{type:"em",raw:f,text:m,tokens:this.lexer.inlineTokens(m)}}let y=f.slice(2,-2);return{type:"strong",raw:f,text:y,tokens:this.lexer.inlineTokens(y)}}}}codespan(t){let e=this.rules.inline.code.exec(t);if(e){let n=e[2].replace(this.rules.other.newLineCharGlobal," "),r=this.rules.other.nonSpaceChar.test(n),s=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return r&&s&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:e[0],text:n}}}br(t){let e=this.rules.inline.br.exec(t);if(e)return{type:"br",raw:e[0]}}del(t,e,n=""){let r=this.rules.inline.delLDelim.exec(t);if(r&&(!r[1]||!n||this.rules.inline.punctuation.exec(n))){let s=[...r[0]].length-1,i,o,a=s,l=this.rules.inline.delRDelim;for(l.lastIndex=0,e=e.slice(-1*t.length+s);(r=l.exec(e))!=null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i||(o=[...i].length,o!==s))continue;if(r[3]||r[4]){a+=o;continue}if(a-=o,a>0)continue;o=Math.min(o,o+a);let c=[...r[0]][0].length,d=t.slice(0,s+r.index+c+o),f=d.slice(s,-s);return{type:"del",raw:d,text:f,tokens:this.lexer.inlineTokens(f)}}}}autolink(t){let e=this.rules.inline.autolink.exec(t);if(e){let n,r;return e[2]==="@"?(n=e[1],r="mailto:"+n):(n=e[1],r=n),{type:"link",raw:e[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}url(t){var n;let e;if(e=this.rules.inline.url.exec(t)){let r,s;if(e[2]==="@")r=e[0],s="mailto:"+r;else{let i;do i=e[0],e[0]=((n=this.rules.inline._backpedal.exec(e[0]))==null?void 0:n[0])??"";while(i!==e[0]);r=e[0],e[1]==="www."?s="http://"+e[0]:s=e[0]}return{type:"link",raw:e[0],text:r,href:s,tokens:[{type:"text",raw:r,text:r}]}}}inlineText(t){let e=this.rules.inline.text.exec(t);if(e){let n=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:e[0],escaped:n}}}},at=class Vl{constructor(e){v(this,"tokens");v(this,"options");v(this,"state");v(this,"inlineQueue");v(this,"tokenizer");this.tokens=[],this.tokens.links=Object.create(null),this.options=e||Kn,this.options.tokenizer=this.options.tokenizer||new Eo,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let n={other:ze,block:Hi.normal,inline:ds.normal};this.options.pedantic?(n.block=Hi.pedantic,n.inline=ds.pedantic):this.options.gfm&&(n.block=Hi.gfm,this.options.breaks?n.inline=ds.breaks:n.inline=ds.gfm),this.tokenizer.rules=n}static get rules(){return{block:Hi,inline:ds}}static lex(e,n){return new Vl(n).lex(e)}static lexInline(e,n){return new Vl(n).inlineTokens(e)}lex(e){e=e.replace(ze.carriageReturn,`
|
|
279
|
-
`),this.blockTokens(e,this.tokens);for(let n=0;n<this.inlineQueue.length;n++){let r=this.inlineQueue[n];this.inlineTokens(r.src,r.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,n=[],r=!1){var s,i,o;for(this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(ze.tabCharGlobal," ").replace(ze.spaceLine,""));e;){let a;if((i=(s=this.options.extensions)==null?void 0:s.block)!=null&&i.some(c=>(a=c.call({lexer:this},e,n))?(e=e.substring(a.raw.length),n.push(a),!0):!1))continue;if(a=this.tokenizer.space(e)){e=e.substring(a.raw.length);let c=n.at(-1);a.raw.length===1&&c!==void 0?c.raw+=`
|
|
280
|
-
`:n.push(a);continue}if(a=this.tokenizer.code(e)){e=e.substring(a.raw.length);let c=n.at(-1);(c==null?void 0:c.type)==="paragraph"||(c==null?void 0:c.type)==="text"?(c.raw+=(c.raw.endsWith(`
|
|
281
|
-
`)?"":`
|
|
282
|
-
`)+a.raw,c.text+=`
|
|
283
|
-
`+a.text,this.inlineQueue.at(-1).src=c.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 c=n.at(-1);(c==null?void 0:c.type)==="paragraph"||(c==null?void 0:c.type)==="text"?(c.raw+=(c.raw.endsWith(`
|
|
284
|
-
`)?"":`
|
|
285
|
-
`)+a.raw,c.text+=`
|
|
286
|
-
`+a.raw,this.inlineQueue.at(-1).src=c.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 l=e;if((o=this.options.extensions)!=null&&o.startBlock){let c=1/0,d=e.slice(1),f;this.options.extensions.startBlock.forEach(y=>{f=y.call({lexer:this},d),typeof f=="number"&&f>=0&&(c=Math.min(c,f))}),c<1/0&&c>=0&&(l=e.substring(0,c+1))}if(this.state.top&&(a=this.tokenizer.paragraph(l))){let c=n.at(-1);r&&(c==null?void 0:c.type)==="paragraph"?(c.raw+=(c.raw.endsWith(`
|
|
287
|
-
`)?"":`
|
|
288
|
-
`)+a.raw,c.text+=`
|
|
289
|
-
`+a.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=c.text):n.push(a),r=l.length!==e.length,e=e.substring(a.raw.length);continue}if(a=this.tokenizer.text(e)){e=e.substring(a.raw.length);let c=n.at(-1);(c==null?void 0:c.type)==="text"?(c.raw+=(c.raw.endsWith(`
|
|
290
|
-
`)?"":`
|
|
291
|
-
`)+a.raw,c.text+=`
|
|
292
|
-
`+a.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=c.text):n.push(a);continue}if(e){let c="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(c);break}else throw new Error(c)}}return this.state.top=!0,n}inline(e,n=[]){return this.inlineQueue.push({src:e,tokens:n}),n}inlineTokens(e,n=[]){var l,c,d,f,y;this.tokenizer.lexer=this;let r=e,s=null;if(this.tokens.links){let m=Object.keys(this.tokens.links);if(m.length>0)for(;(s=this.tokenizer.rules.inline.reflinkSearch.exec(r))!=null;)m.includes(s[0].slice(s[0].lastIndexOf("[")+1,-1))&&(r=r.slice(0,s.index)+"["+"a".repeat(s[0].length-2)+"]"+r.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(s=this.tokenizer.rules.inline.anyPunctuation.exec(r))!=null;)r=r.slice(0,s.index)+"++"+r.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let i;for(;(s=this.tokenizer.rules.inline.blockSkip.exec(r))!=null;)i=s[2]?s[2].length:0,r=r.slice(0,s.index+i)+"["+"a".repeat(s[0].length-i-2)+"]"+r.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);r=((c=(l=this.options.hooks)==null?void 0:l.emStrongMask)==null?void 0:c.call({lexer:this},r))??r;let o=!1,a="";for(;e;){o||(a=""),o=!1;let m;if((f=(d=this.options.extensions)==null?void 0:d.inline)!=null&&f.some(k=>(m=k.call({lexer:this},e,n))?(e=e.substring(m.raw.length),n.push(m),!0):!1))continue;if(m=this.tokenizer.escape(e)){e=e.substring(m.raw.length),n.push(m);continue}if(m=this.tokenizer.tag(e)){e=e.substring(m.raw.length),n.push(m);continue}if(m=this.tokenizer.link(e)){e=e.substring(m.raw.length),n.push(m);continue}if(m=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(m.raw.length);let k=n.at(-1);m.type==="text"&&(k==null?void 0:k.type)==="text"?(k.raw+=m.raw,k.text+=m.text):n.push(m);continue}if(m=this.tokenizer.emStrong(e,r,a)){e=e.substring(m.raw.length),n.push(m);continue}if(m=this.tokenizer.codespan(e)){e=e.substring(m.raw.length),n.push(m);continue}if(m=this.tokenizer.br(e)){e=e.substring(m.raw.length),n.push(m);continue}if(m=this.tokenizer.del(e,r,a)){e=e.substring(m.raw.length),n.push(m);continue}if(m=this.tokenizer.autolink(e)){e=e.substring(m.raw.length),n.push(m);continue}if(!this.state.inLink&&(m=this.tokenizer.url(e))){e=e.substring(m.raw.length),n.push(m);continue}let E=e;if((y=this.options.extensions)!=null&&y.startInline){let k=1/0,I=e.slice(1),V;this.options.extensions.startInline.forEach(N=>{V=N.call({lexer:this},I),typeof V=="number"&&V>=0&&(k=Math.min(k,V))}),k<1/0&&k>=0&&(E=e.substring(0,k+1))}if(m=this.tokenizer.inlineText(E)){e=e.substring(m.raw.length),m.raw.slice(-1)!=="_"&&(a=m.raw.slice(-1)),o=!0;let k=n.at(-1);(k==null?void 0:k.type)==="text"?(k.raw+=m.raw,k.text+=m.text):n.push(m);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}},$o=class{constructor(t){v(this,"options");v(this,"parser");this.options=t||Kn}space(t){return""}code({text:t,lang:e,escaped:n}){var i;let r=(i=(e||"").match(ze.notSpaceStart))==null?void 0:i[0],s=t.replace(ze.endingNewline,"")+`
|
|
293
|
-
`;return r?'<pre><code class="language-'+mt(r)+'">'+(n?s:mt(s,!0))+`</code></pre>
|
|
294
|
-
`:"<pre><code>"+(n?s:mt(s,!0))+`</code></pre>
|
|
295
|
-
`}blockquote({tokens:t}){return`<blockquote>
|
|
296
|
-
${this.parser.parse(t)}</blockquote>
|
|
297
|
-
`}html({text:t}){return t}def(t){return""}heading({tokens:t,depth:e}){return`<h${e}>${this.parser.parseInline(t)}</h${e}>
|
|
298
|
-
`}hr(t){return`<hr>
|
|
299
|
-
`}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 s=e?"ol":"ul",i=e&&n!==1?' start="'+n+'"':"";return"<"+s+i+`>
|
|
300
|
-
`+r+"</"+s+`>
|
|
301
|
-
`}listitem(t){return`<li>${this.parser.parse(t.tokens)}</li>
|
|
302
|
-
`}checkbox({checked:t}){return"<input "+(t?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:t}){return`<p>${this.parser.parseInline(t)}</p>
|
|
303
|
-
`}table(t){let e="",n="";for(let s=0;s<t.header.length;s++)n+=this.tablecell(t.header[s]);e+=this.tablerow({text:n});let r="";for(let s=0;s<t.rows.length;s++){let i=t.rows[s];n="";for(let o=0;o<i.length;o++)n+=this.tablecell(i[o]);r+=this.tablerow({text:n})}return r&&(r=`<tbody>${r}</tbody>`),`<table>
|
|
304
|
-
<thead>
|
|
305
|
-
`+e+`</thead>
|
|
306
|
-
`+r+`</table>
|
|
307
|
-
`}tablerow({text:t}){return`<tr>
|
|
308
|
-
${t}</tr>
|
|
309
|
-
`}tablecell(t){let e=this.parser.parseInline(t.tokens),n=t.header?"th":"td";return(t.align?`<${n} align="${t.align}">`:`<${n}>`)+e+`</${n}>
|
|
310
|
-
`}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${mt(t,!0)}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:e,tokens:n}){let r=this.parser.parseInline(n),s=nf(t);if(s===null)return r;t=s;let i='<a href="'+t+'"';return e&&(i+=' title="'+mt(e)+'"'),i+=">"+r+"</a>",i}image({href:t,title:e,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let s=nf(t);if(s===null)return mt(n);t=s;let i=`<img src="${t}" alt="${mt(n)}"`;return e&&(i+=` title="${mt(e)}"`),i+=">",i}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:mt(t.text)}},Yc=class{strong({text:t}){return t}em({text:t}){return t}codespan({text:t}){return t}del({text:t}){return t}html({text:t}){return t}text({text:t}){return t}link({text:t}){return""+t}image({text:t}){return""+t}br(){return""}checkbox({raw:t}){return t}},lt=class Hl{constructor(e){v(this,"options");v(this,"renderer");v(this,"textRenderer");this.options=e||Kn,this.options.renderer=this.options.renderer||new $o,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Yc}static parse(e,n){return new Hl(n).parse(e)}static parseInline(e,n){return new Hl(n).parseInline(e)}parse(e){var r,s;this.renderer.parser=this;let n="";for(let i=0;i<e.length;i++){let o=e[i];if((s=(r=this.options.extensions)==null?void 0:r.renderers)!=null&&s[o.type]){let l=o,c=this.options.extensions.renderers[l.type].call({parser:this},l);if(c!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(l.type)){n+=c||"";continue}}let a=o;switch(a.type){case"space":{n+=this.renderer.space(a);break}case"hr":{n+=this.renderer.hr(a);break}case"heading":{n+=this.renderer.heading(a);break}case"code":{n+=this.renderer.code(a);break}case"table":{n+=this.renderer.table(a);break}case"blockquote":{n+=this.renderer.blockquote(a);break}case"list":{n+=this.renderer.list(a);break}case"checkbox":{n+=this.renderer.checkbox(a);break}case"html":{n+=this.renderer.html(a);break}case"def":{n+=this.renderer.def(a);break}case"paragraph":{n+=this.renderer.paragraph(a);break}case"text":{n+=this.renderer.text(a);break}default:{let l='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(l),"";throw new Error(l)}}}return n}parseInline(e,n=this.renderer){var s,i;this.renderer.parser=this;let r="";for(let o=0;o<e.length;o++){let a=e[o];if((i=(s=this.options.extensions)==null?void 0:s.renderers)!=null&&i[a.type]){let c=this.options.extensions.renderers[a.type].call({parser:this},a);if(c!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(a.type)){r+=c||"";continue}}let l=a;switch(l.type){case"escape":{r+=n.text(l);break}case"html":{r+=n.html(l);break}case"link":{r+=n.link(l);break}case"image":{r+=n.image(l);break}case"checkbox":{r+=n.checkbox(l);break}case"strong":{r+=n.strong(l);break}case"em":{r+=n.em(l);break}case"codespan":{r+=n.codespan(l);break}case"br":{r+=n.br(l);break}case"del":{r+=n.del(l);break}case"text":{r+=n.text(l);break}default:{let c='Token with "'+l.type+'" type was not found.';if(this.options.silent)return console.error(c),"";throw new Error(c)}}}return r}},Gi,ws=(Gi=class{constructor(t){v(this,"options");v(this,"block");this.options=t||Kn}preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}emStrongMask(t){return t}provideLexer(){return this.block?at.lex:at.lexInline}provideParser(){return this.block?lt.parse:lt.parseInline}},v(Gi,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),v(Gi,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),Gi),sO=class{constructor(...t){v(this,"defaults",Zc());v(this,"options",this.setOptions);v(this,"parse",this.parseMarkdown(!0));v(this,"parseInline",this.parseMarkdown(!1));v(this,"Parser",lt);v(this,"Renderer",$o);v(this,"TextRenderer",Yc);v(this,"Lexer",at);v(this,"Tokenizer",Eo);v(this,"Hooks",ws);this.use(...t)}walkTokens(t,e){var r,s;let n=[];for(let i of t)switch(n=n.concat(e.call(this,i)),i.type){case"table":{let o=i;for(let a of o.header)n=n.concat(this.walkTokens(a.tokens,e));for(let a of o.rows)for(let l of a)n=n.concat(this.walkTokens(l.tokens,e));break}case"list":{let o=i;n=n.concat(this.walkTokens(o.items,e));break}default:{let o=i;(s=(r=this.defaults.extensions)==null?void 0:r.childTokens)!=null&&s[o.type]?this.defaults.extensions.childTokens[o.type].forEach(a=>{let l=o[a].flat(1/0);n=n.concat(this.walkTokens(l,e))}):o.tokens&&(n=n.concat(this.walkTokens(o.tokens,e)))}}return n}use(...t){let e=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach(n=>{let r={...n};if(r.async=this.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(s=>{if(!s.name)throw new Error("extension name required");if("renderer"in s){let i=e.renderers[s.name];i?e.renderers[s.name]=function(...o){let a=s.renderer.apply(this,o);return a===!1&&(a=i.apply(this,o)),a}:e.renderers[s.name]=s.renderer}if("tokenizer"in s){if(!s.level||s.level!=="block"&&s.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let i=e[s.level];i?i.unshift(s.tokenizer):e[s.level]=[s.tokenizer],s.start&&(s.level==="block"?e.startBlock?e.startBlock.push(s.start):e.startBlock=[s.start]:s.level==="inline"&&(e.startInline?e.startInline.push(s.start):e.startInline=[s.start]))}"childTokens"in s&&s.childTokens&&(e.childTokens[s.name]=s.childTokens)}),r.extensions=e),n.renderer){let s=this.defaults.renderer||new $o(this.defaults);for(let i in n.renderer){if(!(i in s))throw new Error(`renderer '${i}' does not exist`);if(["options","parser"].includes(i))continue;let o=i,a=n.renderer[o],l=s[o];s[o]=(...c)=>{let d=a.apply(s,c);return d===!1&&(d=l.apply(s,c)),d||""}}r.renderer=s}if(n.tokenizer){let s=this.defaults.tokenizer||new Eo(this.defaults);for(let i in n.tokenizer){if(!(i in s))throw new Error(`tokenizer '${i}' does not exist`);if(["options","rules","lexer"].includes(i))continue;let o=i,a=n.tokenizer[o],l=s[o];s[o]=(...c)=>{let d=a.apply(s,c);return d===!1&&(d=l.apply(s,c)),d}}r.tokenizer=s}if(n.hooks){let s=this.defaults.hooks||new ws;for(let i in n.hooks){if(!(i in s))throw new Error(`hook '${i}' does not exist`);if(["options","block"].includes(i))continue;let o=i,a=n.hooks[o],l=s[o];ws.passThroughHooks.has(i)?s[o]=c=>{if(this.defaults.async&&ws.passThroughHooksRespectAsync.has(i))return(async()=>{let f=await a.call(s,c);return l.call(s,f)})();let d=a.call(s,c);return l.call(s,d)}:s[o]=(...c)=>{if(this.defaults.async)return(async()=>{let f=await a.apply(s,c);return f===!1&&(f=await l.apply(s,c)),f})();let d=a.apply(s,c);return d===!1&&(d=l.apply(s,c)),d}}r.hooks=s}if(n.walkTokens){let s=this.defaults.walkTokens,i=n.walkTokens;r.walkTokens=function(o){let a=[];return a.push(i.call(this,o)),s&&(a=a.concat(s.call(this,o))),a}}this.defaults={...this.defaults,...r}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,e){return at.lex(t,e??this.defaults)}parser(t,e){return lt.parse(t,e??this.defaults)}parseMarkdown(t){return(e,n)=>{let r={...n},s={...this.defaults,...r},i=this.onError(!!s.silent,!!s.async);if(this.defaults.async===!0&&r.async===!1)return i(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof e>"u"||e===null)return i(new Error("marked(): input parameter is undefined or null"));if(typeof e!="string")return i(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected"));if(s.hooks&&(s.hooks.options=s,s.hooks.block=t),s.async)return(async()=>{let o=s.hooks?await s.hooks.preprocess(e):e,a=await(s.hooks?await s.hooks.provideLexer():t?at.lex:at.lexInline)(o,s),l=s.hooks?await s.hooks.processAllTokens(a):a;s.walkTokens&&await Promise.all(this.walkTokens(l,s.walkTokens));let c=await(s.hooks?await s.hooks.provideParser():t?lt.parse:lt.parseInline)(l,s);return s.hooks?await s.hooks.postprocess(c):c})().catch(i);try{s.hooks&&(e=s.hooks.preprocess(e));let o=(s.hooks?s.hooks.provideLexer():t?at.lex:at.lexInline)(e,s);s.hooks&&(o=s.hooks.processAllTokens(o)),s.walkTokens&&this.walkTokens(o,s.walkTokens);let a=(s.hooks?s.hooks.provideParser():t?lt.parse:lt.parseInline)(o,s);return s.hooks&&(a=s.hooks.postprocess(a)),a}catch(o){return i(o)}}}onError(t,e){return n=>{if(n.message+=`
|
|
311
|
-
Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error occurred:</p><pre>"+mt(n.message+"",!0)+"</pre>";return e?Promise.resolve(r):r}if(e)return Promise.reject(n);throw n}}},Vn=new sO;function X(t,e){return Vn.parse(t,e)}X.options=X.setOptions=function(t){return Vn.setOptions(t),X.defaults=Vn.defaults,Km(X.defaults),X};X.getDefaults=Zc;X.defaults=Kn;X.use=function(...t){return Vn.use(...t),X.defaults=Vn.defaults,Km(X.defaults),X};X.walkTokens=function(t,e){return Vn.walkTokens(t,e)};X.parseInline=Vn.parseInline;X.Parser=lt;X.parser=lt.parse;X.Renderer=$o;X.TextRenderer=Yc;X.Lexer=at;X.lexer=at.lex;X.Tokenizer=Eo;X.Hooks=ws;X.parse=X;X.options;X.setOptions;X.use;X.walkTokens;X.parseInline;lt.parse;at.lex;const iO=8;let of=!1;function oO(){of||(of=!0,Ym.addHook("afterSanitizeAttributes",t=>{t.tagName==="A"&&(t.setAttribute("target","_blank"),t.setAttribute("rel","noopener noreferrer"))}))}function aO(t){oO();const e=X.parse(t,{async:!1});return Ym.sanitize(e,{USE_PROFILES:{html:!0}})}function lO(t){return t.kind==="user"||t.kind==="assistant"}function af(t,e){for(let n=t.length-1;n>=0;n-=1){const r=t[n];if(r&&r.kind===e)return r.id}return null}var Mt,Tr,Nt,Ir,qe,_s,av,si,Ro,lo;class ov extends Os{constructor(){super(...arguments);x(this,qe);v(this,"messages",[]);x(this,Mt,!0);x(this,Tr,null);x(this,Nt,null);x(this,Ir,!1);x(this,si,()=>{const n=h(this,Nt);if(!n)return;const s=n.scrollHeight-n.clientHeight-n.scrollTop<=iO;s!==h(this,Mt)&&($(this,Mt,s),b(this,qe,_s).call(this))});x(this,Ro,()=>{$(this,Mt,!0),b(this,qe,_s).call(this),b(this,qe,lo).call(this,{force:!0})})}connectedCallback(){$(this,Ir,!0),$(this,Tr,af(this.messages??[],"user")),b(this,qe,_s).call(this),b(this,qe,lo).call(this,{force:!0})}disconnectedCallback(){$(this,Ir,!1),$(this,Nt,null)}propertyChangedCallback(n,r,s){if(n!=="messages"||!h(this,Ir))return;const i=this.messages??[],o=af(i,"user"),a=o!==null&&o!==h(this,Tr);$(this,Tr,o),a&&$(this,Mt,!0),b(this,qe,_s).call(this),b(this,qe,lo).call(this,{force:a})}}Mt=new WeakMap,Tr=new WeakMap,Nt=new WeakMap,Ir=new WeakMap,qe=new WeakSet,_s=function(){var i;const n=(this.messages??[]).filter(lO),r=h(this,Mt);be(M`
|
|
312
|
-
<div
|
|
313
|
-
class="chat-history-scroll"
|
|
314
|
-
role="log"
|
|
315
|
-
aria-live="polite"
|
|
316
|
-
@scroll=${h(this,si)}
|
|
317
|
-
>
|
|
318
|
-
${n.map(o=>b(this,qe,av).call(this,o))}
|
|
319
|
-
</div>
|
|
320
|
-
<button
|
|
321
|
-
type="button"
|
|
322
|
-
class="chat-history-jump"
|
|
323
|
-
aria-label="Jump to latest message"
|
|
324
|
-
?hidden=${r}
|
|
325
|
-
@click=${h(this,Ro)}
|
|
326
|
-
>
|
|
327
|
-
${Cl({size:16})}
|
|
328
|
-
<span>Jump to latest</span>
|
|
329
|
-
</button>
|
|
330
|
-
`,this);const s=this.querySelector(".chat-history-scroll");s&&s!==h(this,Nt)&&((i=h(this,Nt))==null||i.removeEventListener("scroll",h(this,si)),$(this,Nt,s))},av=function(n){const r=P1(aO(n.text));if(n.kind==="user")return M`
|
|
331
|
-
<div class="chat-message chat-message-user">
|
|
332
|
-
<div class="chat-message-body">${r}</div>
|
|
333
|
-
</div>
|
|
334
|
-
`;const s=n.status==="cancelled"?M`<span class="chat-message-badge">[cancelled]</span>`:n.status==="error"?M`<span class="chat-message-badge">[error]</span>`:null;return M`
|
|
335
|
-
<div class="chat-message chat-message-assistant">
|
|
336
|
-
<div class="chat-message-body">${r}${s}</div>
|
|
337
|
-
</div>
|
|
338
|
-
`},si=new WeakMap,Ro=new WeakMap,lo=function(n){requestAnimationFrame(()=>{const r=h(this,Nt);r&&(!h(this,Mt)&&!n.force||(r.scrollTop=r.scrollHeight-r.clientHeight))})},v(ov,"observedProperties",{messages:{type:Object}});customElements.define("chat-history",ov);const cO=Be(),uO=Be(),hO=Be(),dO=3;class lv extends Os{constructor(){super(...arguments);v(this,"value","");v(this,"disabled",!1);v(this,"disabledPlaceholder","");v(this,"action","send");v(this,"handleInput",n=>{const s=n.currentTarget.value??"";this.value=s,this.dispatchEvent(new cO("change",{value:s,bubbles:!0,composed:!0}))});v(this,"handleKeyDown",n=>{n.key==="Enter"&&(n.shiftKey||n.isComposing||(n.preventDefault(),!this.disabled&&this.action==="send"&&this.submitMessage()))});v(this,"handleButtonClick",()=>{this.disabled||(this.action==="send"?this.submitMessage():this.dispatchEvent(new hO("cancel",{bubbles:!0,composed:!0})))})}connectedCallback(){this.render()}propertyChangedCallback(){this.render()}get textareaEl(){return this.querySelector("textarea")}submitMessage(){var r;const n=(this.value??"").trim();n.length!==0&&(this.dispatchEvent(new uO("submit",{text:n,bubbles:!0,composed:!0})),(r=this.textareaEl)==null||r.focus())}computeRows(){const n=(this.value??"").split(/\r?\n/).length;return Math.min(dO,Math.max(1,n))}render(){const n=this.action==="send",r=n?"Send message":"Cancel",s=n?M1({size:16}):L1({size:16}),i=this.computeRows(),o=this.value??"",a=this.disabled?"":o,l=this.disabled?this.disabledPlaceholder:"";be(M`
|
|
339
|
-
<textarea
|
|
340
|
-
.value=${a}
|
|
341
|
-
placeholder=${l}
|
|
342
|
-
rows=${i}
|
|
343
|
-
?disabled=${this.disabled}
|
|
344
|
-
@input=${this.handleInput}
|
|
345
|
-
@keydown=${this.handleKeyDown}
|
|
346
|
-
></textarea>
|
|
347
|
-
<button
|
|
348
|
-
type="button"
|
|
349
|
-
aria-label=${r}
|
|
350
|
-
?disabled=${this.disabled}
|
|
351
|
-
@click=${this.handleButtonClick}
|
|
352
|
-
>
|
|
353
|
-
${s}
|
|
354
|
-
</button>
|
|
355
|
-
`,this)}}v(lv,"observedProperties",{value:{type:String},disabled:{type:Boolean},disabledPlaceholder:{type:String},action:{type:String}});customElements.define("chat-input",lv);var Un,xe,Pr,Fn,ii,Pe,Gl,ql,oi,Do,Oo,zo,cv,pr;class fO extends HTMLElement{constructor(){super(...arguments);x(this,Pe);x(this,Un,Ye.resolve("ACPClientManager"));x(this,xe,null);x(this,Pr,"");x(this,Fn,!1);x(this,ii,()=>{if(!h(this,Fn))return;const n=h(this,Un).getActiveClient();n!==h(this,xe)&&(b(this,Pe,ql).call(this),b(this,Pe,Gl).call(this,n)),b(this,Pe,pr).call(this)});x(this,oi,()=>{h(this,Fn)&&b(this,Pe,pr).call(this)});x(this,Do,n=>{const r=n.value;$(this,Pr,r),b(this,Pe,pr).call(this)});x(this,Oo,n=>{if(!h(this,xe))return;const r=n.text;$(this,Pr,""),b(this,Pe,pr).call(this),h(this,xe).sendMessage({text:r}).catch(s=>{console.error("ACPClient.sendMessage() failed",s)})});x(this,zo,n=>{h(this,xe)&&h(this,xe).cancel().catch(r=>{console.error("ACPClient.cancel() failed",r)})})}connectedCallback(){$(this,Fn,!0),h(this,Un).addEventListener("change",h(this,ii)),b(this,Pe,Gl).call(this,h(this,Un).getActiveClient()),b(this,Pe,pr).call(this)}disconnectedCallback(){$(this,Fn,!1),h(this,Un).removeEventListener("change",h(this,ii)),b(this,Pe,ql).call(this)}}Un=new WeakMap,xe=new WeakMap,Pr=new WeakMap,Fn=new WeakMap,ii=new WeakMap,Pe=new WeakSet,Gl=function(n){$(this,xe,n),h(this,xe)&&(h(this,xe).addEventListener("change",h(this,oi)),h(this,xe).connect().catch(r=>{console.error("ACPClient.connect() failed",r)}))},ql=function(){h(this,xe)&&(h(this,xe).removeEventListener("change",h(this,oi)),$(this,xe,null))},oi=new WeakMap,Do=new WeakMap,Oo=new WeakMap,zo=new WeakMap,cv=function(n){return n.lifecycle.status==="connecting"?"Connecting to agent…":n.lifecycle.status==="disconnected"?n.lifecycle.error?"Agent unavailable":"Agent disconnected":n.lifecycle.status==="disposed"?"Agent unavailable":n.run.status==="cancelling"?"Cancelling…":""},pr=function(){if(!h(this,xe)){this.hidden=!0;return}const n=h(this,xe).getState();this.hidden=n.lifecycle.status!=="ready";const r=n.messageOrder.map(a=>n.messagesById[a]).filter(a=>a!==void 0),s=n.run.canCancel&&n.run.status==="running"?"cancel":"send",i=n.lifecycle.status!=="ready"||n.run.status==="cancelling",o=b(this,Pe,cv).call(this,n);be(M`
|
|
356
|
-
<chat-history .messages=${r}></chat-history>
|
|
357
|
-
<div class="chat-panel-input">
|
|
358
|
-
<chat-input
|
|
359
|
-
.value=${h(this,Pr)}
|
|
360
|
-
.action=${s}
|
|
361
|
-
.disabled=${i}
|
|
362
|
-
.disabledPlaceholder=${o}
|
|
363
|
-
@change=${h(this,Do)}
|
|
364
|
-
@submit=${h(this,Oo)}
|
|
365
|
-
@cancel=${h(this,zo)}
|
|
366
|
-
></chat-input>
|
|
367
|
-
</div>
|
|
368
|
-
`,this)};customElements.get("chat-panel")||customElements.define("chat-panel",fO);class uv extends HTMLElement{constructor(){super(...arguments);v(this,"screenManager",Ye.resolve("ScreenManager"));v(this,"serverManager",Ye.resolve("ServerManager"));v(this,"handleActiveChange",()=>{this.render()});v(this,"_mode","edit");v(this,"_targetServerURL");v(this,"createPending",!1)}get open(){return this.hasAttribute("open")}set mode(n){this._mode=n,this.render()}get mode(){return this._mode}set targetServerURL(n){this._targetServerURL=n,this.render()}get targetServerURL(){return this._targetServerURL}attributeChangedCallback(n){n==="open"&&(this.open||(this.createPending=!1),this.render())}connectedCallback(){this.render(),this.screenManager.addEventListener("active-screen-changed",this.handleActiveChange)}disconnectedCallback(){this.screenManager.removeEventListener("active-screen-changed",this.handleActiveChange)}emitClose(){this.dispatchEvent(new Event("close",{bubbles:!0}))}async handleSubmit(n){var a;n.preventDefault();const r=n.currentTarget,s=new FormData(r),i=String(s.get("name")??"").trim();if(!i)return;if(this._mode==="edit"){(a=this.screenManager.activeScreen)==null||a.rename(i),this.emitClose();return}if(!this._targetServerURL)return;const o=this.serverManager.servers.get(this._targetServerURL);if(o){this.createPending=!0,this.render();try{const l=await o.createScreen(i);this.screenManager.setActive(this._targetServerURL,l.id),this.emitClose()}catch{this.createPending=!1,this.render()}}}render(){var i;const n=this._mode==="edit"?"Edit screen":"New screen",r=this._mode==="edit"?"Save":this.createPending?"Creating...":"Create",s=this._mode==="edit"?((i=this.screenManager.activeScreen)==null?void 0:i.name)??"":"";be(M`
|
|
369
|
-
<modal-overlay ?open=${this.open}>
|
|
370
|
-
<section class="screen-modal">
|
|
371
|
-
<form class="screen-form" @submit=${o=>void this.handleSubmit(o)}>
|
|
372
|
-
<h2 class="screen-modal-title">${n}</h2>
|
|
373
|
-
<label class="settings-field">
|
|
374
|
-
<span>Name</span>
|
|
375
|
-
<input type="text" name="name" .value=${s} required />
|
|
376
|
-
</label>
|
|
377
|
-
<div class="screen-form-actions">
|
|
378
|
-
<button type="submit" class="settings-submit-button" ?disabled=${this.createPending}>
|
|
379
|
-
${r}
|
|
380
|
-
</button>
|
|
381
|
-
<button type="button" class="settings-cancel-button" @click=${()=>this.emitClose()}>
|
|
382
|
-
Cancel
|
|
383
|
-
</button>
|
|
384
|
-
</div>
|
|
385
|
-
</form>
|
|
386
|
-
</section>
|
|
387
|
-
</modal-overlay>
|
|
388
|
-
`,this)}}v(uv,"observedAttributes",["open"]);customElements.define("screen-form-modal",uv);class hv extends HTMLElement{constructor(){super(...arguments);v(this,"screenManager",Ye.resolve("ScreenManager"));v(this,"serverManager",Ye.resolve("ServerManager"));v(this,"handleChange",()=>{this.render()});v(this,"deletePending",!1);v(this,"deleteError",null)}get open(){return this.hasAttribute("open")}attributeChangedCallback(n,r,s){n==="open"&&(s!==null&&r===null&&(this.deletePending=!1,this.deleteError=null),this.render())}connectedCallback(){this.render(),this.screenManager.addEventListener("active-screen-changed",this.handleChange),this.serverManager.addEventListener("change",this.handleChange)}disconnectedCallback(){this.screenManager.removeEventListener("active-screen-changed",this.handleChange),this.serverManager.removeEventListener("change",this.handleChange)}emitClose(){this.dispatchEvent(new Event("close",{bubbles:!0}))}async handleDeleteScreen(){const n=this.screenManager.activeScreen;if(n){this.deletePending=!0,this.deleteError=null,this.render();try{await n.remove(),this.emitClose()}catch(r){this.deletePending=!1,this.deleteError=r instanceof Error?r.message:String(r),this.render()}}}render(){const n=this.screenManager.activeScreen,r=(n==null?void 0:n.server.url)??null,s=r!==null&&r!==this.serverManager.localServerURL;be(M`
|
|
389
|
-
<modal-overlay ?open=${this.open}>
|
|
390
|
-
<section class="screen-modal screen-delete-modal">
|
|
391
|
-
<div class="screen-form">
|
|
392
|
-
<h2 class="screen-modal-title">Delete screen</h2>
|
|
393
|
-
<p class="screen-delete-copy">
|
|
394
|
-
Delete <strong>${(n==null?void 0:n.name)??""}</strong>?
|
|
395
|
-
</p>
|
|
396
|
-
${s?M`<p class="screen-delete-warning">This will delete it for everyone.</p>`:null}
|
|
397
|
-
${this.deleteError?M`<p class="screen-delete-error">${this.deleteError}</p>`:null}
|
|
398
|
-
<div class="screen-form-actions">
|
|
399
|
-
<button
|
|
400
|
-
type="button"
|
|
401
|
-
class="settings-server-remove-button"
|
|
402
|
-
?disabled=${this.deletePending}
|
|
403
|
-
@click=${()=>void this.handleDeleteScreen()}
|
|
404
|
-
>
|
|
405
|
-
${this.deletePending?"Deleting...":"Delete"}
|
|
406
|
-
</button>
|
|
407
|
-
<button
|
|
408
|
-
type="button"
|
|
409
|
-
class="settings-cancel-button"
|
|
410
|
-
?disabled=${this.deletePending}
|
|
411
|
-
@click=${()=>this.emitClose()}
|
|
412
|
-
>
|
|
413
|
-
Cancel
|
|
414
|
-
</button>
|
|
415
|
-
</div>
|
|
416
|
-
</div>
|
|
417
|
-
</section>
|
|
418
|
-
</modal-overlay>
|
|
419
|
-
`,this)}}v(hv,"observedAttributes",["open"]);customElements.define("screen-delete-modal",hv);class dv extends HTMLElement{constructor(){super(...arguments);v(this,"serverManager",Ye.resolve("ServerManager"));v(this,"handleChange",()=>{this.render()});v(this,"addServerFormOpen",!1)}get open(){return this.hasAttribute("open")}attributeChangedCallback(n){n==="open"&&(this.open||(this.addServerFormOpen=!1),this.render())}connectedCallback(){this.render(),this.serverManager.addEventListener("change",this.handleChange)}disconnectedCallback(){this.serverManager.removeEventListener("change",this.handleChange)}emitClose(){this.dispatchEvent(new Event("close",{bubbles:!0}))}openAddServerForm(){this.addServerFormOpen=!0,this.render()}closeAddServerForm(){this.addServerFormOpen&&(this.addServerFormOpen=!1,this.render())}handleAddServer(n){n.preventDefault();const r=n.currentTarget,s=new FormData(r),i=String(s.get("name")??"").trim(),o=String(s.get("url")??"").trim();!i||!o||(this.serverManager.addServer(o,i),this.addServerFormOpen=!1,r.reset(),this.render())}render(){const n=[...this.serverManager.servers.values()];be(M`
|
|
420
|
-
<modal-overlay ?open=${this.open}>
|
|
421
|
-
<section class="settings-panel">
|
|
422
|
-
<panel-view closable @close=${r=>r instanceof Tm&&this.emitClose()}>
|
|
423
|
-
<panel-page id="main" title="Settings">
|
|
424
|
-
<div class="settings-section">
|
|
425
|
-
<h3 class="settings-section-title">Servers</h3>
|
|
426
|
-
<div class="settings-server-list">
|
|
427
|
-
${n.map(r=>M`
|
|
428
|
-
<div class="settings-card settings-server">
|
|
429
|
-
<div class="settings-server-details">
|
|
430
|
-
<div class="settings-server-name">${r.name}</div>
|
|
431
|
-
<div class="settings-server-url">${r.url}</div>
|
|
432
|
-
</div>
|
|
433
|
-
${r.url!==this.serverManager.localServerURL?M`
|
|
434
|
-
<button
|
|
435
|
-
type="button"
|
|
436
|
-
class="settings-server-remove-button"
|
|
437
|
-
aria-label=${`Remove ${r.name}`}
|
|
438
|
-
@click=${()=>this.serverManager.removeServer(r.url)}
|
|
439
|
-
>
|
|
440
|
-
Remove
|
|
441
|
-
</button>
|
|
442
|
-
`:null}
|
|
443
|
-
</div>
|
|
444
|
-
`)}
|
|
445
|
-
</div>
|
|
446
|
-
${this.addServerFormOpen?M`
|
|
447
|
-
<form class="settings-card settings-add-server-form" @submit=${r=>this.handleAddServer(r)}>
|
|
448
|
-
<label class="settings-field">
|
|
449
|
-
<span>Name</span>
|
|
450
|
-
<input type="text" name="name" required />
|
|
451
|
-
</label>
|
|
452
|
-
<label class="settings-field">
|
|
453
|
-
<span>URL</span>
|
|
454
|
-
<input type="url" name="url" required />
|
|
455
|
-
</label>
|
|
456
|
-
<div class="settings-form-actions">
|
|
457
|
-
<button type="submit" class="settings-submit-button">Connect</button>
|
|
458
|
-
<button
|
|
459
|
-
type="button"
|
|
460
|
-
class="settings-cancel-button"
|
|
461
|
-
data-action="cancel-connect-form"
|
|
462
|
-
@click=${()=>this.closeAddServerForm()}
|
|
463
|
-
>
|
|
464
|
-
Cancel
|
|
465
|
-
</button>
|
|
466
|
-
</div>
|
|
467
|
-
</form>
|
|
468
|
-
`:M`
|
|
469
|
-
<button
|
|
470
|
-
type="button"
|
|
471
|
-
class="settings-submit-button settings-connect-button"
|
|
472
|
-
data-action="show-connect-form"
|
|
473
|
-
@click=${()=>this.openAddServerForm()}
|
|
474
|
-
>
|
|
475
|
-
+ Connect to server
|
|
476
|
-
</button>
|
|
477
|
-
`}
|
|
478
|
-
</div>
|
|
479
|
-
</panel-page>
|
|
480
|
-
</panel-view>
|
|
481
|
-
</section>
|
|
482
|
-
</modal-overlay>
|
|
483
|
-
`,this)}}v(dv,"observedAttributes",["open"]);customElements.define("settings-modal",dv);class fv extends Event{constructor(n){super("auth-submit",{bubbles:!0,composed:!0});v(this,"token");this.token=n}}class pO extends HTMLElement{constructor(){super(...arguments);v(this,"_invalid",!1);v(this,"_tokenValue","")}set invalid(n){this._invalid=n,this.render()}get invalid(){return this._invalid}set tokenValue(n){this._tokenValue=n,this.render()}get tokenValue(){return this._tokenValue}connectedCallback(){this.render()}handleInput(n){const r=n.currentTarget;this._tokenValue=r.value}handleSubmit(n){n.preventDefault();const r=this._tokenValue.trim();r&&this.dispatchEvent(new fv(r))}render(){be(M`
|
|
484
|
-
<modal-overlay open>
|
|
485
|
-
<section class="auth-modal">
|
|
486
|
-
<form class="auth-form" @submit=${n=>this.handleSubmit(n)}>
|
|
487
|
-
<h2 class="auth-modal-title">Enter access token</h2>
|
|
488
|
-
<p class="auth-modal-copy">This Television server requires a token.</p>
|
|
489
|
-
<label class="settings-field">
|
|
490
|
-
<span>Token</span>
|
|
491
|
-
<input
|
|
492
|
-
class=${this.invalid?"auth-token-input-invalid":""}
|
|
493
|
-
type="password"
|
|
494
|
-
name="token"
|
|
495
|
-
.value=${this.tokenValue}
|
|
496
|
-
@input=${n=>this.handleInput(n)}
|
|
497
|
-
required
|
|
498
|
-
/>
|
|
499
|
-
</label>
|
|
500
|
-
<button type="submit" class="settings-submit-button">Connect</button>
|
|
501
|
-
</form>
|
|
502
|
-
</section>
|
|
503
|
-
</modal-overlay>
|
|
504
|
-
`,this)}}customElements.get("auth-modal")||customElements.define("auth-modal",pO);class gO extends HTMLElement{constructor(){super(...arguments);v(this,"runtimeServerURL",cm());v(this,"electronMode",hm());v(this,"serverManager",Ye.resolve("ServerManager"));v(this,"modals",{screenForm:{open:!1,mode:"edit"},deleteScreen:{open:!1},settings:{open:!1}});v(this,"connectError",null);v(this,"handleServerManagerChange",()=>{this.render()})}connectedCallback(){this.serverManager.addEventListener("change",this.handleServerManagerChange),this.addEventListener("auth-submit",n=>{var s;const r=n instanceof fv?n.token:n instanceof CustomEvent&&typeof((s=n.detail)==null?void 0:s.token)=="string"?n.detail.token:null;r&&this.handleAuthSubmit(r)}),this.initializeConnection(),this.render()}disconnectedCallback(){this.serverManager.removeEventListener("change",this.handleServerManagerChange)}async initializeConnection(){if(this.electronMode){this.serverManager.connectConfiguredServers(this.runtimeServerURL);return}if(this.serverManager.activeServer)return;const n=new wl({url:this.runtimeServerURL,name:"Server",token:um()});this.serverManager.add(n),this.serverManager.setActive(n);try{await n.connect(),this.connectError=null}catch(r){this.connectError=r instanceof Error&&!(r instanceof bl)?r.message:null}this.render()}async handleAuthSubmit(n){const r=this.serverManager.activeServer;if(r){this.connectError=null,r.token=n,this.updateTokenQueryParam(n);try{await r.connect()}catch(s){s instanceof bl||(this.connectError=s instanceof Error?s.message:String(s))}this.render()}}updateTokenQueryParam(n){const r=new URL(window.location.href);r.searchParams.set("token",n),window.history.replaceState({},"",`${r.pathname}${r.search}${r.hash}`)}render(){const n=this.serverManager.activeServer,r=(n==null?void 0:n.status)??null;if(r==="connecting"){be(M`
|
|
505
|
-
<main class="auth-gate"><p>Connecting...</p></main>
|
|
506
|
-
`,this);return}if(r==="disconnected"){const i=n;if(!i)return;be(M`
|
|
507
|
-
<main class="auth-gate">
|
|
508
|
-
<auth-modal
|
|
509
|
-
.invalid=${!!i.token}
|
|
510
|
-
.tokenValue=${i.token??""}
|
|
511
|
-
></auth-modal>
|
|
512
|
-
</main>
|
|
513
|
-
`,this);return}const s=M`
|
|
514
|
-
<header>
|
|
515
|
-
<nav>
|
|
516
|
-
<screen-picker
|
|
517
|
-
@edit-screen=${()=>{this.modals.screenForm={open:!0,mode:"edit"},this.render()}}
|
|
518
|
-
@create-screen=${i=>{this.modals.screenForm={open:!0,mode:"create",targetServerURL:i.serverURL},this.render()}}
|
|
519
|
-
@delete-screen=${()=>{this.modals.deleteScreen={open:!0},this.render()}}
|
|
520
|
-
></screen-picker>
|
|
521
|
-
</nav>
|
|
522
|
-
<button
|
|
523
|
-
type="button"
|
|
524
|
-
variant="toolbar"
|
|
525
|
-
size="sm"
|
|
526
|
-
aria-label="Settings"
|
|
527
|
-
@click=${()=>{this.modals.settings={open:!this.modals.settings.open},this.render()}}
|
|
528
|
-
>
|
|
529
|
-
${N1({size:16,weight:"bold"})}
|
|
530
|
-
</button>
|
|
531
|
-
</header>
|
|
532
|
-
<main>
|
|
533
|
-
${this.connectError?M`<p data-testid="auth-error">${this.connectError}</p>`:M`
|
|
534
|
-
<screen-view></screen-view>
|
|
535
|
-
${r==="connected"?M`<chat-panel></chat-panel>`:null}
|
|
536
|
-
`}
|
|
537
|
-
</main>
|
|
538
|
-
<screen-form-modal
|
|
539
|
-
?open=${this.modals.screenForm.open}
|
|
540
|
-
.mode=${this.modals.screenForm.mode}
|
|
541
|
-
.targetServerURL=${this.modals.screenForm.targetServerURL}
|
|
542
|
-
@close=${()=>{this.modals.screenForm={open:!1,mode:"edit"},this.render()}}
|
|
543
|
-
></screen-form-modal>
|
|
544
|
-
<screen-delete-modal
|
|
545
|
-
?open=${this.modals.deleteScreen.open}
|
|
546
|
-
@close=${()=>{this.modals.deleteScreen={open:!1},this.render()}}
|
|
547
|
-
></screen-delete-modal>
|
|
548
|
-
<settings-modal
|
|
549
|
-
?open=${this.modals.settings.open}
|
|
550
|
-
@close=${()=>{this.modals.settings={open:!1},this.render()}}
|
|
551
|
-
></settings-modal>
|
|
552
|
-
`;be(s,this)}}customElements.get("television-app")||customElements.define("television-app",gO);const Kc=hm(),ea=cm(),pv=new ZE(Kc?"television-electron":"television-browser",FE(ea)),gv=new DC({localStore:pv,localServerURL:ea}),mv=new ME({localStore:pv,serverManager:gv}),mO=new p1({serverURL:ea,token:um()??"",screenManager:mv});Ye.register("ServerManager",()=>gv);Ye.register("ScreenManager",()=>mv);Ye.register("ACPClientManager",()=>mO);const Jc=document.createElement("television-app");Jc.runtimeServerURL=ea;Jc.electronMode=Kc;Kc&&document.body.classList.add("electron");document.body.appendChild(Jc);
|