@telepath-computer/television 0.1.35 → 0.1.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.cjs +637 -632
- package/dist/{browser/assets/index-DCRTjgkN.js → web/assets/index-BJvMtRbp.js} +47 -47
- package/dist/{browser → web}/index.html +1 -1
- package/package.json +11 -71
- package/README.md +0 -75
- package/dist/electron.cjs +0 -46115
- /package/dist/{browser → web}/assets/Hind-Variable-C47b_dt9.woff2 +0 -0
- /package/dist/{browser → web}/assets/gradient-j-DX-EI0uV.jpg +0 -0
- /package/dist/{browser → web}/assets/index-CfQyq4ej.css +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
var Iv=Object.defineProperty;var Au=t=>{throw TypeError(t)};var Pv=(t,e,n)=>e in t?Iv(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var v=(t,e,n)=>Pv(t,typeof e!="symbol"?e+"":e,n),da=(t,e,n)=>e.has(t)||Au("Cannot "+n);var u=(t,e,n)=>(da(t,e,"read from private field"),n?n.call(t):e.get(t)),$=(t,e,n)=>e.has(t)?Au("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),x=(t,e,n,r)=>(da(t,e,"write to private field"),r?r.call(t,n):e.set(t,n),n),b=(t,e,n)=>(da(t,e,"access private method"),n);var xu=(t,e,n,r)=>({set _(s){x(t,e,s,n)},get _(){return u(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 Rv(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 Tu=Object.prototype.toString,pp=function(e){var n=Tu.call(e),r=n==="[object Arguments]";return r||(r=n!=="[object Array]"&&e!==null&&typeof e=="object"&&typeof e.length=="number"&&e.length>=0&&Tu.call(e.callee)==="[object Function]"),r},pa,Cu;function Dv(){if(Cu)return pa;Cu=1;var t;if(!Object.keys){var e=Object.prototype.hasOwnProperty,n=Object.prototype.toString,r=pp,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}(),p=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),G=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(G&&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 H=p(m),he=0;he<a.length;++he)!(H&&a[he]==="constructor")&&e.call(m,a[he])&&N.push(a[he]);return N}}return pa=t,pa}var Ov=Array.prototype.slice,zv=pp,Iu=Object.keys,Hi=Iu?function(e){return Iu(e)}:Dv(),Pu=Object.keys;Hi.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 zv(r)?Pu(Ov.call(r)):Pu(r)})}else Object.keys=Hi;return Object.keys||Hi};var Lv=Hi,qi=Object.defineProperty||!1;if(qi)try{qi({},"a",{value:1})}catch{qi=!1}var ai=qi,Ft=SyntaxError,V=TypeError,Mv=Object.getOwnPropertyDescriptor,Yi=Mv;if(Yi)try{Yi([],"length")}catch{Yi=null}var Ur=Yi,Ru=ai,Nv=Ft,ir=V,Du=Ur,fp=function(e,n,r){if(!e||typeof e!="object"&&typeof e!="function")throw new ir("`obj` must be an object or a function`");if(typeof n!="string"&&typeof n!="symbol")throw new ir("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new ir("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new ir("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new ir("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new ir("`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=!!Du&&Du(e,n);if(Ru)Ru(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 Nv("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},rl=ai,gp=function(){return!!rl};gp.hasArrayLengthDefineBug=function(){if(!rl)return null;try{return rl([],"length",{value:1}).length!==1}catch{return!0}};var Oo=gp,Uv=Lv,Fv=typeof Symbol=="function"&&typeof Symbol("foo")=="symbol",Zv=Object.prototype.toString,jv=Array.prototype.concat,Ou=fp,Wv=function(t){return typeof t=="function"&&Zv.call(t)==="[object Function]"},mp=Oo(),Bv=function(t,e,n,r){if(e in t){if(r===!0){if(t[e]===n)return}else if(!Wv(r)||!r())return}mp?Ou(t,e,n,!0):Ou(t,e,n)},vp=function(t,e){var n=arguments.length>2?arguments[2]:{},r=Uv(e);Fv&&(r=jv.call(r,Object.getOwnPropertySymbols(e)));for(var s=0;s<r.length;s+=1)Bv(t,r[s],e[r[s]],n[r[s]])};vp.supportsDescriptors=!!mp;var Yn=vp,Ki={exports:{}};typeof self<"u"?Ki.exports=self:typeof window<"u"?Ki.exports=window:Ki.exports=Function("return this")();var yp=Ki.exports,Gv=yp,bp=function(){return typeof Sn!="object"||!Sn||Sn.Math!==Math||Sn.Array!==Array?Gv:Sn},Vv=Yn,Hv=Ur,qv=bp,Yv=function(){var e=qv();if(Vv.supportsDescriptors){var n=Hv(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},Kv=Yn,Jv=yp,wp=bp,Xv=Yv,Qv=wp(),_p=function(){return Qv};Kv(_p,{getPolyfill:wp,implementation:Jv,shim:Xv});var ec=_p,Zt=function(e){return!!e&&(typeof e=="function"||typeof e=="object")},tc=Object,Sp=Error,ey=EvalError,ty=RangeError,nc=ReferenceError,ny=URIError,ry=Math.abs,sy=Math.floor,iy=Math.max,oy=Math.min,ay=Math.pow,ly=Math.round,rc=Number.isNaN||function(e){return e!==e},cy=rc,uy=function(e){return cy(e)||e===0?e:e<0?-1:1},Fr=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},zu=typeof Symbol<"u"&&Symbol,hy=Fr,sc=function(){return typeof zu!="function"||typeof Symbol!="function"||typeof zu("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:hy()},fa,Lu;function kp(){return Lu||(Lu=1,fa=typeof Reflect<"u"&&Reflect.getPrototypeOf||null),fa}var ga,Mu;function Ep(){if(Mu)return ga;Mu=1;var t=tc;return ga=t.getPrototypeOf||null,ga}var dy="Function.prototype.bind called on incompatible ",py=Object.prototype.toString,fy=Math.max,gy="[object Function]",Nu=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},my=function(e,n){for(var r=[],s=n,i=0;s<e.length;s+=1,i+=1)r[i]=e[s];return r},vy=function(t,e){for(var n="",r=0;r<t.length;r+=1)n+=t[r],r+1<t.length&&(n+=e);return n},yy=function(e){var n=this;if(typeof n!="function"||py.apply(n)!==gy)throw new TypeError(dy+n);for(var r=my(arguments,1),s,i=function(){if(this instanceof s){var d=n.apply(this,Nu(r,arguments));return Object(d)===d?d:this}return n.apply(e,Nu(r,arguments))},o=fy(0,n.length-r.length),a=[],l=0;l<o;l++)a[l]="$"+l;if(s=Function("binder","return function ("+vy(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},by=yy,li=Function.prototype.bind||by,ic=Function.prototype.call,oc=Function.prototype.apply,wy=typeof Reflect<"u"&&Reflect&&Reflect.apply,_y=li,Sy=oc,ky=ic,Ey=wy,$p=Ey||_y.call(ky,Sy),$y=li,Ay=V,xy=ic,Ty=$p,zo=function(e){if(e.length<1||typeof e[0]!="function")throw new Ay("a function is required");return Ty($y,xy,e)},Cy=zo,Uu=Ur,Ap;try{Ap=[].__proto__===Array.prototype}catch(t){if(!t||typeof t!="object"||!("code"in t)||t.code!=="ERR_PROTO_ACCESS")throw t}var ma=!!Ap&&Uu&&Uu(Object.prototype,"__proto__"),xp=Object,Fu=xp.getPrototypeOf,Iy=ma&&typeof ma.get=="function"?Cy([ma.get]):typeof Fu=="function"?function(e){return Fu(e==null?e:xp(e))}:!1,Zu=kp(),ju=Ep(),Wu=Iy,Tp=Zu?function(e){return Zu(e)}:ju?function(e){if(!e||typeof e!="object"&&typeof e!="function")throw new TypeError("getProto: not an object");return ju(e)}:Wu?function(e){return Wu(e)}:null,Py=Function.prototype.call,Ry=Object.prototype.hasOwnProperty,Dy=li,jt=Dy.call(Py,Ry),B,Oy=tc,zy=Sp,Ly=ey,My=ty,Ny=nc,Dr=Ft,wr=V,Uy=ny,Fy=ry,Zy=sy,jy=iy,Wy=oy,By=ay,Gy=ly,Vy=uy,Cp=Function,va=function(t){try{return Cp('"use strict"; return ('+t+").constructor;")()}catch{}},xs=Ur,Hy=ai,ya=function(){throw new wr},qy=xs?function(){try{return arguments.callee,ya}catch{try{return xs(arguments,"callee").get}catch{return ya}}}():ya,or=sc(),_e=Tp,Yy=Ep(),Ky=kp(),Ip=oc,ci=ic,cr={},Jy=typeof Uint8Array>"u"||!_e?B:_e(Uint8Array),Wn={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?B:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?B:ArrayBuffer,"%ArrayIteratorPrototype%":or&&_e?_e([][Symbol.iterator]()):B,"%AsyncFromSyncIteratorPrototype%":B,"%AsyncFunction%":cr,"%AsyncGenerator%":cr,"%AsyncGeneratorFunction%":cr,"%AsyncIteratorPrototype%":cr,"%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%":zy,"%eval%":eval,"%EvalError%":Ly,"%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%":Cp,"%GeneratorFunction%":cr,"%Int8Array%":typeof Int8Array>"u"?B:Int8Array,"%Int16Array%":typeof Int16Array>"u"?B:Int16Array,"%Int32Array%":typeof Int32Array>"u"?B:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":or&&_e?_e(_e([][Symbol.iterator]())):B,"%JSON%":typeof JSON=="object"?JSON:B,"%Map%":typeof Map>"u"?B:Map,"%MapIteratorPrototype%":typeof Map>"u"||!or||!_e?B:_e(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Oy,"%Object.getOwnPropertyDescriptor%":xs,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?B:Promise,"%Proxy%":typeof Proxy>"u"?B:Proxy,"%RangeError%":My,"%ReferenceError%":Ny,"%Reflect%":typeof Reflect>"u"?B:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?B:Set,"%SetIteratorPrototype%":typeof Set>"u"||!or||!_e?B:_e(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?B:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":or&&_e?_e(""[Symbol.iterator]()):B,"%Symbol%":or?Symbol:B,"%SyntaxError%":Dr,"%ThrowTypeError%":qy,"%TypedArray%":Jy,"%TypeError%":wr,"%Uint8Array%":typeof Uint8Array>"u"?B:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?B:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?B:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?B:Uint32Array,"%URIError%":Uy,"%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%":Ip,"%Object.defineProperty%":Hy,"%Object.getPrototypeOf%":Yy,"%Math.abs%":Fy,"%Math.floor%":Zy,"%Math.max%":jy,"%Math.min%":Wy,"%Math.pow%":By,"%Math.round%":Gy,"%Math.sign%":Vy,"%Reflect.getPrototypeOf%":Ky};if(_e)try{null.error}catch(t){var Xy=_e(_e(t));Wn["%Error.prototype%"]=Xy}var Qy=function t(e){var n;if(e==="%AsyncFunction%")n=va("async function () {}");else if(e==="%GeneratorFunction%")n=va("function* () {}");else if(e==="%AsyncGeneratorFunction%")n=va("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 Wn[e]=n,n},Bu={__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,ao=jt,eb=ui.call(ci,Array.prototype.concat),tb=ui.call(Ip,Array.prototype.splice),Gu=ui.call(ci,String.prototype.replace),lo=ui.call(ci,String.prototype.slice),nb=ui.call(ci,RegExp.prototype.exec),rb=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,sb=/\\(\\)?/g,ib=function(e){var n=lo(e,0,1),r=lo(e,-1);if(n==="%"&&r!=="%")throw new Dr("invalid intrinsic syntax, expected closing `%`");if(r==="%"&&n!=="%")throw new Dr("invalid intrinsic syntax, expected opening `%`");var s=[];return Gu(e,rb,function(i,o,a,l){s[s.length]=a?Gu(l,sb,"$1"):o||i}),s},ob=function(e,n){var r=e,s;if(ao(Bu,r)&&(s=Bu[r],r="%"+s[0]+"%"),ao(Wn,r)){var i=Wn[r];if(i===cr&&(i=Qy(r)),typeof i>"u"&&!n)throw new wr("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:s,name:r,value:i}}throw new Dr("intrinsic "+e+" does not exist!")},Qe=function(e,n){if(typeof e!="string"||e.length===0)throw new wr("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof n!="boolean")throw new wr('"allowMissing" argument must be a boolean');if(nb(/^%?[^%]*%?$/,e)===null)throw new Dr("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var r=ib(e),s=r.length>0?r[0]:"",i=ob("%"+s+"%",n),o=i.name,a=i.value,l=!1,c=i.alias;c&&(s=c[0],tb(r,eb([0,1],c)));for(var d=1,p=!0;d<r.length;d+=1){var y=r[d],m=lo(y,0,1),E=lo(y,-1);if((m==='"'||m==="'"||m==="`"||E==='"'||E==="'"||E==="`")&&m!==E)throw new Dr("property names with quotes must have matching quotes");if((y==="constructor"||!p)&&(l=!0),s+="."+y,o="%"+s+"%",ao(Wn,o))a=Wn[o];else if(a!=null){if(!(y in a)){if(!n)throw new wr("base intrinsic for "+e+" exists, but the property is not available.");return}if(xs&&d+1>=r.length){var k=xs(a,y);p=!!k,p&&"get"in k&&!("originalValue"in k.get)?a=k.get:a=a[y]}else p=ao(a,y),a=a[y];p&&!l&&(Wn[o]=a)}}return a},ba,Vu;function hn(){if(Vu)return ba;Vu=1;var t=Qe,e=zo,n=e([t("%String.prototype.indexOf%")]);return ba=function(s,i){var o=t(s,!!i);return typeof o=="function"&&n(s,".prototype.")>-1?e([o]):o},ba}var wa,Hu;function ac(){if(Hu)return wa;Hu=1;var t=Qe,e=t("%Array%"),n=!e.isArray&&hn()("Object.prototype.toString");return wa=e.isArray||function(s){return n(s)==="[object Array]"},wa}var ab=Oo,qu=ai,Pp=ab.hasArrayLengthDefineBug(),lb=Pp&&ac(),cb=hn(),ub=cb("Object.prototype.propertyIsEnumerable"),lc=function(e,n,r,s,i,o){if(!qu){if(!e(o)||!o["[[Configurable]]"]||!o["[[Writable]]"]||i in s&&ub(s,i)!==!!o["[[Enumerable]]"])return!1;var a=o["[[Value]]"];return s[i]=a,n(s[i],a)}return Pp&&i==="length"&&"[[Value]]"in o&&lb(s)&&s.length!==o["[[Value]]"]?(s.length=o["[[Value]]"],s.length===o["[[Value]]"]):(qu(s,i,r(o)),!0)},hb=V,ts=jt,db={__proto__:null,"[[Configurable]]":!0,"[[Enumerable]]":!0,"[[Get]]":!0,"[[Set]]":!0,"[[Value]]":!0,"[[Writable]]":!0},Zr=function(e){if(!e||typeof e!="object")return!1;for(var n in e)if(ts(e,n)&&!db[n])return!1;var r=ts(e,"[[Value]]")||ts(e,"[[Writable]]"),s=ts(e,"[[Get]]")||ts(e,"[[Set]]");if(r&&s)throw new hb("Property Descriptors may not be both accessor and data descriptors");return!0},Rp=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},pb=V,fb=Zr,gb=Rp,Dp=function(e){if(typeof e<"u"&&!fb(e))throw new pb("Assertion failed: `Desc` must be a Property Descriptor");return gb(e)},mb=V,Yu=jt,vb=Zr,Op=function(e){if(typeof e>"u")return!1;if(!vb(e))throw new mb("Assertion failed: `Desc` must be a Property Descriptor");return!(!Yu(e,"[[Value]]")&&!Yu(e,"[[Writable]]"))},jr=function(e){return typeof e=="string"||typeof e=="symbol"},Ku=rc,zp=function(e,n){return e===n?e===0?1/e===1/n:!0:Ku(e)&&Ku(n)},Ju=V,yb=Zt,bb=lc,wb=Dp,_b=Op,Sb=jr,kb=zp,cc=function(e,n,r){if(!yb(e))throw new Ju("Assertion failed: Type(O) is not Object");if(!Sb(n))throw new Ju("Assertion failed: P is not a Property Key");var s={"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Value]]":r,"[[Writable]]":!0};return bb(_b,kb,wb,e,n,s)},Lp=Function.prototype.toString,mr=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,sl,Ji;if(typeof mr=="function"&&typeof Object.defineProperty=="function")try{sl=Object.defineProperty({},"length",{get:function(){throw Ji}}),Ji={},mr(function(){throw 42},null,sl)}catch(t){t!==Ji&&(mr=null)}else mr=null;var Eb=/^\s*class\b/,il=function(e){try{var n=Lp.call(e);return Eb.test(n)}catch{return!1}},_a=function(e){try{return il(e)?!1:(Lp.call(e),!0)}catch{return!1}},Xi=Object.prototype.toString,$b="[object Object]",Ab="[object Function]",xb="[object GeneratorFunction]",Tb="[object HTMLAllCollection]",Cb="[object HTML document.all class]",Ib="[object HTMLCollection]",Pb=typeof Symbol=="function"&&!!Symbol.toStringTag,Rb=!(0 in[,]),ol=function(){return!1};if(typeof document=="object"){var Db=document.all;Xi.call(Db)===Xi.call(document.all)&&(ol=function(e){if((Rb||!e)&&(typeof e>"u"||typeof e=="object"))try{var n=Xi.call(e);return(n===Tb||n===Cb||n===Ib||n===$b)&&e("")==null}catch{}return!1})}var Mp=mr?function(e){if(ol(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;try{mr(e,null,sl)}catch(n){if(n!==Ji)return!1}return!il(e)&&_a(e)}:function(e){if(ol(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;if(Pb)return _a(e);if(il(e))return!1;var n=Xi.call(e);return n!==Ab&&n!==xb&&!/^\[object HTML/.test(n)?!1:_a(e)},Ob=Mp,zb=function(e){return!!e},dt=jt,Ii=V,Lb=Zt,Xu=Ob,Sa=zb,Mb=function(e){if(!Lb(e))throw new Ii("ToPropertyDescriptor requires an object");var n={};if(dt(e,"enumerable")&&(n["[[Enumerable]]"]=Sa(e.enumerable)),dt(e,"configurable")&&(n["[[Configurable]]"]=Sa(e.configurable)),dt(e,"value")&&(n["[[Value]]"]=e.value),dt(e,"writable")&&(n["[[Writable]]"]=Sa(e.writable)),dt(e,"get")){var r=e.get;if(typeof r<"u"&&!Xu(r))throw new Ii("getter must be a function");n["[[Get]]"]=r}if(dt(e,"set")){var s=e.set;if(typeof s<"u"&&!Xu(s))throw new Ii("setter must be a function");n["[[Set]]"]=s}if((dt(n,"[[Get]]")||dt(n,"[[Set]]"))&&(dt(n,"[[Value]]")||dt(n,"[[Writable]]")))throw new Ii("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute");return n},ka=V,Nb=Zt,Qu=Zr,Ub=lc,Fb=Dp,Zb=Op,jb=jr,Wb=zp,Bb=Mb,Gb=function(e,n,r){if(!Nb(e))throw new ka("Assertion failed: Type(O) is not Object");if(!jb(n))throw new ka("Assertion failed: P is not a Property Key");var s=Qu(r)?r:Bb(r);if(!Qu(s))throw new ka("Assertion failed: Desc is not a valid Property Descriptor");return Ub(Zb,Wb,Fb,e,n,s)},eh=V,Vb=Zt,Hb=Gb,qb=jr,Yb=function(e,n,r){if(!Vb(e))throw new eh("Assertion failed: Type(O) is not Object");if(!qb(n))throw new eh("Assertion failed: P is not a Property Key");var s={"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Value]]":r,"[[Writable]]":!0};return Hb(e,n,s)},Kb=typeof Reflect<"u"&&Reflect.setPrototypeOf||null,Jb=tc,Xb=Jb.setPrototypeOf||null,Qb=zo,th=Ur,ew=V,Np={};try{Np.__proto__=null}catch(t){if(!t||typeof t!="object"||!("code"in t)||t.code!=="ERR_PROTO_ACCESS")throw t}var tw=!("toString"in Np),Ea=th&&th(Object.prototype,"__proto__"),nw=tw&&(!!Ea&&typeof Ea.set=="function"&&Qb([Ea.set])||function(e,n){if(e==null)throw new ew("set Object.prototype.__proto__ called on null or undefined");return e.__proto__=n,n}),nh=Kb,rw=Xb,rh=nw,sw=V,iw=nh?function(e,n){if(nh(e,n))return e;throw new sw("Reflect.setPrototypeOf: failed to set [[Prototype]]")}:rw||(rh?function(e,n){return rh(e,n),e}:null),sh=V,ow=Zt,ih=Tp,aw=function(e){if(!ow(e))throw new sh("Assertion failed: O must be an Object");if(!ih)throw new sh("This environment does not support fetching prototypes.");return ih(e)},lw=V,cw=iw,uw=Zt,hw=aw,dw=function(e,n){if(n!==null&&!uw(n))throw new lw("Assertion failed: V must be Object or Null");try{cw(e,n)}catch{return!1}return hw(e)===n},$a=cc,oh=Yb,Up=dw,pw=Oo(),uc=Sp;function hi(t,e,n){var r=new uc(n);return Up(r,Qi),delete r.constructor,oh(r,"error",t),oh(r,"suppressed",e),r}pw&&Object.defineProperty(hi,"prototype",{writable:!1});var Qi=hi.prototype;if(!$a(Qi,"constructor",hi)||!$a(Qi,"message","")||!$a(Qi,"name","SuppressedError"))throw new uc("unable to install SuppressedError.prototype properties; please report this!");Up(hi.prototype,uc.prototype);var fw=hi,gw=fw,Fp=function(){return typeof SuppressedError=="function"?SuppressedError:gw},mw=Yn,ah=ec(),vw=Fp,yw=function(){var e=vw();return mw(ah,{SuppressedError:e},{SuppressedError:function(){return ah.SuppressedError!==e}}),e};yw();var bw=V,ww=Zr,_w=Rp,Sw=function(e){if(typeof e<"u"&&!ww(e))throw new bw("Assertion failed: `Desc` must be a Property Descriptor");return _w(e)},kw=V,lh=jt,Ew=Zr,$w=function(e){if(typeof e>"u")return!1;if(!Ew(e))throw new kw("Assertion failed: `Desc` must be a Property Descriptor");return!(!lh(e,"[[Value]]")&&!lh(e,"[[Writable]]"))},ch=rc,Aw=function(e,n){return e===n?e===0?1/e===1/n:!0:ch(e)&&ch(n)},Wr=Mp,xw=function(e){return!!e},pt=jt,Pi=V,Tw=Zt,uh=Wr,Aa=xw,Cw=function(e){if(!Tw(e))throw new Pi("ToPropertyDescriptor requires an object");var n={};if(pt(e,"enumerable")&&(n["[[Enumerable]]"]=Aa(e.enumerable)),pt(e,"configurable")&&(n["[[Configurable]]"]=Aa(e.configurable)),pt(e,"value")&&(n["[[Value]]"]=e.value),pt(e,"writable")&&(n["[[Writable]]"]=Aa(e.writable)),pt(e,"get")){var r=e.get;if(typeof r<"u"&&!uh(r))throw new Pi("getter must be a function");n["[[Get]]"]=r}if(pt(e,"set")){var s=e.set;if(typeof s<"u"&&!uh(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},xa=V,Iw=Zt,hh=Zr,Pw=lc,Rw=Sw,Dw=$w,Ow=jr,zw=Aw,Lw=Cw,di=function(e,n,r){if(!Iw(e))throw new xa("Assertion failed: Type(O) is not Object");if(!Ow(n))throw new xa("Assertion failed: P is not a Property Key");var s=hh(r)?r:Lw(r);if(!hh(s))throw new xa("Assertion failed: Desc is not a valid Property Descriptor");return Pw(Dw,zw,Rw,e,n,s)},Mw=Fr(),Nw=Mw?Symbol.dispose||Symbol("Symbol.dispose"):null,Uw=Fr,Fw=Nw,hc=function(){return Uw()&&Symbol.dispose||Fw},Zw=sc,jw=di,Ww=hc,Bw=function(){var e=Ww();return Zw()&&jw(Symbol,"dispose",{"[[Configurable]]":!1,"[[Enumerable]]":!1,"[[Writable]]":!1,"[[Value]]":e}),e},Gw=Fr(),Vw=Gw?Symbol.asyncDispose||Symbol("Symbol.asyncDispose"):null,Hw=Fr,qw=Vw,dc=function(){return Hw()&&Symbol.asyncDispose||qw},Yw=sc,Kw=di,Jw=dc,Xw=function(){var e=Jw();return Yw()&&Kw(Symbol,"asyncDispose",{"[[Configurable]]":!1,"[[Enumerable]]":!1,"[[Writable]]":!1,"[[Value]]":e}),e},Qw=ac(),e_=Qe,t_=hn(),n_=V,r_=Qw,s_=e_("%Reflect.apply%",!0)||t_("Function.prototype.apply"),Lo=function(e,n){var r=arguments.length>2?arguments[2]:[];if(!r_(r))throw new n_("Assertion failed: optional `argumentsList`, if provided, must be a List");return s_(e,n,r)};const i_={},o_=Object.freeze(Object.defineProperty({__proto__:null,default:i_},Symbol.toStringTag,{value:"Module"})),a_=Rv(o_);var pc=typeof Map=="function"&&Map.prototype,Ta=Object.getOwnPropertyDescriptor&&pc?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,co=pc&&Ta&&typeof Ta.get=="function"?Ta.get:null,dh=pc&&Map.prototype.forEach,fc=typeof Set=="function"&&Set.prototype,Ca=Object.getOwnPropertyDescriptor&&fc?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,uo=fc&&Ca&&typeof Ca.get=="function"?Ca.get:null,ph=fc&&Set.prototype.forEach,l_=typeof WeakMap=="function"&&WeakMap.prototype,Ss=l_?WeakMap.prototype.has:null,c_=typeof WeakSet=="function"&&WeakSet.prototype,ks=c_?WeakSet.prototype.has:null,u_=typeof WeakRef=="function"&&WeakRef.prototype,fh=u_?WeakRef.prototype.deref:null,h_=Boolean.prototype.valueOf,d_=Object.prototype.toString,p_=Function.prototype.toString,f_=String.prototype.match,gc=String.prototype.slice,en=String.prototype.replace,g_=String.prototype.toUpperCase,gh=String.prototype.toLowerCase,Zp=RegExp.prototype.test,mh=Array.prototype.concat,_t=Array.prototype.join,m_=Array.prototype.slice,vh=Math.floor,al=typeof BigInt=="function"?BigInt.prototype.valueOf:null,Ia=Object.getOwnPropertySymbols,ll=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,Or=typeof Symbol=="function"&&typeof Symbol.iterator=="object",Es=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===Or||!0)?Symbol.toStringTag:null,jp=Object.prototype.propertyIsEnumerable,yh=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(t){return t.__proto__}:null);function bh(t,e){if(t===1/0||t===-1/0||t!==t||t&&t>-1e3&&t<1e3||Zp.call(/e/,e))return e;var n=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof t=="number"){var r=t<0?-vh(-t):vh(t);if(r!==t){var s=String(r),i=gc.call(e,s.length+1);return en.call(s,n,"$&_")+"."+en.call(en.call(i,/([0-9]{3})/g,"$&_"),/_$/,"")}}return en.call(e,n,"$&_")}var cl=a_,wh=cl.custom,_h=Gp(wh)?wh:null,Wp={__proto__:null,double:'"',single:"'"},v_={__proto__:null,double:/(["\\])/g,single:/(['\\])/g},Br=function t(e,n,r,s){var i=n||{};if(It(i,"quoteStyle")&&!It(Wp,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 Hp(e,i);if(typeof e=="number"){if(e===0)return 1/0/e>0?"0":"-0";var l=String(e);return a?bh(e,l):l}if(typeof e=="bigint"){var c=String(e)+"n";return a?bh(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 ul(e)?"[Array]":"[Object]";var p=z_(i,r);if(typeof s>"u")s=[];else if(Vp(s,e)>=0)return"[Circular]";function y(ct,Wt,ea){if(Wt&&(s=m_.call(s),s.push(Wt)),ea){var _i={depth:i.depth};return It(i,"quoteStyle")&&(_i.quoteStyle=i.quoteStyle),t(ct,_i,r+1,s)}return t(ct,i,r+1,s)}if(typeof e=="function"&&!Sh(e)){var m=A_(e),E=Ri(e,y);return"[Function"+(m?": "+m:" (anonymous)")+"]"+(E.length>0?" { "+_t.call(E,", ")+" }":"")}if(Gp(e)){var k=Or?en.call(String(e),/^(Symbol\(.*\))_[^)]*$/,"$1"):ll.call(e);return typeof e=="object"&&!Or?ns(k):k}if(R_(e)){for(var I="<"+gh.call(String(e.nodeName)),G=e.attributes||[],N=0;N<G.length;N++)I+=" "+G[N].name+"="+Bp(y_(G[N].value),"double",i);return I+=">",e.childNodes&&e.childNodes.length&&(I+="..."),I+="</"+gh.call(String(e.nodeName))+">",I}if(ul(e)){if(e.length===0)return"[]";var j=Ri(e,y);return p&&!O_(j)?"["+hl(j,p)+"]":"[ "+_t.call(j,", ")+" ]"}if(w_(e)){var F=Ri(e,y);return!("cause"in Error.prototype)&&"cause"in e&&!jp.call(e,"cause")?"{ ["+String(e)+"] "+_t.call(mh.call("[cause]: "+y(e.cause),F),", ")+" }":F.length===0?"["+String(e)+"]":"{ ["+String(e)+"] "+_t.call(F,", ")+" }"}if(typeof e=="object"&&o){if(_h&&typeof e[_h]=="function"&&cl)return cl(e,{depth:d-r});if(o!=="symbol"&&typeof e.inspect=="function")return e.inspect()}if(x_(e)){var L=[];return dh&&dh.call(e,function(ct,Wt){L.push(y(Wt,e,!0)+" => "+y(ct,e))}),kh("Map",co.call(e),L,p)}if(I_(e)){var J=[];return ph&&ph.call(e,function(ct){J.push(y(ct,e))}),kh("Set",uo.call(e),J,p)}if(T_(e))return Pa("WeakMap");if(P_(e))return Pa("WeakSet");if(C_(e))return Pa("WeakRef");if(S_(e))return ns(y(Number(e)));if(E_(e))return ns(y(al.call(e)));if(k_(e))return ns(h_.call(e));if(__(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(!b_(e)&&!Sh(e)){var H=Ri(e,y),he=yh?yh(e)===Object.prototype:e instanceof Object||e.constructor===Object,lt=e instanceof Object?"":"null prototype",wi=!he&&Es&&Object(e)===e&&Es in e?gc.call(dn(e),8,-1):lt?"Object":"",Ee=he||typeof e.constructor!="function"?"":e.constructor.name?e.constructor.name+" ":"",gn=Ee+(wi||lt?"["+_t.call(mh.call([],wi||[],lt||[]),": ")+"] ":"");return H.length===0?gn+"{}":p?gn+"{"+hl(H,p)+"}":gn+"{ "+_t.call(H,", ")+" }"}return String(e)};function Bp(t,e,n){var r=n.quoteStyle||e,s=Wp[r];return s+t+s}function y_(t){return en.call(String(t),/"/g,""")}function Kn(t){return!Es||!(typeof t=="object"&&(Es in t||typeof t[Es]<"u"))}function ul(t){return dn(t)==="[object Array]"&&Kn(t)}function b_(t){return dn(t)==="[object Date]"&&Kn(t)}function Sh(t){return dn(t)==="[object RegExp]"&&Kn(t)}function w_(t){return dn(t)==="[object Error]"&&Kn(t)}function __(t){return dn(t)==="[object String]"&&Kn(t)}function S_(t){return dn(t)==="[object Number]"&&Kn(t)}function k_(t){return dn(t)==="[object Boolean]"&&Kn(t)}function Gp(t){if(Or)return t&&typeof t=="object"&&t instanceof Symbol;if(typeof t=="symbol")return!0;if(!t||typeof t!="object"||!ll)return!1;try{return ll.call(t),!0}catch{}return!1}function E_(t){if(!t||typeof t!="object"||!al)return!1;try{return al.call(t),!0}catch{}return!1}var $_=Object.prototype.hasOwnProperty||function(t){return t in this};function It(t,e){return $_.call(t,e)}function dn(t){return d_.call(t)}function A_(t){if(t.name)return t.name;var e=f_.call(p_.call(t),/^function\s*([\w$]+)/);return e?e[1]:null}function Vp(t,e){if(t.indexOf)return t.indexOf(e);for(var n=0,r=t.length;n<r;n++)if(t[n]===e)return n;return-1}function x_(t){if(!co||!t||typeof t!="object")return!1;try{co.call(t);try{uo.call(t)}catch{return!0}return t instanceof Map}catch{}return!1}function T_(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 C_(t){if(!fh||!t||typeof t!="object")return!1;try{return fh.call(t),!0}catch{}return!1}function I_(t){if(!uo||!t||typeof t!="object")return!1;try{uo.call(t);try{co.call(t)}catch{return!0}return t instanceof Set}catch{}return!1}function P_(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 R_(t){return!t||typeof t!="object"?!1:typeof HTMLElement<"u"&&t instanceof HTMLElement?!0:typeof t.nodeName=="string"&&typeof t.getAttribute=="function"}function Hp(t,e){if(t.length>e.maxStringLength){var n=t.length-e.maxStringLength,r="... "+n+" more character"+(n>1?"s":"");return Hp(gc.call(t,0,e.maxStringLength),e)+r}var s=v_[e.quoteStyle||"single"];s.lastIndex=0;var i=en.call(en.call(t,s,"\\$1"),/[\x00-\x1f]/g,D_);return Bp(i,"single",e)}function D_(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":"")+g_.call(e.toString(16))}function ns(t){return"Object("+t+")"}function Pa(t){return t+" { ? }"}function kh(t,e,n,r){var s=r?hl(n,r):_t.call(n,", ");return t+" ("+e+") {"+s+"}"}function O_(t){for(var e=0;e<t.length;e++)if(Vp(t[e],`
|
|
2
|
-
`)>=0)return!1;return!0}function
|
|
1
|
+
var Av=Object.defineProperty;var Au=t=>{throw TypeError(t)};var xv=(t,e,n)=>e in t?Av(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var v=(t,e,n)=>xv(t,typeof e!="symbol"?e+"":e,n),da=(t,e,n)=>e.has(t)||Au("Cannot "+n);var u=(t,e,n)=>(da(t,e,"read from private field"),n?n.call(t):e.get(t)),$=(t,e,n)=>e.has(t)?Au("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),x=(t,e,n,r)=>(da(t,e,"write to private field"),r?r.call(t,n):e.set(t,n),n),b=(t,e,n)=>(da(t,e,"access private method"),n);var xu=(t,e,n,r)=>({set _(s){x(t,e,s,n)},get _(){return u(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 Tu=Object.prototype.toString,cp=function(e){var n=Tu.call(e),r=n==="[object Arguments]";return r||(r=n!=="[object Array]"&&e!==null&&typeof e=="object"&&typeof e.length=="number"&&e.length>=0&&Tu.call(e.callee)==="[object Function]"),r},pa,Cu;function Cv(){if(Cu)return pa;Cu=1;var t;if(!Object.keys){var e=Object.prototype.hasOwnProperty,n=Object.prototype.toString,r=cp,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}(),p=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),G=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(G&&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 H=p(m),he=0;he<a.length;++he)!(H&&a[he]==="constructor")&&e.call(m,a[he])&&N.push(a[he]);return N}}return pa=t,pa}var Iv=Array.prototype.slice,Pv=cp,Iu=Object.keys,Hi=Iu?function(e){return Iu(e)}:Cv(),Pu=Object.keys;Hi.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 Pv(r)?Pu(Iv.call(r)):Pu(r)})}else Object.keys=Hi;return Object.keys||Hi};var Rv=Hi,qi=Object.defineProperty||!1;if(qi)try{qi({},"a",{value:1})}catch{qi=!1}var ai=qi,Ft=SyntaxError,V=TypeError,Dv=Object.getOwnPropertyDescriptor,Yi=Dv;if(Yi)try{Yi([],"length")}catch{Yi=null}var Ur=Yi,Ru=ai,Ov=Ft,ir=V,Du=Ur,up=function(e,n,r){if(!e||typeof e!="object"&&typeof e!="function")throw new ir("`obj` must be an object or a function`");if(typeof n!="string"&&typeof n!="symbol")throw new ir("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new ir("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new ir("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new ir("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new ir("`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=!!Du&&Du(e,n);if(Ru)Ru(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 Ov("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},rl=ai,hp=function(){return!!rl};hp.hasArrayLengthDefineBug=function(){if(!rl)return null;try{return rl([],"length",{value:1}).length!==1}catch{return!0}};var Oo=hp,zv=Rv,Lv=typeof Symbol=="function"&&typeof Symbol("foo")=="symbol",Mv=Object.prototype.toString,Nv=Array.prototype.concat,Ou=up,Uv=function(t){return typeof t=="function"&&Mv.call(t)==="[object Function]"},dp=Oo(),Fv=function(t,e,n,r){if(e in t){if(r===!0){if(t[e]===n)return}else if(!Uv(r)||!r())return}dp?Ou(t,e,n,!0):Ou(t,e,n)},pp=function(t,e){var n=arguments.length>2?arguments[2]:{},r=zv(e);Lv&&(r=Nv.call(r,Object.getOwnPropertySymbols(e)));for(var s=0;s<r.length;s+=1)Fv(t,r[s],e[r[s]],n[r[s]])};pp.supportsDescriptors=!!dp;var Yn=pp,Ki={exports:{}};typeof self<"u"?Ki.exports=self:typeof window<"u"?Ki.exports=window:Ki.exports=Function("return this")();var fp=Ki.exports,Zv=fp,gp=function(){return typeof Sn!="object"||!Sn||Sn.Math!==Math||Sn.Array!==Array?Zv:Sn},jv=Yn,Wv=Ur,Bv=gp,Gv=function(){var e=Bv();if(jv.supportsDescriptors){var n=Wv(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},Vv=Yn,Hv=fp,mp=gp,qv=Gv,Yv=mp(),vp=function(){return Yv};Vv(vp,{getPolyfill:mp,implementation:Hv,shim:qv});var ec=vp,Zt=function(e){return!!e&&(typeof e=="function"||typeof e=="object")},tc=Object,yp=Error,Kv=EvalError,Jv=RangeError,nc=ReferenceError,Xv=URIError,Qv=Math.abs,ey=Math.floor,ty=Math.max,ny=Math.min,ry=Math.pow,sy=Math.round,rc=Number.isNaN||function(e){return e!==e},iy=rc,oy=function(e){return iy(e)||e===0?e:e<0?-1:1},Fr=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},zu=typeof Symbol<"u"&&Symbol,ay=Fr,sc=function(){return typeof zu!="function"||typeof Symbol!="function"||typeof zu("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:ay()},fa,Lu;function bp(){return Lu||(Lu=1,fa=typeof Reflect<"u"&&Reflect.getPrototypeOf||null),fa}var ga,Mu;function wp(){if(Mu)return ga;Mu=1;var t=tc;return ga=t.getPrototypeOf||null,ga}var ly="Function.prototype.bind called on incompatible ",cy=Object.prototype.toString,uy=Math.max,hy="[object Function]",Nu=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},dy=function(e,n){for(var r=[],s=n,i=0;s<e.length;s+=1,i+=1)r[i]=e[s];return r},py=function(t,e){for(var n="",r=0;r<t.length;r+=1)n+=t[r],r+1<t.length&&(n+=e);return n},fy=function(e){var n=this;if(typeof n!="function"||cy.apply(n)!==hy)throw new TypeError(ly+n);for(var r=dy(arguments,1),s,i=function(){if(this instanceof s){var d=n.apply(this,Nu(r,arguments));return Object(d)===d?d:this}return n.apply(e,Nu(r,arguments))},o=uy(0,n.length-r.length),a=[],l=0;l<o;l++)a[l]="$"+l;if(s=Function("binder","return function ("+py(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},gy=fy,li=Function.prototype.bind||gy,ic=Function.prototype.call,oc=Function.prototype.apply,my=typeof Reflect<"u"&&Reflect&&Reflect.apply,vy=li,yy=oc,by=ic,wy=my,_p=wy||vy.call(by,yy),_y=li,Sy=V,ky=ic,Ey=_p,zo=function(e){if(e.length<1||typeof e[0]!="function")throw new Sy("a function is required");return Ey(_y,ky,e)},ma,Uu;function $y(){if(Uu)return ma;Uu=1;var t=zo,e=Ur,n;try{n=[].__proto__===Array.prototype}catch(o){if(!o||typeof o!="object"||!("code"in o)||o.code!=="ERR_PROTO_ACCESS")throw o}var r=!!n&&e&&e(Object.prototype,"__proto__"),s=Object,i=s.getPrototypeOf;return ma=r&&typeof r.get=="function"?t([r.get]):typeof i=="function"?function(a){return i(a==null?a:s(a))}:!1,ma}var va,Fu;function Sp(){if(Fu)return va;Fu=1;var t=bp(),e=wp(),n=$y();return va=t?function(s){return t(s)}:e?function(s){if(!s||typeof s!="object"&&typeof s!="function")throw new TypeError("getProto: not an object");return e(s)}:n?function(s){return n(s)}:null,va}var Ay=Function.prototype.call,xy=Object.prototype.hasOwnProperty,Ty=li,jt=Ty.call(Ay,xy),B,Cy=tc,Iy=yp,Py=Kv,Ry=Jv,Dy=nc,Dr=Ft,wr=V,Oy=Xv,zy=Qv,Ly=ey,My=ty,Ny=ny,Uy=ry,Fy=sy,Zy=oy,kp=Function,ya=function(t){try{return kp('"use strict"; return ('+t+").constructor;")()}catch{}},xs=Ur,jy=ai,ba=function(){throw new wr},Wy=xs?function(){try{return arguments.callee,ba}catch{try{return xs(arguments,"callee").get}catch{return ba}}}():ba,or=sc(),_e=Sp(),By=wp(),Gy=bp(),Ep=oc,ci=ic,cr={},Vy=typeof Uint8Array>"u"||!_e?B:_e(Uint8Array),Wn={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?B:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?B:ArrayBuffer,"%ArrayIteratorPrototype%":or&&_e?_e([][Symbol.iterator]()):B,"%AsyncFromSyncIteratorPrototype%":B,"%AsyncFunction%":cr,"%AsyncGenerator%":cr,"%AsyncGeneratorFunction%":cr,"%AsyncIteratorPrototype%":cr,"%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%":Iy,"%eval%":eval,"%EvalError%":Py,"%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%":kp,"%GeneratorFunction%":cr,"%Int8Array%":typeof Int8Array>"u"?B:Int8Array,"%Int16Array%":typeof Int16Array>"u"?B:Int16Array,"%Int32Array%":typeof Int32Array>"u"?B:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":or&&_e?_e(_e([][Symbol.iterator]())):B,"%JSON%":typeof JSON=="object"?JSON:B,"%Map%":typeof Map>"u"?B:Map,"%MapIteratorPrototype%":typeof Map>"u"||!or||!_e?B:_e(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Cy,"%Object.getOwnPropertyDescriptor%":xs,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?B:Promise,"%Proxy%":typeof Proxy>"u"?B:Proxy,"%RangeError%":Ry,"%ReferenceError%":Dy,"%Reflect%":typeof Reflect>"u"?B:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?B:Set,"%SetIteratorPrototype%":typeof Set>"u"||!or||!_e?B:_e(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?B:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":or&&_e?_e(""[Symbol.iterator]()):B,"%Symbol%":or?Symbol:B,"%SyntaxError%":Dr,"%ThrowTypeError%":Wy,"%TypedArray%":Vy,"%TypeError%":wr,"%Uint8Array%":typeof Uint8Array>"u"?B:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?B:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?B:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?B:Uint32Array,"%URIError%":Oy,"%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%":Ep,"%Object.defineProperty%":jy,"%Object.getPrototypeOf%":By,"%Math.abs%":zy,"%Math.floor%":Ly,"%Math.max%":My,"%Math.min%":Ny,"%Math.pow%":Uy,"%Math.round%":Fy,"%Math.sign%":Zy,"%Reflect.getPrototypeOf%":Gy};if(_e)try{null.error}catch(t){var Hy=_e(_e(t));Wn["%Error.prototype%"]=Hy}var qy=function t(e){var n;if(e==="%AsyncFunction%")n=ya("async function () {}");else if(e==="%GeneratorFunction%")n=ya("function* () {}");else if(e==="%AsyncGeneratorFunction%")n=ya("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 Wn[e]=n,n},Zu={__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,ao=jt,Yy=ui.call(ci,Array.prototype.concat),Ky=ui.call(Ep,Array.prototype.splice),ju=ui.call(ci,String.prototype.replace),lo=ui.call(ci,String.prototype.slice),Jy=ui.call(ci,RegExp.prototype.exec),Xy=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,Qy=/\\(\\)?/g,eb=function(e){var n=lo(e,0,1),r=lo(e,-1);if(n==="%"&&r!=="%")throw new Dr("invalid intrinsic syntax, expected closing `%`");if(r==="%"&&n!=="%")throw new Dr("invalid intrinsic syntax, expected opening `%`");var s=[];return ju(e,Xy,function(i,o,a,l){s[s.length]=a?ju(l,Qy,"$1"):o||i}),s},tb=function(e,n){var r=e,s;if(ao(Zu,r)&&(s=Zu[r],r="%"+s[0]+"%"),ao(Wn,r)){var i=Wn[r];if(i===cr&&(i=qy(r)),typeof i>"u"&&!n)throw new wr("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:s,name:r,value:i}}throw new Dr("intrinsic "+e+" does not exist!")},Qe=function(e,n){if(typeof e!="string"||e.length===0)throw new wr("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof n!="boolean")throw new wr('"allowMissing" argument must be a boolean');if(Jy(/^%?[^%]*%?$/,e)===null)throw new Dr("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var r=eb(e),s=r.length>0?r[0]:"",i=tb("%"+s+"%",n),o=i.name,a=i.value,l=!1,c=i.alias;c&&(s=c[0],Ky(r,Yy([0,1],c)));for(var d=1,p=!0;d<r.length;d+=1){var y=r[d],m=lo(y,0,1),E=lo(y,-1);if((m==='"'||m==="'"||m==="`"||E==='"'||E==="'"||E==="`")&&m!==E)throw new Dr("property names with quotes must have matching quotes");if((y==="constructor"||!p)&&(l=!0),s+="."+y,o="%"+s+"%",ao(Wn,o))a=Wn[o];else if(a!=null){if(!(y in a)){if(!n)throw new wr("base intrinsic for "+e+" exists, but the property is not available.");return}if(xs&&d+1>=r.length){var k=xs(a,y);p=!!k,p&&"get"in k&&!("originalValue"in k.get)?a=k.get:a=a[y]}else p=ao(a,y),a=a[y];p&&!l&&(Wn[o]=a)}}return a},$p=Qe,Ap=zo,nb=Ap([$p("%String.prototype.indexOf%")]),hn=function(e,n){var r=$p(e,!!n);return typeof r=="function"&&nb(e,".prototype.")>-1?Ap([r]):r},wa,Wu;function ac(){if(Wu)return wa;Wu=1;var t=Qe,e=t("%Array%"),n=!e.isArray&&hn("Object.prototype.toString");return wa=e.isArray||function(s){return n(s)==="[object Array]"},wa}var rb=Oo,Bu=ai,xp=rb.hasArrayLengthDefineBug(),sb=xp&&ac(),ib=hn,ob=ib("Object.prototype.propertyIsEnumerable"),lc=function(e,n,r,s,i,o){if(!Bu){if(!e(o)||!o["[[Configurable]]"]||!o["[[Writable]]"]||i in s&&ob(s,i)!==!!o["[[Enumerable]]"])return!1;var a=o["[[Value]]"];return s[i]=a,n(s[i],a)}return xp&&i==="length"&&"[[Value]]"in o&&sb(s)&&s.length!==o["[[Value]]"]?(s.length=o["[[Value]]"],s.length===o["[[Value]]"]):(Bu(s,i,r(o)),!0)},ab=V,ts=jt,lb={__proto__:null,"[[Configurable]]":!0,"[[Enumerable]]":!0,"[[Get]]":!0,"[[Set]]":!0,"[[Value]]":!0,"[[Writable]]":!0},Zr=function(e){if(!e||typeof e!="object")return!1;for(var n in e)if(ts(e,n)&&!lb[n])return!1;var r=ts(e,"[[Value]]")||ts(e,"[[Writable]]"),s=ts(e,"[[Get]]")||ts(e,"[[Set]]");if(r&&s)throw new ab("Property Descriptors may not be both accessor and data descriptors");return!0},Tp=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},cb=V,ub=Zr,hb=Tp,Cp=function(e){if(typeof e<"u"&&!ub(e))throw new cb("Assertion failed: `Desc` must be a Property Descriptor");return hb(e)},db=V,Gu=jt,pb=Zr,Ip=function(e){if(typeof e>"u")return!1;if(!pb(e))throw new db("Assertion failed: `Desc` must be a Property Descriptor");return!(!Gu(e,"[[Value]]")&&!Gu(e,"[[Writable]]"))},jr=function(e){return typeof e=="string"||typeof e=="symbol"},Vu=rc,Pp=function(e,n){return e===n?e===0?1/e===1/n:!0:Vu(e)&&Vu(n)},Hu=V,fb=Zt,gb=lc,mb=Cp,vb=Ip,yb=jr,bb=Pp,cc=function(e,n,r){if(!fb(e))throw new Hu("Assertion failed: Type(O) is not Object");if(!yb(n))throw new Hu("Assertion failed: P is not a Property Key");var s={"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Value]]":r,"[[Writable]]":!0};return gb(vb,bb,mb,e,n,s)},Rp=Function.prototype.toString,mr=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,sl,Ji;if(typeof mr=="function"&&typeof Object.defineProperty=="function")try{sl=Object.defineProperty({},"length",{get:function(){throw Ji}}),Ji={},mr(function(){throw 42},null,sl)}catch(t){t!==Ji&&(mr=null)}else mr=null;var wb=/^\s*class\b/,il=function(e){try{var n=Rp.call(e);return wb.test(n)}catch{return!1}},_a=function(e){try{return il(e)?!1:(Rp.call(e),!0)}catch{return!1}},Xi=Object.prototype.toString,_b="[object Object]",Sb="[object Function]",kb="[object GeneratorFunction]",Eb="[object HTMLAllCollection]",$b="[object HTML document.all class]",Ab="[object HTMLCollection]",xb=typeof Symbol=="function"&&!!Symbol.toStringTag,Tb=!(0 in[,]),ol=function(){return!1};if(typeof document=="object"){var Cb=document.all;Xi.call(Cb)===Xi.call(document.all)&&(ol=function(e){if((Tb||!e)&&(typeof e>"u"||typeof e=="object"))try{var n=Xi.call(e);return(n===Eb||n===$b||n===Ab||n===_b)&&e("")==null}catch{}return!1})}var Dp=mr?function(e){if(ol(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;try{mr(e,null,sl)}catch(n){if(n!==Ji)return!1}return!il(e)&&_a(e)}:function(e){if(ol(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;if(xb)return _a(e);if(il(e))return!1;var n=Xi.call(e);return n!==Sb&&n!==kb&&!/^\[object HTML/.test(n)?!1:_a(e)},Ib=Dp,Pb=function(e){return!!e},dt=jt,Ii=V,Rb=Zt,qu=Ib,Sa=Pb,Db=function(e){if(!Rb(e))throw new Ii("ToPropertyDescriptor requires an object");var n={};if(dt(e,"enumerable")&&(n["[[Enumerable]]"]=Sa(e.enumerable)),dt(e,"configurable")&&(n["[[Configurable]]"]=Sa(e.configurable)),dt(e,"value")&&(n["[[Value]]"]=e.value),dt(e,"writable")&&(n["[[Writable]]"]=Sa(e.writable)),dt(e,"get")){var r=e.get;if(typeof r<"u"&&!qu(r))throw new Ii("getter must be a function");n["[[Get]]"]=r}if(dt(e,"set")){var s=e.set;if(typeof s<"u"&&!qu(s))throw new Ii("setter must be a function");n["[[Set]]"]=s}if((dt(n,"[[Get]]")||dt(n,"[[Set]]"))&&(dt(n,"[[Value]]")||dt(n,"[[Writable]]")))throw new Ii("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute");return n},ka=V,Ob=Zt,Yu=Zr,zb=lc,Lb=Cp,Mb=Ip,Nb=jr,Ub=Pp,Fb=Db,Zb=function(e,n,r){if(!Ob(e))throw new ka("Assertion failed: Type(O) is not Object");if(!Nb(n))throw new ka("Assertion failed: P is not a Property Key");var s=Yu(r)?r:Fb(r);if(!Yu(s))throw new ka("Assertion failed: Desc is not a valid Property Descriptor");return zb(Mb,Ub,Lb,e,n,s)},Ku=V,jb=Zt,Wb=Zb,Bb=jr,Gb=function(e,n,r){if(!jb(e))throw new Ku("Assertion failed: Type(O) is not Object");if(!Bb(n))throw new Ku("Assertion failed: P is not a Property Key");var s={"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Value]]":r,"[[Writable]]":!0};return Wb(e,n,s)},Vb=typeof Reflect<"u"&&Reflect.setPrototypeOf||null,Hb=tc,qb=Hb.setPrototypeOf||null,Yb=zo,Ju=Ur,Kb=V,Op={};try{Op.__proto__=null}catch(t){if(!t||typeof t!="object"||!("code"in t)||t.code!=="ERR_PROTO_ACCESS")throw t}var Jb=!("toString"in Op),Ea=Ju&&Ju(Object.prototype,"__proto__"),Xb=Jb&&(!!Ea&&typeof Ea.set=="function"&&Yb([Ea.set])||function(e,n){if(e==null)throw new Kb("set Object.prototype.__proto__ called on null or undefined");return e.__proto__=n,n}),Xu=Vb,Qb=qb,Qu=Xb,ew=V,tw=Xu?function(e,n){if(Xu(e,n))return e;throw new ew("Reflect.setPrototypeOf: failed to set [[Prototype]]")}:Qb||(Qu?function(e,n){return Qu(e,n),e}:null),eh=V,nw=Zt,th=Sp(),rw=function(e){if(!nw(e))throw new eh("Assertion failed: O must be an Object");if(!th)throw new eh("This environment does not support fetching prototypes.");return th(e)},sw=V,iw=tw,ow=Zt,aw=rw,lw=function(e,n){if(n!==null&&!ow(n))throw new sw("Assertion failed: V must be Object or Null");try{iw(e,n)}catch{return!1}return aw(e)===n},$a=cc,nh=Gb,zp=lw,cw=Oo(),uc=yp;function hi(t,e,n){var r=new uc(n);return zp(r,Qi),delete r.constructor,nh(r,"error",t),nh(r,"suppressed",e),r}cw&&Object.defineProperty(hi,"prototype",{writable:!1});var Qi=hi.prototype;if(!$a(Qi,"constructor",hi)||!$a(Qi,"message","")||!$a(Qi,"name","SuppressedError"))throw new uc("unable to install SuppressedError.prototype properties; please report this!");zp(hi.prototype,uc.prototype);var uw=hi,hw=uw,Lp=function(){return typeof SuppressedError=="function"?SuppressedError:hw},dw=Yn,rh=ec(),pw=Lp,fw=function(){var e=pw();return dw(rh,{SuppressedError:e},{SuppressedError:function(){return rh.SuppressedError!==e}}),e};fw();var gw=V,mw=Zr,vw=Tp,yw=function(e){if(typeof e<"u"&&!mw(e))throw new gw("Assertion failed: `Desc` must be a Property Descriptor");return vw(e)},bw=V,sh=jt,ww=Zr,_w=function(e){if(typeof e>"u")return!1;if(!ww(e))throw new bw("Assertion failed: `Desc` must be a Property Descriptor");return!(!sh(e,"[[Value]]")&&!sh(e,"[[Writable]]"))},ih=rc,Sw=function(e,n){return e===n?e===0?1/e===1/n:!0:ih(e)&&ih(n)},Wr=Dp,kw=function(e){return!!e},pt=jt,Pi=V,Ew=Zt,oh=Wr,Aa=kw,$w=function(e){if(!Ew(e))throw new Pi("ToPropertyDescriptor requires an object");var n={};if(pt(e,"enumerable")&&(n["[[Enumerable]]"]=Aa(e.enumerable)),pt(e,"configurable")&&(n["[[Configurable]]"]=Aa(e.configurable)),pt(e,"value")&&(n["[[Value]]"]=e.value),pt(e,"writable")&&(n["[[Writable]]"]=Aa(e.writable)),pt(e,"get")){var r=e.get;if(typeof r<"u"&&!oh(r))throw new Pi("getter must be a function");n["[[Get]]"]=r}if(pt(e,"set")){var s=e.set;if(typeof s<"u"&&!oh(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},xa=V,Aw=Zt,ah=Zr,xw=lc,Tw=yw,Cw=_w,Iw=jr,Pw=Sw,Rw=$w,di=function(e,n,r){if(!Aw(e))throw new xa("Assertion failed: Type(O) is not Object");if(!Iw(n))throw new xa("Assertion failed: P is not a Property Key");var s=ah(r)?r:Rw(r);if(!ah(s))throw new xa("Assertion failed: Desc is not a valid Property Descriptor");return xw(Cw,Pw,Tw,e,n,s)},Dw=Fr(),Ow=Dw?Symbol.dispose||Symbol("Symbol.dispose"):null,zw=Fr,Lw=Ow,hc=function(){return zw()&&Symbol.dispose||Lw},Mw=sc,Nw=di,Uw=hc,Fw=function(){var e=Uw();return Mw()&&Nw(Symbol,"dispose",{"[[Configurable]]":!1,"[[Enumerable]]":!1,"[[Writable]]":!1,"[[Value]]":e}),e},Zw=Fr(),jw=Zw?Symbol.asyncDispose||Symbol("Symbol.asyncDispose"):null,Ww=Fr,Bw=jw,dc=function(){return Ww()&&Symbol.asyncDispose||Bw},Gw=sc,Vw=di,Hw=dc,qw=function(){var e=Hw();return Gw()&&Vw(Symbol,"asyncDispose",{"[[Configurable]]":!1,"[[Enumerable]]":!1,"[[Writable]]":!1,"[[Value]]":e}),e},Yw=ac(),Kw=Qe,Jw=hn,Xw=V,Qw=Yw,e_=Kw("%Reflect.apply%",!0)||Jw("Function.prototype.apply"),Lo=function(e,n){var r=arguments.length>2?arguments[2]:[];if(!Qw(r))throw new Xw("Assertion failed: optional `argumentsList`, if provided, must be a List");return e_(e,n,r)};const t_={},n_=Object.freeze(Object.defineProperty({__proto__:null,default:t_},Symbol.toStringTag,{value:"Module"})),r_=Tv(n_);var pc=typeof Map=="function"&&Map.prototype,Ta=Object.getOwnPropertyDescriptor&&pc?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,co=pc&&Ta&&typeof Ta.get=="function"?Ta.get:null,lh=pc&&Map.prototype.forEach,fc=typeof Set=="function"&&Set.prototype,Ca=Object.getOwnPropertyDescriptor&&fc?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,uo=fc&&Ca&&typeof Ca.get=="function"?Ca.get:null,ch=fc&&Set.prototype.forEach,s_=typeof WeakMap=="function"&&WeakMap.prototype,Ss=s_?WeakMap.prototype.has:null,i_=typeof WeakSet=="function"&&WeakSet.prototype,ks=i_?WeakSet.prototype.has:null,o_=typeof WeakRef=="function"&&WeakRef.prototype,uh=o_?WeakRef.prototype.deref:null,a_=Boolean.prototype.valueOf,l_=Object.prototype.toString,c_=Function.prototype.toString,u_=String.prototype.match,gc=String.prototype.slice,en=String.prototype.replace,h_=String.prototype.toUpperCase,hh=String.prototype.toLowerCase,Mp=RegExp.prototype.test,dh=Array.prototype.concat,_t=Array.prototype.join,d_=Array.prototype.slice,ph=Math.floor,al=typeof BigInt=="function"?BigInt.prototype.valueOf:null,Ia=Object.getOwnPropertySymbols,ll=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,Or=typeof Symbol=="function"&&typeof Symbol.iterator=="object",Es=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===Or||!0)?Symbol.toStringTag:null,Np=Object.prototype.propertyIsEnumerable,fh=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(t){return t.__proto__}:null);function gh(t,e){if(t===1/0||t===-1/0||t!==t||t&&t>-1e3&&t<1e3||Mp.call(/e/,e))return e;var n=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof t=="number"){var r=t<0?-ph(-t):ph(t);if(r!==t){var s=String(r),i=gc.call(e,s.length+1);return en.call(s,n,"$&_")+"."+en.call(en.call(i,/([0-9]{3})/g,"$&_"),/_$/,"")}}return en.call(e,n,"$&_")}var cl=r_,mh=cl.custom,vh=Zp(mh)?mh:null,Up={__proto__:null,double:'"',single:"'"},p_={__proto__:null,double:/(["\\])/g,single:/(['\\])/g},Br=function t(e,n,r,s){var i=n||{};if(It(i,"quoteStyle")&&!It(Up,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 Wp(e,i);if(typeof e=="number"){if(e===0)return 1/0/e>0?"0":"-0";var l=String(e);return a?gh(e,l):l}if(typeof e=="bigint"){var c=String(e)+"n";return a?gh(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 ul(e)?"[Array]":"[Object]";var p=P_(i,r);if(typeof s>"u")s=[];else if(jp(s,e)>=0)return"[Circular]";function y(ct,Wt,ea){if(Wt&&(s=d_.call(s),s.push(Wt)),ea){var _i={depth:i.depth};return It(i,"quoteStyle")&&(_i.quoteStyle=i.quoteStyle),t(ct,_i,r+1,s)}return t(ct,i,r+1,s)}if(typeof e=="function"&&!yh(e)){var m=S_(e),E=Ri(e,y);return"[Function"+(m?": "+m:" (anonymous)")+"]"+(E.length>0?" { "+_t.call(E,", ")+" }":"")}if(Zp(e)){var k=Or?en.call(String(e),/^(Symbol\(.*\))_[^)]*$/,"$1"):ll.call(e);return typeof e=="object"&&!Or?ns(k):k}if(T_(e)){for(var I="<"+hh.call(String(e.nodeName)),G=e.attributes||[],N=0;N<G.length;N++)I+=" "+G[N].name+"="+Fp(f_(G[N].value),"double",i);return I+=">",e.childNodes&&e.childNodes.length&&(I+="..."),I+="</"+hh.call(String(e.nodeName))+">",I}if(ul(e)){if(e.length===0)return"[]";var j=Ri(e,y);return p&&!I_(j)?"["+hl(j,p)+"]":"[ "+_t.call(j,", ")+" ]"}if(m_(e)){var F=Ri(e,y);return!("cause"in Error.prototype)&&"cause"in e&&!Np.call(e,"cause")?"{ ["+String(e)+"] "+_t.call(dh.call("[cause]: "+y(e.cause),F),", ")+" }":F.length===0?"["+String(e)+"]":"{ ["+String(e)+"] "+_t.call(F,", ")+" }"}if(typeof e=="object"&&o){if(vh&&typeof e[vh]=="function"&&cl)return cl(e,{depth:d-r});if(o!=="symbol"&&typeof e.inspect=="function")return e.inspect()}if(k_(e)){var L=[];return lh&&lh.call(e,function(ct,Wt){L.push(y(Wt,e,!0)+" => "+y(ct,e))}),bh("Map",co.call(e),L,p)}if(A_(e)){var J=[];return ch&&ch.call(e,function(ct){J.push(y(ct,e))}),bh("Set",uo.call(e),J,p)}if(E_(e))return Pa("WeakMap");if(x_(e))return Pa("WeakSet");if($_(e))return Pa("WeakRef");if(y_(e))return ns(y(Number(e)));if(w_(e))return ns(y(al.call(e)));if(b_(e))return ns(a_.call(e));if(v_(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(!g_(e)&&!yh(e)){var H=Ri(e,y),he=fh?fh(e)===Object.prototype:e instanceof Object||e.constructor===Object,lt=e instanceof Object?"":"null prototype",wi=!he&&Es&&Object(e)===e&&Es in e?gc.call(dn(e),8,-1):lt?"Object":"",Ee=he||typeof e.constructor!="function"?"":e.constructor.name?e.constructor.name+" ":"",gn=Ee+(wi||lt?"["+_t.call(dh.call([],wi||[],lt||[]),": ")+"] ":"");return H.length===0?gn+"{}":p?gn+"{"+hl(H,p)+"}":gn+"{ "+_t.call(H,", ")+" }"}return String(e)};function Fp(t,e,n){var r=n.quoteStyle||e,s=Up[r];return s+t+s}function f_(t){return en.call(String(t),/"/g,""")}function Kn(t){return!Es||!(typeof t=="object"&&(Es in t||typeof t[Es]<"u"))}function ul(t){return dn(t)==="[object Array]"&&Kn(t)}function g_(t){return dn(t)==="[object Date]"&&Kn(t)}function yh(t){return dn(t)==="[object RegExp]"&&Kn(t)}function m_(t){return dn(t)==="[object Error]"&&Kn(t)}function v_(t){return dn(t)==="[object String]"&&Kn(t)}function y_(t){return dn(t)==="[object Number]"&&Kn(t)}function b_(t){return dn(t)==="[object Boolean]"&&Kn(t)}function Zp(t){if(Or)return t&&typeof t=="object"&&t instanceof Symbol;if(typeof t=="symbol")return!0;if(!t||typeof t!="object"||!ll)return!1;try{return ll.call(t),!0}catch{}return!1}function w_(t){if(!t||typeof t!="object"||!al)return!1;try{return al.call(t),!0}catch{}return!1}var __=Object.prototype.hasOwnProperty||function(t){return t in this};function It(t,e){return __.call(t,e)}function dn(t){return l_.call(t)}function S_(t){if(t.name)return t.name;var e=u_.call(c_.call(t),/^function\s*([\w$]+)/);return e?e[1]:null}function jp(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 k_(t){if(!co||!t||typeof t!="object")return!1;try{co.call(t);try{uo.call(t)}catch{return!0}return t instanceof Map}catch{}return!1}function E_(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 $_(t){if(!uh||!t||typeof t!="object")return!1;try{return uh.call(t),!0}catch{}return!1}function A_(t){if(!uo||!t||typeof t!="object")return!1;try{uo.call(t);try{co.call(t)}catch{return!0}return t instanceof Set}catch{}return!1}function x_(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 T_(t){return!t||typeof t!="object"?!1:typeof HTMLElement<"u"&&t instanceof HTMLElement?!0:typeof t.nodeName=="string"&&typeof t.getAttribute=="function"}function Wp(t,e){if(t.length>e.maxStringLength){var n=t.length-e.maxStringLength,r="... "+n+" more character"+(n>1?"s":"");return Wp(gc.call(t,0,e.maxStringLength),e)+r}var s=p_[e.quoteStyle||"single"];s.lastIndex=0;var i=en.call(en.call(t,s,"\\$1"),/[\x00-\x1f]/g,C_);return Fp(i,"single",e)}function C_(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":"")+h_.call(e.toString(16))}function ns(t){return"Object("+t+")"}function Pa(t){return t+" { ? }"}function bh(t,e,n,r){var s=r?hl(n,r):_t.call(n,", ");return t+" ("+e+") {"+s+"}"}function I_(t){for(var e=0;e<t.length;e++)if(jp(t[e],`
|
|
2
|
+
`)>=0)return!1;return!0}function P_(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 hl(t,e){if(t.length===0)return"";var n=`
|
|
3
3
|
`+e.prev+e.base;return n+_t.call(t,","+n)+`
|
|
4
|
-
`+e.prev}function Ri(t,e){var n=ul(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 Ia=="function"?Ia(t):[],o;if(Or){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||Or&&o["$"+l]instanceof Symbol||(Zp.call(/[^\w$]/,l)?r.push(e(l,t)+": "+e(t[l],t)):r.push(l+": "+e(t[l],t))));if(typeof Ia=="function")for(var c=0;c<i.length;c++)jp.call(t,i[c])&&r.push("["+e(i[c])+"]: "+e(t[i[c]],t));return r}var L_=Br,M_=V,Mo=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},N_=function(t,e){if(t){var n=Mo(t,e);return n&&n.value}},U_=function(t,e,n){var r=Mo(t,e);r?r.value=n:t.next={key:e,next:t.next,value:n}},F_=function(t,e){return t?!!Mo(t,e):!1},Z_=function(t,e){if(t)return Mo(t,e,!0)},j_=function(){var e,n={assert:function(r){if(!n.has(r))throw new M_("Side channel does not contain "+L_(r))},delete:function(r){var s=e&&e.next,i=Z_(e,r);return i&&s&&s===i&&(e=void 0),!!i},get:function(r){return N_(e,r)},has:function(r){return F_(e,r)},set:function(r,s){e||(e={next:void 0}),U_(e,r,s)}};return n},W_=Qe,pi=hn(),B_=Br,G_=V,Eh=W_("%Map%",!0),V_=pi("Map.prototype.get",!0),H_=pi("Map.prototype.set",!0),q_=pi("Map.prototype.has",!0),Y_=pi("Map.prototype.delete",!0),K_=pi("Map.prototype.size",!0),qp=!!Eh&&function(){var e,n={assert:function(r){if(!n.has(r))throw new G_("Side channel does not contain "+B_(r))},delete:function(r){if(e){var s=Y_(e,r);return K_(e)===0&&(e=void 0),s}return!1},get:function(r){if(e)return V_(e,r)},has:function(r){return e?q_(e,r):!1},set:function(r,s){e||(e=new Eh),H_(e,r,s)}};return n},J_=Qe,No=hn(),X_=Br,Di=qp,Q_=V,ar=J_("%WeakMap%",!0),eS=No("WeakMap.prototype.get",!0),tS=No("WeakMap.prototype.set",!0),nS=No("WeakMap.prototype.has",!0),rS=No("WeakMap.prototype.delete",!0),sS=ar?function(){var e,n,r={assert:function(s){if(!r.has(s))throw new Q_("Side channel does not contain "+X_(s))},delete:function(s){if(ar&&s&&(typeof s=="object"||typeof s=="function")){if(e)return rS(e,s)}else if(Di&&n)return n.delete(s);return!1},get:function(s){return ar&&s&&(typeof s=="object"||typeof s=="function")&&e?eS(e,s):n&&n.get(s)},has:function(s){return ar&&s&&(typeof s=="object"||typeof s=="function")&&e?nS(e,s):!!n&&n.has(s)},set:function(s,i){ar&&s&&(typeof s=="object"||typeof s=="function")?(e||(e=new ar),tS(e,s,i)):Di&&(n||(n=Di()),n.set(s,i))}};return r}:Di,iS=V,oS=Br,aS=j_,lS=qp,cS=sS,uS=cS||lS||aS,hS=function(){var e,n={assert:function(r){if(!n.has(r))throw new iS("Side channel does not contain "+oS(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=uS()),e.set(r,s)}};return n},dS=jt,rs=hS(),xt=V,mc={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),!mc.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&&dS(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(mc);var vc=mc,Yp=Ft,rn=vc,fi=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 Yp('Assertion failed: `type` must be one of "normal", "break", "continue", "return", or "throw"');rn.set(this,"[[Type]]",e),rn.set(this,"[[Value]]",n)};fi.prototype.type=function(){return rn.get(this,"[[Type]]")};fi.prototype.value=function(){return rn.get(this,"[[Value]]")};fi.prototype["?"]=function(){var e=rn.get(this,"[[Type]]"),n=rn.get(this,"[[Value]]");if(e==="throw")throw n;return n};fi.prototype["!"]=function(){var e=rn.get(this,"[[Type]]");if(e!=="normal")throw new Yp('Assertion failed: Completion Record is not of type "normal"');return rn.get(this,"[[Value]]")};var yc=fi,pS=yc,bc=function(e){return new pS("normal",e)},Ra,$h;function fS(){if($h)return Ra;$h=1;var t=Fr;return Ra=function(){return t()&&!!Symbol.toStringTag},Ra}var gS=Qe,Ah=gS("%Object.defineProperty%",!0),mS=fS()(),vS=jt,yS=V,Oi=mS?Symbol.toStringTag:null,Kp=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 yS("if provided, the `overrideIfSet` and `nonConfigurable` options must be booleans");Oi&&(r||!vS(e,Oi))&&(Ah?Ah(e,Oi,{configurable:!s,enumerable:!1,value:n,writable:!1}):e[Oi]=n)},Jp={exports:{}},bS=Qe,xh=fp,wS=Oo(),Th=Ur,Ch=V,_S=bS("%Math.floor%"),SS=function(e,n){if(typeof e!="function")throw new Ch("`fn` is not a function");if(typeof n!="number"||n<0||n>4294967295||_S(n)!==n)throw new Ch("`length` must be a positive 32-bit integer");var r=arguments.length>2&&!!arguments[2],s=!0,i=!0;if("length"in e&&Th){var o=Th(e,"length");o&&!o.configurable&&(s=!1),o&&!o.writable&&(i=!1)}return(s||i||!r)&&(wS?xh(e,"length",n,!0,!0):xh(e,"length",n)),e},kS=li,ES=oc,$S=$p,AS=function(){return $S(kS,ES,arguments)};(function(t){var e=SS,n=ai,r=zo,s=AS;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})(Jp);var wc=Jp.exports,xS=function(e,n){for(var r=0;r<e.length;r+=1)if(!n(e[r],r,e))return!1;return!0},TS=Object,CS=function(e){return e&&typeof e=="object"&&(typeof e["[[ResourceValue]]"]>"u"||TS(e["[[ResourceValue]]"])===e["[[ResourceValue]]"])&&(e["[[Hint]]"]==="SYNC-DISPOSE"||e["[[Hint]]"]==="ASYNC-DISPOSE")&&(typeof e["[[DisposeMethod]]"]=="function"||typeof e["[[DisposeMethod]]"]>"u")},IS=jt,PS=ac(),RS=xS,DS=CS,OS=function(e){return e&&typeof e=="object"&&IS(e,"[[DisposableResourceStack]]")&&PS(e["[[DisposableResourceStack]]"])&&(e["[[DisposableResourceStack]]"].length===0||RS(e["[[DisposableResourceStack]]"],DS))},zS=Zt,LS=function(e){if(e===null)return"Null";if(typeof e>"u")return"Undefined";if(zS(e))return"Object";if(typeof e=="number")return"Number";if(typeof e=="boolean")return"Boolean";if(typeof e=="string")return"String"},MS=LS,_c=function(e){return typeof e=="symbol"?"Symbol":typeof e=="bigint"?"BigInt":MS(e)},NS=V,US=Br,FS=jr,ZS=function(e,n){if(!FS(n))throw new NS("Assertion failed: P is not a Property Key, got "+US(n));return e[n]},Ih=V,jS=ZS,WS=Wr,BS=jr,Ph=Br,GS=function(e,n){if(!BS(n))throw new Ih("Assertion failed: P is not a Property Key");var r=jS(e,n);if(r!=null){if(!WS(r))throw new Ih(Ph(n)+" is not a function: "+Ph(r));return r}},dl={exports:{}},VS=Qe,HS=VS,Rh=HS("%Reflect.construct%",!0),ho=di;try{ho({},"",{"[[Get]]":function(){}})}catch{ho=null}if(ho&&Rh){var Dh={},Oh={};ho(Oh,"length",{"[[Get]]":function(){throw Dh},"[[Enumerable]]":!0}),dl.exports=function(e){try{Rh(e,Oh)}catch(n){return n===Dh}}}else dl.exports=function(e){return typeof e=="function"&&!!e.prototype};var qS=dl.exports,Da=V,zh=Wr,YS=qS,KS=function(e){if(!YS(e))throw new Da("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 Da("executor has already been called");n["[[Resolve]]"]=s,n["[[Reject]]"]=i});if(!zh(n["[[Resolve]]"])||!zh(n["[[Reject]]"]))throw new Da("executor must provide valid resolve and reject functions");return{"[[Promise]]":r,"[[Resolve]]":n["[[Resolve]]"],"[[Reject]]":n["[[Reject]]"]}},Lh=Ft,JS=V,Oa=Lo,Mh=GS,XS=KS,QS=_c,Nh=hc(),Uh=dc(),ek=function(e,n){if(QS(e)!=="Object")throw new JS("`V` must be an Object");if(n!=="SYNC-DISPOSE"&&n!=="ASYNC-DISPOSE")throw new Lh("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");var r;if(n==="ASYNC-DISPOSE"&&Uh&&(r=Mh(e,Uh)),!r){if(!Nh)throw new Lh("`Symbol.dispose` is not supported");if(r=Mh(e,Nh),typeof r<"u")return function(){var s=this;if(n==="ASYNC-DISPOSE"){var i=XS(Promise);try{Oa(r,s),Oa(i["[[Resolve]]"],void 0,[void 0])}catch(o){i["[[Reject]]"](o)}return i["[[Promise]]"]}Oa(r,s)}}return r},tk=Ft,za=V,nk=Wr,rk=_c,sk=ek,ik=function(e,n){if(n!=="SYNC-DISPOSE"&&n!=="ASYNC-DISPOSE")throw new tk("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"&&rk(e)!=="Object")throw new za("`V` must be an Object, or `null` or `undefined`");if(r=sk(e,n),typeof r>"u")throw new za("dispose method must not be `undefined` on `V` when an object `V` is provided")}else if(r=arguments[2],!nk(r))throw new za("`method`, when provided, must be a function");return{"[[ResourceValue]]":e,"[[Hint]]":n,"[[DisposeMethod]]":r}},ok=Ft,zi=V,ak=OS,Fh=ik,lk=hn(),ck=lk("Array.prototype.push"),Xp=function(e,n,r){if(!ak(e))throw new zi("Assertion failed: `disposeCapability` must be a DisposeCapability Record");if(r!=="SYNC-DISPOSE"&&r!=="ASYNC-DISPOSE")throw new ok("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=Fh(n,r)}else{if(typeof n<"u")throw new zi("Assertion failed: `V` must be undefined when `method` is present");i=Fh(void 0,r,s)}return ck(e["[[DisposableResourceStack]]"],i),"UNUSED"},La,Zh;function Sc(){if(Zh)return La;Zh=1;var t=Qe,e=wc,n=Ft,r=t("%Promise.resolve%",!0),s=r&&e(r);return La=function(o,a){if(!s)throw new n("This environment does not support Promises.");return s(o,a)},La}var Ma,jh;function uk(){if(jh)return Ma;jh=1;var t=Qe,e=Ft,n=t("%Promise%",!0),r=Lo,s=Sc(),i=_c;return Ma=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)},Ma}var Na,Wh;function hk(){if(Wh)return Na;Wh=1;var t=yc;return Na=function(n){return new t("throw",n)},Na}var dk=Qe,Ua=Ft,Bh=V,pk=dk("%Promise%",!0),fk=hn(),Gh=fk("Promise.prototype.then",!0),gk=yc,Vh=uk(),mk=bc,vk=Sc(),Hh=hk(),yk=Fp(),Qp=function(e,n){if(!(n instanceof gk))throw new Bh("`completion` must be a Completion Record");var r=e["[[DisposableResourceStack]]"];if(!r)throw new Bh("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 Ua("mixed hint stacks are not supported");for(var o=s==="ASYNC-DISPOSE"&&vk(pk,n),a=function(y){if(n.type()==="throw"){var m=n.value(),E=new yk(y,m);n=Hh(E)}else n=Hh(y)},l=s==="ASYNC-DISPOSE"&&function(m){return Gh(o,function(){var E=Vh(m["[[ResourceValue]]"],m["[[Hint]]"],m["[[DisposeMethod]]"]);if(!E)throw new Ua("Assertion failed: non-`~ASYNC-DISPOSE~` resource returned a promise from Dispose");return Gh(E,mk)},a)},c=r.length-1;c>=0;c-=1)if(s==="ASYNC-DISPOSE")o=l(r[c]);else{var d=r[c];try{var p=Vh(d["[[ResourceValue]]"],d["[[Hint]]"],d["[[DisposeMethod]]"]);if(p)throw new Ua("Assertion failed: `~SYNC-DISPOSE~` resource returned something from Dispose")}catch(y){a(y)}}return e["[[DisposableResourceStack]]"]=null,s==="ASYNC-DISPOSE"?o:n},ef=function(){var e=[];return{"[[DisposableResourceStack]]":e}},Uo=nc,kc=V,bk=Lo,Gr=cc,wk=di,tf=Wr,_k=bc,Ze=vc,Sk=Kp,nf=Yn.supportsDescriptors,kk=wc,Ec=Xp,Ek=Qp,rf=ef,qh=hc(),Ke=function t(){if(!(this instanceof t)||Ze.has(this,"[[DisposableState]]")||Ze.has(this,"[[DisposeCapability]]"))throw new kc("can only be used with new");Ze.set(this,"[[DisposableState]]","PENDING"),Ze.set(this,"[[DisposeCapability]]",rf())},sf=function(){var e=this;return Ze.assert(e,"[[DisposableState]]"),Ze.get(e,"[[DisposableState]]")==="DISPOSED"},gi=kk(sf);nf?wk(Ke.prototype,"disposed",{"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Get]]":sf}):Ke.prototype.disposed=!1;var of=function(e){Ze.set(e,"[[DisposableState]]","DISPOSED"),nf||(e.disposed=!0)};Gr(Ke.prototype,"dispose",function(){var e=this;if(!gi(e))return of(e),Ek(Ze.get(e,"[[DisposeCapability]]"),_k())["?"]()});Gr(Ke.prototype,"use",function(e){var n=this;if(gi(n))throw new Uo("a disposed stack can not use anything new");return Ec(Ze.get(n,"[[DisposeCapability]]"),e,"SYNC-DISPOSE"),e});Gr(Ke.prototype,"adopt",function(e,n){var r=this;if(gi(r))throw new Uo("a disposed stack can not use anything new");if(!tf(n))throw new kc("`onDispose` must be a function");var s=function(){return bk(n,void 0,[e])};return Ec(Ze.get(r,"[[DisposeCapability]]"),void 0,"SYNC-DISPOSE",s),e});Gr(Ke.prototype,"defer",function(e){var n=this;if(gi(n))throw new Uo("a disposed stack can not defer anything new");if(!tf(e))throw new kc("`onDispose` must be a function");Ec(Ze.get(n,"[[DisposeCapability]]"),void 0,"SYNC-DISPOSE",e)});Gr(Ke.prototype,"move",function(){var e=this;if(gi(e))throw new Uo("a disposed stack can not use anything new");var n=new Ke;return Ze.set(n,"[[DisposeCapability]]",Ze.get(e,"[[DisposeCapability]]")),Ze.set(e,"[[DisposeCapability]]",rf()),of(e),n});qh&&Gr(Ke.prototype,qh,Ke.prototype.dispose);Sk(Ke.prototype,"DisposableStack");var $k=Ke,Ak=$k,xk=function(){return typeof DisposableStack=="function"?DisposableStack:Ak},Tk=Yn,Ck=ec(),Ik=xk,Pk=function(){var e=Ik();return Tk(Ck,{DisposableStack:e},{DisposableStack:!0}),e},Rk=Qe,Fo=nc,$c=V,Yh=Rk("%Promise%",!0),Ac=Xp,Dk=Lo,Vr=cc,Ok=di,zk=Qp,af=Wr,lf=ef,Lk=bc,Kh=Sc(),je=vc,Mk=Kp,cf=Yn.supportsDescriptors,Nk=wc,Uk=hn(),Fk=Uk("Promise.prototype.then",!0),Jh=dc(),Je=function t(){if(!(this instanceof t)||je.has(this,"[[AsyncDisposableState]]")||je.has(this,"[[DisposeCapability]]"))throw new $c("can only be used with new");je.set(this,"[[AsyncDisposableState]]","pending"),je.set(this,"[[DisposeCapability]]",lf())},uf=function(){var e=this;return je.assert(e,"[[AsyncDisposableState]]"),je.get(e,"[[AsyncDisposableState]]")==="disposed"},mi=Nk(uf);cf?Ok(Je.prototype,"disposed",{"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Get]]":uf}):Je.prototype.disposed=!1;var hf=function(e){je.set(e,"[[AsyncDisposableState]]","disposed"),cf||(e.disposed=!0)};Vr(Je.prototype,"disposeAsync",function(){var e=this;return mi(e)?Kh(Yh):(hf(e),Fk(Kh(Yh,zk(je.get(e,"[[DisposeCapability]]"),Lk())),function(n){return n["?"]()}))});Vr(Je.prototype,"use",function(e){var n=this;if(mi(n))throw new Fo("a disposed stack can not use anything new");return Ac(je.get(n,"[[DisposeCapability]]"),e,"ASYNC-DISPOSE"),e});Vr(Je.prototype,"adopt",function(e,n){var r=this;if(mi(r))throw new Fo("a disposed stack can not use anything new");if(!af(n))throw new $c("`onDisposeAsync` must be a function");var s=function(){return Dk(n,void 0,[e])};return s.value=e,Ac(je.get(r,"[[DisposeCapability]]"),void 0,"ASYNC-DISPOSE",s),e});Vr(Je.prototype,"defer",function(e){var n=this;if(mi(n))throw new Fo("a disposed stack can not defer anything new");if(!af(e))throw new $c("`onDispose` must be a function");Ac(je.get(n,"[[DisposeCapability]]"),void 0,"ASYNC-DISPOSE",e)});Vr(Je.prototype,"move",function(){var e=this;if(mi(e))throw new Fo("a disposed stack can not use anything new");var n=new Je;return je.set(n,"[[DisposeCapability]]",je.get(e,"[[DisposeCapability]]")),je.set(e,"[[DisposeCapability]]",lf()),hf(e),n});Jh&&Vr(Je.prototype,Jh,Je.prototype.disposeAsync);Mk(Je.prototype,"AsyncDisposableStack");var Zk=Je,jk=Zk,Wk=function(){return typeof AsyncDisposableStack=="function"?AsyncDisposableStack:jk},Bk=Yn,Gk=ec(),Vk=Wk,Hk=function(){var e=Vk();return Bk(Gk,{AsyncDisposableStack:e},{AsyncDisposableStack:!0}),e},qk=Bw,Yk=Xw,Kk=Pk,Jk=Hk,Xk=function(){qk(),Yk(),Kk(),Jk()};Xk();const Xh=new WeakMap;function Qk(t){return(typeof t=="object"||typeof t=="function")&&t!==null&&"then"in t&&typeof t.then=="function"}function lr(t){return typeof t=="string"?t:typeof t=="symbol"?t.description??t.toString():t.name||"(anonymous class)"}function Qh(){return new Error("register(Key, factory) requires a factory function. Wrap existing instances as () => instance.")}function eE(){return new Error("register(Key, factory) does not accept async factories. Await setup before registering.")}class tE{constructor(){v(this,"entries",new Map);v(this,"constructionStack",[])}register(e,n){if(n===void 0){if(typeof e!="function")throw Qh();this.validateClassRegistration(e),this.storeFactory(e,()=>this.instantiateClass(e));return}if(typeof n!="function")throw Qh();if(n.constructor.name==="AsyncFunction")throw eE();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=Xh.get(e);if(n){if(e.length!==n.length)throw new Error(`${lr(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(`${lr(e)} cannot be registered with register(Class). Undecorated classes must have zero required constructor parameters. Use register(Key, () => value) instead.`)}instantiateClass(e){const n=Xh.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(`${lr(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=>lr(s)).join(" -> ");throw new Error(`Circular dependency detected: ${r}`)}this.constructionStack.push(e.key);try{const r=e.factory();if(Qk(r))throw new Error(`Factory for ${lr(e.key)} returned a Promise. Await setup before registering.`);if(typeof r!="object"||r===null)throw new Error(`Factory for ${lr(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 Ve=new tE,nE=new Set(["target","currentTarget","eventPhase","defaultPrevented","isTrusted","timeStamp","srcElement","returnValue","cancelBubble","NONE","CAPTURING_PHASE","AT_TARGET","BUBBLING_PHASE","composedPath","stopPropagation","stopImmediatePropagation","preventDefault","initEvent"]);function rE(t){for(const e of Object.keys(t))if(nE.has(e))throw new Error(`Event payload key "${e}" is reserved; choose a different property name`)}function sE(t,e){rE(e);for(const n of Object.keys(e))Object.defineProperty(t,n,{value:e[n],writable:!0,enumerable:!0,configurable:!0})}function et(){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}),sE(this,l)}}return t}class kt extends globalThis.EventTarget{}function iE(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);$(this,n,!1);iE(this,()=>u(this,n),()=>{x(this,n,!0)})}[Symbol.dispose](){this.dispose()}get disposed(){return u(this,n)}}return n=new WeakMap,e}const oE=et(),eo=et(),df="0123456789ABCDEFGHJKMNPQRSTVWXYZ",po=32,aE=16,pf=10,ed=0xffffffffffff;var xn;(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"})(xn||(xn={}));class fs extends Error{constructor(e,n){super(`${n} (${e})`),this.name="ULIDError",this.code=e}}function lE(t){const e=Math.floor(t()*po)%po;return df.charAt(e)}function cE(t){const e=uE(),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 fs(xn.PRNGDetectFailure,"Failed to find a reliable PRNG")}function uE(){return pE()?self:typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:null}function hE(t,e){let n="";for(;t>0;t--)n=lE(e)+n;return n}function dE(t,e=pf){if(isNaN(t))throw new fs(xn.EncodeTimeValueMalformed,`Time must be a number: ${t}`);if(t>ed)throw new fs(xn.EncodeTimeSizeExceeded,`Cannot encode a time larger than ${ed}: ${t}`);if(t<0)throw new fs(xn.EncodeTimeNegative,`Time must be positive: ${t}`);if(Number.isInteger(t)===!1)throw new fs(xn.EncodeTimeValueMalformed,`Time must be an integer: ${t}`);let n,r="";for(let s=e;s>0;s--)n=t%po,r=df.charAt(n)+r,t=(t-n)/po;return r}function pE(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}function xc(t,e){const n=cE(),r=Date.now();return dE(r,pf)+hE(aE,n)}const St=4,He=6,ff=2,pl=2,fE=St,gE=He,Tc="auto",sn="auto",kn=120,td=75,de=16,tn=kn*St+de*(St-1),vr=kn*He+de*(He-1),mE=200,vE=4,Li=150,yE=10,nd=2,bE=4;function gf(t){return yf(t)}function mf(t,e){return yf(t.flatMap(n=>wf(n,e)))}function vf(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}_f(r,"strip",e,n)}return{valid:e.length===0,errors:e}}function $s(t){const e=gf(t),n=vf(e);if(!n.valid)throw new Error(`Invalid layout: ${n.errors.join("; ")}`);return{totalNodes:e.length,nodes:e.filter(r=>r.type!=="row").map(kE)}}function yf(t){const e=[];for(const n of t){const r=bf(n);for(const s of r){if(s.type==="row"){e.push(...s.children.map(Ut));continue}e.push(s)}}return e}function bf(t){switch(t.type){case"card":return[Ut(t)];case"row":{const e=t.children.map(Ut);return e.length===0?[]:e.length===1?[e[0]]:[{...t,children:e}]}case"stack":{const e=[];for(const n of t.children){const r=bf(n);for(const s of r){if(s.type==="stack"){e.push(...s.children.map(fl));continue}if(s.type==="row"){e.push({...s,children:s.children.map(Ut)});continue}e.push(Ut(s))}}return e.length===0?[]:e.length===1?[fl(e[0])]:[{...t,children:e}]}}}function wf(t,e){switch(t.type){case"card":return t.artifactID===e?[]:[Ut(t)];case"row":{const n=t.children.filter(r=>r.artifactID!==e).map(Ut);return n.length===0?[]:n.length===1?[n[0]]:[{...t,children:n}]}case"stack":{const n=t.children.flatMap(r=>wf(r,e).filter(i=>i.type!=="stack"));return n.length===0?[]:n.length===1?[fl(n[0])]:[{...t,children:n}]}}}function _f(t,e,n,r){switch(t.type){case"card":Sf(t,e,n,r);return;case"row":wE(t,e,n,r);return;case"stack":_E(t,e,n,r);return}}function Sf(t,e,n,r){Cc(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),SE(t.width)||n.push(`Card ${t.id} width must be an integer in the range 2-4`),kf(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<ff&&n.push(`Row child ${t.id} must be at least 2 columns wide`)}function wE(t,e,n,r){if(Cc(t.id,n),e!=="stack"&&n.push(`Row ${t.id} may only appear inside a stack`),kf(t.height,bE)||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}Sf(i,"row",n,r),s+=En(i.width)}s!==St&&n.push(`Row ${t.id} children must sum to 4 columns`)}function _E(t,e,n,r){if(Cc(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(_f(a,"stack",n,r),a.height===sn){i+=1;continue}s+=a.height}if(s>He&&n.push(`Stack ${t.id} exceeds the 6-row budget`),i===0)return;const o=He-s;if(o<i*pl||o%i!==0){n.push(`Stack ${t.id} has auto-height children that cannot resolve to whole height >= 2`);return}o/i<pl&&n.push(`Stack ${t.id} has auto-height children below the minimum row size`)}function Cc(t,e){(typeof t!="string"||t.length===0)&&e.push(`Node id must be a non-empty string: ${String(t)}`)}function SE(t){return t===Tc||Number.isInteger(t)&&t>=ff&&t<=fE}function kf(t,e=gE){return t===sn||Number.isInteger(t)&&t>=pl&&t<=e}function En(t){return t===Tc?St:t}function kE(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:Ef(t.height,He)}]};const e=EE(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 EE(t){let e=0,n=0;for(const s of t)s.height===sn?n+=1:e+=s.height;const r=n>0?(He-e)/n:0;return t.map(s=>Ef(s.height,r))}function Ef(t,e){return t===sn?e:t}function Ut(t){return{...t}}function fl(t){return t.type==="card"?Ut(t):{...t,children:t.children.map(Ut)}}function $f(t,e={}){return{id:e.id??xc(),type:"card",artifactID:t,width:e.width??Tc,height:e.height??sn}}function Af(t,e){return t.some(n=>xf(n,e))}function xf(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=>xf(n,e))}}function rd(t){return t.layout.flatMap(Tf)}function Tf(t){switch(t.type){case"card":return[t.artifactID];case"row":return t.children.map(e=>e.artifactID);case"stack":return t.children.flatMap(Tf)}}const te=et(),Cf=et(),ss=et(),$E=et();function AE(t){class e extends Error{constructor(r,s){super(r),this.name=t,s&&Object.assign(this,s)}}return e}const xE=AE("RequestError"),TE=200,CE=300;class IE{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 PE(s);if(!s.ok||s.status<TE||s.status>=CE)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 Fa(r,r.statusText),r.status)}async requestText(e,n){const r=await this.request(e,n);if(!r.ok)throw this.createError(await Fa(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 Fa(s,s.statusText),s.status)}createError(e,n){const r={serverURL:this.serverURL};return n!==void 0&&(r.status=n),new xE(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 PE(t){try{return await t.json()}catch{const e=await t.text().catch(()=>"");return e?{message:e}:{}}}async function Fa(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 If(t){return t.map(e=>`${e.name} (${e.id})`).join(", ")}var mt,Eo,Pf;class RE{constructor(e){$(this,Eo);$(this,mt);x(this,mt,e)}list(){return u(this,mt).requestJSON("GET","/screens")}async get(e={}){const n=await b(this,Eo,Pf).call(this,e.screenID);return u(this,mt).requestJSON("GET",`/screens/${encodeURIComponent(n)}`)}create(e){const n={name:e.name};return e.id!==void 0&&(n.id=e.id),u(this,mt).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),u(this,mt).requestJSON("PATCH",`/screens/${encodeURIComponent(e.screenID)}`,n)}remove(e){return u(this,mt).requestJSON("DELETE",`/screens/${encodeURIComponent(e.screenID)}`)}}mt=new WeakMap,Eo=new WeakSet,Pf=async function(e){if(e!==void 0)return e;const{screens:n}=await this.list();if(n.length===1)return n[0].id;throw u(this,mt).createError(`screenID is required when multiple screens exist. Available screens: ${If(n)}`)};var Ne,Ds,$o,Rf;class DE{constructor(e,n){$(this,$o);$(this,Ne);$(this,Ds);x(this,Ne,e),x(this,Ds,n)}async create(e){const n=await b(this,$o,Rf).call(this,e.screenID);return u(this,Ne).requestJSON("POST",`/screens/${encodeURIComponent(n)}/artifact`,{type:e.type,title:e.title,externalFilePath:e.externalFilePath})}get(e){return u(this,Ne).requestJSON("GET",`/artifacts/${encodeURIComponent(e.artifactID)}`)}update(e){const n={};return e.title!==void 0&&(n.title=e.title),u(this,Ne).requestJSON("PATCH",`/artifacts/${encodeURIComponent(e.artifactID)}`,n)}edit(e){return u(this,Ne).requestJSON("POST",`/artifacts/${encodeURIComponent(e.artifactID)}/edit`)}commitPending(e){return u(this,Ne).requestJSON("POST",`/artifacts/${encodeURIComponent(e.artifactID)}/commit`)}abandonPending(e){return u(this,Ne).requestVoid("POST",`/artifacts/${encodeURIComponent(e.artifactID)}/abandon`)}remove(e){return u(this,Ne).requestJSON("DELETE",`/screens/${encodeURIComponent(e.screenID)}/artifacts/${encodeURIComponent(e.artifactID)}`)}getContent(e){return u(this,Ne).requestText("GET",`/artifacts/${encodeURIComponent(e.artifactID)}/content`)}putContent(e){return u(this,Ne).requestRawVoid("PUT",`/artifacts/${encodeURIComponent(e.artifactID)}/content`,e.content)}}Ne=new WeakMap,Ds=new WeakMap,$o=new WeakSet,Rf=async function(e){if(e!==void 0)return e;const{screens:n}=await u(this,Ds).list();if(n.length===1)return n[0].id;throw u(this,Ne).createError(`screenID is required when multiple screens exist. Available screens: ${If(n)}`)};var Os;class OE{constructor(e){$(this,Os);x(this,Os,e)}async list(){const{views:e}=await u(this,Os).requestJSON("GET","/views");return e}}Os=new WeakMap;var Vt;class zE{constructor(e,n={}){v(this,"screens");v(this,"artifacts");v(this,"views");$(this,Vt);x(this,Vt,new IE(e,n)),this.screens=new RE(u(this,Vt)),this.artifacts=new DE(u(this,Vt),this.screens),this.views=new OE(u(this,Vt))}health(){return u(this,Vt).requestJSON("GET","/health")}}Vt=new WeakMap;const LE=Hr(kt);var Cn,Ue,In,De,Ht,qt,Q,ur,Df,zs,Of,zf,Lf,Mf,gl,ml,vl,Nf;class ME extends LE{constructor(n){var s;super();$(this,Q);v(this,"id");v(this,"server");$(this,Cn);$(this,Ue,new Map);$(this,In);$(this,De);$(this,Ht);$(this,qt,null);$(this,zs,n=>{if(this.disposed)return;const r=n.event;switch(r.type){case"screen-updated":r.screen.id===this.id&&b(this,Q,Of).call(this,r.screen);break;case"artifact-created":r.screenID===this.id&&b(this,Q,zf).call(this,r.artifact);break;case"artifact-updated":b(this,Q,Lf).call(this,r.artifact);break;case"artifact-removed":r.screenID===this.id&&b(this,Q,Mf).call(this,r.artifactID);break;case"artifact-content-changed":u(this,Ue).has(r.artifactID)&&this.dispatchEvent(new $E("artifact-content-changed",{artifactID:r.artifactID}));break}});this.id=n.screen.id,this.server=n.server,x(this,Cn,n.localStore),x(this,In,n.screen.name),x(this,De,structuredClone(n.screen.layout));const r=((s=u(this,Cn).get().screens[this.id])==null?void 0:s.scrollPosition)??0;x(this,Ht,Math.max(0,r)),this.server.addEventListener("server-event",u(this,zs)),b(this,Q,Df).call(this)}get name(){return u(this,In)}get layout(){return u(this,De)}get scrollPosition(){return u(this,Ht)}get artifacts(){return u(this,Ue)}setScrollPosition(n){b(this,Q,ur).call(this);const r=Math.max(0,n);r!==u(this,Ht)&&(x(this,Ht,r),b(this,Q,Nf).call(this),this.dispatchEvent(new te("change")))}setLayout(n){b(this,Q,ur).call(this);const r=gf(n);if(!vf(r).valid)return;const i=b(this,Q,ml).call(this);x(this,De,r),x(this,qt,{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=u(this,qt))==null?void 0:o.layout)===r&&(x(this,qt,null),b(this,Q,vl).call(this,i),this.dispatchEvent(new te("change")))})}rename(n){b(this,Q,ur).call(this),x(this,In,n),this.dispatchEvent(new te("change")),this.server.client.screens.update({screenID:this.id,name:n}).catch(()=>{})}async remove(){b(this,Q,ur).call(this),await this.server.client.screens.remove({screenID:this.id})}removeArtifact(n){if(b(this,Q,ur).call(this),!u(this,Ue).has(n))return;const r=b(this,Q,ml).call(this);b(this,Q,gl).call(this,n),this.dispatchEvent(new te("change")),this.server.client.artifacts.remove({artifactID:n,screenID:this.id}).catch(()=>{this.disposed||(b(this,Q,vl).call(this,r),this.dispatchEvent(new te("change")))})}dispose(){this.server.removeEventListener("server-event",u(this,zs))}}Cn=new WeakMap,Ue=new WeakMap,In=new WeakMap,De=new WeakMap,Ht=new WeakMap,qt=new WeakMap,Q=new WeakSet,ur=function(){if(this.disposed)throw new Error("ScreenModel is disposed")},Df=async function(){try{const n=await this.server.client.screens.get({screenID:this.id});if(this.disposed)return;for(const r of n.artifacts)u(this,Ue).set(r.id,r);this.dispatchEvent(new te("change"))}catch{}},zs=new WeakMap,Of=function(n){u(this,qt)&&x(this,qt,null),x(this,In,n.name),x(this,De,structuredClone(n.layout)),this.dispatchEvent(new te("change"))},zf=function(n){Af(u(this,De),n.id)||x(this,De,[...u(this,De),$f(n.id)]),u(this,Ue).set(n.id,n),this.dispatchEvent(new te("change"))},Lf=function(n){const r=u(this,Ue).get(n.id);r&&(u(this,Ue).set(n.id,{...r,...n}),this.dispatchEvent(new te("change")))},Mf=function(n){b(this,Q,gl).call(this,n)&&this.dispatchEvent(new te("change"))},gl=function(n){const r=u(this,Ue).delete(n),s=rd({layout:u(this,De)}).length,i=mf(u(this,De),n),o=rd({layout:i}).length;return x(this,De,i),r||s!==o},ml=function(){return{layout:structuredClone(u(this,De)),artifacts:new Map([...u(this,Ue).entries()].map(([n,r])=>[n,structuredClone(r)]))}},vl=function(n){x(this,De,structuredClone(n.layout)),u(this,Ue).clear();for(const[r,s]of n.artifacts)u(this,Ue).set(r,structuredClone(s))},Nf=function(){const n=u(this,Cn).get();u(this,Cn).set({...n,screens:{...n.screens,[this.id]:{scrollPosition:u(this,Ht)}}})};const NE=Hr(kt);var Fe,vt,nt,Ls,Ms,Ns,nn,to,Uf;class UE extends NE{constructor(n){super();$(this,nn);$(this,Fe);$(this,vt);$(this,nt,null);$(this,Ls,()=>{this.disposed||b(this,nn,to).call(this)});$(this,Ms,()=>{this.disposed||b(this,nn,to).call(this)});$(this,Ns,n=>{var s;if(this.disposed)return;const r=n.event;r.type==="screen-removed"&&((s=u(this,nt))==null?void 0:s.id)===r.screenID&&this.clearActive()});x(this,Fe,n.localStore),x(this,vt,n.serverManager),u(this,Fe).addEventListener("change",u(this,Ls)),u(this,vt).addEventListener("change",u(this,Ms)),u(this,vt).addEventListener("server-event",u(this,Ns)),b(this,nn,to).call(this)}get activeScreen(){return u(this,nt)}setActive(n,r){const s=u(this,Fe).get();s.activeServerURL===n&&s.activeScreenID===r||u(this,Fe).set({...s,activeServerURL:n,activeScreenID:r})}clearActive(){const n=u(this,Fe).get();n.activeServerURL===null&&n.activeScreenID===null||u(this,Fe).set({...n,activeServerURL:null,activeScreenID:null})}dispose(){var n;u(this,Fe).removeEventListener("change",u(this,Ls)),u(this,vt).removeEventListener("change",u(this,Ms)),u(this,vt).removeEventListener("server-event",u(this,Ns)),(n=u(this,nt))==null||n.dispose(),x(this,nt,null)}}Fe=new WeakMap,vt=new WeakMap,nt=new WeakMap,Ls=new WeakMap,Ms=new WeakMap,Ns=new WeakMap,nn=new WeakSet,to=function(){var l,c,d;const{activeServerURL:n,activeScreenID:r}=u(this,Fe).get();let s=n?u(this,vt).servers.get(n)??null:null,i=s&&r?s.screens.get(r)??null:null;if(!i){const p=b(this,nn,Uf).call(this);if(p){s=p.server,i=p.screen,u(this,Fe).set({...u(this,Fe).get(),activeServerURL:p.server.url,activeScreenID:p.screen.id});return}}const o=((l=u(this,nt))==null?void 0:l.id)??null,a=(i==null?void 0:i.id)??null;o===a&&((c=u(this,nt))==null?void 0:c.server)===s||((d=u(this,nt))==null||d.dispose(),x(this,nt,s&&i?new ME({screen:i,server:s,localStore:u(this,Fe)}):null),this.dispatchEvent(new oE("active-screen-changed")))},Uf=function(){for(const n of u(this,vt).servers.values()){const r=n.screens.values().next().value;if(r)return{server:n,screen:r}}return null};const FE="Local",ZE="store-";function Pt(t){return new URL(t).origin}function jE(t){return{servers:[{url:Pt(t),name:FE}],activeServerURL:null,activeScreenID:null,screens:{}}}var Pn,Rn,Dn;class WE extends kt{constructor(n,r,s={}){super();$(this,Pn);$(this,Rn);$(this,Dn);x(this,Pn,`${ZE}${n}`),x(this,Rn,s.storage??BE());const i=u(this,Rn).getItem(u(this,Pn));i===null?(x(this,Dn,r),u(this,Rn).setItem(u(this,Pn),JSON.stringify(r))):x(this,Dn,JSON.parse(i))}get(){return u(this,Dn)}set(n){x(this,Dn,n),u(this,Rn).setItem(u(this,Pn),JSON.stringify(n)),this.dispatchEvent(new te("change"))}}Pn=new WeakMap,Rn=new WeakMap,Dn=new WeakMap;function BE(){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 p=0;p<d.length;p++){const y=d[p];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 _r extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Ff extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}}const Zf={};function on(t){return Zf}function jf(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 yl(t,e){return typeof e=="bigint"?e.toString():e}function Ic(t){return{get value(){{const e=t();return Object.defineProperty(this,"value",{value:e}),e}}}}function Pc(t){return t==null}function Rc(t){const e=t.startsWith("^")?1:0,n=t.endsWith("$")?t.length-1:t.length;return t.slice(e,n)}function GE(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 sd=Symbol("evaluating");function ee(t,e,n){let r;Object.defineProperty(t,e,{get(){if(r!==sd)return r===void 0&&(r=sd,r=n()),r},set(s){Object.defineProperty(t,e,{value:s})},configurable:!0})}function Jn(t,e,n){Object.defineProperty(t,e,{value:n,writable:!0,enumerable:!0,configurable:!0})}function pn(...t){const e={};for(const n of t){const r=Object.getOwnPropertyDescriptors(n);Object.assign(e,r)}return Object.defineProperties({},e)}function id(t){return JSON.stringify(t)}function VE(t){return t.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Wf="captureStackTrace"in Error?Error.captureStackTrace:(...t)=>{};function fo(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}const HE=Ic(()=>{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 zr(t){if(fo(t)===!1)return!1;const e=t.constructor;if(e===void 0||typeof e!="function")return!0;const n=e.prototype;return!(fo(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function Bf(t){return zr(t)?{...t}:Array.isArray(t)?[...t]:t}const qE=new Set(["string","number","symbol"]);function Lr(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function fn(t,e,n){const r=new t._zod.constr(e??t._zod.def);return(!e||n!=null&&n.parent)&&(r._zod.parent=t),r}function O(t){const e=t;if(!e)return{};if(typeof e=="string")return{error:()=>e};if((e==null?void 0:e.message)!==void 0){if((e==null?void 0:e.error)!==void 0)throw new Error("Cannot specify both `message` and `error` params");e.error=e.message}return delete e.message,typeof e.error=="string"?{...e,error:()=>e.error}:e}function YE(t){return Object.keys(t).filter(e=>t[e]._zod.optin==="optional"&&t[e]._zod.optout==="optional")}const KE={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function JE(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=pn(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 Jn(this,"shape",o),o},checks:[]});return fn(t,i)}function XE(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=pn(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 Jn(this,"shape",o),o},checks:[]});return fn(t,i)}function QE(t,e){if(!zr(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=pn(t._zod.def,{get shape(){const i={...t._zod.def.shape,...e};return Jn(this,"shape",i),i}});return fn(t,s)}function e$(t,e){if(!zr(e))throw new Error("Invalid input to safeExtend: expected a plain object");const n=pn(t._zod.def,{get shape(){const r={...t._zod.def.shape,...e};return Jn(this,"shape",r),r}});return fn(t,n)}function t$(t,e){const n=pn(t._zod.def,{get shape(){const r={...t._zod.def.shape,...e._zod.def.shape};return Jn(this,"shape",r),r},get catchall(){return e._zod.def.catchall},checks:[]});return fn(t,n)}function n$(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=pn(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 Jn(this,"shape",l),l},checks:[]});return fn(e,o)}function r$(t,e,n){const r=pn(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 Jn(this,"shape",i),i}});return fn(e,r)}function yr(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 br(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 an(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 Dc(t){return Array.isArray(t)?"array":typeof t=="string"?"string":"unknown"}function Ts(...t){const[e,n,r]=t;return typeof e=="string"?{message:e,code:"custom",input:n,inst:r}:{...e}}const Gf=(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,yl,2),Object.defineProperty(t,"toString",{value:()=>t.message,enumerable:!1})},Vf=S("$ZodError",Gf),Hf=S("$ZodError",Gf,{Parent:Error});function s$(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 i$(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 Oc=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 _r;if(o.issues.length){const a=new((s==null?void 0:s.Err)??t)(o.issues.map(l=>an(l,i,on())));throw Wf(a,s==null?void 0:s.callee),a}return o.value},zc=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=>an(l,i,on())));throw Wf(a,s==null?void 0:s.callee),a}return o.value},Zo=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 _r;return i.issues.length?{success:!1,error:new(t??Vf)(i.issues.map(o=>an(o,s,on())))}:{success:!0,data:i.value}},o$=Zo(Hf),jo=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=>an(o,s,on())))}:{success:!0,data:i.value}},a$=jo(Hf),l$=t=>(e,n,r)=>{const s=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Oc(t)(e,n,s)},c$=t=>(e,n,r)=>Oc(t)(e,n,r),u$=t=>async(e,n,r)=>{const s=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return zc(t)(e,n,s)},h$=t=>async(e,n,r)=>zc(t)(e,n,r),d$=t=>(e,n,r)=>{const s=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Zo(t)(e,n,s)},p$=t=>(e,n,r)=>Zo(t)(e,n,r),f$=t=>async(e,n,r)=>{const s=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return jo(t)(e,n,s)},g$=t=>async(e,n,r)=>jo(t)(e,n,r),m$=/^[cC][^\s-]{8,}$/,v$=/^[0-9a-z]+$/,y$=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,b$=/^[0-9a-vA-V]{20}$/,w$=/^[A-Za-z0-9]{27}$/,_$=/^[a-zA-Z0-9_-]{21}$/,S$=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,k$=/^([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})$/,od=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)$/,E$=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,$$="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function A$(){return new RegExp($$,"u")}const x$=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,T$=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,C$=/^((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])$/,I$=/^(([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])$/,P$=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,qf=/^[A-Za-z0-9_-]*$/,R$=/^\+[1-9]\d{6,14}$/,Yf="(?:(?:\\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])))",D$=new RegExp(`^${Yf}$`);function Kf(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 O$(t){return new RegExp(`^${Kf(t)}$`)}function z$(t){const e=Kf({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(`^${Yf}T(?:${r})$`)}const L$=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}$`)},M$=/^-?\d+$/,Jf=/^-?\d+(?:\.\d+)?$/,N$=/^(?:true|false)$/i,U$=/^[^A-Z]*$/,F$=/^[^a-z]*$/,We=S("$ZodCheck",(t,e)=>{var n;t._zod??(t._zod={}),t._zod.def=e,(n=t._zod).onattach??(n.onattach=[])}),Xf={number:"number",bigint:"bigint",object:"date"},Qf=S("$ZodCheckLessThan",(t,e)=>{We.init(t,e);const n=Xf[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})}}),eg=S("$ZodCheckGreaterThan",(t,e)=>{We.init(t,e);const n=Xf[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})}}),Z$=S("$ZodCheckMultipleOf",(t,e)=>{We.init(t,e),t._zod.onattach.push(n=>{var r;(r=n._zod.bag).multipleOf??(r.multipleOf=e.value)}),t._zod.check=n=>{if(typeof n.value!=typeof e.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%e.value===BigInt(0):GE(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})}}),j$=S("$ZodCheckNumberFormat",(t,e)=>{var o;We.init(t,e),e.format=e.format||"float64";const n=(o=e.format)==null?void 0:o.includes("int"),r=n?"int":"number",[s,i]=KE[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=M$)}),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})}}),W$=S("$ZodCheckMaxLength",(t,e)=>{var n;We.init(t,e),(n=t._zod.def).when??(n.when=r=>{const s=r.value;return!Pc(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=Dc(s);r.issues.push({origin:o,code:"too_big",maximum:e.maximum,inclusive:!0,input:s,inst:t,continue:!e.abort})}}),B$=S("$ZodCheckMinLength",(t,e)=>{var n;We.init(t,e),(n=t._zod.def).when??(n.when=r=>{const s=r.value;return!Pc(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=Dc(s);r.issues.push({origin:o,code:"too_small",minimum:e.minimum,inclusive:!0,input:s,inst:t,continue:!e.abort})}}),G$=S("$ZodCheckLengthEquals",(t,e)=>{var n;We.init(t,e),(n=t._zod.def).when??(n.when=r=>{const s=r.value;return!Pc(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=Dc(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})}}),Wo=S("$ZodCheckStringFormat",(t,e)=>{var n,r;We.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=()=>{})}),V$=S("$ZodCheckRegex",(t,e)=>{Wo.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})}}),H$=S("$ZodCheckLowerCase",(t,e)=>{e.pattern??(e.pattern=U$),Wo.init(t,e)}),q$=S("$ZodCheckUpperCase",(t,e)=>{e.pattern??(e.pattern=F$),Wo.init(t,e)}),Y$=S("$ZodCheckIncludes",(t,e)=>{We.init(t,e);const n=Lr(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})}}),K$=S("$ZodCheckStartsWith",(t,e)=>{We.init(t,e);const n=new RegExp(`^${Lr(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})}}),J$=S("$ZodCheckEndsWith",(t,e)=>{We.init(t,e);const n=new RegExp(`.*${Lr(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})}}),X$=S("$ZodCheckOverwrite",(t,e)=>{We.init(t,e),t._zod.check=n=>{n.value=e.tx(n.value)}});class Q${constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if(typeof e=="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}const r=e.split(`
|
|
4
|
+
`+e.prev}function Ri(t,e){var n=ul(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 Ia=="function"?Ia(t):[],o;if(Or){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||Or&&o["$"+l]instanceof Symbol||(Mp.call(/[^\w$]/,l)?r.push(e(l,t)+": "+e(t[l],t)):r.push(l+": "+e(t[l],t))));if(typeof Ia=="function")for(var c=0;c<i.length;c++)Np.call(t,i[c])&&r.push("["+e(i[c])+"]: "+e(t[i[c]],t));return r}var R_=Br,D_=V,Mo=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},O_=function(t,e){if(t){var n=Mo(t,e);return n&&n.value}},z_=function(t,e,n){var r=Mo(t,e);r?r.value=n:t.next={key:e,next:t.next,value:n}},L_=function(t,e){return t?!!Mo(t,e):!1},M_=function(t,e){if(t)return Mo(t,e,!0)},N_=function(){var e,n={assert:function(r){if(!n.has(r))throw new D_("Side channel does not contain "+R_(r))},delete:function(r){var s=e&&e.next,i=M_(e,r);return i&&s&&s===i&&(e=void 0),!!i},get:function(r){return O_(e,r)},has:function(r){return L_(e,r)},set:function(r,s){e||(e={next:void 0}),z_(e,r,s)}};return n},U_=Qe,pi=hn,F_=Br,Z_=V,wh=U_("%Map%",!0),j_=pi("Map.prototype.get",!0),W_=pi("Map.prototype.set",!0),B_=pi("Map.prototype.has",!0),G_=pi("Map.prototype.delete",!0),V_=pi("Map.prototype.size",!0),Bp=!!wh&&function(){var e,n={assert:function(r){if(!n.has(r))throw new Z_("Side channel does not contain "+F_(r))},delete:function(r){if(e){var s=G_(e,r);return V_(e)===0&&(e=void 0),s}return!1},get:function(r){if(e)return j_(e,r)},has:function(r){return e?B_(e,r):!1},set:function(r,s){e||(e=new wh),W_(e,r,s)}};return n},H_=Qe,No=hn,q_=Br,Di=Bp,Y_=V,ar=H_("%WeakMap%",!0),K_=No("WeakMap.prototype.get",!0),J_=No("WeakMap.prototype.set",!0),X_=No("WeakMap.prototype.has",!0),Q_=No("WeakMap.prototype.delete",!0),eS=ar?function(){var e,n,r={assert:function(s){if(!r.has(s))throw new Y_("Side channel does not contain "+q_(s))},delete:function(s){if(ar&&s&&(typeof s=="object"||typeof s=="function")){if(e)return Q_(e,s)}else if(Di&&n)return n.delete(s);return!1},get:function(s){return ar&&s&&(typeof s=="object"||typeof s=="function")&&e?K_(e,s):n&&n.get(s)},has:function(s){return ar&&s&&(typeof s=="object"||typeof s=="function")&&e?X_(e,s):!!n&&n.has(s)},set:function(s,i){ar&&s&&(typeof s=="object"||typeof s=="function")?(e||(e=new ar),J_(e,s,i)):Di&&(n||(n=Di()),n.set(s,i))}};return r}:Di,tS=V,nS=Br,rS=N_,sS=Bp,iS=eS,oS=iS||sS||rS,aS=function(){var e,n={assert:function(r){if(!n.has(r))throw new tS("Side channel does not contain "+nS(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=oS()),e.set(r,s)}};return n},lS=jt,rs=aS(),xt=V,mc={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),!mc.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&&lS(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(mc);var vc=mc,Gp=Ft,rn=vc,fi=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 Gp('Assertion failed: `type` must be one of "normal", "break", "continue", "return", or "throw"');rn.set(this,"[[Type]]",e),rn.set(this,"[[Value]]",n)};fi.prototype.type=function(){return rn.get(this,"[[Type]]")};fi.prototype.value=function(){return rn.get(this,"[[Value]]")};fi.prototype["?"]=function(){var e=rn.get(this,"[[Type]]"),n=rn.get(this,"[[Value]]");if(e==="throw")throw n;return n};fi.prototype["!"]=function(){var e=rn.get(this,"[[Type]]");if(e!=="normal")throw new Gp('Assertion failed: Completion Record is not of type "normal"');return rn.get(this,"[[Value]]")};var yc=fi,cS=yc,bc=function(e){return new cS("normal",e)},Ra,_h;function uS(){if(_h)return Ra;_h=1;var t=Fr;return Ra=function(){return t()&&!!Symbol.toStringTag},Ra}var hS=Qe,Sh=hS("%Object.defineProperty%",!0),dS=uS()(),pS=jt,fS=V,Oi=dS?Symbol.toStringTag:null,Vp=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 fS("if provided, the `overrideIfSet` and `nonConfigurable` options must be booleans");Oi&&(r||!pS(e,Oi))&&(Sh?Sh(e,Oi,{configurable:!s,enumerable:!1,value:n,writable:!1}):e[Oi]=n)},Hp={exports:{}},gS=Qe,kh=up,mS=Oo(),Eh=Ur,$h=V,vS=gS("%Math.floor%"),yS=function(e,n){if(typeof e!="function")throw new $h("`fn` is not a function");if(typeof n!="number"||n<0||n>4294967295||vS(n)!==n)throw new $h("`length` must be a positive 32-bit integer");var r=arguments.length>2&&!!arguments[2],s=!0,i=!0;if("length"in e&&Eh){var o=Eh(e,"length");o&&!o.configurable&&(s=!1),o&&!o.writable&&(i=!1)}return(s||i||!r)&&(mS?kh(e,"length",n,!0,!0):kh(e,"length",n)),e},bS=li,wS=oc,_S=_p,SS=function(){return _S(bS,wS,arguments)};(function(t){var e=yS,n=ai,r=zo,s=SS;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})(Hp);var wc=Hp.exports,kS=function(e,n){for(var r=0;r<e.length;r+=1)if(!n(e[r],r,e))return!1;return!0},ES=Object,$S=function(e){return e&&typeof e=="object"&&(typeof e["[[ResourceValue]]"]>"u"||ES(e["[[ResourceValue]]"])===e["[[ResourceValue]]"])&&(e["[[Hint]]"]==="SYNC-DISPOSE"||e["[[Hint]]"]==="ASYNC-DISPOSE")&&(typeof e["[[DisposeMethod]]"]=="function"||typeof e["[[DisposeMethod]]"]>"u")},AS=jt,xS=ac(),TS=kS,CS=$S,IS=function(e){return e&&typeof e=="object"&&AS(e,"[[DisposableResourceStack]]")&&xS(e["[[DisposableResourceStack]]"])&&(e["[[DisposableResourceStack]]"].length===0||TS(e["[[DisposableResourceStack]]"],CS))},PS=Zt,RS=function(e){if(e===null)return"Null";if(typeof e>"u")return"Undefined";if(PS(e))return"Object";if(typeof e=="number")return"Number";if(typeof e=="boolean")return"Boolean";if(typeof e=="string")return"String"},DS=RS,_c=function(e){return typeof e=="symbol"?"Symbol":typeof e=="bigint"?"BigInt":DS(e)},OS=V,zS=Br,LS=jr,MS=function(e,n){if(!LS(n))throw new OS("Assertion failed: P is not a Property Key, got "+zS(n));return e[n]},Ah=V,NS=MS,US=Wr,FS=jr,xh=Br,ZS=function(e,n){if(!FS(n))throw new Ah("Assertion failed: P is not a Property Key");var r=NS(e,n);if(r!=null){if(!US(r))throw new Ah(xh(n)+" is not a function: "+xh(r));return r}},dl={exports:{}},jS=Qe,WS=jS,Th=WS("%Reflect.construct%",!0),ho=di;try{ho({},"",{"[[Get]]":function(){}})}catch{ho=null}if(ho&&Th){var Ch={},Ih={};ho(Ih,"length",{"[[Get]]":function(){throw Ch},"[[Enumerable]]":!0}),dl.exports=function(e){try{Th(e,Ih)}catch(n){return n===Ch}}}else dl.exports=function(e){return typeof e=="function"&&!!e.prototype};var BS=dl.exports,Da=V,Ph=Wr,GS=BS,VS=function(e){if(!GS(e))throw new Da("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 Da("executor has already been called");n["[[Resolve]]"]=s,n["[[Reject]]"]=i});if(!Ph(n["[[Resolve]]"])||!Ph(n["[[Reject]]"]))throw new Da("executor must provide valid resolve and reject functions");return{"[[Promise]]":r,"[[Resolve]]":n["[[Resolve]]"],"[[Reject]]":n["[[Reject]]"]}},Rh=Ft,HS=V,Oa=Lo,Dh=ZS,qS=VS,YS=_c,Oh=hc(),zh=dc(),KS=function(e,n){if(YS(e)!=="Object")throw new HS("`V` must be an Object");if(n!=="SYNC-DISPOSE"&&n!=="ASYNC-DISPOSE")throw new Rh("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");var r;if(n==="ASYNC-DISPOSE"&&zh&&(r=Dh(e,zh)),!r){if(!Oh)throw new Rh("`Symbol.dispose` is not supported");if(r=Dh(e,Oh),typeof r<"u")return function(){var s=this;if(n==="ASYNC-DISPOSE"){var i=qS(Promise);try{Oa(r,s),Oa(i["[[Resolve]]"],void 0,[void 0])}catch(o){i["[[Reject]]"](o)}return i["[[Promise]]"]}Oa(r,s)}}return r},JS=Ft,za=V,XS=Wr,QS=_c,ek=KS,tk=function(e,n){if(n!=="SYNC-DISPOSE"&&n!=="ASYNC-DISPOSE")throw new JS("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"&&QS(e)!=="Object")throw new za("`V` must be an Object, or `null` or `undefined`");if(r=ek(e,n),typeof r>"u")throw new za("dispose method must not be `undefined` on `V` when an object `V` is provided")}else if(r=arguments[2],!XS(r))throw new za("`method`, when provided, must be a function");return{"[[ResourceValue]]":e,"[[Hint]]":n,"[[DisposeMethod]]":r}},nk=Ft,zi=V,rk=IS,Lh=tk,sk=hn,ik=sk("Array.prototype.push"),qp=function(e,n,r){if(!rk(e))throw new zi("Assertion failed: `disposeCapability` must be a DisposeCapability Record");if(r!=="SYNC-DISPOSE"&&r!=="ASYNC-DISPOSE")throw new nk("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=Lh(n,r)}else{if(typeof n<"u")throw new zi("Assertion failed: `V` must be undefined when `method` is present");i=Lh(void 0,r,s)}return ik(e["[[DisposableResourceStack]]"],i),"UNUSED"},La,Mh;function Sc(){if(Mh)return La;Mh=1;var t=Qe,e=wc,n=Ft,r=t("%Promise.resolve%",!0),s=r&&e(r);return La=function(o,a){if(!s)throw new n("This environment does not support Promises.");return s(o,a)},La}var Ma,Nh;function ok(){if(Nh)return Ma;Nh=1;var t=Qe,e=Ft,n=t("%Promise%",!0),r=Lo,s=Sc(),i=_c;return Ma=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)},Ma}var Na,Uh;function ak(){if(Uh)return Na;Uh=1;var t=yc;return Na=function(n){return new t("throw",n)},Na}var lk=Qe,Ua=Ft,Fh=V,ck=lk("%Promise%",!0),uk=hn,Zh=uk("Promise.prototype.then",!0),hk=yc,jh=ok(),dk=bc,pk=Sc(),Wh=ak(),fk=Lp(),Yp=function(e,n){if(!(n instanceof hk))throw new Fh("`completion` must be a Completion Record");var r=e["[[DisposableResourceStack]]"];if(!r)throw new Fh("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 Ua("mixed hint stacks are not supported");for(var o=s==="ASYNC-DISPOSE"&&pk(ck,n),a=function(y){if(n.type()==="throw"){var m=n.value(),E=new fk(y,m);n=Wh(E)}else n=Wh(y)},l=s==="ASYNC-DISPOSE"&&function(m){return Zh(o,function(){var E=jh(m["[[ResourceValue]]"],m["[[Hint]]"],m["[[DisposeMethod]]"]);if(!E)throw new Ua("Assertion failed: non-`~ASYNC-DISPOSE~` resource returned a promise from Dispose");return Zh(E,dk)},a)},c=r.length-1;c>=0;c-=1)if(s==="ASYNC-DISPOSE")o=l(r[c]);else{var d=r[c];try{var p=jh(d["[[ResourceValue]]"],d["[[Hint]]"],d["[[DisposeMethod]]"]);if(p)throw new Ua("Assertion failed: `~SYNC-DISPOSE~` resource returned something from Dispose")}catch(y){a(y)}}return e["[[DisposableResourceStack]]"]=null,s==="ASYNC-DISPOSE"?o:n},Kp=function(){var e=[];return{"[[DisposableResourceStack]]":e}},Uo=nc,kc=V,gk=Lo,Gr=cc,mk=di,Jp=Wr,vk=bc,Ze=vc,yk=Vp,Xp=Yn.supportsDescriptors,bk=wc,Ec=qp,wk=Yp,Qp=Kp,Bh=hc(),Ke=function t(){if(!(this instanceof t)||Ze.has(this,"[[DisposableState]]")||Ze.has(this,"[[DisposeCapability]]"))throw new kc("can only be used with new");Ze.set(this,"[[DisposableState]]","PENDING"),Ze.set(this,"[[DisposeCapability]]",Qp())},ef=function(){var e=this;return Ze.assert(e,"[[DisposableState]]"),Ze.get(e,"[[DisposableState]]")==="DISPOSED"},gi=bk(ef);Xp?mk(Ke.prototype,"disposed",{"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Get]]":ef}):Ke.prototype.disposed=!1;var tf=function(e){Ze.set(e,"[[DisposableState]]","DISPOSED"),Xp||(e.disposed=!0)};Gr(Ke.prototype,"dispose",function(){var e=this;if(!gi(e))return tf(e),wk(Ze.get(e,"[[DisposeCapability]]"),vk())["?"]()});Gr(Ke.prototype,"use",function(e){var n=this;if(gi(n))throw new Uo("a disposed stack can not use anything new");return Ec(Ze.get(n,"[[DisposeCapability]]"),e,"SYNC-DISPOSE"),e});Gr(Ke.prototype,"adopt",function(e,n){var r=this;if(gi(r))throw new Uo("a disposed stack can not use anything new");if(!Jp(n))throw new kc("`onDispose` must be a function");var s=function(){return gk(n,void 0,[e])};return Ec(Ze.get(r,"[[DisposeCapability]]"),void 0,"SYNC-DISPOSE",s),e});Gr(Ke.prototype,"defer",function(e){var n=this;if(gi(n))throw new Uo("a disposed stack can not defer anything new");if(!Jp(e))throw new kc("`onDispose` must be a function");Ec(Ze.get(n,"[[DisposeCapability]]"),void 0,"SYNC-DISPOSE",e)});Gr(Ke.prototype,"move",function(){var e=this;if(gi(e))throw new Uo("a disposed stack can not use anything new");var n=new Ke;return Ze.set(n,"[[DisposeCapability]]",Ze.get(e,"[[DisposeCapability]]")),Ze.set(e,"[[DisposeCapability]]",Qp()),tf(e),n});Bh&&Gr(Ke.prototype,Bh,Ke.prototype.dispose);yk(Ke.prototype,"DisposableStack");var _k=Ke,Sk=_k,kk=function(){return typeof DisposableStack=="function"?DisposableStack:Sk},Ek=Yn,$k=ec(),Ak=kk,xk=function(){var e=Ak();return Ek($k,{DisposableStack:e},{DisposableStack:!0}),e},Tk=Qe,Fo=nc,$c=V,Gh=Tk("%Promise%",!0),Ac=qp,Ck=Lo,Vr=cc,Ik=di,Pk=Yp,nf=Wr,rf=Kp,Rk=bc,Vh=Sc(),je=vc,Dk=Vp,sf=Yn.supportsDescriptors,Ok=wc,zk=hn,Lk=zk("Promise.prototype.then",!0),Hh=dc(),Je=function t(){if(!(this instanceof t)||je.has(this,"[[AsyncDisposableState]]")||je.has(this,"[[DisposeCapability]]"))throw new $c("can only be used with new");je.set(this,"[[AsyncDisposableState]]","pending"),je.set(this,"[[DisposeCapability]]",rf())},of=function(){var e=this;return je.assert(e,"[[AsyncDisposableState]]"),je.get(e,"[[AsyncDisposableState]]")==="disposed"},mi=Ok(of);sf?Ik(Je.prototype,"disposed",{"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Get]]":of}):Je.prototype.disposed=!1;var af=function(e){je.set(e,"[[AsyncDisposableState]]","disposed"),sf||(e.disposed=!0)};Vr(Je.prototype,"disposeAsync",function(){var e=this;return mi(e)?Vh(Gh):(af(e),Lk(Vh(Gh,Pk(je.get(e,"[[DisposeCapability]]"),Rk())),function(n){return n["?"]()}))});Vr(Je.prototype,"use",function(e){var n=this;if(mi(n))throw new Fo("a disposed stack can not use anything new");return Ac(je.get(n,"[[DisposeCapability]]"),e,"ASYNC-DISPOSE"),e});Vr(Je.prototype,"adopt",function(e,n){var r=this;if(mi(r))throw new Fo("a disposed stack can not use anything new");if(!nf(n))throw new $c("`onDisposeAsync` must be a function");var s=function(){return Ck(n,void 0,[e])};return s.value=e,Ac(je.get(r,"[[DisposeCapability]]"),void 0,"ASYNC-DISPOSE",s),e});Vr(Je.prototype,"defer",function(e){var n=this;if(mi(n))throw new Fo("a disposed stack can not defer anything new");if(!nf(e))throw new $c("`onDispose` must be a function");Ac(je.get(n,"[[DisposeCapability]]"),void 0,"ASYNC-DISPOSE",e)});Vr(Je.prototype,"move",function(){var e=this;if(mi(e))throw new Fo("a disposed stack can not use anything new");var n=new Je;return je.set(n,"[[DisposeCapability]]",je.get(e,"[[DisposeCapability]]")),je.set(e,"[[DisposeCapability]]",rf()),af(e),n});Hh&&Vr(Je.prototype,Hh,Je.prototype.disposeAsync);Dk(Je.prototype,"AsyncDisposableStack");var Mk=Je,Nk=Mk,Uk=function(){return typeof AsyncDisposableStack=="function"?AsyncDisposableStack:Nk},Fk=Yn,Zk=ec(),jk=Uk,Wk=function(){var e=jk();return Fk(Zk,{AsyncDisposableStack:e},{AsyncDisposableStack:!0}),e},Bk=Fw,Gk=qw,Vk=xk,Hk=Wk,qk=function(){Bk(),Gk(),Vk(),Hk()};qk();const qh=new WeakMap;function Yk(t){return(typeof t=="object"||typeof t=="function")&&t!==null&&"then"in t&&typeof t.then=="function"}function lr(t){return typeof t=="string"?t:typeof t=="symbol"?t.description??t.toString():t.name||"(anonymous class)"}function Yh(){return new Error("register(Key, factory) requires a factory function. Wrap existing instances as () => instance.")}function Kk(){return new Error("register(Key, factory) does not accept async factories. Await setup before registering.")}class Jk{constructor(){v(this,"entries",new Map);v(this,"constructionStack",[])}register(e,n){if(n===void 0){if(typeof e!="function")throw Yh();this.validateClassRegistration(e),this.storeFactory(e,()=>this.instantiateClass(e));return}if(typeof n!="function")throw Yh();if(n.constructor.name==="AsyncFunction")throw Kk();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=qh.get(e);if(n){if(e.length!==n.length)throw new Error(`${lr(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(`${lr(e)} cannot be registered with register(Class). Undecorated classes must have zero required constructor parameters. Use register(Key, () => value) instead.`)}instantiateClass(e){const n=qh.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(`${lr(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=>lr(s)).join(" -> ");throw new Error(`Circular dependency detected: ${r}`)}this.constructionStack.push(e.key);try{const r=e.factory();if(Yk(r))throw new Error(`Factory for ${lr(e.key)} returned a Promise. Await setup before registering.`);if(typeof r!="object"||r===null)throw new Error(`Factory for ${lr(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 Ve=new Jk,Xk=new Set(["target","currentTarget","eventPhase","defaultPrevented","isTrusted","timeStamp","srcElement","returnValue","cancelBubble","NONE","CAPTURING_PHASE","AT_TARGET","BUBBLING_PHASE","composedPath","stopPropagation","stopImmediatePropagation","preventDefault","initEvent"]);function Qk(t){for(const e of Object.keys(t))if(Xk.has(e))throw new Error(`Event payload key "${e}" is reserved; choose a different property name`)}function eE(t,e){Qk(e);for(const n of Object.keys(e))Object.defineProperty(t,n,{value:e[n],writable:!0,enumerable:!0,configurable:!0})}function et(){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}),eE(this,l)}}return t}class kt extends globalThis.EventTarget{}function tE(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);$(this,n,!1);tE(this,()=>u(this,n),()=>{x(this,n,!0)})}[Symbol.dispose](){this.dispose()}get disposed(){return u(this,n)}}return n=new WeakMap,e}const nE=et(),eo=et(),lf="0123456789ABCDEFGHJKMNPQRSTVWXYZ",po=32,rE=16,cf=10,Kh=0xffffffffffff;var xn;(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"})(xn||(xn={}));class fs extends Error{constructor(e,n){super(`${n} (${e})`),this.name="ULIDError",this.code=e}}function sE(t){const e=Math.floor(t()*po)%po;return lf.charAt(e)}function iE(t){const e=oE(),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 fs(xn.PRNGDetectFailure,"Failed to find a reliable PRNG")}function oE(){return cE()?self:typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:null}function aE(t,e){let n="";for(;t>0;t--)n=sE(e)+n;return n}function lE(t,e=cf){if(isNaN(t))throw new fs(xn.EncodeTimeValueMalformed,`Time must be a number: ${t}`);if(t>Kh)throw new fs(xn.EncodeTimeSizeExceeded,`Cannot encode a time larger than ${Kh}: ${t}`);if(t<0)throw new fs(xn.EncodeTimeNegative,`Time must be positive: ${t}`);if(Number.isInteger(t)===!1)throw new fs(xn.EncodeTimeValueMalformed,`Time must be an integer: ${t}`);let n,r="";for(let s=e;s>0;s--)n=t%po,r=lf.charAt(n)+r,t=(t-n)/po;return r}function cE(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}function xc(t,e){const n=iE(),r=Date.now();return lE(r,cf)+aE(rE,n)}const St=4,He=6,uf=2,pl=2,uE=St,hE=He,Tc="auto",sn="auto",kn=120,Jh=75,de=16,tn=kn*St+de*(St-1),vr=kn*He+de*(He-1),dE=200,pE=4,Li=150,fE=10,Xh=2,gE=4;function hf(t){return ff(t)}function df(t,e){return ff(t.flatMap(n=>mf(n,e)))}function pf(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}vf(r,"strip",e,n)}return{valid:e.length===0,errors:e}}function $s(t){const e=hf(t),n=pf(e);if(!n.valid)throw new Error(`Invalid layout: ${n.errors.join("; ")}`);return{totalNodes:e.length,nodes:e.filter(r=>r.type!=="row").map(bE)}}function ff(t){const e=[];for(const n of t){const r=gf(n);for(const s of r){if(s.type==="row"){e.push(...s.children.map(Ut));continue}e.push(s)}}return e}function gf(t){switch(t.type){case"card":return[Ut(t)];case"row":{const e=t.children.map(Ut);return e.length===0?[]:e.length===1?[e[0]]:[{...t,children:e}]}case"stack":{const e=[];for(const n of t.children){const r=gf(n);for(const s of r){if(s.type==="stack"){e.push(...s.children.map(fl));continue}if(s.type==="row"){e.push({...s,children:s.children.map(Ut)});continue}e.push(Ut(s))}}return e.length===0?[]:e.length===1?[fl(e[0])]:[{...t,children:e}]}}}function mf(t,e){switch(t.type){case"card":return t.artifactID===e?[]:[Ut(t)];case"row":{const n=t.children.filter(r=>r.artifactID!==e).map(Ut);return n.length===0?[]:n.length===1?[n[0]]:[{...t,children:n}]}case"stack":{const n=t.children.flatMap(r=>mf(r,e).filter(i=>i.type!=="stack"));return n.length===0?[]:n.length===1?[fl(n[0])]:[{...t,children:n}]}}}function vf(t,e,n,r){switch(t.type){case"card":yf(t,e,n,r);return;case"row":mE(t,e,n,r);return;case"stack":vE(t,e,n,r);return}}function yf(t,e,n,r){Cc(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),yE(t.width)||n.push(`Card ${t.id} width must be an integer in the range 2-4`),bf(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<uf&&n.push(`Row child ${t.id} must be at least 2 columns wide`)}function mE(t,e,n,r){if(Cc(t.id,n),e!=="stack"&&n.push(`Row ${t.id} may only appear inside a stack`),bf(t.height,gE)||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}yf(i,"row",n,r),s+=En(i.width)}s!==St&&n.push(`Row ${t.id} children must sum to 4 columns`)}function vE(t,e,n,r){if(Cc(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(vf(a,"stack",n,r),a.height===sn){i+=1;continue}s+=a.height}if(s>He&&n.push(`Stack ${t.id} exceeds the 6-row budget`),i===0)return;const o=He-s;if(o<i*pl||o%i!==0){n.push(`Stack ${t.id} has auto-height children that cannot resolve to whole height >= 2`);return}o/i<pl&&n.push(`Stack ${t.id} has auto-height children below the minimum row size`)}function Cc(t,e){(typeof t!="string"||t.length===0)&&e.push(`Node id must be a non-empty string: ${String(t)}`)}function yE(t){return t===Tc||Number.isInteger(t)&&t>=uf&&t<=uE}function bf(t,e=hE){return t===sn||Number.isInteger(t)&&t>=pl&&t<=e}function En(t){return t===Tc?St:t}function bE(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:wf(t.height,He)}]};const e=wE(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 wE(t){let e=0,n=0;for(const s of t)s.height===sn?n+=1:e+=s.height;const r=n>0?(He-e)/n:0;return t.map(s=>wf(s.height,r))}function wf(t,e){return t===sn?e:t}function Ut(t){return{...t}}function fl(t){return t.type==="card"?Ut(t):{...t,children:t.children.map(Ut)}}function _f(t,e={}){return{id:e.id??xc(),type:"card",artifactID:t,width:e.width??Tc,height:e.height??sn}}function Sf(t,e){return t.some(n=>kf(n,e))}function kf(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=>kf(n,e))}}function Qh(t){return t.layout.flatMap(Ef)}function Ef(t){switch(t.type){case"card":return[t.artifactID];case"row":return t.children.map(e=>e.artifactID);case"stack":return t.children.flatMap(Ef)}}const te=et(),$f=et(),ss=et(),_E=et();function SE(t){class e extends Error{constructor(r,s){super(r),this.name=t,s&&Object.assign(this,s)}}return e}const kE=SE("RequestError"),EE=200,$E=300;class AE{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 xE(s);if(!s.ok||s.status<EE||s.status>=$E)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 Fa(r,r.statusText),r.status)}async requestText(e,n){const r=await this.request(e,n);if(!r.ok)throw this.createError(await Fa(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 Fa(s,s.statusText),s.status)}createError(e,n){const r={serverURL:this.serverURL};return n!==void 0&&(r.status=n),new kE(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 xE(t){try{return await t.json()}catch{const e=await t.text().catch(()=>"");return e?{message:e}:{}}}async function Fa(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 Af(t){return t.map(e=>`${e.name} (${e.id})`).join(", ")}var mt,Eo,xf;class TE{constructor(e){$(this,Eo);$(this,mt);x(this,mt,e)}list(){return u(this,mt).requestJSON("GET","/screens")}async get(e={}){const n=await b(this,Eo,xf).call(this,e.screenID);return u(this,mt).requestJSON("GET",`/screens/${encodeURIComponent(n)}`)}create(e){const n={name:e.name};return e.id!==void 0&&(n.id=e.id),u(this,mt).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),u(this,mt).requestJSON("PATCH",`/screens/${encodeURIComponent(e.screenID)}`,n)}remove(e){return u(this,mt).requestJSON("DELETE",`/screens/${encodeURIComponent(e.screenID)}`)}}mt=new WeakMap,Eo=new WeakSet,xf=async function(e){if(e!==void 0)return e;const{screens:n}=await this.list();if(n.length===1)return n[0].id;throw u(this,mt).createError(`screenID is required when multiple screens exist. Available screens: ${Af(n)}`)};var Ne,Ds,$o,Tf;class CE{constructor(e,n){$(this,$o);$(this,Ne);$(this,Ds);x(this,Ne,e),x(this,Ds,n)}async create(e){const n=await b(this,$o,Tf).call(this,e.screenID);return u(this,Ne).requestJSON("POST",`/screens/${encodeURIComponent(n)}/artifact`,{type:e.type,title:e.title,externalFilePath:e.externalFilePath})}get(e){return u(this,Ne).requestJSON("GET",`/artifacts/${encodeURIComponent(e.artifactID)}`)}update(e){const n={};return e.title!==void 0&&(n.title=e.title),u(this,Ne).requestJSON("PATCH",`/artifacts/${encodeURIComponent(e.artifactID)}`,n)}edit(e){return u(this,Ne).requestJSON("POST",`/artifacts/${encodeURIComponent(e.artifactID)}/edit`)}commitPending(e){return u(this,Ne).requestJSON("POST",`/artifacts/${encodeURIComponent(e.artifactID)}/commit`)}abandonPending(e){return u(this,Ne).requestVoid("POST",`/artifacts/${encodeURIComponent(e.artifactID)}/abandon`)}remove(e){return u(this,Ne).requestJSON("DELETE",`/screens/${encodeURIComponent(e.screenID)}/artifacts/${encodeURIComponent(e.artifactID)}`)}getContent(e){return u(this,Ne).requestText("GET",`/artifacts/${encodeURIComponent(e.artifactID)}/content`)}putContent(e){return u(this,Ne).requestRawVoid("PUT",`/artifacts/${encodeURIComponent(e.artifactID)}/content`,e.content)}}Ne=new WeakMap,Ds=new WeakMap,$o=new WeakSet,Tf=async function(e){if(e!==void 0)return e;const{screens:n}=await u(this,Ds).list();if(n.length===1)return n[0].id;throw u(this,Ne).createError(`screenID is required when multiple screens exist. Available screens: ${Af(n)}`)};var Os;class IE{constructor(e){$(this,Os);x(this,Os,e)}async list(){const{views:e}=await u(this,Os).requestJSON("GET","/views");return e}}Os=new WeakMap;var Vt;class PE{constructor(e,n={}){v(this,"screens");v(this,"artifacts");v(this,"views");$(this,Vt);x(this,Vt,new AE(e,n)),this.screens=new TE(u(this,Vt)),this.artifacts=new CE(u(this,Vt),this.screens),this.views=new IE(u(this,Vt))}health(){return u(this,Vt).requestJSON("GET","/health")}}Vt=new WeakMap;const RE=Hr(kt);var Cn,Ue,In,De,Ht,qt,Q,ur,Cf,zs,If,Pf,Rf,Df,gl,ml,vl,Of;class DE extends RE{constructor(n){var s;super();$(this,Q);v(this,"id");v(this,"server");$(this,Cn);$(this,Ue,new Map);$(this,In);$(this,De);$(this,Ht);$(this,qt,null);$(this,zs,n=>{if(this.disposed)return;const r=n.event;switch(r.type){case"screen-updated":r.screen.id===this.id&&b(this,Q,If).call(this,r.screen);break;case"artifact-created":r.screenID===this.id&&b(this,Q,Pf).call(this,r.artifact);break;case"artifact-updated":b(this,Q,Rf).call(this,r.artifact);break;case"artifact-removed":r.screenID===this.id&&b(this,Q,Df).call(this,r.artifactID);break;case"artifact-content-changed":u(this,Ue).has(r.artifactID)&&this.dispatchEvent(new _E("artifact-content-changed",{artifactID:r.artifactID}));break}});this.id=n.screen.id,this.server=n.server,x(this,Cn,n.localStore),x(this,In,n.screen.name),x(this,De,structuredClone(n.screen.layout));const r=((s=u(this,Cn).get().screens[this.id])==null?void 0:s.scrollPosition)??0;x(this,Ht,Math.max(0,r)),this.server.addEventListener("server-event",u(this,zs)),b(this,Q,Cf).call(this)}get name(){return u(this,In)}get layout(){return u(this,De)}get scrollPosition(){return u(this,Ht)}get artifacts(){return u(this,Ue)}setScrollPosition(n){b(this,Q,ur).call(this);const r=Math.max(0,n);r!==u(this,Ht)&&(x(this,Ht,r),b(this,Q,Of).call(this),this.dispatchEvent(new te("change")))}setLayout(n){b(this,Q,ur).call(this);const r=hf(n);if(!pf(r).valid)return;const i=b(this,Q,ml).call(this);x(this,De,r),x(this,qt,{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=u(this,qt))==null?void 0:o.layout)===r&&(x(this,qt,null),b(this,Q,vl).call(this,i),this.dispatchEvent(new te("change")))})}rename(n){b(this,Q,ur).call(this),x(this,In,n),this.dispatchEvent(new te("change")),this.server.client.screens.update({screenID:this.id,name:n}).catch(()=>{})}async remove(){b(this,Q,ur).call(this),await this.server.client.screens.remove({screenID:this.id})}removeArtifact(n){if(b(this,Q,ur).call(this),!u(this,Ue).has(n))return;const r=b(this,Q,ml).call(this);b(this,Q,gl).call(this,n),this.dispatchEvent(new te("change")),this.server.client.artifacts.remove({artifactID:n,screenID:this.id}).catch(()=>{this.disposed||(b(this,Q,vl).call(this,r),this.dispatchEvent(new te("change")))})}dispose(){this.server.removeEventListener("server-event",u(this,zs))}}Cn=new WeakMap,Ue=new WeakMap,In=new WeakMap,De=new WeakMap,Ht=new WeakMap,qt=new WeakMap,Q=new WeakSet,ur=function(){if(this.disposed)throw new Error("ScreenModel is disposed")},Cf=async function(){try{const n=await this.server.client.screens.get({screenID:this.id});if(this.disposed)return;for(const r of n.artifacts)u(this,Ue).set(r.id,r);this.dispatchEvent(new te("change"))}catch{}},zs=new WeakMap,If=function(n){u(this,qt)&&x(this,qt,null),x(this,In,n.name),x(this,De,structuredClone(n.layout)),this.dispatchEvent(new te("change"))},Pf=function(n){Sf(u(this,De),n.id)||x(this,De,[...u(this,De),_f(n.id)]),u(this,Ue).set(n.id,n),this.dispatchEvent(new te("change"))},Rf=function(n){const r=u(this,Ue).get(n.id);r&&(u(this,Ue).set(n.id,{...r,...n}),this.dispatchEvent(new te("change")))},Df=function(n){b(this,Q,gl).call(this,n)&&this.dispatchEvent(new te("change"))},gl=function(n){const r=u(this,Ue).delete(n),s=Qh({layout:u(this,De)}).length,i=df(u(this,De),n),o=Qh({layout:i}).length;return x(this,De,i),r||s!==o},ml=function(){return{layout:structuredClone(u(this,De)),artifacts:new Map([...u(this,Ue).entries()].map(([n,r])=>[n,structuredClone(r)]))}},vl=function(n){x(this,De,structuredClone(n.layout)),u(this,Ue).clear();for(const[r,s]of n.artifacts)u(this,Ue).set(r,structuredClone(s))},Of=function(){const n=u(this,Cn).get();u(this,Cn).set({...n,screens:{...n.screens,[this.id]:{scrollPosition:u(this,Ht)}}})};const OE=Hr(kt);var Fe,vt,nt,Ls,Ms,Ns,nn,to,zf;class zE extends OE{constructor(n){super();$(this,nn);$(this,Fe);$(this,vt);$(this,nt,null);$(this,Ls,()=>{this.disposed||b(this,nn,to).call(this)});$(this,Ms,()=>{this.disposed||b(this,nn,to).call(this)});$(this,Ns,n=>{var s;if(this.disposed)return;const r=n.event;r.type==="screen-removed"&&((s=u(this,nt))==null?void 0:s.id)===r.screenID&&this.clearActive()});x(this,Fe,n.localStore),x(this,vt,n.serverManager),u(this,Fe).addEventListener("change",u(this,Ls)),u(this,vt).addEventListener("change",u(this,Ms)),u(this,vt).addEventListener("server-event",u(this,Ns)),b(this,nn,to).call(this)}get activeScreen(){return u(this,nt)}setActive(n,r){const s=u(this,Fe).get();s.activeServerURL===n&&s.activeScreenID===r||u(this,Fe).set({...s,activeServerURL:n,activeScreenID:r})}clearActive(){const n=u(this,Fe).get();n.activeServerURL===null&&n.activeScreenID===null||u(this,Fe).set({...n,activeServerURL:null,activeScreenID:null})}dispose(){var n;u(this,Fe).removeEventListener("change",u(this,Ls)),u(this,vt).removeEventListener("change",u(this,Ms)),u(this,vt).removeEventListener("server-event",u(this,Ns)),(n=u(this,nt))==null||n.dispose(),x(this,nt,null)}}Fe=new WeakMap,vt=new WeakMap,nt=new WeakMap,Ls=new WeakMap,Ms=new WeakMap,Ns=new WeakMap,nn=new WeakSet,to=function(){var l,c,d;const{activeServerURL:n,activeScreenID:r}=u(this,Fe).get();let s=n?u(this,vt).servers.get(n)??null:null,i=s&&r?s.screens.get(r)??null:null;if(!i){const p=b(this,nn,zf).call(this);if(p){s=p.server,i=p.screen,u(this,Fe).set({...u(this,Fe).get(),activeServerURL:p.server.url,activeScreenID:p.screen.id});return}}const o=((l=u(this,nt))==null?void 0:l.id)??null,a=(i==null?void 0:i.id)??null;o===a&&((c=u(this,nt))==null?void 0:c.server)===s||((d=u(this,nt))==null||d.dispose(),x(this,nt,s&&i?new DE({screen:i,server:s,localStore:u(this,Fe)}):null),this.dispatchEvent(new nE("active-screen-changed")))},zf=function(){for(const n of u(this,vt).servers.values()){const r=n.screens.values().next().value;if(r)return{server:n,screen:r}}return null};const LE="Local",ME="store-";function Pt(t){return new URL(t).origin}function NE(t){return{servers:[{url:Pt(t),name:LE}],activeServerURL:null,activeScreenID:null,screens:{}}}var Pn,Rn,Dn;class UE extends kt{constructor(n,r,s={}){super();$(this,Pn);$(this,Rn);$(this,Dn);x(this,Pn,`${ME}${n}`),x(this,Rn,s.storage??FE());const i=u(this,Rn).getItem(u(this,Pn));i===null?(x(this,Dn,r),u(this,Rn).setItem(u(this,Pn),JSON.stringify(r))):x(this,Dn,JSON.parse(i))}get(){return u(this,Dn)}set(n){x(this,Dn,n),u(this,Rn).setItem(u(this,Pn),JSON.stringify(n)),this.dispatchEvent(new te("change"))}}Pn=new WeakMap,Rn=new WeakMap,Dn=new WeakMap;function FE(){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 p=0;p<d.length;p++){const y=d[p];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 _r extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Lf extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}}const Mf={};function on(t){return Mf}function Nf(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 yl(t,e){return typeof e=="bigint"?e.toString():e}function Ic(t){return{get value(){{const e=t();return Object.defineProperty(this,"value",{value:e}),e}}}}function Pc(t){return t==null}function Rc(t){const e=t.startsWith("^")?1:0,n=t.endsWith("$")?t.length-1:t.length;return t.slice(e,n)}function ZE(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 ed=Symbol("evaluating");function ee(t,e,n){let r;Object.defineProperty(t,e,{get(){if(r!==ed)return r===void 0&&(r=ed,r=n()),r},set(s){Object.defineProperty(t,e,{value:s})},configurable:!0})}function Jn(t,e,n){Object.defineProperty(t,e,{value:n,writable:!0,enumerable:!0,configurable:!0})}function pn(...t){const e={};for(const n of t){const r=Object.getOwnPropertyDescriptors(n);Object.assign(e,r)}return Object.defineProperties({},e)}function td(t){return JSON.stringify(t)}function jE(t){return t.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Uf="captureStackTrace"in Error?Error.captureStackTrace:(...t)=>{};function fo(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}const WE=Ic(()=>{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 zr(t){if(fo(t)===!1)return!1;const e=t.constructor;if(e===void 0||typeof e!="function")return!0;const n=e.prototype;return!(fo(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function Ff(t){return zr(t)?{...t}:Array.isArray(t)?[...t]:t}const BE=new Set(["string","number","symbol"]);function Lr(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function fn(t,e,n){const r=new t._zod.constr(e??t._zod.def);return(!e||n!=null&&n.parent)&&(r._zod.parent=t),r}function O(t){const e=t;if(!e)return{};if(typeof e=="string")return{error:()=>e};if((e==null?void 0:e.message)!==void 0){if((e==null?void 0:e.error)!==void 0)throw new Error("Cannot specify both `message` and `error` params");e.error=e.message}return delete e.message,typeof e.error=="string"?{...e,error:()=>e.error}:e}function GE(t){return Object.keys(t).filter(e=>t[e]._zod.optin==="optional"&&t[e]._zod.optout==="optional")}const VE={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 HE(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=pn(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 Jn(this,"shape",o),o},checks:[]});return fn(t,i)}function qE(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=pn(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 Jn(this,"shape",o),o},checks:[]});return fn(t,i)}function YE(t,e){if(!zr(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=pn(t._zod.def,{get shape(){const i={...t._zod.def.shape,...e};return Jn(this,"shape",i),i}});return fn(t,s)}function KE(t,e){if(!zr(e))throw new Error("Invalid input to safeExtend: expected a plain object");const n=pn(t._zod.def,{get shape(){const r={...t._zod.def.shape,...e};return Jn(this,"shape",r),r}});return fn(t,n)}function JE(t,e){const n=pn(t._zod.def,{get shape(){const r={...t._zod.def.shape,...e._zod.def.shape};return Jn(this,"shape",r),r},get catchall(){return e._zod.def.catchall},checks:[]});return fn(t,n)}function XE(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=pn(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 Jn(this,"shape",l),l},checks:[]});return fn(e,o)}function QE(t,e,n){const r=pn(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 Jn(this,"shape",i),i}});return fn(e,r)}function yr(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 br(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 an(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 Dc(t){return Array.isArray(t)?"array":typeof t=="string"?"string":"unknown"}function Ts(...t){const[e,n,r]=t;return typeof e=="string"?{message:e,code:"custom",input:n,inst:r}:{...e}}const Zf=(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,yl,2),Object.defineProperty(t,"toString",{value:()=>t.message,enumerable:!1})},jf=S("$ZodError",Zf),Wf=S("$ZodError",Zf,{Parent:Error});function e$(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 t$(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 Oc=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 _r;if(o.issues.length){const a=new((s==null?void 0:s.Err)??t)(o.issues.map(l=>an(l,i,on())));throw Uf(a,s==null?void 0:s.callee),a}return o.value},zc=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=>an(l,i,on())));throw Uf(a,s==null?void 0:s.callee),a}return o.value},Zo=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 _r;return i.issues.length?{success:!1,error:new(t??jf)(i.issues.map(o=>an(o,s,on())))}:{success:!0,data:i.value}},n$=Zo(Wf),jo=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=>an(o,s,on())))}:{success:!0,data:i.value}},r$=jo(Wf),s$=t=>(e,n,r)=>{const s=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Oc(t)(e,n,s)},i$=t=>(e,n,r)=>Oc(t)(e,n,r),o$=t=>async(e,n,r)=>{const s=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return zc(t)(e,n,s)},a$=t=>async(e,n,r)=>zc(t)(e,n,r),l$=t=>(e,n,r)=>{const s=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Zo(t)(e,n,s)},c$=t=>(e,n,r)=>Zo(t)(e,n,r),u$=t=>async(e,n,r)=>{const s=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return jo(t)(e,n,s)},h$=t=>async(e,n,r)=>jo(t)(e,n,r),d$=/^[cC][^\s-]{8,}$/,p$=/^[0-9a-z]+$/,f$=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,g$=/^[0-9a-vA-V]{20}$/,m$=/^[A-Za-z0-9]{27}$/,v$=/^[a-zA-Z0-9_-]{21}$/,y$=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,b$=/^([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})$/,nd=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)$/,w$=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,_$="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function S$(){return new RegExp(_$,"u")}const k$=/^(?:(?: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])$/,E$=/^(([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}|:))$/,$$=/^((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])$/,A$=/^(([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])$/,x$=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Bf=/^[A-Za-z0-9_-]*$/,T$=/^\+[1-9]\d{6,14}$/,Gf="(?:(?:\\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])))",C$=new RegExp(`^${Gf}$`);function Vf(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 I$(t){return new RegExp(`^${Vf(t)}$`)}function P$(t){const e=Vf({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(`^${Gf}T(?:${r})$`)}const R$=t=>{const e=t?`[\\s\\S]{${(t==null?void 0:t.minimum)??0},${(t==null?void 0:t.maximum)??""}}`:"[\\s\\S]*";return new RegExp(`^${e}$`)},D$=/^-?\d+$/,Hf=/^-?\d+(?:\.\d+)?$/,O$=/^(?:true|false)$/i,z$=/^[^A-Z]*$/,L$=/^[^a-z]*$/,We=S("$ZodCheck",(t,e)=>{var n;t._zod??(t._zod={}),t._zod.def=e,(n=t._zod).onattach??(n.onattach=[])}),qf={number:"number",bigint:"bigint",object:"date"},Yf=S("$ZodCheckLessThan",(t,e)=>{We.init(t,e);const n=qf[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})}}),Kf=S("$ZodCheckGreaterThan",(t,e)=>{We.init(t,e);const n=qf[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})}}),M$=S("$ZodCheckMultipleOf",(t,e)=>{We.init(t,e),t._zod.onattach.push(n=>{var r;(r=n._zod.bag).multipleOf??(r.multipleOf=e.value)}),t._zod.check=n=>{if(typeof n.value!=typeof e.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%e.value===BigInt(0):ZE(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})}}),N$=S("$ZodCheckNumberFormat",(t,e)=>{var o;We.init(t,e),e.format=e.format||"float64";const n=(o=e.format)==null?void 0:o.includes("int"),r=n?"int":"number",[s,i]=VE[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=D$)}),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})}}),U$=S("$ZodCheckMaxLength",(t,e)=>{var n;We.init(t,e),(n=t._zod.def).when??(n.when=r=>{const s=r.value;return!Pc(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=Dc(s);r.issues.push({origin:o,code:"too_big",maximum:e.maximum,inclusive:!0,input:s,inst:t,continue:!e.abort})}}),F$=S("$ZodCheckMinLength",(t,e)=>{var n;We.init(t,e),(n=t._zod.def).when??(n.when=r=>{const s=r.value;return!Pc(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=Dc(s);r.issues.push({origin:o,code:"too_small",minimum:e.minimum,inclusive:!0,input:s,inst:t,continue:!e.abort})}}),Z$=S("$ZodCheckLengthEquals",(t,e)=>{var n;We.init(t,e),(n=t._zod.def).when??(n.when=r=>{const s=r.value;return!Pc(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=Dc(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})}}),Wo=S("$ZodCheckStringFormat",(t,e)=>{var n,r;We.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=()=>{})}),j$=S("$ZodCheckRegex",(t,e)=>{Wo.init(t,e),t._zod.check=n=>{e.pattern.lastIndex=0,!e.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:e.pattern.toString(),inst:t,continue:!e.abort})}}),W$=S("$ZodCheckLowerCase",(t,e)=>{e.pattern??(e.pattern=z$),Wo.init(t,e)}),B$=S("$ZodCheckUpperCase",(t,e)=>{e.pattern??(e.pattern=L$),Wo.init(t,e)}),G$=S("$ZodCheckIncludes",(t,e)=>{We.init(t,e);const n=Lr(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})}}),V$=S("$ZodCheckStartsWith",(t,e)=>{We.init(t,e);const n=new RegExp(`^${Lr(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})}}),H$=S("$ZodCheckEndsWith",(t,e)=>{We.init(t,e);const n=new RegExp(`.*${Lr(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})}}),q$=S("$ZodCheckOverwrite",(t,e)=>{We.init(t,e),t._zod.check=n=>{n.value=e.tx(n.value)}});class Y${constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if(typeof e=="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}const r=e.split(`
|
|
5
5
|
`).filter(o=>o),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
|
|
6
|
+
`))}}const K$={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=K$;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=yr(a),p;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 _r;if(p||E instanceof Promise)p=(p??Promise.resolve()).then(async()=>{await E,a.issues.length!==m&&(d||(d=yr(a,m)))});else{if(a.issues.length===m)continue;d||(d=yr(a,m))}}return p?p.then(()=>a):a},o=(a,l,c)=>{if(yr(a))return a.aborted=!0,a;const d=i(l,r,c);if(d instanceof Promise){if(c.async===!1)throw new _r;return d.then(p=>t._zod.parse(p,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(p=>o(p,a,l)):o(d,a,l)}const c=t._zod.parse(a,l);if(c instanceof Promise){if(l.async===!1)throw new _r;return c.then(d=>i(d,r,l))}return i(c,r,l)}}ee(t,"~standard",()=>({validate:i=>{var o;try{const a=n$(t,i);return a.success?{value:a.data}:{issues:(o=a.error)==null?void 0:o.issues}}catch{return r$(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}))}),Lc=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()??R$(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)=>{Wo.init(t,e),Lc.init(t,e)}),J$=S("$ZodGUID",(t,e)=>{e.pattern??(e.pattern=b$),oe.init(t,e)}),X$=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=nd(r))}else e.pattern??(e.pattern=nd());oe.init(t,e)}),Q$=S("$ZodEmail",(t,e)=>{e.pattern??(e.pattern=w$),oe.init(t,e)}),eA=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})}}}),tA=S("$ZodEmoji",(t,e)=>{e.pattern??(e.pattern=S$()),oe.init(t,e)}),nA=S("$ZodNanoID",(t,e)=>{e.pattern??(e.pattern=v$),oe.init(t,e)}),rA=S("$ZodCUID",(t,e)=>{e.pattern??(e.pattern=d$),oe.init(t,e)}),sA=S("$ZodCUID2",(t,e)=>{e.pattern??(e.pattern=p$),oe.init(t,e)}),iA=S("$ZodULID",(t,e)=>{e.pattern??(e.pattern=f$),oe.init(t,e)}),oA=S("$ZodXID",(t,e)=>{e.pattern??(e.pattern=g$),oe.init(t,e)}),aA=S("$ZodKSUID",(t,e)=>{e.pattern??(e.pattern=m$),oe.init(t,e)}),lA=S("$ZodISODateTime",(t,e)=>{e.pattern??(e.pattern=P$(e)),oe.init(t,e)}),cA=S("$ZodISODate",(t,e)=>{e.pattern??(e.pattern=C$),oe.init(t,e)}),uA=S("$ZodISOTime",(t,e)=>{e.pattern??(e.pattern=I$(e)),oe.init(t,e)}),hA=S("$ZodISODuration",(t,e)=>{e.pattern??(e.pattern=y$),oe.init(t,e)}),dA=S("$ZodIPv4",(t,e)=>{e.pattern??(e.pattern=k$),oe.init(t,e),t._zod.bag.format="ipv4"}),pA=S("$ZodIPv6",(t,e)=>{e.pattern??(e.pattern=E$),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})}}}),fA=S("$ZodCIDRv4",(t,e)=>{e.pattern??(e.pattern=$$),oe.init(t,e)}),gA=S("$ZodCIDRv6",(t,e)=>{e.pattern??(e.pattern=A$),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 Jf(t){if(t==="")return!0;if(t.length%4!==0)return!1;try{return atob(t),!0}catch{return!1}}const mA=S("$ZodBase64",(t,e)=>{e.pattern??(e.pattern=x$),oe.init(t,e),t._zod.bag.contentEncoding="base64",t._zod.check=n=>{Jf(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:t,continue:!e.abort})}});function vA(t){if(!Bf.test(t))return!1;const e=t.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=e.padEnd(Math.ceil(e.length/4)*4,"=");return Jf(n)}const yA=S("$ZodBase64URL",(t,e)=>{e.pattern??(e.pattern=Bf),oe.init(t,e),t._zod.bag.contentEncoding="base64url",t._zod.check=n=>{vA(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:t,continue:!e.abort})}}),bA=S("$ZodE164",(t,e)=>{e.pattern??(e.pattern=T$),oe.init(t,e)});function wA(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 _A=S("$ZodJWT",(t,e)=>{oe.init(t,e),t._zod.check=n=>{wA(n.value,e.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:t,continue:!e.abort})}}),Xf=S("$ZodNumber",(t,e)=>{le.init(t,e),t._zod.pattern=t._zod.bag.pattern??Hf,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}}),SA=S("$ZodNumberFormat",(t,e)=>{N$.init(t,e),Xf.init(t,e)}),kA=S("$ZodBoolean",(t,e)=>{le.init(t,e),t._zod.pattern=O$,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}}),EA=S("$ZodUnknown",(t,e)=>{le.init(t,e),t._zod.parse=n=>n}),$A=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 rd(t,e,n){t.issues.length&&e.issues.push(...br(n,t.issues)),e.value[n]=t.value}const AA=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=>rd(c,n,o))):rd(l,n,o)}return i.length?Promise.all(i).then(()=>n):n}});function go(t,e,n,r,s){if(t.issues.length){if(s&&!(n in r))return;e.issues.push(...br(n,t.issues))}t.value===void 0?n in r&&(e.value[n]=void 0):e.value[n]=t.value}function Qf(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 eg(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 p in e){if(a.has(p))continue;if(c==="never"){o.push(p);continue}const y=l.run({value:e[p],issues:[]},r);y instanceof Promise?t.push(y.then(m=>go(m,n,p,e,d))):go(y,n,p,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 xA=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=Ic(()=>Qf(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 p of d.values)l[c].add(p)}}return l});const s=fo,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=[],p=o.shape;for(const y of o.keys){const m=p[y],E=m._zod.optout==="optional",k=m._zod.run({value:c[y],issues:[]},l);k instanceof Promise?d.push(k.then(I=>go(I,a,y,c,E))):go(k,a,y,c,E)}return i?eg(d,c,a,l,r.value,t):d.length?Promise.all(d).then(()=>a):a}}),TA=S("$ZodObjectJIT",(t,e)=>{xA.init(t,e);const n=t._zod.parse,r=Ic(()=>Qf(e)),s=y=>{var j;const m=new Y$(["shape","payload","ctx"]),E=r.value,k=F=>{const L=td(F);return`shape[${L}]._zod.run({ value: input[${L}], issues: [] }, ctx)`};m.write("const input = payload.value;");const I=Object.create(null);let G=0;for(const F of E.keys)I[F]=`key_${G++}`;m.write("const newResult = {};");for(const F of E.keys){const L=I[F],J=td(F),H=y[F],he=((j=H==null?void 0:H._zod)==null?void 0:j.optout)==="optional";m.write(`const ${L} = ${k(F)};`),he?m.write(`
|
|
7
7
|
if (${L}.issues.length) {
|
|
8
8
|
if (${J} in input) {
|
|
9
9
|
payload.issues = payload.issues.concat(${L}.issues.map(iss => ({
|
|
@@ -37,40 +37,40 @@ var Iv=Object.defineProperty;var Au=t=>{throw TypeError(t)};var Pv=(t,e,n)=>e in
|
|
|
37
37
|
newResult[${J}] = ${L}.value;
|
|
38
38
|
}
|
|
39
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=fo,a=!Zf.jitless,c=a&&HE.value,d=e.catchall;let p;t._zod.parse=(y,m)=>{p??(p=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?sg([],E,y,m,p,t):y):n(y,m):(y.issues.push({expected:"object",code:"invalid_type",input:E,inst:t}),y)}});function ld(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=>!yr(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=>an(o,r,on())))}),e)}const DA=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=>Rc(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=>ld(l,s,t,i)):ld(a,s,t,i)}}),OA=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])=>cd(n,l,c)):cd(n,i,o)}});function bl(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(zr(t)&&zr(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=bl(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=bl(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 cd(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}),yr(t))return t;const o=bl(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 zA=S("$ZodRecord",(t,e)=>{le.init(t,e),t._zod.parse=(n,r)=>{const s=n.value;if(!zr(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(p=>{p.issues.length&&n.issues.push(...br(c,p.issues)),n.value[c]=p.value})):(d.issues.length&&n.issues.push(...br(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"&&Jf.test(a)&&l.issues.length){const p=e.keyType._zod.run({value:Number(a),issues:[]},r);if(p instanceof Promise)throw new Error("Async schemas not supported in object keys currently");p.issues.length===0&&(l=p)}if(l.issues.length){e.mode==="loose"?n.value[a]=s[a]:n.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map(p=>an(p,r,on())),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(p=>{p.issues.length&&n.issues.push(...br(a,p.issues)),n.value[l.value]=p.value})):(d.issues.length&&n.issues.push(...br(a,d.issues)),n.value[l.value]=d.value)}}return i.length?Promise.all(i).then(()=>n):n}}),LA=S("$ZodEnum",(t,e)=>{le.init(t,e);const n=jf(e.entries),r=new Set(n);t._zod.values=r,t._zod.pattern=new RegExp(`^(${n.filter(s=>qE.has(typeof s)).map(s=>typeof s=="string"?Lr(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}}),MA=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"?Lr(r):r?Lr(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}}),NA=S("$ZodTransform",(t,e)=>{le.init(t,e),t._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Ff(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 _r;return n.value=s,n}});function ud(t,e){return t.issues.length&&e===void 0?{issues:[],value:void 0}:t}const ig=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(`^(${Rc(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=>ud(i,n.value)):ud(s,n.value)}return n.value===void 0?n:e.innerType._zod.run(n,r)}}),UA=S("$ZodExactOptional",(t,e)=>{ig.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)}),FA=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(`^(${Rc(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)}),ZA=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=>hd(i,e)):hd(s,e)}});function hd(t,e){return t.value===void 0&&(t.value=e.defaultValue),t}const jA=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))}),WA=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=>dd(i,t)):dd(s,t)}});function dd(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 BA=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=>an(o,r,on()))},input:n.value}),n.issues=[]),n)):(n.value=s.value,s.issues.length&&(n.value=e.catchValue({...n,error:{issues:s.issues.map(i=>an(i,r,on()))},input:n.value}),n.issues=[]),n)}}),GA=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 VA=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(pd):pd(s)}});function pd(t){return t.value=Object.freeze(t.value),t}const HA=S("$ZodCustom",(t,e)=>{We.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=>fd(i,n,r,t));fd(s,n,r,t)}});function fd(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(Ts(s))}}var gd;class qA{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 YA(){return new qA}(gd=globalThis).__zod_globalRegistry??(gd.__zod_globalRegistry=YA());const gs=globalThis.__zod_globalRegistry;function KA(t,e){return new t({type:"string",...O(e)})}function JA(t,e){return new t({type:"string",format:"email",check:"string_format",abort:!1,...O(e)})}function md(t,e){return new t({type:"string",format:"guid",check:"string_format",abort:!1,...O(e)})}function XA(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,...O(e)})}function QA(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...O(e)})}function ex(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...O(e)})}function tx(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...O(e)})}function nx(t,e){return new t({type:"string",format:"url",check:"string_format",abort:!1,...O(e)})}function rx(t,e){return new t({type:"string",format:"emoji",check:"string_format",abort:!1,...O(e)})}function sx(t,e){return new t({type:"string",format:"nanoid",check:"string_format",abort:!1,...O(e)})}function ix(t,e){return new t({type:"string",format:"cuid",check:"string_format",abort:!1,...O(e)})}function ox(t,e){return new t({type:"string",format:"cuid2",check:"string_format",abort:!1,...O(e)})}function ax(t,e){return new t({type:"string",format:"ulid",check:"string_format",abort:!1,...O(e)})}function lx(t,e){return new t({type:"string",format:"xid",check:"string_format",abort:!1,...O(e)})}function cx(t,e){return new t({type:"string",format:"ksuid",check:"string_format",abort:!1,...O(e)})}function ux(t,e){return new t({type:"string",format:"ipv4",check:"string_format",abort:!1,...O(e)})}function hx(t,e){return new t({type:"string",format:"ipv6",check:"string_format",abort:!1,...O(e)})}function dx(t,e){return new t({type:"string",format:"cidrv4",check:"string_format",abort:!1,...O(e)})}function px(t,e){return new t({type:"string",format:"cidrv6",check:"string_format",abort:!1,...O(e)})}function fx(t,e){return new t({type:"string",format:"base64",check:"string_format",abort:!1,...O(e)})}function gx(t,e){return new t({type:"string",format:"base64url",check:"string_format",abort:!1,...O(e)})}function mx(t,e){return new t({type:"string",format:"e164",check:"string_format",abort:!1,...O(e)})}function vx(t,e){return new t({type:"string",format:"jwt",check:"string_format",abort:!1,...O(e)})}function yx(t,e){return new t({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...O(e)})}function bx(t,e){return new t({type:"string",format:"date",check:"string_format",...O(e)})}function wx(t,e){return new t({type:"string",format:"time",check:"string_format",precision:null,...O(e)})}function _x(t,e){return new t({type:"string",format:"duration",check:"string_format",...O(e)})}function Sx(t,e){return new t({type:"number",checks:[],...O(e)})}function kx(t,e){return new t({type:"number",check:"number_format",abort:!1,format:"safeint",...O(e)})}function Ex(t,e){return new t({type:"boolean",...O(e)})}function $x(t){return new t({type:"unknown"})}function Ax(t,e){return new t({type:"never",...O(e)})}function vd(t,e){return new Qf({check:"less_than",...O(e),value:t,inclusive:!1})}function Za(t,e){return new Qf({check:"less_than",...O(e),value:t,inclusive:!0})}function yd(t,e){return new eg({check:"greater_than",...O(e),value:t,inclusive:!1})}function ja(t,e){return new eg({check:"greater_than",...O(e),value:t,inclusive:!0})}function bd(t,e){return new Z$({check:"multiple_of",...O(e),value:t})}function og(t,e){return new W$({check:"max_length",...O(e),maximum:t})}function mo(t,e){return new B$({check:"min_length",...O(e),minimum:t})}function ag(t,e){return new G$({check:"length_equals",...O(e),length:t})}function xx(t,e){return new V$({check:"string_format",format:"regex",...O(e),pattern:t})}function Tx(t){return new H$({check:"string_format",format:"lowercase",...O(t)})}function Cx(t){return new q$({check:"string_format",format:"uppercase",...O(t)})}function Ix(t,e){return new Y$({check:"string_format",format:"includes",...O(e),includes:t})}function Px(t,e){return new K$({check:"string_format",format:"starts_with",...O(e),prefix:t})}function Rx(t,e){return new J$({check:"string_format",format:"ends_with",...O(e),suffix:t})}function qr(t){return new X$({check:"overwrite",tx:t})}function Dx(t){return qr(e=>e.normalize(t))}function Ox(){return qr(t=>t.trim())}function zx(){return qr(t=>t.toLowerCase())}function Lx(){return qr(t=>t.toUpperCase())}function Mx(){return qr(t=>VE(t))}function Nx(t,e,n){return new t({type:"array",element:e,...O(n)})}function Ux(t,e,n){return new t({type:"custom",check:"custom",fn:e,...O(n)})}function Fx(t){const e=Zx(n=>(n.addIssue=r=>{if(typeof r=="string")n.issues.push(Ts(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(Ts(s))}},t(n.value,n)));return e}function Zx(t,e){const n=new We({check:"custom",...O(e)});return n._zod.check=t,n}function lg(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,p;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=(p=(d=t._zod).toJSONSchema)==null?void 0:p.call(d);if(a)o.schema=a;else{const y={...n,schemaPath:[...n.schemaPath,t],path:n.path};if(t._zod.processJSONSchema)t._zod.processJSONSchema(e,o.schema,y);else{const 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"&&Re(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 cg(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 p=(o=t.metadataRegistry.get(d[0]))==null?void 0:o.id;if(p){const y=r.get(p);if(y&&y!==d[0])throw new Error(`Duplicate schema id "${p}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(p,d[0])}}const s=d=>{var k;const p=t.target==="draft-2020-12"?"$defs":"definitions";if(t.external){const I=(k=t.external.registry.get(d[0]))==null?void 0:k.id,G=t.external.uri??(j=>j);if(I)return{ref:G(I)};const N=d[1].defId??d[1].schema.id??`schema${t.counter++}`;return d[1].defId=N,{defId:N,ref:`${G("__shared")}#/${p}/${N}`}}if(d[1]===n)return{ref:"#"};const m=`#/${p}/`,E=d[1].schema.id??`__schema${t.counter++}`;return{defId:E,ref:m+E}},i=d=>{if(d[1].schema.$ref)return;const p=d[1],{ref:y,defId:m}=s(d);p.def={...p.schema},m&&(p.defId=m);const E=p.schema;for(const k in E)delete E[k];E.$ref=y};if(t.cycles==="throw")for(const d of t.seen.entries()){const p=d[1];if(p.cycle)throw new Error(`Cycle detected: #/${(a=p.cycle)==null?void 0:a.join("/")}/<root>
|
|
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=fo,a=!Mf.jitless,c=a&&WE.value,d=e.catchall;let p;t._zod.parse=(y,m)=>{p??(p=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?eg([],E,y,m,p,t):y):n(y,m):(y.issues.push({expected:"object",code:"invalid_type",input:E,inst:t}),y)}});function sd(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=>!yr(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=>an(o,r,on())))}),e)}const CA=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=>Rc(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=>sd(l,s,t,i)):sd(a,s,t,i)}}),IA=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])=>id(n,l,c)):id(n,i,o)}});function bl(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(zr(t)&&zr(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=bl(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=bl(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 id(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}),yr(t))return t;const o=bl(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 PA=S("$ZodRecord",(t,e)=>{le.init(t,e),t._zod.parse=(n,r)=>{const s=n.value;if(!zr(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(p=>{p.issues.length&&n.issues.push(...br(c,p.issues)),n.value[c]=p.value})):(d.issues.length&&n.issues.push(...br(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"&&Hf.test(a)&&l.issues.length){const p=e.keyType._zod.run({value:Number(a),issues:[]},r);if(p instanceof Promise)throw new Error("Async schemas not supported in object keys currently");p.issues.length===0&&(l=p)}if(l.issues.length){e.mode==="loose"?n.value[a]=s[a]:n.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map(p=>an(p,r,on())),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(p=>{p.issues.length&&n.issues.push(...br(a,p.issues)),n.value[l.value]=p.value})):(d.issues.length&&n.issues.push(...br(a,d.issues)),n.value[l.value]=d.value)}}return i.length?Promise.all(i).then(()=>n):n}}),RA=S("$ZodEnum",(t,e)=>{le.init(t,e);const n=Nf(e.entries),r=new Set(n);t._zod.values=r,t._zod.pattern=new RegExp(`^(${n.filter(s=>BE.has(typeof s)).map(s=>typeof s=="string"?Lr(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}}),DA=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"?Lr(r):r?Lr(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}}),OA=S("$ZodTransform",(t,e)=>{le.init(t,e),t._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Lf(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 _r;return n.value=s,n}});function od(t,e){return t.issues.length&&e===void 0?{issues:[],value:void 0}:t}const tg=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(`^(${Rc(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=>od(i,n.value)):od(s,n.value)}return n.value===void 0?n:e.innerType._zod.run(n,r)}}),zA=S("$ZodExactOptional",(t,e)=>{tg.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)}),LA=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(`^(${Rc(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)}),MA=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=>ad(i,e)):ad(s,e)}});function ad(t,e){return t.value===void 0&&(t.value=e.defaultValue),t}const NA=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))}),UA=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=>ld(i,t)):ld(s,t)}});function ld(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 FA=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=>an(o,r,on()))},input:n.value}),n.issues=[]),n)):(n.value=s.value,s.issues.length&&(n.value=e.catchValue({...n,error:{issues:s.issues.map(i=>an(i,r,on()))},input:n.value}),n.issues=[]),n)}}),ZA=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 jA=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(cd):cd(s)}});function cd(t){return t.value=Object.freeze(t.value),t}const WA=S("$ZodCustom",(t,e)=>{We.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=>ud(i,n,r,t));ud(s,n,r,t)}});function ud(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(Ts(s))}}var hd;class BA{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 GA(){return new BA}(hd=globalThis).__zod_globalRegistry??(hd.__zod_globalRegistry=GA());const gs=globalThis.__zod_globalRegistry;function VA(t,e){return new t({type:"string",...O(e)})}function HA(t,e){return new t({type:"string",format:"email",check:"string_format",abort:!1,...O(e)})}function dd(t,e){return new t({type:"string",format:"guid",check:"string_format",abort:!1,...O(e)})}function qA(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,...O(e)})}function YA(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...O(e)})}function KA(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...O(e)})}function JA(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...O(e)})}function XA(t,e){return new t({type:"string",format:"url",check:"string_format",abort:!1,...O(e)})}function QA(t,e){return new t({type:"string",format:"emoji",check:"string_format",abort:!1,...O(e)})}function ex(t,e){return new t({type:"string",format:"nanoid",check:"string_format",abort:!1,...O(e)})}function tx(t,e){return new t({type:"string",format:"cuid",check:"string_format",abort:!1,...O(e)})}function nx(t,e){return new t({type:"string",format:"cuid2",check:"string_format",abort:!1,...O(e)})}function rx(t,e){return new t({type:"string",format:"ulid",check:"string_format",abort:!1,...O(e)})}function sx(t,e){return new t({type:"string",format:"xid",check:"string_format",abort:!1,...O(e)})}function ix(t,e){return new t({type:"string",format:"ksuid",check:"string_format",abort:!1,...O(e)})}function ox(t,e){return new t({type:"string",format:"ipv4",check:"string_format",abort:!1,...O(e)})}function ax(t,e){return new t({type:"string",format:"ipv6",check:"string_format",abort:!1,...O(e)})}function lx(t,e){return new t({type:"string",format:"cidrv4",check:"string_format",abort:!1,...O(e)})}function cx(t,e){return new t({type:"string",format:"cidrv6",check:"string_format",abort:!1,...O(e)})}function ux(t,e){return new t({type:"string",format:"base64",check:"string_format",abort:!1,...O(e)})}function hx(t,e){return new t({type:"string",format:"base64url",check:"string_format",abort:!1,...O(e)})}function dx(t,e){return new t({type:"string",format:"e164",check:"string_format",abort:!1,...O(e)})}function px(t,e){return new t({type:"string",format:"jwt",check:"string_format",abort:!1,...O(e)})}function fx(t,e){return new t({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...O(e)})}function gx(t,e){return new t({type:"string",format:"date",check:"string_format",...O(e)})}function mx(t,e){return new t({type:"string",format:"time",check:"string_format",precision:null,...O(e)})}function vx(t,e){return new t({type:"string",format:"duration",check:"string_format",...O(e)})}function yx(t,e){return new t({type:"number",checks:[],...O(e)})}function bx(t,e){return new t({type:"number",check:"number_format",abort:!1,format:"safeint",...O(e)})}function wx(t,e){return new t({type:"boolean",...O(e)})}function _x(t){return new t({type:"unknown"})}function Sx(t,e){return new t({type:"never",...O(e)})}function pd(t,e){return new Yf({check:"less_than",...O(e),value:t,inclusive:!1})}function Za(t,e){return new Yf({check:"less_than",...O(e),value:t,inclusive:!0})}function fd(t,e){return new Kf({check:"greater_than",...O(e),value:t,inclusive:!1})}function ja(t,e){return new Kf({check:"greater_than",...O(e),value:t,inclusive:!0})}function gd(t,e){return new M$({check:"multiple_of",...O(e),value:t})}function ng(t,e){return new U$({check:"max_length",...O(e),maximum:t})}function mo(t,e){return new F$({check:"min_length",...O(e),minimum:t})}function rg(t,e){return new Z$({check:"length_equals",...O(e),length:t})}function kx(t,e){return new j$({check:"string_format",format:"regex",...O(e),pattern:t})}function Ex(t){return new W$({check:"string_format",format:"lowercase",...O(t)})}function $x(t){return new B$({check:"string_format",format:"uppercase",...O(t)})}function Ax(t,e){return new G$({check:"string_format",format:"includes",...O(e),includes:t})}function xx(t,e){return new V$({check:"string_format",format:"starts_with",...O(e),prefix:t})}function Tx(t,e){return new H$({check:"string_format",format:"ends_with",...O(e),suffix:t})}function qr(t){return new q$({check:"overwrite",tx:t})}function Cx(t){return qr(e=>e.normalize(t))}function Ix(){return qr(t=>t.trim())}function Px(){return qr(t=>t.toLowerCase())}function Rx(){return qr(t=>t.toUpperCase())}function Dx(){return qr(t=>jE(t))}function Ox(t,e,n){return new t({type:"array",element:e,...O(n)})}function zx(t,e,n){return new t({type:"custom",check:"custom",fn:e,...O(n)})}function Lx(t){const e=Mx(n=>(n.addIssue=r=>{if(typeof r=="string")n.issues.push(Ts(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(Ts(s))}},t(n.value,n)));return e}function Mx(t,e){const n=new We({check:"custom",...O(e)});return n._zod.check=t,n}function sg(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,p;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=(p=(d=t._zod).toJSONSchema)==null?void 0:p.call(d);if(a)o.schema=a;else{const y={...n,schemaPath:[...n.schemaPath,t],path:n.path};if(t._zod.processJSONSchema)t._zod.processJSONSchema(e,o.schema,y);else{const 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"&&Re(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 ig(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 p=(o=t.metadataRegistry.get(d[0]))==null?void 0:o.id;if(p){const y=r.get(p);if(y&&y!==d[0])throw new Error(`Duplicate schema id "${p}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(p,d[0])}}const s=d=>{var k;const p=t.target==="draft-2020-12"?"$defs":"definitions";if(t.external){const I=(k=t.external.registry.get(d[0]))==null?void 0:k.id,G=t.external.uri??(j=>j);if(I)return{ref:G(I)};const N=d[1].defId??d[1].schema.id??`schema${t.counter++}`;return d[1].defId=N,{defId:N,ref:`${G("__shared")}#/${p}/${N}`}}if(d[1]===n)return{ref:"#"};const m=`#/${p}/`,E=d[1].schema.id??`__schema${t.counter++}`;return{defId:E,ref:m+E}},i=d=>{if(d[1].schema.$ref)return;const p=d[1],{ref:y,defId:m}=s(d);p.def={...p.schema},m&&(p.defId=m);const E=p.schema;for(const k in E)delete E[k];E.$ref=y};if(t.cycles==="throw")for(const d of t.seen.entries()){const p=d[1];if(p.cycle)throw new Error(`Cycle detected: #/${(a=p.cycle)==null?void 0:a.join("/")}/<root>
|
|
41
41
|
|
|
42
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const d of t.seen.entries()){const p=d[1];if(e===d[0]){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(p.cycle){i(d);continue}if(p.count>1&&t.reused==="ref"){i(d);continue}}}function ug(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 p=d.def??d.schema,y={...p},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")?(p.allOf=p.allOf??[],p.allOf.push(I)):Object.assign(p,I),Object.assign(p,y),c._zod.parent===m)for(const N in p)N==="$ref"||N==="allOf"||N in y||delete p[N];if(I.$ref&&k.def)for(const N in p)N==="$ref"||N==="allOf"||N in k.def&&JSON.stringify(p[N])===JSON.stringify(k.def[N])&&delete p[N]}const E=c._zod.parent;if(E&&E!==m){r(E);const k=t.seen.get(E);if(k!=null&&k.schema.$ref&&(p.$ref=k.schema.$ref,k.def))for(const I in p)I==="$ref"||I==="allOf"||I in k.def&&JSON.stringify(p[I])===JSON.stringify(k.def[I])&&delete p[I]}t.override({zodSchema:c,jsonSchema:p,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:vo(e,"input",t.processors),output:vo(e,"output",t.processors)}},enumerable:!1,writable:!1}),c}catch{throw new Error("Error converting schema to JSON.")}}function Re(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 Re(r.element,n);if(r.type==="set")return Re(r.valueType,n);if(r.type==="lazy")return Re(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 Re(r.innerType,n);if(r.type==="intersection")return Re(r.left,n)||Re(r.right,n);if(r.type==="record"||r.type==="map")return Re(r.keyType,n)||Re(r.valueType,n);if(r.type==="pipe")return Re(r.in,n)||Re(r.out,n);if(r.type==="object"){for(const s in r.shape)if(Re(r.shape[s],n))return!0;return!1}if(r.type==="union"){for(const s of r.options)if(Re(s,n))return!0;return!1}if(r.type==="tuple"){for(const s of r.items)if(Re(s,n))return!0;return!!(r.rest&&Re(r.rest,n))}return!1}const jx=(t,e={})=>n=>{const r=lg({...n,processors:e});return me(t,r),cg(r,t),ug(r,t)},vo=(t,e,n={})=>r=>{const{libraryOptions:s,target:i}=r??{},o=lg({...s??{},target:i,io:e,processors:n});return me(t,o),cg(o,t),ug(o,t)},Wx={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Bx=(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=Wx[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(p=>({...e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"?{type:"string"}:{},pattern:p.source}))])}},Gx=(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)},Vx=(t,e,n,r)=>{n.type="boolean"},Hx=(t,e,n,r)=>{n.not={}},qx=(t,e,n,r)=>{},Yx=(t,e,n,r)=>{const s=t._zod.def,i=jf(s.entries);i.every(o=>typeof o=="number")&&(n.type="number"),i.every(o=>typeof o=="string")&&(n.type="string"),n.enum=i},Kx=(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},Jx=(t,e,n,r)=>{if(e.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},Xx=(t,e,n,r)=>{if(e.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},Qx=(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"]})},eT=(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 p=i.shape[d]._zod;return e.io==="input"?p.optin===void 0:p.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)},tT=(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},nT=(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},rT=(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 p of l)s.patternProperties[p.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(p=>typeof p=="string"||typeof p=="number");d.length>0&&(s.required=d)}},sT=(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"}]},iT=(t,e,n,r)=>{const s=t._zod.def;me(s.innerType,e,r);const i=e.seen.get(t);i.ref=s.innerType},oT=(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))},aT=(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)))},lT=(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},cT=(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},uT=(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},hg=(t,e,n,r)=>{const s=t._zod.def;me(s.innerType,e,r);const i=e.seen.get(t);i.ref=s.innerType},hT=S("ZodISODateTime",(t,e)=>{dA.init(t,e),ue.init(t,e)});function dT(t){return yx(hT,t)}const pT=S("ZodISODate",(t,e)=>{pA.init(t,e),ue.init(t,e)});function fT(t){return bx(pT,t)}const gT=S("ZodISOTime",(t,e)=>{fA.init(t,e),ue.init(t,e)});function mT(t){return wx(gT,t)}const vT=S("ZodISODuration",(t,e)=>{gA.init(t,e),ue.init(t,e)});function yT(t){return _x(vT,t)}const dg=(t,e)=>{Vf.init(t,e),t.name="ZodError",Object.defineProperties(t,{format:{value:n=>i$(t,n)},flatten:{value:n=>s$(t,n)},addIssue:{value:n=>{t.issues.push(n),t.message=JSON.stringify(t.issues,yl,2)}},addIssues:{value:n=>{t.issues.push(...n),t.message=JSON.stringify(t.issues,yl,2)}},isEmpty:{get(){return t.issues.length===0}}})},wd=S("ZodError",dg),tt=S("ZodError",dg,{Parent:Error}),bT=Oc(tt),wT=zc(tt),_T=Zo(tt),ST=jo(tt),kT=l$(tt),ET=c$(tt),$T=u$(tt),AT=h$(tt),xT=d$(tt),TT=p$(tt),CT=f$(tt),IT=g$(tt),ce=S("ZodType",(t,e)=>(le.init(t,e),Object.assign(t["~standard"],{jsonSchema:{input:vo(t,"input"),output:vo(t,"output")}}),t.toJSONSchema=jx(t,{}),t.def=e,t.type=e.type,Object.defineProperty(t,"_def",{value:e}),t.check=(...n)=>t.clone(pn(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)=>fn(t,n,r),t.brand=()=>t,t.register=(n,r)=>(n.add(t,r),t),t.parse=(n,r)=>bT(t,n,r,{callee:t.parse}),t.safeParse=(n,r)=>_T(t,n,r),t.parseAsync=async(n,r)=>wT(t,n,r,{callee:t.parseAsync}),t.safeParseAsync=async(n,r)=>ST(t,n,r),t.spa=t.safeParseAsync,t.encode=(n,r)=>kT(t,n,r),t.decode=(n,r)=>ET(t,n,r),t.encodeAsync=async(n,r)=>$T(t,n,r),t.decodeAsync=async(n,r)=>AT(t,n,r),t.safeEncode=(n,r)=>xT(t,n,r),t.safeDecode=(n,r)=>TT(t,n,r),t.safeEncodeAsync=async(n,r)=>CT(t,n,r),t.safeDecodeAsync=async(n,r)=>IT(t,n,r),t.refine=(n,r)=>t.check(_C(n,r)),t.superRefine=n=>t.check(SC(n)),t.overwrite=n=>t.check(qr(n)),t.optional=()=>kd(t),t.exactOptional=()=>lC(t),t.nullable=()=>Ed(t),t.nullish=()=>kd(Ed(t)),t.nonoptional=n=>fC(t,n),t.array=()=>R(t),t.or=n=>Z([t,n]),t.and=n=>Bo(t,n),t.transform=n=>$d(t,oC(n)),t.default=n=>hC(t,n),t.prefault=n=>pC(t,n),t.catch=n=>mC(t,n),t.pipe=n=>$d(t,n),t.readonly=()=>bC(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)),pg=S("_ZodString",(t,e)=>{Lc.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(r,s,i)=>Bx(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(xx(...r)),t.includes=(...r)=>t.check(Ix(...r)),t.startsWith=(...r)=>t.check(Px(...r)),t.endsWith=(...r)=>t.check(Rx(...r)),t.min=(...r)=>t.check(mo(...r)),t.max=(...r)=>t.check(og(...r)),t.length=(...r)=>t.check(ag(...r)),t.nonempty=(...r)=>t.check(mo(1,...r)),t.lowercase=r=>t.check(Tx(r)),t.uppercase=r=>t.check(Cx(r)),t.trim=()=>t.check(Ox()),t.normalize=(...r)=>t.check(Dx(...r)),t.toLowerCase=()=>t.check(zx()),t.toUpperCase=()=>t.check(Lx()),t.slugify=()=>t.check(Mx())}),PT=S("ZodString",(t,e)=>{Lc.init(t,e),pg.init(t,e),t.email=n=>t.check(JA(RT,n)),t.url=n=>t.check(nx(DT,n)),t.jwt=n=>t.check(vx(qT,n)),t.emoji=n=>t.check(rx(OT,n)),t.guid=n=>t.check(md(_d,n)),t.uuid=n=>t.check(XA(Ui,n)),t.uuidv4=n=>t.check(QA(Ui,n)),t.uuidv6=n=>t.check(ex(Ui,n)),t.uuidv7=n=>t.check(tx(Ui,n)),t.nanoid=n=>t.check(sx(zT,n)),t.guid=n=>t.check(md(_d,n)),t.cuid=n=>t.check(ix(LT,n)),t.cuid2=n=>t.check(ox(MT,n)),t.ulid=n=>t.check(ax(NT,n)),t.base64=n=>t.check(fx(GT,n)),t.base64url=n=>t.check(gx(VT,n)),t.xid=n=>t.check(lx(UT,n)),t.ksuid=n=>t.check(cx(FT,n)),t.ipv4=n=>t.check(ux(ZT,n)),t.ipv6=n=>t.check(hx(jT,n)),t.cidrv4=n=>t.check(dx(WT,n)),t.cidrv6=n=>t.check(px(BT,n)),t.e164=n=>t.check(mx(HT,n)),t.datetime=n=>t.check(dT(n)),t.date=n=>t.check(fT(n)),t.time=n=>t.check(mT(n)),t.duration=n=>t.check(yT(n))});function h(t){return KA(PT,t)}const ue=S("ZodStringFormat",(t,e)=>{oe.init(t,e),pg.init(t,e)}),RT=S("ZodEmail",(t,e)=>{rA.init(t,e),ue.init(t,e)}),_d=S("ZodGUID",(t,e)=>{tA.init(t,e),ue.init(t,e)}),Ui=S("ZodUUID",(t,e)=>{nA.init(t,e),ue.init(t,e)}),DT=S("ZodURL",(t,e)=>{sA.init(t,e),ue.init(t,e)}),OT=S("ZodEmoji",(t,e)=>{iA.init(t,e),ue.init(t,e)}),zT=S("ZodNanoID",(t,e)=>{oA.init(t,e),ue.init(t,e)}),LT=S("ZodCUID",(t,e)=>{aA.init(t,e),ue.init(t,e)}),MT=S("ZodCUID2",(t,e)=>{lA.init(t,e),ue.init(t,e)}),NT=S("ZodULID",(t,e)=>{cA.init(t,e),ue.init(t,e)}),UT=S("ZodXID",(t,e)=>{uA.init(t,e),ue.init(t,e)}),FT=S("ZodKSUID",(t,e)=>{hA.init(t,e),ue.init(t,e)}),ZT=S("ZodIPv4",(t,e)=>{mA.init(t,e),ue.init(t,e)}),jT=S("ZodIPv6",(t,e)=>{vA.init(t,e),ue.init(t,e)}),WT=S("ZodCIDRv4",(t,e)=>{yA.init(t,e),ue.init(t,e)}),BT=S("ZodCIDRv6",(t,e)=>{bA.init(t,e),ue.init(t,e)}),GT=S("ZodBase64",(t,e)=>{wA.init(t,e),ue.init(t,e)}),VT=S("ZodBase64URL",(t,e)=>{SA.init(t,e),ue.init(t,e)}),HT=S("ZodE164",(t,e)=>{kA.init(t,e),ue.init(t,e)}),qT=S("ZodJWT",(t,e)=>{$A.init(t,e),ue.init(t,e)}),fg=S("ZodNumber",(t,e)=>{ng.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(r,s,i)=>Gx(t,r,s),t.gt=(r,s)=>t.check(yd(r,s)),t.gte=(r,s)=>t.check(ja(r,s)),t.min=(r,s)=>t.check(ja(r,s)),t.lt=(r,s)=>t.check(vd(r,s)),t.lte=(r,s)=>t.check(Za(r,s)),t.max=(r,s)=>t.check(Za(r,s)),t.int=r=>t.check(Sd(r)),t.safe=r=>t.check(Sd(r)),t.positive=r=>t.check(yd(0,r)),t.nonnegative=r=>t.check(ja(0,r)),t.negative=r=>t.check(vd(0,r)),t.nonpositive=r=>t.check(Za(0,r)),t.multipleOf=(r,s)=>t.check(bd(r,s)),t.step=(r,s)=>t.check(bd(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 Sx(fg,t)}const YT=S("ZodNumberFormat",(t,e)=>{AA.init(t,e),fg.init(t,e)});function Sd(t){return kx(YT,t)}const KT=S("ZodBoolean",(t,e)=>{xA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>Vx(t,n,r)});function ke(t){return Ex(KT,t)}const JT=S("ZodUnknown",(t,e)=>{TA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>qx()});function w(){return $x(JT)}const XT=S("ZodNever",(t,e)=>{CA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>Hx(t,n,r)});function QT(t){return Ax(XT,t)}const eC=S("ZodArray",(t,e)=>{IA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>Qx(t,n,r,s),t.element=e.element,t.min=(n,r)=>t.check(mo(n,r)),t.nonempty=n=>t.check(mo(1,n)),t.max=(n,r)=>t.check(og(n,r)),t.length=(n,r)=>t.check(ag(n,r)),t.unwrap=()=>t.element});function R(t,e){return Nx(eC,t,e)}const gg=S("ZodObject",(t,e)=>{RA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>eT(t,n,r,s),ee(t,"shape",()=>e.shape),t.keyof=()=>yo(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:QT()}),t.strip=()=>t.clone({...t._zod.def,catchall:void 0}),t.extend=n=>QE(t,n),t.safeExtend=n=>e$(t,n),t.merge=n=>t$(t,n),t.pick=n=>JE(t,n),t.omit=n=>XE(t,n),t.partial=(...n)=>n$(vg,t,n[0]),t.required=(...n)=>r$(yg,t,n[0])});function mg(t,e){const n={type:"object",shape:t??{},...O(e)};return new gg(n)}function f(t,e){return new gg({type:"object",shape:t,catchall:w(),...O(e)})}const tC=S("ZodUnion",(t,e)=>{DA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>tT(t,n,r,s),t.options=e.options});function Z(t,e){return new tC({type:"union",options:t,...O(e)})}const nC=S("ZodIntersection",(t,e)=>{OA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>nT(t,n,r,s)});function Bo(t,e){return new nC({type:"intersection",left:t,right:e})}const rC=S("ZodRecord",(t,e)=>{zA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>rT(t,n,r,s),t.keyType=e.keyType,t.valueType=e.valueType});function _(t,e,n){return new rC({type:"record",keyType:t,valueType:e,...O(n)})}const wl=S("ZodEnum",(t,e)=>{LA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(r,s,i)=>Yx(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 wl({...e,checks:[],...O(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 wl({...e,checks:[],...O(s),entries:i})}});function yo(t,e){const n=Array.isArray(t)?Object.fromEntries(t.map(r=>[r,r])):t;return new wl({type:"enum",entries:n,...O(e)})}const sC=S("ZodLiteral",(t,e)=>{MA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>Kx(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 sC({type:"literal",values:Array.isArray(t)?t:[t],...O(e)})}const iC=S("ZodTransform",(t,e)=>{NA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>Xx(t,n),t._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Ff(t.constructor.name);n.addIssue=i=>{if(typeof i=="string")n.issues.push(Ts(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(Ts(o))}};const s=e.transform(n.value,n);return s instanceof Promise?s.then(i=>(n.value=i,n)):(n.value=s,n)}});function oC(t){return new iC({type:"transform",transform:t})}const vg=S("ZodOptional",(t,e)=>{ig.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>hg(t,n,r,s),t.unwrap=()=>t._zod.def.innerType});function kd(t){return new vg({type:"optional",innerType:t})}const aC=S("ZodExactOptional",(t,e)=>{UA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>hg(t,n,r,s),t.unwrap=()=>t._zod.def.innerType});function lC(t){return new aC({type:"optional",innerType:t})}const cC=S("ZodNullable",(t,e)=>{FA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>sT(t,n,r,s),t.unwrap=()=>t._zod.def.innerType});function Ed(t){return new cC({type:"nullable",innerType:t})}const uC=S("ZodDefault",(t,e)=>{ZA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>oT(t,n,r,s),t.unwrap=()=>t._zod.def.innerType,t.removeDefault=t.unwrap});function hC(t,e){return new uC({type:"default",innerType:t,get defaultValue(){return typeof e=="function"?e():Bf(e)}})}const dC=S("ZodPrefault",(t,e)=>{jA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>aT(t,n,r,s),t.unwrap=()=>t._zod.def.innerType});function pC(t,e){return new dC({type:"prefault",innerType:t,get defaultValue(){return typeof e=="function"?e():Bf(e)}})}const yg=S("ZodNonOptional",(t,e)=>{WA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>iT(t,n,r,s),t.unwrap=()=>t._zod.def.innerType});function fC(t,e){return new yg({type:"nonoptional",innerType:t,...O(e)})}const gC=S("ZodCatch",(t,e)=>{BA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>lT(t,n,r,s),t.unwrap=()=>t._zod.def.innerType,t.removeCatch=t.unwrap});function mC(t,e){return new gC({type:"catch",innerType:t,catchValue:typeof e=="function"?e:()=>e})}const vC=S("ZodPipe",(t,e)=>{GA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>cT(t,n,r,s),t.in=e.in,t.out=e.out});function $d(t,e){return new vC({type:"pipe",in:t,out:e})}const yC=S("ZodReadonly",(t,e)=>{VA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>uT(t,n,r,s),t.unwrap=()=>t._zod.def.innerType});function bC(t){return new yC({type:"readonly",innerType:t})}const wC=S("ZodCustom",(t,e)=>{HA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>Jx(t,n)});function _C(t,e={}){return Ux(wC,t,e)}function SC(t){return Fx(t)}const kC=["text/markdown","text/html"],EC=["committed","pending"];mg({id:h().min(1),type:yo(kC),title:h(),status:yo(EC),externalFilePath:h().optional()});mg({name:h().min(1),description:h(),accepts:R(h().min(1)).min(1)});function Mc(t){return typeof t=="object"&&t!==null}function $C(t){return!Mc(t)||t.type!=="ready"?!1:!("id"in t)}function AC(t){return!(!Mc(t)||t.type!=="update-content"||typeof t.id!="string"||typeof t.content!="string")}function xC(t){return!Mc(t)||t.type!=="wheel"||typeof t.deltaX!="number"||typeof t.deltaY!="number"||typeof t.shiftKey!="boolean"?!1:!("id"in t)}function TC(t,e){if(t===e)return 2;if(t==="*/*")return 0;const n=t.indexOf("/");if(n>0&&t.slice(n+1)==="*"){const r=t.slice(0,n),s=e.indexOf("/");if(s>0&&e.slice(0,s)===r)return 1}return null}function CC(t,e){let n=null;for(const r of t.accepts){const s=TC(r,e);s!==null&&(n===null||s>n)&&(n=s)}return n}function IC(t,e){let n=-1,r=null;for(const s of e){const i=CC(s,t);i!==null&&(i>n||i===n&&r!==null&&s.id<r.id)&&(n=i,r=s)}return r}const PC=4401;class _l extends Error{constructor(e="Authentication required"){super(e),this.name="AuthError"}}class Sl 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 zE(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(RC(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=p=>{a||this.connectAttempt!==n||(a=!0,this.status="disconnected",this.dispatchEvent(new te("change")),o(p))},d=async()=>{try{const[{screens:p},y]=await Promise.all([this.client.screens.list(),this.client.views.list()]);this.screens=new Map(p.map(m=>[m.id,structuredClone(m)])),this.views=y,this.dispatchEvent(new te("change")),l()}catch(p){c(p instanceof Error?p:new Error(String(p)))}};r.addEventListener("open",()=>{d()}),r.addEventListener("message",p=>{const y=OC(p);y&&(this.applyServerEvent(y),this.dispatchEvent(new Cf("server-event",{serverURL:this.url,event:y})))}),r.addEventListener("close",p=>{if(this.connectAttempt===n){if(this.socket=null,DC(p)===PC){c(new _l);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=IC(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 eo("screens-changed"));break;case"screen-updated":this.screens.set(n.screen.id,structuredClone(n.screen)),this.dispatchEvent(new eo("screens-changed"));break;case"screen-removed":this.screens.delete(n.screenID),this.dispatchEvent(new eo("screens-changed"));break;case"artifact-created":{const r=this.screens.get(n.screenID);r&&!Af(r.layout,n.artifact.id)&&(r.layout=[...r.layout,$f(n.artifact.id)]);break}case"artifact-removed":{const r=this.screens.get(n.screenID);r&&(r.layout=mf(r.layout,n.artifactID));break}}}}function RC(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 DC(t){return typeof t=="object"&&t!==null&&"code"in t&&typeof t.code=="number"?t.code:null}function OC(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 zC 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 Cf("server-event",{serverURL:l.serverURL,event:l.event}))},a=()=>{this.dispatchEvent(new eo("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 Sl({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 Sl({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"},Tt={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"},LC=1,MC=f({_meta:_(h(),w()).nullish(),terminal:ke().optional().default(!1)}),NC=f({_meta:_(h(),w()).nullish(),label:h().nullish(),name:h(),optional:ke().optional().default(!1),secret:ke().optional().default(!0)}),UC=f({_meta:_(h(),w()).nullish(),description:h().nullish(),id:h(),name:h()}),FC=f({_meta:_(h(),w()).nullish(),description:h().nullish(),id:h(),link:h().nullish(),name:h(),vars:R(NC)}),ZC=f({_meta:_(h(),w()).nullish(),args:R(h()).optional(),description:h().nullish(),env:_(h(),h()).optional(),id:h(),name:h()}),jC=Z([FC.and(f({type:A("env_var")})),ZC.and(f({type:A("terminal")})),UC]),WC=f({_meta:_(h(),w()).nullish(),methodId:h()}),BC=f({_meta:_(h(),w()).nullish()}),GC=f({_meta:_(h(),w()).nullish(),blob:h(),mimeType:h().nullish(),uri:h()}),VC=f({default:ke().nullish(),description:h().nullish(),title:h().nullish()}),HC=f({_meta:_(h(),w()).nullish()}),qC=f({_meta:_(h(),w()).nullish()}),YC=f({amount:U(),currency:h()}),KC=f({_meta:_(h(),w()).nullish(),terminalId:h()}),JC=f({_meta:_(h(),w()).nullish(),newText:h(),oldText:h().nullish(),path:h()}),XC=Z([h(),U(),U(),ke(),R(h())]),QC=f({content:_(h(),XC).nullish()}),eI=Z([QC.and(f({action:A("accept")})),f({action:A("decline")}),f({action:A("cancel")})]),tI=f({_meta:_(h(),w()).nullish()}),bg=h(),nI=f({_meta:_(h(),w()).nullish(),elicitationId:bg}),rI=f({_meta:_(h(),w()).nullish(),action:eI}),sI=A("object"),iI=A("string"),oI=f({_meta:_(h(),w()).nullish()}),aI=f({_meta:_(h(),w()).nullish(),form:tI.nullish(),url:oI.nullish()}),lI=f({elicitationId:bg,url:h().url()}),wg=f({const:h(),title:h()}),_g=f({_meta:_(h(),w()).nullish(),name:h(),value:h()}),cI=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"})]),Sg=f({code:cI,data:w().optional(),message:h()}),kg=w(),Eg=w(),$g=w(),uI=f({_meta:_(h(),w()).nullish(),readTextFile:ke().optional().default(!1),writeTextFile:ke().optional().default(!1)}),Ag=f({_meta:_(h(),w()).nullish(),name:h(),value:h()}),xg=f({_meta:_(h(),w()).nullish(),name:h(),title:h().nullish(),version:h()}),hI=f({default:U().nullish(),description:h().nullish(),maximum:U().nullish(),minimum:U().nullish(),title:h().nullish()}),dI=f({_meta:_(h(),w()).nullish()}),pI=f({_meta:_(h(),w()).nullish(),additionalDirectories:R(h()).optional(),cursor:h().nullish(),cwd:h().nullish()}),fI=f({_meta:_(h(),w()).nullish()}),gI=f({_meta:_(h(),w()).nullish(),logout:fI.nullish()}),mI=f({_meta:_(h(),w()).nullish()}),vI=f({_meta:_(h(),w()).nullish()}),yI=f({_meta:_(h(),w()).nullish(),http:ke().optional().default(!1),sse:ke().optional().default(!1)}),bI=f({_meta:_(h(),w()).nullish(),headers:R(Ag),name:h(),url:h()}),wI=f({_meta:_(h(),w()).nullish(),headers:R(Ag),name:h(),url:h()}),_I=f({_meta:_(h(),w()).nullish(),args:R(h()),command:h(),env:R(_g),name:h()}),Go=Z([bI.and(f({type:A("http")})),wI.and(f({type:A("sse")})),_I]),Nc=h(),SI=f({_meta:_(h(),w()).nullish(),description:h().nullish(),modelId:Nc,name:h()}),kI=Z([A("error"),A("warning"),A("information"),A("hint")]),EI=f({_meta:_(h(),w()).nullish()}),$I=f({_meta:_(h(),w()).nullish()}),AI=f({_meta:_(h(),w()).nullish()}),xI=f({_meta:_(h(),w()).nullish()}),TI=f({_meta:_(h(),w()).nullish()}),CI=f({_meta:_(h(),w()).nullish(),maxCount:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),II=f({diff:h(),uri:h()}),PI=f({endLine:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),startLine:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),text:h()}),RI=f({_meta:_(h(),w()).nullish()}),DI=f({_meta:_(h(),w()).nullish()}),OI=f({languageId:h(),text:h(),uri:h()}),zI=f({_meta:_(h(),w()).nullish(),maxCount:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),LI=Z([A("rejected"),A("ignored"),A("replaced"),A("cancelled")]),MI=f({excerpts:R(PI),uri:h()}),NI=f({_meta:_(h(),w()).nullish()}),UI=f({_meta:_(h(),w()).nullish()}),FI=f({name:h(),owner:h(),remoteUrl:h()}),ZI=f({_meta:_(h(),w()).nullish()}),jI=f({_meta:_(h(),w()).nullish(),jump:RI.nullish(),rename:UI.nullish(),searchAndReplace:ZI.nullish()}),WI=f({id:h(),isRegex:ke().nullish(),replace:h(),search:h(),uri:h()}),BI=Z([A("automatic"),A("diagnostic"),A("manual")]),GI=f({_meta:_(h(),w()).nullish(),maxCount:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),VI=f({_meta:_(h(),w()).nullish(),diagnostics:EI.nullish(),editHistory:CI.nullish(),openFiles:DI.nullish(),recentFiles:zI.nullish(),relatedSnippets:NI.nullish(),userActions:GI.nullish()}),HI=f({_meta:_(h(),w()).nullish(),additionalDirectories:R(h()).optional(),cwd:h(),mcpServers:R(Go)}),qI=f({default:U().nullish(),description:h().nullish(),maximum:U().nullish(),minimum:U().nullish(),title:h().nullish()}),Tg=h(),YI=Z([A("allow_once"),A("allow_always"),A("reject_once"),A("reject_always")]),KI=f({_meta:_(h(),w()).nullish(),kind:YI,name:h(),optionId:Tg}),JI=Z([A("high"),A("medium"),A("low")]),XI=Z([A("pending"),A("in_progress"),A("completed")]),QI=f({_meta:_(h(),w()).nullish(),content:h(),priority:JI,status:XI}),e0=f({_meta:_(h(),w()).nullish(),entries:R(QI)}),ln=f({character:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),line:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"})}),t0=f({id:h(),position:ln,uri:h()}),n0=f({id:h(),newName:h(),position:ln,uri:h()}),r0=f({action:h(),position:ln,timestampMs:U(),uri:h()}),Cg=Z([A("utf-16"),A("utf-32"),A("utf-8")]),s0=f({_meta:_(h(),w()).nullish(),auth:MC.optional().default({terminal:!1}),elicitation:aI.nullish(),fs:uI.optional().default({readTextFile:!1,writeTextFile:!1}),nes:jI.nullish(),positionEncodings:R(Cg).optional(),terminal:ke().optional().default(!1)}),i0=f({_meta:_(h(),w()).nullish(),audio:ke().optional().default(!1),embeddedContext:ke().optional().default(!1),image:ke().optional().default(!1)}),Ig=U().int().gte(0).lte(65535),o0=f({_meta:_(h(),w()).nullish(),clientCapabilities:s0.optional().default({auth:{terminal:!1},fs:{readTextFile:!1,writeTextFile:!1},terminal:!1}),clientInfo:xg.nullish(),protocolVersion:Ig}),Yr=f({end:ln,start:ln}),a0=f({message:h(),range:Yr,severity:kI,uri:h()}),l0=f({languageId:h(),lastFocusedMs:U().nullish(),uri:h(),visibleRange:Yr.nullish()}),c0=f({_meta:_(h(),w()).nullish(),diagnostics:R(a0).nullish(),editHistory:R(II).nullish(),openFiles:R(l0).nullish(),recentFiles:R(OI).nullish(),relatedSnippets:R(MI).nullish(),userActions:R(r0).nullish()}),u0=f({newText:h(),range:Yr}),h0=f({cursorPosition:ln.nullish(),edits:R(u0),id:h(),uri:h()}),d0=Z([h0.and(f({kind:A("edit")})),t0.and(f({kind:A("jump")})),n0.and(f({kind:A("rename")})),WI.and(f({kind:A("searchAndReplace")}))]),p0=f({_meta:_(h(),w()).nullish(),content:h()}),f0=f({_meta:_(h(),w()).nullish()}),Bn=Z([U(),h()]).nullable();f({_meta:_(h(),w()).nullish(),requestId:Bn});const g0=yo(["assistant","user"]),vi=f({_meta:_(h(),w()).nullish(),audience:R(g0).nullish(),lastModified:h().nullish(),priority:U().nullish()}),m0=f({_meta:_(h(),w()).nullish(),annotations:vi.nullish(),data:h(),mimeType:h()}),v0=f({_meta:_(h(),w()).nullish(),annotations:vi.nullish(),data:h(),mimeType:h(),uri:h().nullish()}),y0=f({_meta:_(h(),w()).nullish(),annotations:vi.nullish(),description:h().nullish(),mimeType:h().nullish(),name:h(),size:U().nullish(),title:h().nullish(),uri:h()}),b0=f({_meta:_(h(),w()).nullish(),optionId:Tg}),w0=Z([f({outcome:A("cancelled")}),b0.and(f({outcome:A("selected")}))]),_0=f({_meta:_(h(),w()).nullish(),outcome:w0}),S0=f({_meta:_(h(),w()).nullish()}),k0=f({_meta:_(h(),w()).nullish()}),E0=f({currentValue:ke()}),$0=h(),Pg=h(),A0=Z([A("mode"),A("model"),A("thought_level"),h()]),Uc=h(),Rg=f({_meta:_(h(),w()).nullish(),description:h().nullish(),name:h(),value:Uc}),x0=f({_meta:_(h(),w()).nullish(),group:$0,name:h(),options:R(Rg)}),T0=Z([R(Rg),R(x0)]),C0=f({currentValue:Uc,options:T0}),Kr=Bo(Z([C0.and(f({type:A("select")})),E0.and(f({type:A("boolean")}))]),f({_meta:_(h(),w()).nullish(),category:A0.nullish(),description:h().nullish(),id:Pg,name:h()})),I0=f({_meta:_(h(),w()).nullish(),configOptions:R(Kr)}),P0=f({_meta:_(h(),w()).nullish()}),K=h(),R0=f({_meta:_(h(),w()).nullish(),id:h(),sessionId:K}),D0=f({_meta:_(h(),w()).nullish(),sessionId:K}),O0=f({_meta:_(h(),w()).nullish(),sessionId:K}),z0=f({_meta:_(h(),w()).nullish(),sessionId:K}),Dg=f({_meta:_(h(),w()).nullish(),args:R(h()).optional(),command:h(),cwd:h().nullish(),env:R(_g).optional(),outputByteLimit:U().nullish(),sessionId:K}),L0=f({_meta:_(h(),w()).nullish(),sessionId:K,uri:h()}),M0=f({_meta:_(h(),w()).nullish(),position:ln,sessionId:K,uri:h(),version:U(),visibleRange:Yr}),N0=f({_meta:_(h(),w()).nullish(),languageId:h(),sessionId:K,text:h(),uri:h(),version:U()}),U0=f({_meta:_(h(),w()).nullish(),sessionId:K,uri:h()}),F0=f({_meta:_(h(),w()).nullish(),additionalDirectories:R(h()).optional(),cwd:h(),mcpServers:R(Go).optional(),sessionId:K}),Og=f({_meta:_(h(),w()).nullish(),sessionId:K,terminalId:h()}),Z0=f({_meta:_(h(),w()).nullish(),additionalDirectories:R(h()).optional(),cwd:h(),mcpServers:R(Go),sessionId:K}),zg=f({_meta:_(h(),w()).nullish(),limit:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),line:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:h(),sessionId:K}),j0=f({_meta:_(h(),w()).nullish(),id:h(),reason:LI.nullish(),sessionId:K}),Lg=f({_meta:_(h(),w()).nullish(),sessionId:K,terminalId:h()}),W0=f({_meta:_(h(),w()).nullish(),additionalDirectories:R(h()).optional(),cwd:h(),mcpServers:R(Go).optional(),sessionId:K}),B0=f({_meta:_(h(),w()).nullish(),additionalDirectories:R(h()).optional(),cwd:h(),sessionId:K,title:h().nullish(),updatedAt:h().nullish()}),G0=f({_meta:_(h(),w()).nullish(),nextCursor:h().nullish(),sessions:R(B0)}),V0=f({_meta:_(h(),w()).nullish(),title:h().nullish(),updatedAt:h().nullish()}),H0=f({_meta:_(h(),w()).nullish()}),Vo=h(),q0=f({_meta:_(h(),w()).nullish(),currentModeId:Vo}),Y0=f({_meta:_(h(),w()).nullish(),description:h().nullish(),id:Vo,name:h()}),Ho=f({_meta:_(h(),w()).nullish(),availableModes:R(Y0),currentModeId:Vo}),qo=f({_meta:_(h(),w()).nullish(),availableModels:R(SI),currentModelId:Nc}),K0=f({_meta:_(h(),w()).nullish(),configOptions:R(Kr).nullish(),models:qo.nullish(),modes:Ho.nullish(),sessionId:K}),J0=f({_meta:_(h(),w()).nullish(),configOptions:R(Kr).nullish(),models:qo.nullish(),modes:Ho.nullish()}),X0=f({_meta:_(h(),w()).nullish(),configOptions:R(Kr).nullish(),models:qo.nullish(),modes:Ho.nullish(),sessionId:K}),Q0=f({_meta:_(h(),w()).nullish(),configOptions:R(Kr).nullish(),models:qo.nullish(),modes:Ho.nullish()}),eP=f({_meta:_(h(),w()).nullish()}),tP=f({_meta:_(h(),w()).nullish(),additionalDirectories:S0.nullish(),close:k0.nullish(),fork:P0.nullish(),list:H0.nullish(),resume:eP.nullish()}),nP=Bo(Z([f({type:A("boolean"),value:ke()}),f({value:Uc})]),f({_meta:_(h(),w()).nullish(),configId:Pg,sessionId:K})),rP=f({_meta:_(h(),w()).nullish(),configOptions:R(Kr)}),sP=f({_meta:_(h(),w()).nullish(),modeId:Vo,sessionId:K}),iP=f({_meta:_(h(),w()).nullish()}),oP=f({_meta:_(h(),w()).nullish(),modelId:Nc,sessionId:K}),aP=f({_meta:_(h(),w()).nullish()}),lP=f({_meta:_(h(),w()).nullish(),sessionId:K}),cP=Z([A("end_turn"),A("max_tokens"),A("max_turn_requests"),A("refusal"),A("cancelled")]),uP=Z([A("email"),A("uri"),A("date"),A("date-time")]),hP=f({default:h().nullish(),description:h().nullish(),enum:R(h()).nullish(),format:uP.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(wg).nullish(),pattern:h().nullish(),title:h().nullish()}),dP=f({_meta:_(h(),w()).nullish(),context:c0.nullish(),position:ln,selection:Yr.nullish(),sessionId:K,triggerKind:BI,uri:h(),version:U()}),pP=f({_meta:_(h(),w()).nullish(),suggestions:R(d0)}),fP=f({_meta:_(h(),w()).nullish(),terminalId:h()}),gP=f({_meta:_(h(),w()).nullish(),exitCode:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:h().nullish()}),Mg=f({_meta:_(h(),w()).nullish(),sessionId:K,terminalId:h()}),mP=f({_meta:_(h(),w()).nullish(),exitStatus:gP.nullish(),output:h(),truncated:ke()}),vP=f({_meta:_(h(),w()).nullish(),annotations:vi.nullish(),text:h()}),yP=f({range:Yr.nullish(),text:h()}),bP=f({_meta:_(h(),w()).nullish(),contentChanges:R(yP),sessionId:K,uri:h(),version:U()});f({method:h(),params:Z([D0,N0,bP,L0,U0,M0,R0,j0,kg]).nullish()});const wP=Z([A("full"),A("incremental")]),_P=f({_meta:_(h(),w()).nullish(),syncKind:wP}),SP=f({_meta:_(h(),w()).nullish(),didChange:_P.nullish(),didClose:$I.nullish(),didFocus:AI.nullish(),didOpen:xI.nullish(),didSave:TI.nullish()}),kP=f({_meta:_(h(),w()).nullish(),document:SP.nullish()}),EP=f({_meta:_(h(),w()).nullish(),context:VI.nullish(),events:kP.nullish()}),$P=f({_meta:_(h(),w()).nullish(),auth:gI.optional().default({}),loadSession:ke().optional().default(!1),mcpCapabilities:yI.optional().default({http:!1,sse:!1}),nes:EP.nullish(),positionEncoding:Cg.nullish(),promptCapabilities:i0.optional().default({audio:!1,embeddedContext:!1,image:!1}),sessionCapabilities:tP.optional().default({})}),AP=f({_meta:_(h(),w()).nullish(),agentCapabilities:$P.optional().default({auth:{},loadSession:!1,mcpCapabilities:{http:!1,sse:!1},promptCapabilities:{audio:!1,embeddedContext:!1,image:!1},sessionCapabilities:{}}),agentInfo:xg.nullish(),authMethods:R(jC).optional().default([]),protocolVersion:Ig}),xP=f({_meta:_(h(),w()).nullish(),mimeType:h().nullish(),text:h(),uri:h()}),TP=Z([xP,GC]),CP=f({_meta:_(h(),w()).nullish(),annotations:vi.nullish(),resource:TP}),Fc=Z([vP.and(f({type:A("text")})),v0.and(f({type:A("image")})),m0.and(f({type:A("audio")})),y0.and(f({type:A("resource_link")})),CP.and(f({type:A("resource")}))]),IP=f({_meta:_(h(),w()).nullish(),content:Fc}),Wa=f({_meta:_(h(),w()).nullish(),content:Fc,messageId:h().nullish()}),PP=f({_meta:_(h(),w()).nullish(),messageId:h().nullish(),prompt:R(Fc),sessionId:K}),RP=f({anyOf:R(wg)}),Ng=Z([IP.and(f({type:A("content")})),JC.and(f({type:A("diff")})),fP.and(f({type:A("terminal")}))]),Ug=h(),Fg=f({_meta:_(h(),w()).nullish(),line:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:h()}),Zg=Z([A("pending"),A("in_progress"),A("completed"),A("failed")]),jg=Z([A("read"),A("edit"),A("delete"),A("move"),A("search"),A("execute"),A("think"),A("fetch"),A("switch_mode"),A("other")]),DP=f({_meta:_(h(),w()).nullish(),content:R(Ng).optional(),kind:jg.optional(),locations:R(Fg).optional(),rawInput:w().optional(),rawOutput:w().optional(),status:Zg.optional(),title:h(),toolCallId:Ug}),Wg=f({_meta:_(h(),w()).nullish(),content:R(Ng).nullish(),kind:jg.nullish(),locations:R(Fg).nullish(),rawInput:w().optional(),rawOutput:w().optional(),status:Zg.nullish(),title:h().nullish(),toolCallId:Ug}),Bg=f({_meta:_(h(),w()).nullish(),options:R(KI),sessionId:K,toolCall:Wg}),OP=f({_meta:_(h(),w()).nullish(),hint:h()}),zP=OP,LP=f({_meta:_(h(),w()).nullish(),description:h(),input:zP.nullish(),name:h()}),MP=f({_meta:_(h(),w()).nullish(),availableCommands:R(LP)}),NP=f({enum:R(h()),type:iI}),UP=Z([NP,RP]),FP=f({default:R(h()).nullish(),description:h().nullish(),items:UP,maxItems:U().nullish(),minItems:U().nullish(),title:h().nullish()}),ZP=Z([hP.and(f({type:A("string")})),qI.and(f({type:A("number")})),hI.and(f({type:A("integer")})),VC.and(f({type:A("boolean")})),FP.and(f({type:A("array")}))]),jP=f({description:h().nullish(),properties:_(h(),ZP).optional().default({}),required:R(h()).nullish(),title:h().nullish(),type:sI.optional().default("object")}),WP=f({requestedSchema:jP}),BP=Bo(Z([WP.and(f({mode:A("form")})),lI.and(f({mode:A("url")}))]),f({_meta:_(h(),w()).nullish(),message:h(),sessionId:K})),GP=f({cachedReadTokens:U().nullish(),cachedWriteTokens:U().nullish(),inputTokens:U(),outputTokens:U(),thoughtTokens:U().nullish(),totalTokens:U()}),VP=f({_meta:_(h(),w()).nullish(),stopReason:cP,usage:GP.nullish(),userMessageId:h().nullish()});Z([f({id:Bn,result:Z([AP,BC,vI,X0,J0,G0,K0,Q0,qC,iP,rP,VP,aP,lP,pP,HC,$g])}),f({error:Sg,id:Bn})]);const HP=f({_meta:_(h(),w()).nullish(),cost:YC.nullish(),size:U(),used:U()}),qP=Z([Wa.and(f({sessionUpdate:A("user_message_chunk")})),Wa.and(f({sessionUpdate:A("agent_message_chunk")})),Wa.and(f({sessionUpdate:A("agent_thought_chunk")})),DP.and(f({sessionUpdate:A("tool_call")})),Wg.and(f({sessionUpdate:A("tool_call_update")})),e0.and(f({sessionUpdate:A("plan")})),MP.and(f({sessionUpdate:A("available_commands_update")})),q0.and(f({sessionUpdate:A("current_mode_update")})),I0.and(f({sessionUpdate:A("config_option_update")})),V0.and(f({sessionUpdate:A("session_info_update")})),HP.and(f({sessionUpdate:A("usage_update")}))]),Gg=f({_meta:_(h(),w()).nullish(),sessionId:K,update:qP});f({method:h(),params:Z([Gg,nI,kg]).nullish()});const Vg=f({_meta:_(h(),w()).nullish(),sessionId:K,terminalId:h()}),YP=f({_meta:_(h(),w()).nullish(),exitCode:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:h().nullish()}),KP=f({name:h(),uri:h()}),JP=f({_meta:_(h(),w()).nullish(),repository:FI.nullish(),workspaceFolders:R(KP).nullish(),workspaceUri:h().nullish()});f({id:Bn,method:h(),params:Z([o0,WC,mI,HI,Z0,pI,F0,W0,z0,sP,nP,PP,oP,JP,dP,O0,Eg]).nullish()});const Hg=f({_meta:_(h(),w()).nullish(),content:h(),path:h(),sessionId:K});f({id:Bn,method:h(),params:Z([Hg,zg,Bg,Dg,Mg,Lg,Vg,Og,BP,Eg]).nullish()});const XP=f({_meta:_(h(),w()).nullish()});Z([f({id:Bn,result:Z([XP,p0,_0,KC,mP,f0,YP,dI,rI,$g])}),f({error:Sg,id:Bn})]);var Y;class QP{constructor(e,n){$(this,Y);const r=e(this),s=async(o,a)=>{var l,c,d,p,y,m,E;switch(o){case Tt.fs_write_text_file:{const k=Hg.parse(a);return(l=r.writeTextFile)==null?void 0:l.call(r,k)}case Tt.fs_read_text_file:{const k=zg.parse(a);return(c=r.readTextFile)==null?void 0:c.call(r,k)}case Tt.session_request_permission:{const k=Bg.parse(a);return r.requestPermission(k)}case Tt.terminal_create:{const k=Dg.parse(a);return(d=r.createTerminal)==null?void 0:d.call(r,k)}case Tt.terminal_output:{const k=Mg.parse(a);return(p=r.terminalOutput)==null?void 0:p.call(r,k)}case Tt.terminal_release:{const k=Lg.parse(a);return await((y=r.releaseTerminal)==null?void 0:y.call(r,k))??{}}case Tt.terminal_wait_for_exit:{const k=Vg.parse(a);return(m=r.waitForTerminalExit)==null?void 0:m.call(r,k)}case Tt.terminal_kill:{const k=Og.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 Tt.session_update:{const l=Gg.parse(a);return r.sessionUpdate(l)}default:if(r.extNotification)return r.extNotification(o,a);throw ye.methodNotFound(o)}};x(this,Y,new eR(s,i,n))}async initialize(e){return await u(this,Y).sendRequest(ie.initialize,e)}async newSession(e){return await u(this,Y).sendRequest(ie.session_new,e)}async loadSession(e){return await u(this,Y).sendRequest(ie.session_load,e)??{}}async unstable_forkSession(e){return await u(this,Y).sendRequest(ie.session_fork,e)}async listSessions(e){return await u(this,Y).sendRequest(ie.session_list,e)}async unstable_resumeSession(e){return await u(this,Y).sendRequest(ie.session_resume,e)}async unstable_closeSession(e){return await u(this,Y).sendRequest(ie.session_close,e)}async setSessionMode(e){return await u(this,Y).sendRequest(ie.session_set_mode,e)??{}}async unstable_setSessionModel(e){return await u(this,Y).sendRequest(ie.session_set_model,e)??{}}async setSessionConfigOption(e){return await u(this,Y).sendRequest(ie.session_set_config_option,e)}async authenticate(e){return await u(this,Y).sendRequest(ie.authenticate,e)??{}}async unstable_logout(e){return await u(this,Y).sendRequest(ie.logout,e)??{}}async prompt(e){return await u(this,Y).sendRequest(ie.session_prompt,e)}async cancel(e){return await u(this,Y).sendNotification(ie.session_cancel,e)}async unstable_startNes(e){return await u(this,Y).sendRequest(ie.nes_start,e)}async unstable_suggestNes(e){return await u(this,Y).sendRequest(ie.nes_suggest,e)}async unstable_closeNes(e){return await u(this,Y).sendRequest(ie.nes_close,e)??{}}async unstable_didOpenDocument(e){return await u(this,Y).sendNotification(ie.document_did_open,e)}async unstable_didChangeDocument(e){return await u(this,Y).sendNotification(ie.document_did_change,e)}async unstable_didCloseDocument(e){return await u(this,Y).sendNotification(ie.document_did_close,e)}async unstable_didSaveDocument(e){return await u(this,Y).sendNotification(ie.document_did_save,e)}async unstable_didFocusDocument(e){return await u(this,Y).sendNotification(ie.document_did_focus,e)}async unstable_acceptNes(e){return await u(this,Y).sendNotification(ie.nes_accept,e)}async unstable_rejectNes(e){return await u(this,Y).sendNotification(ie.nes_reject,e)}async extMethod(e,n){return await u(this,Y).sendRequest(e,n)}async extNotification(e,n){return await u(this,Y).sendNotification(e,n)}get signal(){return u(this,Y).signal}get closed(){return u(this,Y).closed}}Y=new WeakMap;var Yt,Ao,Us,Fs,Sr,kr,yt,Zs,ae,qg,kl,Yg,Kg,Jg,Xg,El,ms;class eR{constructor(e,n,r){$(this,ae);$(this,Yt,new Map);$(this,Ao,0);$(this,Us);$(this,Fs);$(this,Sr);$(this,kr,Promise.resolve());$(this,yt,new AbortController);$(this,Zs);x(this,Us,e),x(this,Fs,n),x(this,Sr,r),x(this,Zs,new Promise(s=>{u(this,yt).signal.addEventListener("abort",()=>s())})),b(this,ae,qg).call(this)}get signal(){return u(this,yt).signal}get closed(){return u(this,Zs)}async sendRequest(e,n){b(this,ae,El).call(this);const r=xu(this,Ao)._++,s=new Promise((i,o)=>{u(this,Yt).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,El).call(this),await b(this,ae,ms).call(this,{jsonrpc:"2.0",method:e,params:n})}}Yt=new WeakMap,Ao=new WeakMap,Us=new WeakMap,Fs=new WeakMap,Sr=new WeakMap,kr=new WeakMap,yt=new WeakMap,Zs=new WeakMap,ae=new WeakSet,qg=async function(){let e;try{const n=u(this,Sr).readable.getReader();try{for(;!u(this,yt).signal.aborted;){const{value:r,done:s}=await n.read();if(s)break;if(r)try{b(this,ae,Yg).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,kl).call(this,e)}},kl=function(e){if(u(this,yt).signal.aborted)return;const n=e??new Error("ACP connection closed");for(const r of u(this,Yt).values())r.reject(n);u(this,Yt).clear(),u(this,yt).abort(n)},Yg=async function(e){if("method"in e&&"id"in e){const n=await b(this,ae,Kg).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,Jg).call(this,e.method,e.params);"error"in n&&console.error("Error handling notification",e,n.error)}else"id"in e?b(this,ae,Xg).call(this,e):console.error("Invalid message",{message:e})},Kg=async function(e,n){try{return{result:await u(this,Us).call(this,e,n)??null}}catch(r){if(r instanceof ye)return r.toResult();if(r instanceof wd)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()}}},Jg=async function(e,n){try{return await u(this,Fs).call(this,e,n),{result:null}}catch(r){if(r instanceof ye)return r.toResult();if(r instanceof wd)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()}}},Xg=function(e){const n=u(this,Yt).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))}u(this,Yt).delete(e.id)}else console.error("Got response to unknown request",e.id)},El=function(){if(u(this,yt).signal.aborted)throw u(this,yt).signal.reason??new Error("ACP connection closed")},ms=async function(e){return x(this,kr,u(this,kr).then(async()=>{const n=u(this,Sr).writable.getWriter();try{await n.write(e)}finally{n.releaseLock()}}).catch(n=>{b(this,ae,kl).call(this,n)})),u(this,kr)};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 tR=/^Sender \(untrusted metadata\):\n```json\n[\s\S]*?\n```\n\n?/,nR=/^\[[^\n]*Working directory:[^\n]*\]\n\n?/,rR=/\[Television screen context\][\s\S]*?\[\/Television screen context\]\n*/,sR=/\[\[\s*(?:reply_to_current|reply_to\s*:\s*[^\]\n]+|audio_as_voice)\s*\]\]\s*/gi,iR="single_session",oR={name:"television-acp-client",version:"0.0.0"},Qg="agent:main:television",aR=Hr(kt);var ne,Rt,Er,Dt,On,zn,Kt,$r,bt,rt,Jt,Ln,Ot,Xt,js,zt,st,xo,Lt,C,em,tm,$l,nm,rm,sm,im,om,am,lm,wn,hr,dr,Be,cm,pr,Al,xl,no,um,Ws,Bs,Tl,fr,hm,dm;class lR extends aR{constructor(n){super();$(this,C);$(this,ne,cR());$(this,Rt,null);$(this,Er,null);$(this,Dt,null);$(this,On,null);$(this,zn,null);$(this,Kt,null);$(this,$r,1);$(this,bt,null);$(this,rt,null);$(this,Jt,!1);$(this,Ln,!1);$(this,Ot,null);$(this,Xt,new Set);$(this,js);$(this,zt);$(this,st);$(this,xo,n=>{b(this,C,tm).call(this,n)});$(this,Lt,null);$(this,Ws,()=>{b(this,C,fr).call(this,"ACP bridge websocket closed")});$(this,Bs,()=>{b(this,C,fr).call(this,"ACP bridge websocket error")});x(this,zt,n),x(this,st,n.sessionMode??iR),x(this,js,n.createSocket??(r=>new WebSocket(r)))}getState(){return u(this,ne)}get messages(){return u(this,ne).messageOrder.map(n=>u(this,ne).messagesById[n]).filter(n=>n!==void 0)}async connect(){if(this.disposed)throw new Error("ACPClient has been disposed");if(u(this,ne).lifecycle.status!=="ready"){b(this,C,Be).call(this,{lifecycle:{status:"connecting"}}),u(this,Er)??x(this,Er,b(this,C,em).call(this));try{await u(this,Er),await b(this,C,$l).call(this)}catch(n){throw b(this,C,fr).call(this,Fi(n)),n}}}dispose(){b(this,C,Tl).call(this),b(this,C,Be).call(this,{lifecycle:{status:"disposed"},run:{status:"idle",stopReason:null,canCancel:!1,error:null}})}async sendMessage(n){if(await this.connect(),u(this,ne).lifecycle.status!=="ready"||u(this,ne).run.status==="running"||u(this,ne).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,C,hr).call(this,{id:b(this,C,pr).call(this,"user"),kind:"user",text:r,status:"final"}),b(this,C,Be).call(this,{run:{status:"running",stopReason:null,canCancel:!0,error:null}});try{const s=await b(this,C,no).call(this).prompt({sessionId:b(this,C,xl).call(this),prompt:[{type:"text",text:b(this,C,cm).call(this,r)}]});b(this,C,wn).call(this,s.stopReason==="cancelled"?"cancelled":"final"),b(this,C,Be).call(this,{run:{status:s.stopReason==="cancelled"?"cancelled":"completed",stopReason:s.stopReason,canCancel:!1,error:null}})}catch(s){throw b(this,C,dm).call(this)||(b(this,C,wn).call(this,"error"),b(this,C,Be).call(this,{run:{status:"error",stopReason:null,canCancel:!1,error:Fi(s)}})),s}}async cancel(){if(await this.connect(),!u(this,ne).run.canCancel||u(this,ne).run.status!=="running")throw new Error("No active cancellable run");b(this,C,Be).call(this,{run:{...u(this,ne).run,status:"cancelling"}}),await b(this,C,no).call(this).cancel({sessionId:b(this,C,xl).call(this)})}setScreenContext(n){var i,o,a;const r={screenID:n.screenID,screenName:n.screenName};if(((i=u(this,rt))==null?void 0:i.screenID)===r.screenID&&((o=u(this,rt))==null?void 0:o.screenName)===r.screenName)return;const s=((a=u(this,rt))==null?void 0:a.screenID)??null;if(x(this,rt,r),u(this,st)==="single_session"){(!u(this,Kt)||s!==r.screenID)&&x(this,Jt,!0);return}u(this,Kt)!==Ad(u(this,st),r.screenID,u(this,zt).clientGUID??"default-client")&&(x(this,Dt,null),x(this,On,null),u(this,Rt)&&u(this,ne).run.status==="idle"&&b(this,C,$l).call(this).catch(l=>{b(this,C,fr).call(this,Fi(l))}))}}ne=new WeakMap,Rt=new WeakMap,Er=new WeakMap,Dt=new WeakMap,On=new WeakMap,zn=new WeakMap,Kt=new WeakMap,$r=new WeakMap,bt=new WeakMap,rt=new WeakMap,Jt=new WeakMap,Ln=new WeakMap,Ot=new WeakMap,Xt=new WeakMap,js=new WeakMap,zt=new WeakMap,st=new WeakMap,xo=new WeakMap,Lt=new WeakMap,C=new WeakSet,em=async function(){try{b(this,C,Be).call(this,{lifecycle:{status:"connecting"}});const{stream:n,socket:r}=await dR({serverURL:u(this,zt).serverURL,token:u(this,zt).token,createSocket:u(this,js),onDisconnect:u(this,xo)});x(this,Lt,r),r.addEventListener("close",u(this,Ws)),r.addEventListener("error",u(this,Bs)),x(this,Rt,new QP(s=>({connection:s,sessionUpdate:async i=>{await b(this,C,rm).call(this,i)},requestPermission:async i=>b(this,C,sm).call(this,i)}),n)),await u(this,Rt).initialize({protocolVersion:LC,clientCapabilities:{},clientInfo:oR})}catch(n){throw n}},tm=function(n){b(this,C,fr).call(this,Fi(n))},$l=async function(){const n=b(this,C,um).call(this);if(u(this,Dt)&&u(this,On)===n){await u(this,Dt);return}x(this,On,n),x(this,Dt,b(this,C,nm).call(this,n)),await u(this,Dt)},nm=async function(n){const r=b(this,C,no).call(this);b(this,C,hm).call(this);let s,i=!1;try{x(this,Ln,!0),x(this,Ot,null),await r.loadSession({sessionId:n,cwd:"/",mcpServers:[],_meta:{sessionKey:n}}),s=n,i=u(this,ne).messageOrder.length>0}catch{s=(await r.newSession({cwd:"/",mcpServers:[],_meta:{sessionKey:n}})).sessionId,i=!1}finally{x(this,Ln,!1),x(this,Ot,null),b(this,C,wn).call(this,"final")}await r.setSessionConfigOption({sessionId:s,configId:"verbose_level",value:"full"}),x(this,zn,s),x(this,Kt,n),i?(u(this,Xt).add(n),u(this,st)==="single_session"&&x(this,Jt,!1)):(u(this,Xt).delete(n),x(this,Jt,u(this,st)==="single_session")),b(this,C,Be).call(this,{lifecycle:{status:"ready"}})},rm=async function(n){const r=n.update;switch(r.sessionUpdate){case"user_message_chunk":r.content.type==="text"&&b(this,C,lm).call(this,r.content.text);return;case"agent_message_chunk":r.content.type==="text"&&b(this,C,im).call(this,r.content.text);return;case"tool_call":b(this,C,om).call(this,r);return;case"tool_call_update":b(this,C,am).call(this,r);return;case"agent_thought_chunk":return;default:return}},sm=async function(n){return{outcome:{outcome:"cancelled"}}},im=function(n){x(this,Ot,null);const r=uR(n);if(!r)return;if(!u(this,bt)){const i={id:b(this,C,pr).call(this,"assistant"),kind:"assistant",text:r,status:"streaming"};x(this,bt,i.id),b(this,C,hr).call(this,i);return}const s=u(this,ne).messagesById[u(this,bt)];if(!s||s.kind!=="assistant")throw new Error("Open assistant message invariant violated");b(this,C,dr).call(this,{...s,text:`${s.text}${r}`,status:"streaming"})},om=function(n){b(this,C,wn).call(this,"final");const r=b(this,C,Al).call(this,n.toolCallId),s={id:(r==null?void 0:r.id)??b(this,C,pr).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,C,dr).call(this,s);return}b(this,C,hr).call(this,s)},am=function(n){const r=b(this,C,Al).call(this,n.toolCallId),s=(r==null?void 0:r.text)??"",i=hR(n.content),o=i?`${s}${i}`:s,a={id:(r==null?void 0:r.id)??b(this,C,pr).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,C,dr).call(this,a);return}b(this,C,hr).call(this,a)},lm=function(n){if(b(this,C,wn).call(this,"final"),!n)return;const r=u(this,Ln)?u(this,Ot):null;if(!r){const i=xd(n);if(!i)return;const o={id:b(this,C,pr).call(this,"user"),kind:"user",text:i,status:"final"};b(this,C,hr).call(this,o),u(this,Ln)&&x(this,Ot,o.id);return}const s=u(this,ne).messagesById[r];if(!s||s.kind!=="user")throw new Error("Replay user message invariant violated");b(this,C,dr).call(this,{...s,text:xd(`${s.text}${n}`)})},wn=function(n){if(!u(this,bt))return;const r=u(this,ne).messagesById[u(this,bt)];(r==null?void 0:r.kind)==="assistant"&&b(this,C,dr).call(this,{...r,status:n}),x(this,bt,null)},hr=function(n){b(this,C,Be).call(this,{messagesById:{...u(this,ne).messagesById,[n.id]:n},messageOrder:[...u(this,ne).messageOrder,n.id]})},dr=function(n){b(this,C,Be).call(this,{messagesById:{...u(this,ne).messagesById,[n.id]:n}})},Be=function(n){const r={...u(this,ne),...n};x(this,ne,{...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"))},cm=function(n){const r=u(this,Kt);return!u(this,rt)||!r||!(u(this,st)==="single_session"?u(this,Jt)||!u(this,Xt).has(r):!u(this,Xt).has(r))?n:(x(this,Jt,!1),u(this,Xt).add(r),["[Television screen context]","This chat session is coming from a Television client in the screen below.",`screen_id: ${u(this,rt).screenID}`,`screen_name: ${u(this,rt).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
|
-
`))},pr=function(n){const r=`${n}-${u(this,$r)}`;return x(this,$r,u(this,$r)+1),r},Al=function(n){for(const r of u(this,ne).messageOrder){const s=u(this,ne).messagesById[r];if((s==null?void 0:s.kind)==="tool_call"&&s.toolCallId===n)return s}return null},xl=function(){if(!u(this,zn))throw new Error("ACP session is not ready");return u(this,zn)},no=function(){if(!u(this,Rt))throw new Error("ACP connection is not ready");return u(this,Rt)},
|
|
42
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const d of t.seen.entries()){const p=d[1];if(e===d[0]){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(p.cycle){i(d);continue}if(p.count>1&&t.reused==="ref"){i(d);continue}}}function og(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 p=d.def??d.schema,y={...p},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")?(p.allOf=p.allOf??[],p.allOf.push(I)):Object.assign(p,I),Object.assign(p,y),c._zod.parent===m)for(const N in p)N==="$ref"||N==="allOf"||N in y||delete p[N];if(I.$ref&&k.def)for(const N in p)N==="$ref"||N==="allOf"||N in k.def&&JSON.stringify(p[N])===JSON.stringify(k.def[N])&&delete p[N]}const E=c._zod.parent;if(E&&E!==m){r(E);const k=t.seen.get(E);if(k!=null&&k.schema.$ref&&(p.$ref=k.schema.$ref,k.def))for(const I in p)I==="$ref"||I==="allOf"||I in k.def&&JSON.stringify(p[I])===JSON.stringify(k.def[I])&&delete p[I]}t.override({zodSchema:c,jsonSchema:p,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:vo(e,"input",t.processors),output:vo(e,"output",t.processors)}},enumerable:!1,writable:!1}),c}catch{throw new Error("Error converting schema to JSON.")}}function Re(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 Re(r.element,n);if(r.type==="set")return Re(r.valueType,n);if(r.type==="lazy")return Re(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 Re(r.innerType,n);if(r.type==="intersection")return Re(r.left,n)||Re(r.right,n);if(r.type==="record"||r.type==="map")return Re(r.keyType,n)||Re(r.valueType,n);if(r.type==="pipe")return Re(r.in,n)||Re(r.out,n);if(r.type==="object"){for(const s in r.shape)if(Re(r.shape[s],n))return!0;return!1}if(r.type==="union"){for(const s of r.options)if(Re(s,n))return!0;return!1}if(r.type==="tuple"){for(const s of r.items)if(Re(s,n))return!0;return!!(r.rest&&Re(r.rest,n))}return!1}const Nx=(t,e={})=>n=>{const r=sg({...n,processors:e});return me(t,r),ig(r,t),og(r,t)},vo=(t,e,n={})=>r=>{const{libraryOptions:s,target:i}=r??{},o=sg({...s??{},target:i,io:e,processors:n});return me(t,o),ig(o,t),og(o,t)},Ux={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Fx=(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=Ux[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(p=>({...e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"?{type:"string"}:{},pattern:p.source}))])}},Zx=(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)},jx=(t,e,n,r)=>{n.type="boolean"},Wx=(t,e,n,r)=>{n.not={}},Bx=(t,e,n,r)=>{},Gx=(t,e,n,r)=>{const s=t._zod.def,i=Nf(s.entries);i.every(o=>typeof o=="number")&&(n.type="number"),i.every(o=>typeof o=="string")&&(n.type="string"),n.enum=i},Vx=(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},Hx=(t,e,n,r)=>{if(e.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},qx=(t,e,n,r)=>{if(e.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},Yx=(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"]})},Kx=(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 p=i.shape[d]._zod;return e.io==="input"?p.optin===void 0:p.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)},Jx=(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},Xx=(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},Qx=(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 p of l)s.patternProperties[p.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(p=>typeof p=="string"||typeof p=="number");d.length>0&&(s.required=d)}},eT=(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"}]},tT=(t,e,n,r)=>{const s=t._zod.def;me(s.innerType,e,r);const i=e.seen.get(t);i.ref=s.innerType},nT=(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))},rT=(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)))},sT=(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},iT=(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},oT=(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},ag=(t,e,n,r)=>{const s=t._zod.def;me(s.innerType,e,r);const i=e.seen.get(t);i.ref=s.innerType},aT=S("ZodISODateTime",(t,e)=>{lA.init(t,e),ue.init(t,e)});function lT(t){return fx(aT,t)}const cT=S("ZodISODate",(t,e)=>{cA.init(t,e),ue.init(t,e)});function uT(t){return gx(cT,t)}const hT=S("ZodISOTime",(t,e)=>{uA.init(t,e),ue.init(t,e)});function dT(t){return mx(hT,t)}const pT=S("ZodISODuration",(t,e)=>{hA.init(t,e),ue.init(t,e)});function fT(t){return vx(pT,t)}const lg=(t,e)=>{jf.init(t,e),t.name="ZodError",Object.defineProperties(t,{format:{value:n=>t$(t,n)},flatten:{value:n=>e$(t,n)},addIssue:{value:n=>{t.issues.push(n),t.message=JSON.stringify(t.issues,yl,2)}},addIssues:{value:n=>{t.issues.push(...n),t.message=JSON.stringify(t.issues,yl,2)}},isEmpty:{get(){return t.issues.length===0}}})},md=S("ZodError",lg),tt=S("ZodError",lg,{Parent:Error}),gT=Oc(tt),mT=zc(tt),vT=Zo(tt),yT=jo(tt),bT=s$(tt),wT=i$(tt),_T=o$(tt),ST=a$(tt),kT=l$(tt),ET=c$(tt),$T=u$(tt),AT=h$(tt),ce=S("ZodType",(t,e)=>(le.init(t,e),Object.assign(t["~standard"],{jsonSchema:{input:vo(t,"input"),output:vo(t,"output")}}),t.toJSONSchema=Nx(t,{}),t.def=e,t.type=e.type,Object.defineProperty(t,"_def",{value:e}),t.check=(...n)=>t.clone(pn(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)=>fn(t,n,r),t.brand=()=>t,t.register=(n,r)=>(n.add(t,r),t),t.parse=(n,r)=>gT(t,n,r,{callee:t.parse}),t.safeParse=(n,r)=>vT(t,n,r),t.parseAsync=async(n,r)=>mT(t,n,r,{callee:t.parseAsync}),t.safeParseAsync=async(n,r)=>yT(t,n,r),t.spa=t.safeParseAsync,t.encode=(n,r)=>bT(t,n,r),t.decode=(n,r)=>wT(t,n,r),t.encodeAsync=async(n,r)=>_T(t,n,r),t.decodeAsync=async(n,r)=>ST(t,n,r),t.safeEncode=(n,r)=>kT(t,n,r),t.safeDecode=(n,r)=>ET(t,n,r),t.safeEncodeAsync=async(n,r)=>$T(t,n,r),t.safeDecodeAsync=async(n,r)=>AT(t,n,r),t.refine=(n,r)=>t.check(vC(n,r)),t.superRefine=n=>t.check(yC(n)),t.overwrite=n=>t.check(qr(n)),t.optional=()=>bd(t),t.exactOptional=()=>sC(t),t.nullable=()=>wd(t),t.nullish=()=>bd(wd(t)),t.nonoptional=n=>uC(t,n),t.array=()=>R(t),t.or=n=>Z([t,n]),t.and=n=>Bo(t,n),t.transform=n=>_d(t,nC(n)),t.default=n=>aC(t,n),t.prefault=n=>cC(t,n),t.catch=n=>dC(t,n),t.pipe=n=>_d(t,n),t.readonly=()=>gC(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)),cg=S("_ZodString",(t,e)=>{Lc.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(r,s,i)=>Fx(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(kx(...r)),t.includes=(...r)=>t.check(Ax(...r)),t.startsWith=(...r)=>t.check(xx(...r)),t.endsWith=(...r)=>t.check(Tx(...r)),t.min=(...r)=>t.check(mo(...r)),t.max=(...r)=>t.check(ng(...r)),t.length=(...r)=>t.check(rg(...r)),t.nonempty=(...r)=>t.check(mo(1,...r)),t.lowercase=r=>t.check(Ex(r)),t.uppercase=r=>t.check($x(r)),t.trim=()=>t.check(Ix()),t.normalize=(...r)=>t.check(Cx(...r)),t.toLowerCase=()=>t.check(Px()),t.toUpperCase=()=>t.check(Rx()),t.slugify=()=>t.check(Dx())}),xT=S("ZodString",(t,e)=>{Lc.init(t,e),cg.init(t,e),t.email=n=>t.check(HA(TT,n)),t.url=n=>t.check(XA(CT,n)),t.jwt=n=>t.check(px(BT,n)),t.emoji=n=>t.check(QA(IT,n)),t.guid=n=>t.check(dd(vd,n)),t.uuid=n=>t.check(qA(Ui,n)),t.uuidv4=n=>t.check(YA(Ui,n)),t.uuidv6=n=>t.check(KA(Ui,n)),t.uuidv7=n=>t.check(JA(Ui,n)),t.nanoid=n=>t.check(ex(PT,n)),t.guid=n=>t.check(dd(vd,n)),t.cuid=n=>t.check(tx(RT,n)),t.cuid2=n=>t.check(nx(DT,n)),t.ulid=n=>t.check(rx(OT,n)),t.base64=n=>t.check(ux(ZT,n)),t.base64url=n=>t.check(hx(jT,n)),t.xid=n=>t.check(sx(zT,n)),t.ksuid=n=>t.check(ix(LT,n)),t.ipv4=n=>t.check(ox(MT,n)),t.ipv6=n=>t.check(ax(NT,n)),t.cidrv4=n=>t.check(lx(UT,n)),t.cidrv6=n=>t.check(cx(FT,n)),t.e164=n=>t.check(dx(WT,n)),t.datetime=n=>t.check(lT(n)),t.date=n=>t.check(uT(n)),t.time=n=>t.check(dT(n)),t.duration=n=>t.check(fT(n))});function h(t){return VA(xT,t)}const ue=S("ZodStringFormat",(t,e)=>{oe.init(t,e),cg.init(t,e)}),TT=S("ZodEmail",(t,e)=>{Q$.init(t,e),ue.init(t,e)}),vd=S("ZodGUID",(t,e)=>{J$.init(t,e),ue.init(t,e)}),Ui=S("ZodUUID",(t,e)=>{X$.init(t,e),ue.init(t,e)}),CT=S("ZodURL",(t,e)=>{eA.init(t,e),ue.init(t,e)}),IT=S("ZodEmoji",(t,e)=>{tA.init(t,e),ue.init(t,e)}),PT=S("ZodNanoID",(t,e)=>{nA.init(t,e),ue.init(t,e)}),RT=S("ZodCUID",(t,e)=>{rA.init(t,e),ue.init(t,e)}),DT=S("ZodCUID2",(t,e)=>{sA.init(t,e),ue.init(t,e)}),OT=S("ZodULID",(t,e)=>{iA.init(t,e),ue.init(t,e)}),zT=S("ZodXID",(t,e)=>{oA.init(t,e),ue.init(t,e)}),LT=S("ZodKSUID",(t,e)=>{aA.init(t,e),ue.init(t,e)}),MT=S("ZodIPv4",(t,e)=>{dA.init(t,e),ue.init(t,e)}),NT=S("ZodIPv6",(t,e)=>{pA.init(t,e),ue.init(t,e)}),UT=S("ZodCIDRv4",(t,e)=>{fA.init(t,e),ue.init(t,e)}),FT=S("ZodCIDRv6",(t,e)=>{gA.init(t,e),ue.init(t,e)}),ZT=S("ZodBase64",(t,e)=>{mA.init(t,e),ue.init(t,e)}),jT=S("ZodBase64URL",(t,e)=>{yA.init(t,e),ue.init(t,e)}),WT=S("ZodE164",(t,e)=>{bA.init(t,e),ue.init(t,e)}),BT=S("ZodJWT",(t,e)=>{_A.init(t,e),ue.init(t,e)}),ug=S("ZodNumber",(t,e)=>{Xf.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(r,s,i)=>Zx(t,r,s),t.gt=(r,s)=>t.check(fd(r,s)),t.gte=(r,s)=>t.check(ja(r,s)),t.min=(r,s)=>t.check(ja(r,s)),t.lt=(r,s)=>t.check(pd(r,s)),t.lte=(r,s)=>t.check(Za(r,s)),t.max=(r,s)=>t.check(Za(r,s)),t.int=r=>t.check(yd(r)),t.safe=r=>t.check(yd(r)),t.positive=r=>t.check(fd(0,r)),t.nonnegative=r=>t.check(ja(0,r)),t.negative=r=>t.check(pd(0,r)),t.nonpositive=r=>t.check(Za(0,r)),t.multipleOf=(r,s)=>t.check(gd(r,s)),t.step=(r,s)=>t.check(gd(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 yx(ug,t)}const GT=S("ZodNumberFormat",(t,e)=>{SA.init(t,e),ug.init(t,e)});function yd(t){return bx(GT,t)}const VT=S("ZodBoolean",(t,e)=>{kA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>jx(t,n,r)});function ke(t){return wx(VT,t)}const HT=S("ZodUnknown",(t,e)=>{EA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>Bx()});function w(){return _x(HT)}const qT=S("ZodNever",(t,e)=>{$A.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>Wx(t,n,r)});function YT(t){return Sx(qT,t)}const KT=S("ZodArray",(t,e)=>{AA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>Yx(t,n,r,s),t.element=e.element,t.min=(n,r)=>t.check(mo(n,r)),t.nonempty=n=>t.check(mo(1,n)),t.max=(n,r)=>t.check(ng(n,r)),t.length=(n,r)=>t.check(rg(n,r)),t.unwrap=()=>t.element});function R(t,e){return Ox(KT,t,e)}const hg=S("ZodObject",(t,e)=>{TA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>Kx(t,n,r,s),ee(t,"shape",()=>e.shape),t.keyof=()=>yo(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:YT()}),t.strip=()=>t.clone({...t._zod.def,catchall:void 0}),t.extend=n=>YE(t,n),t.safeExtend=n=>KE(t,n),t.merge=n=>JE(t,n),t.pick=n=>HE(t,n),t.omit=n=>qE(t,n),t.partial=(...n)=>XE(pg,t,n[0]),t.required=(...n)=>QE(fg,t,n[0])});function dg(t,e){const n={type:"object",shape:t??{},...O(e)};return new hg(n)}function f(t,e){return new hg({type:"object",shape:t,catchall:w(),...O(e)})}const JT=S("ZodUnion",(t,e)=>{CA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>Jx(t,n,r,s),t.options=e.options});function Z(t,e){return new JT({type:"union",options:t,...O(e)})}const XT=S("ZodIntersection",(t,e)=>{IA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>Xx(t,n,r,s)});function Bo(t,e){return new XT({type:"intersection",left:t,right:e})}const QT=S("ZodRecord",(t,e)=>{PA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>Qx(t,n,r,s),t.keyType=e.keyType,t.valueType=e.valueType});function _(t,e,n){return new QT({type:"record",keyType:t,valueType:e,...O(n)})}const wl=S("ZodEnum",(t,e)=>{RA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(r,s,i)=>Gx(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 wl({...e,checks:[],...O(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 wl({...e,checks:[],...O(s),entries:i})}});function yo(t,e){const n=Array.isArray(t)?Object.fromEntries(t.map(r=>[r,r])):t;return new wl({type:"enum",entries:n,...O(e)})}const eC=S("ZodLiteral",(t,e)=>{DA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>Vx(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 eC({type:"literal",values:Array.isArray(t)?t:[t],...O(e)})}const tC=S("ZodTransform",(t,e)=>{OA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>qx(t,n),t._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Lf(t.constructor.name);n.addIssue=i=>{if(typeof i=="string")n.issues.push(Ts(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(Ts(o))}};const s=e.transform(n.value,n);return s instanceof Promise?s.then(i=>(n.value=i,n)):(n.value=s,n)}});function nC(t){return new tC({type:"transform",transform:t})}const pg=S("ZodOptional",(t,e)=>{tg.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>ag(t,n,r,s),t.unwrap=()=>t._zod.def.innerType});function bd(t){return new pg({type:"optional",innerType:t})}const rC=S("ZodExactOptional",(t,e)=>{zA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>ag(t,n,r,s),t.unwrap=()=>t._zod.def.innerType});function sC(t){return new rC({type:"optional",innerType:t})}const iC=S("ZodNullable",(t,e)=>{LA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>eT(t,n,r,s),t.unwrap=()=>t._zod.def.innerType});function wd(t){return new iC({type:"nullable",innerType:t})}const oC=S("ZodDefault",(t,e)=>{MA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>nT(t,n,r,s),t.unwrap=()=>t._zod.def.innerType,t.removeDefault=t.unwrap});function aC(t,e){return new oC({type:"default",innerType:t,get defaultValue(){return typeof e=="function"?e():Ff(e)}})}const lC=S("ZodPrefault",(t,e)=>{NA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>rT(t,n,r,s),t.unwrap=()=>t._zod.def.innerType});function cC(t,e){return new lC({type:"prefault",innerType:t,get defaultValue(){return typeof e=="function"?e():Ff(e)}})}const fg=S("ZodNonOptional",(t,e)=>{UA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>tT(t,n,r,s),t.unwrap=()=>t._zod.def.innerType});function uC(t,e){return new fg({type:"nonoptional",innerType:t,...O(e)})}const hC=S("ZodCatch",(t,e)=>{FA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>sT(t,n,r,s),t.unwrap=()=>t._zod.def.innerType,t.removeCatch=t.unwrap});function dC(t,e){return new hC({type:"catch",innerType:t,catchValue:typeof e=="function"?e:()=>e})}const pC=S("ZodPipe",(t,e)=>{ZA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>iT(t,n,r,s),t.in=e.in,t.out=e.out});function _d(t,e){return new pC({type:"pipe",in:t,out:e})}const fC=S("ZodReadonly",(t,e)=>{jA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>oT(t,n,r,s),t.unwrap=()=>t._zod.def.innerType});function gC(t){return new fC({type:"readonly",innerType:t})}const mC=S("ZodCustom",(t,e)=>{WA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>Hx(t,n)});function vC(t,e={}){return zx(mC,t,e)}function yC(t){return Lx(t)}const bC=["text/markdown","text/html"],wC=["committed","pending"];dg({id:h().min(1),type:yo(bC),title:h(),status:yo(wC),externalFilePath:h().optional()});dg({name:h().min(1),description:h(),accepts:R(h().min(1)).min(1)});function Mc(t){return typeof t=="object"&&t!==null}function _C(t){return!Mc(t)||t.type!=="ready"?!1:!("id"in t)}function SC(t){return!(!Mc(t)||t.type!=="update-content"||typeof t.id!="string"||typeof t.content!="string")}function kC(t){return!Mc(t)||t.type!=="wheel"||typeof t.deltaX!="number"||typeof t.deltaY!="number"||typeof t.shiftKey!="boolean"?!1:!("id"in t)}function EC(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 $C(t,e){let n=null;for(const r of t.accepts){const s=EC(r,e);s!==null&&(n===null||s>n)&&(n=s)}return n}function AC(t,e){let n=-1,r=null;for(const s of e){const i=$C(s,t);i!==null&&(i>n||i===n&&r!==null&&s.id<r.id)&&(n=i,r=s)}return r}const xC=4401;class _l extends Error{constructor(e="Authentication required"){super(e),this.name="AuthError"}}class Sl 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 PE(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(TC(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=p=>{a||this.connectAttempt!==n||(a=!0,this.status="disconnected",this.dispatchEvent(new te("change")),o(p))},d=async()=>{try{const[{screens:p},y]=await Promise.all([this.client.screens.list(),this.client.views.list()]);this.screens=new Map(p.map(m=>[m.id,structuredClone(m)])),this.views=y,this.dispatchEvent(new te("change")),l()}catch(p){c(p instanceof Error?p:new Error(String(p)))}};r.addEventListener("open",()=>{d()}),r.addEventListener("message",p=>{const y=IC(p);y&&(this.applyServerEvent(y),this.dispatchEvent(new $f("server-event",{serverURL:this.url,event:y})))}),r.addEventListener("close",p=>{if(this.connectAttempt===n){if(this.socket=null,CC(p)===xC){c(new _l);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=AC(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 eo("screens-changed"));break;case"screen-updated":this.screens.set(n.screen.id,structuredClone(n.screen)),this.dispatchEvent(new eo("screens-changed"));break;case"screen-removed":this.screens.delete(n.screenID),this.dispatchEvent(new eo("screens-changed"));break;case"artifact-created":{const r=this.screens.get(n.screenID);r&&!Sf(r.layout,n.artifact.id)&&(r.layout=[...r.layout,_f(n.artifact.id)]);break}case"artifact-removed":{const r=this.screens.get(n.screenID);r&&(r.layout=df(r.layout,n.artifactID));break}}}}function TC(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 CC(t){return typeof t=="object"&&t!==null&&"code"in t&&typeof t.code=="number"?t.code:null}function IC(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 PC 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 $f("server-event",{serverURL:l.serverURL,event:l.event}))},a=()=>{this.dispatchEvent(new eo("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 Sl({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 Sl({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"},Tt={fs_read_text_file:"fs/read_text_file",fs_write_text_file:"fs/write_text_file",session_request_permission:"session/request_permission",session_update:"session/update",terminal_create:"terminal/create",terminal_kill:"terminal/kill",terminal_output:"terminal/output",terminal_release:"terminal/release",terminal_wait_for_exit:"terminal/wait_for_exit"},RC=1,DC=f({_meta:_(h(),w()).nullish(),terminal:ke().optional().default(!1)}),OC=f({_meta:_(h(),w()).nullish(),label:h().nullish(),name:h(),optional:ke().optional().default(!1),secret:ke().optional().default(!0)}),zC=f({_meta:_(h(),w()).nullish(),description:h().nullish(),id:h(),name:h()}),LC=f({_meta:_(h(),w()).nullish(),description:h().nullish(),id:h(),link:h().nullish(),name:h(),vars:R(OC)}),MC=f({_meta:_(h(),w()).nullish(),args:R(h()).optional(),description:h().nullish(),env:_(h(),h()).optional(),id:h(),name:h()}),NC=Z([LC.and(f({type:A("env_var")})),MC.and(f({type:A("terminal")})),zC]),UC=f({_meta:_(h(),w()).nullish(),methodId:h()}),FC=f({_meta:_(h(),w()).nullish()}),ZC=f({_meta:_(h(),w()).nullish(),blob:h(),mimeType:h().nullish(),uri:h()}),jC=f({default:ke().nullish(),description:h().nullish(),title:h().nullish()}),WC=f({_meta:_(h(),w()).nullish()}),BC=f({_meta:_(h(),w()).nullish()}),GC=f({amount:U(),currency:h()}),VC=f({_meta:_(h(),w()).nullish(),terminalId:h()}),HC=f({_meta:_(h(),w()).nullish(),newText:h(),oldText:h().nullish(),path:h()}),qC=Z([h(),U(),U(),ke(),R(h())]),YC=f({content:_(h(),qC).nullish()}),KC=Z([YC.and(f({action:A("accept")})),f({action:A("decline")}),f({action:A("cancel")})]),JC=f({_meta:_(h(),w()).nullish()}),gg=h(),XC=f({_meta:_(h(),w()).nullish(),elicitationId:gg}),QC=f({_meta:_(h(),w()).nullish(),action:KC}),eI=A("object"),tI=A("string"),nI=f({_meta:_(h(),w()).nullish()}),rI=f({_meta:_(h(),w()).nullish(),form:JC.nullish(),url:nI.nullish()}),sI=f({elicitationId:gg,url:h().url()}),mg=f({const:h(),title:h()}),vg=f({_meta:_(h(),w()).nullish(),name:h(),value:h()}),iI=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"})]),yg=f({code:iI,data:w().optional(),message:h()}),bg=w(),wg=w(),_g=w(),oI=f({_meta:_(h(),w()).nullish(),readTextFile:ke().optional().default(!1),writeTextFile:ke().optional().default(!1)}),Sg=f({_meta:_(h(),w()).nullish(),name:h(),value:h()}),kg=f({_meta:_(h(),w()).nullish(),name:h(),title:h().nullish(),version:h()}),aI=f({default:U().nullish(),description:h().nullish(),maximum:U().nullish(),minimum:U().nullish(),title:h().nullish()}),lI=f({_meta:_(h(),w()).nullish()}),cI=f({_meta:_(h(),w()).nullish(),additionalDirectories:R(h()).optional(),cursor:h().nullish(),cwd:h().nullish()}),uI=f({_meta:_(h(),w()).nullish()}),hI=f({_meta:_(h(),w()).nullish(),logout:uI.nullish()}),dI=f({_meta:_(h(),w()).nullish()}),pI=f({_meta:_(h(),w()).nullish()}),fI=f({_meta:_(h(),w()).nullish(),http:ke().optional().default(!1),sse:ke().optional().default(!1)}),gI=f({_meta:_(h(),w()).nullish(),headers:R(Sg),name:h(),url:h()}),mI=f({_meta:_(h(),w()).nullish(),headers:R(Sg),name:h(),url:h()}),vI=f({_meta:_(h(),w()).nullish(),args:R(h()),command:h(),env:R(vg),name:h()}),Go=Z([gI.and(f({type:A("http")})),mI.and(f({type:A("sse")})),vI]),Nc=h(),yI=f({_meta:_(h(),w()).nullish(),description:h().nullish(),modelId:Nc,name:h()}),bI=Z([A("error"),A("warning"),A("information"),A("hint")]),wI=f({_meta:_(h(),w()).nullish()}),_I=f({_meta:_(h(),w()).nullish()}),SI=f({_meta:_(h(),w()).nullish()}),kI=f({_meta:_(h(),w()).nullish()}),EI=f({_meta:_(h(),w()).nullish()}),$I=f({_meta:_(h(),w()).nullish(),maxCount:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),AI=f({diff:h(),uri:h()}),xI=f({endLine:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),startLine:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),text:h()}),TI=f({_meta:_(h(),w()).nullish()}),CI=f({_meta:_(h(),w()).nullish()}),II=f({languageId:h(),text:h(),uri:h()}),PI=f({_meta:_(h(),w()).nullish(),maxCount:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),RI=Z([A("rejected"),A("ignored"),A("replaced"),A("cancelled")]),DI=f({excerpts:R(xI),uri:h()}),OI=f({_meta:_(h(),w()).nullish()}),zI=f({_meta:_(h(),w()).nullish()}),LI=f({name:h(),owner:h(),remoteUrl:h()}),MI=f({_meta:_(h(),w()).nullish()}),NI=f({_meta:_(h(),w()).nullish(),jump:TI.nullish(),rename:zI.nullish(),searchAndReplace:MI.nullish()}),UI=f({id:h(),isRegex:ke().nullish(),replace:h(),search:h(),uri:h()}),FI=Z([A("automatic"),A("diagnostic"),A("manual")]),ZI=f({_meta:_(h(),w()).nullish(),maxCount:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),jI=f({_meta:_(h(),w()).nullish(),diagnostics:wI.nullish(),editHistory:$I.nullish(),openFiles:CI.nullish(),recentFiles:PI.nullish(),relatedSnippets:OI.nullish(),userActions:ZI.nullish()}),WI=f({_meta:_(h(),w()).nullish(),additionalDirectories:R(h()).optional(),cwd:h(),mcpServers:R(Go)}),BI=f({default:U().nullish(),description:h().nullish(),maximum:U().nullish(),minimum:U().nullish(),title:h().nullish()}),Eg=h(),GI=Z([A("allow_once"),A("allow_always"),A("reject_once"),A("reject_always")]),VI=f({_meta:_(h(),w()).nullish(),kind:GI,name:h(),optionId:Eg}),HI=Z([A("high"),A("medium"),A("low")]),qI=Z([A("pending"),A("in_progress"),A("completed")]),YI=f({_meta:_(h(),w()).nullish(),content:h(),priority:HI,status:qI}),KI=f({_meta:_(h(),w()).nullish(),entries:R(YI)}),ln=f({character:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),line:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"})}),JI=f({id:h(),position:ln,uri:h()}),XI=f({id:h(),newName:h(),position:ln,uri:h()}),QI=f({action:h(),position:ln,timestampMs:U(),uri:h()}),$g=Z([A("utf-16"),A("utf-32"),A("utf-8")]),e0=f({_meta:_(h(),w()).nullish(),auth:DC.optional().default({terminal:!1}),elicitation:rI.nullish(),fs:oI.optional().default({readTextFile:!1,writeTextFile:!1}),nes:NI.nullish(),positionEncodings:R($g).optional(),terminal:ke().optional().default(!1)}),t0=f({_meta:_(h(),w()).nullish(),audio:ke().optional().default(!1),embeddedContext:ke().optional().default(!1),image:ke().optional().default(!1)}),Ag=U().int().gte(0).lte(65535),n0=f({_meta:_(h(),w()).nullish(),clientCapabilities:e0.optional().default({auth:{terminal:!1},fs:{readTextFile:!1,writeTextFile:!1},terminal:!1}),clientInfo:kg.nullish(),protocolVersion:Ag}),Yr=f({end:ln,start:ln}),r0=f({message:h(),range:Yr,severity:bI,uri:h()}),s0=f({languageId:h(),lastFocusedMs:U().nullish(),uri:h(),visibleRange:Yr.nullish()}),i0=f({_meta:_(h(),w()).nullish(),diagnostics:R(r0).nullish(),editHistory:R(AI).nullish(),openFiles:R(s0).nullish(),recentFiles:R(II).nullish(),relatedSnippets:R(DI).nullish(),userActions:R(QI).nullish()}),o0=f({newText:h(),range:Yr}),a0=f({cursorPosition:ln.nullish(),edits:R(o0),id:h(),uri:h()}),l0=Z([a0.and(f({kind:A("edit")})),JI.and(f({kind:A("jump")})),XI.and(f({kind:A("rename")})),UI.and(f({kind:A("searchAndReplace")}))]),c0=f({_meta:_(h(),w()).nullish(),content:h()}),u0=f({_meta:_(h(),w()).nullish()}),Bn=Z([U(),h()]).nullable();f({_meta:_(h(),w()).nullish(),requestId:Bn});const h0=yo(["assistant","user"]),vi=f({_meta:_(h(),w()).nullish(),audience:R(h0).nullish(),lastModified:h().nullish(),priority:U().nullish()}),d0=f({_meta:_(h(),w()).nullish(),annotations:vi.nullish(),data:h(),mimeType:h()}),p0=f({_meta:_(h(),w()).nullish(),annotations:vi.nullish(),data:h(),mimeType:h(),uri:h().nullish()}),f0=f({_meta:_(h(),w()).nullish(),annotations:vi.nullish(),description:h().nullish(),mimeType:h().nullish(),name:h(),size:U().nullish(),title:h().nullish(),uri:h()}),g0=f({_meta:_(h(),w()).nullish(),optionId:Eg}),m0=Z([f({outcome:A("cancelled")}),g0.and(f({outcome:A("selected")}))]),v0=f({_meta:_(h(),w()).nullish(),outcome:m0}),y0=f({_meta:_(h(),w()).nullish()}),b0=f({_meta:_(h(),w()).nullish()}),w0=f({currentValue:ke()}),_0=h(),xg=h(),S0=Z([A("mode"),A("model"),A("thought_level"),h()]),Uc=h(),Tg=f({_meta:_(h(),w()).nullish(),description:h().nullish(),name:h(),value:Uc}),k0=f({_meta:_(h(),w()).nullish(),group:_0,name:h(),options:R(Tg)}),E0=Z([R(Tg),R(k0)]),$0=f({currentValue:Uc,options:E0}),Kr=Bo(Z([$0.and(f({type:A("select")})),w0.and(f({type:A("boolean")}))]),f({_meta:_(h(),w()).nullish(),category:S0.nullish(),description:h().nullish(),id:xg,name:h()})),A0=f({_meta:_(h(),w()).nullish(),configOptions:R(Kr)}),x0=f({_meta:_(h(),w()).nullish()}),K=h(),T0=f({_meta:_(h(),w()).nullish(),id:h(),sessionId:K}),C0=f({_meta:_(h(),w()).nullish(),sessionId:K}),I0=f({_meta:_(h(),w()).nullish(),sessionId:K}),P0=f({_meta:_(h(),w()).nullish(),sessionId:K}),Cg=f({_meta:_(h(),w()).nullish(),args:R(h()).optional(),command:h(),cwd:h().nullish(),env:R(vg).optional(),outputByteLimit:U().nullish(),sessionId:K}),R0=f({_meta:_(h(),w()).nullish(),sessionId:K,uri:h()}),D0=f({_meta:_(h(),w()).nullish(),position:ln,sessionId:K,uri:h(),version:U(),visibleRange:Yr}),O0=f({_meta:_(h(),w()).nullish(),languageId:h(),sessionId:K,text:h(),uri:h(),version:U()}),z0=f({_meta:_(h(),w()).nullish(),sessionId:K,uri:h()}),L0=f({_meta:_(h(),w()).nullish(),additionalDirectories:R(h()).optional(),cwd:h(),mcpServers:R(Go).optional(),sessionId:K}),Ig=f({_meta:_(h(),w()).nullish(),sessionId:K,terminalId:h()}),M0=f({_meta:_(h(),w()).nullish(),additionalDirectories:R(h()).optional(),cwd:h(),mcpServers:R(Go),sessionId:K}),Pg=f({_meta:_(h(),w()).nullish(),limit:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),line:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:h(),sessionId:K}),N0=f({_meta:_(h(),w()).nullish(),id:h(),reason:RI.nullish(),sessionId:K}),Rg=f({_meta:_(h(),w()).nullish(),sessionId:K,terminalId:h()}),U0=f({_meta:_(h(),w()).nullish(),additionalDirectories:R(h()).optional(),cwd:h(),mcpServers:R(Go).optional(),sessionId:K}),F0=f({_meta:_(h(),w()).nullish(),additionalDirectories:R(h()).optional(),cwd:h(),sessionId:K,title:h().nullish(),updatedAt:h().nullish()}),Z0=f({_meta:_(h(),w()).nullish(),nextCursor:h().nullish(),sessions:R(F0)}),j0=f({_meta:_(h(),w()).nullish(),title:h().nullish(),updatedAt:h().nullish()}),W0=f({_meta:_(h(),w()).nullish()}),Vo=h(),B0=f({_meta:_(h(),w()).nullish(),currentModeId:Vo}),G0=f({_meta:_(h(),w()).nullish(),description:h().nullish(),id:Vo,name:h()}),Ho=f({_meta:_(h(),w()).nullish(),availableModes:R(G0),currentModeId:Vo}),qo=f({_meta:_(h(),w()).nullish(),availableModels:R(yI),currentModelId:Nc}),V0=f({_meta:_(h(),w()).nullish(),configOptions:R(Kr).nullish(),models:qo.nullish(),modes:Ho.nullish(),sessionId:K}),H0=f({_meta:_(h(),w()).nullish(),configOptions:R(Kr).nullish(),models:qo.nullish(),modes:Ho.nullish()}),q0=f({_meta:_(h(),w()).nullish(),configOptions:R(Kr).nullish(),models:qo.nullish(),modes:Ho.nullish(),sessionId:K}),Y0=f({_meta:_(h(),w()).nullish(),configOptions:R(Kr).nullish(),models:qo.nullish(),modes:Ho.nullish()}),K0=f({_meta:_(h(),w()).nullish()}),J0=f({_meta:_(h(),w()).nullish(),additionalDirectories:y0.nullish(),close:b0.nullish(),fork:x0.nullish(),list:W0.nullish(),resume:K0.nullish()}),X0=Bo(Z([f({type:A("boolean"),value:ke()}),f({value:Uc})]),f({_meta:_(h(),w()).nullish(),configId:xg,sessionId:K})),Q0=f({_meta:_(h(),w()).nullish(),configOptions:R(Kr)}),eP=f({_meta:_(h(),w()).nullish(),modeId:Vo,sessionId:K}),tP=f({_meta:_(h(),w()).nullish()}),nP=f({_meta:_(h(),w()).nullish(),modelId:Nc,sessionId:K}),rP=f({_meta:_(h(),w()).nullish()}),sP=f({_meta:_(h(),w()).nullish(),sessionId:K}),iP=Z([A("end_turn"),A("max_tokens"),A("max_turn_requests"),A("refusal"),A("cancelled")]),oP=Z([A("email"),A("uri"),A("date"),A("date-time")]),aP=f({default:h().nullish(),description:h().nullish(),enum:R(h()).nullish(),format:oP.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(mg).nullish(),pattern:h().nullish(),title:h().nullish()}),lP=f({_meta:_(h(),w()).nullish(),context:i0.nullish(),position:ln,selection:Yr.nullish(),sessionId:K,triggerKind:FI,uri:h(),version:U()}),cP=f({_meta:_(h(),w()).nullish(),suggestions:R(l0)}),uP=f({_meta:_(h(),w()).nullish(),terminalId:h()}),hP=f({_meta:_(h(),w()).nullish(),exitCode:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:h().nullish()}),Dg=f({_meta:_(h(),w()).nullish(),sessionId:K,terminalId:h()}),dP=f({_meta:_(h(),w()).nullish(),exitStatus:hP.nullish(),output:h(),truncated:ke()}),pP=f({_meta:_(h(),w()).nullish(),annotations:vi.nullish(),text:h()}),fP=f({range:Yr.nullish(),text:h()}),gP=f({_meta:_(h(),w()).nullish(),contentChanges:R(fP),sessionId:K,uri:h(),version:U()});f({method:h(),params:Z([C0,O0,gP,R0,z0,D0,T0,N0,bg]).nullish()});const mP=Z([A("full"),A("incremental")]),vP=f({_meta:_(h(),w()).nullish(),syncKind:mP}),yP=f({_meta:_(h(),w()).nullish(),didChange:vP.nullish(),didClose:_I.nullish(),didFocus:SI.nullish(),didOpen:kI.nullish(),didSave:EI.nullish()}),bP=f({_meta:_(h(),w()).nullish(),document:yP.nullish()}),wP=f({_meta:_(h(),w()).nullish(),context:jI.nullish(),events:bP.nullish()}),_P=f({_meta:_(h(),w()).nullish(),auth:hI.optional().default({}),loadSession:ke().optional().default(!1),mcpCapabilities:fI.optional().default({http:!1,sse:!1}),nes:wP.nullish(),positionEncoding:$g.nullish(),promptCapabilities:t0.optional().default({audio:!1,embeddedContext:!1,image:!1}),sessionCapabilities:J0.optional().default({})}),SP=f({_meta:_(h(),w()).nullish(),agentCapabilities:_P.optional().default({auth:{},loadSession:!1,mcpCapabilities:{http:!1,sse:!1},promptCapabilities:{audio:!1,embeddedContext:!1,image:!1},sessionCapabilities:{}}),agentInfo:kg.nullish(),authMethods:R(NC).optional().default([]),protocolVersion:Ag}),kP=f({_meta:_(h(),w()).nullish(),mimeType:h().nullish(),text:h(),uri:h()}),EP=Z([kP,ZC]),$P=f({_meta:_(h(),w()).nullish(),annotations:vi.nullish(),resource:EP}),Fc=Z([pP.and(f({type:A("text")})),p0.and(f({type:A("image")})),d0.and(f({type:A("audio")})),f0.and(f({type:A("resource_link")})),$P.and(f({type:A("resource")}))]),AP=f({_meta:_(h(),w()).nullish(),content:Fc}),Wa=f({_meta:_(h(),w()).nullish(),content:Fc,messageId:h().nullish()}),xP=f({_meta:_(h(),w()).nullish(),messageId:h().nullish(),prompt:R(Fc),sessionId:K}),TP=f({anyOf:R(mg)}),Og=Z([AP.and(f({type:A("content")})),HC.and(f({type:A("diff")})),uP.and(f({type:A("terminal")}))]),zg=h(),Lg=f({_meta:_(h(),w()).nullish(),line:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:h()}),Mg=Z([A("pending"),A("in_progress"),A("completed"),A("failed")]),Ng=Z([A("read"),A("edit"),A("delete"),A("move"),A("search"),A("execute"),A("think"),A("fetch"),A("switch_mode"),A("other")]),CP=f({_meta:_(h(),w()).nullish(),content:R(Og).optional(),kind:Ng.optional(),locations:R(Lg).optional(),rawInput:w().optional(),rawOutput:w().optional(),status:Mg.optional(),title:h(),toolCallId:zg}),Ug=f({_meta:_(h(),w()).nullish(),content:R(Og).nullish(),kind:Ng.nullish(),locations:R(Lg).nullish(),rawInput:w().optional(),rawOutput:w().optional(),status:Mg.nullish(),title:h().nullish(),toolCallId:zg}),Fg=f({_meta:_(h(),w()).nullish(),options:R(VI),sessionId:K,toolCall:Ug}),IP=f({_meta:_(h(),w()).nullish(),hint:h()}),PP=IP,RP=f({_meta:_(h(),w()).nullish(),description:h(),input:PP.nullish(),name:h()}),DP=f({_meta:_(h(),w()).nullish(),availableCommands:R(RP)}),OP=f({enum:R(h()),type:tI}),zP=Z([OP,TP]),LP=f({default:R(h()).nullish(),description:h().nullish(),items:zP,maxItems:U().nullish(),minItems:U().nullish(),title:h().nullish()}),MP=Z([aP.and(f({type:A("string")})),BI.and(f({type:A("number")})),aI.and(f({type:A("integer")})),jC.and(f({type:A("boolean")})),LP.and(f({type:A("array")}))]),NP=f({description:h().nullish(),properties:_(h(),MP).optional().default({}),required:R(h()).nullish(),title:h().nullish(),type:eI.optional().default("object")}),UP=f({requestedSchema:NP}),FP=Bo(Z([UP.and(f({mode:A("form")})),sI.and(f({mode:A("url")}))]),f({_meta:_(h(),w()).nullish(),message:h(),sessionId:K})),ZP=f({cachedReadTokens:U().nullish(),cachedWriteTokens:U().nullish(),inputTokens:U(),outputTokens:U(),thoughtTokens:U().nullish(),totalTokens:U()}),jP=f({_meta:_(h(),w()).nullish(),stopReason:iP,usage:ZP.nullish(),userMessageId:h().nullish()});Z([f({id:Bn,result:Z([SP,FC,pI,q0,H0,Z0,V0,Y0,BC,tP,Q0,jP,rP,sP,cP,WC,_g])}),f({error:yg,id:Bn})]);const WP=f({_meta:_(h(),w()).nullish(),cost:GC.nullish(),size:U(),used:U()}),BP=Z([Wa.and(f({sessionUpdate:A("user_message_chunk")})),Wa.and(f({sessionUpdate:A("agent_message_chunk")})),Wa.and(f({sessionUpdate:A("agent_thought_chunk")})),CP.and(f({sessionUpdate:A("tool_call")})),Ug.and(f({sessionUpdate:A("tool_call_update")})),KI.and(f({sessionUpdate:A("plan")})),DP.and(f({sessionUpdate:A("available_commands_update")})),B0.and(f({sessionUpdate:A("current_mode_update")})),A0.and(f({sessionUpdate:A("config_option_update")})),j0.and(f({sessionUpdate:A("session_info_update")})),WP.and(f({sessionUpdate:A("usage_update")}))]),Zg=f({_meta:_(h(),w()).nullish(),sessionId:K,update:BP});f({method:h(),params:Z([Zg,XC,bg]).nullish()});const jg=f({_meta:_(h(),w()).nullish(),sessionId:K,terminalId:h()}),GP=f({_meta:_(h(),w()).nullish(),exitCode:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:h().nullish()}),VP=f({name:h(),uri:h()}),HP=f({_meta:_(h(),w()).nullish(),repository:LI.nullish(),workspaceFolders:R(VP).nullish(),workspaceUri:h().nullish()});f({id:Bn,method:h(),params:Z([n0,UC,dI,WI,M0,cI,L0,U0,P0,eP,X0,xP,nP,HP,lP,I0,wg]).nullish()});const Wg=f({_meta:_(h(),w()).nullish(),content:h(),path:h(),sessionId:K});f({id:Bn,method:h(),params:Z([Wg,Pg,Fg,Cg,Dg,Rg,jg,Ig,FP,wg]).nullish()});const qP=f({_meta:_(h(),w()).nullish()});Z([f({id:Bn,result:Z([qP,c0,v0,VC,dP,u0,GP,lI,QC,_g])}),f({error:yg,id:Bn})]);var Y;class YP{constructor(e,n){$(this,Y);const r=e(this),s=async(o,a)=>{var l,c,d,p,y,m,E;switch(o){case Tt.fs_write_text_file:{const k=Wg.parse(a);return(l=r.writeTextFile)==null?void 0:l.call(r,k)}case Tt.fs_read_text_file:{const k=Pg.parse(a);return(c=r.readTextFile)==null?void 0:c.call(r,k)}case Tt.session_request_permission:{const k=Fg.parse(a);return r.requestPermission(k)}case Tt.terminal_create:{const k=Cg.parse(a);return(d=r.createTerminal)==null?void 0:d.call(r,k)}case Tt.terminal_output:{const k=Dg.parse(a);return(p=r.terminalOutput)==null?void 0:p.call(r,k)}case Tt.terminal_release:{const k=Rg.parse(a);return await((y=r.releaseTerminal)==null?void 0:y.call(r,k))??{}}case Tt.terminal_wait_for_exit:{const k=jg.parse(a);return(m=r.waitForTerminalExit)==null?void 0:m.call(r,k)}case Tt.terminal_kill:{const k=Ig.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 Tt.session_update:{const l=Zg.parse(a);return r.sessionUpdate(l)}default:if(r.extNotification)return r.extNotification(o,a);throw ye.methodNotFound(o)}};x(this,Y,new KP(s,i,n))}async initialize(e){return await u(this,Y).sendRequest(ie.initialize,e)}async newSession(e){return await u(this,Y).sendRequest(ie.session_new,e)}async loadSession(e){return await u(this,Y).sendRequest(ie.session_load,e)??{}}async unstable_forkSession(e){return await u(this,Y).sendRequest(ie.session_fork,e)}async listSessions(e){return await u(this,Y).sendRequest(ie.session_list,e)}async unstable_resumeSession(e){return await u(this,Y).sendRequest(ie.session_resume,e)}async unstable_closeSession(e){return await u(this,Y).sendRequest(ie.session_close,e)}async setSessionMode(e){return await u(this,Y).sendRequest(ie.session_set_mode,e)??{}}async unstable_setSessionModel(e){return await u(this,Y).sendRequest(ie.session_set_model,e)??{}}async setSessionConfigOption(e){return await u(this,Y).sendRequest(ie.session_set_config_option,e)}async authenticate(e){return await u(this,Y).sendRequest(ie.authenticate,e)??{}}async unstable_logout(e){return await u(this,Y).sendRequest(ie.logout,e)??{}}async prompt(e){return await u(this,Y).sendRequest(ie.session_prompt,e)}async cancel(e){return await u(this,Y).sendNotification(ie.session_cancel,e)}async unstable_startNes(e){return await u(this,Y).sendRequest(ie.nes_start,e)}async unstable_suggestNes(e){return await u(this,Y).sendRequest(ie.nes_suggest,e)}async unstable_closeNes(e){return await u(this,Y).sendRequest(ie.nes_close,e)??{}}async unstable_didOpenDocument(e){return await u(this,Y).sendNotification(ie.document_did_open,e)}async unstable_didChangeDocument(e){return await u(this,Y).sendNotification(ie.document_did_change,e)}async unstable_didCloseDocument(e){return await u(this,Y).sendNotification(ie.document_did_close,e)}async unstable_didSaveDocument(e){return await u(this,Y).sendNotification(ie.document_did_save,e)}async unstable_didFocusDocument(e){return await u(this,Y).sendNotification(ie.document_did_focus,e)}async unstable_acceptNes(e){return await u(this,Y).sendNotification(ie.nes_accept,e)}async unstable_rejectNes(e){return await u(this,Y).sendNotification(ie.nes_reject,e)}async extMethod(e,n){return await u(this,Y).sendRequest(e,n)}async extNotification(e,n){return await u(this,Y).sendNotification(e,n)}get signal(){return u(this,Y).signal}get closed(){return u(this,Y).closed}}Y=new WeakMap;var Yt,Ao,Us,Fs,Sr,kr,yt,Zs,ae,Bg,kl,Gg,Vg,Hg,qg,El,ms;class KP{constructor(e,n,r){$(this,ae);$(this,Yt,new Map);$(this,Ao,0);$(this,Us);$(this,Fs);$(this,Sr);$(this,kr,Promise.resolve());$(this,yt,new AbortController);$(this,Zs);x(this,Us,e),x(this,Fs,n),x(this,Sr,r),x(this,Zs,new Promise(s=>{u(this,yt).signal.addEventListener("abort",()=>s())})),b(this,ae,Bg).call(this)}get signal(){return u(this,yt).signal}get closed(){return u(this,Zs)}async sendRequest(e,n){b(this,ae,El).call(this);const r=xu(this,Ao)._++,s=new Promise((i,o)=>{u(this,Yt).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,El).call(this),await b(this,ae,ms).call(this,{jsonrpc:"2.0",method:e,params:n})}}Yt=new WeakMap,Ao=new WeakMap,Us=new WeakMap,Fs=new WeakMap,Sr=new WeakMap,kr=new WeakMap,yt=new WeakMap,Zs=new WeakMap,ae=new WeakSet,Bg=async function(){let e;try{const n=u(this,Sr).readable.getReader();try{for(;!u(this,yt).signal.aborted;){const{value:r,done:s}=await n.read();if(s)break;if(r)try{b(this,ae,Gg).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,kl).call(this,e)}},kl=function(e){if(u(this,yt).signal.aborted)return;const n=e??new Error("ACP connection closed");for(const r of u(this,Yt).values())r.reject(n);u(this,Yt).clear(),u(this,yt).abort(n)},Gg=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,qg).call(this,e):console.error("Invalid message",{message:e})},Vg=async function(e,n){try{return{result:await u(this,Us).call(this,e,n)??null}}catch(r){if(r instanceof ye)return r.toResult();if(r instanceof md)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 u(this,Fs).call(this,e,n),{result:null}}catch(r){if(r instanceof ye)return r.toResult();if(r instanceof md)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()}}},qg=function(e){const n=u(this,Yt).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))}u(this,Yt).delete(e.id)}else console.error("Got response to unknown request",e.id)},El=function(){if(u(this,yt).signal.aborted)throw u(this,yt).signal.reason??new Error("ACP connection closed")},ms=async function(e){return x(this,kr,u(this,kr).then(async()=>{const n=u(this,Sr).writable.getWriter();try{await n.write(e)}finally{n.releaseLock()}}).catch(n=>{b(this,ae,kl).call(this,n)})),u(this,kr)};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 JP=/^Sender \(untrusted metadata\):\n```json\n[\s\S]*?\n```\n\n?/,XP=/^\[[^\n]*Working directory:[^\n]*\]\n\n?/,QP=/\[Television screen context\][\s\S]*?\[\/Television screen context\]\n*/,eR=/\[\[\s*(?:reply_to_current|reply_to\s*:\s*[^\]\n]+|audio_as_voice)\s*\]\]\s*/gi,tR="single_session",nR={name:"television-acp-client",version:"0.0.0"},Yg="agent:main:television",rR=Hr(kt);var ne,Rt,Er,Dt,On,zn,Kt,$r,bt,rt,Jt,Ln,Ot,Xt,js,zt,st,xo,Lt,C,Kg,Jg,$l,Xg,Qg,em,tm,nm,rm,sm,wn,hr,dr,Be,im,pr,Al,xl,no,om,Ws,Bs,Tl,fr,am,lm;class sR extends rR{constructor(n){super();$(this,C);$(this,ne,iR());$(this,Rt,null);$(this,Er,null);$(this,Dt,null);$(this,On,null);$(this,zn,null);$(this,Kt,null);$(this,$r,1);$(this,bt,null);$(this,rt,null);$(this,Jt,!1);$(this,Ln,!1);$(this,Ot,null);$(this,Xt,new Set);$(this,js);$(this,zt);$(this,st);$(this,xo,n=>{b(this,C,Jg).call(this,n)});$(this,Lt,null);$(this,Ws,()=>{b(this,C,fr).call(this,"ACP bridge websocket closed")});$(this,Bs,()=>{b(this,C,fr).call(this,"ACP bridge websocket error")});x(this,zt,n),x(this,st,n.sessionMode??tR),x(this,js,n.createSocket??(r=>new WebSocket(r)))}getState(){return u(this,ne)}get messages(){return u(this,ne).messageOrder.map(n=>u(this,ne).messagesById[n]).filter(n=>n!==void 0)}async connect(){if(this.disposed)throw new Error("ACPClient has been disposed");if(u(this,ne).lifecycle.status!=="ready"){b(this,C,Be).call(this,{lifecycle:{status:"connecting"}}),u(this,Er)??x(this,Er,b(this,C,Kg).call(this));try{await u(this,Er),await b(this,C,$l).call(this)}catch(n){throw b(this,C,fr).call(this,Fi(n)),n}}}dispose(){b(this,C,Tl).call(this),b(this,C,Be).call(this,{lifecycle:{status:"disposed"},run:{status:"idle",stopReason:null,canCancel:!1,error:null}})}async sendMessage(n){if(await this.connect(),u(this,ne).lifecycle.status!=="ready"||u(this,ne).run.status==="running"||u(this,ne).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,C,hr).call(this,{id:b(this,C,pr).call(this,"user"),kind:"user",text:r,status:"final"}),b(this,C,Be).call(this,{run:{status:"running",stopReason:null,canCancel:!0,error:null}});try{const s=await b(this,C,no).call(this).prompt({sessionId:b(this,C,xl).call(this),prompt:[{type:"text",text:b(this,C,im).call(this,r)}]});b(this,C,wn).call(this,s.stopReason==="cancelled"?"cancelled":"final"),b(this,C,Be).call(this,{run:{status:s.stopReason==="cancelled"?"cancelled":"completed",stopReason:s.stopReason,canCancel:!1,error:null}})}catch(s){throw b(this,C,lm).call(this)||(b(this,C,wn).call(this,"error"),b(this,C,Be).call(this,{run:{status:"error",stopReason:null,canCancel:!1,error:Fi(s)}})),s}}async cancel(){if(await this.connect(),!u(this,ne).run.canCancel||u(this,ne).run.status!=="running")throw new Error("No active cancellable run");b(this,C,Be).call(this,{run:{...u(this,ne).run,status:"cancelling"}}),await b(this,C,no).call(this).cancel({sessionId:b(this,C,xl).call(this)})}setScreenContext(n){var i,o,a;const r={screenID:n.screenID,screenName:n.screenName};if(((i=u(this,rt))==null?void 0:i.screenID)===r.screenID&&((o=u(this,rt))==null?void 0:o.screenName)===r.screenName)return;const s=((a=u(this,rt))==null?void 0:a.screenID)??null;if(x(this,rt,r),u(this,st)==="single_session"){(!u(this,Kt)||s!==r.screenID)&&x(this,Jt,!0);return}u(this,Kt)!==Sd(u(this,st),r.screenID,u(this,zt).clientGUID??"default-client")&&(x(this,Dt,null),x(this,On,null),u(this,Rt)&&u(this,ne).run.status==="idle"&&b(this,C,$l).call(this).catch(l=>{b(this,C,fr).call(this,Fi(l))}))}}ne=new WeakMap,Rt=new WeakMap,Er=new WeakMap,Dt=new WeakMap,On=new WeakMap,zn=new WeakMap,Kt=new WeakMap,$r=new WeakMap,bt=new WeakMap,rt=new WeakMap,Jt=new WeakMap,Ln=new WeakMap,Ot=new WeakMap,Xt=new WeakMap,js=new WeakMap,zt=new WeakMap,st=new WeakMap,xo=new WeakMap,Lt=new WeakMap,C=new WeakSet,Kg=async function(){try{b(this,C,Be).call(this,{lifecycle:{status:"connecting"}});const{stream:n,socket:r}=await lR({serverURL:u(this,zt).serverURL,token:u(this,zt).token,createSocket:u(this,js),onDisconnect:u(this,xo)});x(this,Lt,r),r.addEventListener("close",u(this,Ws)),r.addEventListener("error",u(this,Bs)),x(this,Rt,new YP(s=>({connection:s,sessionUpdate:async i=>{await b(this,C,Qg).call(this,i)},requestPermission:async i=>b(this,C,em).call(this,i)}),n)),await u(this,Rt).initialize({protocolVersion:RC,clientCapabilities:{},clientInfo:nR})}catch(n){throw n}},Jg=function(n){b(this,C,fr).call(this,Fi(n))},$l=async function(){const n=b(this,C,om).call(this);if(u(this,Dt)&&u(this,On)===n){await u(this,Dt);return}x(this,On,n),x(this,Dt,b(this,C,Xg).call(this,n)),await u(this,Dt)},Xg=async function(n){const r=b(this,C,no).call(this);b(this,C,am).call(this);let s,i=!1;try{x(this,Ln,!0),x(this,Ot,null),await r.loadSession({sessionId:n,cwd:"/",mcpServers:[],_meta:{sessionKey:n}}),s=n,i=u(this,ne).messageOrder.length>0}catch{s=(await r.newSession({cwd:"/",mcpServers:[],_meta:{sessionKey:n}})).sessionId,i=!1}finally{x(this,Ln,!1),x(this,Ot,null),b(this,C,wn).call(this,"final")}await r.setSessionConfigOption({sessionId:s,configId:"verbose_level",value:"full"}),x(this,zn,s),x(this,Kt,n),i?(u(this,Xt).add(n),u(this,st)==="single_session"&&x(this,Jt,!1)):(u(this,Xt).delete(n),x(this,Jt,u(this,st)==="single_session")),b(this,C,Be).call(this,{lifecycle:{status:"ready"}})},Qg=async function(n){const r=n.update;switch(r.sessionUpdate){case"user_message_chunk":r.content.type==="text"&&b(this,C,sm).call(this,r.content.text);return;case"agent_message_chunk":r.content.type==="text"&&b(this,C,tm).call(this,r.content.text);return;case"tool_call":b(this,C,nm).call(this,r);return;case"tool_call_update":b(this,C,rm).call(this,r);return;case"agent_thought_chunk":return;default:return}},em=async function(n){return{outcome:{outcome:"cancelled"}}},tm=function(n){x(this,Ot,null);const r=oR(n);if(!r)return;if(!u(this,bt)){const i={id:b(this,C,pr).call(this,"assistant"),kind:"assistant",text:r,status:"streaming"};x(this,bt,i.id),b(this,C,hr).call(this,i);return}const s=u(this,ne).messagesById[u(this,bt)];if(!s||s.kind!=="assistant")throw new Error("Open assistant message invariant violated");b(this,C,dr).call(this,{...s,text:`${s.text}${r}`,status:"streaming"})},nm=function(n){b(this,C,wn).call(this,"final");const r=b(this,C,Al).call(this,n.toolCallId),s={id:(r==null?void 0:r.id)??b(this,C,pr).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,C,dr).call(this,s);return}b(this,C,hr).call(this,s)},rm=function(n){const r=b(this,C,Al).call(this,n.toolCallId),s=(r==null?void 0:r.text)??"",i=aR(n.content),o=i?`${s}${i}`:s,a={id:(r==null?void 0:r.id)??b(this,C,pr).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,C,dr).call(this,a);return}b(this,C,hr).call(this,a)},sm=function(n){if(b(this,C,wn).call(this,"final"),!n)return;const r=u(this,Ln)?u(this,Ot):null;if(!r){const i=kd(n);if(!i)return;const o={id:b(this,C,pr).call(this,"user"),kind:"user",text:i,status:"final"};b(this,C,hr).call(this,o),u(this,Ln)&&x(this,Ot,o.id);return}const s=u(this,ne).messagesById[r];if(!s||s.kind!=="user")throw new Error("Replay user message invariant violated");b(this,C,dr).call(this,{...s,text:kd(`${s.text}${n}`)})},wn=function(n){if(!u(this,bt))return;const r=u(this,ne).messagesById[u(this,bt)];(r==null?void 0:r.kind)==="assistant"&&b(this,C,dr).call(this,{...r,status:n}),x(this,bt,null)},hr=function(n){b(this,C,Be).call(this,{messagesById:{...u(this,ne).messagesById,[n.id]:n},messageOrder:[...u(this,ne).messageOrder,n.id]})},dr=function(n){b(this,C,Be).call(this,{messagesById:{...u(this,ne).messagesById,[n.id]:n}})},Be=function(n){const r={...u(this,ne),...n};x(this,ne,{...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"))},im=function(n){const r=u(this,Kt);return!u(this,rt)||!r||!(u(this,st)==="single_session"?u(this,Jt)||!u(this,Xt).has(r):!u(this,Xt).has(r))?n:(x(this,Jt,!1),u(this,Xt).add(r),["[Television screen context]","This chat session is coming from a Television client in the screen below.",`screen_id: ${u(this,rt).screenID}`,`screen_name: ${u(this,rt).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
|
+
`))},pr=function(n){const r=`${n}-${u(this,$r)}`;return x(this,$r,u(this,$r)+1),r},Al=function(n){for(const r of u(this,ne).messageOrder){const s=u(this,ne).messagesById[r];if((s==null?void 0:s.kind)==="tool_call"&&s.toolCallId===n)return s}return null},xl=function(){if(!u(this,zn))throw new Error("ACP session is not ready");return u(this,zn)},no=function(){if(!u(this,Rt))throw new Error("ACP connection is not ready");return u(this,Rt)},om=function(){var r;if(u(this,st)==="single_session")return`${Yg}-${(u(this,zt).clientGUID??"default-client").toLowerCase()}`;const n=(r=u(this,rt))==null?void 0:r.screenID;if(!n)throw new Error("Screen context is required for per-screen session mode");return Sd(u(this,st),n,u(this,zt).clientGUID??"default-client")},Ws=new WeakMap,Bs=new WeakMap,Tl=function(){x(this,Rt,null),x(this,Er,null),x(this,Dt,null),x(this,On,null),x(this,zn,null),x(this,Kt,null),u(this,Lt)&&(u(this,Lt).removeEventListener("close",u(this,Ws)),u(this,Lt).removeEventListener("error",u(this,Bs)),u(this,Lt).close(),x(this,Lt,null))},fr=function(n){this.disposed||u(this,ne).lifecycle.status==="disconnected"||(b(this,C,wn).call(this,"error"),b(this,C,Tl).call(this),b(this,C,Be).call(this,{lifecycle:{status:"disconnected",...n?{error:n}:{}},run:{status:"idle",stopReason:null,canCancel:!1,error:null}}))},am=function(){x(this,bt,null),x(this,Ot,null),x(this,$r,1),b(this,C,Be).call(this,{run:{status:"idle",stopReason:null,canCancel:!1,error:null},messagesById:{},messageOrder:[]})},lm=function(){return u(this,ne).lifecycle.status==="disconnected"};function iR(){return{lifecycle:{status:"connecting"},run:{status:"idle",stopReason:null,canCancel:!1,error:null},messagesById:{},messageOrder:[],sendDisabled:!0,cancelDisabled:!0}}function Sd(t,e,n){return t==="single_session"?`${Yg}-${n.toLowerCase()}`:`agent:main:television-${n.toLowerCase()}-${e.toLowerCase()}`}function cm(t){return t.replace(/^(?:\s*\n)+/,"")}function kd(t){let e=t;return e=e.replace(JP,""),e=e.replace(XP,""),e=e.replace(QP,""),e=cm(e),e}function oR(t){let e=t;return e=e.replace(eR,""),e=cm(e),e}function aR(t){return!t||t.length===0?"":t.flatMap(e=>e.type==="content"&&e.content.type==="text"?[e.content.text]:[]).join("")}async function lR(t){const e=t.createSocket(uR(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"}))},p=E=>{const k=cR(E);if(!k)return;let I;try{I=JSON.parse(k)}catch(G){const N=G instanceof Error?G:new Error(String(G));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 G=new Error(I.error??`ACP bridge ${I.status}`);n||s(G),l.error(G)}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",p),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 cR(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 uR(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 Ed="television.acpClientGUID",hR=Hr(kt);class dR extends hR{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??pR(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 sR({...this.options,sessionMode:this.sessionMode,clientGUID:this.clientGUID}),this.clients.set(r,s)),s.setScreenContext({screenID:n.id,screenName:n.name}),s}}function pR(t){const e=t.getItem(Ed);if(e)return e;const n=xc().toLowerCase();return t.setItem(Ed,n),n}const fR="serverURL",gR="token",mR="mode",vR="electron";function um(t=window.location.search,e=window.location.origin){const r=new URLSearchParams(t).get(fR);return r?new URL(r).origin:new URL(e).origin}function hm(t=window.location.search){return new URLSearchParams(t).get(gR)}function dm(t=window.location.search){return new URLSearchParams(t).get(mR)===vR}/**
|
|
44
44
|
* @license
|
|
45
45
|
* Copyright 2017 Google LLC
|
|
46
46
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
47
|
-
*/const As=globalThis
|
|
48
|
-
\f\r]`,is=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,
|
|
49
|
-
\f\r"'\`<>=]|("|')|))|$)`,"g"),
|
|
47
|
+
*/const As=globalThis,$d=t=>t,bo=As.trustedTypes,Ad=bo?bo.createPolicy("lit-html",{createHTML:t=>t}):void 0,pm="$lit$",Gt=`lit$${Math.random().toFixed(9).slice(2)}$`,fm="?"+Gt,yR=`<${fm}>`,Gn=document,Cs=()=>Gn.createComment(""),Is=t=>t===null||typeof t!="object"&&typeof t!="function",Zc=Array.isArray,bR=t=>Zc(t)||typeof(t==null?void 0:t[Symbol.iterator])=="function",Ba=`[
|
|
48
|
+
\f\r]`,is=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,xd=/-->/g,Td=/>/g,yn=RegExp(`>|${Ba}(?:([^\\s"'>=/]+)(${Ba}*=${Ba}*(?:[^
|
|
49
|
+
\f\r"'\`<>=]|("|')|))|$)`,"g"),Cd=/'/g,Id=/"/g,gm=/^(?:script|style|textarea|title)$/i,wR=t=>(e,...n)=>({_$litType$:t,strings:e,values:n}),M=wR(1),Mr=Symbol.for("lit-noChange"),ge=Symbol.for("lit-nothing"),Pd=new WeakMap,Tn=Gn.createTreeWalker(Gn,129);function mm(t,e){if(!Zc(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return Ad!==void 0?Ad.createHTML(e):e}const _R=(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,p=-1,y=0;for(;y<l.length&&(o.lastIndex=y,d=o.exec(l),d!==null);)y=o.lastIndex,o===is?d[1]==="!--"?o=xd:d[1]!==void 0?o=Td:d[2]!==void 0?(gm.test(d[2])&&(s=RegExp("</"+d[2],"g")),o=yn):d[3]!==void 0&&(o=yn):o===yn?d[0]===">"?(o=s??is,p=-1):d[1]===void 0?p=-2:(p=o.lastIndex-d[2].length,c=d[1],o=d[3]===void 0?yn:d[3]==='"'?Id:Cd):o===Id||o===Cd?o=yn:o===xd||o===Td?o=is:(o=yn,s=void 0);const m=o===yn&&t[a+1].startsWith("/>")?" ":"";i+=o===is?l+yR:p>=0?(r.push(c),l.slice(0,p)+pm+l.slice(p)+Gt+m):l+Gt+(p===-2?a:m)}return[mm(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]=_R(e,n);if(this.el=Ps.createElement(c,r),Tn.currentNode=this.el.content,n===2||n===3){const p=this.el.content.firstChild;p.replaceWith(...p.childNodes)}for(;(s=Tn.nextNode())!==null&&l.length<a;){if(s.nodeType===1){if(s.hasAttributes())for(const p of s.getAttributeNames())if(p.endsWith(pm)){const y=d[o++],m=s.getAttribute(p).split(Gt),E=/([.?@])?(.*)/.exec(y);l.push({type:1,index:i,name:E[2],strings:m,ctor:E[1]==="."?kR:E[1]==="?"?ER:E[1]==="@"?$R:Yo}),s.removeAttribute(p)}else p.startsWith(Gt)&&(l.push({type:6,index:i}),s.removeAttribute(p));if(gm.test(s.tagName)){const p=s.textContent.split(Gt),y=p.length-1;if(y>0){s.textContent=bo?bo.emptyScript:"";for(let m=0;m<y;m++)s.append(p[m],Cs()),Tn.nextNode(),l.push({type:2,index:++i});s.append(p[y],Cs())}}}else if(s.nodeType===8)if(s.data===fm)l.push({type:2,index:i});else{let p=-1;for(;(p=s.data.indexOf(Gt,p+1))!==-1;)l.push({type:7,index:i}),p+=Gt.length-1}i++}}static createElement(e,n){const r=Gn.createElement("template");return r.innerHTML=e,r}}function Nr(t,e,n=t,r){var o,a;if(e===Mr)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=Nr(t,s._$AS(t,e.values),s,r)),e}class SR{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)??Gn).importNode(n,!0);Tn.currentNode=s;let i=Tn.nextNode(),o=0,a=0,l=r[0];for(;l!==void 0;){if(o===l.index){let c;l.type===2?c=new jc(i,i.nextSibling,this,e):l.type===1?c=new l.ctor(i,l.name,l.strings,this,e):l.type===6&&(c=new AR(i,this,e)),this._$AV.push(c),l=r[++a]}o!==(l==null?void 0:l.index)&&(i=Tn.nextNode(),o++)}return Tn.currentNode=Gn,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 jc=class vm{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=Nr(this,e,n),Is(e)?e===ge||e==null||e===""?(this._$AH!==ge&&this._$AR(),this._$AH=ge):e!==this._$AH&&e!==Mr&&this._(e):e._$litType$!==void 0?this.$(e):e.nodeType!==void 0?this.T(e):bR(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(Gn.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(mm(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 SR(s,this),a=o.u(this.options);o.p(n),this.T(a),this._$AH=o}}_$AC(e){let n=Pd.get(e.strings);return n===void 0&&Pd.set(e.strings,n=new Ps(e)),n}k(e){Zc(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 vm(this.O(Cs()),this.O(Cs()),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=$d(e).nextSibling;$d(e).remove(),e=s}}setConnected(e){var n;this._$AM===void 0&&(this._$Cv=e,(n=this._$AP)==null||n.call(this,e))}},Yo=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=Nr(this,e,n,0),o=!Is(e)||e!==this._$AH&&e!==Mr,o&&(this._$AH=e);else{const a=e;let l,c;for(e=i[0],l=0;l<i.length-1;l++)c=Nr(this,a[r+l],n,l),c===Mr&&(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??"")}},kR=class extends Yo{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===ge?void 0:e}},ER=class extends Yo{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==ge)}},$R=class extends Yo{constructor(e,n,r,s,i){super(e,n,r,s,i),this.type=5}_$AI(e,n=this){if((e=Nr(this,e,n,0)??ge)===Mr)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 AR{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){Nr(this,e)}}const Ga=As.litHtmlPolyfillSupport;Ga==null||Ga(Ps,jc),(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 jc(e.insertBefore(Cs(),null),null,void 0,{})),s._$AI(t),s};/**
|
|
50
50
|
* @license
|
|
51
51
|
* Copyright 2017 Google LLC
|
|
52
52
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
53
|
-
*/const
|
|
53
|
+
*/const xR={CHILD:2},ym=t=>(...e)=>({_$litDirective$:t,values:e});class TR{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
54
|
* @license
|
|
55
55
|
* Copyright 2017 Google LLC
|
|
56
56
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
57
|
-
*/class wo extends
|
|
57
|
+
*/class wo extends TR{constructor(e){if(super(e),this.it=ge,e.type!==xR.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===Mr)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:[]}}}wo.directiveName="unsafeHTML",wo.resultType=1;const CR=ym(wo);/**
|
|
58
58
|
* @license
|
|
59
59
|
* Copyright 2017 Google LLC
|
|
60
60
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
61
|
-
*/class Cl extends wo{}Cl.directiveName="unsafeSVG",Cl.resultType=2;const
|
|
61
|
+
*/class Cl extends wo{}Cl.directiveName="unsafeSVG",Cl.resultType=2;const IR=ym(Cl),PR={size:16,color:"currentColor",weight:"regular"};function RR(t){return typeof t=="string"?{regular:t}:t}function Ko(t,e="0 0 256 256"){const n=RR(t);return r=>{const{size:s,color:i,weight:o}={...PR,...r},a=n[o]??n.regular;return M`<svg
|
|
62
62
|
xmlns="http://www.w3.org/2000/svg"
|
|
63
63
|
data-ui-icon=""
|
|
64
64
|
width="${s}"
|
|
65
65
|
height="${s}"
|
|
66
66
|
viewBox="${e}"
|
|
67
67
|
fill="${i}"
|
|
68
|
-
>${
|
|
68
|
+
>${IR(a)}</svg>`}}const DR=Ko('<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"/>'),bm=Ko('<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"/>'),wm=Ko('<path d="M213.66,93.66l-80,80a8,8,0,0,1-11.32,0l-80-80A8,8,0,0,1,53.66,82.34L128,156.69l74.34-74.35a8,8,0,0,1,11.32,11.32Z"/>'),OR=Ko('<path d="M213.66,162.34l-80-80a8,8,0,0,0-11.32,0l-80,80A8,8,0,0,0,53.66,173.66L128,99.31l74.34,74.35a8,8,0,0,0,11.32-11.32Z"/>');class _m extends Event{constructor(n){super("dropdown-item-select",{bubbles:!0,composed:!0});v(this,"value");this.value=n}}class zR extends Event{constructor(n){super("select",{bubbles:!0,composed:!0});v(this,"value");this.value=n}}var qe,it,Qt,Ar,re,Gs,D,km,vs,Em,$m,Il,Pl,ro,_n,Mn,Vs,Hs,qs,To,Am,xm,Rl,ys,Dl,Ol,Ct;class Sm extends HTMLElement{constructor(){super();$(this,D);$(this,qe,!1);$(this,it,null);$(this,Qt,null);$(this,Ar);$(this,re,null);$(this,Gs,new MutationObserver(n=>b(this,D,Am).call(this,n)));$(this,Mn,()=>{b(this,D,ro).call(this,!u(this,qe))});$(this,Vs,n=>{n.key!=="Enter"&&n.key!==" "||(n.preventDefault(),u(this,Mn).call(this))});$(this,Hs,n=>{u(this,qe)&&(n.composedPath().includes(this)||b(this,D,ro).call(this,!1))});$(this,qs,n=>{n instanceof _m&&(n.stopPropagation(),x(this,qe,!1),b(this,D,vs).call(this,n.value),b(this,D,Ct).call(this),this.dispatchEvent(new zR(n.value)))});$(this,To,()=>{b(this,D,Rl).call(this)});x(this,Ar,this.attachShadow({mode:"open"}))}connectedCallback(){this.addEventListener("dropdown-item-select",u(this,qs)),document.addEventListener("click",u(this,Hs),!0),b(this,D,km).call(this),u(this,Gs).observe(this,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["selected","value","slot"]}),b(this,D,Ct).call(this)}disconnectedCallback(){this.removeEventListener("dropdown-item-select",u(this,qs)),document.removeEventListener("click",u(this,Hs),!0),u(this,Gs).disconnect(),b(this,D,Ol).call(this)}attributeChangedCallback(){b(this,D,Ct).call(this)}get title(){return this.getAttribute("title")??""}get placement(){return this.getAttribute("placement")==="top"?"top":"bottom"}get value(){return u(this,it)}set value(n){n===null?(b(this,D,_n).call(this,null,null),b(this,D,Em).call(this)):b(this,D,vs).call(this,n),b(this,D,Ct).call(this)}close(){b(this,D,ro).call(this,!1)}}qe=new WeakMap,it=new WeakMap,Qt=new WeakMap,Ar=new WeakMap,re=new WeakMap,Gs=new WeakMap,D=new WeakSet,km=function(){var r;const n=this.querySelector("dropdown-item[selected]");n&&b(this,D,_n).call(this,n.value,((r=n.textContent)==null?void 0:r.trim())??null)},vs=function(n){var r;for(const s of u(this,D,Il))s.value===n?(b(this,D,_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")},Em=function(){const n=this.querySelectorAll("dropdown-item[selected]");for(const r of n)r.removeAttribute("selected")},$m=function(n){for(const r of u(this,D,Il))if(r.value===n)return r;return null},Il=function(){return this.querySelectorAll("dropdown-item")},Pl=function(){return u(this,Qt)??this.title},ro=function(n){u(this,qe)!==n&&(x(this,qe,n),b(this,D,Ct).call(this))},_n=function(n,r){x(this,it,n),x(this,Qt,r)},Mn=new WeakMap,Vs=new WeakMap,Hs=new WeakMap,qs=new WeakMap,To=new WeakMap,Am=function(n){n.every(s=>s.target instanceof Element?s.target.closest('[slot="trigger"]')!==null:!1)||b(this,D,xm).call(this)},xm=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=u(this,it)!==i||u(this,Qt)!==o;b(this,D,_n).call(this,i,o),b(this,D,vs).call(this,i),a?b(this,D,Ct).call(this):b(this,D,ys).call(this);return}if(u(this,it)!==null){const i=b(this,D,$m).call(this,u(this,it));if(i){const o=((s=i.textContent)==null?void 0:s.trim())??null,a=u(this,Qt)!==o;b(this,D,_n).call(this,u(this,it),o),b(this,D,vs).call(this,u(this,it)),a?b(this,D,Ct).call(this):b(this,D,ys).call(this);return}}if(u(this,it)!==null||u(this,Qt)!==null){b(this,D,_n).call(this,null,null),b(this,D,Ct).call(this);return}b(this,D,ys).call(this)},Rl=function(){const n=u(this,Ar).querySelector('slot[name="trigger"]'),r=n instanceof HTMLSlotElement?n.assignedElements()[0]??null:null;u(this,re)!==r&&(b(this,D,Ol).call(this),x(this,re,r),u(this,re)&&(u(this,re).addEventListener("click",u(this,Mn)),u(this,re)instanceof HTMLButtonElement?u(this,re).hasAttribute("type")||(u(this,re).type="button"):(u(this,re).hasAttribute("role")||u(this,re).setAttribute("role","button"),u(this,re).hasAttribute("tabindex")||(u(this,re).tabIndex=0),u(this,re).addEventListener("keydown",u(this,Vs))))),b(this,D,ys).call(this)},ys=function(){u(this,re)&&(u(this,re).setAttribute("data-dropdown-trigger",""),u(this,re).setAttribute("aria-haspopup","listbox"),u(this,re).setAttribute("aria-expanded",u(this,qe)?"true":"false"),be(M`
|
|
69
69
|
<span class="trigger-label" data-dropdown-trigger-label>${u(this,D,Pl)}</span>
|
|
70
70
|
<span class="trigger-icon" data-dropdown-trigger-icon aria-hidden="true">
|
|
71
71
|
${u(this,D,Dl).call(this,{size:16})}
|
|
72
72
|
</span>
|
|
73
|
-
`,u(this,re)))},Dl=function(){return this.placement==="top"?
|
|
73
|
+
`,u(this,re)))},Dl=function(){return this.placement==="top"?OR:wm},Ol=function(){u(this,re)&&(u(this,re).removeEventListener("click",u(this,Mn)),u(this,re).removeEventListener("keydown",u(this,Vs)),u(this,re).removeAttribute("data-dropdown-trigger"),u(this,re).removeAttribute("aria-haspopup"),u(this,re).removeAttribute("aria-expanded"),x(this,re,null))},Ct=function(){this.toggleAttribute("open",u(this,qe)),be(M`
|
|
74
74
|
<slot name="trigger" @slotchange=${u(this,To)}>
|
|
75
75
|
<button
|
|
76
76
|
class="fallback-trigger"
|
|
@@ -95,13 +95,13 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
95
95
|
<slot></slot>
|
|
96
96
|
</div>
|
|
97
97
|
`:null}
|
|
98
|
-
`,u(this,Ar)),queueMicrotask(()=>b(this,D,Rl).call(this))},v(
|
|
98
|
+
`,u(this,Ar)),queueMicrotask(()=>b(this,D,Rl).call(this))},v(Sm,"observedAttributes",["title","placement"]);class LR extends HTMLElement{}class MR extends HTMLElement{}class NR extends HTMLElement{}var qn,zl,Cm,Ys,Ks;class Tm extends HTMLElement{constructor(){super(...arguments);$(this,qn);$(this,Ys,()=>{this.action||b(this,qn,Cm).call(this)});$(this,Ks,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",u(this,Ys)),this.addEventListener("keydown",u(this,Ks)),b(this,qn,zl).call(this)}disconnectedCallback(){this.removeEventListener("click",u(this,Ys)),this.removeEventListener("keydown",u(this,Ks))}attributeChangedCallback(){b(this,qn,zl).call(this)}get value(){return this.getAttribute("value")??""}get selected(){return this.hasAttribute("selected")}get action(){return this.hasAttribute("action")}}qn=new WeakSet,zl=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")},Cm=function(){this.dispatchEvent(new _m(this.value))},Ys=new WeakMap,Ks=new WeakMap,v(Tm,"observedAttributes",["action","selected","value"]);customElements.get("dropdown-menu")||customElements.define("dropdown-menu",Sm);customElements.get("dropdown-group")||customElements.define("dropdown-group",LR);customElements.get("dropdown-label")||customElements.define("dropdown-label",MR);customElements.get("dropdown-divider")||customElements.define("dropdown-divider",NR);customElements.get("dropdown-item")||customElements.define("dropdown-item",Tm);class UR extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}var Js,cn,Ll,Co,Xs,Ml;class Im extends HTMLElement{constructor(){super();$(this,cn);$(this,Js);$(this,Co,n=>{n.target===n.currentTarget&&b(this,cn,Ll).call(this)});$(this,Xs,n=>{this.open&&n.key==="Escape"&&b(this,cn,Ll).call(this)});x(this,Js,this.attachShadow({mode:"open"}))}connectedCallback(){document.addEventListener("keydown",u(this,Xs)),b(this,cn,Ml).call(this)}disconnectedCallback(){document.removeEventListener("keydown",u(this,Xs))}attributeChangedCallback(){b(this,cn,Ml).call(this)}get open(){return this.hasAttribute("open")}}Js=new WeakMap,cn=new WeakSet,Ll=function(){this.dispatchEvent(new UR)},Co=new WeakMap,Xs=new WeakMap,Ml=function(){be(M`
|
|
99
99
|
${this.open?M`
|
|
100
100
|
<div class="backdrop" part="backdrop" @click=${u(this,Co)}>
|
|
101
101
|
<slot></slot>
|
|
102
102
|
</div>
|
|
103
103
|
`:null}
|
|
104
|
-
`,u(this,Js))},v(
|
|
104
|
+
`,u(this,Js))},v(Im,"observedAttributes",["open"]);customElements.get("modal-overlay")||customElements.define("modal-overlay",Im);class Pm extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}class FR extends HTMLElement{}var Qs,ei,Nl;class Rm extends HTMLElement{constructor(){super();$(this,ei);$(this,Qs);x(this,Qs,this.attachShadow({mode:"open"}))}connectedCallback(){b(this,ei,Nl).call(this)}attributeChangedCallback(){b(this,ei,Nl).call(this)}get closable(){return this.hasAttribute("closable")}}Qs=new WeakMap,ei=new WeakSet,Nl=function(){const n=this.querySelector("panel-page");be(M`
|
|
105
105
|
<section class="panel" part="panel">
|
|
106
106
|
<header class="title-bar" part="header">
|
|
107
107
|
<h2 class="title" part="title">${(n==null?void 0:n.getAttribute("title"))??""}</h2>
|
|
@@ -111,16 +111,16 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
111
111
|
class="title-button"
|
|
112
112
|
part="button close-button"
|
|
113
113
|
aria-label="Close"
|
|
114
|
-
@click=${()=>this.dispatchEvent(new
|
|
114
|
+
@click=${()=>this.dispatchEvent(new Pm)}
|
|
115
115
|
>
|
|
116
|
-
<span class="close-icon" part="icon close-icon">${
|
|
116
|
+
<span class="close-icon" part="icon close-icon">${bm({size:16})}</span>
|
|
117
117
|
</button>
|
|
118
118
|
`:null}
|
|
119
119
|
</header>
|
|
120
120
|
<slot></slot>
|
|
121
121
|
</section>
|
|
122
|
-
`,u(this,Qs))},v(
|
|
123
|
-
${r.documentElement.outerHTML}`],{type:"text/html"});return URL.createObjectURL(o)}const
|
|
122
|
+
`,u(this,Qs))},v(Rm,"observedAttributes",["closable"]);customElements.get("panel-view")||customElements.define("panel-view",Rm);customElements.get("panel-page")||customElements.define("panel-page",FR);const ZR=et(),jR="No handler registered for update-content",WR="handleUpdateContent: handler already registered";function BR(t){return t instanceof Error&&typeof t.message=="string"?t.message:String(t)}const GR=Hr(kt);var xr,Tr,Cr,Nn,Un,ti,Te,Ul,Dm,Om,bs,Fl,lp;let VR=(lp=class extends GR{constructor(n){super();$(this,Te);$(this,xr);$(this,Tr);$(this,Cr);$(this,Nn,null);$(this,Un,null);$(this,ti,!1);x(this,xr,n);const r=n.ownerDocument.defaultView;if(!r)throw new Error("ArtifactView: iframe has no owner window");x(this,Tr,r),x(this,Cr,s=>b(this,Te,Dm).call(this,s)),u(this,Tr).addEventListener("message",u(this,Cr))}get content(){return u(this,Un)}set content(n){b(this,Te,Fl).call(this),x(this,Un,n),u(this,ti)&&b(this,Te,Ul).call(this,n)}handleUpdateContent(n){if(b(this,Te,Fl).call(this),u(this,Nn)!==null)throw new Error(WR);x(this,Nn,n)}dispose(){u(this,Tr).removeEventListener("message",u(this,Cr)),x(this,Nn,null)}},xr=new WeakMap,Tr=new WeakMap,Cr=new WeakMap,Nn=new WeakMap,Un=new WeakMap,ti=new WeakMap,Te=new WeakSet,Ul=function(n){const r={type:"content-updated",content:n};b(this,Te,bs).call(this,r)},Dm=function(n){if(this.disposed||n.source!==u(this,xr).contentWindow)return;const r=n.data;if(_C(r)){x(this,ti,!0),this.dispatchEvent(new ZR("ready")),u(this,Un)!==null&&b(this,Te,Ul).call(this,u(this,Un));return}if(SC(r)){b(this,Te,Om).call(this,r);return}},Om=async function(n){const r=u(this,Nn);if(r===null){b(this,Te,bs).call(this,{type:"response",id:n.id,error:{message:jR}});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:BR(s)}});return}this.disposed||b(this,Te,bs).call(this,{type:"response",id:n.id,result:{}})},bs=function(n){const r=u(this,xr).contentWindow;r&&r.postMessage(n,"*")},Fl=function(){if(this.disposed)throw new Error("ArtifactView is disposed")},lp);function HR(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 qR(){return`(${HR.toString()})(window);`}async function YR(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=qR(),r.head.appendChild(i);const o=new Blob([`<!DOCTYPE html>
|
|
123
|
+
${r.documentElement.outerHTML}`],{type:"text/html"});return URL.createObjectURL(o)}const zm=et();class KR 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 zm("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 VR(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 YR(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`
|
|
124
124
|
<div class="artifact-content artifact-placeholder">
|
|
125
125
|
<em>Failed to load content</em>
|
|
126
126
|
</div>
|
|
@@ -138,7 +138,7 @@ ${r.documentElement.outerHTML}`],{type:"text/html"});return URL.createObjectURL(
|
|
|
138
138
|
${this.contentTemplate()}
|
|
139
139
|
<footer class="artifact-title-bar" drag-handle>
|
|
140
140
|
<div class="artifact-title-group">
|
|
141
|
-
<span class="artifact-title-icon">${
|
|
141
|
+
<span class="artifact-title-icon">${DR({size:16})}</span>
|
|
142
142
|
<span class="artifact-title">${n.title}</span>
|
|
143
143
|
</div>
|
|
144
144
|
<button
|
|
@@ -146,10 +146,10 @@ ${r.documentElement.outerHTML}`],{type:"text/html"});return URL.createObjectURL(
|
|
|
146
146
|
@click=${()=>this.handleClose()}
|
|
147
147
|
aria-label="Close"
|
|
148
148
|
>
|
|
149
|
-
${
|
|
149
|
+
${bm({size:16})}
|
|
150
150
|
</button>
|
|
151
151
|
</footer>
|
|
152
|
-
`}render(){this._artifact&&(this.setAttribute("type",this._artifact.type),be(this.template(),this))}}customElements.define("artifact-view",eD);const Se=t=>({type:"px",...t}),xe=t=>({type:"unit",...t}),Zi=2,tD=2;class nD{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??tn,r=this._viewport.y??vr,s=this._gap.x??de,i=this._gap.y??de,o=tn+s*tD,a=n<=o,l=a?n-s*Zi:Math.min(tn,n-s*Zi),c=a?r-i*Zi:Math.min(vr,r-i*Zi),d=(l-s*(St-1))/St,p=(c-i*(He-1))/He,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,p)}:{x:Math.max(E,Math.min(y,d)),y:Math.max(k,Math.min(m,p))})}get unit(){return this._unit}get viewport(){return this._viewport}get gap(){return this._gap}toUnits(e){return xe({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 Vn=1e-4,Nt=1e-6,rD=40,sD=24;function Fm(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 jm(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 Wm(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+Vn)break;r=a,s+=1}return Math.max(1,s)}function iD(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+Vn)break;r=a,s+=1}return Math.max(1,s)}function oD(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+Vn)break;n=o,r+=1}return Math.max(1,r)}function Wc(t,e){if(t.length===0)return 0;const n=oD(t,e);return Math.max(0,t.length-n)}function Ld(t,e,n){if(t.length===0)return 0;const r=Wm(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 Zl(t,e,n){const r=t[e]??0;return n-r}function gr(t,e,n,r,s){if(t.length===0)return 0;const i=Wc(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,H=e[L+1]??J;if(a>=J&&a<=H+Vn){l=L;break}l=L+1}const c=Math.min(l+1,i),d=e[l]??0,p=e[c]??d,y=Math.max(p-d,Vn),m=c===l?0:(a-d)/y,E=jm(t),k=Ld(t,l,s),I=Ld(t,c,s),G=(r-k)/2,N=(r-I)/2,j=Zl(E,l,G),F=Zl(E,c,N);return j+(F-j)*m}function Md(t,e,n,r,s){const i=Wc(t,r),o=e[i]??0;let a=0,l=o;for(let c=0;c<rD;c+=1){const d=(a+l)/2;gr(t,e,d,n,r)>s?a=d:l=d}return(a+l)/2}function Nd(t,e,n){const r=jm(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 Zl(r,s,l)}function aD(t,e,n){const r=Wm(t,e,n);return[e,Math.min(t.length-1,e+r-1)]}function lD(t,e,n){const r=iD(t,e,n);return[Math.max(0,e-r+1),e]}function cD(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)<=Nt||(e.add(s),n.push(r))}return n}function uD(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=Fm(r,s),o=Zm(e),a=Wc(n,i),l=o[a]??0,c=[];for(let d=0;d<=a;d+=1){const p=aD(n,d,i),y=Nd(n,p,r),m=Md(n,o,r,i,y);c.push({nodeRange:p,anchor:Math.max(0,Math.min(l,m))})}for(let d=n.length-1;d>=0;d-=1){const p=lD(n,d,i),y=`${p[0]}:${p[1]}`;if(c.some(k=>`${k.nodeRange[0]}:${k.nodeRange[1]}`===y))continue;const m=Nd(n,p,r),E=Md(n,o,r,i,m);c.push({nodeRange:p,anchor:Math.max(0,Math.min(l,E))})}return c.sort((d,p)=>Math.abs(d.anchor-p.anchor)>Nt?d.anchor-p.anchor:d.nodeRange[0]!==p.nodeRange[0]?d.nodeRange[0]-p.nodeRange[0]:d.nodeRange[1]-p.nodeRange[1]),{viewspans:cD(c),minScroll:0,maxScroll:l}}function hD(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+Nt<r){r=o,n=i;continue}Math.abs(o-r)<=Nt&&i<n&&(n=i)}return n}function dD(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 pD 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 xe({x:this._scroll})}get translate(){return Se({x:gr(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)<=Nt||(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(xe({x:c})).x??0),i=n.grid.viewport.x??0,o=n.grid.gap.x??de,a=uD({nodeCols:r,nodeWidthsPx:s,viewportWidthPx:i,gapPx:o});this.nodeWidthsPx=s,this.boundaryCols=Zm(r),this.viewportWidthPx=i,this.framedViewportWidthPx=Fm(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)>Nt&&(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??hD(this.viewspans,this._scroll),s=dD(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)<=Nt)&&(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)<=Nt)&&(this._scroll=r,this.dispatchEvent(new ss("layout-scroll",{scroll:this.scroll})))}wheelPixels(n){const r=n.x??0;if(Math.abs(r)<=Vn)return;this.activeViewspanIndex=null;const s=gr(this.nodeWidthsPx,this.boundaryCols,this._scroll,this.viewportWidthPx,this.framedViewportWidthPx),i=s-r,o=gr(this.nodeWidthsPx,this.boundaryCols,this.maxScroll,this.viewportWidthPx,this.framedViewportWidthPx),a=gr(this.nodeWidthsPx,this.boundaryCols,this.minScroll,this.viewportWidthPx,this.framedViewportWidthPx),l=Math.max(o,Math.min(a,i));if(Math.abs(l-s)<=Vn)return;let c=this.minScroll,d=this.maxScroll;for(let y=0;y<sD;y+=1){const m=(c+d)/2;gr(this.nodeWidthsPx,this.boundaryCols,m,this.viewportWidthPx,this.framedViewportWidthPx)>l?c=m:d=m}const p=os((c+d)/2,this.minScroll,this.maxScroll);Math.abs(p-this._scroll)<=Nt||(this._scroll=p,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}},fD=["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 Bc(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 jl(t){return t.height===He||t.height===sn?{...t,height:sn}:t}function Wl(t){return t.height===sn?{...t,height:He}:t}function gD(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"?Wl(d):d}else l[s]={...i,children:a};const c=Math.max(0,Math.min(r,l.length));return l.splice(c,0,Wl(o)),l}const mD=et(),vD=et(),yD=50;function bD(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 Ud(t){return t.map(_D)}function wD(t){return t.type==="drop-target"?{id:t.id,type:"card",artifactID:t.id,width:t.width,height:t.height}:t}function _D(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(wD)}:t}function Bm(t,e){return t.find(r=>r.type==="card"&&r.id===e)??null}function Fd(t,e){return t.find(r=>r.type==="stack"&&r.id===e)??null}function SD(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 kD(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=Bm(r,e.nodeId);if(!a)return null;const l=jl(a),c=jl(o),d=yi(l),p=n.position==="above"?[d,c]:[c,d];return s[i]={id:o.id,type:"stack",children:p},s}function qa(t,e){return t.parentStackId?$D(t,e):ED(t,e)}function ED(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=SD(t,e);return r?kD(r,t,n,e)??[...e]:[...e]}return[...e]}function $D(t,e){const n=t.hitTarget;switch(n.type){case"stack-child-reorder":return AD(t,e,n.position);case"stack-child-extract":return xD(t,e,n.toIndex);case"stack-child-noop":return TD(t,e);default:return[...e]}}function AD(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],p=[...e];return p[r]={...s,children:d},p}function xD(t,e,n){if(!t.parentStackId)return[...e];const r=gD(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 TD(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 CD(t,e){return e.find(r=>r.type==="stack"&&r.id===t.id)?t.id:xc()}function ID(t,e,n){if(t.type==="drop-target"){const r=Bc(e,n);if(!r)throw new Error(`finalize: missing dragged card ${n}`);return jl(r)}return t}function PD(t,e,n){const r=t.children.map(i=>ID(i,e,n));return{id:CD(t,e),type:"stack",children:r}}function RD(t,e,n){if(t.type==="drop-target"){const r=Bc(e,n);if(!r)throw new Error(`finalize: missing dragged card ${n}`);return Bm(e,n)!==null?r:Wl(r)}return t.type==="card"||t.type==="row"?t:PD(t,e,n)}function DD(t,e,n){return t.map(r=>RD(r,e,n))}function OD(t,e){return JSON.stringify(t)===JSON.stringify(e)}const zD=Hr(kt);class LD extends zD{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)>=vE&&(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=qa(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&&bD(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=qa(this.active,n),i=DD(s,n,this.active.nodeId);OD(i,n)||(r=i)}catch{r=null}this.reset(),r&&this.dispatchEvent(new vD("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=qa(this.active,this.active.baseLayout);this.dispatchEvent(new mD("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=Fd(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=Fd(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)<=yD;for(const I of o){const G=I.rect;if(!bn(n,r,G))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)),p=this.resolveTopLevelTargetForCard(d,r,c,c.logicalIndex,l);if(p)return p;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 p of o){if(!bn(n,r,p.rect))continue;const y=Ha(p.rect,Va["reorder-before"]);if(bn(n,r,y))return p.logicalIndex;const m=Ha(p.rect,Va["reorder-after"]);if(bn(n,r,m))return p.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 fD){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,MD=80,jd=.5,Wd=10;class ND{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),p=Math.abs(i);return this.activeGestureType==="vertical-artifact"&&o?d>=jd&&d>=p*Wd?this.classifyHorizontal(n,c):(this.lastWheelGestureAt=n,{type:"scroll-native"}):this.activeGestureType==="horizontal-filmstrip"?!l&&o&&p>0&&p>=d*Wd?(this.activeGestureType="vertical-artifact",this.lastWheelGestureAt=n,{type:"scroll-native"}):this.classifyHorizontal(n,c):d<jd?(o&&(this.activeGestureType="vertical-artifact"),this.lastWheelGestureAt=n,{type:"scroll-native"}):l||d>p?this.classifyHorizontal(n,c):p>d?(o&&(this.activeGestureType="vertical-artifact"),this.lastWheelGestureAt=n,{type:"scroll-native"}):o?(this.activeGestureType="vertical-artifact",this.lastWheelGestureAt=n,{type:"scroll-native"}):this.classifyHorizontal(n,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)+MD;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 UD=2,Bd=1e3,ji=1e-4;function Gd(t,e,n){if(t===0)return 0;const r=e.toPixels(xe({y:He})).y??0;return(n-r)/UD}class FD extends Event{constructor(n){super("scroll",{bubbles:!0,composed:!0});v(this,"scrollPosition");this.scrollPosition=n}}class Gm extends Event{constructor(n){super("layout-change",{bubbles:!0,composed:!0});v(this,"layout");this.layout=n}}class ZD extends HTMLElement{constructor(){super();v(this,"_layout",[]);v(this,"_scrollPosition",0);v(this,"layoutGrid",null);v(this,"layoutScroll",new pD(xe({x:0})));v(this,"scrollModelKey","");v(this,"resizeObserver",null);v(this,"renderPending",!1);v(this,"animateNextRender",!0);v(this,"wheelGesture",new ND);v(this,"dragController",new LD);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=Ud(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)||!xC(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=WD(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)/Bd;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=xe({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=xe({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 nD({basis:Se({x:kn,y:kn}),min:Se({x:td,y:td}),viewport:Se({x:n,y:r}),gap:Se({x:de,y:de})})}syncScrollModel(){const n=this.clientWidth>0?this.clientWidth:tn,r=this.clientHeight>0?this.clientHeight:vr,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=>xe({x:a}))}))}emitScrollPositionChanged(n){this.dispatchEvent(new FD(n))}emitLayoutChanged(){this.dispatchEvent(new Gm([...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(xe({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:Ud(this.dragState.projectedLayout),activePlaceholderId:this.dragState.nodeId,placeholdersById:n}}render(){const n=this.clientWidth>0?this.clientWidth:tn,r=this.clientHeight>0?this.clientHeight:vr,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=>xe({x:L}))}),this._scrollPosition=this.layoutScroll.scroll.x??this._scrollPosition);const p=jD(o),y=s.unit.x??kn,m=s.unit.y??kn,E=a?this.dragTrackOffsetXPx:0,k=(this.layoutScroll.translate.x??0)+E,I=Gd(l.nodes.length,s,r),G=this.animateNextRender&&!a,N=[`transform: translate(${k}px, ${I}px);`,`transition-duration: ${G?mE: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`
|
|
152
|
+
`}render(){this._artifact&&(this.setAttribute("type",this._artifact.type),be(this.template(),this))}}customElements.define("artifact-view",KR);const Se=t=>({type:"px",...t}),xe=t=>({type:"unit",...t}),Zi=2,JR=2;class XR{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??tn,r=this._viewport.y??vr,s=this._gap.x??de,i=this._gap.y??de,o=tn+s*JR,a=n<=o,l=a?n-s*Zi:Math.min(tn,n-s*Zi),c=a?r-i*Zi:Math.min(vr,r-i*Zi),d=(l-s*(St-1))/St,p=(c-i*(He-1))/He,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,p)}:{x:Math.max(E,Math.min(y,d)),y:Math.max(k,Math.min(m,p))})}get unit(){return this._unit}get viewport(){return this._viewport}get gap(){return this._gap}toUnits(e){return xe({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 Vn=1e-4,Nt=1e-6,QR=40,eD=24;function Lm(t,e){return Math.max(0,t-e*2)}function Mm(t){const e=[0];for(const n of t)e.push((e[e.length-1]??0)+n);return e}function Nm(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 Um(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+Vn)break;r=a,s+=1}return Math.max(1,s)}function tD(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+Vn)break;r=a,s+=1}return Math.max(1,s)}function nD(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+Vn)break;n=o,r+=1}return Math.max(1,r)}function Wc(t,e){if(t.length===0)return 0;const n=nD(t,e);return Math.max(0,t.length-n)}function Rd(t,e,n){if(t.length===0)return 0;const r=Um(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 Zl(t,e,n){const r=t[e]??0;return n-r}function gr(t,e,n,r,s){if(t.length===0)return 0;const i=Wc(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,H=e[L+1]??J;if(a>=J&&a<=H+Vn){l=L;break}l=L+1}const c=Math.min(l+1,i),d=e[l]??0,p=e[c]??d,y=Math.max(p-d,Vn),m=c===l?0:(a-d)/y,E=Nm(t),k=Rd(t,l,s),I=Rd(t,c,s),G=(r-k)/2,N=(r-I)/2,j=Zl(E,l,G),F=Zl(E,c,N);return j+(F-j)*m}function Dd(t,e,n,r,s){const i=Wc(t,r),o=e[i]??0;let a=0,l=o;for(let c=0;c<QR;c+=1){const d=(a+l)/2;gr(t,e,d,n,r)>s?a=d:l=d}return(a+l)/2}function Od(t,e,n){const r=Nm(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 Zl(r,s,l)}function rD(t,e,n){const r=Um(t,e,n);return[e,Math.min(t.length-1,e+r-1)]}function sD(t,e,n){const r=tD(t,e,n);return[Math.max(0,e-r+1),e]}function iD(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)<=Nt||(e.add(s),n.push(r))}return n}function oD(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=Lm(r,s),o=Mm(e),a=Wc(n,i),l=o[a]??0,c=[];for(let d=0;d<=a;d+=1){const p=rD(n,d,i),y=Od(n,p,r),m=Dd(n,o,r,i,y);c.push({nodeRange:p,anchor:Math.max(0,Math.min(l,m))})}for(let d=n.length-1;d>=0;d-=1){const p=sD(n,d,i),y=`${p[0]}:${p[1]}`;if(c.some(k=>`${k.nodeRange[0]}:${k.nodeRange[1]}`===y))continue;const m=Od(n,p,r),E=Dd(n,o,r,i,m);c.push({nodeRange:p,anchor:Math.max(0,Math.min(l,E))})}return c.sort((d,p)=>Math.abs(d.anchor-p.anchor)>Nt?d.anchor-p.anchor:d.nodeRange[0]!==p.nodeRange[0]?d.nodeRange[0]-p.nodeRange[0]:d.nodeRange[1]-p.nodeRange[1]),{viewspans:iD(c),minScroll:0,maxScroll:l}}function aD(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+Nt<r){r=o,n=i;continue}Math.abs(o-r)<=Nt&&i<n&&(n=i)}return n}function lD(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 cD 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 xe({x:this._scroll})}get translate(){return Se({x:gr(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)<=Nt||(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(xe({x:c})).x??0),i=n.grid.viewport.x??0,o=n.grid.gap.x??de,a=oD({nodeCols:r,nodeWidthsPx:s,viewportWidthPx:i,gapPx:o});this.nodeWidthsPx=s,this.boundaryCols=Mm(r),this.viewportWidthPx=i,this.framedViewportWidthPx=Lm(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)>Nt&&(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??aD(this.viewspans,this._scroll),s=lD(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)<=Nt)&&(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)<=Nt)&&(this._scroll=r,this.dispatchEvent(new ss("layout-scroll",{scroll:this.scroll})))}wheelPixels(n){const r=n.x??0;if(Math.abs(r)<=Vn)return;this.activeViewspanIndex=null;const s=gr(this.nodeWidthsPx,this.boundaryCols,this._scroll,this.viewportWidthPx,this.framedViewportWidthPx),i=s-r,o=gr(this.nodeWidthsPx,this.boundaryCols,this.maxScroll,this.viewportWidthPx,this.framedViewportWidthPx),a=gr(this.nodeWidthsPx,this.boundaryCols,this.minScroll,this.viewportWidthPx,this.framedViewportWidthPx),l=Math.max(o,Math.min(a,i));if(Math.abs(l-s)<=Vn)return;let c=this.minScroll,d=this.maxScroll;for(let y=0;y<eD;y+=1){const m=(c+d)/2;gr(this.nodeWidthsPx,this.boundaryCols,m,this.viewportWidthPx,this.framedViewportWidthPx)>l?c=m:d=m}const p=os((c+d)/2,this.minScroll,this.maxScroll);Math.abs(p-this._scroll)<=Nt||(this._scroll=p,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}},uD=["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 Bc(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 jl(t){return t.height===He||t.height===sn?{...t,height:sn}:t}function Wl(t){return t.height===sn?{...t,height:He}:t}function hD(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"?Wl(d):d}else l[s]={...i,children:a};const c=Math.max(0,Math.min(r,l.length));return l.splice(c,0,Wl(o)),l}const dD=et(),pD=et(),fD=50;function gD(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 zd(t){return t.map(vD)}function mD(t){return t.type==="drop-target"?{id:t.id,type:"card",artifactID:t.id,width:t.width,height:t.height}:t}function vD(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(mD)}:t}function Fm(t,e){return t.find(r=>r.type==="card"&&r.id===e)??null}function Ld(t,e){return t.find(r=>r.type==="stack"&&r.id===e)??null}function yD(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 bD(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=Fm(r,e.nodeId);if(!a)return null;const l=jl(a),c=jl(o),d=yi(l),p=n.position==="above"?[d,c]:[c,d];return s[i]={id:o.id,type:"stack",children:p},s}function qa(t,e){return t.parentStackId?_D(t,e):wD(t,e)}function wD(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=yD(t,e);return r?bD(r,t,n,e)??[...e]:[...e]}return[...e]}function _D(t,e){const n=t.hitTarget;switch(n.type){case"stack-child-reorder":return SD(t,e,n.position);case"stack-child-extract":return kD(t,e,n.toIndex);case"stack-child-noop":return ED(t,e);default:return[...e]}}function SD(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],p=[...e];return p[r]={...s,children:d},p}function kD(t,e,n){if(!t.parentStackId)return[...e];const r=hD(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 ED(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 $D(t,e){return e.find(r=>r.type==="stack"&&r.id===t.id)?t.id:xc()}function AD(t,e,n){if(t.type==="drop-target"){const r=Bc(e,n);if(!r)throw new Error(`finalize: missing dragged card ${n}`);return jl(r)}return t}function xD(t,e,n){const r=t.children.map(i=>AD(i,e,n));return{id:$D(t,e),type:"stack",children:r}}function TD(t,e,n){if(t.type==="drop-target"){const r=Bc(e,n);if(!r)throw new Error(`finalize: missing dragged card ${n}`);return Fm(e,n)!==null?r:Wl(r)}return t.type==="card"||t.type==="row"?t:xD(t,e,n)}function CD(t,e,n){return t.map(r=>TD(r,e,n))}function ID(t,e){return JSON.stringify(t)===JSON.stringify(e)}const PD=Hr(kt);class RD extends PD{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)>=pE&&(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=qa(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&&gD(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=qa(this.active,n),i=CD(s,n,this.active.nodeId);ID(i,n)||(r=i)}catch{r=null}this.reset(),r&&this.dispatchEvent(new pD("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=qa(this.active,this.active.baseLayout);this.dispatchEvent(new dD("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=Ld(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=Ld(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)<=fD;for(const I of o){const G=I.rect;if(!bn(n,r,G))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)),p=this.resolveTopLevelTargetForCard(d,r,c,c.logicalIndex,l);if(p)return p;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 p of o){if(!bn(n,r,p.rect))continue;const y=Ha(p.rect,Va["reorder-before"]);if(bn(n,r,y))return p.logicalIndex;const m=Ha(p.rect,Va["reorder-after"]);if(bn(n,r,m))return p.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 uD){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 Md=60,DD=80,Nd=.5,Ud=10;class OD{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>=Md&&(this.activeGestureType="none");const l=r&&i!==0,c=l?i:s,d=Math.abs(c),p=Math.abs(i);return this.activeGestureType==="vertical-artifact"&&o?d>=Nd&&d>=p*Ud?this.classifyHorizontal(n,c):(this.lastWheelGestureAt=n,{type:"scroll-native"}):this.activeGestureType==="horizontal-filmstrip"?!l&&o&&p>0&&p>=d*Ud?(this.activeGestureType="vertical-artifact",this.lastWheelGestureAt=n,{type:"scroll-native"}):this.classifyHorizontal(n,c):d<Nd?(o&&(this.activeGestureType="vertical-artifact"),this.lastWheelGestureAt=n,{type:"scroll-native"}):l||d>p?this.classifyHorizontal(n,c):p>d?(o&&(this.activeGestureType="vertical-artifact"),this.lastWheelGestureAt=n,{type:"scroll-native"}):o?(this.activeGestureType="vertical-artifact",this.lastWheelGestureAt=n,{type:"scroll-native"}):this.classifyHorizontal(n,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)+DD;return this.awaitingFreshWheelGesture&&r<Md&&!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 zD=2,Fd=1e3,ji=1e-4;function Zd(t,e,n){if(t===0)return 0;const r=e.toPixels(xe({y:He})).y??0;return(n-r)/zD}class LD extends Event{constructor(n){super("scroll",{bubbles:!0,composed:!0});v(this,"scrollPosition");this.scrollPosition=n}}class Zm extends Event{constructor(n){super("layout-change",{bubbles:!0,composed:!0});v(this,"layout");this.layout=n}}class MD extends HTMLElement{constructor(){super();v(this,"_layout",[]);v(this,"_scrollPosition",0);v(this,"layoutGrid",null);v(this,"layoutScroll",new cD(xe({x:0})));v(this,"scrollModelKey","");v(this,"resizeObserver",null);v(this,"renderPending",!1);v(this,"animateNextRender",!0);v(this,"wheelGesture",new OD);v(this,"dragController",new RD);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=zd(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)||!kC(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=UD(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)/Fd;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=xe({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=xe({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 XR({basis:Se({x:kn,y:kn}),min:Se({x:Jh,y:Jh}),viewport:Se({x:n,y:r}),gap:Se({x:de,y:de})})}syncScrollModel(){const n=this.clientWidth>0?this.clientWidth:tn,r=this.clientHeight>0?this.clientHeight:vr,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=>xe({x:a}))}))}emitScrollPositionChanged(n){this.dispatchEvent(new LD(n))}emitLayoutChanged(){this.dispatchEvent(new Zm([...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(xe({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:zd(this.dragState.projectedLayout),activePlaceholderId:this.dragState.nodeId,placeholdersById:n}}render(){const n=this.clientWidth>0?this.clientWidth:tn,r=this.clientHeight>0?this.clientHeight:vr,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=>xe({x:L}))}),this._scrollPosition=this.layoutScroll.scroll.x??this._scrollPosition);const p=ND(o),y=s.unit.x??kn,m=s.unit.y??kn,E=a?this.dragTrackOffsetXPx:0,k=(this.layoutScroll.translate.x??0)+E,I=Zd(l.nodes.length,s,r),G=this.animateNextRender&&!a,N=[`transform: translate(${k}px, ${I}px);`,`transition-duration: ${G?dE: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`
|
|
153
153
|
<div class="track" style=${N}>
|
|
154
154
|
${l.nodes.map((L,J)=>M`
|
|
155
155
|
<div
|
|
@@ -192,7 +192,7 @@ ${r.documentElement.outerHTML}`],{type:"text/html"});return URL.createObjectURL(
|
|
|
192
192
|
${this.renderDraggedPreview(j.nodeId)}
|
|
193
193
|
</div>
|
|
194
194
|
`})():null}
|
|
195
|
-
`,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*
|
|
195
|
+
`,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*Fd,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=fE*a;if(n<i){const d=Math.max(0,Math.min(1,(i-n)/Li));return-(l*d**Xh)*s}if(n>o){const d=Math.max(0,Math.min(1,(n-o)/Li));return l*d**Xh*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(xe({y:He})).y??vr,c=this.clientHeight>0?this.clientHeight:vr,d=(this.layoutScroll.translate.x??0)+s,p=Zd(o.nodes.length,i,c),y=[];let m=d;for(const E of n){const k=a.get(E.id)??St,I=i.toPixels(xe({x:k})).x??tn,G={left:m,top:p,width:I,height:l};y.push({id:E.id,rect:G}),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(xe({x:a.width})).x??i.width,height:s.toPixels(xe({y:a.height})).y??i.height};return i}renderDraggedPreview(n){const r=Bc(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?Wd(n,l,this.layoutGrid):Bd(n,l,this.layoutGrid),d=i?Wd(r,l,this.layoutGrid):Bd(r,l,this.layoutGrid);return c===null||d===null?a:a+(c-d)}getStableAnchorCardId(n,r,s){const i=jd(n),o=new Set(jd(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 ND(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 UD(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 jd(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 Wd(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(xe({x:a})).x??tn;i+=l+de}return null}function Bd(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(xe({x:a})).x??tn;i+=l+de}return null}customElements.get("layout-view")||customElements.define("layout-view",MD);class FD extends HTMLElement{constructor(){super(...arguments);v(this,"screenManager",Ve.resolve("ScreenManager"));v(this,"boundModel",null);v(this,"handleActiveScreenChanged",()=>{this.rebindModel(),this.render()});v(this,"handleModelChange",()=>{this.render()});v(this,"handleCloseArtifact",n=>{n instanceof zm&&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 Zm&&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`
|
|
196
196
|
<layout-view
|
|
197
197
|
.layout=${r}
|
|
198
198
|
.renderContent=${(o,a)=>{const l=s.get(o.artifactID);return!l||!n?M``:M`<artifact-view
|
|
@@ -207,12 +207,12 @@ ${r.documentElement.outerHTML}`],{type:"text/html"});return URL.createObjectURL(
|
|
|
207
207
|
@layout-change=${this.handleLayoutChanged}
|
|
208
208
|
@close-artifact=${this.handleCloseArtifact}
|
|
209
209
|
></layout-view>
|
|
210
|
-
`,this)}}customElements.define("screen-view",BD);const Ya=new WeakMap,Yd=Object.prototype.hasOwnProperty,GD=(()=>{const t=new Set;let e=HTMLElement.prototype;for(;e;){for(const n of Object.getOwnPropertyNames(e))t.add(n);if(e===Node.prototype)break;e=Object.getPrototypeOf(e)}return t})();function VD(t,e){if(t===Boolean)return e!==null;if(e!==null)return t===Number?Number(e):e}var ni,Bl,Fn,Ye,wt,Ir,Zn,Pr,Ce,ws,Vm,Hm,qm,so;const An=class An extends HTMLElement{constructor(){var s;super();$(this,Ce);$(this,Fn,new Map);$(this,Ye,new Map);$(this,wt,new Map);$(this,Ir,!1);$(this,Zn,!1);$(this,Pr,!1);const n=b(s=An,ni,Bl).call(s,this.constructor),r=this;for(const i of n.properties)Yd.call(r,i)&&(u(this,wt).set(i,r[i]),delete r[i])}static get observedAttributes(){var n;return b(n=An,ni,Bl).call(n,this).observedAttributes}connected(){}disconnected(){}changed(n){}connectedCallback(){if(b(this,Ce,qm).call(this),!u(this,Zn))for(const n of b(this,Ce,ws).call(this).properties)u(this,Ye).has(n)||u(this,Ye).set(n,void 0);this.dispatchEvent(new Event("reactive:connect")),this.connected(),b(this,Ce,so).call(this)}disconnectedCallback(){this.dispatchEvent(new Event("reactive:disconnect")),this.disconnected()}attributeChangedCallback(n,r,s){if(r===s)return;const i=b(this,Ce,ws).call(this).byAttr.get(n);i&&(u(this,wt).has(i.property)||(this[i.property]=VD(i.type,s)))}};ni=new WeakSet,Bl=function(n){const r=Ya.get(n);if(r)return r;const s=[...n.properties??[]],i=n.attributes??{},o=new Map,a=new Map;for(const c of s)if(GD.has(c))throw new Error(`Reactive property "${c}" collides with a built-in DOM property. Rename it to avoid shadowing the platform API.`);for(const[c,d]of Object.entries(i)){if(c.includes("-")&&d.property===void 0)throw new Error(`Attribute "${c}" must declare a "property" name because kebab-case cannot be a property.`);const p=d.property??c;if(!s.includes(p))throw new Error(`Attribute '${c}' references property '${p}', which isn't declared in \`static properties\`. Add it to \`properties\` to make it reactive.`);const y={attribute:c,property:p,type:d.type};o.set(c,y),a.set(p,y)}for(const c of s){const d=Object.getOwnPropertyDescriptor(n.prototype,c);if((d==null?void 0:d.get)!==void 0||(d==null?void 0:d.set)!==void 0)throw new Error(`Observed property "${c}" cannot define a custom getter/setter. Use changed() for side effects instead.`);d===void 0&&Object.defineProperty(n.prototype,c,{configurable:!0,enumerable:!0,get(){return u(this,Fn).get(c)},set(p){b(this,Ce,Vm).call(this,c,p)}})}const l={properties:s,observedAttributes:Object.keys(i),byAttr:o,byProp:a};return Ya.set(n,l),l},Fn=new WeakMap,Ye=new WeakMap,wt=new WeakMap,Ir=new WeakMap,Zn=new WeakMap,Pr=new WeakMap,Ce=new WeakSet,ws=function(){return Ya.get(this.constructor)},Vm=function(n,r){if(!u(this,Pr)&&u(this,wt).has(n))return;const s=u(this,Fn).get(n);Object.is(s,r)||(u(this,Ye).has(n)||u(this,Ye).set(n,s),u(this,Fn).set(n,r),u(this,wt).delete(n),b(this,Ce,Hm).call(this,n,r),this.isConnected&&b(this,Ce,so).call(this))},Hm=function(n,r){const s=b(this,Ce,ws).call(this).byProp.get(n);if(!s)return;const{attribute:i,type:o}=s;if(o===Boolean){const l=this.hasAttribute(i);r&&!l?this.setAttribute(i,""):!r&&l&&this.removeAttribute(i);return}if(r==null){this.hasAttribute(i)&&this.removeAttribute(i);return}const a=String(r);this.getAttribute(i)!==a&&this.setAttribute(i,a)},qm=function(){const n=this,r=b(this,Ce,ws).call(this);for(const s of r.properties){if(!Yd.call(n,s))continue;const i=n[s];delete n[s],!(u(this,wt).has(s)||u(this,Fn).has(s))&&(n[s]=i)}x(this,Pr,!0);try{for(const[s,i]of u(this,wt))n[s]=i;u(this,wt).clear()}finally{x(this,Pr,!1)}},so=function(){u(this,Ir)||!this.isConnected||u(this,Zn)&&u(this,Ye).size===0||(x(this,Ir,!0),queueMicrotask(()=>{if(x(this,Ir,!1),!this.isConnected||u(this,Zn)&&u(this,Ye).size===0)return;const n=new Map(u(this,Ye));u(this,Ye).clear(),x(this,Zn,!0);try{this.changed(n)}catch(r){console.error(r)}this.isConnected&&u(this,Ye).size>0&&b(this,Ce,so).call(this)}))},$(An,ni),v(An,"properties"),v(An,"attributes");let Rs=An;function HD(t,e){let n=null;const r=()=>e((n==null?void 0:n.messages)??[]),s=()=>{const o=t.getActiveClient();o!==n&&(n==null||n.removeEventListener("change",r),n=o,n&&(n.addEventListener("change",r),n.connect().catch(a=>{console.error("ACPClient.connect() failed",a)})),r())};t.addEventListener("change",s),s();const i=()=>{t.removeEventListener("change",s),n==null||n.removeEventListener("change",r),n=null};return{dispose:i,[Symbol.dispose](){i()}}}/*! @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:Ym,setPrototypeOf:Kd,isFrozen:qD,getPrototypeOf:YD,getOwnPropertyDescriptor:KD}=Object;let{freeze:ze,seal:Xe,create:io}=Object,{apply:Gl,construct:Vl}=typeof Reflect<"u"&&Reflect;ze||(ze=function(e){return e});Xe||(Xe=function(e){return e});Gl||(Gl=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)});Vl||(Vl=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 Wi=Le(Array.prototype.forEach),JD=Le(Array.prototype.lastIndexOf),Jd=Le(Array.prototype.pop),as=Le(Array.prototype.push),XD=Le(Array.prototype.splice),oo=Le(String.prototype.toLowerCase),Ka=Le(String.prototype.toString),Ja=Le(String.prototype.match),ls=Le(String.prototype.replace),QD=Le(String.prototype.indexOf),eO=Le(String.prototype.trim),Ge=Le(Object.prototype.hasOwnProperty),Pe=Le(RegExp.prototype.test),cs=tO(TypeError);function Le(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 Gl(t,e,r)}}function tO(t){return function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return Vl(t,n)}}function W(t,e){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:oo;Kd&&Kd(t,null);let r=e.length;for(;r--;){let s=e[r];if(typeof s=="string"){const i=n(s);i!==s&&(qD(e)||(e[r]=i),s=i)}t[s]=!0}return t}function nO(t){for(let e=0;e<t.length;e++)Ge(t,e)||(t[e]=null);return t}function ft(t){const e=io(null);for(const[n,r]of Ym(t))Ge(t,n)&&(Array.isArray(r)?e[n]=nO(r):r&&typeof r=="object"&&r.constructor===Object?e[n]=ft(r):e[n]=r);return e}function us(t,e){for(;t!==null;){const r=KD(t,e);if(r){if(r.get)return Le(r.get);if(typeof r.value=="function")return Le(r.value)}t=YD(t)}function n(){return null}return n}const Xd=ze(["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"]),Xa=ze(["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"]),Qa=ze(["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"]),rO=ze(["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"]),el=ze(["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"]),sO=ze(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Qd=ze(["#text"]),ep=ze(["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"]),tl=ze(["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"]),tp=ze(["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"]),Bi=ze(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),iO=Xe(/\{\{[\w\W]*|[\w\W]*\}\}/gm),oO=Xe(/<%[\w\W]*|[\w\W]*%>/gm),aO=Xe(/\$\{[\w\W]*/gm),lO=Xe(/^data-[\-\w.\u00B7-\uFFFF]+$/),cO=Xe(/^aria-[\-\w]+$/),Km=Xe(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),uO=Xe(/^(?:\w+script|data):/i),hO=Xe(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Jm=Xe(/^html$/i),dO=Xe(/^[a-z][.\w]*(-[.\w]+)+$/i);var np=Object.freeze({__proto__:null,ARIA_ATTR:cO,ATTR_WHITESPACE:hO,CUSTOM_ELEMENT:dO,DATA_ATTR:lO,DOCTYPE_NAME:Jm,ERB_EXPR:oO,IS_ALLOWED_URI:Km,IS_SCRIPT_OR_DATA:uO,MUSTACHE_EXPR:iO,TMPLIT_EXPR:aO});const hs={element:1,text:3,progressingInstruction:7,comment:8,document:9},pO=function(){return typeof window>"u"?null:window},fO=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}},rp=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Xm(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:pO();const e=z=>Xm(z);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:p,DOMParser:y,trustedTypes:m}=t,E=l.prototype,k=us(E,"cloneNode"),I=us(E,"remove"),G=us(E,"nextSibling"),N=us(E,"childNodes"),j=us(E,"parentNode");if(typeof o=="function"){const z=n.createElement("template");z.content&&z.content.ownerDocument&&(n=z.content.ownerDocument)}let F,L="";const{implementation:J,createNodeIterator:H,createDocumentFragment:he,getElementsByTagName:lt}=n,{importNode:wi}=r;let Ee=rp();e.isSupported=typeof Ym=="function"&&typeof j=="function"&&J&&J.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:gn,ERB_EXPR:ct,TMPLIT_EXPR:Wt,DATA_ATTR:ea,ARIA_ATTR:_i,IS_SCRIPT_OR_DATA:wv,ATTR_WHITESPACE:nu,CUSTOM_ELEMENT:_v}=np;let{IS_ALLOWED_URI:ru}=np,we=null;const su=W({},[...Xd,...Xa,...Qa,...el,...Qd]);let $e=null;const iu=W({},[...ep,...tl,...tp,...Bi]);let pe=Object.seal(io(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 Bt=Object.seal(io(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let ou=!0,ta=!0,au=!1,lu=!0,Qn=!1,ki=!0,mn=!1,na=!1,ra=!1,er=!1,Ei=!1,$i=!1,cu=!0,uu=!1;const Sv="user-content-";let sa=!0,Qr=!1,tr={},ut=null;const ia=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 hu=null;const du=W({},["audio","video","img","source","image","track"]);let oa=null;const pu=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 nr=Et,aa=!1,la=null;const kv=W({},[Ai,xi,Et],Ka);let Ti=W({},["mi","mo","mn","ms","mtext"]),Ci=W({},["annotation-xml"]);const Ev=W({},["title","style","font","a","script"]);let es=null;const $v=["application/xhtml+xml","text/html"],Av="text/html";let ve=null,rr=null;const xv=n.createElement("form"),fu=function(g){return g instanceof RegExp||g instanceof Function},ca=function(){let g=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(rr&&rr===g)){if((!g||typeof g!="object")&&(g={}),g=ft(g),es=$v.indexOf(g.PARSER_MEDIA_TYPE)===-1?Av:g.PARSER_MEDIA_TYPE,ve=es==="application/xhtml+xml"?Ka:oo,we=Ge(g,"ALLOWED_TAGS")?W({},g.ALLOWED_TAGS,ve):su,$e=Ge(g,"ALLOWED_ATTR")?W({},g.ALLOWED_ATTR,ve):iu,la=Ge(g,"ALLOWED_NAMESPACES")?W({},g.ALLOWED_NAMESPACES,Ka):kv,oa=Ge(g,"ADD_URI_SAFE_ATTR")?W(ft(pu),g.ADD_URI_SAFE_ATTR,ve):pu,hu=Ge(g,"ADD_DATA_URI_TAGS")?W(ft(du),g.ADD_DATA_URI_TAGS,ve):du,ut=Ge(g,"FORBID_CONTENTS")?W({},g.FORBID_CONTENTS,ve):ia,Xr=Ge(g,"FORBID_TAGS")?W({},g.FORBID_TAGS,ve):ft({}),Si=Ge(g,"FORBID_ATTR")?W({},g.FORBID_ATTR,ve):ft({}),tr=Ge(g,"USE_PROFILES")?g.USE_PROFILES:!1,ou=g.ALLOW_ARIA_ATTR!==!1,ta=g.ALLOW_DATA_ATTR!==!1,au=g.ALLOW_UNKNOWN_PROTOCOLS||!1,lu=g.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Qn=g.SAFE_FOR_TEMPLATES||!1,ki=g.SAFE_FOR_XML!==!1,mn=g.WHOLE_DOCUMENT||!1,er=g.RETURN_DOM||!1,Ei=g.RETURN_DOM_FRAGMENT||!1,$i=g.RETURN_TRUSTED_TYPE||!1,ra=g.FORCE_BODY||!1,cu=g.SANITIZE_DOM!==!1,uu=g.SANITIZE_NAMED_PROPS||!1,sa=g.KEEP_CONTENT!==!1,Qr=g.IN_PLACE||!1,ru=g.ALLOWED_URI_REGEXP||Km,nr=g.NAMESPACE||Et,Ti=g.MATHML_TEXT_INTEGRATION_POINTS||Ti,Ci=g.HTML_INTEGRATION_POINTS||Ci,pe=g.CUSTOM_ELEMENT_HANDLING||{},g.CUSTOM_ELEMENT_HANDLING&&fu(g.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(pe.tagNameCheck=g.CUSTOM_ELEMENT_HANDLING.tagNameCheck),g.CUSTOM_ELEMENT_HANDLING&&fu(g.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(pe.attributeNameCheck=g.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),g.CUSTOM_ELEMENT_HANDLING&&typeof g.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(pe.allowCustomizedBuiltInElements=g.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Qn&&(ta=!1),Ei&&(er=!0),tr&&(we=W({},Qd),$e=io(null),tr.html===!0&&(W(we,Xd),W($e,ep)),tr.svg===!0&&(W(we,Xa),W($e,tl),W($e,Bi)),tr.svgFilters===!0&&(W(we,Qa),W($e,tl),W($e,Bi)),tr.mathMl===!0&&(W(we,el),W($e,tp),W($e,Bi))),Ge(g,"ADD_TAGS")||(Bt.tagCheck=null),Ge(g,"ADD_ATTR")||(Bt.attributeCheck=null),g.ADD_TAGS&&(typeof g.ADD_TAGS=="function"?Bt.tagCheck=g.ADD_TAGS:(we===su&&(we=ft(we)),W(we,g.ADD_TAGS,ve))),g.ADD_ATTR&&(typeof g.ADD_ATTR=="function"?Bt.attributeCheck=g.ADD_ATTR:($e===iu&&($e=ft($e)),W($e,g.ADD_ATTR,ve))),g.ADD_URI_SAFE_ATTR&&W(oa,g.ADD_URI_SAFE_ATTR,ve),g.FORBID_CONTENTS&&(ut===ia&&(ut=ft(ut)),W(ut,g.FORBID_CONTENTS,ve)),g.ADD_FORBID_CONTENTS&&(ut===ia&&(ut=ft(ut)),W(ut,g.ADD_FORBID_CONTENTS,ve)),sa&&(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=fO(m,s)),F!==null&&typeof L=="string"&&(L=F.createHTML(""));ze&&ze(g),rr=g}},gu=W({},[...Xa,...Qa,...rO]),mu=W({},[...el,...sO]),Tv=function(g){let T=j(g);(!T||!T.tagName)&&(T={namespaceURI:nr,tagName:"template"});const P=oo(g.tagName),se=oo(T.tagName);return la[g.namespaceURI]?g.namespaceURI===xi?T.namespaceURI===Et?P==="svg":T.namespaceURI===Ai?P==="svg"&&(se==="annotation-xml"||Ti[se]):!!gu[P]:g.namespaceURI===Ai?T.namespaceURI===Et?P==="math":T.namespaceURI===xi?P==="math"&&Ci[se]:!!mu[P]:g.namespaceURI===Et?T.namespaceURI===xi&&!Ci[se]||T.namespaceURI===Ai&&!Ti[se]?!1:!mu[P]&&(Ev[P]||!gu[P]):!!(es==="application/xhtml+xml"&&la[g.namespaceURI]):!1},ht=function(g){as(e.removed,{element:g});try{j(g).removeChild(g)}catch{I(g)}},vn=function(g,T){try{as(e.removed,{attribute:T.getAttributeNode(g),from:T})}catch{as(e.removed,{attribute:null,from:T})}if(T.removeAttribute(g),g==="is")if(er||Ei)try{ht(T)}catch{}else try{T.setAttribute(g,"")}catch{}},vu=function(g){let T=null,P=null;if(ra)g="<remove></remove>"+g;else{const fe=Ja(g,/^[\r\n\t ]+/);P=fe&&fe[0]}es==="application/xhtml+xml"&&nr===Et&&(g='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+g+"</body></html>");const se=F?F.createHTML(g):g;if(nr===Et)try{T=new y().parseFromString(se,es)}catch{}if(!T||!T.documentElement){T=J.createDocument(nr,"template",null);try{T.documentElement.innerHTML=aa?L:se}catch{}}const Ie=T.body||T.documentElement;return g&&P&&Ie.insertBefore(n.createTextNode(P),Ie.childNodes[0]||null),nr===Et?lt.call(T,mn?"html":"body")[0]:mn?T.documentElement:Ie},yu=function(g){return H.call(g.ownerDocument||g,g,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},ua=function(g){return g instanceof p&&(typeof g.nodeName!="string"||typeof g.textContent!="string"||typeof g.removeChild!="function"||!(g.attributes instanceof d)||typeof g.removeAttribute!="function"||typeof g.setAttribute!="function"||typeof g.namespaceURI!="string"||typeof g.insertBefore!="function"||typeof g.hasChildNodes!="function")},bu=function(g){return typeof a=="function"&&g instanceof a};function $t(z,g,T){Wi(z,P=>{P.call(e,g,T,rr)})}const wu=function(g){let T=null;if($t(Ee.beforeSanitizeElements,g,null),ua(g))return ht(g),!0;const P=ve(g.nodeName);if($t(Ee.uponSanitizeElement,g,{tagName:P,allowedTags:we}),ki&&g.hasChildNodes()&&!bu(g.firstElementChild)&&Pe(/<[/\w!]/g,g.innerHTML)&&Pe(/<[/\w!]/g,g.textContent)||g.nodeType===hs.progressingInstruction||ki&&g.nodeType===hs.comment&&Pe(/<[/\w]/g,g.data))return ht(g),!0;if(!(Bt.tagCheck instanceof Function&&Bt.tagCheck(P))&&(!we[P]||Xr[P])){if(!Xr[P]&&Su(P)&&(pe.tagNameCheck instanceof RegExp&&Pe(pe.tagNameCheck,P)||pe.tagNameCheck instanceof Function&&pe.tagNameCheck(P)))return!1;if(sa&&!ut[P]){const se=j(g)||g.parentNode,Ie=N(g)||g.childNodes;if(Ie&&se){const fe=Ie.length;for(let Me=fe-1;Me>=0;--Me){const At=k(Ie[Me],!0);At.__removalCount=(g.__removalCount||0)+1,se.insertBefore(At,G(g))}}}return ht(g),!0}return g instanceof l&&!Tv(g)||(P==="noscript"||P==="noembed"||P==="noframes")&&Pe(/<\/no(script|embed|frames)/i,g.innerHTML)?(ht(g),!0):(Qn&&g.nodeType===hs.text&&(T=g.textContent,Wi([gn,ct,Wt],se=>{T=ls(T,se," ")}),g.textContent!==T&&(as(e.removed,{element:g.cloneNode()}),g.textContent=T)),$t(Ee.afterSanitizeElements,g,null),!1)},_u=function(g,T,P){if(Si[T]||cu&&(T==="id"||T==="name")&&(P in n||P in xv))return!1;if(!(ta&&!Si[T]&&Pe(ea,T))){if(!(ou&&Pe(_i,T))){if(!(Bt.attributeCheck instanceof Function&&Bt.attributeCheck(T,g))){if(!$e[T]||Si[T]){if(!(Su(g)&&(pe.tagNameCheck instanceof RegExp&&Pe(pe.tagNameCheck,g)||pe.tagNameCheck instanceof Function&&pe.tagNameCheck(g))&&(pe.attributeNameCheck instanceof RegExp&&Pe(pe.attributeNameCheck,T)||pe.attributeNameCheck instanceof Function&&pe.attributeNameCheck(T,g))||T==="is"&&pe.allowCustomizedBuiltInElements&&(pe.tagNameCheck instanceof RegExp&&Pe(pe.tagNameCheck,P)||pe.tagNameCheck instanceof Function&&pe.tagNameCheck(P))))return!1}else if(!oa[T]){if(!Pe(ru,ls(P,nu,""))){if(!((T==="src"||T==="xlink:href"||T==="href")&&g!=="script"&&QD(P,"data:")===0&&hu[g])){if(!(au&&!Pe(wv,ls(P,nu,"")))){if(P)return!1}}}}}}}return!0},Su=function(g){return g!=="annotation-xml"&&Ja(g,_v)},ku=function(g){$t(Ee.beforeSanitizeAttributes,g,null);const{attributes:T}=g;if(!T||ua(g))return;const P={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:$e,forceKeepAttr:void 0};let se=T.length;for(;se--;){const Ie=T[se],{name:fe,namespaceURI:Me,value:At}=Ie,sr=ve(fe),ha=At;let Ae=fe==="value"?ha:eO(ha);if(P.attrName=sr,P.attrValue=Ae,P.keepAttr=!0,P.forceKeepAttr=void 0,$t(Ee.uponSanitizeAttribute,g,P),Ae=P.attrValue,uu&&(sr==="id"||sr==="name")&&(vn(fe,g),Ae=Sv+Ae),ki&&Pe(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,Ae)){vn(fe,g);continue}if(sr==="attributename"&&Ja(Ae,"href")){vn(fe,g);continue}if(P.forceKeepAttr)continue;if(!P.keepAttr){vn(fe,g);continue}if(!lu&&Pe(/\/>/i,Ae)){vn(fe,g);continue}Qn&&Wi([gn,ct,Wt],$u=>{Ae=ls(Ae,$u," ")});const Eu=ve(g.nodeName);if(!_u(Eu,sr,Ae)){vn(fe,g);continue}if(F&&typeof m=="object"&&typeof m.getAttributeType=="function"&&!Me)switch(m.getAttributeType(Eu,sr)){case"TrustedHTML":{Ae=F.createHTML(Ae);break}case"TrustedScriptURL":{Ae=F.createScriptURL(Ae);break}}if(Ae!==ha)try{Me?g.setAttributeNS(Me,fe,Ae):g.setAttribute(fe,Ae),ua(g)?ht(g):Jd(e.removed)}catch{vn(fe,g)}}$t(Ee.afterSanitizeAttributes,g,null)},Cv=function z(g){let T=null;const P=yu(g);for($t(Ee.beforeSanitizeShadowDOM,g,null);T=P.nextNode();)$t(Ee.uponSanitizeShadowNode,T,null),wu(T),ku(T),T.content instanceof i&&z(T.content);$t(Ee.afterSanitizeShadowDOM,g,null)};return e.sanitize=function(z){let g=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},T=null,P=null,se=null,Ie=null;if(aa=!z,aa&&(z="<!-->"),typeof z!="string"&&!bu(z))if(typeof z.toString=="function"){if(z=z.toString(),typeof z!="string")throw cs("dirty is not a string, aborting")}else throw cs("toString is not a function");if(!e.isSupported)return z;if(na||ca(g),e.removed=[],typeof z=="string"&&(Qr=!1),Qr){if(z.nodeName){const At=ve(z.nodeName);if(!we[At]||Xr[At])throw cs("root node is forbidden and cannot be sanitized in-place")}}else if(z instanceof a)T=vu("<!---->"),P=T.ownerDocument.importNode(z,!0),P.nodeType===hs.element&&P.nodeName==="BODY"||P.nodeName==="HTML"?T=P:T.appendChild(P);else{if(!er&&!Qn&&!mn&&z.indexOf("<")===-1)return F&&$i?F.createHTML(z):z;if(T=vu(z),!T)return er?null:$i?L:""}T&&ra&&ht(T.firstChild);const fe=yu(Qr?z:T);for(;se=fe.nextNode();)wu(se),ku(se),se.content instanceof i&&Cv(se.content);if(Qr)return z;if(er){if(Ei)for(Ie=he.call(T.ownerDocument);T.firstChild;)Ie.appendChild(T.firstChild);else Ie=T;return($e.shadowroot||$e.shadowrootmode)&&(Ie=wi.call(r,Ie,!0)),Ie}let Me=mn?T.outerHTML:T.innerHTML;return mn&&we["!doctype"]&&T.ownerDocument&&T.ownerDocument.doctype&&T.ownerDocument.doctype.name&&Pe(Jm,T.ownerDocument.doctype.name)&&(Me="<!DOCTYPE "+T.ownerDocument.doctype.name+`>
|
|
211
|
-
`+Me),Qn&&Wi([gn,ct,Wt],At=>{Me=ls(Me,At," ")}),F&&$i?F.createHTML(Me):Me},e.setConfig=function(){let z=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};ca(z),na=!0},e.clearConfig=function(){rr=null,na=!1},e.isValidAttribute=function(z,g,T){rr||ca({});const P=ve(z),se=ve(g);return _u(P,se,T)},e.addHook=function(z,g){typeof g=="function"&&as(Ee[z],g)},e.removeHook=function(z,g){if(g!==void 0){const T=
|
|
212
|
-
]`).replace("lheading",
|
|
210
|
+
`,this)}}customElements.define("screen-view",FD);const Ya=new WeakMap,Gd=Object.prototype.hasOwnProperty,ZD=(()=>{const t=new Set;let e=HTMLElement.prototype;for(;e;){for(const n of Object.getOwnPropertyNames(e))t.add(n);if(e===Node.prototype)break;e=Object.getPrototypeOf(e)}return t})();function jD(t,e){if(t===Boolean)return e!==null;if(e!==null)return t===Number?Number(e):e}var ni,Bl,Fn,Ye,wt,Ir,Zn,Pr,Ce,ws,jm,Wm,Bm,so;const An=class An extends HTMLElement{constructor(){var s;super();$(this,Ce);$(this,Fn,new Map);$(this,Ye,new Map);$(this,wt,new Map);$(this,Ir,!1);$(this,Zn,!1);$(this,Pr,!1);const n=b(s=An,ni,Bl).call(s,this.constructor),r=this;for(const i of n.properties)Gd.call(r,i)&&(u(this,wt).set(i,r[i]),delete r[i])}static get observedAttributes(){var n;return b(n=An,ni,Bl).call(n,this).observedAttributes}connected(){}disconnected(){}changed(n){}connectedCallback(){if(b(this,Ce,Bm).call(this),!u(this,Zn))for(const n of b(this,Ce,ws).call(this).properties)u(this,Ye).has(n)||u(this,Ye).set(n,void 0);this.dispatchEvent(new Event("reactive:connect")),this.connected(),b(this,Ce,so).call(this)}disconnectedCallback(){this.dispatchEvent(new Event("reactive:disconnect")),this.disconnected()}attributeChangedCallback(n,r,s){if(r===s)return;const i=b(this,Ce,ws).call(this).byAttr.get(n);i&&(u(this,wt).has(i.property)||(this[i.property]=jD(i.type,s)))}};ni=new WeakSet,Bl=function(n){const r=Ya.get(n);if(r)return r;const s=[...n.properties??[]],i=n.attributes??{},o=new Map,a=new Map;for(const c of s)if(ZD.has(c))throw new Error(`Reactive property "${c}" collides with a built-in DOM property. Rename it to avoid shadowing the platform API.`);for(const[c,d]of Object.entries(i)){if(c.includes("-")&&d.property===void 0)throw new Error(`Attribute "${c}" must declare a "property" name because kebab-case cannot be a property.`);const p=d.property??c;if(!s.includes(p))throw new Error(`Attribute '${c}' references property '${p}', which isn't declared in \`static properties\`. Add it to \`properties\` to make it reactive.`);const y={attribute:c,property:p,type:d.type};o.set(c,y),a.set(p,y)}for(const c of s){const d=Object.getOwnPropertyDescriptor(n.prototype,c);if((d==null?void 0:d.get)!==void 0||(d==null?void 0:d.set)!==void 0)throw new Error(`Observed property "${c}" cannot define a custom getter/setter. Use changed() for side effects instead.`);d===void 0&&Object.defineProperty(n.prototype,c,{configurable:!0,enumerable:!0,get(){return u(this,Fn).get(c)},set(p){b(this,Ce,jm).call(this,c,p)}})}const l={properties:s,observedAttributes:Object.keys(i),byAttr:o,byProp:a};return Ya.set(n,l),l},Fn=new WeakMap,Ye=new WeakMap,wt=new WeakMap,Ir=new WeakMap,Zn=new WeakMap,Pr=new WeakMap,Ce=new WeakSet,ws=function(){return Ya.get(this.constructor)},jm=function(n,r){if(!u(this,Pr)&&u(this,wt).has(n))return;const s=u(this,Fn).get(n);Object.is(s,r)||(u(this,Ye).has(n)||u(this,Ye).set(n,s),u(this,Fn).set(n,r),u(this,wt).delete(n),b(this,Ce,Wm).call(this,n,r),this.isConnected&&b(this,Ce,so).call(this))},Wm=function(n,r){const s=b(this,Ce,ws).call(this).byProp.get(n);if(!s)return;const{attribute:i,type:o}=s;if(o===Boolean){const l=this.hasAttribute(i);r&&!l?this.setAttribute(i,""):!r&&l&&this.removeAttribute(i);return}if(r==null){this.hasAttribute(i)&&this.removeAttribute(i);return}const a=String(r);this.getAttribute(i)!==a&&this.setAttribute(i,a)},Bm=function(){const n=this,r=b(this,Ce,ws).call(this);for(const s of r.properties){if(!Gd.call(n,s))continue;const i=n[s];delete n[s],!(u(this,wt).has(s)||u(this,Fn).has(s))&&(n[s]=i)}x(this,Pr,!0);try{for(const[s,i]of u(this,wt))n[s]=i;u(this,wt).clear()}finally{x(this,Pr,!1)}},so=function(){u(this,Ir)||!this.isConnected||u(this,Zn)&&u(this,Ye).size===0||(x(this,Ir,!0),queueMicrotask(()=>{if(x(this,Ir,!1),!this.isConnected||u(this,Zn)&&u(this,Ye).size===0)return;const n=new Map(u(this,Ye));u(this,Ye).clear(),x(this,Zn,!0);try{this.changed(n)}catch(r){console.error(r)}this.isConnected&&u(this,Ye).size>0&&b(this,Ce,so).call(this)}))},$(An,ni),v(An,"properties"),v(An,"attributes");let Rs=An;function WD(t,e){let n=null;const r=()=>e((n==null?void 0:n.messages)??[]),s=()=>{const o=t.getActiveClient();o!==n&&(n==null||n.removeEventListener("change",r),n=o,n&&(n.addEventListener("change",r),n.connect().catch(a=>{console.error("ACPClient.connect() failed",a)})),r())};t.addEventListener("change",s),s();const i=()=>{t.removeEventListener("change",s),n==null||n.removeEventListener("change",r),n=null};return{dispose:i,[Symbol.dispose](){i()}}}/*! @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:Gm,setPrototypeOf:Vd,isFrozen:BD,getPrototypeOf:GD,getOwnPropertyDescriptor:VD}=Object;let{freeze:ze,seal:Xe,create:io}=Object,{apply:Gl,construct:Vl}=typeof Reflect<"u"&&Reflect;ze||(ze=function(e){return e});Xe||(Xe=function(e){return e});Gl||(Gl=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)});Vl||(Vl=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 Wi=Le(Array.prototype.forEach),HD=Le(Array.prototype.lastIndexOf),Hd=Le(Array.prototype.pop),as=Le(Array.prototype.push),qD=Le(Array.prototype.splice),oo=Le(String.prototype.toLowerCase),Ka=Le(String.prototype.toString),Ja=Le(String.prototype.match),ls=Le(String.prototype.replace),YD=Le(String.prototype.indexOf),KD=Le(String.prototype.trim),Ge=Le(Object.prototype.hasOwnProperty),Pe=Le(RegExp.prototype.test),cs=JD(TypeError);function Le(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 Gl(t,e,r)}}function JD(t){return function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return Vl(t,n)}}function W(t,e){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:oo;Vd&&Vd(t,null);let r=e.length;for(;r--;){let s=e[r];if(typeof s=="string"){const i=n(s);i!==s&&(BD(e)||(e[r]=i),s=i)}t[s]=!0}return t}function XD(t){for(let e=0;e<t.length;e++)Ge(t,e)||(t[e]=null);return t}function ft(t){const e=io(null);for(const[n,r]of Gm(t))Ge(t,n)&&(Array.isArray(r)?e[n]=XD(r):r&&typeof r=="object"&&r.constructor===Object?e[n]=ft(r):e[n]=r);return e}function us(t,e){for(;t!==null;){const r=VD(t,e);if(r){if(r.get)return Le(r.get);if(typeof r.value=="function")return Le(r.value)}t=GD(t)}function n(){return null}return n}const qd=ze(["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"]),Xa=ze(["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"]),Qa=ze(["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"]),QD=ze(["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"]),el=ze(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),eO=ze(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Yd=ze(["#text"]),Kd=ze(["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"]),tl=ze(["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"]),Jd=ze(["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"]),Bi=ze(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),tO=Xe(/\{\{[\w\W]*|[\w\W]*\}\}/gm),nO=Xe(/<%[\w\W]*|[\w\W]*%>/gm),rO=Xe(/\$\{[\w\W]*/gm),sO=Xe(/^data-[\-\w.\u00B7-\uFFFF]+$/),iO=Xe(/^aria-[\-\w]+$/),Vm=Xe(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),oO=Xe(/^(?:\w+script|data):/i),aO=Xe(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Hm=Xe(/^html$/i),lO=Xe(/^[a-z][.\w]*(-[.\w]+)+$/i);var Xd=Object.freeze({__proto__:null,ARIA_ATTR:iO,ATTR_WHITESPACE:aO,CUSTOM_ELEMENT:lO,DATA_ATTR:sO,DOCTYPE_NAME:Hm,ERB_EXPR:nO,IS_ALLOWED_URI:Vm,IS_SCRIPT_OR_DATA:oO,MUSTACHE_EXPR:tO,TMPLIT_EXPR:rO});const hs={element:1,text:3,progressingInstruction:7,comment:8,document:9},cO=function(){return typeof window>"u"?null:window},uO=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}},Qd=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function qm(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:cO();const e=z=>qm(z);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:p,DOMParser:y,trustedTypes:m}=t,E=l.prototype,k=us(E,"cloneNode"),I=us(E,"remove"),G=us(E,"nextSibling"),N=us(E,"childNodes"),j=us(E,"parentNode");if(typeof o=="function"){const z=n.createElement("template");z.content&&z.content.ownerDocument&&(n=z.content.ownerDocument)}let F,L="";const{implementation:J,createNodeIterator:H,createDocumentFragment:he,getElementsByTagName:lt}=n,{importNode:wi}=r;let Ee=Qd();e.isSupported=typeof Gm=="function"&&typeof j=="function"&&J&&J.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:gn,ERB_EXPR:ct,TMPLIT_EXPR:Wt,DATA_ATTR:ea,ARIA_ATTR:_i,IS_SCRIPT_OR_DATA:mv,ATTR_WHITESPACE:nu,CUSTOM_ELEMENT:vv}=Xd;let{IS_ALLOWED_URI:ru}=Xd,we=null;const su=W({},[...qd,...Xa,...Qa,...el,...Yd]);let $e=null;const iu=W({},[...Kd,...tl,...Jd,...Bi]);let pe=Object.seal(io(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 Bt=Object.seal(io(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let ou=!0,ta=!0,au=!1,lu=!0,Qn=!1,ki=!0,mn=!1,na=!1,ra=!1,er=!1,Ei=!1,$i=!1,cu=!0,uu=!1;const yv="user-content-";let sa=!0,Qr=!1,tr={},ut=null;const ia=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 hu=null;const du=W({},["audio","video","img","source","image","track"]);let oa=null;const pu=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 nr=Et,aa=!1,la=null;const bv=W({},[Ai,xi,Et],Ka);let Ti=W({},["mi","mo","mn","ms","mtext"]),Ci=W({},["annotation-xml"]);const wv=W({},["title","style","font","a","script"]);let es=null;const _v=["application/xhtml+xml","text/html"],Sv="text/html";let ve=null,rr=null;const kv=n.createElement("form"),fu=function(g){return g instanceof RegExp||g instanceof Function},ca=function(){let g=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(rr&&rr===g)){if((!g||typeof g!="object")&&(g={}),g=ft(g),es=_v.indexOf(g.PARSER_MEDIA_TYPE)===-1?Sv:g.PARSER_MEDIA_TYPE,ve=es==="application/xhtml+xml"?Ka:oo,we=Ge(g,"ALLOWED_TAGS")?W({},g.ALLOWED_TAGS,ve):su,$e=Ge(g,"ALLOWED_ATTR")?W({},g.ALLOWED_ATTR,ve):iu,la=Ge(g,"ALLOWED_NAMESPACES")?W({},g.ALLOWED_NAMESPACES,Ka):bv,oa=Ge(g,"ADD_URI_SAFE_ATTR")?W(ft(pu),g.ADD_URI_SAFE_ATTR,ve):pu,hu=Ge(g,"ADD_DATA_URI_TAGS")?W(ft(du),g.ADD_DATA_URI_TAGS,ve):du,ut=Ge(g,"FORBID_CONTENTS")?W({},g.FORBID_CONTENTS,ve):ia,Xr=Ge(g,"FORBID_TAGS")?W({},g.FORBID_TAGS,ve):ft({}),Si=Ge(g,"FORBID_ATTR")?W({},g.FORBID_ATTR,ve):ft({}),tr=Ge(g,"USE_PROFILES")?g.USE_PROFILES:!1,ou=g.ALLOW_ARIA_ATTR!==!1,ta=g.ALLOW_DATA_ATTR!==!1,au=g.ALLOW_UNKNOWN_PROTOCOLS||!1,lu=g.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Qn=g.SAFE_FOR_TEMPLATES||!1,ki=g.SAFE_FOR_XML!==!1,mn=g.WHOLE_DOCUMENT||!1,er=g.RETURN_DOM||!1,Ei=g.RETURN_DOM_FRAGMENT||!1,$i=g.RETURN_TRUSTED_TYPE||!1,ra=g.FORCE_BODY||!1,cu=g.SANITIZE_DOM!==!1,uu=g.SANITIZE_NAMED_PROPS||!1,sa=g.KEEP_CONTENT!==!1,Qr=g.IN_PLACE||!1,ru=g.ALLOWED_URI_REGEXP||Vm,nr=g.NAMESPACE||Et,Ti=g.MATHML_TEXT_INTEGRATION_POINTS||Ti,Ci=g.HTML_INTEGRATION_POINTS||Ci,pe=g.CUSTOM_ELEMENT_HANDLING||{},g.CUSTOM_ELEMENT_HANDLING&&fu(g.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(pe.tagNameCheck=g.CUSTOM_ELEMENT_HANDLING.tagNameCheck),g.CUSTOM_ELEMENT_HANDLING&&fu(g.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(pe.attributeNameCheck=g.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),g.CUSTOM_ELEMENT_HANDLING&&typeof g.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(pe.allowCustomizedBuiltInElements=g.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Qn&&(ta=!1),Ei&&(er=!0),tr&&(we=W({},Yd),$e=io(null),tr.html===!0&&(W(we,qd),W($e,Kd)),tr.svg===!0&&(W(we,Xa),W($e,tl),W($e,Bi)),tr.svgFilters===!0&&(W(we,Qa),W($e,tl),W($e,Bi)),tr.mathMl===!0&&(W(we,el),W($e,Jd),W($e,Bi))),Ge(g,"ADD_TAGS")||(Bt.tagCheck=null),Ge(g,"ADD_ATTR")||(Bt.attributeCheck=null),g.ADD_TAGS&&(typeof g.ADD_TAGS=="function"?Bt.tagCheck=g.ADD_TAGS:(we===su&&(we=ft(we)),W(we,g.ADD_TAGS,ve))),g.ADD_ATTR&&(typeof g.ADD_ATTR=="function"?Bt.attributeCheck=g.ADD_ATTR:($e===iu&&($e=ft($e)),W($e,g.ADD_ATTR,ve))),g.ADD_URI_SAFE_ATTR&&W(oa,g.ADD_URI_SAFE_ATTR,ve),g.FORBID_CONTENTS&&(ut===ia&&(ut=ft(ut)),W(ut,g.FORBID_CONTENTS,ve)),g.ADD_FORBID_CONTENTS&&(ut===ia&&(ut=ft(ut)),W(ut,g.ADD_FORBID_CONTENTS,ve)),sa&&(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=uO(m,s)),F!==null&&typeof L=="string"&&(L=F.createHTML(""));ze&&ze(g),rr=g}},gu=W({},[...Xa,...Qa,...QD]),mu=W({},[...el,...eO]),Ev=function(g){let T=j(g);(!T||!T.tagName)&&(T={namespaceURI:nr,tagName:"template"});const P=oo(g.tagName),se=oo(T.tagName);return la[g.namespaceURI]?g.namespaceURI===xi?T.namespaceURI===Et?P==="svg":T.namespaceURI===Ai?P==="svg"&&(se==="annotation-xml"||Ti[se]):!!gu[P]:g.namespaceURI===Ai?T.namespaceURI===Et?P==="math":T.namespaceURI===xi?P==="math"&&Ci[se]:!!mu[P]:g.namespaceURI===Et?T.namespaceURI===xi&&!Ci[se]||T.namespaceURI===Ai&&!Ti[se]?!1:!mu[P]&&(wv[P]||!gu[P]):!!(es==="application/xhtml+xml"&&la[g.namespaceURI]):!1},ht=function(g){as(e.removed,{element:g});try{j(g).removeChild(g)}catch{I(g)}},vn=function(g,T){try{as(e.removed,{attribute:T.getAttributeNode(g),from:T})}catch{as(e.removed,{attribute:null,from:T})}if(T.removeAttribute(g),g==="is")if(er||Ei)try{ht(T)}catch{}else try{T.setAttribute(g,"")}catch{}},vu=function(g){let T=null,P=null;if(ra)g="<remove></remove>"+g;else{const fe=Ja(g,/^[\r\n\t ]+/);P=fe&&fe[0]}es==="application/xhtml+xml"&&nr===Et&&(g='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+g+"</body></html>");const se=F?F.createHTML(g):g;if(nr===Et)try{T=new y().parseFromString(se,es)}catch{}if(!T||!T.documentElement){T=J.createDocument(nr,"template",null);try{T.documentElement.innerHTML=aa?L:se}catch{}}const Ie=T.body||T.documentElement;return g&&P&&Ie.insertBefore(n.createTextNode(P),Ie.childNodes[0]||null),nr===Et?lt.call(T,mn?"html":"body")[0]:mn?T.documentElement:Ie},yu=function(g){return H.call(g.ownerDocument||g,g,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},ua=function(g){return g instanceof p&&(typeof g.nodeName!="string"||typeof g.textContent!="string"||typeof g.removeChild!="function"||!(g.attributes instanceof d)||typeof g.removeAttribute!="function"||typeof g.setAttribute!="function"||typeof g.namespaceURI!="string"||typeof g.insertBefore!="function"||typeof g.hasChildNodes!="function")},bu=function(g){return typeof a=="function"&&g instanceof a};function $t(z,g,T){Wi(z,P=>{P.call(e,g,T,rr)})}const wu=function(g){let T=null;if($t(Ee.beforeSanitizeElements,g,null),ua(g))return ht(g),!0;const P=ve(g.nodeName);if($t(Ee.uponSanitizeElement,g,{tagName:P,allowedTags:we}),ki&&g.hasChildNodes()&&!bu(g.firstElementChild)&&Pe(/<[/\w!]/g,g.innerHTML)&&Pe(/<[/\w!]/g,g.textContent)||g.nodeType===hs.progressingInstruction||ki&&g.nodeType===hs.comment&&Pe(/<[/\w]/g,g.data))return ht(g),!0;if(!(Bt.tagCheck instanceof Function&&Bt.tagCheck(P))&&(!we[P]||Xr[P])){if(!Xr[P]&&Su(P)&&(pe.tagNameCheck instanceof RegExp&&Pe(pe.tagNameCheck,P)||pe.tagNameCheck instanceof Function&&pe.tagNameCheck(P)))return!1;if(sa&&!ut[P]){const se=j(g)||g.parentNode,Ie=N(g)||g.childNodes;if(Ie&&se){const fe=Ie.length;for(let Me=fe-1;Me>=0;--Me){const At=k(Ie[Me],!0);At.__removalCount=(g.__removalCount||0)+1,se.insertBefore(At,G(g))}}}return ht(g),!0}return g instanceof l&&!Ev(g)||(P==="noscript"||P==="noembed"||P==="noframes")&&Pe(/<\/no(script|embed|frames)/i,g.innerHTML)?(ht(g),!0):(Qn&&g.nodeType===hs.text&&(T=g.textContent,Wi([gn,ct,Wt],se=>{T=ls(T,se," ")}),g.textContent!==T&&(as(e.removed,{element:g.cloneNode()}),g.textContent=T)),$t(Ee.afterSanitizeElements,g,null),!1)},_u=function(g,T,P){if(Si[T]||cu&&(T==="id"||T==="name")&&(P in n||P in kv))return!1;if(!(ta&&!Si[T]&&Pe(ea,T))){if(!(ou&&Pe(_i,T))){if(!(Bt.attributeCheck instanceof Function&&Bt.attributeCheck(T,g))){if(!$e[T]||Si[T]){if(!(Su(g)&&(pe.tagNameCheck instanceof RegExp&&Pe(pe.tagNameCheck,g)||pe.tagNameCheck instanceof Function&&pe.tagNameCheck(g))&&(pe.attributeNameCheck instanceof RegExp&&Pe(pe.attributeNameCheck,T)||pe.attributeNameCheck instanceof Function&&pe.attributeNameCheck(T,g))||T==="is"&&pe.allowCustomizedBuiltInElements&&(pe.tagNameCheck instanceof RegExp&&Pe(pe.tagNameCheck,P)||pe.tagNameCheck instanceof Function&&pe.tagNameCheck(P))))return!1}else if(!oa[T]){if(!Pe(ru,ls(P,nu,""))){if(!((T==="src"||T==="xlink:href"||T==="href")&&g!=="script"&&YD(P,"data:")===0&&hu[g])){if(!(au&&!Pe(mv,ls(P,nu,"")))){if(P)return!1}}}}}}}return!0},Su=function(g){return g!=="annotation-xml"&&Ja(g,vv)},ku=function(g){$t(Ee.beforeSanitizeAttributes,g,null);const{attributes:T}=g;if(!T||ua(g))return;const P={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:$e,forceKeepAttr:void 0};let se=T.length;for(;se--;){const Ie=T[se],{name:fe,namespaceURI:Me,value:At}=Ie,sr=ve(fe),ha=At;let Ae=fe==="value"?ha:KD(ha);if(P.attrName=sr,P.attrValue=Ae,P.keepAttr=!0,P.forceKeepAttr=void 0,$t(Ee.uponSanitizeAttribute,g,P),Ae=P.attrValue,uu&&(sr==="id"||sr==="name")&&(vn(fe,g),Ae=yv+Ae),ki&&Pe(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,Ae)){vn(fe,g);continue}if(sr==="attributename"&&Ja(Ae,"href")){vn(fe,g);continue}if(P.forceKeepAttr)continue;if(!P.keepAttr){vn(fe,g);continue}if(!lu&&Pe(/\/>/i,Ae)){vn(fe,g);continue}Qn&&Wi([gn,ct,Wt],$u=>{Ae=ls(Ae,$u," ")});const Eu=ve(g.nodeName);if(!_u(Eu,sr,Ae)){vn(fe,g);continue}if(F&&typeof m=="object"&&typeof m.getAttributeType=="function"&&!Me)switch(m.getAttributeType(Eu,sr)){case"TrustedHTML":{Ae=F.createHTML(Ae);break}case"TrustedScriptURL":{Ae=F.createScriptURL(Ae);break}}if(Ae!==ha)try{Me?g.setAttributeNS(Me,fe,Ae):g.setAttribute(fe,Ae),ua(g)?ht(g):Hd(e.removed)}catch{vn(fe,g)}}$t(Ee.afterSanitizeAttributes,g,null)},$v=function z(g){let T=null;const P=yu(g);for($t(Ee.beforeSanitizeShadowDOM,g,null);T=P.nextNode();)$t(Ee.uponSanitizeShadowNode,T,null),wu(T),ku(T),T.content instanceof i&&z(T.content);$t(Ee.afterSanitizeShadowDOM,g,null)};return e.sanitize=function(z){let g=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},T=null,P=null,se=null,Ie=null;if(aa=!z,aa&&(z="<!-->"),typeof z!="string"&&!bu(z))if(typeof z.toString=="function"){if(z=z.toString(),typeof z!="string")throw cs("dirty is not a string, aborting")}else throw cs("toString is not a function");if(!e.isSupported)return z;if(na||ca(g),e.removed=[],typeof z=="string"&&(Qr=!1),Qr){if(z.nodeName){const At=ve(z.nodeName);if(!we[At]||Xr[At])throw cs("root node is forbidden and cannot be sanitized in-place")}}else if(z instanceof a)T=vu("<!---->"),P=T.ownerDocument.importNode(z,!0),P.nodeType===hs.element&&P.nodeName==="BODY"||P.nodeName==="HTML"?T=P:T.appendChild(P);else{if(!er&&!Qn&&!mn&&z.indexOf("<")===-1)return F&&$i?F.createHTML(z):z;if(T=vu(z),!T)return er?null:$i?L:""}T&&ra&&ht(T.firstChild);const fe=yu(Qr?z:T);for(;se=fe.nextNode();)wu(se),ku(se),se.content instanceof i&&$v(se.content);if(Qr)return z;if(er){if(Ei)for(Ie=he.call(T.ownerDocument);T.firstChild;)Ie.appendChild(T.firstChild);else Ie=T;return($e.shadowroot||$e.shadowrootmode)&&(Ie=wi.call(r,Ie,!0)),Ie}let Me=mn?T.outerHTML:T.innerHTML;return mn&&we["!doctype"]&&T.ownerDocument&&T.ownerDocument.doctype&&T.ownerDocument.doctype.name&&Pe(Hm,T.ownerDocument.doctype.name)&&(Me="<!DOCTYPE "+T.ownerDocument.doctype.name+`>
|
|
211
|
+
`+Me),Qn&&Wi([gn,ct,Wt],At=>{Me=ls(Me,At," ")}),F&&$i?F.createHTML(Me):Me},e.setConfig=function(){let z=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};ca(z),na=!0},e.clearConfig=function(){rr=null,na=!1},e.isValidAttribute=function(z,g,T){rr||ca({});const P=ve(z),se=ve(g);return _u(P,se,T)},e.addHook=function(z,g){typeof g=="function"&&as(Ee[z],g)},e.removeHook=function(z,g){if(g!==void 0){const T=HD(Ee[z],g);return T===-1?void 0:qD(Ee[z],T,1)[0]}return Hd(Ee[z])},e.removeHooks=function(z){Ee[z]=[]},e.removeAllHooks=function(){Ee=Qd()},e}var Ym=qm();function Gc(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Xn=Gc();function Km(t){Xn=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(Oe.caret,"$1"),n=n.replace(s,o),r},getRegex:()=>new RegExp(n,e)};return r}var hO=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),Oe={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)}}>`)},dO=/^(?:[ \t]*(?:\n|$))+/,pO=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,fO=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,bi=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,gO=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Vc=/ {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,Vc).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),mO=q(Jm).replace(/bull/g,Vc).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(),Hc=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,vO=/^[^\n]+/,qc=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,yO=q(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",qc).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),bO=q(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Vc).getRegex(),Jo="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",Yc=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,wO=q("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",Yc).replace("tag",Jo).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Qm=q(Hc).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",Jo).getRegex(),_O=q(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Qm).getRegex(),Kc={blockquote:_O,code:pO,def:yO,fences:fO,heading:gO,hr:bi,html:wO,lheading:Xm,list:bO,newline:dO,paragraph:Qm,table:$n,text:vO},ep=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",Jo).getRegex(),SO={...Kc,lheading:mO,table:ep,paragraph:q(Hc).replace("hr",bi).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",ep).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",Jo).getRegex()},kO={...Kc,html:q(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Yc).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(Hc).replace("hr",bi).replace("heading",` *#{1,6} *[^
|
|
212
|
+
]`).replace("lheading",Xm).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},EO=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,$O=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,ev=/^( {2,}|\\)\n(?!\s*$)/,AO=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Jr=/[\p{P}\p{S}]/u,Xo=/[\s\p{P}\p{S}]/u,Jc=/[^\s\p{P}\p{S}]/u,xO=q(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Xo).getRegex(),tv=/(?!~)[\p{P}\p{S}]/u,TO=/(?!~)[\s\p{P}\p{S}]/u,CO=/(?:[^\s\p{P}\p{S}]|~)/u,IO=q(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",hO?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),nv=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,PO=q(nv,"u").replace(/punct/g,Jr).getRegex(),RO=q(nv,"u").replace(/punct/g,tv).getRegex(),rv="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",DO=q(rv,"gu").replace(/notPunctSpace/g,Jc).replace(/punctSpace/g,Xo).replace(/punct/g,Jr).getRegex(),OO=q(rv,"gu").replace(/notPunctSpace/g,CO).replace(/punctSpace/g,TO).replace(/punct/g,tv).getRegex(),zO=q("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Jc).replace(/punctSpace/g,Xo).replace(/punct/g,Jr).getRegex(),LO=q(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,Jr).getRegex(),MO="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",NO=q(MO,"gu").replace(/notPunctSpace/g,Jc).replace(/punctSpace/g,Xo).replace(/punct/g,Jr).getRegex(),UO=q(/\\(punct)/,"gu").replace(/punct/g,Jr).getRegex(),FO=q(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),ZO=q(Yc).replace("(?:-->|$)","-->").getRegex(),jO=q("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",ZO).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),_o=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,WO=q(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",_o).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),sv=q(/^!?\[(label)\]\[(ref)\]/).replace("label",_o).replace("ref",qc).getRegex(),iv=q(/^!?\[(ref)\](?:\[\])?/).replace("ref",qc).getRegex(),BO=q("reflink|nolink(?!\\()","g").replace("reflink",sv).replace("nolink",iv).getRegex(),tp=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Xc={_backpedal:$n,anyPunctuation:UO,autolink:FO,blockSkip:IO,br:ev,code:$O,del:$n,delLDelim:$n,delRDelim:$n,emStrongLDelim:PO,emStrongRDelimAst:DO,emStrongRDelimUnd:zO,escape:EO,link:WO,nolink:iv,punctuation:xO,reflink:sv,reflinkSearch:BO,tag:jO,text:AO,url:$n},GO={...Xc,link:q(/^!?\[(label)\]\((.*?)\)/).replace("label",_o).getRegex(),reflink:q(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",_o).getRegex()},Hl={...Xc,emStrongRDelimAst:OO,emStrongLDelim:RO,delLDelim:LO,delRDelim:NO,url:q(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",tp).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",tp).getRegex()},VO={...Hl,br:q(ev).replace("{2,}","*").getRegex(),text:q(Hl.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Gi={normal:Kc,gfm:SO,pedantic:kO},ds={normal:Xc,gfm:Hl,breaks:VO,pedantic:GO},HO={"&":"&","<":"<",">":">",'"':""","'":"'"},np=t=>HO[t];function gt(t,e){if(e){if(Oe.escapeTest.test(t))return t.replace(Oe.escapeReplace,np)}else if(Oe.escapeTestNoEncode.test(t))return t.replace(Oe.escapeReplaceNoEncode,np);return t}function rp(t){try{t=encodeURI(t).replace(Oe.percentDecode,"%")}catch{return null}return t}function sp(t,e){var i;let n=t.replace(Oe.findPipe,(o,a,l)=>{let c=!1,d=a;for(;--d>=0&&l[d]==="\\";)c=!c;return c?"|":" |"}),r=n.split(Oe.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(Oe.slashPipe,"|");return r}function ps(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 qO(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 YO(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 ip(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 KO(t,e,n){let r=t.match(n.other.indentCodeCompensation);if(r===null)return e;let s=r[1];return e.split(`
|
|
213
213
|
`).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(`
|
|
214
214
|
`)}var So=class{constructor(t){v(this,"options");v(this,"rules");v(this,"lexer");this.options=t||Xn}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:ps(n,`
|
|
215
|
-
`)}}}fences(t){let e=this.rules.block.fences.exec(t);if(e){let n=e[0],r=
|
|
215
|
+
`)}}}fences(t){let e=this.rules.block.fences.exec(t);if(e){let n=e[0],r=KO(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=ps(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:ps(e[0],`
|
|
216
216
|
`)}}blockquote(t){let e=this.rules.block.blockquote.exec(t);if(e){let n=ps(e[0],`
|
|
217
217
|
`).split(`
|
|
218
218
|
`),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(`
|
|
@@ -224,16 +224,16 @@ ${d}`:d;let p=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTo
|
|
|
224
224
|
`),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+`
|
|
225
225
|
`+n.join(`
|
|
226
226
|
`),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(`
|
|
227
|
-
`);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,p="",y="";if(!(e=a.exec(t))||this.rules.block.hr.test(t))break;p=e[0],t=t.substring(p.length);let m=
|
|
227
|
+
`);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,p="",y="";if(!(e=a.exec(t))||this.rules.block.hr.test(t))break;p=e[0],t=t.substring(p.length);let m=YO(e[2].split(`
|
|
228
228
|
`,1)[0],e[1].length),E=t.split(`
|
|
229
229
|
`,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)&&(p+=E+`
|
|
230
230
|
`,t=t.substring(E.length+1),d=!0),!d){let G=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 H=t.split(`
|
|
231
231
|
`,1)[0],he;if(E=H,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)||G.test(E)||N.test(E))break;if(he.search(this.rules.other.nonSpaceChar)>=I||!E.trim())y+=`
|
|
232
232
|
`+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+=`
|
|
233
233
|
`+E}k=!E.trim(),p+=H+`
|
|
234
|
-
`,t=t.substring(H.length+1),m=he.slice(I)}}o.loose||(l?o.loose=!0:this.rules.other.doubleBlankLine.test(p)&&(l=!0)),o.items.push({type:"list_item",raw:p,task:!!this.options.gfm&&this.rules.other.listIsTask.test(y),loose:!1,text:y,tokens:[]}),o.raw+=p}let 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 p=this.rules.other.listTaskCheckbox.exec(d.raw);if(p){let y={type:"checkbox",raw:p[0]+" ",checked:p[0]!=="[ ]"};d.checked=y.checked,o.loose?d.tokens[0]&&["paragraph","text"].includes(d.tokens[0].type)&&"tokens"in d.tokens[0]&&d.tokens[0].tokens?(d.tokens[0].raw=y.raw+d.tokens[0].raw,d.tokens[0].text=y.raw+d.tokens[0].text,d.tokens[0].tokens.unshift(y)):d.tokens.unshift({type:"paragraph",raw:y.raw,text:y.raw,tokens:[y]}):d.tokens.unshift(y)}}if(!o.loose){let p=d.tokens.filter(m=>m.type==="space"),y=p.length>0&&p.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 p of d.tokens)p.type==="text"&&(p.type="paragraph")}return o}}html(t){let e=this.rules.block.html.exec(t);if(e)return{type:"html",block:!0,raw:e[0],pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:e[0]}}def(t){let e=this.rules.block.def.exec(t);if(e){let n=e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),r=e[2]?e[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",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=
|
|
235
|
-
`):[],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(
|
|
236
|
-
`?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=ps(n.slice(0,-1),"\\");if((n.length-i.length)%2===0)return}else{let i=
|
|
234
|
+
`,t=t.substring(H.length+1),m=he.slice(I)}}o.loose||(l?o.loose=!0:this.rules.other.doubleBlankLine.test(p)&&(l=!0)),o.items.push({type:"list_item",raw:p,task:!!this.options.gfm&&this.rules.other.listIsTask.test(y),loose:!1,text:y,tokens:[]}),o.raw+=p}let 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 p=this.rules.other.listTaskCheckbox.exec(d.raw);if(p){let y={type:"checkbox",raw:p[0]+" ",checked:p[0]!=="[ ]"};d.checked=y.checked,o.loose?d.tokens[0]&&["paragraph","text"].includes(d.tokens[0].type)&&"tokens"in d.tokens[0]&&d.tokens[0].tokens?(d.tokens[0].raw=y.raw+d.tokens[0].raw,d.tokens[0].text=y.raw+d.tokens[0].text,d.tokens[0].tokens.unshift(y)):d.tokens.unshift({type:"paragraph",raw:y.raw,text:y.raw,tokens:[y]}):d.tokens.unshift(y)}}if(!o.loose){let p=d.tokens.filter(m=>m.type==="space"),y=p.length>0&&p.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 p of d.tokens)p.type==="text"&&(p.type="paragraph")}return o}}html(t){let e=this.rules.block.html.exec(t);if(e)return{type:"html",block:!0,raw:e[0],pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:e[0]}}def(t){let e=this.rules.block.def.exec(t);if(e){let n=e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),r=e[2]?e[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",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=sp(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(`
|
|
235
|
+
`):[],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(sp(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)===`
|
|
236
|
+
`?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=ps(n.slice(0,-1),"\\");if((n.length-i.length)%2===0)return}else{let i=qO(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)),ip(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 ip(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,p=t.slice(0,s+r.index+d+o);if(Math.min(s,o)%2){let m=p.slice(1,-1);return{type:"em",raw:p,text:m,tokens:this.lexer.inlineTokens(m)}}let y=p.slice(2,-2);return{type:"strong",raw:p,text:y,tokens:this.lexer.inlineTokens(y)}}}}codespan(t){let e=this.rules.inline.code.exec(t);if(e){let n=e[2].replace(this.rules.other.newLineCharGlobal," "),r=this.rules.other.nonSpaceChar.test(n),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),p=d.slice(s,-s);return{type:"del",raw:d,text:p,tokens:this.lexer.inlineTokens(p)}}}}autolink(t){let e=this.rules.inline.autolink.exec(t);if(e){let n,r;return e[2]==="@"?(n=e[1],r="mailto:"+n):(n=e[1],r=n),{type:"link",raw:e[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}url(t){var n;let e;if(e=this.rules.inline.url.exec(t)){let r,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}}}},ot=class ql{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||Xn,this.options.tokenizer=this.options.tokenizer||new So,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:Oe,block:Gi.normal,inline:ds.normal};this.options.pedantic?(n.block=Gi.pedantic,n.inline=ds.pedantic):this.options.gfm&&(n.block=Gi.gfm,this.options.breaks?n.inline=ds.breaks:n.inline=ds.gfm),this.tokenizer.rules=n}static get rules(){return{block:Gi,inline:ds}}static lex(e,n){return new ql(n).lex(e)}static lexInline(e,n){return new ql(n).inlineTokens(e)}lex(e){e=e.replace(Oe.carriageReturn,`
|
|
237
237
|
`),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(Oe.tabCharGlobal," ").replace(Oe.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+=`
|
|
238
238
|
`: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(`
|
|
239
239
|
`)?"":`
|
|
@@ -265,10 +265,10 @@ ${this.parser.parse(t)}</blockquote>
|
|
|
265
265
|
`}tablerow({text:t}){return`<tr>
|
|
266
266
|
${t}</tr>
|
|
267
267
|
`}tablecell(t){let e=this.parser.parseInline(t.tokens),n=t.header?"th":"td";return(t.align?`<${n} align="${t.align}">`:`<${n}>`)+e+`</${n}>
|
|
268
|
-
`}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>${gt(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=
|
|
269
|
-
Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error occurred:</p><pre>"+gt(n.message+"",!0)+"</pre>";return e?Promise.resolve(r):r}if(e)return Promise.reject(n);throw n}}},Hn=new
|
|
268
|
+
`}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>${gt(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=rp(t);if(s===null)return r;t=s;let i='<a href="'+t+'"';return e&&(i+=' title="'+gt(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=rp(t);if(s===null)return gt(n);t=s;let i=`<img src="${t}" alt="${gt(n)}"`;return e&&(i+=` title="${gt(e)}"`),i+=">",i}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:gt(t.text)}},Qc=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}},at=class Yl{constructor(e){v(this,"options");v(this,"renderer");v(this,"textRenderer");this.options=e||Xn,this.options.renderer=this.options.renderer||new ko,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Qc}static parse(e,n){return new Yl(n).parse(e)}static parseInline(e,n){return new Yl(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}},Vi,_s=(Vi=class{constructor(t){v(this,"options");v(this,"block");this.options=t||Xn}preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}emStrongMask(t){return t}provideLexer(){return this.block?ot.lex:ot.lexInline}provideParser(){return this.block?at.parse:at.parseInline}},v(Vi,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),v(Vi,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),Vi),JO=class{constructor(...t){v(this,"defaults",Gc());v(this,"options",this.setOptions);v(this,"parse",this.parseMarkdown(!0));v(this,"parseInline",this.parseMarkdown(!1));v(this,"Parser",at);v(this,"Renderer",ko);v(this,"TextRenderer",Qc);v(this,"Lexer",ot);v(this,"Tokenizer",So);v(this,"Hooks",_s);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 ko(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 So(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 _s;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];_s.passThroughHooks.has(i)?s[o]=c=>{if(this.defaults.async&&_s.passThroughHooksRespectAsync.has(i))return(async()=>{let p=await a.call(s,c);return l.call(s,p)})();let d=a.call(s,c);return l.call(s,d)}:s[o]=(...c)=>{if(this.defaults.async)return(async()=>{let p=await a.apply(s,c);return p===!1&&(p=await l.apply(s,c)),p})();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 ot.lex(t,e??this.defaults)}parser(t,e){return at.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?ot.lex:ot.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?at.parse:at.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?ot.lex:ot.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?at.parse:at.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+=`
|
|
269
|
+
Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error occurred:</p><pre>"+gt(n.message+"",!0)+"</pre>";return e?Promise.resolve(r):r}if(e)return Promise.reject(n);throw n}}},Hn=new JO;function X(t,e){return Hn.parse(t,e)}X.options=X.setOptions=function(t){return Hn.setOptions(t),X.defaults=Hn.defaults,Km(X.defaults),X};X.getDefaults=Gc;X.defaults=Xn;X.use=function(...t){return Hn.use(...t),X.defaults=Hn.defaults,Km(X.defaults),X};X.walkTokens=function(t,e){return Hn.walkTokens(t,e)};X.parseInline=Hn.parseInline;X.Parser=at;X.parser=at.parse;X.Renderer=ko;X.TextRenderer=Qc;X.Lexer=ot;X.lexer=ot.lex;X.Tokenizer=So;X.Hooks=_s;X.parse=X;X.options;X.setOptions;X.use;X.walkTokens;X.parseInline;at.parse;ot.lex;Ym.addHook("afterSanitizeAttributes",t=>{t.tagName==="A"&&(t.setAttribute("target","_blank"),t.setAttribute("rel","noopener noreferrer"))});function XO(t){const e=X.parse(t,{async:!1});return Ym.sanitize(e,{USE_PROFILES:{html:!0}})}const QO=8,op=new WeakMap;function ez(t){const e=op.get(t);if(e&&e.text===t.text)return e.html;const n=XO(t.text);return op.set(t,{text:t.text,html:n}),n}function ap(t){for(let e=t.length-1;e>=0;e-=1){const n=t[e];if(n&&n.kind==="user")return n.id}return null}var Mt,jn,Io,Po,ri,Kl;class ov extends Rs{constructor(){super(...arguments);$(this,ri);v(this,"messages",[]);$(this,Mt,!0);$(this,jn,null);$(this,Io,()=>{const n=u(this,jn);if(!n)return;const s=n.scrollHeight-n.clientHeight-n.scrollTop<=QO;s!==u(this,Mt)&&(x(this,Mt,s),this.toggleAttribute("data-pinned",s))});$(this,Po,()=>{x(this,Mt,!0),this.toggleAttribute("data-pinned",!0),b(this,ri,Kl).call(this,!0)})}changed(n){let r=!1;if(n.has("messages")){const s=n.get("messages")??[],i=ap(this.messages);r=i!==null&&i!==ap(s),r&&x(this,Mt,!0)}be(this.template(),this),u(this,jn)||x(this,jn,this.querySelector(".history-scroll")),this.toggleAttribute("data-pinned",u(this,Mt)),b(this,ri,Kl).call(this,r)}template(){const n=this.messages.filter(r=>r.kind==="user"||r.kind==="assistant");return M`
|
|
270
270
|
<div class="history-scroll" @scroll=${u(this,Io)}>
|
|
271
|
-
${n.map(r=>{const s=r.kind==="assistant"?
|
|
271
|
+
${n.map(r=>{const s=r.kind==="assistant"?CR(ez(r)):r.text;return M`<div
|
|
272
272
|
class="message message-${r.kind}"
|
|
273
273
|
data-message-id=${r.id}
|
|
274
274
|
>${s}</div>`})}
|
|
@@ -279,9 +279,9 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
279
279
|
aria-label="Jump to latest message"
|
|
280
280
|
@click=${u(this,Po)}
|
|
281
281
|
>
|
|
282
|
-
${
|
|
282
|
+
${wm({size:16})}
|
|
283
283
|
</button>
|
|
284
|
-
`}}Mt=new WeakMap,jn=new WeakMap,Io=new WeakMap,Po=new WeakMap,ri=new WeakSet,Kl=function(n){requestAnimationFrame(()=>{const r=u(this,jn);r&&(!u(this,Mt)&&!n||(r.scrollTop=r.scrollHeight-r.clientHeight))})},v(
|
|
284
|
+
`}}Mt=new WeakMap,jn=new WeakMap,Io=new WeakMap,Po=new WeakMap,ri=new WeakSet,Kl=function(n){requestAnimationFrame(()=>{const r=u(this,jn);r&&(!u(this,Mt)&&!n||(r.scrollTop=r.scrollHeight-r.clientHeight))})},v(ov,"properties",["messages"]);customElements.define("message-history",ov);const tz=et();var un,Xl,Ql,si,ii;class Jl extends Rs{constructor(){super(...arguments);$(this,un);v(this,"placeholder","What do you want to do?");v(this,"open",!1);v(this,"messages",[]);v(this,"handleTriggerActivate",()=>{this.open=!0});v(this,"handleKeydown",n=>{if(n.key!=="Enter"||n.shiftKey)return;const r=n.currentTarget,s=r.value.trim();n.preventDefault(),s&&(r.value="",this.dispatchEvent(new tz("command-submit",{value:s,bubbles:!0,composed:!0})))});$(this,si,n=>{n.target instanceof Node&&(this.contains(n.target)||(this.open=!1))});$(this,ii,n=>{n.key==="Escape"&&(this.open=!1)})}connected(){this.open&&b(this,un,Xl).call(this)}disconnected(){b(this,un,Ql).call(this)}changed(n){if(be(this.template(),this),n.has("open"))if(this.open){b(this,un,Xl).call(this);const r=this.querySelector("textarea");r==null||r.focus()}else b(this,un,Ql).call(this)}template(){return this.open?M`
|
|
285
285
|
<message-history .messages=${this.messages}></message-history>
|
|
286
286
|
<textarea
|
|
287
287
|
class="input"
|
|
@@ -298,7 +298,7 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
298
298
|
>
|
|
299
299
|
${this.placeholder}
|
|
300
300
|
</button>
|
|
301
|
-
`}}un=new WeakSet,Xl=function(){document.addEventListener("mousedown",u(this,si)),document.addEventListener("keydown",u(this,ii))},Ql=function(){document.removeEventListener("mousedown",u(this,si)),document.removeEventListener("keydown",u(this,ii))},si=new WeakMap,ii=new WeakMap,v(Jl,"properties",["placeholder","open","messages"]),v(Jl,"attributes",{placeholder:{type:String},open:{type:Boolean}});customElements.define("command-panel",Jl);const nl=et();class
|
|
301
|
+
`}}un=new WeakSet,Xl=function(){document.addEventListener("mousedown",u(this,si)),document.addEventListener("keydown",u(this,ii))},Ql=function(){document.removeEventListener("mousedown",u(this,si)),document.removeEventListener("keydown",u(this,ii))},si=new WeakMap,ii=new WeakMap,v(Jl,"properties",["placeholder","open","messages"]),v(Jl,"attributes",{placeholder:{type:String},open:{type:Boolean}});customElements.define("command-panel",Jl);const nl=et();class nz extends HTMLElement{constructor(){super(...arguments);v(this,"screenManager",Ve.resolve("ScreenManager"));v(this,"serverManager",Ve.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 nl("edit-screen",{bubbles:!0,composed:!0})))}handleCreateScreen(n){this.closeDropdown(),this.dispatchEvent(new nl("create-screen",{serverURL:n,bubbles:!0,composed:!0}))}handleDeleteScreen(){this.screenManager.activeScreen&&(this.closeDropdown(),this.dispatchEvent(new nl("delete-screen",{bubbles:!0,composed:!0})))}render(){var l;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()],o=i.flatMap(c=>[...c.screens.values()]).sort((c,d)=>c.name.localeCompare(d.name,void 0,{sensitivity:"base"})),a=((l=i[0])==null?void 0:l.url)??null;be(M`
|
|
302
302
|
<dropdown-menu
|
|
303
303
|
title=${r}
|
|
304
304
|
placement="top"
|
|
@@ -345,13 +345,13 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
345
345
|
<dropdown-item value=${n.id} ?selected=${i}>
|
|
346
346
|
${o}
|
|
347
347
|
</dropdown-item>
|
|
348
|
-
`}}customElements.define("screen-picker",
|
|
348
|
+
`}}customElements.define("screen-picker",nz);var oi,Rr,Ro,Do,lv;class av extends Rs{constructor(){super(...arguments);$(this,Do);v(this,"messages",[]);$(this,oi,Ve.resolve("ACPClientManager"));$(this,Rr);$(this,Ro,n=>{const r=u(this,oi).getActiveClient();if(!r)return;const s=n.value;r.sendMessage({text:s}).catch(i=>{console.error("ACPClient.sendMessage() failed",i)})})}connected(){x(this,Rr,WD(u(this,oi),n=>{this.messages=n}))}disconnected(){var n;(n=u(this,Rr))==null||n.dispose(),x(this,Rr,void 0)}changed(){be(b(this,Do,lv).call(this),this)}}oi=new WeakMap,Rr=new WeakMap,Ro=new WeakMap,Do=new WeakSet,lv=function(){return M`
|
|
349
349
|
<screen-picker></screen-picker>
|
|
350
350
|
<command-panel
|
|
351
351
|
.messages=${this.messages}
|
|
352
352
|
@command-submit=${u(this,Ro)}
|
|
353
353
|
></command-panel>
|
|
354
|
-
`},v(
|
|
354
|
+
`},v(av,"properties",["messages"]);customElements.define("app-toolbar",av);class cv extends HTMLElement{constructor(){super(...arguments);v(this,"screenManager",Ve.resolve("ScreenManager"));v(this,"serverManager",Ve.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`
|
|
355
355
|
<modal-overlay ?open=${this.open}>
|
|
356
356
|
<section class="screen-modal">
|
|
357
357
|
<form class="screen-form" @submit=${o=>void this.handleSubmit(o)}>
|
|
@@ -371,7 +371,7 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
371
371
|
</form>
|
|
372
372
|
</section>
|
|
373
373
|
</modal-overlay>
|
|
374
|
-
`,this)}}v(
|
|
374
|
+
`,this)}}v(cv,"observedAttributes",["open"]);customElements.define("screen-form-modal",cv);class uv extends HTMLElement{constructor(){super(...arguments);v(this,"screenManager",Ve.resolve("ScreenManager"));v(this,"serverManager",Ve.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`
|
|
375
375
|
<modal-overlay ?open=${this.open}>
|
|
376
376
|
<section class="screen-modal screen-delete-modal">
|
|
377
377
|
<div class="screen-form">
|
|
@@ -402,10 +402,10 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
402
402
|
</div>
|
|
403
403
|
</section>
|
|
404
404
|
</modal-overlay>
|
|
405
|
-
`,this)}}v(
|
|
405
|
+
`,this)}}v(uv,"observedAttributes",["open"]);customElements.define("screen-delete-modal",uv);class hv extends HTMLElement{constructor(){super(...arguments);v(this,"serverManager",Ve.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`
|
|
406
406
|
<modal-overlay ?open=${this.open}>
|
|
407
407
|
<section class="settings-panel">
|
|
408
|
-
<panel-view closable @close=${r=>r instanceof
|
|
408
|
+
<panel-view closable @close=${r=>r instanceof Pm&&this.emitClose()}>
|
|
409
409
|
<panel-page id="main" title="Settings">
|
|
410
410
|
<div class="settings-section">
|
|
411
411
|
<h3 class="settings-section-title">Servers</h3>
|
|
@@ -466,7 +466,7 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
466
466
|
</panel-view>
|
|
467
467
|
</section>
|
|
468
468
|
</modal-overlay>
|
|
469
|
-
`,this)}}v(
|
|
469
|
+
`,this)}}v(hv,"observedAttributes",["open"]);customElements.define("settings-modal",hv);class dv extends Event{constructor(n){super("auth-submit",{bubbles:!0,composed:!0});v(this,"token");this.token=n}}class rz 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 dv(r))}render(){be(M`
|
|
470
470
|
<modal-overlay open>
|
|
471
471
|
<section class="auth-modal">
|
|
472
472
|
<form class="auth-form" @submit=${n=>this.handleSubmit(n)}>
|
|
@@ -487,7 +487,7 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
487
487
|
</form>
|
|
488
488
|
</section>
|
|
489
489
|
</modal-overlay>
|
|
490
|
-
`,this)}}customElements.get("auth-modal")||customElements.define("auth-modal",
|
|
490
|
+
`,this)}}customElements.get("auth-modal")||customElements.define("auth-modal",rz);class sz extends HTMLElement{constructor(){super(...arguments);v(this,"runtimeServerURL",um());v(this,"electronMode",dm());v(this,"serverManager",Ve.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 dv?n.token:n instanceof CustomEvent&&typeof((s=n.detail)==null?void 0:s.token)=="string"?n.detail.token:null;r&&this.handleAuthSubmit(r)}),this.addEventListener("edit-screen",()=>{this.modals.screenForm={open:!0,mode:"edit"},this.render()}),this.addEventListener("create-screen",n=>{const r=n.serverURL;this.modals.screenForm={open:!0,mode:"create",targetServerURL:r},this.render()}),this.addEventListener("delete-screen",()=>{this.modals.deleteScreen={open:!0},this.render()}),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 Sl({url:this.runtimeServerURL,name:"Server",token:hm()});this.serverManager.add(n),this.serverManager.setActive(n);try{await n.connect(),this.connectError=null}catch(r){this.connectError=r instanceof Error&&!(r instanceof _l)?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 _l||(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`
|
|
491
491
|
<main class="auth-gate"><p>Connecting...</p></main>
|
|
492
492
|
`,this);return}if(r==="disconnected"){const i=n;if(!i)return;be(M`
|
|
493
493
|
<main class="auth-gate">
|
|
@@ -517,4 +517,4 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
517
517
|
?open=${this.modals.settings.open}
|
|
518
518
|
@close=${()=>{this.modals.settings={open:!1},this.render()}}
|
|
519
519
|
></settings-modal>
|
|
520
|
-
`;be(s,this)}}customElements.get("television-app")||customElements.define("television-app",
|
|
520
|
+
`;be(s,this)}}customElements.get("television-app")||customElements.define("television-app",sz);const eu=dm(),Qo=um(),pv=new UE(eu?"television-electron":"television-browser",NE(Qo)),fv=new PC({localStore:pv,localServerURL:Qo}),gv=new zE({localStore:pv,serverManager:fv}),iz=new dR({serverURL:Qo,token:hm()??"",screenManager:gv});Ve.register("ServerManager",()=>fv);Ve.register("ScreenManager",()=>gv);Ve.register("ACPClientManager",()=>iz);const tu=document.createElement("television-app");tu.runtimeServerURL=Qo;tu.electronMode=eu;eu&&document.body.classList.add("electron");document.body.appendChild(tu);
|