@telepath-computer/television 0.1.117 → 0.1.118
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/canonical/v1/components.js +157 -0
- package/dist/canonical/v1/styles.css +148 -4
- package/dist/cli.cjs +6 -2
- package/dist/skills/television/SKILL.md +71 -8
- package/dist/web/assets/index-B8wrBJd5.css +1 -0
- package/dist/web/assets/{index-B4JThtNB.js → index-CMNMkOMk.js} +200 -98
- package/dist/web/index.html +2 -2
- package/package.json +1 -1
- package/dist/web/assets/index-CQF4vfjH.css +0 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
var Xw=Object.defineProperty;var rp=n=>{throw TypeError(n)};var Kw=(n,t,e)=>t in n?Xw(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var g=(n,t,e)=>Kw(n,typeof t!="symbol"?t+"":t,e),gc=(n,t,e)=>t.has(n)||rp("Cannot "+e);var l=(n,t,e)=>(gc(n,t,"read from private field"),e?e.call(n):t.get(n)),w=(n,t,e)=>t.has(n)?rp("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(n):t.set(n,e),S=(n,t,e,r)=>(gc(n,t,"write to private field"),r?r.call(n,e):t.set(n,e),e),f=(n,t,e)=>(gc(n,t,"access private method"),e);var ip=(n,t,e,r)=>({set _(i){S(n,t,i,e)},get _(){return l(n,t,r)}});(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const s of i)if(s.type==="childList")for(const o of s.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function e(i){const s={};return i.integrity&&(s.integrity=i.integrity),i.referrerPolicy&&(s.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?s.credentials="include":i.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function r(i){if(i.ep)return;i.ep=!0;const s=e(i);fetch(i.href,s)}})();var ur=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Jw(n){if(n.__esModule)return n;var t=n.default;if(typeof t=="function"){var e=function r(){return this instanceof r?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};e.prototype=t.prototype}else e={};return Object.defineProperty(e,"__esModule",{value:!0}),Object.keys(n).forEach(function(r){var i=Object.getOwnPropertyDescriptor(n,r);Object.defineProperty(e,r,i.get?i:{enumerable:!0,get:function(){return n[r]}})}),e}var sp=Object.prototype.toString,am=function(t){var e=sp.call(t),r=e==="[object Arguments]";return r||(r=e!=="[object Array]"&&t!==null&&typeof t=="object"&&typeof t.length=="number"&&t.length>=0&&sp.call(t.callee)==="[object Function]"),r},mc,op;function Qw(){if(op)return mc;op=1;var n;if(!Object.keys){var t=Object.prototype.hasOwnProperty,e=Object.prototype.toString,r=am,i=Object.prototype.propertyIsEnumerable,s=!i.call({toString:null},"toString"),o=i.call(function(){},"prototype"),a=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],c=function(v){var m=v.constructor;return m&&m.prototype===v},u={$applicationCache:!0,$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$onmozfullscreenchange:!0,$onmozfullscreenerror:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},h=function(){if(typeof window>"u")return!1;for(var v in window)try{if(!u["$"+v]&&t.call(window,v)&&window[v]!==null&&typeof window[v]=="object")try{c(window[v])}catch{return!0}}catch{return!0}return!1}(),p=function(v){if(typeof window>"u"||!h)return c(v);try{return c(v)}catch{return!1}};n=function(m){var _=m!==null&&typeof m=="object",k=e.call(m)==="[object Function]",T=r(m),P=_&&e.call(m)==="[object String]",R=[];if(!_&&!k&&!T)throw new TypeError("Object.keys called on a non-object");var W=o&&k;if(P&&m.length>0&&!t.call(m,0))for(var N=0;N<m.length;++N)R.push(String(N));if(T&&m.length>0)for(var F=0;F<m.length;++F)R.push(String(F));else for(var Y in m)!(W&&Y==="prototype")&&t.call(m,Y)&&R.push(String(Y));if(s)for(var j=p(m),oe=0;oe<a.length;++oe)!(j&&a[oe]==="constructor")&&t.call(m,a[oe])&&R.push(a[oe]);return R}}return mc=n,mc}var e0=Array.prototype.slice,t0=am,ap=Object.keys,Ea=ap?function(t){return ap(t)}:Qw(),lp=Object.keys;Ea.shim=function(){if(Object.keys){var t=function(){var e=Object.keys(arguments);return e&&e.length===arguments.length}(1,2);t||(Object.keys=function(r){return t0(r)?lp(e0.call(r)):lp(r)})}else Object.keys=Ea;return Object.keys||Ea};var n0=Ea,xa=Object.defineProperty||!1;if(xa)try{xa({},"a",{value:1})}catch{xa=!1}var Mo=xa,_n=SyntaxError,X=TypeError,r0=Object.getOwnPropertyDescriptor,Aa=r0;if(Aa)try{Aa([],"length")}catch{Aa=null}var Xi=Aa,cp=Mo,i0=_n,Jr=X,up=Xi,lm=function(t,e,r){if(!t||typeof t!="object"&&typeof t!="function")throw new Jr("`obj` must be an object or a function`");if(typeof e!="string"&&typeof e!="symbol")throw new Jr("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new Jr("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new Jr("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new Jr("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new Jr("`loose`, if provided, must be a boolean");var i=arguments.length>3?arguments[3]:null,s=arguments.length>4?arguments[4]:null,o=arguments.length>5?arguments[5]:null,a=arguments.length>6?arguments[6]:!1,c=!!up&&up(t,e);if(cp)cp(t,e,{configurable:o===null&&c?c.configurable:!o,enumerable:i===null&&c?c.enumerable:!i,value:r,writable:s===null&&c?c.writable:!s});else if(a||!i&&!s&&!o)t[e]=r;else throw new i0("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},du=Mo,cm=function(){return!!du};cm.hasArrayLengthDefineBug=function(){if(!du)return null;try{return du([],"length",{value:1}).length!==1}catch{return!0}};var zl=cm,s0=n0,o0=typeof Symbol=="function"&&typeof Symbol("foo")=="symbol",a0=Object.prototype.toString,l0=Array.prototype.concat,hp=lm,c0=function(n){return typeof n=="function"&&a0.call(n)==="[object Function]"},um=zl(),u0=function(n,t,e,r){if(t in n){if(r===!0){if(n[t]===e)return}else if(!c0(r)||!r())return}um?hp(n,t,e,!0):hp(n,t,e)},hm=function(n,t){var e=arguments.length>2?arguments[2]:{},r=s0(t);o0&&(r=l0.call(r,Object.getOwnPropertySymbols(t)));for(var i=0;i<r.length;i+=1)u0(n,r[i],t[r[i]],e[r[i]])};hm.supportsDescriptors=!!um;var Wr=hm,$a={exports:{}};typeof self<"u"?$a.exports=self:typeof window<"u"?$a.exports=window:$a.exports=Function("return this")();var dm=$a.exports,h0=dm,pm=function(){return typeof ur!="object"||!ur||ur.Math!==Math||ur.Array!==Array?h0:ur},d0=Wr,p0=Xi,f0=pm,g0=function(){var t=f0();if(d0.supportsDescriptors){var e=p0(t,"globalThis");(!e||e.configurable&&(e.enumerable||!e.writable||globalThis!==t))&&Object.defineProperty(t,"globalThis",{configurable:!0,enumerable:!1,value:t,writable:!0})}else(typeof globalThis!="object"||globalThis!==t)&&(t.globalThis=t);return t},m0=Wr,v0=dm,fm=pm,y0=g0,b0=fm(),gm=function(){return b0};m0(gm,{getPolyfill:fm,implementation:v0,shim:y0});var Ah=gm,kn=function(t){return!!t&&(typeof t=="function"||typeof t=="object")},$h=Object,mm=Error,w0=EvalError,S0=RangeError,Th=ReferenceError,_0=URIError,k0=Math.abs,E0=Math.floor,x0=Math.max,A0=Math.min,$0=Math.pow,T0=Math.round,Ih=Number.isNaN||function(t){return t!==t},I0=Ih,C0=function(t){return I0(t)||t===0?t:t<0?-1:1},Ki=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var t={},e=Symbol("test"),r=Object(e);if(typeof e=="string"||Object.prototype.toString.call(e)!=="[object Symbol]"||Object.prototype.toString.call(r)!=="[object Symbol]")return!1;var i=42;t[e]=i;for(var s in t)return!1;if(typeof Object.keys=="function"&&Object.keys(t).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(t).length!==0)return!1;var o=Object.getOwnPropertySymbols(t);if(o.length!==1||o[0]!==e||!Object.prototype.propertyIsEnumerable.call(t,e))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var a=Object.getOwnPropertyDescriptor(t,e);if(a.value!==i||a.enumerable!==!0)return!1}return!0},dp=typeof Symbol<"u"&&Symbol,R0=Ki,Ch=function(){return typeof dp!="function"||typeof Symbol!="function"||typeof dp("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:R0()},vm=typeof Reflect<"u"&&Reflect.getPrototypeOf||null,P0=$h,ym=P0.getPrototypeOf||null,D0="Function.prototype.bind called on incompatible ",L0=Object.prototype.toString,z0=Math.max,O0="[object Function]",pp=function(t,e){for(var r=[],i=0;i<t.length;i+=1)r[i]=t[i];for(var s=0;s<e.length;s+=1)r[s+t.length]=e[s];return r},M0=function(t,e){for(var r=[],i=e,s=0;i<t.length;i+=1,s+=1)r[s]=t[i];return r},N0=function(n,t){for(var e="",r=0;r<n.length;r+=1)e+=n[r],r+1<n.length&&(e+=t);return e},U0=function(t){var e=this;if(typeof e!="function"||L0.apply(e)!==O0)throw new TypeError(D0+e);for(var r=M0(arguments,1),i,s=function(){if(this instanceof i){var h=e.apply(this,pp(r,arguments));return Object(h)===h?h:this}return e.apply(t,pp(r,arguments))},o=z0(0,e.length-r.length),a=[],c=0;c<o;c++)a[c]="$"+c;if(i=Function("binder","return function ("+N0(a,",")+"){ return binder.apply(this,arguments); }")(s),e.prototype){var u=function(){};u.prototype=e.prototype,i.prototype=new u,u.prototype=null}return i},F0=U0,No=Function.prototype.bind||F0,Rh=Function.prototype.call,Ph=Function.prototype.apply,H0=typeof Reflect<"u"&&Reflect&&Reflect.apply,W0=No,Z0=Ph,V0=Rh,B0=H0,bm=B0||W0.call(V0,Z0),j0=No,G0=X,q0=Rh,Y0=bm,Ol=function(t){if(t.length<1||typeof t[0]!="function")throw new G0("a function is required");return Y0(j0,q0,t)},X0=Ol,fp=Xi,wm;try{wm=[].__proto__===Array.prototype}catch(n){if(!n||typeof n!="object"||!("code"in n)||n.code!=="ERR_PROTO_ACCESS")throw n}var vc=!!wm&&fp&&fp(Object.prototype,"__proto__"),Sm=Object,gp=Sm.getPrototypeOf,K0=vc&&typeof vc.get=="function"?X0([vc.get]):typeof gp=="function"?function(t){return gp(t==null?t:Sm(t))}:!1,mp=vm,vp=ym,yp=K0,_m=mp?function(t){return mp(t)}:vp?function(t){if(!t||typeof t!="object"&&typeof t!="function")throw new TypeError("getProto: not an object");return vp(t)}:yp?function(t){return yp(t)}:null,J0=Function.prototype.call,Q0=Object.prototype.hasOwnProperty,eS=No,En=eS.call(J0,Q0),q,tS=$h,nS=mm,rS=w0,iS=S0,sS=Th,Vi=_n,yi=X,oS=_0,aS=k0,lS=E0,cS=x0,uS=A0,hS=$0,dS=T0,pS=C0,km=Function,yc=function(n){try{return km('"use strict"; return ('+n+").constructor;")()}catch{}},Ns=Xi,fS=Mo,bc=function(){throw new yi},gS=Ns?function(){try{return arguments.callee,bc}catch{try{return Ns(arguments,"callee").get}catch{return bc}}}():bc,Qr=Ch(),Te=_m,mS=ym,vS=vm,Em=Ph,Uo=Rh,ii={},yS=typeof Uint8Array>"u"||!Te?q:Te(Uint8Array),Lr={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?q:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?q:ArrayBuffer,"%ArrayIteratorPrototype%":Qr&&Te?Te([][Symbol.iterator]()):q,"%AsyncFromSyncIteratorPrototype%":q,"%AsyncFunction%":ii,"%AsyncGenerator%":ii,"%AsyncGeneratorFunction%":ii,"%AsyncIteratorPrototype%":ii,"%Atomics%":typeof Atomics>"u"?q:Atomics,"%BigInt%":typeof BigInt>"u"?q:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?q:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?q:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?q:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":nS,"%eval%":eval,"%EvalError%":rS,"%Float16Array%":typeof Float16Array>"u"?q:Float16Array,"%Float32Array%":typeof Float32Array>"u"?q:Float32Array,"%Float64Array%":typeof Float64Array>"u"?q:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?q:FinalizationRegistry,"%Function%":km,"%GeneratorFunction%":ii,"%Int8Array%":typeof Int8Array>"u"?q:Int8Array,"%Int16Array%":typeof Int16Array>"u"?q:Int16Array,"%Int32Array%":typeof Int32Array>"u"?q:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":Qr&&Te?Te(Te([][Symbol.iterator]())):q,"%JSON%":typeof JSON=="object"?JSON:q,"%Map%":typeof Map>"u"?q:Map,"%MapIteratorPrototype%":typeof Map>"u"||!Qr||!Te?q:Te(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":tS,"%Object.getOwnPropertyDescriptor%":Ns,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?q:Promise,"%Proxy%":typeof Proxy>"u"?q:Proxy,"%RangeError%":iS,"%ReferenceError%":sS,"%Reflect%":typeof Reflect>"u"?q:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?q:Set,"%SetIteratorPrototype%":typeof Set>"u"||!Qr||!Te?q:Te(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?q:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":Qr&&Te?Te(""[Symbol.iterator]()):q,"%Symbol%":Qr?Symbol:q,"%SyntaxError%":Vi,"%ThrowTypeError%":gS,"%TypedArray%":yS,"%TypeError%":yi,"%Uint8Array%":typeof Uint8Array>"u"?q:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?q:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?q:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?q:Uint32Array,"%URIError%":oS,"%WeakMap%":typeof WeakMap>"u"?q:WeakMap,"%WeakRef%":typeof WeakRef>"u"?q:WeakRef,"%WeakSet%":typeof WeakSet>"u"?q:WeakSet,"%Function.prototype.call%":Uo,"%Function.prototype.apply%":Em,"%Object.defineProperty%":fS,"%Object.getPrototypeOf%":mS,"%Math.abs%":aS,"%Math.floor%":lS,"%Math.max%":cS,"%Math.min%":uS,"%Math.pow%":hS,"%Math.round%":dS,"%Math.sign%":pS,"%Reflect.getPrototypeOf%":vS};if(Te)try{null.error}catch(n){var bS=Te(Te(n));Lr["%Error.prototype%"]=bS}var wS=function n(t){var e;if(t==="%AsyncFunction%")e=yc("async function () {}");else if(t==="%GeneratorFunction%")e=yc("function* () {}");else if(t==="%AsyncGeneratorFunction%")e=yc("async function* () {}");else if(t==="%AsyncGenerator%"){var r=n("%AsyncGeneratorFunction%");r&&(e=r.prototype)}else if(t==="%AsyncIteratorPrototype%"){var i=n("%AsyncGenerator%");i&&Te&&(e=Te(i.prototype))}return Lr[t]=e,e},bp={__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"]},Fo=No,Ja=En,SS=Fo.call(Uo,Array.prototype.concat),_S=Fo.call(Em,Array.prototype.splice),wp=Fo.call(Uo,String.prototype.replace),Qa=Fo.call(Uo,String.prototype.slice),kS=Fo.call(Uo,RegExp.prototype.exec),ES=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,xS=/\\(\\)?/g,AS=function(t){var e=Qa(t,0,1),r=Qa(t,-1);if(e==="%"&&r!=="%")throw new Vi("invalid intrinsic syntax, expected closing `%`");if(r==="%"&&e!=="%")throw new Vi("invalid intrinsic syntax, expected opening `%`");var i=[];return wp(t,ES,function(s,o,a,c){i[i.length]=a?wp(c,xS,"$1"):o||s}),i},$S=function(t,e){var r=t,i;if(Ja(bp,r)&&(i=bp[r],r="%"+i[0]+"%"),Ja(Lr,r)){var s=Lr[r];if(s===ii&&(s=wS(r)),typeof s>"u"&&!e)throw new yi("intrinsic "+t+" exists, but is not available. Please file an issue!");return{alias:i,name:r,value:s}}throw new Vi("intrinsic "+t+" does not exist!")},yt=function(t,e){if(typeof t!="string"||t.length===0)throw new yi("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof e!="boolean")throw new yi('"allowMissing" argument must be a boolean');if(kS(/^%?[^%]*%?$/,t)===null)throw new Vi("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var r=AS(t),i=r.length>0?r[0]:"",s=$S("%"+i+"%",e),o=s.name,a=s.value,c=!1,u=s.alias;u&&(i=u[0],_S(r,SS([0,1],u)));for(var h=1,p=!0;h<r.length;h+=1){var v=r[h],m=Qa(v,0,1),_=Qa(v,-1);if((m==='"'||m==="'"||m==="`"||_==='"'||_==="'"||_==="`")&&m!==_)throw new Vi("property names with quotes must have matching quotes");if((v==="constructor"||!p)&&(c=!0),i+="."+v,o="%"+i+"%",Ja(Lr,o))a=Lr[o];else if(a!=null){if(!(v in a)){if(!e)throw new yi("base intrinsic for "+t+" exists, but the property is not available.");return}if(Ns&&h+1>=r.length){var k=Ns(a,v);p=!!k,p&&"get"in k&&!("originalValue"in k.get)?a=k.get:a=a[v]}else p=Ja(a,v),a=a[v];p&&!c&&(Lr[o]=a)}}return a},wc,Sp;function Xn(){if(Sp)return wc;Sp=1;var n=yt,t=Ol,e=t([n("%String.prototype.indexOf%")]);return wc=function(i,s){var o=n(i,!!s);return typeof o=="function"&&e(i,".prototype.")>-1?t([o]):o},wc}var Sc,_p;function Dh(){if(_p)return Sc;_p=1;var n=yt,t=n("%Array%"),e=!t.isArray&&Xn()("Object.prototype.toString");return Sc=t.isArray||function(i){return e(i)==="[object Array]"},Sc}var TS=zl,kp=Mo,xm=TS.hasArrayLengthDefineBug(),IS=xm&&Dh(),CS=Xn(),RS=CS("Object.prototype.propertyIsEnumerable"),Lh=function(t,e,r,i,s,o){if(!kp){if(!t(o)||!o["[[Configurable]]"]||!o["[[Writable]]"]||s in i&&RS(i,s)!==!!o["[[Enumerable]]"])return!1;var a=o["[[Value]]"];return i[s]=a,e(i[s],a)}return xm&&s==="length"&&"[[Value]]"in o&&IS(i)&&i.length!==o["[[Value]]"]?(i.length=o["[[Value]]"],i.length===o["[[Value]]"]):(kp(i,s,r(o)),!0)},PS=X,hs=En,DS={__proto__:null,"[[Configurable]]":!0,"[[Enumerable]]":!0,"[[Get]]":!0,"[[Set]]":!0,"[[Value]]":!0,"[[Writable]]":!0},Ji=function(t){if(!t||typeof t!="object")return!1;for(var e in t)if(hs(t,e)&&!DS[e])return!1;var r=hs(t,"[[Value]]")||hs(t,"[[Writable]]"),i=hs(t,"[[Get]]")||hs(t,"[[Set]]");if(r&&i)throw new PS("Property Descriptors may not be both accessor and data descriptors");return!0},Am=function(t){if(typeof t>"u")return t;var e={};return"[[Value]]"in t&&(e.value=t["[[Value]]"]),"[[Writable]]"in t&&(e.writable=!!t["[[Writable]]"]),"[[Get]]"in t&&(e.get=t["[[Get]]"]),"[[Set]]"in t&&(e.set=t["[[Set]]"]),"[[Enumerable]]"in t&&(e.enumerable=!!t["[[Enumerable]]"]),"[[Configurable]]"in t&&(e.configurable=!!t["[[Configurable]]"]),e},LS=X,zS=Ji,OS=Am,$m=function(t){if(typeof t<"u"&&!zS(t))throw new LS("Assertion failed: `Desc` must be a Property Descriptor");return OS(t)},MS=X,Ep=En,NS=Ji,Tm=function(t){if(typeof t>"u")return!1;if(!NS(t))throw new MS("Assertion failed: `Desc` must be a Property Descriptor");return!(!Ep(t,"[[Value]]")&&!Ep(t,"[[Writable]]"))},Qi=function(t){return typeof t=="string"||typeof t=="symbol"},xp=Ih,Im=function(t,e){return t===e?t===0?1/t===1/e:!0:xp(t)&&xp(e)},Ap=X,US=kn,FS=Lh,HS=$m,WS=Tm,ZS=Qi,VS=Im,zh=function(t,e,r){if(!US(t))throw new Ap("Assertion failed: Type(O) is not Object");if(!ZS(e))throw new Ap("Assertion failed: P is not a Property Key");var i={"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Value]]":r,"[[Writable]]":!0};return FS(WS,VS,HS,t,e,i)},Cm=Function.prototype.toString,fi=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,pu,Ta;if(typeof fi=="function"&&typeof Object.defineProperty=="function")try{pu=Object.defineProperty({},"length",{get:function(){throw Ta}}),Ta={},fi(function(){throw 42},null,pu)}catch(n){n!==Ta&&(fi=null)}else fi=null;var BS=/^\s*class\b/,fu=function(t){try{var e=Cm.call(t);return BS.test(e)}catch{return!1}},_c=function(t){try{return fu(t)?!1:(Cm.call(t),!0)}catch{return!1}},Ia=Object.prototype.toString,jS="[object Object]",GS="[object Function]",qS="[object GeneratorFunction]",YS="[object HTMLAllCollection]",XS="[object HTML document.all class]",KS="[object HTMLCollection]",JS=typeof Symbol=="function"&&!!Symbol.toStringTag,QS=!(0 in[,]),gu=function(){return!1};if(typeof document=="object"){var e_=document.all;Ia.call(e_)===Ia.call(document.all)&&(gu=function(t){if((QS||!t)&&(typeof t>"u"||typeof t=="object"))try{var e=Ia.call(t);return(e===YS||e===XS||e===KS||e===jS)&&t("")==null}catch{}return!1})}var Rm=fi?function(t){if(gu(t))return!0;if(!t||typeof t!="function"&&typeof t!="object")return!1;try{fi(t,null,pu)}catch(e){if(e!==Ta)return!1}return!fu(t)&&_c(t)}:function(t){if(gu(t))return!0;if(!t||typeof t!="function"&&typeof t!="object")return!1;if(JS)return _c(t);if(fu(t))return!1;var e=Ia.call(t);return e!==GS&&e!==qS&&!/^\[object HTML/.test(e)?!1:_c(t)},t_=Rm,n_=function(t){return!!t},Dt=En,oa=X,r_=kn,$p=t_,kc=n_,i_=function(t){if(!r_(t))throw new oa("ToPropertyDescriptor requires an object");var e={};if(Dt(t,"enumerable")&&(e["[[Enumerable]]"]=kc(t.enumerable)),Dt(t,"configurable")&&(e["[[Configurable]]"]=kc(t.configurable)),Dt(t,"value")&&(e["[[Value]]"]=t.value),Dt(t,"writable")&&(e["[[Writable]]"]=kc(t.writable)),Dt(t,"get")){var r=t.get;if(typeof r<"u"&&!$p(r))throw new oa("getter must be a function");e["[[Get]]"]=r}if(Dt(t,"set")){var i=t.set;if(typeof i<"u"&&!$p(i))throw new oa("setter must be a function");e["[[Set]]"]=i}if((Dt(e,"[[Get]]")||Dt(e,"[[Set]]"))&&(Dt(e,"[[Value]]")||Dt(e,"[[Writable]]")))throw new oa("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute");return e},Ec=X,s_=kn,Tp=Ji,o_=Lh,a_=$m,l_=Tm,c_=Qi,u_=Im,h_=i_,d_=function(t,e,r){if(!s_(t))throw new Ec("Assertion failed: Type(O) is not Object");if(!c_(e))throw new Ec("Assertion failed: P is not a Property Key");var i=Tp(r)?r:h_(r);if(!Tp(i))throw new Ec("Assertion failed: Desc is not a valid Property Descriptor");return o_(l_,u_,a_,t,e,i)},Ip=X,p_=kn,f_=d_,g_=Qi,m_=function(t,e,r){if(!p_(t))throw new Ip("Assertion failed: Type(O) is not Object");if(!g_(e))throw new Ip("Assertion failed: P is not a Property Key");var i={"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Value]]":r,"[[Writable]]":!0};return f_(t,e,i)},v_=typeof Reflect<"u"&&Reflect.setPrototypeOf||null,y_=$h,b_=y_.setPrototypeOf||null,w_=Ol,Cp=Xi,S_=X,Pm={};try{Pm.__proto__=null}catch(n){if(!n||typeof n!="object"||!("code"in n)||n.code!=="ERR_PROTO_ACCESS")throw n}var __=!("toString"in Pm),xc=Cp&&Cp(Object.prototype,"__proto__"),k_=__&&(!!xc&&typeof xc.set=="function"&&w_([xc.set])||function(t,e){if(t==null)throw new S_("set Object.prototype.__proto__ called on null or undefined");return t.__proto__=e,e}),Rp=v_,E_=b_,Pp=k_,x_=X,A_=Rp?function(t,e){if(Rp(t,e))return t;throw new x_("Reflect.setPrototypeOf: failed to set [[Prototype]]")}:E_||(Pp?function(t,e){return Pp(t,e),t}:null),Dp=X,$_=kn,Lp=_m,T_=function(t){if(!$_(t))throw new Dp("Assertion failed: O must be an Object");if(!Lp)throw new Dp("This environment does not support fetching prototypes.");return Lp(t)},I_=X,C_=A_,R_=kn,P_=T_,D_=function(t,e){if(e!==null&&!R_(e))throw new I_("Assertion failed: V must be Object or Null");try{C_(t,e)}catch{return!1}return P_(t)===e},Ac=zh,zp=m_,Dm=D_,L_=zl(),Oh=mm;function Ho(n,t,e){var r=new Oh(e);return Dm(r,Ca),delete r.constructor,zp(r,"error",n),zp(r,"suppressed",t),r}L_&&Object.defineProperty(Ho,"prototype",{writable:!1});var Ca=Ho.prototype;if(!Ac(Ca,"constructor",Ho)||!Ac(Ca,"message","")||!Ac(Ca,"name","SuppressedError"))throw new Oh("unable to install SuppressedError.prototype properties; please report this!");Dm(Ho.prototype,Oh.prototype);var z_=Ho,O_=z_,Lm=function(){return typeof SuppressedError=="function"?SuppressedError:O_},M_=Wr,Op=Ah(),N_=Lm,U_=function(){var t=N_();return M_(Op,{SuppressedError:t},{SuppressedError:function(){return Op.SuppressedError!==t}}),t};U_();var F_=X,H_=Ji,W_=Am,Z_=function(t){if(typeof t<"u"&&!H_(t))throw new F_("Assertion failed: `Desc` must be a Property Descriptor");return W_(t)},V_=X,Mp=En,B_=Ji,j_=function(t){if(typeof t>"u")return!1;if(!B_(t))throw new V_("Assertion failed: `Desc` must be a Property Descriptor");return!(!Mp(t,"[[Value]]")&&!Mp(t,"[[Writable]]"))},Np=Ih,G_=function(t,e){return t===e?t===0?1/t===1/e:!0:Np(t)&&Np(e)},es=Rm,q_=function(t){return!!t},Lt=En,aa=X,Y_=kn,Up=es,$c=q_,X_=function(t){if(!Y_(t))throw new aa("ToPropertyDescriptor requires an object");var e={};if(Lt(t,"enumerable")&&(e["[[Enumerable]]"]=$c(t.enumerable)),Lt(t,"configurable")&&(e["[[Configurable]]"]=$c(t.configurable)),Lt(t,"value")&&(e["[[Value]]"]=t.value),Lt(t,"writable")&&(e["[[Writable]]"]=$c(t.writable)),Lt(t,"get")){var r=t.get;if(typeof r<"u"&&!Up(r))throw new aa("getter must be a function");e["[[Get]]"]=r}if(Lt(t,"set")){var i=t.set;if(typeof i<"u"&&!Up(i))throw new aa("setter must be a function");e["[[Set]]"]=i}if((Lt(e,"[[Get]]")||Lt(e,"[[Set]]"))&&(Lt(e,"[[Value]]")||Lt(e,"[[Writable]]")))throw new aa("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute");return e},Tc=X,K_=kn,Fp=Ji,J_=Lh,Q_=Z_,ek=j_,tk=Qi,nk=G_,rk=X_,Wo=function(t,e,r){if(!K_(t))throw new Tc("Assertion failed: Type(O) is not Object");if(!tk(e))throw new Tc("Assertion failed: P is not a Property Key");var i=Fp(r)?r:rk(r);if(!Fp(i))throw new Tc("Assertion failed: Desc is not a valid Property Descriptor");return J_(ek,nk,Q_,t,e,i)},ik=Ki(),sk=ik?Symbol.dispose||Symbol("Symbol.dispose"):null,ok=Ki,ak=sk,Mh=function(){return ok()&&Symbol.dispose||ak},lk=Ch,ck=Wo,uk=Mh,hk=function(){var t=uk();return lk()&&ck(Symbol,"dispose",{"[[Configurable]]":!1,"[[Enumerable]]":!1,"[[Writable]]":!1,"[[Value]]":t}),t},dk=Ki(),pk=dk?Symbol.asyncDispose||Symbol("Symbol.asyncDispose"):null,fk=Ki,gk=pk,Nh=function(){return fk()&&Symbol.asyncDispose||gk},mk=Ch,vk=Wo,yk=Nh,bk=function(){var t=yk();return mk()&&vk(Symbol,"asyncDispose",{"[[Configurable]]":!1,"[[Enumerable]]":!1,"[[Writable]]":!1,"[[Value]]":t}),t},wk=Dh(),Sk=yt,_k=Xn(),kk=X,Ek=wk,xk=Sk("%Reflect.apply%",!0)||_k("Function.prototype.apply"),Ml=function(t,e){var r=arguments.length>2?arguments[2]:[];if(!Ek(r))throw new kk("Assertion failed: optional `argumentsList`, if provided, must be a List");return xk(t,e,r)};const Ak={},$k=Object.freeze(Object.defineProperty({__proto__:null,default:Ak},Symbol.toStringTag,{value:"Module"})),Tk=Jw($k);var Uh=typeof Map=="function"&&Map.prototype,Ic=Object.getOwnPropertyDescriptor&&Uh?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,el=Uh&&Ic&&typeof Ic.get=="function"?Ic.get:null,Hp=Uh&&Map.prototype.forEach,Fh=typeof Set=="function"&&Set.prototype,Cc=Object.getOwnPropertyDescriptor&&Fh?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,tl=Fh&&Cc&&typeof Cc.get=="function"?Cc.get:null,Wp=Fh&&Set.prototype.forEach,Ik=typeof WeakMap=="function"&&WeakMap.prototype,Ps=Ik?WeakMap.prototype.has:null,Ck=typeof WeakSet=="function"&&WeakSet.prototype,Ds=Ck?WeakSet.prototype.has:null,Rk=typeof WeakRef=="function"&&WeakRef.prototype,Zp=Rk?WeakRef.prototype.deref:null,Pk=Boolean.prototype.valueOf,Dk=Object.prototype.toString,Lk=Function.prototype.toString,zk=String.prototype.match,Hh=String.prototype.slice,Wn=String.prototype.replace,Ok=String.prototype.toUpperCase,Vp=String.prototype.toLowerCase,zm=RegExp.prototype.test,Bp=Array.prototype.concat,Qt=Array.prototype.join,Mk=Array.prototype.slice,jp=Math.floor,mu=typeof BigInt=="function"?BigInt.prototype.valueOf:null,Rc=Object.getOwnPropertySymbols,vu=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,Bi=typeof Symbol=="function"&&typeof Symbol.iterator=="object",Ls=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===Bi||!0)?Symbol.toStringTag:null,Om=Object.prototype.propertyIsEnumerable,Gp=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(n){return n.__proto__}:null);function qp(n,t){if(n===1/0||n===-1/0||n!==n||n&&n>-1e3&&n<1e3||zm.call(/e/,t))return t;var e=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof n=="number"){var r=n<0?-jp(-n):jp(n);if(r!==n){var i=String(r),s=Hh.call(t,i.length+1);return Wn.call(i,e,"$&_")+"."+Wn.call(Wn.call(s,/([0-9]{3})/g,"$&_"),/_$/,"")}}return Wn.call(t,e,"$&_")}var yu=Tk,Yp=yu.custom,Xp=Um(Yp)?Yp:null,Mm={__proto__:null,double:'"',single:"'"},Nk={__proto__:null,double:/(["\\])/g,single:/(['\\])/g},ts=function n(t,e,r,i){var s=e||{};if(dn(s,"quoteStyle")&&!dn(Mm,s.quoteStyle))throw new TypeError('option "quoteStyle" must be "single" or "double"');if(dn(s,"maxStringLength")&&(typeof s.maxStringLength=="number"?s.maxStringLength<0&&s.maxStringLength!==1/0:s.maxStringLength!==null))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var o=dn(s,"customInspect")?s.customInspect:!0;if(typeof o!="boolean"&&o!=="symbol")throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(dn(s,"indent")&&s.indent!==null&&s.indent!==" "&&!(parseInt(s.indent,10)===s.indent&&s.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(dn(s,"numericSeparator")&&typeof s.numericSeparator!="boolean")throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var a=s.numericSeparator;if(typeof t>"u")return"undefined";if(t===null)return"null";if(typeof t=="boolean")return t?"true":"false";if(typeof t=="string")return Hm(t,s);if(typeof t=="number"){if(t===0)return 1/0/t>0?"0":"-0";var c=String(t);return a?qp(t,c):c}if(typeof t=="bigint"){var u=String(t)+"n";return a?qp(t,u):u}var h=typeof s.depth>"u"?5:s.depth;if(typeof r>"u"&&(r=0),r>=h&&h>0&&typeof t=="object")return bu(t)?"[Array]":"[Object]";var p=nE(s,r);if(typeof i>"u")i=[];else if(Fm(i,t)>=0)return"[Circular]";function v(Ct,xn,rc){if(xn&&(i=Mk.call(i),i.push(xn)),rc){var Ko={depth:s.depth};return dn(s,"quoteStyle")&&(Ko.quoteStyle=s.quoteStyle),n(Ct,Ko,r+1,i)}return n(Ct,s,r+1,i)}if(typeof t=="function"&&!Kp(t)){var m=Gk(t),_=la(t,v);return"[Function"+(m?": "+m:" (anonymous)")+"]"+(_.length>0?" { "+Qt.call(_,", ")+" }":"")}if(Um(t)){var k=Bi?Wn.call(String(t),/^(Symbol\(.*\))_[^)]*$/,"$1"):vu.call(t);return typeof t=="object"&&!Bi?ds(k):k}if(Qk(t)){for(var T="<"+Vp.call(String(t.nodeName)),P=t.attributes||[],R=0;R<P.length;R++)T+=" "+P[R].name+"="+Nm(Uk(P[R].value),"double",s);return T+=">",t.childNodes&&t.childNodes.length&&(T+="..."),T+="</"+Vp.call(String(t.nodeName))+">",T}if(bu(t)){if(t.length===0)return"[]";var W=la(t,v);return p&&!tE(W)?"["+wu(W,p)+"]":"[ "+Qt.call(W,", ")+" ]"}if(Hk(t)){var N=la(t,v);return!("cause"in Error.prototype)&&"cause"in t&&!Om.call(t,"cause")?"{ ["+String(t)+"] "+Qt.call(Bp.call("[cause]: "+v(t.cause),N),", ")+" }":N.length===0?"["+String(t)+"]":"{ ["+String(t)+"] "+Qt.call(N,", ")+" }"}if(typeof t=="object"&&o){if(Xp&&typeof t[Xp]=="function"&&yu)return yu(t,{depth:h-r});if(o!=="symbol"&&typeof t.inspect=="function")return t.inspect()}if(qk(t)){var F=[];return Hp&&Hp.call(t,function(Ct,xn){F.push(v(xn,t,!0)+" => "+v(Ct,t))}),Jp("Map",el.call(t),F,p)}if(Kk(t)){var Y=[];return Wp&&Wp.call(t,function(Ct){Y.push(v(Ct,t))}),Jp("Set",tl.call(t),Y,p)}if(Yk(t))return Pc("WeakMap");if(Jk(t))return Pc("WeakSet");if(Xk(t))return Pc("WeakRef");if(Zk(t))return ds(v(Number(t)));if(Bk(t))return ds(v(mu.call(t)));if(Vk(t))return ds(Pk.call(t));if(Wk(t))return ds(v(String(t)));if(typeof window<"u"&&t===window)return"{ [object Window] }";if(typeof globalThis<"u"&&t===globalThis||typeof ur<"u"&&t===ur)return"{ [object globalThis] }";if(!Fk(t)&&!Kp(t)){var j=la(t,v),oe=Gp?Gp(t)===Object.prototype:t instanceof Object||t.constructor===Object,wt=t instanceof Object?"":"null prototype",er=!oe&&Ls&&Object(t)===t&&Ls in t?Hh.call(Kn(t),8,-1):wt?"Object":"",Re=oe||typeof t.constructor!="function"?"":t.constructor.name?t.constructor.name+" ":"",tr=Re+(er||wt?"["+Qt.call(Bp.call([],er||[],wt||[]),": ")+"] ":"");return j.length===0?tr+"{}":p?tr+"{"+wu(j,p)+"}":tr+"{ "+Qt.call(j,", ")+" }"}return String(t)};function Nm(n,t,e){var r=e.quoteStyle||t,i=Mm[r];return i+n+i}function Uk(n){return Wn.call(String(n),/"/g,""")}function Zr(n){return!Ls||!(typeof n=="object"&&(Ls in n||typeof n[Ls]<"u"))}function bu(n){return Kn(n)==="[object Array]"&&Zr(n)}function Fk(n){return Kn(n)==="[object Date]"&&Zr(n)}function Kp(n){return Kn(n)==="[object RegExp]"&&Zr(n)}function Hk(n){return Kn(n)==="[object Error]"&&Zr(n)}function Wk(n){return Kn(n)==="[object String]"&&Zr(n)}function Zk(n){return Kn(n)==="[object Number]"&&Zr(n)}function Vk(n){return Kn(n)==="[object Boolean]"&&Zr(n)}function Um(n){if(Bi)return n&&typeof n=="object"&&n instanceof Symbol;if(typeof n=="symbol")return!0;if(!n||typeof n!="object"||!vu)return!1;try{return vu.call(n),!0}catch{}return!1}function Bk(n){if(!n||typeof n!="object"||!mu)return!1;try{return mu.call(n),!0}catch{}return!1}var jk=Object.prototype.hasOwnProperty||function(n){return n in this};function dn(n,t){return jk.call(n,t)}function Kn(n){return Dk.call(n)}function Gk(n){if(n.name)return n.name;var t=zk.call(Lk.call(n),/^function\s*([\w$]+)/);return t?t[1]:null}function Fm(n,t){if(n.indexOf)return n.indexOf(t);for(var e=0,r=n.length;e<r;e++)if(n[e]===t)return e;return-1}function qk(n){if(!el||!n||typeof n!="object")return!1;try{el.call(n);try{tl.call(n)}catch{return!0}return n instanceof Map}catch{}return!1}function Yk(n){if(!Ps||!n||typeof n!="object")return!1;try{Ps.call(n,Ps);try{Ds.call(n,Ds)}catch{return!0}return n instanceof WeakMap}catch{}return!1}function Xk(n){if(!Zp||!n||typeof n!="object")return!1;try{return Zp.call(n),!0}catch{}return!1}function Kk(n){if(!tl||!n||typeof n!="object")return!1;try{tl.call(n);try{el.call(n)}catch{return!0}return n instanceof Set}catch{}return!1}function Jk(n){if(!Ds||!n||typeof n!="object")return!1;try{Ds.call(n,Ds);try{Ps.call(n,Ps)}catch{return!0}return n instanceof WeakSet}catch{}return!1}function Qk(n){return!n||typeof n!="object"?!1:typeof HTMLElement<"u"&&n instanceof HTMLElement?!0:typeof n.nodeName=="string"&&typeof n.getAttribute=="function"}function Hm(n,t){if(n.length>t.maxStringLength){var e=n.length-t.maxStringLength,r="... "+e+" more character"+(e>1?"s":"");return Hm(Hh.call(n,0,t.maxStringLength),t)+r}var i=Nk[t.quoteStyle||"single"];i.lastIndex=0;var s=Wn.call(Wn.call(n,i,"\\$1"),/[\x00-\x1f]/g,eE);return Nm(s,"single",t)}function eE(n){var t=n.charCodeAt(0),e={8:"b",9:"t",10:"n",12:"f",13:"r"}[t];return e?"\\"+e:"\\x"+(t<16?"0":"")+Ok.call(t.toString(16))}function ds(n){return"Object("+n+")"}function Pc(n){return n+" { ? }"}function Jp(n,t,e,r){var i=r?wu(e,r):Qt.call(e,", ");return n+" ("+t+") {"+i+"}"}function tE(n){for(var t=0;t<n.length;t++)if(Fm(n[t],`
|
|
2
|
-
`)>=0)return!1;return!0}function
|
|
1
|
+
var n0=Object.defineProperty;var lp=n=>{throw TypeError(n)};var r0=(n,t,e)=>t in n?n0(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var g=(n,t,e)=>r0(n,typeof t!="symbol"?t+"":t,e),bc=(n,t,e)=>t.has(n)||lp("Cannot "+e);var l=(n,t,e)=>(bc(n,t,"read from private field"),e?e.call(n):t.get(n)),w=(n,t,e)=>t.has(n)?lp("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(n):t.set(n,e),S=(n,t,e,r)=>(bc(n,t,"write to private field"),r?r.call(n,e):t.set(n,e),e),f=(n,t,e)=>(bc(n,t,"access private method"),e);var cp=(n,t,e,r)=>({set _(i){S(n,t,i,e)},get _(){return l(n,t,r)}});(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const s of i)if(s.type==="childList")for(const o of s.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function e(i){const s={};return i.integrity&&(s.integrity=i.integrity),i.referrerPolicy&&(s.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?s.credentials="include":i.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function r(i){if(i.ep)return;i.ep=!0;const s=e(i);fetch(i.href,s)}})();var ur=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function i0(n){if(n.__esModule)return n;var t=n.default;if(typeof t=="function"){var e=function r(){return this instanceof r?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};e.prototype=t.prototype}else e={};return Object.defineProperty(e,"__esModule",{value:!0}),Object.keys(n).forEach(function(r){var i=Object.getOwnPropertyDescriptor(n,r);Object.defineProperty(e,r,i.get?i:{enumerable:!0,get:function(){return n[r]}})}),e}var up=Object.prototype.toString,dm=function(t){var e=up.call(t),r=e==="[object Arguments]";return r||(r=e!=="[object Array]"&&t!==null&&typeof t=="object"&&typeof t.length=="number"&&t.length>=0&&up.call(t.callee)==="[object Function]"),r},wc,hp;function s0(){if(hp)return wc;hp=1;var n;if(!Object.keys){var t=Object.prototype.hasOwnProperty,e=Object.prototype.toString,r=dm,i=Object.prototype.propertyIsEnumerable,s=!i.call({toString:null},"toString"),o=i.call(function(){},"prototype"),a=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],c=function(v){var m=v.constructor;return m&&m.prototype===v},u={$applicationCache:!0,$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$onmozfullscreenchange:!0,$onmozfullscreenerror:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},h=function(){if(typeof window>"u")return!1;for(var v in window)try{if(!u["$"+v]&&t.call(window,v)&&window[v]!==null&&typeof window[v]=="object")try{c(window[v])}catch{return!0}}catch{return!0}return!1}(),p=function(v){if(typeof window>"u"||!h)return c(v);try{return c(v)}catch{return!1}};n=function(m){var _=m!==null&&typeof m=="object",k=e.call(m)==="[object Function]",T=r(m),P=_&&e.call(m)==="[object String]",R=[];if(!_&&!k&&!T)throw new TypeError("Object.keys called on a non-object");var W=o&&k;if(P&&m.length>0&&!t.call(m,0))for(var N=0;N<m.length;++N)R.push(String(N));if(T&&m.length>0)for(var F=0;F<m.length;++F)R.push(String(F));else for(var Y in m)!(W&&Y==="prototype")&&t.call(m,Y)&&R.push(String(Y));if(s)for(var j=p(m),oe=0;oe<a.length;++oe)!(j&&a[oe]==="constructor")&&t.call(m,a[oe])&&R.push(a[oe]);return R}}return wc=n,wc}var o0=Array.prototype.slice,a0=dm,dp=Object.keys,Ta=dp?function(t){return dp(t)}:s0(),pp=Object.keys;Ta.shim=function(){if(Object.keys){var t=function(){var e=Object.keys(arguments);return e&&e.length===arguments.length}(1,2);t||(Object.keys=function(r){return a0(r)?pp(o0.call(r)):pp(r)})}else Object.keys=Ta;return Object.keys||Ta};var l0=Ta,Ia=Object.defineProperty||!1;if(Ia)try{Ia({},"a",{value:1})}catch{Ia=!1}var Ho=Ia,_n=SyntaxError,X=TypeError,c0=Object.getOwnPropertyDescriptor,Ca=c0;if(Ca)try{Ca([],"length")}catch{Ca=null}var Ki=Ca,fp=Ho,u0=_n,Jr=X,gp=Ki,pm=function(t,e,r){if(!t||typeof t!="object"&&typeof t!="function")throw new Jr("`obj` must be an object or a function`");if(typeof e!="string"&&typeof e!="symbol")throw new Jr("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new Jr("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new Jr("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new Jr("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new Jr("`loose`, if provided, must be a boolean");var i=arguments.length>3?arguments[3]:null,s=arguments.length>4?arguments[4]:null,o=arguments.length>5?arguments[5]:null,a=arguments.length>6?arguments[6]:!1,c=!!gp&&gp(t,e);if(fp)fp(t,e,{configurable:o===null&&c?c.configurable:!o,enumerable:i===null&&c?c.enumerable:!i,value:r,writable:s===null&&c?c.writable:!s});else if(a||!i&&!s&&!o)t[e]=r;else throw new u0("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},mu=Ho,fm=function(){return!!mu};fm.hasArrayLengthDefineBug=function(){if(!mu)return null;try{return mu([],"length",{value:1}).length!==1}catch{return!0}};var Ul=fm,h0=l0,d0=typeof Symbol=="function"&&typeof Symbol("foo")=="symbol",p0=Object.prototype.toString,f0=Array.prototype.concat,mp=pm,g0=function(n){return typeof n=="function"&&p0.call(n)==="[object Function]"},gm=Ul(),m0=function(n,t,e,r){if(t in n){if(r===!0){if(n[t]===e)return}else if(!g0(r)||!r())return}gm?mp(n,t,e,!0):mp(n,t,e)},mm=function(n,t){var e=arguments.length>2?arguments[2]:{},r=h0(t);d0&&(r=f0.call(r,Object.getOwnPropertySymbols(t)));for(var i=0;i<r.length;i+=1)m0(n,r[i],t[r[i]],e[r[i]])};mm.supportsDescriptors=!!gm;var Wr=mm,Ra={exports:{}};typeof self<"u"?Ra.exports=self:typeof window<"u"?Ra.exports=window:Ra.exports=Function("return this")();var vm=Ra.exports,v0=vm,ym=function(){return typeof ur!="object"||!ur||ur.Math!==Math||ur.Array!==Array?v0:ur},y0=Wr,b0=Ki,w0=ym,S0=function(){var t=w0();if(y0.supportsDescriptors){var e=b0(t,"globalThis");(!e||e.configurable&&(e.enumerable||!e.writable||globalThis!==t))&&Object.defineProperty(t,"globalThis",{configurable:!0,enumerable:!1,value:t,writable:!0})}else(typeof globalThis!="object"||globalThis!==t)&&(t.globalThis=t);return t},_0=Wr,k0=vm,bm=ym,x0=S0,E0=bm(),wm=function(){return E0};_0(wm,{getPolyfill:bm,implementation:k0,shim:x0});var Rh=wm,kn=function(t){return!!t&&(typeof t=="function"||typeof t=="object")},Ph=Object,Sm=Error,A0=EvalError,$0=RangeError,Dh=ReferenceError,T0=URIError,I0=Math.abs,C0=Math.floor,R0=Math.max,P0=Math.min,D0=Math.pow,L0=Math.round,Lh=Number.isNaN||function(t){return t!==t},z0=Lh,O0=function(t){return z0(t)||t===0?t:t<0?-1:1},Ji=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var t={},e=Symbol("test"),r=Object(e);if(typeof e=="string"||Object.prototype.toString.call(e)!=="[object Symbol]"||Object.prototype.toString.call(r)!=="[object Symbol]")return!1;var i=42;t[e]=i;for(var s in t)return!1;if(typeof Object.keys=="function"&&Object.keys(t).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(t).length!==0)return!1;var o=Object.getOwnPropertySymbols(t);if(o.length!==1||o[0]!==e||!Object.prototype.propertyIsEnumerable.call(t,e))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var a=Object.getOwnPropertyDescriptor(t,e);if(a.value!==i||a.enumerable!==!0)return!1}return!0},vp=typeof Symbol<"u"&&Symbol,M0=Ji,zh=function(){return typeof vp!="function"||typeof Symbol!="function"||typeof vp("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:M0()},_m=typeof Reflect<"u"&&Reflect.getPrototypeOf||null,N0=Ph,km=N0.getPrototypeOf||null,U0="Function.prototype.bind called on incompatible ",F0=Object.prototype.toString,H0=Math.max,W0="[object Function]",yp=function(t,e){for(var r=[],i=0;i<t.length;i+=1)r[i]=t[i];for(var s=0;s<e.length;s+=1)r[s+t.length]=e[s];return r},Z0=function(t,e){for(var r=[],i=e,s=0;i<t.length;i+=1,s+=1)r[s]=t[i];return r},V0=function(n,t){for(var e="",r=0;r<n.length;r+=1)e+=n[r],r+1<n.length&&(e+=t);return e},B0=function(t){var e=this;if(typeof e!="function"||F0.apply(e)!==W0)throw new TypeError(U0+e);for(var r=Z0(arguments,1),i,s=function(){if(this instanceof i){var h=e.apply(this,yp(r,arguments));return Object(h)===h?h:this}return e.apply(t,yp(r,arguments))},o=H0(0,e.length-r.length),a=[],c=0;c<o;c++)a[c]="$"+c;if(i=Function("binder","return function ("+V0(a,",")+"){ return binder.apply(this,arguments); }")(s),e.prototype){var u=function(){};u.prototype=e.prototype,i.prototype=new u,u.prototype=null}return i},j0=B0,Wo=Function.prototype.bind||j0,Oh=Function.prototype.call,Mh=Function.prototype.apply,G0=typeof Reflect<"u"&&Reflect&&Reflect.apply,q0=Wo,Y0=Mh,X0=Oh,K0=G0,xm=K0||q0.call(X0,Y0),J0=Wo,Q0=X,eS=Oh,tS=xm,Fl=function(t){if(t.length<1||typeof t[0]!="function")throw new Q0("a function is required");return tS(J0,eS,t)},nS=Fl,bp=Ki,Em;try{Em=[].__proto__===Array.prototype}catch(n){if(!n||typeof n!="object"||!("code"in n)||n.code!=="ERR_PROTO_ACCESS")throw n}var Sc=!!Em&&bp&&bp(Object.prototype,"__proto__"),Am=Object,wp=Am.getPrototypeOf,rS=Sc&&typeof Sc.get=="function"?nS([Sc.get]):typeof wp=="function"?function(t){return wp(t==null?t:Am(t))}:!1,Sp=_m,_p=km,kp=rS,$m=Sp?function(t){return Sp(t)}:_p?function(t){if(!t||typeof t!="object"&&typeof t!="function")throw new TypeError("getProto: not an object");return _p(t)}:kp?function(t){return kp(t)}:null,iS=Function.prototype.call,sS=Object.prototype.hasOwnProperty,oS=Wo,xn=oS.call(iS,sS),q,aS=Ph,lS=Sm,cS=A0,uS=$0,hS=Dh,Bi=_n,yi=X,dS=T0,pS=I0,fS=C0,gS=R0,mS=P0,vS=D0,yS=L0,bS=O0,Tm=Function,_c=function(n){try{return Tm('"use strict"; return ('+n+").constructor;")()}catch{}},Us=Ki,wS=Ho,kc=function(){throw new yi},SS=Us?function(){try{return arguments.callee,kc}catch{try{return Us(arguments,"callee").get}catch{return kc}}}():kc,Qr=zh(),Te=$m,_S=km,kS=_m,Im=Mh,Zo=Oh,ii={},xS=typeof Uint8Array>"u"||!Te?q:Te(Uint8Array),Lr={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?q:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?q:ArrayBuffer,"%ArrayIteratorPrototype%":Qr&&Te?Te([][Symbol.iterator]()):q,"%AsyncFromSyncIteratorPrototype%":q,"%AsyncFunction%":ii,"%AsyncGenerator%":ii,"%AsyncGeneratorFunction%":ii,"%AsyncIteratorPrototype%":ii,"%Atomics%":typeof Atomics>"u"?q:Atomics,"%BigInt%":typeof BigInt>"u"?q:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?q:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?q:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?q:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":lS,"%eval%":eval,"%EvalError%":cS,"%Float16Array%":typeof Float16Array>"u"?q:Float16Array,"%Float32Array%":typeof Float32Array>"u"?q:Float32Array,"%Float64Array%":typeof Float64Array>"u"?q:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?q:FinalizationRegistry,"%Function%":Tm,"%GeneratorFunction%":ii,"%Int8Array%":typeof Int8Array>"u"?q:Int8Array,"%Int16Array%":typeof Int16Array>"u"?q:Int16Array,"%Int32Array%":typeof Int32Array>"u"?q:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":Qr&&Te?Te(Te([][Symbol.iterator]())):q,"%JSON%":typeof JSON=="object"?JSON:q,"%Map%":typeof Map>"u"?q:Map,"%MapIteratorPrototype%":typeof Map>"u"||!Qr||!Te?q:Te(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":aS,"%Object.getOwnPropertyDescriptor%":Us,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?q:Promise,"%Proxy%":typeof Proxy>"u"?q:Proxy,"%RangeError%":uS,"%ReferenceError%":hS,"%Reflect%":typeof Reflect>"u"?q:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?q:Set,"%SetIteratorPrototype%":typeof Set>"u"||!Qr||!Te?q:Te(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?q:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":Qr&&Te?Te(""[Symbol.iterator]()):q,"%Symbol%":Qr?Symbol:q,"%SyntaxError%":Bi,"%ThrowTypeError%":SS,"%TypedArray%":xS,"%TypeError%":yi,"%Uint8Array%":typeof Uint8Array>"u"?q:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?q:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?q:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?q:Uint32Array,"%URIError%":dS,"%WeakMap%":typeof WeakMap>"u"?q:WeakMap,"%WeakRef%":typeof WeakRef>"u"?q:WeakRef,"%WeakSet%":typeof WeakSet>"u"?q:WeakSet,"%Function.prototype.call%":Zo,"%Function.prototype.apply%":Im,"%Object.defineProperty%":wS,"%Object.getPrototypeOf%":_S,"%Math.abs%":pS,"%Math.floor%":fS,"%Math.max%":gS,"%Math.min%":mS,"%Math.pow%":vS,"%Math.round%":yS,"%Math.sign%":bS,"%Reflect.getPrototypeOf%":kS};if(Te)try{null.error}catch(n){var ES=Te(Te(n));Lr["%Error.prototype%"]=ES}var AS=function n(t){var e;if(t==="%AsyncFunction%")e=_c("async function () {}");else if(t==="%GeneratorFunction%")e=_c("function* () {}");else if(t==="%AsyncGeneratorFunction%")e=_c("async function* () {}");else if(t==="%AsyncGenerator%"){var r=n("%AsyncGeneratorFunction%");r&&(e=r.prototype)}else if(t==="%AsyncIteratorPrototype%"){var i=n("%AsyncGenerator%");i&&Te&&(e=Te(i.prototype))}return Lr[t]=e,e},xp={__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"]},Vo=Wo,nl=xn,$S=Vo.call(Zo,Array.prototype.concat),TS=Vo.call(Im,Array.prototype.splice),Ep=Vo.call(Zo,String.prototype.replace),rl=Vo.call(Zo,String.prototype.slice),IS=Vo.call(Zo,RegExp.prototype.exec),CS=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,RS=/\\(\\)?/g,PS=function(t){var e=rl(t,0,1),r=rl(t,-1);if(e==="%"&&r!=="%")throw new Bi("invalid intrinsic syntax, expected closing `%`");if(r==="%"&&e!=="%")throw new Bi("invalid intrinsic syntax, expected opening `%`");var i=[];return Ep(t,CS,function(s,o,a,c){i[i.length]=a?Ep(c,RS,"$1"):o||s}),i},DS=function(t,e){var r=t,i;if(nl(xp,r)&&(i=xp[r],r="%"+i[0]+"%"),nl(Lr,r)){var s=Lr[r];if(s===ii&&(s=AS(r)),typeof s>"u"&&!e)throw new yi("intrinsic "+t+" exists, but is not available. Please file an issue!");return{alias:i,name:r,value:s}}throw new Bi("intrinsic "+t+" does not exist!")},yt=function(t,e){if(typeof t!="string"||t.length===0)throw new yi("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof e!="boolean")throw new yi('"allowMissing" argument must be a boolean');if(IS(/^%?[^%]*%?$/,t)===null)throw new Bi("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var r=PS(t),i=r.length>0?r[0]:"",s=DS("%"+i+"%",e),o=s.name,a=s.value,c=!1,u=s.alias;u&&(i=u[0],TS(r,$S([0,1],u)));for(var h=1,p=!0;h<r.length;h+=1){var v=r[h],m=rl(v,0,1),_=rl(v,-1);if((m==='"'||m==="'"||m==="`"||_==='"'||_==="'"||_==="`")&&m!==_)throw new Bi("property names with quotes must have matching quotes");if((v==="constructor"||!p)&&(c=!0),i+="."+v,o="%"+i+"%",nl(Lr,o))a=Lr[o];else if(a!=null){if(!(v in a)){if(!e)throw new yi("base intrinsic for "+t+" exists, but the property is not available.");return}if(Us&&h+1>=r.length){var k=Us(a,v);p=!!k,p&&"get"in k&&!("originalValue"in k.get)?a=k.get:a=a[v]}else p=nl(a,v),a=a[v];p&&!c&&(Lr[o]=a)}}return a},xc,Ap;function Xn(){if(Ap)return xc;Ap=1;var n=yt,t=Fl,e=t([n("%String.prototype.indexOf%")]);return xc=function(i,s){var o=n(i,!!s);return typeof o=="function"&&e(i,".prototype.")>-1?t([o]):o},xc}var Ec,$p;function Nh(){if($p)return Ec;$p=1;var n=yt,t=n("%Array%"),e=!t.isArray&&Xn()("Object.prototype.toString");return Ec=t.isArray||function(i){return e(i)==="[object Array]"},Ec}var LS=Ul,Tp=Ho,Cm=LS.hasArrayLengthDefineBug(),zS=Cm&&Nh(),OS=Xn(),MS=OS("Object.prototype.propertyIsEnumerable"),Uh=function(t,e,r,i,s,o){if(!Tp){if(!t(o)||!o["[[Configurable]]"]||!o["[[Writable]]"]||s in i&&MS(i,s)!==!!o["[[Enumerable]]"])return!1;var a=o["[[Value]]"];return i[s]=a,e(i[s],a)}return Cm&&s==="length"&&"[[Value]]"in o&&zS(i)&&i.length!==o["[[Value]]"]?(i.length=o["[[Value]]"],i.length===o["[[Value]]"]):(Tp(i,s,r(o)),!0)},NS=X,ds=xn,US={__proto__:null,"[[Configurable]]":!0,"[[Enumerable]]":!0,"[[Get]]":!0,"[[Set]]":!0,"[[Value]]":!0,"[[Writable]]":!0},Qi=function(t){if(!t||typeof t!="object")return!1;for(var e in t)if(ds(t,e)&&!US[e])return!1;var r=ds(t,"[[Value]]")||ds(t,"[[Writable]]"),i=ds(t,"[[Get]]")||ds(t,"[[Set]]");if(r&&i)throw new NS("Property Descriptors may not be both accessor and data descriptors");return!0},Rm=function(t){if(typeof t>"u")return t;var e={};return"[[Value]]"in t&&(e.value=t["[[Value]]"]),"[[Writable]]"in t&&(e.writable=!!t["[[Writable]]"]),"[[Get]]"in t&&(e.get=t["[[Get]]"]),"[[Set]]"in t&&(e.set=t["[[Set]]"]),"[[Enumerable]]"in t&&(e.enumerable=!!t["[[Enumerable]]"]),"[[Configurable]]"in t&&(e.configurable=!!t["[[Configurable]]"]),e},FS=X,HS=Qi,WS=Rm,Pm=function(t){if(typeof t<"u"&&!HS(t))throw new FS("Assertion failed: `Desc` must be a Property Descriptor");return WS(t)},ZS=X,Ip=xn,VS=Qi,Dm=function(t){if(typeof t>"u")return!1;if(!VS(t))throw new ZS("Assertion failed: `Desc` must be a Property Descriptor");return!(!Ip(t,"[[Value]]")&&!Ip(t,"[[Writable]]"))},es=function(t){return typeof t=="string"||typeof t=="symbol"},Cp=Lh,Lm=function(t,e){return t===e?t===0?1/t===1/e:!0:Cp(t)&&Cp(e)},Rp=X,BS=kn,jS=Uh,GS=Pm,qS=Dm,YS=es,XS=Lm,Fh=function(t,e,r){if(!BS(t))throw new Rp("Assertion failed: Type(O) is not Object");if(!YS(e))throw new Rp("Assertion failed: P is not a Property Key");var i={"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Value]]":r,"[[Writable]]":!0};return jS(qS,XS,GS,t,e,i)},zm=Function.prototype.toString,fi=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,vu,Pa;if(typeof fi=="function"&&typeof Object.defineProperty=="function")try{vu=Object.defineProperty({},"length",{get:function(){throw Pa}}),Pa={},fi(function(){throw 42},null,vu)}catch(n){n!==Pa&&(fi=null)}else fi=null;var KS=/^\s*class\b/,yu=function(t){try{var e=zm.call(t);return KS.test(e)}catch{return!1}},Ac=function(t){try{return yu(t)?!1:(zm.call(t),!0)}catch{return!1}},Da=Object.prototype.toString,JS="[object Object]",QS="[object Function]",e_="[object GeneratorFunction]",t_="[object HTMLAllCollection]",n_="[object HTML document.all class]",r_="[object HTMLCollection]",i_=typeof Symbol=="function"&&!!Symbol.toStringTag,s_=!(0 in[,]),bu=function(){return!1};if(typeof document=="object"){var o_=document.all;Da.call(o_)===Da.call(document.all)&&(bu=function(t){if((s_||!t)&&(typeof t>"u"||typeof t=="object"))try{var e=Da.call(t);return(e===t_||e===n_||e===r_||e===JS)&&t("")==null}catch{}return!1})}var Om=fi?function(t){if(bu(t))return!0;if(!t||typeof t!="function"&&typeof t!="object")return!1;try{fi(t,null,vu)}catch(e){if(e!==Pa)return!1}return!yu(t)&&Ac(t)}:function(t){if(bu(t))return!0;if(!t||typeof t!="function"&&typeof t!="object")return!1;if(i_)return Ac(t);if(yu(t))return!1;var e=Da.call(t);return e!==QS&&e!==e_&&!/^\[object HTML/.test(e)?!1:Ac(t)},a_=Om,l_=function(t){return!!t},Dt=xn,ua=X,c_=kn,Pp=a_,$c=l_,u_=function(t){if(!c_(t))throw new ua("ToPropertyDescriptor requires an object");var e={};if(Dt(t,"enumerable")&&(e["[[Enumerable]]"]=$c(t.enumerable)),Dt(t,"configurable")&&(e["[[Configurable]]"]=$c(t.configurable)),Dt(t,"value")&&(e["[[Value]]"]=t.value),Dt(t,"writable")&&(e["[[Writable]]"]=$c(t.writable)),Dt(t,"get")){var r=t.get;if(typeof r<"u"&&!Pp(r))throw new ua("getter must be a function");e["[[Get]]"]=r}if(Dt(t,"set")){var i=t.set;if(typeof i<"u"&&!Pp(i))throw new ua("setter must be a function");e["[[Set]]"]=i}if((Dt(e,"[[Get]]")||Dt(e,"[[Set]]"))&&(Dt(e,"[[Value]]")||Dt(e,"[[Writable]]")))throw new ua("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute");return e},Tc=X,h_=kn,Dp=Qi,d_=Uh,p_=Pm,f_=Dm,g_=es,m_=Lm,v_=u_,y_=function(t,e,r){if(!h_(t))throw new Tc("Assertion failed: Type(O) is not Object");if(!g_(e))throw new Tc("Assertion failed: P is not a Property Key");var i=Dp(r)?r:v_(r);if(!Dp(i))throw new Tc("Assertion failed: Desc is not a valid Property Descriptor");return d_(f_,m_,p_,t,e,i)},Lp=X,b_=kn,w_=y_,S_=es,__=function(t,e,r){if(!b_(t))throw new Lp("Assertion failed: Type(O) is not Object");if(!S_(e))throw new Lp("Assertion failed: P is not a Property Key");var i={"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Value]]":r,"[[Writable]]":!0};return w_(t,e,i)},k_=typeof Reflect<"u"&&Reflect.setPrototypeOf||null,x_=Ph,E_=x_.setPrototypeOf||null,A_=Fl,zp=Ki,$_=X,Mm={};try{Mm.__proto__=null}catch(n){if(!n||typeof n!="object"||!("code"in n)||n.code!=="ERR_PROTO_ACCESS")throw n}var T_=!("toString"in Mm),Ic=zp&&zp(Object.prototype,"__proto__"),I_=T_&&(!!Ic&&typeof Ic.set=="function"&&A_([Ic.set])||function(t,e){if(t==null)throw new $_("set Object.prototype.__proto__ called on null or undefined");return t.__proto__=e,e}),Op=k_,C_=E_,Mp=I_,R_=X,P_=Op?function(t,e){if(Op(t,e))return t;throw new R_("Reflect.setPrototypeOf: failed to set [[Prototype]]")}:C_||(Mp?function(t,e){return Mp(t,e),t}:null),Np=X,D_=kn,Up=$m,L_=function(t){if(!D_(t))throw new Np("Assertion failed: O must be an Object");if(!Up)throw new Np("This environment does not support fetching prototypes.");return Up(t)},z_=X,O_=P_,M_=kn,N_=L_,U_=function(t,e){if(e!==null&&!M_(e))throw new z_("Assertion failed: V must be Object or Null");try{O_(t,e)}catch{return!1}return N_(t)===e},Cc=Fh,Fp=__,Nm=U_,F_=Ul(),Hh=Sm;function Bo(n,t,e){var r=new Hh(e);return Nm(r,La),delete r.constructor,Fp(r,"error",n),Fp(r,"suppressed",t),r}F_&&Object.defineProperty(Bo,"prototype",{writable:!1});var La=Bo.prototype;if(!Cc(La,"constructor",Bo)||!Cc(La,"message","")||!Cc(La,"name","SuppressedError"))throw new Hh("unable to install SuppressedError.prototype properties; please report this!");Nm(Bo.prototype,Hh.prototype);var H_=Bo,W_=H_,Um=function(){return typeof SuppressedError=="function"?SuppressedError:W_},Z_=Wr,Hp=Rh(),V_=Um,B_=function(){var t=V_();return Z_(Hp,{SuppressedError:t},{SuppressedError:function(){return Hp.SuppressedError!==t}}),t};B_();var j_=X,G_=Qi,q_=Rm,Y_=function(t){if(typeof t<"u"&&!G_(t))throw new j_("Assertion failed: `Desc` must be a Property Descriptor");return q_(t)},X_=X,Wp=xn,K_=Qi,J_=function(t){if(typeof t>"u")return!1;if(!K_(t))throw new X_("Assertion failed: `Desc` must be a Property Descriptor");return!(!Wp(t,"[[Value]]")&&!Wp(t,"[[Writable]]"))},Zp=Lh,Q_=function(t,e){return t===e?t===0?1/t===1/e:!0:Zp(t)&&Zp(e)},ts=Om,ek=function(t){return!!t},Lt=xn,ha=X,tk=kn,Vp=ts,Rc=ek,nk=function(t){if(!tk(t))throw new ha("ToPropertyDescriptor requires an object");var e={};if(Lt(t,"enumerable")&&(e["[[Enumerable]]"]=Rc(t.enumerable)),Lt(t,"configurable")&&(e["[[Configurable]]"]=Rc(t.configurable)),Lt(t,"value")&&(e["[[Value]]"]=t.value),Lt(t,"writable")&&(e["[[Writable]]"]=Rc(t.writable)),Lt(t,"get")){var r=t.get;if(typeof r<"u"&&!Vp(r))throw new ha("getter must be a function");e["[[Get]]"]=r}if(Lt(t,"set")){var i=t.set;if(typeof i<"u"&&!Vp(i))throw new ha("setter must be a function");e["[[Set]]"]=i}if((Lt(e,"[[Get]]")||Lt(e,"[[Set]]"))&&(Lt(e,"[[Value]]")||Lt(e,"[[Writable]]")))throw new ha("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute");return e},Pc=X,rk=kn,Bp=Qi,ik=Uh,sk=Y_,ok=J_,ak=es,lk=Q_,ck=nk,jo=function(t,e,r){if(!rk(t))throw new Pc("Assertion failed: Type(O) is not Object");if(!ak(e))throw new Pc("Assertion failed: P is not a Property Key");var i=Bp(r)?r:ck(r);if(!Bp(i))throw new Pc("Assertion failed: Desc is not a valid Property Descriptor");return ik(ok,lk,sk,t,e,i)},uk=Ji(),hk=uk?Symbol.dispose||Symbol("Symbol.dispose"):null,dk=Ji,pk=hk,Wh=function(){return dk()&&Symbol.dispose||pk},fk=zh,gk=jo,mk=Wh,vk=function(){var t=mk();return fk()&&gk(Symbol,"dispose",{"[[Configurable]]":!1,"[[Enumerable]]":!1,"[[Writable]]":!1,"[[Value]]":t}),t},yk=Ji(),bk=yk?Symbol.asyncDispose||Symbol("Symbol.asyncDispose"):null,wk=Ji,Sk=bk,Zh=function(){return wk()&&Symbol.asyncDispose||Sk},_k=zh,kk=jo,xk=Zh,Ek=function(){var t=xk();return _k()&&kk(Symbol,"asyncDispose",{"[[Configurable]]":!1,"[[Enumerable]]":!1,"[[Writable]]":!1,"[[Value]]":t}),t},Ak=Nh(),$k=yt,Tk=Xn(),Ik=X,Ck=Ak,Rk=$k("%Reflect.apply%",!0)||Tk("Function.prototype.apply"),Hl=function(t,e){var r=arguments.length>2?arguments[2]:[];if(!Ck(r))throw new Ik("Assertion failed: optional `argumentsList`, if provided, must be a List");return Rk(t,e,r)};const Pk={},Dk=Object.freeze(Object.defineProperty({__proto__:null,default:Pk},Symbol.toStringTag,{value:"Module"})),Lk=i0(Dk);var Vh=typeof Map=="function"&&Map.prototype,Dc=Object.getOwnPropertyDescriptor&&Vh?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,il=Vh&&Dc&&typeof Dc.get=="function"?Dc.get:null,jp=Vh&&Map.prototype.forEach,Bh=typeof Set=="function"&&Set.prototype,Lc=Object.getOwnPropertyDescriptor&&Bh?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,sl=Bh&&Lc&&typeof Lc.get=="function"?Lc.get:null,Gp=Bh&&Set.prototype.forEach,zk=typeof WeakMap=="function"&&WeakMap.prototype,Ds=zk?WeakMap.prototype.has:null,Ok=typeof WeakSet=="function"&&WeakSet.prototype,Ls=Ok?WeakSet.prototype.has:null,Mk=typeof WeakRef=="function"&&WeakRef.prototype,qp=Mk?WeakRef.prototype.deref:null,Nk=Boolean.prototype.valueOf,Uk=Object.prototype.toString,Fk=Function.prototype.toString,Hk=String.prototype.match,jh=String.prototype.slice,Wn=String.prototype.replace,Wk=String.prototype.toUpperCase,Yp=String.prototype.toLowerCase,Fm=RegExp.prototype.test,Xp=Array.prototype.concat,Qt=Array.prototype.join,Zk=Array.prototype.slice,Kp=Math.floor,wu=typeof BigInt=="function"?BigInt.prototype.valueOf:null,zc=Object.getOwnPropertySymbols,Su=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,ji=typeof Symbol=="function"&&typeof Symbol.iterator=="object",zs=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===ji||!0)?Symbol.toStringTag:null,Hm=Object.prototype.propertyIsEnumerable,Jp=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(n){return n.__proto__}:null);function Qp(n,t){if(n===1/0||n===-1/0||n!==n||n&&n>-1e3&&n<1e3||Fm.call(/e/,t))return t;var e=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof n=="number"){var r=n<0?-Kp(-n):Kp(n);if(r!==n){var i=String(r),s=jh.call(t,i.length+1);return Wn.call(i,e,"$&_")+"."+Wn.call(Wn.call(s,/([0-9]{3})/g,"$&_"),/_$/,"")}}return Wn.call(t,e,"$&_")}var _u=Lk,ef=_u.custom,tf=Vm(ef)?ef:null,Wm={__proto__:null,double:'"',single:"'"},Vk={__proto__:null,double:/(["\\])/g,single:/(['\\])/g},ns=function n(t,e,r,i){var s=e||{};if(dn(s,"quoteStyle")&&!dn(Wm,s.quoteStyle))throw new TypeError('option "quoteStyle" must be "single" or "double"');if(dn(s,"maxStringLength")&&(typeof s.maxStringLength=="number"?s.maxStringLength<0&&s.maxStringLength!==1/0:s.maxStringLength!==null))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var o=dn(s,"customInspect")?s.customInspect:!0;if(typeof o!="boolean"&&o!=="symbol")throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(dn(s,"indent")&&s.indent!==null&&s.indent!==" "&&!(parseInt(s.indent,10)===s.indent&&s.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(dn(s,"numericSeparator")&&typeof s.numericSeparator!="boolean")throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var a=s.numericSeparator;if(typeof t>"u")return"undefined";if(t===null)return"null";if(typeof t=="boolean")return t?"true":"false";if(typeof t=="string")return jm(t,s);if(typeof t=="number"){if(t===0)return 1/0/t>0?"0":"-0";var c=String(t);return a?Qp(t,c):c}if(typeof t=="bigint"){var u=String(t)+"n";return a?Qp(t,u):u}var h=typeof s.depth>"u"?5:s.depth;if(typeof r>"u"&&(r=0),r>=h&&h>0&&typeof t=="object")return ku(t)?"[Array]":"[Object]";var p=lx(s,r);if(typeof i>"u")i=[];else if(Bm(i,t)>=0)return"[Circular]";function v(Ct,En,ac){if(En&&(i=Zk.call(i),i.push(En)),ac){var ta={depth:s.depth};return dn(s,"quoteStyle")&&(ta.quoteStyle=s.quoteStyle),n(Ct,ta,r+1,i)}return n(Ct,s,r+1,i)}if(typeof t=="function"&&!nf(t)){var m=Qk(t),_=da(t,v);return"[Function"+(m?": "+m:" (anonymous)")+"]"+(_.length>0?" { "+Qt.call(_,", ")+" }":"")}if(Vm(t)){var k=ji?Wn.call(String(t),/^(Symbol\(.*\))_[^)]*$/,"$1"):Su.call(t);return typeof t=="object"&&!ji?ps(k):k}if(sx(t)){for(var T="<"+Yp.call(String(t.nodeName)),P=t.attributes||[],R=0;R<P.length;R++)T+=" "+P[R].name+"="+Zm(Bk(P[R].value),"double",s);return T+=">",t.childNodes&&t.childNodes.length&&(T+="..."),T+="</"+Yp.call(String(t.nodeName))+">",T}if(ku(t)){if(t.length===0)return"[]";var W=da(t,v);return p&&!ax(W)?"["+xu(W,p)+"]":"[ "+Qt.call(W,", ")+" ]"}if(Gk(t)){var N=da(t,v);return!("cause"in Error.prototype)&&"cause"in t&&!Hm.call(t,"cause")?"{ ["+String(t)+"] "+Qt.call(Xp.call("[cause]: "+v(t.cause),N),", ")+" }":N.length===0?"["+String(t)+"]":"{ ["+String(t)+"] "+Qt.call(N,", ")+" }"}if(typeof t=="object"&&o){if(tf&&typeof t[tf]=="function"&&_u)return _u(t,{depth:h-r});if(o!=="symbol"&&typeof t.inspect=="function")return t.inspect()}if(ex(t)){var F=[];return jp&&jp.call(t,function(Ct,En){F.push(v(En,t,!0)+" => "+v(Ct,t))}),rf("Map",il.call(t),F,p)}if(rx(t)){var Y=[];return Gp&&Gp.call(t,function(Ct){Y.push(v(Ct,t))}),rf("Set",sl.call(t),Y,p)}if(tx(t))return Oc("WeakMap");if(ix(t))return Oc("WeakSet");if(nx(t))return Oc("WeakRef");if(Yk(t))return ps(v(Number(t)));if(Kk(t))return ps(v(wu.call(t)));if(Xk(t))return ps(Nk.call(t));if(qk(t))return ps(v(String(t)));if(typeof window<"u"&&t===window)return"{ [object Window] }";if(typeof globalThis<"u"&&t===globalThis||typeof ur<"u"&&t===ur)return"{ [object globalThis] }";if(!jk(t)&&!nf(t)){var j=da(t,v),oe=Jp?Jp(t)===Object.prototype:t instanceof Object||t.constructor===Object,wt=t instanceof Object?"":"null prototype",er=!oe&&zs&&Object(t)===t&&zs in t?jh.call(Kn(t),8,-1):wt?"Object":"",Re=oe||typeof t.constructor!="function"?"":t.constructor.name?t.constructor.name+" ":"",tr=Re+(er||wt?"["+Qt.call(Xp.call([],er||[],wt||[]),": ")+"] ":"");return j.length===0?tr+"{}":p?tr+"{"+xu(j,p)+"}":tr+"{ "+Qt.call(j,", ")+" }"}return String(t)};function Zm(n,t,e){var r=e.quoteStyle||t,i=Wm[r];return i+n+i}function Bk(n){return Wn.call(String(n),/"/g,""")}function Zr(n){return!zs||!(typeof n=="object"&&(zs in n||typeof n[zs]<"u"))}function ku(n){return Kn(n)==="[object Array]"&&Zr(n)}function jk(n){return Kn(n)==="[object Date]"&&Zr(n)}function nf(n){return Kn(n)==="[object RegExp]"&&Zr(n)}function Gk(n){return Kn(n)==="[object Error]"&&Zr(n)}function qk(n){return Kn(n)==="[object String]"&&Zr(n)}function Yk(n){return Kn(n)==="[object Number]"&&Zr(n)}function Xk(n){return Kn(n)==="[object Boolean]"&&Zr(n)}function Vm(n){if(ji)return n&&typeof n=="object"&&n instanceof Symbol;if(typeof n=="symbol")return!0;if(!n||typeof n!="object"||!Su)return!1;try{return Su.call(n),!0}catch{}return!1}function Kk(n){if(!n||typeof n!="object"||!wu)return!1;try{return wu.call(n),!0}catch{}return!1}var Jk=Object.prototype.hasOwnProperty||function(n){return n in this};function dn(n,t){return Jk.call(n,t)}function Kn(n){return Uk.call(n)}function Qk(n){if(n.name)return n.name;var t=Hk.call(Fk.call(n),/^function\s*([\w$]+)/);return t?t[1]:null}function Bm(n,t){if(n.indexOf)return n.indexOf(t);for(var e=0,r=n.length;e<r;e++)if(n[e]===t)return e;return-1}function ex(n){if(!il||!n||typeof n!="object")return!1;try{il.call(n);try{sl.call(n)}catch{return!0}return n instanceof Map}catch{}return!1}function tx(n){if(!Ds||!n||typeof n!="object")return!1;try{Ds.call(n,Ds);try{Ls.call(n,Ls)}catch{return!0}return n instanceof WeakMap}catch{}return!1}function nx(n){if(!qp||!n||typeof n!="object")return!1;try{return qp.call(n),!0}catch{}return!1}function rx(n){if(!sl||!n||typeof n!="object")return!1;try{sl.call(n);try{il.call(n)}catch{return!0}return n instanceof Set}catch{}return!1}function ix(n){if(!Ls||!n||typeof n!="object")return!1;try{Ls.call(n,Ls);try{Ds.call(n,Ds)}catch{return!0}return n instanceof WeakSet}catch{}return!1}function sx(n){return!n||typeof n!="object"?!1:typeof HTMLElement<"u"&&n instanceof HTMLElement?!0:typeof n.nodeName=="string"&&typeof n.getAttribute=="function"}function jm(n,t){if(n.length>t.maxStringLength){var e=n.length-t.maxStringLength,r="... "+e+" more character"+(e>1?"s":"");return jm(jh.call(n,0,t.maxStringLength),t)+r}var i=Vk[t.quoteStyle||"single"];i.lastIndex=0;var s=Wn.call(Wn.call(n,i,"\\$1"),/[\x00-\x1f]/g,ox);return Zm(s,"single",t)}function ox(n){var t=n.charCodeAt(0),e={8:"b",9:"t",10:"n",12:"f",13:"r"}[t];return e?"\\"+e:"\\x"+(t<16?"0":"")+Wk.call(t.toString(16))}function ps(n){return"Object("+n+")"}function Oc(n){return n+" { ? }"}function rf(n,t,e,r){var i=r?xu(e,r):Qt.call(e,", ");return n+" ("+t+") {"+i+"}"}function ax(n){for(var t=0;t<n.length;t++)if(Bm(n[t],`
|
|
2
|
+
`)>=0)return!1;return!0}function lx(n,t){var e;if(n.indent===" ")e=" ";else if(typeof n.indent=="number"&&n.indent>0)e=Qt.call(Array(n.indent+1)," ");else return null;return{base:e,prev:Qt.call(Array(t+1),e)}}function xu(n,t){if(n.length===0)return"";var e=`
|
|
3
3
|
`+t.prev+t.base;return e+Qt.call(n,","+e)+`
|
|
4
|
-
`+t.prev}function la(n,t){var e=bu(n),r=[];if(e){r.length=n.length;for(var i=0;i<n.length;i++)r[i]=dn(n,i)?t(n[i],n):""}var s=typeof Rc=="function"?Rc(n):[],o;if(Bi){o={};for(var a=0;a<s.length;a++)o["$"+s[a]]=s[a]}for(var c in n)dn(n,c)&&(e&&String(Number(c))===c&&c<n.length||Bi&&o["$"+c]instanceof Symbol||(zm.call(/[^\w$]/,c)?r.push(t(c,n)+": "+t(n[c],n)):r.push(c+": "+t(n[c],n))));if(typeof Rc=="function")for(var u=0;u<s.length;u++)Om.call(n,s[u])&&r.push("["+t(s[u])+"]: "+t(n[s[u]],n));return r}var rE=ts,iE=X,Nl=function(n,t,e){for(var r=n,i;(i=r.next)!=null;r=i)if(i.key===t)return r.next=i.next,e||(i.next=n.next,n.next=i),i},sE=function(n,t){if(n){var e=Nl(n,t);return e&&e.value}},oE=function(n,t,e){var r=Nl(n,t);r?r.value=e:n.next={key:t,next:n.next,value:e}},aE=function(n,t){return n?!!Nl(n,t):!1},lE=function(n,t){if(n)return Nl(n,t,!0)},cE=function(){var t,e={assert:function(r){if(!e.has(r))throw new iE("Side channel does not contain "+rE(r))},delete:function(r){var i=t&&t.next,s=lE(t,r);return s&&i&&i===s&&(t=void 0),!!s},get:function(r){return sE(t,r)},has:function(r){return aE(t,r)},set:function(r,i){t||(t={next:void 0}),oE(t,r,i)}};return e},uE=yt,Zo=Xn(),hE=ts,dE=X,Qp=uE("%Map%",!0),pE=Zo("Map.prototype.get",!0),fE=Zo("Map.prototype.set",!0),gE=Zo("Map.prototype.has",!0),mE=Zo("Map.prototype.delete",!0),vE=Zo("Map.prototype.size",!0),Wm=!!Qp&&function(){var t,e={assert:function(r){if(!e.has(r))throw new dE("Side channel does not contain "+hE(r))},delete:function(r){if(t){var i=mE(t,r);return vE(t)===0&&(t=void 0),i}return!1},get:function(r){if(t)return pE(t,r)},has:function(r){return t?gE(t,r):!1},set:function(r,i){t||(t=new Qp),fE(t,r,i)}};return e},yE=yt,Ul=Xn(),bE=ts,ca=Wm,wE=X,ei=yE("%WeakMap%",!0),SE=Ul("WeakMap.prototype.get",!0),_E=Ul("WeakMap.prototype.set",!0),kE=Ul("WeakMap.prototype.has",!0),EE=Ul("WeakMap.prototype.delete",!0),xE=ei?function(){var t,e,r={assert:function(i){if(!r.has(i))throw new wE("Side channel does not contain "+bE(i))},delete:function(i){if(ei&&i&&(typeof i=="object"||typeof i=="function")){if(t)return EE(t,i)}else if(ca&&e)return e.delete(i);return!1},get:function(i){return ei&&i&&(typeof i=="object"||typeof i=="function")&&t?SE(t,i):e&&e.get(i)},has:function(i){return ei&&i&&(typeof i=="object"||typeof i=="function")&&t?kE(t,i):!!e&&e.has(i)},set:function(i,s){ei&&i&&(typeof i=="object"||typeof i=="function")?(t||(t=new ei),_E(t,i,s)):ca&&(e||(e=ca()),e.set(i,s))}};return r}:ca,AE=X,$E=ts,TE=cE,IE=Wm,CE=xE,RE=CE||IE||TE,PE=function(){var t,e={assert:function(r){if(!e.has(r))throw new AE("Side channel does not contain "+$E(r))},delete:function(r){return!!t&&t.delete(r)},get:function(r){return t&&t.get(r)},has:function(r){return!!t&&t.has(r)},set:function(r,i){t||(t=RE()),t.set(r,i)}};return e},DE=En,ps=PE(),an=X,Wh={assert:function(n,t){if(!n||typeof n!="object"&&typeof n!="function")throw new an("`O` is not an object");if(typeof t!="string")throw new an("`slot` must be a string");if(ps.assert(n),!Wh.has(n,t))throw new an("`"+t+"` is not present on `O`")},get:function(n,t){if(!n||typeof n!="object"&&typeof n!="function")throw new an("`O` is not an object");if(typeof t!="string")throw new an("`slot` must be a string");var e=ps.get(n);return e&&e["$"+t]},has:function(n,t){if(!n||typeof n!="object"&&typeof n!="function")throw new an("`O` is not an object");if(typeof t!="string")throw new an("`slot` must be a string");var e=ps.get(n);return!!e&&DE(e,"$"+t)},set:function(n,t,e){if(!n||typeof n!="object"&&typeof n!="function")throw new an("`O` is not an object");if(typeof t!="string")throw new an("`slot` must be a string");var r=ps.get(n);r||(r={},ps.set(n,r)),r["$"+t]=e}};Object.freeze&&Object.freeze(Wh);var Zh=Wh,Zm=_n,Vn=Zh,Vo=function n(t,e){if(!(this instanceof n))return new n(t,e);if(t!=="normal"&&t!=="break"&&t!=="continue"&&t!=="return"&&t!=="throw")throw new Zm('Assertion failed: `type` must be one of "normal", "break", "continue", "return", or "throw"');Vn.set(this,"[[Type]]",t),Vn.set(this,"[[Value]]",e)};Vo.prototype.type=function(){return Vn.get(this,"[[Type]]")};Vo.prototype.value=function(){return Vn.get(this,"[[Value]]")};Vo.prototype["?"]=function(){var t=Vn.get(this,"[[Type]]"),e=Vn.get(this,"[[Value]]");if(t==="throw")throw e;return e};Vo.prototype["!"]=function(){var t=Vn.get(this,"[[Type]]");if(t!=="normal")throw new Zm('Assertion failed: Completion Record is not of type "normal"');return Vn.get(this,"[[Value]]")};var Vh=Vo,LE=Vh,Bh=function(t){return new LE("normal",t)},Dc,ef;function zE(){if(ef)return Dc;ef=1;var n=Ki;return Dc=function(){return n()&&!!Symbol.toStringTag},Dc}var OE=yt,tf=OE("%Object.defineProperty%",!0),ME=zE()(),NE=En,UE=X,ua=ME?Symbol.toStringTag:null,Vm=function(t,e){var r=arguments.length>2&&!!arguments[2]&&arguments[2].force,i=arguments.length>2&&!!arguments[2]&&arguments[2].nonConfigurable;if(typeof r<"u"&&typeof r!="boolean"||typeof i<"u"&&typeof i!="boolean")throw new UE("if provided, the `overrideIfSet` and `nonConfigurable` options must be booleans");ua&&(r||!NE(t,ua))&&(tf?tf(t,ua,{configurable:!i,enumerable:!1,value:e,writable:!1}):t[ua]=e)},Bm={exports:{}},FE=yt,nf=lm,HE=zl(),rf=Xi,sf=X,WE=FE("%Math.floor%"),ZE=function(t,e){if(typeof t!="function")throw new sf("`fn` is not a function");if(typeof e!="number"||e<0||e>4294967295||WE(e)!==e)throw new sf("`length` must be a positive 32-bit integer");var r=arguments.length>2&&!!arguments[2],i=!0,s=!0;if("length"in t&&rf){var o=rf(t,"length");o&&!o.configurable&&(i=!1),o&&!o.writable&&(s=!1)}return(i||s||!r)&&(HE?nf(t,"length",e,!0,!0):nf(t,"length",e)),t},VE=No,BE=Ph,jE=bm,GE=function(){return jE(VE,BE,arguments)};(function(n){var t=ZE,e=Mo,r=Ol,i=GE;n.exports=function(o){var a=r(arguments),c=1+o.length-(arguments.length-1);return t(a,c>0?c:0,!0)},e?e(n.exports,"apply",{value:i}):n.exports.apply=i})(Bm);var jh=Bm.exports,qE=function(t,e){for(var r=0;r<t.length;r+=1)if(!e(t[r],r,t))return!1;return!0},YE=Object,XE=function(t){return t&&typeof t=="object"&&(typeof t["[[ResourceValue]]"]>"u"||YE(t["[[ResourceValue]]"])===t["[[ResourceValue]]"])&&(t["[[Hint]]"]==="SYNC-DISPOSE"||t["[[Hint]]"]==="ASYNC-DISPOSE")&&(typeof t["[[DisposeMethod]]"]=="function"||typeof t["[[DisposeMethod]]"]>"u")},KE=En,JE=Dh(),QE=qE,ex=XE,tx=function(t){return t&&typeof t=="object"&&KE(t,"[[DisposableResourceStack]]")&&JE(t["[[DisposableResourceStack]]"])&&(t["[[DisposableResourceStack]]"].length===0||QE(t["[[DisposableResourceStack]]"],ex))},nx=kn,rx=function(t){if(t===null)return"Null";if(typeof t>"u")return"Undefined";if(nx(t))return"Object";if(typeof t=="number")return"Number";if(typeof t=="boolean")return"Boolean";if(typeof t=="string")return"String"},ix=rx,Gh=function(t){return typeof t=="symbol"?"Symbol":typeof t=="bigint"?"BigInt":ix(t)},sx=X,ox=ts,ax=Qi,lx=function(t,e){if(!ax(e))throw new sx("Assertion failed: P is not a Property Key, got "+ox(e));return t[e]},of=X,cx=lx,ux=es,hx=Qi,af=ts,dx=function(t,e){if(!hx(e))throw new of("Assertion failed: P is not a Property Key");var r=cx(t,e);if(r!=null){if(!ux(r))throw new of(af(e)+" is not a function: "+af(r));return r}},Su={exports:{}},px=yt,fx=px,lf=fx("%Reflect.construct%",!0),nl=Wo;try{nl({},"",{"[[Get]]":function(){}})}catch{nl=null}if(nl&&lf){var cf={},uf={};nl(uf,"length",{"[[Get]]":function(){throw cf},"[[Enumerable]]":!0}),Su.exports=function(t){try{lf(t,uf)}catch(e){return e===cf}}}else Su.exports=function(t){return typeof t=="function"&&!!t.prototype};var gx=Su.exports,Lc=X,hf=es,mx=gx,vx=function(t){if(!mx(t))throw new Lc("C must be a constructor");var e={"[[Resolve]]":void 0,"[[Reject]]":void 0},r=new t(function(i,s){if(typeof e["[[Resolve]]"]<"u"||typeof e["[[Reject]]"]<"u")throw new Lc("executor has already been called");e["[[Resolve]]"]=i,e["[[Reject]]"]=s});if(!hf(e["[[Resolve]]"])||!hf(e["[[Reject]]"]))throw new Lc("executor must provide valid resolve and reject functions");return{"[[Promise]]":r,"[[Resolve]]":e["[[Resolve]]"],"[[Reject]]":e["[[Reject]]"]}},df=_n,yx=X,zc=Ml,pf=dx,bx=vx,wx=Gh,ff=Mh(),gf=Nh(),Sx=function(t,e){if(wx(t)!=="Object")throw new yx("`V` must be an Object");if(e!=="SYNC-DISPOSE"&&e!=="ASYNC-DISPOSE")throw new df("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");var r;if(e==="ASYNC-DISPOSE"&&gf&&(r=pf(t,gf)),!r){if(!ff)throw new df("`Symbol.dispose` is not supported");if(r=pf(t,ff),typeof r<"u")return function(){var i=this;if(e==="ASYNC-DISPOSE"){var s=bx(Promise);try{zc(r,i),zc(s["[[Resolve]]"],void 0,[void 0])}catch(o){s["[[Reject]]"](o)}return s["[[Promise]]"]}zc(r,i)}}return r},_x=_n,Oc=X,kx=es,Ex=Gh,xx=Sx,Ax=function(t,e){if(e!=="SYNC-DISPOSE"&&e!=="ASYNC-DISPOSE")throw new _x("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");var r;if(arguments.length<3)if(t==null)t=void 0,r=void 0;else{if(typeof t<"u"&&Ex(t)!=="Object")throw new Oc("`V` must be an Object, or `null` or `undefined`");if(r=xx(t,e),typeof r>"u")throw new Oc("dispose method must not be `undefined` on `V` when an object `V` is provided")}else if(r=arguments[2],!kx(r))throw new Oc("`method`, when provided, must be a function");return{"[[ResourceValue]]":t,"[[Hint]]":e,"[[DisposeMethod]]":r}},$x=_n,ha=X,Tx=tx,mf=Ax,Ix=Xn(),Cx=Ix("Array.prototype.push"),jm=function(t,e,r){if(!Tx(t))throw new ha("Assertion failed: `disposeCapability` must be a DisposeCapability Record");if(r!=="SYNC-DISPOSE"&&r!=="ASYNC-DISPOSE")throw new $x("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");var i=arguments.length>3?arguments[3]:void 0;if(arguments.length>3&&typeof i!="function")throw new ha("Assertion failed: `method`, when present, must be a function");if(!t["[[DisposableResourceStack]]"])throw new ha("Assertion failed: `disposeCapability.[[DisposableResourceStack]]` must not be ~EMPTY~");var s;if(arguments.length<4){if(e==null&&r==="SYNC_DISPOSE")return"UNUSED";s=mf(e,r)}else{if(typeof e<"u")throw new ha("Assertion failed: `V` must be undefined when `method` is present");s=mf(void 0,r,i)}return Cx(t["[[DisposableResourceStack]]"],s),"UNUSED"},Mc,vf;function qh(){if(vf)return Mc;vf=1;var n=yt,t=jh,e=_n,r=n("%Promise.resolve%",!0),i=r&&t(r);return Mc=function(o,a){if(!i)throw new e("This environment does not support Promises.");return i(o,a)},Mc}var Nc,yf;function Rx(){if(yf)return Nc;yf=1;var n=yt,t=_n,e=n("%Promise%",!0),r=Ml,i=qh(),s=Gh;return Nc=function(a,c,u){if(typeof a<"u"&&s(a)!=="Object")throw new t("Assertion failed: `V` must be `undefined` or an Object");if(c!=="SYNC-DISPOSE"&&c!=="ASYNC-DISPOSE")throw new t("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");if(typeof u<"u"&&typeof u!="function")throw new t("Assertion failed: `method` must be `undefined` or a function");var h=typeof u>"u"?u:r(u,a);if(c==="ASYNC-DISPOSE")return i(e,h)},Nc}var Uc,bf;function Px(){if(bf)return Uc;bf=1;var n=Vh;return Uc=function(e){return new n("throw",e)},Uc}var Dx=yt,Fc=_n,wf=X,Lx=Dx("%Promise%",!0),zx=Xn(),Sf=zx("Promise.prototype.then",!0),Ox=Vh,_f=Rx(),Mx=Bh,Nx=qh(),kf=Px(),Ux=Lm(),Gm=function(t,e){if(!(e instanceof Ox))throw new wf("`completion` must be a Completion Record");var r=t["[[DisposableResourceStack]]"];if(!r)throw new wf("Assertion failed: `disposeCapability.[[DisposableResourceStack]]` must not be ~EMPTY~");for(var i,s=r.length-1;s>=0;s-=1)if(!i)i=r[s]["[[Hint]]"];else if(i!==r[s]["[[Hint]]"])throw new Fc("mixed hint stacks are not supported");for(var o=i==="ASYNC-DISPOSE"&&Nx(Lx,e),a=function(v){if(e.type()==="throw"){var m=e.value(),_=new Ux(v,m);e=kf(_)}else e=kf(v)},c=i==="ASYNC-DISPOSE"&&function(m){return Sf(o,function(){var _=_f(m["[[ResourceValue]]"],m["[[Hint]]"],m["[[DisposeMethod]]"]);if(!_)throw new Fc("Assertion failed: non-`~ASYNC-DISPOSE~` resource returned a promise from Dispose");return Sf(_,Mx)},a)},u=r.length-1;u>=0;u-=1)if(i==="ASYNC-DISPOSE")o=c(r[u]);else{var h=r[u];try{var p=_f(h["[[ResourceValue]]"],h["[[Hint]]"],h["[[DisposeMethod]]"]);if(p)throw new Fc("Assertion failed: `~SYNC-DISPOSE~` resource returned something from Dispose")}catch(v){a(v)}}return t["[[DisposableResourceStack]]"]=null,i==="ASYNC-DISPOSE"?o:e},qm=function(){var t=[];return{"[[DisposableResourceStack]]":t}},Fl=Th,Yh=X,Fx=Ml,ns=zh,Hx=Wo,Ym=es,Wx=Bh,nt=Zh,Zx=Vm,Xm=Wr.supportsDescriptors,Vx=jh,Xh=jm,Bx=Gm,Km=qm,Ef=Mh(),ft=function n(){if(!(this instanceof n)||nt.has(this,"[[DisposableState]]")||nt.has(this,"[[DisposeCapability]]"))throw new Yh("can only be used with new");nt.set(this,"[[DisposableState]]","PENDING"),nt.set(this,"[[DisposeCapability]]",Km())},Jm=function(){var t=this;return nt.assert(t,"[[DisposableState]]"),nt.get(t,"[[DisposableState]]")==="DISPOSED"},Bo=Vx(Jm);Xm?Hx(ft.prototype,"disposed",{"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Get]]":Jm}):ft.prototype.disposed=!1;var Qm=function(t){nt.set(t,"[[DisposableState]]","DISPOSED"),Xm||(t.disposed=!0)};ns(ft.prototype,"dispose",function(){var t=this;if(!Bo(t))return Qm(t),Bx(nt.get(t,"[[DisposeCapability]]"),Wx())["?"]()});ns(ft.prototype,"use",function(t){var e=this;if(Bo(e))throw new Fl("a disposed stack can not use anything new");return Xh(nt.get(e,"[[DisposeCapability]]"),t,"SYNC-DISPOSE"),t});ns(ft.prototype,"adopt",function(t,e){var r=this;if(Bo(r))throw new Fl("a disposed stack can not use anything new");if(!Ym(e))throw new Yh("`onDispose` must be a function");var i=function(){return Fx(e,void 0,[t])};return Xh(nt.get(r,"[[DisposeCapability]]"),void 0,"SYNC-DISPOSE",i),t});ns(ft.prototype,"defer",function(t){var e=this;if(Bo(e))throw new Fl("a disposed stack can not defer anything new");if(!Ym(t))throw new Yh("`onDispose` must be a function");Xh(nt.get(e,"[[DisposeCapability]]"),void 0,"SYNC-DISPOSE",t)});ns(ft.prototype,"move",function(){var t=this;if(Bo(t))throw new Fl("a disposed stack can not use anything new");var e=new ft;return nt.set(e,"[[DisposeCapability]]",nt.get(t,"[[DisposeCapability]]")),nt.set(t,"[[DisposeCapability]]",Km()),Qm(t),e});Ef&&ns(ft.prototype,Ef,ft.prototype.dispose);Zx(ft.prototype,"DisposableStack");var jx=ft,Gx=jx,qx=function(){return typeof DisposableStack=="function"?DisposableStack:Gx},Yx=Wr,Xx=Ah(),Kx=qx,Jx=function(){var t=Kx();return Yx(Xx,{DisposableStack:t},{DisposableStack:!0}),t},Qx=yt,Hl=Th,Kh=X,xf=Qx("%Promise%",!0),Jh=jm,eA=Ml,rs=zh,tA=Wo,nA=Gm,ev=es,tv=qm,rA=Bh,Af=qh(),rt=Zh,iA=Vm,nv=Wr.supportsDescriptors,sA=jh,oA=Xn(),aA=oA("Promise.prototype.then",!0),$f=Nh(),gt=function n(){if(!(this instanceof n)||rt.has(this,"[[AsyncDisposableState]]")||rt.has(this,"[[DisposeCapability]]"))throw new Kh("can only be used with new");rt.set(this,"[[AsyncDisposableState]]","pending"),rt.set(this,"[[DisposeCapability]]",tv())},rv=function(){var t=this;return rt.assert(t,"[[AsyncDisposableState]]"),rt.get(t,"[[AsyncDisposableState]]")==="disposed"},jo=sA(rv);nv?tA(gt.prototype,"disposed",{"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Get]]":rv}):gt.prototype.disposed=!1;var iv=function(t){rt.set(t,"[[AsyncDisposableState]]","disposed"),nv||(t.disposed=!0)};rs(gt.prototype,"disposeAsync",function(){var t=this;return jo(t)?Af(xf):(iv(t),aA(Af(xf,nA(rt.get(t,"[[DisposeCapability]]"),rA())),function(e){return e["?"]()}))});rs(gt.prototype,"use",function(t){var e=this;if(jo(e))throw new Hl("a disposed stack can not use anything new");return Jh(rt.get(e,"[[DisposeCapability]]"),t,"ASYNC-DISPOSE"),t});rs(gt.prototype,"adopt",function(t,e){var r=this;if(jo(r))throw new Hl("a disposed stack can not use anything new");if(!ev(e))throw new Kh("`onDisposeAsync` must be a function");var i=function(){return eA(e,void 0,[t])};return i.value=t,Jh(rt.get(r,"[[DisposeCapability]]"),void 0,"ASYNC-DISPOSE",i),t});rs(gt.prototype,"defer",function(t){var e=this;if(jo(e))throw new Hl("a disposed stack can not defer anything new");if(!ev(t))throw new Kh("`onDispose` must be a function");Jh(rt.get(e,"[[DisposeCapability]]"),void 0,"ASYNC-DISPOSE",t)});rs(gt.prototype,"move",function(){var t=this;if(jo(t))throw new Hl("a disposed stack can not use anything new");var e=new gt;return rt.set(e,"[[DisposeCapability]]",rt.get(t,"[[DisposeCapability]]")),rt.set(t,"[[DisposeCapability]]",tv()),iv(t),e});$f&&rs(gt.prototype,$f,gt.prototype.disposeAsync);iA(gt.prototype,"AsyncDisposableStack");var lA=gt,cA=lA,uA=function(){return typeof AsyncDisposableStack=="function"?AsyncDisposableStack:cA},hA=Wr,dA=Ah(),pA=uA,fA=function(){var t=pA();return hA(dA,{AsyncDisposableStack:t},{AsyncDisposableStack:!0}),t},gA=hk,mA=bk,vA=Jx,yA=fA,bA=function(){gA(),mA(),vA(),yA()};bA();const Tf=new WeakMap;function wA(n){return(typeof n=="object"||typeof n=="function")&&n!==null&&"then"in n&&typeof n.then=="function"}function ti(n){return typeof n=="string"?n:typeof n=="symbol"?n.description??n.toString():n.name||"(anonymous class)"}function If(){return new Error("register(Key, factory) requires a factory function. Wrap existing instances as () => instance.")}function SA(){return new Error("register(Key, factory) does not accept async factories. Await setup before registering.")}class _A{constructor(){g(this,"entries",new Map);g(this,"constructionStack",[])}register(t,e){if(e===void 0){if(typeof t!="function")throw If();this.validateClassRegistration(t),this.storeFactory(t,()=>this.instantiateClass(t));return}if(typeof e!="function")throw If();if(e.constructor.name==="AsyncFunction")throw SA();this.storeFactory(t,e)}has(t){var e;return((e=this.entries.get(t))==null?void 0:e.factory)!==void 0}resolve(t){return this.resolveAny(t)}storeFactory(t,e){const r=this.getOrCreateEntry(t);r.factory=e,r.instance=void 0,r.error=void 0}validateClassRegistration(t){const e=Tf.get(t);if(e){if(t.length!==e.length)throw new Error(`${ti(t)} cannot be registered with register(Class). @injectable(...) declared ${e.length} dependencies but constructor arity is ${t.length}. Use register(Key, () => value) instead.`);return}if(t.length!==0)throw new Error(`${ti(t)} cannot be registered with register(Class). Undecorated classes must have zero required constructor parameters. Use register(Key, () => value) instead.`)}instantiateClass(t){const e=Tf.get(t);if(!e)return new t;const r=e.map(i=>this.resolveAny(i));return new t(...r)}resolveAny(t){return this.getOrCreateEntry(t).proxy}getOrCreateEntry(t){let e=this.entries.get(t);return e||(e={key:t},e.proxy=this.createProxy(e),this.entries.set(t,e),e)}createProxy(t){return new Proxy({},{get:(e,r)=>{if(r==="then")return;const i=this.getInstance(t),s=Reflect.get(i,r,i);return typeof s=="function"?s.bind(i):s},set:(e,r,i)=>{const s=this.getInstance(t);return Reflect.set(s,r,i,s)},has:(e,r)=>{const i=this.getInstance(t);return r in i}})}getInstance(t){if(t.instance)return t.instance;if(t.error)throw t.error;if(!t.factory)throw new Error(`${ti(t.key)} was resolved but never registered`);const e=this.constructionStack.indexOf(t.key);if(e!==-1){const r=[...this.constructionStack.slice(e),t.key].map(i=>ti(i)).join(" -> ");throw new Error(`Circular dependency detected: ${r}`)}this.constructionStack.push(t.key);try{const r=t.factory();if(wA(r))throw new Error(`Factory for ${ti(t.key)} returned a Promise. Await setup before registering.`);if(typeof r!="object"||r===null)throw new Error(`Factory for ${ti(t.key)} returned a non-object value. Wrap primitives in an object.`);return t.instance=r,r}catch(r){throw t.error=r,r}finally{this.constructionStack.pop()}}}const en=new _A,kA=.5,Cf=.1,Rf=8,EA=4,sv=3,ov=3,xA=4,pr=255,av=.2126,lv=.7152,cv=.0722;async function uv(n){const t=AA(n);if(!t)return"light";try{return await IA(n,t)>=kA?"light":"dark"}catch{return"light"}}function AA(n){if(typeof document.elementsFromPoint!="function")return null;const t=n.getBoundingClientRect(),e=t.left+t.width/2,r=t.top+t.height/2,i=document.elementsFromPoint(e,r);for(const s of i){if(!(s instanceof HTMLElement)||s===n||n.contains(s))continue;const o=window.getComputedStyle(s);if($A(o))return s}return null}function $A(n){return n.backgroundImage&&n.backgroundImage!=="none"?!0:TA(n.backgroundColor)>0}function TA(n){if(!n)return 0;const t=n.match(/rgba?\(([^)]+)\)/);if(!t)return 0;const e=t[1].split(/[\s,/]+/).filter(Boolean);return e.length===xA?parseFloat(e[sv]):e.length===ov?1:0}async function IA(n,t){const e=n.getBoundingClientRect(),r=t.getBoundingClientRect(),i={x:da((e.left-r.left)/r.width),y:da((e.top-r.top)/r.height),width:da(e.width/r.width),height:da(e.height/r.height)},s=window.getComputedStyle(t),o=CA(s.backgroundImage);return o?PA({url:o,surfaceWidth:r.width,surfaceHeight:r.height,region:i}):DA(s.backgroundColor)}function CA(n){const t=n.match(/url\(\s*["']?([^"')]+)["']?\s*\)/);return t?t[1]:null}const Pf=new Map;function RA(n){let t=Pf.get(n);return t||(t=new Promise((e,r)=>{const i=new Image;i.crossOrigin="anonymous",i.onload=()=>e(i),i.onerror=()=>r(new Error(`Failed to load ${n}`)),i.src=n}),Pf.set(n,t),t)}async function PA(n){const t=await RA(n.url),e=Math.max(Rf,Math.ceil(n.surfaceWidth*Cf)),r=Math.max(Rf,Math.ceil(n.surfaceHeight*Cf)),i=document.createElement("canvas");i.width=e,i.height=r;const s=i.getContext("2d",{willReadFrequently:!0});if(!s)return 1;const o=n.surfaceWidth/n.surfaceHeight,a=t.naturalWidth/t.naturalHeight;let c,u;a>o?(u=r,c=r*a):(c=e,u=e/a);const h=(e-c)/2,p=(r-u)/2;s.drawImage(t,h,p,c,u);const v=Math.max(0,Math.floor(n.region.x*e)),m=Math.max(0,Math.floor(n.region.y*r)),_=Math.max(1,Math.min(e-v,Math.floor(n.region.width*e))),k=Math.max(1,Math.min(r-m,Math.floor(n.region.height*r))),T=s.getImageData(v,m,_,k).data;let P=0,R=0;for(let W=0;W<T.length;W+=EA){const N=T[W]/pr,F=T[W+1]/pr,Y=T[W+2]/pr,j=T[W+sv]/pr;P+=j*(av*N+lv*F+cv*Y),R+=1}return R>0?P/R:1}function DA(n){const t=n.match(/rgba?\(([^)]+)\)/);if(!t)return 1;const e=t[1].split(/[\s,/]+/).filter(Boolean).map(parseFloat);if(e.length<ov)return 1;const r=e[0]/pr,i=e[1]/pr,s=e[2]/pr;return av*r+lv*i+cv*s}function da(n){return n<0?0:n>1?1:n}const LA=["ghost","glass"],Us=[...LA.flatMap(n=>[`button[variant="${n}"]`,`segmented-control[variant="${n}"]`]),'[material="glass"]'].join(", "),pa=new WeakSet,Df=new WeakSet;function hv(n){if(Df.has(n))return;Df.add(n);for(const e of n.querySelectorAll(Us))Hc(e);if(typeof MutationObserver!="function")return;new MutationObserver(e=>{for(const r of e)if(r.type==="childList")for(const i of r.addedNodes)zA(i,Hc);else r.type==="attributes"&&r.target instanceof HTMLElement&&r.target.matches(Us)&&Hc(r.target)}).observe(n,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["variant","material"]})}function zA(n,t){if(n instanceof Element){n instanceof HTMLElement&&n.matches(Us)&&t(n);for(const e of n.querySelectorAll(Us))t(e)}}async function Hc(n){if(pa.has(n)||n.hasAttribute("tone"))return;pa.add(n);const t=await uv(n);if(!n.matches(Us)){pa.delete(n);return}if(n.hasAttribute("tone")){pa.delete(n);return}n.setAttribute("tone",t)}const OA="*,*:before,*:after{box-sizing:border-box}html,body{margin:0;padding:0;width:100%;height:100%}h1,h2,h3,h4,h5,h6,p,ul,ol,blockquote,pre,hr{margin:0}button,input,textarea,select{font:inherit;color:inherit}@font-face{font-family:Hind;src:url("+new URL("Hind-Variable-C47b_dt9.woff2",import.meta.url).href+') format("woff2-variations");font-weight:300 700;font-style:normal;font-display:swap}:root{--font-sans: "Hind", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;--font-brand: var(--font-sans);--font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, monospace;--font-weight-body: 500;--text-base: 13.5px;--text-scale: 1.125;--text-sm: round(calc(var(--text-base) / var(--text-scale)), 1px);--text-lg: round(calc(var(--text-base) * var(--text-scale)), 1px);--text-xl: round(calc(var(--text-lg) * var(--text-scale)), 1px);--leading-base: 1.5;--control-height-xs: 18px;--control-height-sm: 24px;--control-height-md: 28px;--control-height-lg: 32px;--space-2: 2px;--space-4: 4px;--space-6: 6px;--space-8: 8px;--space-12: 12px;--space-16: 16px;--space-20: 20px;--space-24: 24px;--space-32: 32px;--space-48: 48px;--space-64: 64px;--radius-4: 4px;--radius-8: 8px;--radius-12: 12px;--radius-16: 16px;--radius-24: 24px;--radius-full: 9999px;--layer-chrome: 100;--layer-panel: 500;--layer-overlay: 2000;--shadow-hairline: 0 0 0 .5px var(--color-border);--shadow-control: 0 1px 1px rgb(0 0 0 / .04), 0 2px 6px rgb(0 0 0 / .06);--alpha-50: 4%;--alpha-100: 8%;--alpha-150: 11%;--alpha-200: 15%;--alpha-300: 22%;--alpha-400: 30%;--alpha-500: 40%;--alpha-600: 50%;--alpha-700: 65%;--alpha-800: 80%;--alpha-900: 90%;--alpha-950: 95%;--tint-50: color-mix(in srgb, currentColor var(--alpha-50), transparent);--tint-100: color-mix(in srgb, currentColor var(--alpha-100), transparent);--tint-150: color-mix(in srgb, currentColor var(--alpha-150), transparent);--tint-200: color-mix(in srgb, currentColor var(--alpha-200), transparent);--tint-300: color-mix(in srgb, currentColor var(--alpha-300), transparent);--tint-400: color-mix(in srgb, currentColor var(--alpha-400), transparent);--tint-500: color-mix(in srgb, currentColor var(--alpha-500), transparent);--tint-600: color-mix(in srgb, currentColor var(--alpha-600), transparent);--tint-700: color-mix(in srgb, currentColor var(--alpha-700), transparent);--tint-800: color-mix(in srgb, currentColor var(--alpha-800), transparent);--tint-900: color-mix(in srgb, currentColor var(--alpha-900), transparent);--tint-950: color-mix(in srgb, currentColor var(--alpha-950), transparent);--color-overlay-hover: color-mix(in srgb, var(--black) var(--alpha-100), transparent);--color-overlay-active: color-mix(in srgb, var(--black) var(--alpha-300), transparent);--backdrop-blur-glass: blur(20px) saturate(1.4);--black: #000000;--white: #ffffff;--neutral-50: oklch(.985 0 0);--neutral-100: oklch(.97 0 0);--neutral-200: oklch(.923 0 0);--neutral-300: oklch(.869 0 0);--neutral-350: oklch(.79 0 0);--neutral-400: oklch(.709 0 0);--neutral-500: oklch(.553 0 0);--neutral-600: oklch(.444 0 0);--neutral-700: oklch(.374 0 0);--neutral-800: oklch(.268 0 0);--neutral-900: oklch(.216 0 0);--neutral-950: oklch(.147 0 0);--red-50: oklch(.969 .015 12.422);--red-100: oklch(.941 .03 12.58);--red-200: oklch(.892 .058 10.001);--red-300: oklch(.81 .117 11.638);--red-400: oklch(.712 .194 13.428);--red-500: oklch(.645 .246 16.439);--red-600: oklch(.586 .253 17.585);--red-700: oklch(.514 .222 16.935);--red-800: oklch(.455 .188 13.697);--red-900: oklch(.41 .159 10.272);--red-950: oklch(.271 .105 12.094);--orange-50: oklch(.98 .016 73.684);--orange-100: oklch(.954 .038 75.164);--orange-200: oklch(.901 .076 70.697);--orange-300: oklch(.837 .128 66.29);--orange-400: oklch(.75 .183 55.934);--orange-500: oklch(.705 .213 47.604);--orange-600: oklch(.646 .222 41.116);--orange-700: oklch(.553 .195 38.402);--orange-800: oklch(.47 .157 37.304);--orange-900: oklch(.408 .123 38.172);--orange-950: oklch(.266 .079 36.259);--yellow-50: oklch(.987 .026 102.212);--yellow-100: oklch(.973 .071 103.193);--yellow-200: oklch(.945 .129 101.54);--yellow-300: oklch(.905 .182 98.111);--yellow-400: oklch(.852 .199 91.936);--yellow-500: oklch(.795 .184 86.047);--yellow-600: oklch(.681 .162 75.834);--yellow-700: oklch(.554 .135 66.442);--yellow-800: oklch(.476 .114 61.907);--yellow-900: oklch(.421 .095 57.708);--yellow-950: oklch(.286 .066 53.813);--green-50: oklch(.979 .021 166.113);--green-100: oklch(.95 .052 163.051);--green-200: oklch(.905 .093 164.15);--green-300: oklch(.845 .143 164.978);--green-400: oklch(.765 .177 163.223);--green-500: oklch(.696 .17 162.48);--green-600: oklch(.596 .145 163.225);--green-700: oklch(.508 .118 165.612);--green-800: oklch(.432 .095 166.913);--green-900: oklch(.378 .077 168.94);--green-950: oklch(.262 .051 172.552);--blue-50: oklch(.97 .014 254.604);--blue-100: oklch(.932 .032 255.585);--blue-200: oklch(.882 .059 254.128);--blue-300: oklch(.809 .105 251.813);--blue-400: oklch(.707 .165 254.624);--blue-500: oklch(.623 .214 259.815);--blue-600: oklch(.546 .245 262.881);--blue-700: oklch(.488 .243 264.376);--blue-800: oklch(.424 .199 265.638);--blue-900: oklch(.379 .146 265.522);--blue-950: oklch(.282 .091 267.935);--purple-50: oklch(.969 .016 293.756);--purple-100: oklch(.943 .029 294.588);--purple-200: oklch(.894 .057 293.283);--purple-300: oklch(.811 .111 293.571);--purple-400: oklch(.702 .183 293.541);--purple-500: oklch(.606 .25 292.717);--purple-600: oklch(.541 .281 293.009);--purple-700: oklch(.491 .27 292.581);--purple-800: oklch(.432 .232 292.759);--purple-900: oklch(.38 .189 293.745);--purple-950: oklch(.283 .141 291.089)}@supports (corner-shape: squircle){:root{--radius-8: 10px;--radius-12: 15px;--radius-16: 20px;--radius-24: 30px}}:root[data-font=system]{--font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif}:root{--color-bg: var(--neutral-50);--color-bg-muted: var(--neutral-100);--color-surface: var(--white);--color-surface-muted: var(--neutral-100);--color-interactive: var(--neutral-200);--color-interactive-hover: var(--neutral-300);--color-border: rgba(0, 0, 0, .1);--color-border-muted: rgba(0, 0, 0, .06);--color-text: var(--neutral-900);--color-text-muted: var(--neutral-500);--color-link: inherit;--color-focus-ring: var(--neutral-500);--color-overlay-backdrop: rgb(0 0 0 / .5);--color-highlight: rgb(255 255 255 / .5);--color-primary: var(--blue-500);--color-danger: var(--red-600);color-scheme:light}body{font-family:var(--font-sans);font-size:var(--text-base);font-weight:var(--font-weight-body);line-height:var(--leading-base);letter-spacing:.015em;color:var(--color-text);background:var(--color-bg);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}a{color:var(--color-link);text-underline-offset:.15em;text-decoration-thickness:.08em}h1,h2,h3,h4,h5,h6{font-weight:600;color:inherit}code{font-family:var(--font-mono);font-size:.9em;background:var(--color-bg-muted);padding:var(--space-2) var(--space-4);border-radius:var(--radius-4)}pre{font-family:var(--font-mono);background:var(--color-bg-muted);padding:var(--space-12);border-radius:var(--radius-8);overflow-x:auto}pre code{background:none;padding:0}blockquote{padding-left:var(--space-16);border-left:3px solid var(--color-border);color:var(--color-text-muted)}hr{border:none;border-top:1px solid var(--color-border)}table{border-collapse:collapse}th,td{padding:var(--space-8) var(--space-12);border:1px solid var(--color-border);text-align:left}th{background:var(--color-bg-muted);font-weight:600}input,textarea{border:.5px solid var(--tint-300);border-radius:var(--radius-12);background:var(--tint-100);color:inherit;font:inherit;box-sizing:border-box;transition:background .12s ease,border-color .12s ease,box-shadow .12s ease}input{height:var(--control-height-lg);padding:0 12px}textarea{padding:6px 10px;resize:none}input::placeholder,textarea::placeholder{color:var(--tint-500)}input:focus,textarea:focus{background:color-mix(in srgb,var(--white) var(--alpha-300),transparent);border-color:var(--color-primary);outline:none;box-shadow:0 0 0 1.5px var(--color-primary)}label.field{display:grid;gap:4px;font-size:13px}label.field>span{font-size:11.5px;font-weight:450;color:var(--tint-800)}@supports (corner-shape: squircle){*{corner-shape:squircle}}button{display:inline-flex;align-items:center;justify-content:center;gap:var(--space-6);box-sizing:border-box;height:var(--control-height-md);padding:0 14px 2px;font:inherit;cursor:default}button,segmented-control{background:var(--color-surface);border:.5px solid var(--tint-200);border-radius:var(--radius-12);box-shadow:var(--shadow-control);color:inherit}button:not([material]):hover:not(:disabled){background:color-mix(in srgb,var(--color-surface) 96%,black)}button:not([material]):active:not(:disabled){background:color-mix(in srgb,var(--color-surface) 88%,black);box-shadow:inset 0 1px 2px #00000014}button:focus-visible{outline:2px solid var(--color-focus-ring);outline-offset:2px}button[variant=primary]{background:var(--color-primary);border-color:#0000002e;color:var(--white)}button[variant=primary]:hover:not(:disabled){background:color-mix(in srgb,var(--color-primary) 92%,black)}button[variant=primary]:active:not(:disabled){background:color-mix(in srgb,var(--color-primary) 82%,black);box-shadow:inset 0 1px 2px #0000002e}button[variant=danger]{background:var(--color-danger);border-color:#0000002e;color:var(--white)}button[variant=danger]:hover:not(:disabled){background:color-mix(in srgb,var(--color-danger) 92%,black)}button[variant=danger]:active:not(:disabled){background:color-mix(in srgb,var(--color-danger) 82%,black);box-shadow:inset 0 1px 2px #0000002e}button[variant=ghost]{background:transparent;border-color:transparent;color:inherit;box-shadow:none}button[variant=ghost]:hover:not(:disabled){background:var(--tint-150);backdrop-filter:saturate(1.2);-webkit-backdrop-filter:saturate(1.2)}button[variant=ghost]:active:not(:disabled){background:var(--tint-300);backdrop-filter:saturate(1.4);-webkit-backdrop-filter:saturate(1.4);box-shadow:none}button[variant=ghost][data-active]:not(:disabled),button[variant=ghost][data-active]:hover:not(:disabled),button[variant=ghost][aria-pressed=true]:not(:disabled),button[variant=ghost][aria-pressed=true]:hover:not(:disabled),button[variant=ghost][aria-expanded=true]:not(:disabled),button[variant=ghost][aria-expanded=true]:hover:not(:disabled){background:var(--color-overlay-active);backdrop-filter:saturate(1.3);-webkit-backdrop-filter:saturate(1.3);box-shadow:none}button[variant=glass],segmented-control[variant=glass]{background:transparent;border:.5px solid color-mix(in srgb,var(--black) var(--alpha-100),transparent);box-shadow:none}button[variant=glass]{backdrop-filter:blur(20px) brightness(.95) saturate(1.5);-webkit-backdrop-filter:blur(20px) brightness(.95) saturate(1.5)}button[variant=glass]:hover:not(:disabled){background:linear-gradient(var(--color-overlay-hover),var(--color-overlay-hover));backdrop-filter:blur(20px) brightness(.95) saturate(1.8);-webkit-backdrop-filter:blur(20px) brightness(.95) saturate(1.8)}button[variant=glass]:active:not(:disabled){background:linear-gradient(var(--color-overlay-active),var(--color-overlay-active));backdrop-filter:blur(20px) brightness(.95) saturate(2.2);-webkit-backdrop-filter:blur(20px) brightness(.95) saturate(2.2)}button[variant=glass][aria-pressed=true]:not(:disabled),button[variant=glass][aria-pressed=true]:hover:not(:disabled),button[variant=glass][aria-expanded=true]:not(:disabled),button[variant=glass][aria-expanded=true]:hover:not(:disabled){background:linear-gradient(var(--color-overlay-active),var(--color-overlay-active));backdrop-filter:blur(20px) brightness(.95) saturate(2);-webkit-backdrop-filter:blur(20px) brightness(.95) saturate(2)}[tone=dark] button[variant=glass],[tone=dark] segmented-control[variant=glass]{border-color:var(--tint-400)}button[material],segmented-control[material]{color:inherit;box-shadow:none}button[material]:hover:not(:disabled){background-image:linear-gradient(var(--color-overlay-hover),var(--color-overlay-hover))}button[material]:active:not(:disabled){background-image:linear-gradient(var(--color-overlay-active),var(--color-overlay-active))}[tone=dark] button[material],[tone=dark] segmented-control[material]{border-color:var(--tint-400)}button:disabled{background:var(--tint-300);border-color:transparent;color:var(--tint-700);box-shadow:none}button[variant=ghost]:disabled{background:transparent}:where([tone=dark]) button:not([variant]):not([material]):not(:disabled),:where([tone=dark]) button[variant=default]:not([material]):not(:disabled),:where([tone=dark]) segmented-control:not([variant]):not([material]),:where([tone=dark]) segmented-control[variant=default]:not([material]){background:var(--tint-200);border-color:var(--tint-300);box-shadow:inset 0 .5px 0 var(--tint-300)}:where([tone=dark]) button:not([variant]):hover:not(:disabled),:where([tone=dark]) button[variant=default]:hover:not(:disabled){background:var(--tint-300)}:where([tone=dark]) button:not([variant]):active:not(:disabled),:where([tone=dark]) button[variant=default]:active:not(:disabled){background:var(--tint-400);box-shadow:inset 0 1px 2px #0003}:where([tone=light]) button:not([variant]):not([material]):not(:disabled),:where([tone=light]) button[variant=default]:not([material]):not(:disabled),:where([tone=light]) segmented-control:not([variant]):not([material]),:where([tone=light]) segmented-control[variant=default]:not([material]){background:var(--color-surface);border-color:var(--tint-200);box-shadow:var(--shadow-control)}:where([tone=light]) button:not([variant]):hover:not(:disabled){background:color-mix(in srgb,var(--color-surface) 96%,black)}:where([tone=light]) button:not([variant]):active:not(:disabled){background:color-mix(in srgb,var(--color-surface) 88%,black);box-shadow:inset 0 1px 2px #00000014}button[size=sm],segmented-control[size=sm]{height:var(--control-height-sm)}button[size=sm][icon-only]{width:var(--control-height-sm)}button[size=xs]{height:var(--control-height-xs);padding:0 var(--space-6) 1px;border-radius:var(--radius-8)}button[size=xs][icon-only]{width:var(--control-height-xs);padding:0}button[icon-only]{width:var(--control-height-md);padding:0}[data-ui-icon]{display:inline-block;vertical-align:middle}[selectable],[selectable] *{user-select:text;-webkit-user-select:text}[unselectable],[unselectable] *{user-select:none;-webkit-user-select:none}.prose{line-height:var(--leading-base)}.prose h1{font-size:var(--text-xl);margin-bottom:var(--space-8)}.prose h2{font-size:var(--text-lg);margin-top:var(--space-24);margin-bottom:var(--space-8)}.prose h3,.prose h4,.prose h5,.prose h6{font-size:var(--text-base);margin-top:var(--space-24);margin-bottom:var(--space-8)}.prose p{margin:var(--space-12) 0}.prose ul,.prose ol{padding-left:var(--space-24);margin:var(--space-12) 0}.prose blockquote,.prose pre{margin:var(--space-12) 0}.prose hr{margin:var(--space-24) 0}.prose table{width:100%;margin:var(--space-12) 0}.prose img{max-width:100%;height:auto}.prose>:first-child{margin-top:0}.prose>:last-child{margin-bottom:0}[material=paper]{background:var(--white);border:.5px solid color-mix(in srgb,var(--black) var(--alpha-100),transparent);color:var(--color-text)}[material=glass]{background:transparent;border:.5px solid color-mix(in srgb,var(--black) var(--alpha-100),transparent);backdrop-filter:blur(20px) brightness(.95) saturate(1.5);-webkit-backdrop-filter:blur(20px) brightness(.95) saturate(1.5)}[material=glass-frosted]{background:color-mix(in srgb,var(--white) var(--alpha-800),transparent);border:.5px solid color-mix(in srgb,var(--black) var(--alpha-100),transparent);color:var(--color-text);backdrop-filter:var(--backdrop-blur-glass);-webkit-backdrop-filter:var(--backdrop-blur-glass)}[tone=dark]{color:color-mix(in srgb,var(--white) var(--alpha-950),transparent);border-color:color-mix(in srgb,var(--white) var(--alpha-200),transparent);--color-overlay-hover: color-mix(in srgb, var(--white) var(--alpha-100), transparent);--color-overlay-active: color-mix(in srgb, var(--white) var(--alpha-200), transparent)}[tone=dark][material=paper]{background:#000}[tone=dark][material=glass-frosted]{background:color-mix(in srgb,var(--black) 70%,transparent)}[tone=light]{color:var(--color-text);border-color:color-mix(in srgb,var(--black) var(--alpha-100),transparent);--color-overlay-hover: color-mix(in srgb, var(--black) var(--alpha-50), transparent);--color-overlay-active: color-mix(in srgb, var(--black) var(--alpha-100), transparent)}[level="1"]{box-shadow:0 12px 32px #00000024}[level="2"]{box-shadow:0 4px 6px -2px #0000001f,0 40px 60px -16px #00000038}dropdown-menu{position:relative;display:inline-block;color:inherit}dropdown-group{display:grid;gap:var(--space-4)}dropdown-label{display:block;padding:var(--space-4) var(--space-8);color:var(--color-text-muted);font:inherit;font-size:var(--text-sm);font-weight:600;letter-spacing:.04em;text-transform:uppercase}dropdown-divider{display:block;height:1px;margin:2px 0;background:var(--color-border)}[data-dropdown-trigger][aria-expanded=true],[data-dropdown-trigger][aria-expanded=true]:hover,dropdown-menu[open]::part(trigger),dropdown-menu[open]::part(trigger):hover{background:color-mix(in srgb,var(--color-surface) 88%,black);box-shadow:inset 0 1px 2px #00000014}[data-dropdown-trigger-label],dropdown-menu::part(trigger-label){min-width:0}[data-dropdown-trigger-icon],dropdown-menu::part(trigger-icon){display:inline-flex;align-items:center;justify-content:center;flex:none;color:var(--color-text-muted);transform:translateY(1px)}dropdown-item:focus-visible{outline:2px solid var(--color-focus-ring);outline-offset:2px}ui-popover.dropdown-popover::part(panel){min-width:192px;padding:var(--space-4)}.dropdown-list{display:flex;flex-direction:column;gap:2px}dropdown-item{display:flex;align-items:center;gap:var(--space-8);margin:0;padding:6px 12px;border-radius:var(--radius-8);font:inherit;line-height:1.2;color:inherit;font-weight:var(--font-weight-body);-webkit-user-select:none;user-select:none}dropdown-item>[data-ui-icon]{flex:none}dropdown-item[selected]{background:var(--color-overlay-active)}dropdown-item:hover,dropdown-item[action]:hover{background:var(--color-primary);color:var(--white)}dropdown-item[action]{color:inherit}dropdown-item[danger]{color:var(--color-danger)}dropdown-item[danger]:hover{background:var(--color-danger);color:var(--white)}editable-text{display:inline-block;max-width:100%;vertical-align:top}editable-text>.editable-text-span{display:inline-block;max-width:100%;outline:none;overflow:hidden;white-space:nowrap;cursor:inherit;vertical-align:top}editable-text:not([data-editing])>.editable-text-span{text-overflow:ellipsis}editable-text[data-editing]>.editable-text-span{cursor:text}modal-overlay{color:inherit}modal-overlay::part(backdrop){position:fixed;top:0;right:0;bottom:0;left:0;z-index:var(--layer-overlay);display:flex;align-items:center;justify-content:center;padding:var(--space-16);background:linear-gradient(to bottom,color-mix(in srgb,var(--black) var(--alpha-50),transparent),color-mix(in srgb,var(--black) var(--alpha-400),transparent));backdrop-filter:blur(1px);-webkit-backdrop-filter:blur(1px)}panel-view{display:block}panel-view::part(panel){display:flex;flex-direction:column;gap:var(--space-16);color:var(--color-text)}panel-view::part(header){display:flex;align-items:center;justify-content:space-between;gap:var(--space-12)}panel-view::part(title){margin:0;font:inherit;font-size:var(--text-lg);font-weight:600;color:var(--color-text)}panel-view::part(button){display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;margin:0;border:1px solid var(--color-border);border-radius:var(--radius-4);background:var(--color-surface);color:var(--color-text);box-shadow:none}panel-view::part(button):hover{background:var(--color-interactive-hover)}panel-view::part(button):focus-visible{outline:2px solid var(--color-focus-ring);outline-offset:2px}panel-view::part(icon){display:inline-flex;align-items:center;justify-content:center;flex:none}ui-popover{display:contents}ui-popover::part(panel){position:fixed;inset:0 auto auto 0;margin:0;min-width:192px;max-width:384px;padding:var(--space-16) var(--space-20);border-radius:var(--radius-12);outline:none;z-index:2000}segmented-control{display:inline-flex;align-items:stretch;box-sizing:border-box;height:var(--control-height-md)}segmented-control>button{height:auto}segmented-control[variant=ghost]{background:transparent;box-shadow:none}[tone=dark] segmented-control[variant=ghost]{border-color:var(--tint-400)}segmented-control>button{position:relative}segmented-control>button[icon-only]{width:auto;height:auto;padding:0 var(--space-6)}segmented-control>button:not([variant]):not(:disabled),[tone] segmented-control>button:not([variant]):not(:disabled){background:transparent;border:0;box-shadow:none}segmented-control>button:first-child{border-top-right-radius:0;border-bottom-right-radius:0}segmented-control>button:last-child{border-top-left-radius:0;border-bottom-left-radius:0}segmented-control>button:not(:first-child):not(:last-child){border-radius:0}segmented-control>button:not([variant]):hover:not(:disabled),[tone] segmented-control>button:not([variant]):hover:not(:disabled){background:var(--color-overlay-hover)}segmented-control>button:not([variant]):active:not(:disabled),[tone] segmented-control>button:not([variant]):active:not(:disabled){background:var(--color-overlay-active);box-shadow:none}segmented-control>button:not([variant])[aria-pressed=true]:not(:disabled),segmented-control>button:not([variant])[aria-current]:not([aria-current=false]):not(:disabled),segmented-control>button:not([variant])[aria-expanded=true]:not(:disabled),[tone] segmented-control>button:not([variant])[aria-pressed=true]:not(:disabled),[tone] segmented-control>button:not([variant])[aria-current]:not([aria-current=false]):not(:disabled),[tone] segmented-control>button:not([variant])[aria-expanded=true]:not(:disabled){background:linear-gradient(var(--color-overlay-active),var(--color-overlay-active))}segmented-control>button:not(:last-child):after{content:"";position:absolute;top:0;bottom:0;right:0;width:.5px;background:var(--tint-200);pointer-events:none}[tone=dark] segmented-control>button:not(:last-child):after{background:var(--tint-400)}segmented-control>dropdown-menu{display:inline-flex;align-items:stretch;height:auto}segmented-control>dropdown-menu>[slot=trigger]{height:auto;position:relative}segmented-control>dropdown-menu>[slot=trigger]:not([variant]):not(:disabled),[tone] segmented-control>dropdown-menu>[slot=trigger]:not([variant]):not(:disabled){background:transparent;border:0;box-shadow:none}segmented-control>dropdown-menu:first-child>[slot=trigger]{border-top-right-radius:0;border-bottom-right-radius:0}segmented-control>dropdown-menu:last-child>[slot=trigger]{border-top-left-radius:0;border-bottom-left-radius:0}segmented-control>dropdown-menu:not(:first-child):not(:last-child)>[slot=trigger]{border-radius:0}segmented-control>dropdown-menu>[slot=trigger]:not([variant]):hover:not(:disabled),[tone] segmented-control>dropdown-menu>[slot=trigger]:not([variant]):hover:not(:disabled){background:var(--color-overlay-hover)}segmented-control>dropdown-menu>[slot=trigger]:not([variant]):active:not(:disabled),[tone] segmented-control>dropdown-menu>[slot=trigger]:not([variant]):active:not(:disabled){background:var(--color-overlay-active);box-shadow:none}segmented-control>dropdown-menu>[slot=trigger]:not([variant])[aria-pressed=true]:not(:disabled),segmented-control>dropdown-menu>[slot=trigger]:not([variant])[aria-current]:not([aria-current=false]):not(:disabled),segmented-control>dropdown-menu>[slot=trigger]:not([variant])[aria-expanded=true]:not(:disabled),[tone] segmented-control>dropdown-menu>[slot=trigger]:not([variant])[aria-pressed=true]:not(:disabled),[tone] segmented-control>dropdown-menu>[slot=trigger]:not([variant])[aria-current]:not([aria-current=false]):not(:disabled),[tone] segmented-control>dropdown-menu>[slot=trigger]:not([variant])[aria-expanded=true]:not(:disabled){background:linear-gradient(var(--color-overlay-active),var(--color-overlay-active))}segmented-control[variant=glass]>button,segmented-control[variant=glass]>dropdown-menu{backdrop-filter:blur(20px) brightness(.95) saturate(1.5);-webkit-backdrop-filter:blur(20px) brightness(.95) saturate(1.5)}segmented-control[variant=glass]>button:not(:disabled):hover,segmented-control[variant=glass]>dropdown-menu:has(>[slot=trigger]:not(:disabled):hover){backdrop-filter:blur(20px) brightness(.95) saturate(1.8);-webkit-backdrop-filter:blur(20px) brightness(.95) saturate(1.8)}segmented-control[variant=glass]>button:not(:disabled):active,segmented-control[variant=glass]>dropdown-menu:has(>[slot=trigger]:not(:disabled):active){backdrop-filter:blur(20px) brightness(.95) saturate(2.2);-webkit-backdrop-filter:blur(20px) brightness(.95) saturate(2.2)}segmented-control[variant=glass]>button:not(:disabled)[aria-pressed=true],segmented-control[variant=glass]>button:not(:disabled)[aria-current]:not([aria-current=false]),segmented-control[variant=glass]>dropdown-menu:has(>[slot=trigger]:not(:disabled)[aria-pressed=true]),segmented-control[variant=glass]>dropdown-menu:has(>[slot=trigger]:not(:disabled)[aria-current]:not([aria-current=false])){backdrop-filter:blur(20px) brightness(.95) saturate(1.8);-webkit-backdrop-filter:blur(20px) brightness(.95) saturate(1.8)}segmented-control[variant=glass]>button:not(:disabled)[aria-expanded=true],segmented-control[variant=glass]>dropdown-menu:has(>[slot=trigger]:not(:disabled)[aria-expanded=true]){backdrop-filter:blur(20px) brightness(.95) saturate(2);-webkit-backdrop-filter:blur(20px) brightness(.95) saturate(2)}segmented-control>dropdown-menu:not(:last-child):after{content:"";position:absolute;top:0;bottom:0;right:0;width:.5px;background:var(--tint-200);pointer-events:none}[tone=dark] segmented-control>dropdown-menu:not(:last-child):after{background:var(--tint-400)}ui-spinner{display:inline-flex;align-items:center;justify-content:center;line-height:0;color:inherit}ui-spinner .spin,.spin{display:inline-flex;animation:ui-spinner-spin 1s steps(8,end) infinite}@keyframes ui-spinner-spin{to{transform:rotate(360deg)}}@media (prefers-reduced-motion: reduce){.spin{animation:none}}system-modal{display:flex;flex-direction:column;width:min(400px,100%);box-sizing:border-box;padding:var(--space-32) var(--space-24);border-radius:var(--radius-12)}system-modal header{display:flex;flex-direction:column;align-items:center;gap:var(--space-16);text-align:center}system-modal header>hgroup{display:flex;flex-direction:column;align-items:center;gap:var(--space-4);max-width:100%}system-modal header h2{margin:0;font-size:var(--text-lg);font-weight:600;letter-spacing:.01em;max-width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}system-modal header p{margin:0;font-size:var(--text-base);opacity:.7;max-width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}ui-pill{display:inline-block;vertical-align:baseline;margin:2px 0;padding:0 var(--space-8);font-size:var(--text-sm);font-weight:500;line-height:1.7;border-radius:var(--radius-full);border:1px solid var(--neutral-300);background:var(--neutral-200);color:var(--neutral-900);white-space:nowrap}ui-pill[color=gray]{border-color:var(--neutral-300);background:var(--neutral-200);color:var(--neutral-900)}ui-pill[color=red]{border-color:var(--red-200);background:var(--red-100);color:var(--red-950)}ui-pill[color=orange]{border-color:var(--orange-200);background:var(--orange-100);color:var(--orange-950)}ui-pill[color=yellow]{border-color:var(--yellow-200);background:var(--yellow-100);color:var(--yellow-950)}ui-pill[color=green]{border-color:var(--green-200);background:var(--green-100);color:var(--green-950)}ui-pill[color=blue]{border-color:var(--blue-200);background:var(--blue-100);color:var(--blue-950)}ui-pill[color=purple]{border-color:var(--purple-200);background:var(--purple-100);color:var(--purple-950)}',Qh=new CSSStyleSheet;Qh.replaceSync(OA);const ed=new CSSStyleSheet;try{document.adoptedStyleSheets=[...document.adoptedStyleSheets,Qh,ed]}catch{}hv(document);function dv(n){ed.replaceSync(n)}function rl(){dv("")}function td(n){try{n.adoptedStyleSheets=[...n.adoptedStyleSheets,Qh,ed]}catch{}hv(n)}const MA=new Set(["target","currentTarget","eventPhase","defaultPrevented","isTrusted","timeStamp","srcElement","returnValue","cancelBubble","NONE","CAPTURING_PHASE","AT_TARGET","BUBBLING_PHASE","composedPath","stopPropagation","stopImmediatePropagation","preventDefault","initEvent"]);function NA(n){for(const t of Object.keys(n))if(MA.has(t))throw new Error(`Event payload key "${t}" is reserved; choose a different property name`)}function UA(n,t){NA(t);for(const e of Object.keys(t))Object.defineProperty(n,e,{value:t[e],writable:!0,enumerable:!0,configurable:!0})}function He(){class n extends Event{constructor(e,r){const{type:i,bubbles:s,cancelable:o,composed:a,...c}=r??{};if(i!==void 0)throw new Error('Do not pass "type" in init; use the constructor argument instead');super(e,{bubbles:s,cancelable:o,composed:a}),UA(this,c)}}return n}class tn extends globalThis.EventTarget{}function FA(n,t,e){const r=n.dispose.bind(n);n.dispose=()=>{if(!t())return e(),r()}}function Go(n){var e;class t extends n{constructor(...s){super(...s);w(this,e,!1);FA(this,()=>l(this,e),()=>{S(this,e,!0)})}[Symbol.dispose](){this.dispose()}get disposed(){return l(this,e)}}return e=new WeakMap,t}const HA=He(),WA=He(),ZA=He(),Ra=He(),VA=He(),Wc=He(),pv="0123456789ABCDEFGHJKMNPQRSTVWXYZ",il=32,BA=16,fv=10,Lf=0xffffffffffff;var fr;(function(n){n.Base32IncorrectEncoding="B32_ENC_INVALID",n.DecodeTimeInvalidCharacter="DEC_TIME_CHAR",n.DecodeTimeValueMalformed="DEC_TIME_MALFORMED",n.EncodeTimeNegative="ENC_TIME_NEG",n.EncodeTimeSizeExceeded="ENC_TIME_SIZE_EXCEED",n.EncodeTimeValueMalformed="ENC_TIME_MALFORMED",n.PRNGDetectFailure="PRNG_DETECT",n.ULIDInvalid="ULID_INVALID",n.Unexpected="UNEXPECTED",n.UUIDInvalid="UUID_INVALID"})(fr||(fr={}));class ks extends Error{constructor(t,e){super(`${e} (${t})`),this.name="ULIDError",this.code=t}}function jA(n){const t=Math.floor(n()*il)%il;return pv.charAt(t)}function GA(n){const t=qA(),e=t&&(t.crypto||t.msCrypto)||null;if(typeof(e==null?void 0:e.getRandomValues)=="function")return()=>{const r=new Uint8Array(1);return e.getRandomValues(r),r[0]/256};if(typeof(e==null?void 0:e.randomBytes)=="function")return()=>e.randomBytes(1).readUInt8()/256;throw new ks(fr.PRNGDetectFailure,"Failed to find a reliable PRNG")}function qA(){return KA()?self:typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:null}function YA(n,t){let e="";for(;n>0;n--)e=jA(t)+e;return e}function XA(n,t=fv){if(isNaN(n))throw new ks(fr.EncodeTimeValueMalformed,`Time must be a number: ${n}`);if(n>Lf)throw new ks(fr.EncodeTimeSizeExceeded,`Cannot encode a time larger than ${Lf}: ${n}`);if(n<0)throw new ks(fr.EncodeTimeNegative,`Time must be positive: ${n}`);if(Number.isInteger(n)===!1)throw new ks(fr.EncodeTimeValueMalformed,`Time must be an integer: ${n}`);let e,r="";for(let i=t;i>0;i--)e=n%il,r=pv.charAt(e)+r,n=(n-e)/il;return r}function KA(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}function Wl(n,t){const e=GA(),r=Date.now();return XA(r,fv)+YA(BA,e)}const Fe=4,ct=6,Fs=2,_u=2,nd=8,JA=ct,rd="auto",Bn="auto",In=120,zf=50,le=16,zr=In*Fe+le*(Fe-1),sl=In*ct+le*(ct-1),QA=zr+le*2,e1=200,t1=4,fa=150,n1=10,Of=2,Mf=8,r1=300,i1=4;function gv(n){return yv(n)}function mv(n,t){return yv(n.flatMap(e=>wv(e,t)))}function vv(n){const t=[],e=new Set;for(const r of n){if(r.type==="row"){t.push(`Top-level rows are invalid: ${r.id}`);continue}Sv(r,"strip",t,e)}return{valid:t.length===0,errors:t}}function gr(n){const t=gv(n),e=vv(t);if(!e.valid)throw new Error(`Invalid layout: ${e.errors.join("; ")}`);return{totalNodes:t.length,nodes:t.filter(r=>r.type!=="row").map(l1)}}function yv(n){const t=[];for(const e of n){const r=bv(e);for(const i of r){if(i.type==="row"){t.push(...i.children.map(wn));continue}t.push(i)}}return t}function bv(n){switch(n.type){case"card":return[wn(n)];case"row":{const t=n.children.map(wn);return t.length===0?[]:t.length===1?[t[0]]:[{...n,children:t}]}case"stack":{const t=[];for(const e of n.children){const r=bv(e);for(const i of r){if(i.type==="stack"){t.push(...i.children.map(ku));continue}if(i.type==="row"){t.push({...i,children:i.children.map(wn)});continue}t.push(wn(i))}}return t.length===0?[]:t.length===1?[ku(t[0])]:[{...n,children:t}]}}}function wv(n,t){switch(n.type){case"card":return n.artifactID===t?[]:[wn(n)];case"row":{const e=n.children.filter(r=>r.artifactID!==t).map(wn);return e.length===0?[]:e.length===1?[e[0]]:[{...n,children:e}]}case"stack":{const e=n.children.flatMap(r=>wv(r,t).filter(s=>s.type!=="stack"));return e.length===0?[]:e.length===1?[ku(e[0])]:[{...n,children:e}]}}}function Sv(n,t,e,r){switch(n.type){case"card":_v(n,t,e,r);return;case"row":s1(n,t,e,r);return;case"stack":o1(n,t,e,r);return}}function _v(n,t,e,r){id(n.id,e),typeof n.artifactID!="string"||n.artifactID.length===0?e.push(`Card ${n.id} is missing artifactID`):r.has(n.artifactID)?e.push(`Duplicate artifactID in layout: ${n.artifactID}`):r.add(n.artifactID),a1(n.width)||e.push(`Card ${n.id} width must be an integer in the range ${Fs}-${nd}`),kv(n.height)||e.push(`Card ${n.id} height must be an integer in the range 2-6 or "auto"`);const i=gi(n.width);t==="stack"&&i!==Fe&&e.push(`Stack child ${n.id} width must be ${Fe}`),t==="row"&&i<Fs&&e.push(`Row child ${n.id} must be at least 2 columns wide`)}function s1(n,t,e,r){if(id(n.id,e),t!=="stack"&&e.push(`Row ${n.id} may only appear inside a stack`),kv(n.height,i1)||e.push(`Row ${n.id} height must be an integer in the range 2-4 or "auto"`),!Array.isArray(n.children)||n.children.length===0){e.push(`Row ${n.id} must contain card nodes`);return}let i=0;for(const s of n.children){if(s.type!=="card"){e.push(`Row ${n.id} must contain only card nodes`);continue}_v(s,"row",e,r),i+=gi(s.width)}i!==Fe&&e.push(`Row ${n.id} children must sum to 4 columns`)}function o1(n,t,e,r){if(id(n.id,e),t!=="strip"&&e.push(`Invalid nested stack at ${n.id}; stack children cannot contain another nested stack`),!Array.isArray(n.children)||n.children.length===0){e.push(`Stack ${n.id} must contain at least one child`);return}let i=0,s=0;for(const a of n.children){if(a.type==="stack"){e.push(`Stack ${n.id} cannot contain another nested stack`);continue}if(Sv(a,"stack",e,r),a.height===Bn){s+=1;continue}i+=a.height}if(i>ct&&e.push(`Stack ${n.id} exceeds the 6-row budget`),s===0)return;const o=ct-i;if(o<s*_u||o%s!==0){e.push(`Stack ${n.id} has auto-height children that cannot resolve to whole height >= 2`);return}o/s<_u&&e.push(`Stack ${n.id} has auto-height children below the minimum row size`)}function id(n,t){(typeof n!="string"||n.length===0)&&t.push(`Node id must be a non-empty string: ${String(n)}`)}function a1(n){return n===rd||Number.isInteger(n)&&n>=Fs&&n<=nd}function kv(n,t=JA){return n===Bn||Number.isInteger(n)&&n>=_u&&n<=t}function gi(n){return n===rd?Fe:n}function l1(n){if(n.type==="card")return{id:n.id,type:"card",width:gi(n.width),cards:[{id:n.id,artifactID:n.artifactID,col:1,row:1,width:gi(n.width),height:Ev(n.height,ct)}]};const t=c1(n.children),e=[];let r=1;for(let i=0;i<n.children.length;i+=1){const s=n.children[i],o=t[i];if(s.type==="card")e.push({id:s.id,artifactID:s.artifactID,col:1,row:r,width:Fe,height:o});else{let a=1;for(const c of s.children)e.push({id:c.id,artifactID:c.artifactID,col:a,row:r,width:gi(c.width),height:o}),a+=gi(c.width)}r+=o}return{id:n.id,type:"stack",width:e.reduce((i,s)=>Math.max(i,s.col+s.width-1),1),cards:e}}function c1(n){let t=0,e=0;for(const i of n)i.height===Bn?e+=1:t+=i.height;const r=e>0?(ct-t)/e:0;return n.map(i=>Ev(i.height,r))}function Ev(n,t){return n===Bn?t:n}function wn(n){return{...n}}function ku(n){return n.type==="card"?wn(n):{...n,children:n.children.map(wn)}}function xv(n,t={}){return{id:t.id??Wl(),type:"card",artifactID:n,width:t.width??rd,height:t.height??Bn}}function Av(n,t){return n.some(e=>$v(e,t))}function $v(n,t){switch(n.type){case"card":return n.artifactID===t;case"row":return n.children.some(e=>e.artifactID===t);case"stack":return n.children.some(e=>$v(e,t))}}function Nf(n){return n.layout.flatMap(Tv)}function Tv(n){switch(n.type){case"card":return[n.artifactID];case"row":return n.children.map(t=>t.artifactID);case"stack":return n.children.flatMap(Tv)}}const ae=He(),Eu=He(),ni=He(),u1=He();function h1(n){class t extends Error{constructor(r,i){super(r),this.name=n,i&&Object.assign(this,i)}}return t}const Iv=h1("RequestError"),d1=200,p1=300;class f1{constructor(t,e){g(this,"serverURL");g(this,"token");this.serverURL=t.replace(/\/$/,""),this.token=e.token}async requestJSON(t,e,r){const i=await this.request(t,e,r!==void 0?JSON.stringify(r):void 0,r!==void 0?{"content-type":"application/json"}:void 0),s=await g1(i);if(!i.ok||i.status<d1||i.status>=p1)throw this.createError(typeof s.error=="string"?s.error:i.statusText,i.status);return s}async requestVoid(t,e,r){const i=await this.request(t,e,r!==void 0?JSON.stringify(r):void 0,r!==void 0?{"content-type":"application/json"}:void 0);if(!i.ok)throw this.createError(await Zc(i,i.statusText),i.status)}async requestText(t,e){const r=await this.request(t,e);if(!r.ok)throw this.createError(await Zc(r,r.statusText),r.status);return r.text()}async requestRawVoid(t,e,r){const i=await this.request(t,e,r,{"content-type":"text/plain"});if(!i.ok)throw this.createError(await Zc(i,i.statusText),i.status)}createError(t,e){const r={serverURL:this.serverURL};return e!==void 0&&(r.status=e),new Iv(t,r)}async request(t,e,r,i){const s=`${this.serverURL}${e}`;try{return await fetch(s,{method:t,headers:this.buildHeaders(i),body:r})}catch(o){throw this.createError(o instanceof Error?o.message:"Failed to reach server")}}buildHeaders(t){const e={...t??{}};return this.token&&(e.Authorization=`Bearer ${this.token}`),Object.keys(e).length>0?e:void 0}}async function g1(n){try{return await n.json()}catch{const t=await n.text().catch(()=>"");return t?{message:t}:{}}}async function Zc(n,t){try{const e=await n.json();if(typeof e.error=="string")return e.error;if(typeof e.message=="string")return e.message}catch{}return t}function m1(n){return n.map(t=>`${t.name} (${t.id})`).join(", ")}var Mt,yl,Cv;class v1{constructor(t){w(this,yl);w(this,Mt);S(this,Mt,t)}list(){return l(this,Mt).requestJSON("GET","/screens")}async get(t={}){const e=await f(this,yl,Cv).call(this,t.screenID);return l(this,Mt).requestJSON("GET",`/screens/${encodeURIComponent(e)}`)}create(t){const e={name:t.name};return t.id!==void 0&&(e.id=t.id),l(this,Mt).requestJSON("POST","/screens",e)}update(t){const{screenID:e,...r}=t;return l(this,Mt).requestJSON("PATCH",`/screens/${encodeURIComponent(e)}`,r)}remove(t){return l(this,Mt).requestJSON("DELETE",`/screens/${encodeURIComponent(t.screenID)}`)}}Mt=new WeakMap,yl=new WeakSet,Cv=async function(t){if(t!==void 0)return t;const{screens:e}=await this.list();if(e.length===1)return e[0].id;throw l(this,Mt).createError(`screenID is required when multiple screens exist. Available screens: ${m1(e)}`)};var Ue;class y1{constructor(t){w(this,Ue);S(this,Ue,t)}create(t){const e={kind:t.kind,title:t.title};switch(t.kind){case"markdown":e.externalFilePath=t.externalFilePath;break;case"url":e.externalURL=t.externalURL;break;case"web-bundle":t.skipPending!==void 0&&(e.skipPending=t.skipPending);break}return t.screenID!==void 0&&(e.screenID=t.screenID),l(this,Ue).requestJSON("POST","/artifacts",e)}list(t={}){const e=new URLSearchParams;t.screenID!==void 0&&e.set("screenID",t.screenID),t.unplaced&&e.set("unplaced","true");const r=e.toString();return l(this,Ue).requestJSON("GET",r?`/artifacts?${r}`:"/artifacts")}get(t){return l(this,Ue).requestJSON("GET",`/artifacts/${encodeURIComponent(t.artifactID)}`)}update(t){const e={};return t.title!==void 0&&(e.title=t.title),l(this,Ue).requestJSON("PATCH",`/artifacts/${encodeURIComponent(t.artifactID)}`,e)}edit(t){return l(this,Ue).requestJSON("POST",`/artifacts/${encodeURIComponent(t.artifactID)}/edit`)}commitPending(t){return l(this,Ue).requestJSON("POST",`/artifacts/${encodeURIComponent(t.artifactID)}/commit`)}abandonPending(t){return l(this,Ue).requestVoid("POST",`/artifacts/${encodeURIComponent(t.artifactID)}/abandon`)}attach(t){return l(this,Ue).requestJSON("POST",`/screens/${encodeURIComponent(t.screenID)}/artifacts/${encodeURIComponent(t.artifactID)}`)}detach(t){return l(this,Ue).requestJSON("DELETE",`/screens/${encodeURIComponent(t.screenID)}/artifacts/${encodeURIComponent(t.artifactID)}`)}delete(t){return l(this,Ue).requestJSON("DELETE",`/artifacts/${encodeURIComponent(t.artifactID)}`)}getContent(t){return l(this,Ue).requestText("GET",`/artifacts/${encodeURIComponent(t.artifactID)}/content`)}putContent(t){return l(this,Ue).requestRawVoid("PUT",`/artifacts/${encodeURIComponent(t.artifactID)}/content`,t.content)}}Ue=new WeakMap;var vr;class b1{constructor(t){w(this,vr);S(this,vr,t)}get(){return l(this,vr).requestJSON("GET","/display")}patch(t){const e={};return t.activeScreenID!==void 0&&(e.activeScreenID=t.activeScreenID),t.activeThemeName!==void 0&&(e.activeThemeName=t.activeThemeName),l(this,vr).requestVoid("PATCH","/display",e)}focus(t){const e={artifactID:t.artifactID};return t.screenID!==void 0&&(e.screenID=t.screenID),l(this,vr).requestJSON("POST","/display/focus",e)}}vr=new WeakMap;var js;class w1{constructor(t){w(this,js);S(this,js,t)}async list(){const{views:t}=await l(this,js).requestJSON("GET","/views");return t}}js=new WeakMap;var pn;class S1{constructor(t,e={}){g(this,"screens");g(this,"artifacts");g(this,"display");g(this,"views");w(this,pn);S(this,pn,new f1(t,e)),this.screens=new v1(l(this,pn)),this.artifacts=new y1(l(this,pn)),this.display=new b1(l(this,pn)),this.views=new w1(l(this,pn))}health(){return l(this,pn).requestJSON("GET","/health")}}pn=new WeakMap;const _1={focusCommandInput:{label:"Focus Command Input",trigger:{key:"k",meta:!0}}},k1="Local",E1="store-";function be(n){return new URL(n).origin}function x1(n){return{servers:[{url:be(n),name:k1}],activeServerURL:null,activeScreenID:null,tabs:{},screens:{}}}function A1(n,t){return[...n.tabs[be(t)]??[]]}function $1(n,t,e){const r=be(t),i=n.tabs[r]??[];return i.includes(e)?n:{...n,tabs:{...n.tabs,[r]:[...i,e]}}}function T1(n,t,e){const r=be(t),i=n.tabs[r]??[],s=i.filter(a=>a!==e);if(s.length===i.length)return n;const o={...n.tabs};return s.length===0?delete o[r]:o[r]=s,{...n,tabs:o}}var yr,br,wr;class I1 extends tn{constructor(e,r,i={}){super();w(this,yr);w(this,br);w(this,wr);S(this,yr,`${E1}${e}`),S(this,br,i.storage??C1());const s=l(this,br).getItem(l(this,yr));s===null?(S(this,wr,r),l(this,br).setItem(l(this,yr),JSON.stringify(r))):S(this,wr,R1(JSON.parse(s),r))}get(){return l(this,wr)}set(e){S(this,wr,e),l(this,br).setItem(l(this,yr),JSON.stringify(e)),this.dispatchEvent(new ae("change"))}}yr=new WeakMap,br=new WeakMap,wr=new WeakMap;function C1(){const n=globalThis.localStorage;if(!n)throw new Error("LocalStore: no storage adapter supplied and window.localStorage is unavailable");return n}function R1(n,t){return{servers:Array.isArray(n.servers)?n.servers:t.servers,activeServerURL:typeof n.activeServerURL=="string"||n.activeServerURL===null?n.activeServerURL:t.activeServerURL,activeScreenID:typeof n.activeScreenID=="string"||n.activeScreenID===null?n.activeScreenID:t.activeScreenID,tabs:n.tabs&&typeof n.tabs=="object"?n.tabs:t.tabs,screens:n.screens&&typeof n.screens=="object"?n.screens:t.screens}}const P1=Go(tn);var Sr,Ke,_r,Ve,Rn,Pn,te,si,Rv,Gs,Pv,Dv,Lv,zv,xu,Au,$u,Ov;class D1 extends P1{constructor(e){var i;super();w(this,te);g(this,"id");g(this,"server");w(this,Sr);w(this,Ke,new Map);w(this,_r);w(this,Ve);w(this,Rn);w(this,Pn,null);w(this,Gs,e=>{if(this.disposed)return;const r=e.event;switch(r.type){case"screen-updated":r.screen.id===this.id&&f(this,te,Pv).call(this,r.screen);break;case"artifact-created":break;case"artifact-attached":r.screenID===this.id&&f(this,te,Dv).call(this,r.cardID,r.artifact);break;case"artifact-updated":f(this,te,Lv).call(this,r.artifact);break;case"artifact-removed":r.screenID===this.id&&f(this,te,zv).call(this,r.artifactID);break;case"artifact-content-changed":l(this,Ke).has(r.artifactID)&&this.dispatchEvent(new u1("artifact-content-changed",{artifactID:r.artifactID}));break}});this.id=e.screen.id,this.server=e.server,S(this,Sr,e.localStore),S(this,_r,e.screen.name),S(this,Ve,structuredClone(e.screen.layout));const r=((i=l(this,Sr).get().screens[this.id])==null?void 0:i.scrollPosition)??0;S(this,Rn,Math.max(0,r)),this.server.addEventListener("server-event",l(this,Gs)),f(this,te,Rv).call(this)}get name(){return l(this,_r)}get layout(){return l(this,Ve)}get scrollPosition(){return l(this,Rn)}get artifacts(){return l(this,Ke)}setScrollPosition(e){f(this,te,si).call(this);const r=Math.max(0,e);r!==l(this,Rn)&&(S(this,Rn,r),f(this,te,Ov).call(this),this.dispatchEvent(new ae("change")))}setLayout(e){f(this,te,si).call(this);const r=gv(e);if(!vv(r).valid)return;const s=f(this,te,Au).call(this);S(this,Ve,r),S(this,Pn,{layout:r,snapshot:s}),this.dispatchEvent(new ae("change")),this.server.client.screens.update({screenID:this.id,layout:r.map(o=>structuredClone(o))}).catch(()=>{var o;this.disposed||((o=l(this,Pn))==null?void 0:o.layout)===r&&(S(this,Pn,null),f(this,te,$u).call(this,s),this.dispatchEvent(new ae("change")))})}rename(e){f(this,te,si).call(this),S(this,_r,e),this.dispatchEvent(new ae("change")),this.server.client.screens.update({screenID:this.id,name:e}).catch(()=>{})}async remove(){f(this,te,si).call(this),await this.server.client.screens.remove({screenID:this.id})}removeArtifact(e){if(f(this,te,si).call(this),!l(this,Ke).has(e))return;const r=f(this,te,Au).call(this);f(this,te,xu).call(this,e),this.dispatchEvent(new ae("change")),this.server.client.artifacts.detach({artifactID:e,screenID:this.id}).catch(()=>{this.disposed||(f(this,te,$u).call(this,r),this.dispatchEvent(new ae("change")))})}dispose(){this.server.removeEventListener("server-event",l(this,Gs))}}Sr=new WeakMap,Ke=new WeakMap,_r=new WeakMap,Ve=new WeakMap,Rn=new WeakMap,Pn=new WeakMap,te=new WeakSet,si=function(){if(this.disposed)throw new Error("ScreenModel is disposed")},Rv=async function(){try{const e=await this.server.client.screens.get({screenID:this.id});if(this.disposed)return;for(const r of e.artifacts)l(this,Ke).set(r.id,r);this.dispatchEvent(new ae("change"))}catch{}},Gs=new WeakMap,Pv=function(e){l(this,Pn)&&S(this,Pn,null),S(this,_r,e.name),S(this,Ve,structuredClone(e.layout)),this.dispatchEvent(new ae("change"))},Dv=function(e,r){Av(l(this,Ve),r.id)||S(this,Ve,[...l(this,Ve),xv(r.id,{id:e})]),l(this,Ke).set(r.id,r),this.dispatchEvent(new ae("change"))},Lv=function(e){const r=l(this,Ke).get(e.id);r&&(l(this,Ke).set(e.id,{...r,...e}),this.dispatchEvent(new ae("change")))},zv=function(e){f(this,te,xu).call(this,e)&&this.dispatchEvent(new ae("change"))},xu=function(e){const r=l(this,Ke).delete(e),i=Nf({layout:l(this,Ve)}).length,s=mv(l(this,Ve),e),o=Nf({layout:s}).length;return S(this,Ve,s),r||i!==o},Au=function(){return{layout:structuredClone(l(this,Ve)),artifacts:new Map([...l(this,Ke).entries()].map(([e,r])=>[e,structuredClone(r)]))}},$u=function(e){S(this,Ve,structuredClone(e.layout)),l(this,Ke).clear();for(const[r,i]of e.artifacts)l(this,Ke).set(r,structuredClone(i))},Ov=function(){const e=l(this,Sr).get();l(this,Sr).set({...e,screens:{...e.screens,[this.id]:{scrollPosition:l(this,Rn)}}})};const L1=Go(tn);var Le,Je,Nt,qs,Ys,Xs,je,Pa,Tu,oi;class z1 extends L1{constructor(e){super();w(this,je);w(this,Le);w(this,Je);w(this,Nt,null);w(this,qs,()=>{this.disposed||f(this,je,Pa).call(this)});w(this,Ys,()=>{this.disposed||f(this,je,Pa).call(this)});w(this,Xs,e=>{if(this.disposed)return;const r=e.event;if(r.type==="screen-removed"){this.removeTab(e.serverURL,r.screenID);const i=l(this,Le).get();i.activeServerURL===be(e.serverURL)&&i.activeScreenID===r.screenID&&f(this,je,oi).call(this,e.serverURL,null);return}if(r.type==="screen-changed"){if(r.screenID===null){f(this,je,oi).call(this,e.serverURL,null);return}const i=l(this,Je).servers.get(be(e.serverURL));if(!i||!i.screens.has(r.screenID))return;this.addTab(e.serverURL,r.screenID),f(this,je,oi).call(this,e.serverURL,r.screenID)}});S(this,Le,e.localStore),S(this,Je,e.serverManager),l(this,Le).addEventListener("change",l(this,qs)),l(this,Je).addEventListener("change",l(this,Ys)),l(this,Je).addEventListener("server-event",l(this,Xs)),f(this,je,Pa).call(this)}get activeScreen(){return l(this,Nt)}getTabs(e){const r=be(e),i=A1(l(this,Le).get(),r),s=l(this,Je).servers.get(r);return s?i.filter(o=>s.screens.has(o)):i}hasTab(e,r){return this.getTabs(e).includes(r)}addTab(e,r){const i=be(e),s=l(this,Je).servers.get(i);s&&!s.screens.has(r)||f(this,je,Tu).call(this,$1(l(this,Le).get(),i,r))}removeTab(e,r){f(this,je,Tu).call(this,T1(l(this,Le).get(),e,r))}setActive(e,r){const i=be(e),s=l(this,Je).servers.get(i);!s||!s.screens.has(r)||f(this,je,oi).call(this,i,r)&&s.client.display.patch({activeScreenID:r}).catch(()=>{})}clearActive(){const e=l(this,Le).get().activeServerURL;if(!e||!f(this,je,oi).call(this,e,null))return;const r=l(this,Je).servers.get(e);r==null||r.client.display.patch({activeScreenID:null}).catch(()=>{})}dispose(){var e;l(this,Le).removeEventListener("change",l(this,qs)),l(this,Je).removeEventListener("change",l(this,Ys)),l(this,Je).removeEventListener("server-event",l(this,Xs)),(e=l(this,Nt))==null||e.dispose(),S(this,Nt,null)}}Le=new WeakMap,Je=new WeakMap,Nt=new WeakMap,qs=new WeakMap,Ys=new WeakMap,Xs=new WeakMap,je=new WeakSet,Pa=function(){var c,u,h;const{activeServerURL:e,activeScreenID:r}=l(this,Le).get(),i=e?l(this,Je).servers.get(e)??null:null,s=i&&r?i.screens.get(r)??null:null,o=((c=l(this,Nt))==null?void 0:c.id)??null,a=(s==null?void 0:s.id)??null;o===a&&((u=l(this,Nt))==null?void 0:u.server)===i||((h=l(this,Nt))==null||h.dispose(),S(this,Nt,i&&s?new D1({screen:s,server:i,localStore:l(this,Le)}):null),i&&i.acpClient.setScreenContext(s?{screenID:s.id,screenName:s.name}:null),this.dispatchEvent(new HA("active-screen-changed")))},Tu=function(e){e!==l(this,Le).get()&&(l(this,Le).set(e),this.dispatchEvent(new WA("tabs-changed")))},oi=function(e,r){const i=be(e),s=l(this,Le).get();return s.activeServerURL===i&&s.activeScreenID===r?!1:(l(this,Le).set({...s,activeServerURL:i,activeScreenID:r}),!0)};function A(n,t,e){function r(a,c){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:c,constr:o,traits:new Set},enumerable:!1}),a._zod.traits.has(n))return;a._zod.traits.add(n),t(a,c);const u=o.prototype,h=Object.keys(u);for(let p=0;p<h.length;p++){const v=h[p];v in a||(a[v]=u[v].bind(a))}}const i=(e==null?void 0:e.Parent)??Object;class s extends i{}Object.defineProperty(s,"name",{value:n});function o(a){var c;const u=e!=null&&e.Parent?new s:this;r(u,a),(c=u._zod).deferred??(c.deferred=[]);for(const h of u._zod.deferred)h();return u}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:a=>{var c,u;return e!=null&&e.Parent&&a instanceof e.Parent?!0:(u=(c=a==null?void 0:a._zod)==null?void 0:c.traits)==null?void 0:u.has(n)}}),Object.defineProperty(o,"name",{value:n}),o}class bi extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Mv extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const Nv={};function jn(n){return Nv}function Uv(n){const t=Object.values(n).filter(r=>typeof r=="number");return Object.entries(n).filter(([r,i])=>t.indexOf(+r)===-1).map(([r,i])=>i)}function Iu(n,t){return typeof t=="bigint"?t.toString():t}function sd(n){return{get value(){{const t=n();return Object.defineProperty(this,"value",{value:t}),t}}}}function od(n){return n==null}function ad(n){const t=n.startsWith("^")?1:0,e=n.endsWith("$")?n.length-1:n.length;return n.slice(t,e)}function O1(n,t){const e=(n.toString().split(".")[1]||"").length,r=t.toString();let i=(r.split(".")[1]||"").length;if(i===0&&/\d?e-\d?/.test(r)){const c=r.match(/\d?e-(\d?)/);c!=null&&c[1]&&(i=Number.parseInt(c[1]))}const s=e>i?e:i,o=Number.parseInt(n.toFixed(s).replace(".","")),a=Number.parseInt(t.toFixed(s).replace(".",""));return o%a/10**s}const Uf=Symbol("evaluating");function ne(n,t,e){let r;Object.defineProperty(n,t,{get(){if(r!==Uf)return r===void 0&&(r=Uf,r=e()),r},set(i){Object.defineProperty(n,t,{value:i})},configurable:!0})}function Vr(n,t,e){Object.defineProperty(n,t,{value:e,writable:!0,enumerable:!0,configurable:!0})}function Jn(...n){const t={};for(const e of n){const r=Object.getOwnPropertyDescriptors(e);Object.assign(t,r)}return Object.defineProperties({},t)}function Ff(n){return JSON.stringify(n)}function M1(n){return n.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Fv="captureStackTrace"in Error?Error.captureStackTrace:(...n)=>{};function ol(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}const N1=sd(()=>{var n;if(typeof navigator<"u"&&((n=navigator==null?void 0:navigator.userAgent)!=null&&n.includes("Cloudflare")))return!1;try{const t=Function;return new t(""),!0}catch{return!1}});function ji(n){if(ol(n)===!1)return!1;const t=n.constructor;if(t===void 0||typeof t!="function")return!0;const e=t.prototype;return!(ol(e)===!1||Object.prototype.hasOwnProperty.call(e,"isPrototypeOf")===!1)}function Hv(n){return ji(n)?{...n}:Array.isArray(n)?[...n]:n}const U1=new Set(["string","number","symbol"]);function Gi(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Qn(n,t,e){const r=new n._zod.constr(t??n._zod.def);return(!t||e!=null&&e.parent)&&(r._zod.parent=n),r}function M(n){const t=n;if(!t)return{};if(typeof t=="string")return{error:()=>t};if((t==null?void 0:t.message)!==void 0){if((t==null?void 0:t.error)!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function F1(n){return Object.keys(n).filter(t=>n[t]._zod.optin==="optional"&&n[t]._zod.optout==="optional")}const H1={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 W1(n,t){const e=n._zod.def,r=e.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const s=Jn(n._zod.def,{get shape(){const o={};for(const a in t){if(!(a in e.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&(o[a]=e.shape[a])}return Vr(this,"shape",o),o},checks:[]});return Qn(n,s)}function Z1(n,t){const e=n._zod.def,r=e.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const s=Jn(n._zod.def,{get shape(){const o={...n._zod.def.shape};for(const a in t){if(!(a in e.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&delete o[a]}return Vr(this,"shape",o),o},checks:[]});return Qn(n,s)}function V1(n,t){if(!ji(t))throw new Error("Invalid input to extend: expected a plain object");const e=n._zod.def.checks;if(e&&e.length>0){const s=n._zod.def.shape;for(const o in t)if(Object.getOwnPropertyDescriptor(s,o)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const i=Jn(n._zod.def,{get shape(){const s={...n._zod.def.shape,...t};return Vr(this,"shape",s),s}});return Qn(n,i)}function B1(n,t){if(!ji(t))throw new Error("Invalid input to safeExtend: expected a plain object");const e=Jn(n._zod.def,{get shape(){const r={...n._zod.def.shape,...t};return Vr(this,"shape",r),r}});return Qn(n,e)}function j1(n,t){const e=Jn(n._zod.def,{get shape(){const r={...n._zod.def.shape,...t._zod.def.shape};return Vr(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:[]});return Qn(n,e)}function G1(n,t,e){const i=t._zod.def.checks;if(i&&i.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const o=Jn(t._zod.def,{get shape(){const a=t._zod.def.shape,c={...a};if(e)for(const u in e){if(!(u in a))throw new Error(`Unrecognized key: "${u}"`);e[u]&&(c[u]=n?new n({type:"optional",innerType:a[u]}):a[u])}else for(const u in a)c[u]=n?new n({type:"optional",innerType:a[u]}):a[u];return Vr(this,"shape",c),c},checks:[]});return Qn(t,o)}function q1(n,t,e){const r=Jn(t._zod.def,{get shape(){const i=t._zod.def.shape,s={...i};if(e)for(const o in e){if(!(o in s))throw new Error(`Unrecognized key: "${o}"`);e[o]&&(s[o]=new n({type:"nonoptional",innerType:i[o]}))}else for(const o in i)s[o]=new n({type:"nonoptional",innerType:i[o]});return Vr(this,"shape",s),s}});return Qn(t,r)}function mi(n,t=0){var e;if(n.aborted===!0)return!0;for(let r=t;r<n.issues.length;r++)if(((e=n.issues[r])==null?void 0:e.continue)!==!0)return!0;return!1}function vi(n,t){return t.map(e=>{var r;return(r=e).path??(r.path=[]),e.path.unshift(n),e})}function ga(n){return typeof n=="string"?n:n==null?void 0:n.message}function Gn(n,t,e){var i,s,o,a,c,u;const r={...n,path:n.path??[]};if(!n.message){const h=ga((o=(s=(i=n.inst)==null?void 0:i._zod.def)==null?void 0:s.error)==null?void 0:o.call(s,n))??ga((a=t==null?void 0:t.error)==null?void 0:a.call(t,n))??ga((c=e.customError)==null?void 0:c.call(e,n))??ga((u=e.localeError)==null?void 0:u.call(e,n))??"Invalid input";r.message=h}return delete r.inst,delete r.continue,t!=null&&t.reportInput||delete r.input,r}function ld(n){return Array.isArray(n)?"array":typeof n=="string"?"string":"unknown"}function Hs(...n){const[t,e,r]=n;return typeof t=="string"?{message:t,code:"custom",input:e,inst:r}:{...t}}const Wv=(n,t)=>{n.name="$ZodError",Object.defineProperty(n,"_zod",{value:n._zod,enumerable:!1}),Object.defineProperty(n,"issues",{value:t,enumerable:!1}),n.message=JSON.stringify(t,Iu,2),Object.defineProperty(n,"toString",{value:()=>n.message,enumerable:!1})},Zv=A("$ZodError",Wv),Vv=A("$ZodError",Wv,{Parent:Error});function Y1(n,t=e=>e.message){const e={},r=[];for(const i of n.issues)i.path.length>0?(e[i.path[0]]=e[i.path[0]]||[],e[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:e}}function X1(n,t=e=>e.message){const e={_errors:[]},r=i=>{for(const s of i.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(o=>r({issues:o}));else if(s.code==="invalid_key")r({issues:s.issues});else if(s.code==="invalid_element")r({issues:s.issues});else if(s.path.length===0)e._errors.push(t(s));else{let o=e,a=0;for(;a<s.path.length;){const c=s.path[a];a===s.path.length-1?(o[c]=o[c]||{_errors:[]},o[c]._errors.push(t(s))):o[c]=o[c]||{_errors:[]},o=o[c],a++}}};return r(n),e}const cd=n=>(t,e,r,i)=>{const s=r?Object.assign(r,{async:!1}):{async:!1},o=t._zod.run({value:e,issues:[]},s);if(o instanceof Promise)throw new bi;if(o.issues.length){const a=new((i==null?void 0:i.Err)??n)(o.issues.map(c=>Gn(c,s,jn())));throw Fv(a,i==null?void 0:i.callee),a}return o.value},ud=n=>async(t,e,r,i)=>{const s=r?Object.assign(r,{async:!0}):{async:!0};let o=t._zod.run({value:e,issues:[]},s);if(o instanceof Promise&&(o=await o),o.issues.length){const a=new((i==null?void 0:i.Err)??n)(o.issues.map(c=>Gn(c,s,jn())));throw Fv(a,i==null?void 0:i.callee),a}return o.value},Zl=n=>(t,e,r)=>{const i=r?{...r,async:!1}:{async:!1},s=t._zod.run({value:e,issues:[]},i);if(s instanceof Promise)throw new bi;return s.issues.length?{success:!1,error:new(n??Zv)(s.issues.map(o=>Gn(o,i,jn())))}:{success:!0,data:s.value}},K1=Zl(Vv),Vl=n=>async(t,e,r)=>{const i=r?Object.assign(r,{async:!0}):{async:!0};let s=t._zod.run({value:e,issues:[]},i);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new n(s.issues.map(o=>Gn(o,i,jn())))}:{success:!0,data:s.value}},J1=Vl(Vv),Q1=n=>(t,e,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return cd(n)(t,e,i)},e$=n=>(t,e,r)=>cd(n)(t,e,r),t$=n=>async(t,e,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return ud(n)(t,e,i)},n$=n=>async(t,e,r)=>ud(n)(t,e,r),r$=n=>(t,e,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Zl(n)(t,e,i)},i$=n=>(t,e,r)=>Zl(n)(t,e,r),s$=n=>async(t,e,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Vl(n)(t,e,i)},o$=n=>async(t,e,r)=>Vl(n)(t,e,r),a$=/^[cC][^\s-]{8,}$/,l$=/^[0-9a-z]+$/,c$=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,u$=/^[0-9a-vA-V]{20}$/,h$=/^[A-Za-z0-9]{27}$/,d$=/^[a-zA-Z0-9_-]{21}$/,p$=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,f$=/^([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})$/,Hf=n=>n?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${n}[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)$/,g$=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,m$="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function v$(){return new RegExp(m$,"u")}const y$=/^(?:(?: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])$/,b$=/^(([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}|:))$/,w$=/^((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])$/,S$=/^(([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])$/,_$=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Bv=/^[A-Za-z0-9_-]*$/,k$=/^\+[1-9]\d{6,14}$/,jv="(?:(?:\\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])))",E$=new RegExp(`^${jv}$`);function Gv(n){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof n.precision=="number"?n.precision===-1?`${t}`:n.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${n.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function x$(n){return new RegExp(`^${Gv(n)}$`)}function A$(n){const t=Gv({precision:n.precision}),e=["Z"];n.local&&e.push(""),n.offset&&e.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${t}(?:${e.join("|")})`;return new RegExp(`^${jv}T(?:${r})$`)}const $$=n=>{const t=n?`[\\s\\S]{${(n==null?void 0:n.minimum)??0},${(n==null?void 0:n.maximum)??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},T$=/^-?\d+$/,qv=/^-?\d+(?:\.\d+)?$/,I$=/^(?:true|false)$/i,C$=/^[^A-Z]*$/,R$=/^[^a-z]*$/,it=A("$ZodCheck",(n,t)=>{var e;n._zod??(n._zod={}),n._zod.def=t,(e=n._zod).onattach??(e.onattach=[])}),Yv={number:"number",bigint:"bigint",object:"date"},Xv=A("$ZodCheckLessThan",(n,t)=>{it.init(n,t);const e=Yv[typeof t.value];n._zod.onattach.push(r=>{const i=r._zod.bag,s=(t.inclusive?i.maximum:i.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<s&&(t.inclusive?i.maximum=t.value:i.exclusiveMaximum=t.value)}),n._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:e,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:n,continue:!t.abort})}}),Kv=A("$ZodCheckGreaterThan",(n,t)=>{it.init(n,t);const e=Yv[typeof t.value];n._zod.onattach.push(r=>{const i=r._zod.bag,s=(t.inclusive?i.minimum:i.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>s&&(t.inclusive?i.minimum=t.value:i.exclusiveMinimum=t.value)}),n._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:e,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:n,continue:!t.abort})}}),P$=A("$ZodCheckMultipleOf",(n,t)=>{it.init(n,t),n._zod.onattach.push(e=>{var r;(r=e._zod.bag).multipleOf??(r.multipleOf=t.value)}),n._zod.check=e=>{if(typeof e.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof e.value=="bigint"?e.value%t.value===BigInt(0):O1(e.value,t.value)===0)||e.issues.push({origin:typeof e.value,code:"not_multiple_of",divisor:t.value,input:e.value,inst:n,continue:!t.abort})}}),D$=A("$ZodCheckNumberFormat",(n,t)=>{var o;it.init(n,t),t.format=t.format||"float64";const e=(o=t.format)==null?void 0:o.includes("int"),r=e?"int":"number",[i,s]=H1[t.format];n._zod.onattach.push(a=>{const c=a._zod.bag;c.format=t.format,c.minimum=i,c.maximum=s,e&&(c.pattern=T$)}),n._zod.check=a=>{const c=a.value;if(e){if(!Number.isInteger(c)){a.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:c,inst:n});return}if(!Number.isSafeInteger(c)){c>0?a.issues.push({input:c,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:n,origin:r,inclusive:!0,continue:!t.abort}):a.issues.push({input:c,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:n,origin:r,inclusive:!0,continue:!t.abort});return}}c<i&&a.issues.push({origin:"number",input:c,code:"too_small",minimum:i,inclusive:!0,inst:n,continue:!t.abort}),c>s&&a.issues.push({origin:"number",input:c,code:"too_big",maximum:s,inclusive:!0,inst:n,continue:!t.abort})}}),L$=A("$ZodCheckMaxLength",(n,t)=>{var e;it.init(n,t),(e=n._zod.def).when??(e.when=r=>{const i=r.value;return!od(i)&&i.length!==void 0}),n._zod.onattach.push(r=>{const i=r._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<i&&(r._zod.bag.maximum=t.maximum)}),n._zod.check=r=>{const i=r.value;if(i.length<=t.maximum)return;const o=ld(i);r.issues.push({origin:o,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:n,continue:!t.abort})}}),z$=A("$ZodCheckMinLength",(n,t)=>{var e;it.init(n,t),(e=n._zod.def).when??(e.when=r=>{const i=r.value;return!od(i)&&i.length!==void 0}),n._zod.onattach.push(r=>{const i=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>i&&(r._zod.bag.minimum=t.minimum)}),n._zod.check=r=>{const i=r.value;if(i.length>=t.minimum)return;const o=ld(i);r.issues.push({origin:o,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:n,continue:!t.abort})}}),O$=A("$ZodCheckLengthEquals",(n,t)=>{var e;it.init(n,t),(e=n._zod.def).when??(e.when=r=>{const i=r.value;return!od(i)&&i.length!==void 0}),n._zod.onattach.push(r=>{const i=r._zod.bag;i.minimum=t.length,i.maximum=t.length,i.length=t.length}),n._zod.check=r=>{const i=r.value,s=i.length;if(s===t.length)return;const o=ld(i),a=s>t.length;r.issues.push({origin:o,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:n,continue:!t.abort})}}),Bl=A("$ZodCheckStringFormat",(n,t)=>{var e,r;it.init(n,t),n._zod.onattach.push(i=>{const s=i._zod.bag;s.format=t.format,t.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(t.pattern))}),t.pattern?(e=n._zod).check??(e.check=i=>{t.pattern.lastIndex=0,!t.pattern.test(i.value)&&i.issues.push({origin:"string",code:"invalid_format",format:t.format,input:i.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:n,continue:!t.abort})}):(r=n._zod).check??(r.check=()=>{})}),M$=A("$ZodCheckRegex",(n,t)=>{Bl.init(n,t),n._zod.check=e=>{t.pattern.lastIndex=0,!t.pattern.test(e.value)&&e.issues.push({origin:"string",code:"invalid_format",format:"regex",input:e.value,pattern:t.pattern.toString(),inst:n,continue:!t.abort})}}),N$=A("$ZodCheckLowerCase",(n,t)=>{t.pattern??(t.pattern=C$),Bl.init(n,t)}),U$=A("$ZodCheckUpperCase",(n,t)=>{t.pattern??(t.pattern=R$),Bl.init(n,t)}),F$=A("$ZodCheckIncludes",(n,t)=>{it.init(n,t);const e=Gi(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position}}${e}`:e);t.pattern=r,n._zod.onattach.push(i=>{const s=i._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(r)}),n._zod.check=i=>{i.value.includes(t.includes,t.position)||i.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:i.value,inst:n,continue:!t.abort})}}),H$=A("$ZodCheckStartsWith",(n,t)=>{it.init(n,t);const e=new RegExp(`^${Gi(t.prefix)}.*`);t.pattern??(t.pattern=e),n._zod.onattach.push(r=>{const i=r._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(e)}),n._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:n,continue:!t.abort})}}),W$=A("$ZodCheckEndsWith",(n,t)=>{it.init(n,t);const e=new RegExp(`.*${Gi(t.suffix)}$`);t.pattern??(t.pattern=e),n._zod.onattach.push(r=>{const i=r._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(e)}),n._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:n,continue:!t.abort})}}),Z$=A("$ZodCheckOverwrite",(n,t)=>{it.init(n,t),n._zod.check=e=>{e.value=t.tx(e.value)}});class V${constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const r=t.split(`
|
|
4
|
+
`+t.prev}function da(n,t){var e=ku(n),r=[];if(e){r.length=n.length;for(var i=0;i<n.length;i++)r[i]=dn(n,i)?t(n[i],n):""}var s=typeof zc=="function"?zc(n):[],o;if(ji){o={};for(var a=0;a<s.length;a++)o["$"+s[a]]=s[a]}for(var c in n)dn(n,c)&&(e&&String(Number(c))===c&&c<n.length||ji&&o["$"+c]instanceof Symbol||(Fm.call(/[^\w$]/,c)?r.push(t(c,n)+": "+t(n[c],n)):r.push(c+": "+t(n[c],n))));if(typeof zc=="function")for(var u=0;u<s.length;u++)Hm.call(n,s[u])&&r.push("["+t(s[u])+"]: "+t(n[s[u]],n));return r}var cx=ns,ux=X,Wl=function(n,t,e){for(var r=n,i;(i=r.next)!=null;r=i)if(i.key===t)return r.next=i.next,e||(i.next=n.next,n.next=i),i},hx=function(n,t){if(n){var e=Wl(n,t);return e&&e.value}},dx=function(n,t,e){var r=Wl(n,t);r?r.value=e:n.next={key:t,next:n.next,value:e}},px=function(n,t){return n?!!Wl(n,t):!1},fx=function(n,t){if(n)return Wl(n,t,!0)},gx=function(){var t,e={assert:function(r){if(!e.has(r))throw new ux("Side channel does not contain "+cx(r))},delete:function(r){var i=t&&t.next,s=fx(t,r);return s&&i&&i===s&&(t=void 0),!!s},get:function(r){return hx(t,r)},has:function(r){return px(t,r)},set:function(r,i){t||(t={next:void 0}),dx(t,r,i)}};return e},mx=yt,Go=Xn(),vx=ns,yx=X,sf=mx("%Map%",!0),bx=Go("Map.prototype.get",!0),wx=Go("Map.prototype.set",!0),Sx=Go("Map.prototype.has",!0),_x=Go("Map.prototype.delete",!0),kx=Go("Map.prototype.size",!0),Gm=!!sf&&function(){var t,e={assert:function(r){if(!e.has(r))throw new yx("Side channel does not contain "+vx(r))},delete:function(r){if(t){var i=_x(t,r);return kx(t)===0&&(t=void 0),i}return!1},get:function(r){if(t)return bx(t,r)},has:function(r){return t?Sx(t,r):!1},set:function(r,i){t||(t=new sf),wx(t,r,i)}};return e},xx=yt,Zl=Xn(),Ex=ns,pa=Gm,Ax=X,ei=xx("%WeakMap%",!0),$x=Zl("WeakMap.prototype.get",!0),Tx=Zl("WeakMap.prototype.set",!0),Ix=Zl("WeakMap.prototype.has",!0),Cx=Zl("WeakMap.prototype.delete",!0),Rx=ei?function(){var t,e,r={assert:function(i){if(!r.has(i))throw new Ax("Side channel does not contain "+Ex(i))},delete:function(i){if(ei&&i&&(typeof i=="object"||typeof i=="function")){if(t)return Cx(t,i)}else if(pa&&e)return e.delete(i);return!1},get:function(i){return ei&&i&&(typeof i=="object"||typeof i=="function")&&t?$x(t,i):e&&e.get(i)},has:function(i){return ei&&i&&(typeof i=="object"||typeof i=="function")&&t?Ix(t,i):!!e&&e.has(i)},set:function(i,s){ei&&i&&(typeof i=="object"||typeof i=="function")?(t||(t=new ei),Tx(t,i,s)):pa&&(e||(e=pa()),e.set(i,s))}};return r}:pa,Px=X,Dx=ns,Lx=gx,zx=Gm,Ox=Rx,Mx=Ox||zx||Lx,Nx=function(){var t,e={assert:function(r){if(!e.has(r))throw new Px("Side channel does not contain "+Dx(r))},delete:function(r){return!!t&&t.delete(r)},get:function(r){return t&&t.get(r)},has:function(r){return!!t&&t.has(r)},set:function(r,i){t||(t=Mx()),t.set(r,i)}};return e},Ux=xn,fs=Nx(),an=X,Gh={assert:function(n,t){if(!n||typeof n!="object"&&typeof n!="function")throw new an("`O` is not an object");if(typeof t!="string")throw new an("`slot` must be a string");if(fs.assert(n),!Gh.has(n,t))throw new an("`"+t+"` is not present on `O`")},get:function(n,t){if(!n||typeof n!="object"&&typeof n!="function")throw new an("`O` is not an object");if(typeof t!="string")throw new an("`slot` must be a string");var e=fs.get(n);return e&&e["$"+t]},has:function(n,t){if(!n||typeof n!="object"&&typeof n!="function")throw new an("`O` is not an object");if(typeof t!="string")throw new an("`slot` must be a string");var e=fs.get(n);return!!e&&Ux(e,"$"+t)},set:function(n,t,e){if(!n||typeof n!="object"&&typeof n!="function")throw new an("`O` is not an object");if(typeof t!="string")throw new an("`slot` must be a string");var r=fs.get(n);r||(r={},fs.set(n,r)),r["$"+t]=e}};Object.freeze&&Object.freeze(Gh);var qh=Gh,qm=_n,Vn=qh,qo=function n(t,e){if(!(this instanceof n))return new n(t,e);if(t!=="normal"&&t!=="break"&&t!=="continue"&&t!=="return"&&t!=="throw")throw new qm('Assertion failed: `type` must be one of "normal", "break", "continue", "return", or "throw"');Vn.set(this,"[[Type]]",t),Vn.set(this,"[[Value]]",e)};qo.prototype.type=function(){return Vn.get(this,"[[Type]]")};qo.prototype.value=function(){return Vn.get(this,"[[Value]]")};qo.prototype["?"]=function(){var t=Vn.get(this,"[[Type]]"),e=Vn.get(this,"[[Value]]");if(t==="throw")throw e;return e};qo.prototype["!"]=function(){var t=Vn.get(this,"[[Type]]");if(t!=="normal")throw new qm('Assertion failed: Completion Record is not of type "normal"');return Vn.get(this,"[[Value]]")};var Yh=qo,Fx=Yh,Xh=function(t){return new Fx("normal",t)},Mc,of;function Hx(){if(of)return Mc;of=1;var n=Ji;return Mc=function(){return n()&&!!Symbol.toStringTag},Mc}var Wx=yt,af=Wx("%Object.defineProperty%",!0),Zx=Hx()(),Vx=xn,Bx=X,fa=Zx?Symbol.toStringTag:null,Ym=function(t,e){var r=arguments.length>2&&!!arguments[2]&&arguments[2].force,i=arguments.length>2&&!!arguments[2]&&arguments[2].nonConfigurable;if(typeof r<"u"&&typeof r!="boolean"||typeof i<"u"&&typeof i!="boolean")throw new Bx("if provided, the `overrideIfSet` and `nonConfigurable` options must be booleans");fa&&(r||!Vx(t,fa))&&(af?af(t,fa,{configurable:!i,enumerable:!1,value:e,writable:!1}):t[fa]=e)},Xm={exports:{}},jx=yt,lf=pm,Gx=Ul(),cf=Ki,uf=X,qx=jx("%Math.floor%"),Yx=function(t,e){if(typeof t!="function")throw new uf("`fn` is not a function");if(typeof e!="number"||e<0||e>4294967295||qx(e)!==e)throw new uf("`length` must be a positive 32-bit integer");var r=arguments.length>2&&!!arguments[2],i=!0,s=!0;if("length"in t&&cf){var o=cf(t,"length");o&&!o.configurable&&(i=!1),o&&!o.writable&&(s=!1)}return(i||s||!r)&&(Gx?lf(t,"length",e,!0,!0):lf(t,"length",e)),t},Xx=Wo,Kx=Mh,Jx=xm,Qx=function(){return Jx(Xx,Kx,arguments)};(function(n){var t=Yx,e=Ho,r=Fl,i=Qx;n.exports=function(o){var a=r(arguments),c=1+o.length-(arguments.length-1);return t(a,c>0?c:0,!0)},e?e(n.exports,"apply",{value:i}):n.exports.apply=i})(Xm);var Kh=Xm.exports,eE=function(t,e){for(var r=0;r<t.length;r+=1)if(!e(t[r],r,t))return!1;return!0},tE=Object,nE=function(t){return t&&typeof t=="object"&&(typeof t["[[ResourceValue]]"]>"u"||tE(t["[[ResourceValue]]"])===t["[[ResourceValue]]"])&&(t["[[Hint]]"]==="SYNC-DISPOSE"||t["[[Hint]]"]==="ASYNC-DISPOSE")&&(typeof t["[[DisposeMethod]]"]=="function"||typeof t["[[DisposeMethod]]"]>"u")},rE=xn,iE=Nh(),sE=eE,oE=nE,aE=function(t){return t&&typeof t=="object"&&rE(t,"[[DisposableResourceStack]]")&&iE(t["[[DisposableResourceStack]]"])&&(t["[[DisposableResourceStack]]"].length===0||sE(t["[[DisposableResourceStack]]"],oE))},lE=kn,cE=function(t){if(t===null)return"Null";if(typeof t>"u")return"Undefined";if(lE(t))return"Object";if(typeof t=="number")return"Number";if(typeof t=="boolean")return"Boolean";if(typeof t=="string")return"String"},uE=cE,Jh=function(t){return typeof t=="symbol"?"Symbol":typeof t=="bigint"?"BigInt":uE(t)},hE=X,dE=ns,pE=es,fE=function(t,e){if(!pE(e))throw new hE("Assertion failed: P is not a Property Key, got "+dE(e));return t[e]},hf=X,gE=fE,mE=ts,vE=es,df=ns,yE=function(t,e){if(!vE(e))throw new hf("Assertion failed: P is not a Property Key");var r=gE(t,e);if(r!=null){if(!mE(r))throw new hf(df(e)+" is not a function: "+df(r));return r}},Eu={exports:{}},bE=yt,wE=bE,pf=wE("%Reflect.construct%",!0),ol=jo;try{ol({},"",{"[[Get]]":function(){}})}catch{ol=null}if(ol&&pf){var ff={},gf={};ol(gf,"length",{"[[Get]]":function(){throw ff},"[[Enumerable]]":!0}),Eu.exports=function(t){try{pf(t,gf)}catch(e){return e===ff}}}else Eu.exports=function(t){return typeof t=="function"&&!!t.prototype};var SE=Eu.exports,Nc=X,mf=ts,_E=SE,kE=function(t){if(!_E(t))throw new Nc("C must be a constructor");var e={"[[Resolve]]":void 0,"[[Reject]]":void 0},r=new t(function(i,s){if(typeof e["[[Resolve]]"]<"u"||typeof e["[[Reject]]"]<"u")throw new Nc("executor has already been called");e["[[Resolve]]"]=i,e["[[Reject]]"]=s});if(!mf(e["[[Resolve]]"])||!mf(e["[[Reject]]"]))throw new Nc("executor must provide valid resolve and reject functions");return{"[[Promise]]":r,"[[Resolve]]":e["[[Resolve]]"],"[[Reject]]":e["[[Reject]]"]}},vf=_n,xE=X,Uc=Hl,yf=yE,EE=kE,AE=Jh,bf=Wh(),wf=Zh(),$E=function(t,e){if(AE(t)!=="Object")throw new xE("`V` must be an Object");if(e!=="SYNC-DISPOSE"&&e!=="ASYNC-DISPOSE")throw new vf("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");var r;if(e==="ASYNC-DISPOSE"&&wf&&(r=yf(t,wf)),!r){if(!bf)throw new vf("`Symbol.dispose` is not supported");if(r=yf(t,bf),typeof r<"u")return function(){var i=this;if(e==="ASYNC-DISPOSE"){var s=EE(Promise);try{Uc(r,i),Uc(s["[[Resolve]]"],void 0,[void 0])}catch(o){s["[[Reject]]"](o)}return s["[[Promise]]"]}Uc(r,i)}}return r},TE=_n,Fc=X,IE=ts,CE=Jh,RE=$E,PE=function(t,e){if(e!=="SYNC-DISPOSE"&&e!=="ASYNC-DISPOSE")throw new TE("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");var r;if(arguments.length<3)if(t==null)t=void 0,r=void 0;else{if(typeof t<"u"&&CE(t)!=="Object")throw new Fc("`V` must be an Object, or `null` or `undefined`");if(r=RE(t,e),typeof r>"u")throw new Fc("dispose method must not be `undefined` on `V` when an object `V` is provided")}else if(r=arguments[2],!IE(r))throw new Fc("`method`, when provided, must be a function");return{"[[ResourceValue]]":t,"[[Hint]]":e,"[[DisposeMethod]]":r}},DE=_n,ga=X,LE=aE,Sf=PE,zE=Xn(),OE=zE("Array.prototype.push"),Km=function(t,e,r){if(!LE(t))throw new ga("Assertion failed: `disposeCapability` must be a DisposeCapability Record");if(r!=="SYNC-DISPOSE"&&r!=="ASYNC-DISPOSE")throw new DE("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");var i=arguments.length>3?arguments[3]:void 0;if(arguments.length>3&&typeof i!="function")throw new ga("Assertion failed: `method`, when present, must be a function");if(!t["[[DisposableResourceStack]]"])throw new ga("Assertion failed: `disposeCapability.[[DisposableResourceStack]]` must not be ~EMPTY~");var s;if(arguments.length<4){if(e==null&&r==="SYNC_DISPOSE")return"UNUSED";s=Sf(e,r)}else{if(typeof e<"u")throw new ga("Assertion failed: `V` must be undefined when `method` is present");s=Sf(void 0,r,i)}return OE(t["[[DisposableResourceStack]]"],s),"UNUSED"},Hc,_f;function Qh(){if(_f)return Hc;_f=1;var n=yt,t=Kh,e=_n,r=n("%Promise.resolve%",!0),i=r&&t(r);return Hc=function(o,a){if(!i)throw new e("This environment does not support Promises.");return i(o,a)},Hc}var Wc,kf;function ME(){if(kf)return Wc;kf=1;var n=yt,t=_n,e=n("%Promise%",!0),r=Hl,i=Qh(),s=Jh;return Wc=function(a,c,u){if(typeof a<"u"&&s(a)!=="Object")throw new t("Assertion failed: `V` must be `undefined` or an Object");if(c!=="SYNC-DISPOSE"&&c!=="ASYNC-DISPOSE")throw new t("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");if(typeof u<"u"&&typeof u!="function")throw new t("Assertion failed: `method` must be `undefined` or a function");var h=typeof u>"u"?u:r(u,a);if(c==="ASYNC-DISPOSE")return i(e,h)},Wc}var Zc,xf;function NE(){if(xf)return Zc;xf=1;var n=Yh;return Zc=function(e){return new n("throw",e)},Zc}var UE=yt,Vc=_n,Ef=X,FE=UE("%Promise%",!0),HE=Xn(),Af=HE("Promise.prototype.then",!0),WE=Yh,$f=ME(),ZE=Xh,VE=Qh(),Tf=NE(),BE=Um(),Jm=function(t,e){if(!(e instanceof WE))throw new Ef("`completion` must be a Completion Record");var r=t["[[DisposableResourceStack]]"];if(!r)throw new Ef("Assertion failed: `disposeCapability.[[DisposableResourceStack]]` must not be ~EMPTY~");for(var i,s=r.length-1;s>=0;s-=1)if(!i)i=r[s]["[[Hint]]"];else if(i!==r[s]["[[Hint]]"])throw new Vc("mixed hint stacks are not supported");for(var o=i==="ASYNC-DISPOSE"&&VE(FE,e),a=function(v){if(e.type()==="throw"){var m=e.value(),_=new BE(v,m);e=Tf(_)}else e=Tf(v)},c=i==="ASYNC-DISPOSE"&&function(m){return Af(o,function(){var _=$f(m["[[ResourceValue]]"],m["[[Hint]]"],m["[[DisposeMethod]]"]);if(!_)throw new Vc("Assertion failed: non-`~ASYNC-DISPOSE~` resource returned a promise from Dispose");return Af(_,ZE)},a)},u=r.length-1;u>=0;u-=1)if(i==="ASYNC-DISPOSE")o=c(r[u]);else{var h=r[u];try{var p=$f(h["[[ResourceValue]]"],h["[[Hint]]"],h["[[DisposeMethod]]"]);if(p)throw new Vc("Assertion failed: `~SYNC-DISPOSE~` resource returned something from Dispose")}catch(v){a(v)}}return t["[[DisposableResourceStack]]"]=null,i==="ASYNC-DISPOSE"?o:e},Qm=function(){var t=[];return{"[[DisposableResourceStack]]":t}},Vl=Dh,ed=X,jE=Hl,rs=Fh,GE=jo,ev=ts,qE=Xh,nt=qh,YE=Ym,tv=Wr.supportsDescriptors,XE=Kh,td=Km,KE=Jm,nv=Qm,If=Wh(),ft=function n(){if(!(this instanceof n)||nt.has(this,"[[DisposableState]]")||nt.has(this,"[[DisposeCapability]]"))throw new ed("can only be used with new");nt.set(this,"[[DisposableState]]","PENDING"),nt.set(this,"[[DisposeCapability]]",nv())},rv=function(){var t=this;return nt.assert(t,"[[DisposableState]]"),nt.get(t,"[[DisposableState]]")==="DISPOSED"},Yo=XE(rv);tv?GE(ft.prototype,"disposed",{"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Get]]":rv}):ft.prototype.disposed=!1;var iv=function(t){nt.set(t,"[[DisposableState]]","DISPOSED"),tv||(t.disposed=!0)};rs(ft.prototype,"dispose",function(){var t=this;if(!Yo(t))return iv(t),KE(nt.get(t,"[[DisposeCapability]]"),qE())["?"]()});rs(ft.prototype,"use",function(t){var e=this;if(Yo(e))throw new Vl("a disposed stack can not use anything new");return td(nt.get(e,"[[DisposeCapability]]"),t,"SYNC-DISPOSE"),t});rs(ft.prototype,"adopt",function(t,e){var r=this;if(Yo(r))throw new Vl("a disposed stack can not use anything new");if(!ev(e))throw new ed("`onDispose` must be a function");var i=function(){return jE(e,void 0,[t])};return td(nt.get(r,"[[DisposeCapability]]"),void 0,"SYNC-DISPOSE",i),t});rs(ft.prototype,"defer",function(t){var e=this;if(Yo(e))throw new Vl("a disposed stack can not defer anything new");if(!ev(t))throw new ed("`onDispose` must be a function");td(nt.get(e,"[[DisposeCapability]]"),void 0,"SYNC-DISPOSE",t)});rs(ft.prototype,"move",function(){var t=this;if(Yo(t))throw new Vl("a disposed stack can not use anything new");var e=new ft;return nt.set(e,"[[DisposeCapability]]",nt.get(t,"[[DisposeCapability]]")),nt.set(t,"[[DisposeCapability]]",nv()),iv(t),e});If&&rs(ft.prototype,If,ft.prototype.dispose);YE(ft.prototype,"DisposableStack");var JE=ft,QE=JE,eA=function(){return typeof DisposableStack=="function"?DisposableStack:QE},tA=Wr,nA=Rh(),rA=eA,iA=function(){var t=rA();return tA(nA,{DisposableStack:t},{DisposableStack:!0}),t},sA=yt,Bl=Dh,nd=X,Cf=sA("%Promise%",!0),rd=Km,oA=Hl,is=Fh,aA=jo,lA=Jm,sv=ts,ov=Qm,cA=Xh,Rf=Qh(),rt=qh,uA=Ym,av=Wr.supportsDescriptors,hA=Kh,dA=Xn(),pA=dA("Promise.prototype.then",!0),Pf=Zh(),gt=function n(){if(!(this instanceof n)||rt.has(this,"[[AsyncDisposableState]]")||rt.has(this,"[[DisposeCapability]]"))throw new nd("can only be used with new");rt.set(this,"[[AsyncDisposableState]]","pending"),rt.set(this,"[[DisposeCapability]]",ov())},lv=function(){var t=this;return rt.assert(t,"[[AsyncDisposableState]]"),rt.get(t,"[[AsyncDisposableState]]")==="disposed"},Xo=hA(lv);av?aA(gt.prototype,"disposed",{"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Get]]":lv}):gt.prototype.disposed=!1;var cv=function(t){rt.set(t,"[[AsyncDisposableState]]","disposed"),av||(t.disposed=!0)};is(gt.prototype,"disposeAsync",function(){var t=this;return Xo(t)?Rf(Cf):(cv(t),pA(Rf(Cf,lA(rt.get(t,"[[DisposeCapability]]"),cA())),function(e){return e["?"]()}))});is(gt.prototype,"use",function(t){var e=this;if(Xo(e))throw new Bl("a disposed stack can not use anything new");return rd(rt.get(e,"[[DisposeCapability]]"),t,"ASYNC-DISPOSE"),t});is(gt.prototype,"adopt",function(t,e){var r=this;if(Xo(r))throw new Bl("a disposed stack can not use anything new");if(!sv(e))throw new nd("`onDisposeAsync` must be a function");var i=function(){return oA(e,void 0,[t])};return i.value=t,rd(rt.get(r,"[[DisposeCapability]]"),void 0,"ASYNC-DISPOSE",i),t});is(gt.prototype,"defer",function(t){var e=this;if(Xo(e))throw new Bl("a disposed stack can not defer anything new");if(!sv(t))throw new nd("`onDispose` must be a function");rd(rt.get(e,"[[DisposeCapability]]"),void 0,"ASYNC-DISPOSE",t)});is(gt.prototype,"move",function(){var t=this;if(Xo(t))throw new Bl("a disposed stack can not use anything new");var e=new gt;return rt.set(e,"[[DisposeCapability]]",rt.get(t,"[[DisposeCapability]]")),rt.set(t,"[[DisposeCapability]]",ov()),cv(t),e});Pf&&is(gt.prototype,Pf,gt.prototype.disposeAsync);uA(gt.prototype,"AsyncDisposableStack");var fA=gt,gA=fA,mA=function(){return typeof AsyncDisposableStack=="function"?AsyncDisposableStack:gA},vA=Wr,yA=Rh(),bA=mA,wA=function(){var t=bA();return vA(yA,{AsyncDisposableStack:t},{AsyncDisposableStack:!0}),t},SA=vk,_A=Ek,kA=iA,xA=wA,EA=function(){SA(),_A(),kA(),xA()};EA();const Df=new WeakMap;function AA(n){return(typeof n=="object"||typeof n=="function")&&n!==null&&"then"in n&&typeof n.then=="function"}function ti(n){return typeof n=="string"?n:typeof n=="symbol"?n.description??n.toString():n.name||"(anonymous class)"}function Lf(){return new Error("register(Key, factory) requires a factory function. Wrap existing instances as () => instance.")}function $A(){return new Error("register(Key, factory) does not accept async factories. Await setup before registering.")}class TA{constructor(){g(this,"entries",new Map);g(this,"constructionStack",[])}register(t,e){if(e===void 0){if(typeof t!="function")throw Lf();this.validateClassRegistration(t),this.storeFactory(t,()=>this.instantiateClass(t));return}if(typeof e!="function")throw Lf();if(e.constructor.name==="AsyncFunction")throw $A();this.storeFactory(t,e)}has(t){var e;return((e=this.entries.get(t))==null?void 0:e.factory)!==void 0}resolve(t){return this.resolveAny(t)}storeFactory(t,e){const r=this.getOrCreateEntry(t);r.factory=e,r.instance=void 0,r.error=void 0}validateClassRegistration(t){const e=Df.get(t);if(e){if(t.length!==e.length)throw new Error(`${ti(t)} cannot be registered with register(Class). @injectable(...) declared ${e.length} dependencies but constructor arity is ${t.length}. Use register(Key, () => value) instead.`);return}if(t.length!==0)throw new Error(`${ti(t)} cannot be registered with register(Class). Undecorated classes must have zero required constructor parameters. Use register(Key, () => value) instead.`)}instantiateClass(t){const e=Df.get(t);if(!e)return new t;const r=e.map(i=>this.resolveAny(i));return new t(...r)}resolveAny(t){return this.getOrCreateEntry(t).proxy}getOrCreateEntry(t){let e=this.entries.get(t);return e||(e={key:t},e.proxy=this.createProxy(e),this.entries.set(t,e),e)}createProxy(t){return new Proxy({},{get:(e,r)=>{if(r==="then")return;const i=this.getInstance(t),s=Reflect.get(i,r,i);return typeof s=="function"?s.bind(i):s},set:(e,r,i)=>{const s=this.getInstance(t);return Reflect.set(s,r,i,s)},has:(e,r)=>{const i=this.getInstance(t);return r in i}})}getInstance(t){if(t.instance)return t.instance;if(t.error)throw t.error;if(!t.factory)throw new Error(`${ti(t.key)} was resolved but never registered`);const e=this.constructionStack.indexOf(t.key);if(e!==-1){const r=[...this.constructionStack.slice(e),t.key].map(i=>ti(i)).join(" -> ");throw new Error(`Circular dependency detected: ${r}`)}this.constructionStack.push(t.key);try{const r=t.factory();if(AA(r))throw new Error(`Factory for ${ti(t.key)} returned a Promise. Await setup before registering.`);if(typeof r!="object"||r===null)throw new Error(`Factory for ${ti(t.key)} returned a non-object value. Wrap primitives in an object.`);return t.instance=r,r}catch(r){throw t.error=r,r}finally{this.constructionStack.pop()}}}const en=new TA,IA=.5,zf=.1,Of=8,CA=4,uv=3,hv=3,RA=4,pr=255,dv=.2126,pv=.7152,fv=.0722;async function gv(n){const t=PA(n);if(!t)return"light";try{return await zA(n,t)>=IA?"light":"dark"}catch{return"light"}}function PA(n){if(typeof document.elementsFromPoint!="function")return null;const t=n.getBoundingClientRect(),e=t.left+t.width/2,r=t.top+t.height/2,i=document.elementsFromPoint(e,r);for(const s of i){if(!(s instanceof HTMLElement)||s===n||n.contains(s))continue;const o=window.getComputedStyle(s);if(DA(o))return s}return null}function DA(n){return n.backgroundImage&&n.backgroundImage!=="none"?!0:LA(n.backgroundColor)>0}function LA(n){if(!n)return 0;const t=n.match(/rgba?\(([^)]+)\)/);if(!t)return 0;const e=t[1].split(/[\s,/]+/).filter(Boolean);return e.length===RA?parseFloat(e[uv]):e.length===hv?1:0}async function zA(n,t){const e=n.getBoundingClientRect(),r=t.getBoundingClientRect(),i={x:ma((e.left-r.left)/r.width),y:ma((e.top-r.top)/r.height),width:ma(e.width/r.width),height:ma(e.height/r.height)},s=window.getComputedStyle(t),o=OA(s.backgroundImage);return o?NA({url:o,surfaceWidth:r.width,surfaceHeight:r.height,region:i}):UA(s.backgroundColor)}function OA(n){const t=n.match(/url\(\s*["']?([^"')]+)["']?\s*\)/);return t?t[1]:null}const Mf=new Map;function MA(n){let t=Mf.get(n);return t||(t=new Promise((e,r)=>{const i=new Image;i.crossOrigin="anonymous",i.onload=()=>e(i),i.onerror=()=>r(new Error(`Failed to load ${n}`)),i.src=n}),Mf.set(n,t),t)}async function NA(n){const t=await MA(n.url),e=Math.max(Of,Math.ceil(n.surfaceWidth*zf)),r=Math.max(Of,Math.ceil(n.surfaceHeight*zf)),i=document.createElement("canvas");i.width=e,i.height=r;const s=i.getContext("2d",{willReadFrequently:!0});if(!s)return 1;const o=n.surfaceWidth/n.surfaceHeight,a=t.naturalWidth/t.naturalHeight;let c,u;a>o?(u=r,c=r*a):(c=e,u=e/a);const h=(e-c)/2,p=(r-u)/2;s.drawImage(t,h,p,c,u);const v=Math.max(0,Math.floor(n.region.x*e)),m=Math.max(0,Math.floor(n.region.y*r)),_=Math.max(1,Math.min(e-v,Math.floor(n.region.width*e))),k=Math.max(1,Math.min(r-m,Math.floor(n.region.height*r))),T=s.getImageData(v,m,_,k).data;let P=0,R=0;for(let W=0;W<T.length;W+=CA){const N=T[W]/pr,F=T[W+1]/pr,Y=T[W+2]/pr,j=T[W+uv]/pr;P+=j*(dv*N+pv*F+fv*Y),R+=1}return R>0?P/R:1}function UA(n){const t=n.match(/rgba?\(([^)]+)\)/);if(!t)return 1;const e=t[1].split(/[\s,/]+/).filter(Boolean).map(parseFloat);if(e.length<hv)return 1;const r=e[0]/pr,i=e[1]/pr,s=e[2]/pr;return dv*r+pv*i+fv*s}function ma(n){return n<0?0:n>1?1:n}const FA=["ghost","glass"],Fs=[...FA.flatMap(n=>[`button[variant="${n}"]`,`segmented-control[variant="${n}"]`]),'[material="glass"]'].join(", "),va=new WeakSet,Nf=new WeakSet;function mv(n){if(Nf.has(n))return;Nf.add(n);for(const e of n.querySelectorAll(Fs))Bc(e);if(typeof MutationObserver!="function")return;new MutationObserver(e=>{for(const r of e)if(r.type==="childList")for(const i of r.addedNodes)HA(i,Bc);else r.type==="attributes"&&r.target instanceof HTMLElement&&r.target.matches(Fs)&&Bc(r.target)}).observe(n,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["variant","material"]})}function HA(n,t){if(n instanceof Element){n instanceof HTMLElement&&n.matches(Fs)&&t(n);for(const e of n.querySelectorAll(Fs))t(e)}}async function Bc(n){if(va.has(n)||n.hasAttribute("tone"))return;va.add(n);const t=await gv(n);if(!n.matches(Fs)){va.delete(n);return}if(n.hasAttribute("tone")){va.delete(n);return}n.setAttribute("tone",t)}const WA="*,*:before,*:after{box-sizing:border-box}html,body{margin:0;padding:0;width:100%;height:100%}h1,h2,h3,h4,h5,h6,p,ul,ol,blockquote,pre,hr{margin:0}button,input,textarea,select{font:inherit;color:inherit}@font-face{font-family:Hind;src:url("+new URL("Hind-Variable-C47b_dt9.woff2",import.meta.url).href+') format("woff2-variations");font-weight:300 700;font-style:normal;font-display:swap}:root{--font-sans: "Hind", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;--font-brand: var(--font-sans);--font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, monospace;--font-weight-body: 500;--text-base: 13.5px;--text-scale: 1.125;--text-sm: round(calc(var(--text-base) / var(--text-scale)), 1px);--text-lg: round(calc(var(--text-base) * var(--text-scale)), 1px);--text-xl: round(calc(var(--text-lg) * var(--text-scale)), 1px);--leading-base: 1.5;--control-height-xs: 18px;--control-height-sm: 24px;--control-height-md: 28px;--control-height-lg: 32px;--space-2: 2px;--space-4: 4px;--space-6: 6px;--space-8: 8px;--space-12: 12px;--space-16: 16px;--space-20: 20px;--space-24: 24px;--space-32: 32px;--space-48: 48px;--space-64: 64px;--radius-4: 4px;--radius-8: 8px;--radius-12: 12px;--radius-16: 16px;--radius-24: 24px;--radius-full: 9999px;--layer-chrome: 100;--layer-panel: 500;--layer-overlay: 2000;--shadow-hairline: 0 0 0 .5px var(--color-border);--shadow-control: 0 1px 1px rgb(0 0 0 / .04), 0 2px 6px rgb(0 0 0 / .06);--alpha-50: 4%;--alpha-100: 8%;--alpha-150: 11%;--alpha-200: 15%;--alpha-300: 22%;--alpha-400: 30%;--alpha-500: 40%;--alpha-600: 50%;--alpha-700: 65%;--alpha-800: 80%;--alpha-900: 90%;--alpha-950: 95%;--tint-50: color-mix(in srgb, currentColor var(--alpha-50), transparent);--tint-100: color-mix(in srgb, currentColor var(--alpha-100), transparent);--tint-150: color-mix(in srgb, currentColor var(--alpha-150), transparent);--tint-200: color-mix(in srgb, currentColor var(--alpha-200), transparent);--tint-300: color-mix(in srgb, currentColor var(--alpha-300), transparent);--tint-400: color-mix(in srgb, currentColor var(--alpha-400), transparent);--tint-500: color-mix(in srgb, currentColor var(--alpha-500), transparent);--tint-600: color-mix(in srgb, currentColor var(--alpha-600), transparent);--tint-700: color-mix(in srgb, currentColor var(--alpha-700), transparent);--tint-800: color-mix(in srgb, currentColor var(--alpha-800), transparent);--tint-900: color-mix(in srgb, currentColor var(--alpha-900), transparent);--tint-950: color-mix(in srgb, currentColor var(--alpha-950), transparent);--color-overlay-hover: color-mix(in srgb, var(--black) var(--alpha-100), transparent);--color-overlay-active: color-mix(in srgb, var(--black) var(--alpha-300), transparent);--backdrop-blur-glass: blur(20px) saturate(1.4);--black: #000000;--white: #ffffff;--neutral-50: oklch(.985 0 0);--neutral-100: oklch(.97 0 0);--neutral-200: oklch(.923 0 0);--neutral-300: oklch(.869 0 0);--neutral-350: oklch(.79 0 0);--neutral-400: oklch(.709 0 0);--neutral-500: oklch(.553 0 0);--neutral-600: oklch(.444 0 0);--neutral-700: oklch(.374 0 0);--neutral-800: oklch(.268 0 0);--neutral-900: oklch(.216 0 0);--neutral-950: oklch(.147 0 0);--red-50: oklch(.969 .015 12.422);--red-100: oklch(.941 .03 12.58);--red-200: oklch(.892 .058 10.001);--red-300: oklch(.81 .117 11.638);--red-400: oklch(.712 .194 13.428);--red-500: oklch(.645 .246 16.439);--red-600: oklch(.586 .253 17.585);--red-700: oklch(.514 .222 16.935);--red-800: oklch(.455 .188 13.697);--red-900: oklch(.41 .159 10.272);--red-950: oklch(.271 .105 12.094);--orange-50: oklch(.98 .016 73.684);--orange-100: oklch(.954 .038 75.164);--orange-200: oklch(.901 .076 70.697);--orange-300: oklch(.837 .128 66.29);--orange-400: oklch(.75 .183 55.934);--orange-500: oklch(.705 .213 47.604);--orange-600: oklch(.646 .222 41.116);--orange-700: oklch(.553 .195 38.402);--orange-800: oklch(.47 .157 37.304);--orange-900: oklch(.408 .123 38.172);--orange-950: oklch(.266 .079 36.259);--yellow-50: oklch(.987 .026 102.212);--yellow-100: oklch(.973 .071 103.193);--yellow-200: oklch(.945 .129 101.54);--yellow-300: oklch(.905 .182 98.111);--yellow-400: oklch(.852 .199 91.936);--yellow-500: oklch(.795 .184 86.047);--yellow-600: oklch(.681 .162 75.834);--yellow-700: oklch(.554 .135 66.442);--yellow-800: oklch(.476 .114 61.907);--yellow-900: oklch(.421 .095 57.708);--yellow-950: oklch(.286 .066 53.813);--green-50: oklch(.979 .021 166.113);--green-100: oklch(.95 .052 163.051);--green-200: oklch(.905 .093 164.15);--green-300: oklch(.845 .143 164.978);--green-400: oklch(.765 .177 163.223);--green-500: oklch(.696 .17 162.48);--green-600: oklch(.596 .145 163.225);--green-700: oklch(.508 .118 165.612);--green-800: oklch(.432 .095 166.913);--green-900: oklch(.378 .077 168.94);--green-950: oklch(.262 .051 172.552);--blue-50: oklch(.97 .014 254.604);--blue-100: oklch(.932 .032 255.585);--blue-200: oklch(.882 .059 254.128);--blue-300: oklch(.809 .105 251.813);--blue-400: oklch(.707 .165 254.624);--blue-500: oklch(.623 .214 259.815);--blue-600: oklch(.546 .245 262.881);--blue-700: oklch(.488 .243 264.376);--blue-800: oklch(.424 .199 265.638);--blue-900: oklch(.379 .146 265.522);--blue-950: oklch(.282 .091 267.935);--purple-50: oklch(.969 .016 293.756);--purple-100: oklch(.943 .029 294.588);--purple-200: oklch(.894 .057 293.283);--purple-300: oklch(.811 .111 293.571);--purple-400: oklch(.702 .183 293.541);--purple-500: oklch(.606 .25 292.717);--purple-600: oklch(.541 .281 293.009);--purple-700: oklch(.491 .27 292.581);--purple-800: oklch(.432 .232 292.759);--purple-900: oklch(.38 .189 293.745);--purple-950: oklch(.283 .141 291.089)}@supports (corner-shape: squircle){:root{--radius-8: 10px;--radius-12: 15px;--radius-16: 20px;--radius-24: 30px}}:root[data-font=system]{--font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif}:root{--color-bg: var(--neutral-50);--color-bg-muted: var(--neutral-100);--color-surface: var(--white);--color-surface-muted: var(--neutral-100);--color-interactive: var(--neutral-200);--color-interactive-hover: var(--neutral-300);--color-border: rgba(0, 0, 0, .1);--color-border-muted: rgba(0, 0, 0, .06);--color-text: var(--neutral-900);--color-text-muted: var(--neutral-500);--color-link: inherit;--color-focus-ring: var(--neutral-500);--color-overlay-backdrop: rgb(0 0 0 / .5);--color-highlight: rgb(255 255 255 / .5);--color-primary: var(--blue-500);--color-danger: var(--red-600);color-scheme:light}body{font-family:var(--font-sans);font-size:var(--text-base);font-weight:var(--font-weight-body);line-height:var(--leading-base);letter-spacing:.015em;color:var(--color-text);background:var(--color-bg);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}a{color:var(--color-link);text-underline-offset:.15em;text-decoration-thickness:.08em}h1,h2,h3,h4,h5,h6{font-weight:600;color:inherit}code{font-family:var(--font-mono);font-size:.9em;background:var(--color-bg-muted);padding:var(--space-2) var(--space-4);border-radius:var(--radius-4)}pre{font-family:var(--font-mono);background:var(--color-bg-muted);padding:var(--space-12);border-radius:var(--radius-8);overflow-x:auto}pre code{background:none;padding:0}blockquote{padding-left:var(--space-16);border-left:3px solid var(--color-border);color:var(--color-text-muted)}hr{border:none;border-top:1px solid var(--color-border)}table{border-collapse:collapse}th,td{padding:var(--space-8) var(--space-12);border:1px solid var(--color-border);text-align:left}th{background:var(--color-bg-muted);font-weight:600}input,textarea{border:.5px solid var(--tint-300);border-radius:var(--radius-12);background:var(--tint-100);color:inherit;font:inherit;box-sizing:border-box;transition:background .12s ease,border-color .12s ease,box-shadow .12s ease}input{height:var(--control-height-lg);padding:0 12px}textarea{padding:6px 10px;resize:none}input::placeholder,textarea::placeholder{color:var(--tint-500)}input:focus,textarea:focus{background:color-mix(in srgb,var(--white) var(--alpha-300),transparent);border-color:var(--color-primary);outline:none;box-shadow:0 0 0 1.5px var(--color-primary)}label.field{display:grid;gap:4px;font-size:13px}label.field>span{font-size:11.5px;font-weight:450;color:var(--tint-800)}@supports (corner-shape: squircle){*{corner-shape:squircle}}button{display:inline-flex;align-items:center;justify-content:center;gap:var(--space-6);box-sizing:border-box;height:var(--control-height-md);padding:0 14px 2px;font:inherit;cursor:default}button,segmented-control{background:var(--color-surface);border:.5px solid var(--tint-200);border-radius:var(--radius-12);box-shadow:var(--shadow-control);color:inherit}button:not([material]):hover:not(:disabled){background:color-mix(in srgb,var(--color-surface) 96%,black)}button:not([material]):active:not(:disabled){background:color-mix(in srgb,var(--color-surface) 88%,black);box-shadow:inset 0 1px 2px #00000014}button:focus-visible{outline:2px solid var(--color-focus-ring);outline-offset:2px}button[variant=primary]{background:var(--color-primary);border-color:#0000002e;color:var(--white)}button[variant=primary]:hover:not(:disabled){background:color-mix(in srgb,var(--color-primary) 92%,black)}button[variant=primary]:active:not(:disabled){background:color-mix(in srgb,var(--color-primary) 82%,black);box-shadow:inset 0 1px 2px #0000002e}button[variant=danger]{background:var(--color-danger);border-color:#0000002e;color:var(--white)}button[variant=danger]:hover:not(:disabled){background:color-mix(in srgb,var(--color-danger) 92%,black)}button[variant=danger]:active:not(:disabled){background:color-mix(in srgb,var(--color-danger) 82%,black);box-shadow:inset 0 1px 2px #0000002e}button[variant=ghost]{background:transparent;border-color:transparent;color:inherit;box-shadow:none}button[variant=ghost]:hover:not(:disabled){background:var(--tint-150);backdrop-filter:saturate(1.2);-webkit-backdrop-filter:saturate(1.2)}button[variant=ghost]:active:not(:disabled){background:var(--tint-300);backdrop-filter:saturate(1.4);-webkit-backdrop-filter:saturate(1.4);box-shadow:none}button[variant=ghost][data-active]:not(:disabled),button[variant=ghost][data-active]:hover:not(:disabled),button[variant=ghost][aria-pressed=true]:not(:disabled),button[variant=ghost][aria-pressed=true]:hover:not(:disabled),button[variant=ghost][aria-expanded=true]:not(:disabled),button[variant=ghost][aria-expanded=true]:hover:not(:disabled){background:var(--color-overlay-active);backdrop-filter:saturate(1.3);-webkit-backdrop-filter:saturate(1.3);box-shadow:none}button[variant=glass],segmented-control[variant=glass]{background:transparent;border:.5px solid color-mix(in srgb,var(--black) var(--alpha-100),transparent);box-shadow:none}button[variant=glass]{backdrop-filter:blur(20px) brightness(.95) saturate(1.5);-webkit-backdrop-filter:blur(20px) brightness(.95) saturate(1.5)}button[variant=glass]:hover:not(:disabled){background:linear-gradient(var(--color-overlay-hover),var(--color-overlay-hover));backdrop-filter:blur(20px) brightness(.95) saturate(1.8);-webkit-backdrop-filter:blur(20px) brightness(.95) saturate(1.8)}button[variant=glass]:active:not(:disabled){background:linear-gradient(var(--color-overlay-active),var(--color-overlay-active));backdrop-filter:blur(20px) brightness(.95) saturate(2.2);-webkit-backdrop-filter:blur(20px) brightness(.95) saturate(2.2)}button[variant=glass][aria-pressed=true]:not(:disabled),button[variant=glass][aria-pressed=true]:hover:not(:disabled),button[variant=glass][aria-expanded=true]:not(:disabled),button[variant=glass][aria-expanded=true]:hover:not(:disabled){background:linear-gradient(var(--color-overlay-active),var(--color-overlay-active));backdrop-filter:blur(20px) brightness(.95) saturate(2);-webkit-backdrop-filter:blur(20px) brightness(.95) saturate(2)}[tone=dark] button[variant=glass],[tone=dark] segmented-control[variant=glass]{border-color:var(--tint-400)}button[material],segmented-control[material]{color:inherit;box-shadow:none}button[material]:hover:not(:disabled){background-image:linear-gradient(var(--color-overlay-hover),var(--color-overlay-hover))}button[material]:active:not(:disabled){background-image:linear-gradient(var(--color-overlay-active),var(--color-overlay-active))}[tone=dark] button[material],[tone=dark] segmented-control[material]{border-color:var(--tint-400)}button:disabled{background:var(--tint-300);border-color:transparent;color:var(--tint-700);box-shadow:none}button[variant=ghost]:disabled{background:transparent}:where([tone=dark]) button:not([variant]):not([material]):not(:disabled),:where([tone=dark]) button[variant=default]:not([material]):not(:disabled),:where([tone=dark]) segmented-control:not([variant]):not([material]),:where([tone=dark]) segmented-control[variant=default]:not([material]){background:var(--tint-200);border-color:var(--tint-300);box-shadow:inset 0 .5px 0 var(--tint-300)}:where([tone=dark]) button:not([variant]):hover:not(:disabled),:where([tone=dark]) button[variant=default]:hover:not(:disabled){background:var(--tint-300)}:where([tone=dark]) button:not([variant]):active:not(:disabled),:where([tone=dark]) button[variant=default]:active:not(:disabled){background:var(--tint-400);box-shadow:inset 0 1px 2px #0003}:where([tone=light]) button:not([variant]):not([material]):not(:disabled),:where([tone=light]) button[variant=default]:not([material]):not(:disabled),:where([tone=light]) segmented-control:not([variant]):not([material]),:where([tone=light]) segmented-control[variant=default]:not([material]){background:var(--color-surface);border-color:var(--tint-200);box-shadow:var(--shadow-control)}:where([tone=light]) button:not([variant]):hover:not(:disabled){background:color-mix(in srgb,var(--color-surface) 96%,black)}:where([tone=light]) button:not([variant]):active:not(:disabled){background:color-mix(in srgb,var(--color-surface) 88%,black);box-shadow:inset 0 1px 2px #00000014}button[size=sm],segmented-control[size=sm]{height:var(--control-height-sm)}button[size=sm][icon-only]{width:var(--control-height-sm)}button[size=xs]{height:var(--control-height-xs);padding:0 var(--space-6) 1px;border-radius:var(--radius-8)}button[size=xs][icon-only]{width:var(--control-height-xs);padding:0}button[icon-only]{width:var(--control-height-md);padding:0}[data-ui-icon]{display:inline-block;vertical-align:middle}[selectable],[selectable] *{user-select:text;-webkit-user-select:text}[unselectable],[unselectable] *{user-select:none;-webkit-user-select:none}.prose{line-height:var(--leading-base)}.prose h1{font-size:var(--text-xl);margin-bottom:var(--space-8)}.prose h2{font-size:var(--text-lg);margin-top:var(--space-24);margin-bottom:var(--space-8)}.prose h3,.prose h4,.prose h5,.prose h6{font-size:var(--text-base);margin-top:var(--space-24);margin-bottom:var(--space-8)}.prose p{margin:var(--space-12) 0}.prose ul,.prose ol{padding-left:var(--space-24);margin:var(--space-12) 0}.prose blockquote,.prose pre{margin:var(--space-12) 0}.prose hr{margin:var(--space-24) 0}.prose table{width:100%;margin:var(--space-12) 0}.prose img{max-width:100%;height:auto}.prose>:first-child{margin-top:0}.prose>:last-child{margin-bottom:0}[material=paper]{background:var(--white);border:.5px solid color-mix(in srgb,var(--black) var(--alpha-100),transparent);color:var(--color-text)}[material=glass]{background:transparent;border:.5px solid color-mix(in srgb,var(--black) var(--alpha-100),transparent);backdrop-filter:blur(20px) brightness(.95) saturate(1.5);-webkit-backdrop-filter:blur(20px) brightness(.95) saturate(1.5)}[material=glass-frosted]{background:color-mix(in srgb,var(--white) var(--alpha-800),transparent);border:.5px solid color-mix(in srgb,var(--black) var(--alpha-100),transparent);color:var(--color-text);backdrop-filter:var(--backdrop-blur-glass);-webkit-backdrop-filter:var(--backdrop-blur-glass)}[tone=dark]{color:color-mix(in srgb,var(--white) var(--alpha-950),transparent);border-color:color-mix(in srgb,var(--white) var(--alpha-200),transparent);--color-overlay-hover: color-mix(in srgb, var(--white) var(--alpha-100), transparent);--color-overlay-active: color-mix(in srgb, var(--white) var(--alpha-200), transparent)}[tone=dark][material=paper]{background:#000}[tone=dark][material=glass-frosted]{background:color-mix(in srgb,var(--black) 70%,transparent)}[tone=light]{color:var(--color-text);border-color:color-mix(in srgb,var(--black) var(--alpha-100),transparent);--color-overlay-hover: color-mix(in srgb, var(--black) var(--alpha-50), transparent);--color-overlay-active: color-mix(in srgb, var(--black) var(--alpha-100), transparent)}[level="1"]{box-shadow:0 12px 32px #00000024}[level="2"]{box-shadow:0 4px 6px -2px #0000001f,0 40px 60px -16px #00000038}dropdown-menu{position:relative;display:inline-block;color:inherit}dropdown-group{display:grid;gap:var(--space-4)}dropdown-label{display:block;padding:var(--space-4) var(--space-8);color:var(--color-text-muted);font:inherit;font-size:var(--text-sm);font-weight:600;letter-spacing:.04em;text-transform:uppercase}dropdown-divider{display:block;height:1px;margin:2px 0;background:var(--color-border)}[data-dropdown-trigger][aria-expanded=true],[data-dropdown-trigger][aria-expanded=true]:hover,dropdown-menu[open]::part(trigger),dropdown-menu[open]::part(trigger):hover{background:color-mix(in srgb,var(--color-surface) 88%,black);box-shadow:inset 0 1px 2px #00000014}[data-dropdown-trigger-label],dropdown-menu::part(trigger-label){min-width:0}[data-dropdown-trigger-icon],dropdown-menu::part(trigger-icon){display:inline-flex;align-items:center;justify-content:center;flex:none;color:var(--color-text-muted);transform:translateY(1px)}dropdown-item:focus-visible{outline:2px solid var(--color-focus-ring);outline-offset:2px}ui-popover.dropdown-popover::part(panel){min-width:192px;padding:var(--space-4)}.dropdown-list{display:flex;flex-direction:column;gap:2px}dropdown-item{display:flex;align-items:center;gap:var(--space-8);margin:0;padding:6px 12px;border-radius:var(--radius-8);font:inherit;line-height:1.2;color:inherit;font-weight:var(--font-weight-body);-webkit-user-select:none;user-select:none}dropdown-item>[data-ui-icon]{flex:none}dropdown-item[selected]{background:var(--color-overlay-active)}dropdown-item:hover,dropdown-item[action]:hover{background:var(--color-primary);color:var(--white)}dropdown-item[action]{color:inherit}dropdown-item[danger]{color:var(--color-danger)}dropdown-item[danger]:hover{background:var(--color-danger);color:var(--white)}editable-text{display:inline-block;max-width:100%;vertical-align:top}editable-text>.editable-text-span{display:inline-block;max-width:100%;outline:none;overflow:hidden;white-space:nowrap;cursor:inherit;vertical-align:top}editable-text:not([data-editing])>.editable-text-span{text-overflow:ellipsis}editable-text[data-editing]>.editable-text-span{cursor:text}modal-overlay{color:inherit}modal-overlay::part(backdrop){position:fixed;top:0;right:0;bottom:0;left:0;z-index:var(--layer-overlay);display:flex;align-items:center;justify-content:center;padding:var(--space-16);background:linear-gradient(to bottom,color-mix(in srgb,var(--black) var(--alpha-50),transparent),color-mix(in srgb,var(--black) var(--alpha-400),transparent));backdrop-filter:blur(1px);-webkit-backdrop-filter:blur(1px)}panel-view{display:block}panel-view::part(panel){display:flex;flex-direction:column;gap:var(--space-16);color:var(--color-text)}panel-view::part(header){display:flex;align-items:center;justify-content:space-between;gap:var(--space-12)}panel-view::part(title){margin:0;font:inherit;font-size:var(--text-lg);font-weight:600;color:var(--color-text)}panel-view::part(button){display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;margin:0;border:1px solid var(--color-border);border-radius:var(--radius-4);background:var(--color-surface);color:var(--color-text);box-shadow:none}panel-view::part(button):hover{background:var(--color-interactive-hover)}panel-view::part(button):focus-visible{outline:2px solid var(--color-focus-ring);outline-offset:2px}panel-view::part(icon){display:inline-flex;align-items:center;justify-content:center;flex:none}ui-popover{display:contents}ui-popover::part(panel){position:fixed;inset:0 auto auto 0;margin:0;min-width:192px;max-width:384px;padding:var(--space-16) var(--space-20);border-radius:var(--radius-12);outline:none;z-index:2000}segmented-control{display:inline-flex;align-items:stretch;box-sizing:border-box;height:var(--control-height-md)}segmented-control>button{height:auto}segmented-control[variant=ghost]{background:transparent;box-shadow:none}[tone=dark] segmented-control[variant=ghost]{border-color:var(--tint-400)}segmented-control>button{position:relative}segmented-control>button[icon-only]{width:auto;height:auto;padding:0 var(--space-6)}segmented-control>button:not([variant]):not(:disabled),[tone] segmented-control>button:not([variant]):not(:disabled){background:transparent;border:0;box-shadow:none}segmented-control>button:first-child{border-top-right-radius:0;border-bottom-right-radius:0}segmented-control>button:last-child{border-top-left-radius:0;border-bottom-left-radius:0}segmented-control>button:not(:first-child):not(:last-child){border-radius:0}segmented-control>button:not([variant]):hover:not(:disabled),[tone] segmented-control>button:not([variant]):hover:not(:disabled){background:var(--color-overlay-hover)}segmented-control>button:not([variant]):active:not(:disabled),[tone] segmented-control>button:not([variant]):active:not(:disabled){background:var(--color-overlay-active);box-shadow:none}segmented-control>button:not([variant])[aria-pressed=true]:not(:disabled),segmented-control>button:not([variant])[aria-current]:not([aria-current=false]):not(:disabled),segmented-control>button:not([variant])[aria-expanded=true]:not(:disabled),[tone] segmented-control>button:not([variant])[aria-pressed=true]:not(:disabled),[tone] segmented-control>button:not([variant])[aria-current]:not([aria-current=false]):not(:disabled),[tone] segmented-control>button:not([variant])[aria-expanded=true]:not(:disabled){background:linear-gradient(var(--color-overlay-active),var(--color-overlay-active))}segmented-control>button:not(:last-child):after{content:"";position:absolute;top:0;bottom:0;right:0;width:.5px;background:var(--tint-200);pointer-events:none}[tone=dark] segmented-control>button:not(:last-child):after{background:var(--tint-400)}segmented-control>dropdown-menu{display:inline-flex;align-items:stretch;height:auto}segmented-control>dropdown-menu>[slot=trigger]{height:auto;position:relative}segmented-control>dropdown-menu>[slot=trigger]:not([variant]):not(:disabled),[tone] segmented-control>dropdown-menu>[slot=trigger]:not([variant]):not(:disabled){background:transparent;border:0;box-shadow:none}segmented-control>dropdown-menu:first-child>[slot=trigger]{border-top-right-radius:0;border-bottom-right-radius:0}segmented-control>dropdown-menu:last-child>[slot=trigger]{border-top-left-radius:0;border-bottom-left-radius:0}segmented-control>dropdown-menu:not(:first-child):not(:last-child)>[slot=trigger]{border-radius:0}segmented-control>dropdown-menu>[slot=trigger]:not([variant]):hover:not(:disabled),[tone] segmented-control>dropdown-menu>[slot=trigger]:not([variant]):hover:not(:disabled){background:var(--color-overlay-hover)}segmented-control>dropdown-menu>[slot=trigger]:not([variant]):active:not(:disabled),[tone] segmented-control>dropdown-menu>[slot=trigger]:not([variant]):active:not(:disabled){background:var(--color-overlay-active);box-shadow:none}segmented-control>dropdown-menu>[slot=trigger]:not([variant])[aria-pressed=true]:not(:disabled),segmented-control>dropdown-menu>[slot=trigger]:not([variant])[aria-current]:not([aria-current=false]):not(:disabled),segmented-control>dropdown-menu>[slot=trigger]:not([variant])[aria-expanded=true]:not(:disabled),[tone] segmented-control>dropdown-menu>[slot=trigger]:not([variant])[aria-pressed=true]:not(:disabled),[tone] segmented-control>dropdown-menu>[slot=trigger]:not([variant])[aria-current]:not([aria-current=false]):not(:disabled),[tone] segmented-control>dropdown-menu>[slot=trigger]:not([variant])[aria-expanded=true]:not(:disabled){background:linear-gradient(var(--color-overlay-active),var(--color-overlay-active))}segmented-control[variant=glass]>button,segmented-control[variant=glass]>dropdown-menu{backdrop-filter:blur(20px) brightness(.95) saturate(1.5);-webkit-backdrop-filter:blur(20px) brightness(.95) saturate(1.5)}segmented-control[variant=glass]>button:not(:disabled):hover,segmented-control[variant=glass]>dropdown-menu:has(>[slot=trigger]:not(:disabled):hover){backdrop-filter:blur(20px) brightness(.95) saturate(1.8);-webkit-backdrop-filter:blur(20px) brightness(.95) saturate(1.8)}segmented-control[variant=glass]>button:not(:disabled):active,segmented-control[variant=glass]>dropdown-menu:has(>[slot=trigger]:not(:disabled):active){backdrop-filter:blur(20px) brightness(.95) saturate(2.2);-webkit-backdrop-filter:blur(20px) brightness(.95) saturate(2.2)}segmented-control[variant=glass]>button:not(:disabled)[aria-pressed=true],segmented-control[variant=glass]>button:not(:disabled)[aria-current]:not([aria-current=false]),segmented-control[variant=glass]>dropdown-menu:has(>[slot=trigger]:not(:disabled)[aria-pressed=true]),segmented-control[variant=glass]>dropdown-menu:has(>[slot=trigger]:not(:disabled)[aria-current]:not([aria-current=false])){backdrop-filter:blur(20px) brightness(.95) saturate(1.8);-webkit-backdrop-filter:blur(20px) brightness(.95) saturate(1.8)}segmented-control[variant=glass]>button:not(:disabled)[aria-expanded=true],segmented-control[variant=glass]>dropdown-menu:has(>[slot=trigger]:not(:disabled)[aria-expanded=true]){backdrop-filter:blur(20px) brightness(.95) saturate(2);-webkit-backdrop-filter:blur(20px) brightness(.95) saturate(2)}segmented-control>dropdown-menu:not(:last-child):after{content:"";position:absolute;top:0;bottom:0;right:0;width:.5px;background:var(--tint-200);pointer-events:none}[tone=dark] segmented-control>dropdown-menu:not(:last-child):after{background:var(--tint-400)}ui-spinner{display:inline-flex;align-items:center;justify-content:center;line-height:0;color:inherit}ui-spinner .spin,.spin{display:inline-flex;animation:ui-spinner-spin 1s steps(8,end) infinite}@keyframes ui-spinner-spin{to{transform:rotate(360deg)}}@media (prefers-reduced-motion: reduce){.spin{animation:none}}system-modal{display:flex;flex-direction:column;width:min(400px,100%);box-sizing:border-box;padding:var(--space-32) var(--space-24);border-radius:var(--radius-12)}system-modal header{display:flex;flex-direction:column;align-items:center;gap:var(--space-16);text-align:center}system-modal header>hgroup{display:flex;flex-direction:column;align-items:center;gap:var(--space-4);max-width:100%}system-modal header h2{margin:0;font-size:var(--text-lg);font-weight:600;letter-spacing:.01em;max-width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}system-modal header p{margin:0;font-size:var(--text-base);opacity:.7;max-width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}ui-pill{display:inline-block;vertical-align:baseline;margin:2px 0;padding:0 var(--space-8);font-size:var(--text-sm);font-weight:500;line-height:1.7;border-radius:var(--radius-full);border:1px solid var(--neutral-300);background:var(--neutral-200);color:var(--neutral-900);white-space:nowrap}ui-pill[color=gray]{border-color:var(--neutral-300);background:var(--neutral-200);color:var(--neutral-900)}ui-pill[color=red]{border-color:var(--red-200);background:var(--red-100);color:var(--red-950)}ui-pill[color=orange]{border-color:var(--orange-200);background:var(--orange-100);color:var(--orange-950)}ui-pill[color=yellow]{border-color:var(--yellow-200);background:var(--yellow-100);color:var(--yellow-950)}ui-pill[color=green]{border-color:var(--green-200);background:var(--green-100);color:var(--green-950)}ui-pill[color=blue]{border-color:var(--blue-200);background:var(--blue-100);color:var(--blue-950)}ui-pill[color=purple]{border-color:var(--purple-200);background:var(--purple-100);color:var(--purple-950)}',id=new CSSStyleSheet;id.replaceSync(WA);const sd=new CSSStyleSheet;try{document.adoptedStyleSheets=[...document.adoptedStyleSheets,id,sd]}catch{}mv(document);function vv(n){sd.replaceSync(n)}function al(){vv("")}function od(n){try{n.adoptedStyleSheets=[...n.adoptedStyleSheets,id,sd]}catch{}mv(n)}const ZA=new Set(["target","currentTarget","eventPhase","defaultPrevented","isTrusted","timeStamp","srcElement","returnValue","cancelBubble","NONE","CAPTURING_PHASE","AT_TARGET","BUBBLING_PHASE","composedPath","stopPropagation","stopImmediatePropagation","preventDefault","initEvent"]);function VA(n){for(const t of Object.keys(n))if(ZA.has(t))throw new Error(`Event payload key "${t}" is reserved; choose a different property name`)}function BA(n,t){VA(t);for(const e of Object.keys(t))Object.defineProperty(n,e,{value:t[e],writable:!0,enumerable:!0,configurable:!0})}function He(){class n extends Event{constructor(e,r){const{type:i,bubbles:s,cancelable:o,composed:a,...c}=r??{};if(i!==void 0)throw new Error('Do not pass "type" in init; use the constructor argument instead');super(e,{bubbles:s,cancelable:o,composed:a}),BA(this,c)}}return n}class tn extends globalThis.EventTarget{}function jA(n,t,e){const r=n.dispose.bind(n);n.dispose=()=>{if(!t())return e(),r()}}function Ko(n){var e;class t extends n{constructor(...s){super(...s);w(this,e,!1);jA(this,()=>l(this,e),()=>{S(this,e,!0)})}[Symbol.dispose](){this.dispose()}get disposed(){return l(this,e)}}return e=new WeakMap,t}const GA=He(),qA=He(),YA=He(),za=He(),XA=He(),jc=He(),yv="0123456789ABCDEFGHJKMNPQRSTVWXYZ",ll=32,KA=16,bv=10,Uf=0xffffffffffff;var fr;(function(n){n.Base32IncorrectEncoding="B32_ENC_INVALID",n.DecodeTimeInvalidCharacter="DEC_TIME_CHAR",n.DecodeTimeValueMalformed="DEC_TIME_MALFORMED",n.EncodeTimeNegative="ENC_TIME_NEG",n.EncodeTimeSizeExceeded="ENC_TIME_SIZE_EXCEED",n.EncodeTimeValueMalformed="ENC_TIME_MALFORMED",n.PRNGDetectFailure="PRNG_DETECT",n.ULIDInvalid="ULID_INVALID",n.Unexpected="UNEXPECTED",n.UUIDInvalid="UUID_INVALID"})(fr||(fr={}));class xs extends Error{constructor(t,e){super(`${e} (${t})`),this.name="ULIDError",this.code=t}}function JA(n){const t=Math.floor(n()*ll)%ll;return yv.charAt(t)}function QA(n){const t=e1(),e=t&&(t.crypto||t.msCrypto)||null;if(typeof(e==null?void 0:e.getRandomValues)=="function")return()=>{const r=new Uint8Array(1);return e.getRandomValues(r),r[0]/256};if(typeof(e==null?void 0:e.randomBytes)=="function")return()=>e.randomBytes(1).readUInt8()/256;throw new xs(fr.PRNGDetectFailure,"Failed to find a reliable PRNG")}function e1(){return r1()?self:typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:null}function t1(n,t){let e="";for(;n>0;n--)e=JA(t)+e;return e}function n1(n,t=bv){if(isNaN(n))throw new xs(fr.EncodeTimeValueMalformed,`Time must be a number: ${n}`);if(n>Uf)throw new xs(fr.EncodeTimeSizeExceeded,`Cannot encode a time larger than ${Uf}: ${n}`);if(n<0)throw new xs(fr.EncodeTimeNegative,`Time must be positive: ${n}`);if(Number.isInteger(n)===!1)throw new xs(fr.EncodeTimeValueMalformed,`Time must be an integer: ${n}`);let e,r="";for(let i=t;i>0;i--)e=n%ll,r=yv.charAt(e)+r,n=(n-e)/ll;return r}function r1(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}function jl(n,t){const e=QA(),r=Date.now();return n1(r,bv)+t1(KA,e)}const Fe=4,ct=6,Hs=2,Au=2,ad=8,i1=ct,ld="auto",Bn="auto",In=120,Ff=50,le=16,zr=In*Fe+le*(Fe-1),cl=In*ct+le*(ct-1),s1=zr+le*2,o1=200,a1=4,ya=150,l1=10,Hf=2,Wf=8,c1=300,u1=4;function wv(n){return kv(n)}function Sv(n,t){return kv(n.flatMap(e=>Ev(e,t)))}function _v(n){const t=[],e=new Set;for(const r of n){if(r.type==="row"){t.push(`Top-level rows are invalid: ${r.id}`);continue}Av(r,"strip",t,e)}return{valid:t.length===0,errors:t}}function gr(n){const t=wv(n),e=_v(t);if(!e.valid)throw new Error(`Invalid layout: ${e.errors.join("; ")}`);return{totalNodes:t.length,nodes:t.filter(r=>r.type!=="row").map(f1)}}function kv(n){const t=[];for(const e of n){const r=xv(e);for(const i of r){if(i.type==="row"){t.push(...i.children.map(wn));continue}t.push(i)}}return t}function xv(n){switch(n.type){case"card":return[wn(n)];case"row":{const t=n.children.map(wn);return t.length===0?[]:t.length===1?[t[0]]:[{...n,children:t}]}case"stack":{const t=[];for(const e of n.children){const r=xv(e);for(const i of r){if(i.type==="stack"){t.push(...i.children.map($u));continue}if(i.type==="row"){t.push({...i,children:i.children.map(wn)});continue}t.push(wn(i))}}return t.length===0?[]:t.length===1?[$u(t[0])]:[{...n,children:t}]}}}function Ev(n,t){switch(n.type){case"card":return n.artifactID===t?[]:[wn(n)];case"row":{const e=n.children.filter(r=>r.artifactID!==t).map(wn);return e.length===0?[]:e.length===1?[e[0]]:[{...n,children:e}]}case"stack":{const e=n.children.flatMap(r=>Ev(r,t).filter(s=>s.type!=="stack"));return e.length===0?[]:e.length===1?[$u(e[0])]:[{...n,children:e}]}}}function Av(n,t,e,r){switch(n.type){case"card":$v(n,t,e,r);return;case"row":h1(n,t,e,r);return;case"stack":d1(n,t,e,r);return}}function $v(n,t,e,r){cd(n.id,e),typeof n.artifactID!="string"||n.artifactID.length===0?e.push(`Card ${n.id} is missing artifactID`):r.has(n.artifactID)?e.push(`Duplicate artifactID in layout: ${n.artifactID}`):r.add(n.artifactID),p1(n.width)||e.push(`Card ${n.id} width must be an integer in the range ${Hs}-${ad}`),Tv(n.height)||e.push(`Card ${n.id} height must be an integer in the range 2-6 or "auto"`);const i=gi(n.width);t==="stack"&&i!==Fe&&e.push(`Stack child ${n.id} width must be ${Fe}`),t==="row"&&i<Hs&&e.push(`Row child ${n.id} must be at least 2 columns wide`)}function h1(n,t,e,r){if(cd(n.id,e),t!=="stack"&&e.push(`Row ${n.id} may only appear inside a stack`),Tv(n.height,u1)||e.push(`Row ${n.id} height must be an integer in the range 2-4 or "auto"`),!Array.isArray(n.children)||n.children.length===0){e.push(`Row ${n.id} must contain card nodes`);return}let i=0;for(const s of n.children){if(s.type!=="card"){e.push(`Row ${n.id} must contain only card nodes`);continue}$v(s,"row",e,r),i+=gi(s.width)}i!==Fe&&e.push(`Row ${n.id} children must sum to 4 columns`)}function d1(n,t,e,r){if(cd(n.id,e),t!=="strip"&&e.push(`Invalid nested stack at ${n.id}; stack children cannot contain another nested stack`),!Array.isArray(n.children)||n.children.length===0){e.push(`Stack ${n.id} must contain at least one child`);return}let i=0,s=0;for(const a of n.children){if(a.type==="stack"){e.push(`Stack ${n.id} cannot contain another nested stack`);continue}if(Av(a,"stack",e,r),a.height===Bn){s+=1;continue}i+=a.height}if(i>ct&&e.push(`Stack ${n.id} exceeds the 6-row budget`),s===0)return;const o=ct-i;if(o<s*Au||o%s!==0){e.push(`Stack ${n.id} has auto-height children that cannot resolve to whole height >= 2`);return}o/s<Au&&e.push(`Stack ${n.id} has auto-height children below the minimum row size`)}function cd(n,t){(typeof n!="string"||n.length===0)&&t.push(`Node id must be a non-empty string: ${String(n)}`)}function p1(n){return n===ld||Number.isInteger(n)&&n>=Hs&&n<=ad}function Tv(n,t=i1){return n===Bn||Number.isInteger(n)&&n>=Au&&n<=t}function gi(n){return n===ld?Fe:n}function f1(n){if(n.type==="card")return{id:n.id,type:"card",width:gi(n.width),cards:[{id:n.id,artifactID:n.artifactID,col:1,row:1,width:gi(n.width),height:Iv(n.height,ct)}]};const t=g1(n.children),e=[];let r=1;for(let i=0;i<n.children.length;i+=1){const s=n.children[i],o=t[i];if(s.type==="card")e.push({id:s.id,artifactID:s.artifactID,col:1,row:r,width:Fe,height:o});else{let a=1;for(const c of s.children)e.push({id:c.id,artifactID:c.artifactID,col:a,row:r,width:gi(c.width),height:o}),a+=gi(c.width)}r+=o}return{id:n.id,type:"stack",width:e.reduce((i,s)=>Math.max(i,s.col+s.width-1),1),cards:e}}function g1(n){let t=0,e=0;for(const i of n)i.height===Bn?e+=1:t+=i.height;const r=e>0?(ct-t)/e:0;return n.map(i=>Iv(i.height,r))}function Iv(n,t){return n===Bn?t:n}function wn(n){return{...n}}function $u(n){return n.type==="card"?wn(n):{...n,children:n.children.map(wn)}}function Cv(n,t={}){return{id:t.id??jl(),type:"card",artifactID:n,width:t.width??ld,height:t.height??Bn}}function Rv(n,t){return n.some(e=>Pv(e,t))}function Pv(n,t){switch(n.type){case"card":return n.artifactID===t;case"row":return n.children.some(e=>e.artifactID===t);case"stack":return n.children.some(e=>Pv(e,t))}}function Zf(n){return n.layout.flatMap(Dv)}function Dv(n){switch(n.type){case"card":return[n.artifactID];case"row":return n.children.map(t=>t.artifactID);case"stack":return n.children.flatMap(Dv)}}const ae=He(),Tu=He(),ni=He(),m1=He();function v1(n){class t extends Error{constructor(r,i){super(r),this.name=n,i&&Object.assign(this,i)}}return t}const Lv=v1("RequestError"),y1=200,b1=300;class w1{constructor(t,e){g(this,"serverURL");g(this,"token");this.serverURL=t.replace(/\/$/,""),this.token=e.token}async requestJSON(t,e,r){const i=await this.request(t,e,r!==void 0?JSON.stringify(r):void 0,r!==void 0?{"content-type":"application/json"}:void 0),s=await S1(i);if(!i.ok||i.status<y1||i.status>=b1)throw this.createError(typeof s.error=="string"?s.error:i.statusText,i.status);return s}async requestVoid(t,e,r){const i=await this.request(t,e,r!==void 0?JSON.stringify(r):void 0,r!==void 0?{"content-type":"application/json"}:void 0);if(!i.ok)throw this.createError(await Gc(i,i.statusText),i.status)}async requestText(t,e){const r=await this.request(t,e);if(!r.ok)throw this.createError(await Gc(r,r.statusText),r.status);return r.text()}async requestRawVoid(t,e,r){const i=await this.request(t,e,r,{"content-type":"text/plain"});if(!i.ok)throw this.createError(await Gc(i,i.statusText),i.status)}createError(t,e){const r={serverURL:this.serverURL};return e!==void 0&&(r.status=e),new Lv(t,r)}async request(t,e,r,i){const s=`${this.serverURL}${e}`;try{return await fetch(s,{method:t,headers:this.buildHeaders(i),body:r})}catch(o){throw this.createError(o instanceof Error?o.message:"Failed to reach server")}}buildHeaders(t){const e={...t??{}};return this.token&&(e.Authorization=`Bearer ${this.token}`),Object.keys(e).length>0?e:void 0}}async function S1(n){try{return await n.json()}catch{const t=await n.text().catch(()=>"");return t?{message:t}:{}}}async function Gc(n,t){try{const e=await n.json();if(typeof e.error=="string")return e.error;if(typeof e.message=="string")return e.message}catch{}return t}function _1(n){return n.map(t=>`${t.name} (${t.id})`).join(", ")}var Mt,_l,zv;class k1{constructor(t){w(this,_l);w(this,Mt);S(this,Mt,t)}list(){return l(this,Mt).requestJSON("GET","/screens")}async get(t={}){const e=await f(this,_l,zv).call(this,t.screenID);return l(this,Mt).requestJSON("GET",`/screens/${encodeURIComponent(e)}`)}create(t){const e={name:t.name};return t.id!==void 0&&(e.id=t.id),l(this,Mt).requestJSON("POST","/screens",e)}update(t){const{screenID:e,...r}=t;return l(this,Mt).requestJSON("PATCH",`/screens/${encodeURIComponent(e)}`,r)}remove(t){return l(this,Mt).requestJSON("DELETE",`/screens/${encodeURIComponent(t.screenID)}`)}}Mt=new WeakMap,_l=new WeakSet,zv=async function(t){if(t!==void 0)return t;const{screens:e}=await this.list();if(e.length===1)return e[0].id;throw l(this,Mt).createError(`screenID is required when multiple screens exist. Available screens: ${_1(e)}`)};var Ue;class x1{constructor(t){w(this,Ue);S(this,Ue,t)}create(t){const e={kind:t.kind,title:t.title};switch(t.kind){case"markdown":e.externalFilePath=t.externalFilePath;break;case"url":e.externalURL=t.externalURL;break;case"web-bundle":t.skipPending!==void 0&&(e.skipPending=t.skipPending);break}return t.screenID!==void 0&&(e.screenID=t.screenID),l(this,Ue).requestJSON("POST","/artifacts",e)}list(t={}){const e=new URLSearchParams;t.screenID!==void 0&&e.set("screenID",t.screenID),t.unplaced&&e.set("unplaced","true");const r=e.toString();return l(this,Ue).requestJSON("GET",r?`/artifacts?${r}`:"/artifacts")}get(t){return l(this,Ue).requestJSON("GET",`/artifacts/${encodeURIComponent(t.artifactID)}`)}update(t){const e={};return t.title!==void 0&&(e.title=t.title),l(this,Ue).requestJSON("PATCH",`/artifacts/${encodeURIComponent(t.artifactID)}`,e)}edit(t){return l(this,Ue).requestJSON("POST",`/artifacts/${encodeURIComponent(t.artifactID)}/edit`)}commitPending(t){return l(this,Ue).requestJSON("POST",`/artifacts/${encodeURIComponent(t.artifactID)}/commit`)}abandonPending(t){return l(this,Ue).requestVoid("POST",`/artifacts/${encodeURIComponent(t.artifactID)}/abandon`)}attach(t){return l(this,Ue).requestJSON("POST",`/screens/${encodeURIComponent(t.screenID)}/artifacts/${encodeURIComponent(t.artifactID)}`)}detach(t){return l(this,Ue).requestJSON("DELETE",`/screens/${encodeURIComponent(t.screenID)}/artifacts/${encodeURIComponent(t.artifactID)}`)}delete(t){return l(this,Ue).requestJSON("DELETE",`/artifacts/${encodeURIComponent(t.artifactID)}`)}getContent(t){return l(this,Ue).requestText("GET",`/artifacts/${encodeURIComponent(t.artifactID)}/content`)}putContent(t){return l(this,Ue).requestRawVoid("PUT",`/artifacts/${encodeURIComponent(t.artifactID)}/content`,t.content)}}Ue=new WeakMap;var vr;class E1{constructor(t){w(this,vr);S(this,vr,t)}get(){return l(this,vr).requestJSON("GET","/display")}patch(t){const e={};return t.activeScreenID!==void 0&&(e.activeScreenID=t.activeScreenID),t.activeThemeName!==void 0&&(e.activeThemeName=t.activeThemeName),l(this,vr).requestVoid("PATCH","/display",e)}focus(t){const e={artifactID:t.artifactID};return t.screenID!==void 0&&(e.screenID=t.screenID),l(this,vr).requestJSON("POST","/display/focus",e)}}vr=new WeakMap;var Gs;class A1{constructor(t){w(this,Gs);S(this,Gs,t)}async list(){const{views:t}=await l(this,Gs).requestJSON("GET","/views");return t}}Gs=new WeakMap;var pn;class $1{constructor(t,e={}){g(this,"screens");g(this,"artifacts");g(this,"display");g(this,"views");w(this,pn);S(this,pn,new w1(t,e)),this.screens=new k1(l(this,pn)),this.artifacts=new x1(l(this,pn)),this.display=new E1(l(this,pn)),this.views=new A1(l(this,pn))}health(){return l(this,pn).requestJSON("GET","/health")}}pn=new WeakMap;const T1={focusCommandInput:{label:"Focus Command Input",trigger:{key:"k",meta:!0}}},I1="Local",C1="store-";function be(n){return new URL(n).origin}function R1(n){return{servers:[{url:be(n),name:I1}],activeServerURL:null,activeScreenID:null,tabs:{},screens:{}}}function P1(n,t){return[...n.tabs[be(t)]??[]]}function D1(n,t,e){const r=be(t),i=n.tabs[r]??[];return i.includes(e)?n:{...n,tabs:{...n.tabs,[r]:[...i,e]}}}function L1(n,t,e){const r=be(t),i=n.tabs[r]??[],s=i.filter(a=>a!==e);if(s.length===i.length)return n;const o={...n.tabs};return s.length===0?delete o[r]:o[r]=s,{...n,tabs:o}}var yr,br,wr;class z1 extends tn{constructor(e,r,i={}){super();w(this,yr);w(this,br);w(this,wr);S(this,yr,`${C1}${e}`),S(this,br,i.storage??O1());const s=l(this,br).getItem(l(this,yr));s===null?(S(this,wr,r),l(this,br).setItem(l(this,yr),JSON.stringify(r))):S(this,wr,M1(JSON.parse(s),r))}get(){return l(this,wr)}set(e){S(this,wr,e),l(this,br).setItem(l(this,yr),JSON.stringify(e)),this.dispatchEvent(new ae("change"))}}yr=new WeakMap,br=new WeakMap,wr=new WeakMap;function O1(){const n=globalThis.localStorage;if(!n)throw new Error("LocalStore: no storage adapter supplied and window.localStorage is unavailable");return n}function M1(n,t){return{servers:Array.isArray(n.servers)?n.servers:t.servers,activeServerURL:typeof n.activeServerURL=="string"||n.activeServerURL===null?n.activeServerURL:t.activeServerURL,activeScreenID:typeof n.activeScreenID=="string"||n.activeScreenID===null?n.activeScreenID:t.activeScreenID,tabs:n.tabs&&typeof n.tabs=="object"?n.tabs:t.tabs,screens:n.screens&&typeof n.screens=="object"?n.screens:t.screens}}const N1=Ko(tn);var Sr,Ke,_r,Ve,Rn,Pn,te,si,Ov,qs,Mv,Nv,Uv,Fv,Iu,Cu,Ru,Hv;class U1 extends N1{constructor(e){var i;super();w(this,te);g(this,"id");g(this,"server");w(this,Sr);w(this,Ke,new Map);w(this,_r);w(this,Ve);w(this,Rn);w(this,Pn,null);w(this,qs,e=>{if(this.disposed)return;const r=e.event;switch(r.type){case"screen-updated":r.screen.id===this.id&&f(this,te,Mv).call(this,r.screen);break;case"artifact-created":break;case"artifact-attached":r.screenID===this.id&&f(this,te,Nv).call(this,r.cardID,r.artifact);break;case"artifact-updated":f(this,te,Uv).call(this,r.artifact);break;case"artifact-removed":r.screenID===this.id&&f(this,te,Fv).call(this,r.artifactID);break;case"artifact-content-changed":l(this,Ke).has(r.artifactID)&&this.dispatchEvent(new m1("artifact-content-changed",{artifactID:r.artifactID}));break}});this.id=e.screen.id,this.server=e.server,S(this,Sr,e.localStore),S(this,_r,e.screen.name),S(this,Ve,structuredClone(e.screen.layout));const r=((i=l(this,Sr).get().screens[this.id])==null?void 0:i.scrollPosition)??0;S(this,Rn,Math.max(0,r)),this.server.addEventListener("server-event",l(this,qs)),f(this,te,Ov).call(this)}get name(){return l(this,_r)}get layout(){return l(this,Ve)}get scrollPosition(){return l(this,Rn)}get artifacts(){return l(this,Ke)}setScrollPosition(e){f(this,te,si).call(this);const r=Math.max(0,e);r!==l(this,Rn)&&(S(this,Rn,r),f(this,te,Hv).call(this),this.dispatchEvent(new ae("change")))}setLayout(e){f(this,te,si).call(this);const r=wv(e);if(!_v(r).valid)return;const s=f(this,te,Cu).call(this);S(this,Ve,r),S(this,Pn,{layout:r,snapshot:s}),this.dispatchEvent(new ae("change")),this.server.client.screens.update({screenID:this.id,layout:r.map(o=>structuredClone(o))}).catch(()=>{var o;this.disposed||((o=l(this,Pn))==null?void 0:o.layout)===r&&(S(this,Pn,null),f(this,te,Ru).call(this,s),this.dispatchEvent(new ae("change")))})}rename(e){f(this,te,si).call(this),S(this,_r,e),this.dispatchEvent(new ae("change")),this.server.client.screens.update({screenID:this.id,name:e}).catch(()=>{})}async remove(){f(this,te,si).call(this),await this.server.client.screens.remove({screenID:this.id})}removeArtifact(e){if(f(this,te,si).call(this),!l(this,Ke).has(e))return;const r=f(this,te,Cu).call(this);f(this,te,Iu).call(this,e),this.dispatchEvent(new ae("change")),this.server.client.artifacts.detach({artifactID:e,screenID:this.id}).catch(()=>{this.disposed||(f(this,te,Ru).call(this,r),this.dispatchEvent(new ae("change")))})}dispose(){this.server.removeEventListener("server-event",l(this,qs))}}Sr=new WeakMap,Ke=new WeakMap,_r=new WeakMap,Ve=new WeakMap,Rn=new WeakMap,Pn=new WeakMap,te=new WeakSet,si=function(){if(this.disposed)throw new Error("ScreenModel is disposed")},Ov=async function(){try{const e=await this.server.client.screens.get({screenID:this.id});if(this.disposed)return;for(const r of e.artifacts)l(this,Ke).set(r.id,r);this.dispatchEvent(new ae("change"))}catch{}},qs=new WeakMap,Mv=function(e){l(this,Pn)&&S(this,Pn,null),S(this,_r,e.name),S(this,Ve,structuredClone(e.layout)),this.dispatchEvent(new ae("change"))},Nv=function(e,r){Rv(l(this,Ve),r.id)||S(this,Ve,[...l(this,Ve),Cv(r.id,{id:e})]),l(this,Ke).set(r.id,r),this.dispatchEvent(new ae("change"))},Uv=function(e){const r=l(this,Ke).get(e.id);r&&(l(this,Ke).set(e.id,{...r,...e}),this.dispatchEvent(new ae("change")))},Fv=function(e){f(this,te,Iu).call(this,e)&&this.dispatchEvent(new ae("change"))},Iu=function(e){const r=l(this,Ke).delete(e),i=Zf({layout:l(this,Ve)}).length,s=Sv(l(this,Ve),e),o=Zf({layout:s}).length;return S(this,Ve,s),r||i!==o},Cu=function(){return{layout:structuredClone(l(this,Ve)),artifacts:new Map([...l(this,Ke).entries()].map(([e,r])=>[e,structuredClone(r)]))}},Ru=function(e){S(this,Ve,structuredClone(e.layout)),l(this,Ke).clear();for(const[r,i]of e.artifacts)l(this,Ke).set(r,structuredClone(i))},Hv=function(){const e=l(this,Sr).get();l(this,Sr).set({...e,screens:{...e.screens,[this.id]:{scrollPosition:l(this,Rn)}}})};const F1=Ko(tn);var Le,Je,Nt,Ys,Xs,Ks,je,Oa,Pu,oi;class H1 extends F1{constructor(e){super();w(this,je);w(this,Le);w(this,Je);w(this,Nt,null);w(this,Ys,()=>{this.disposed||f(this,je,Oa).call(this)});w(this,Xs,()=>{this.disposed||f(this,je,Oa).call(this)});w(this,Ks,e=>{if(this.disposed)return;const r=e.event;if(r.type==="screen-removed"){this.removeTab(e.serverURL,r.screenID);const i=l(this,Le).get();i.activeServerURL===be(e.serverURL)&&i.activeScreenID===r.screenID&&f(this,je,oi).call(this,e.serverURL,null);return}if(r.type==="screen-changed"){if(r.screenID===null){f(this,je,oi).call(this,e.serverURL,null);return}const i=l(this,Je).servers.get(be(e.serverURL));if(!i||!i.screens.has(r.screenID))return;this.addTab(e.serverURL,r.screenID),f(this,je,oi).call(this,e.serverURL,r.screenID)}});S(this,Le,e.localStore),S(this,Je,e.serverManager),l(this,Le).addEventListener("change",l(this,Ys)),l(this,Je).addEventListener("change",l(this,Xs)),l(this,Je).addEventListener("server-event",l(this,Ks)),f(this,je,Oa).call(this)}get activeScreen(){return l(this,Nt)}getTabs(e){const r=be(e),i=P1(l(this,Le).get(),r),s=l(this,Je).servers.get(r);return s?i.filter(o=>s.screens.has(o)):i}hasTab(e,r){return this.getTabs(e).includes(r)}addTab(e,r){const i=be(e),s=l(this,Je).servers.get(i);s&&!s.screens.has(r)||f(this,je,Pu).call(this,D1(l(this,Le).get(),i,r))}removeTab(e,r){f(this,je,Pu).call(this,L1(l(this,Le).get(),e,r))}setActive(e,r){const i=be(e),s=l(this,Je).servers.get(i);!s||!s.screens.has(r)||f(this,je,oi).call(this,i,r)&&s.client.display.patch({activeScreenID:r}).catch(()=>{})}clearActive(){const e=l(this,Le).get().activeServerURL;if(!e||!f(this,je,oi).call(this,e,null))return;const r=l(this,Je).servers.get(e);r==null||r.client.display.patch({activeScreenID:null}).catch(()=>{})}dispose(){var e;l(this,Le).removeEventListener("change",l(this,Ys)),l(this,Je).removeEventListener("change",l(this,Xs)),l(this,Je).removeEventListener("server-event",l(this,Ks)),(e=l(this,Nt))==null||e.dispose(),S(this,Nt,null)}}Le=new WeakMap,Je=new WeakMap,Nt=new WeakMap,Ys=new WeakMap,Xs=new WeakMap,Ks=new WeakMap,je=new WeakSet,Oa=function(){var c,u,h;const{activeServerURL:e,activeScreenID:r}=l(this,Le).get(),i=e?l(this,Je).servers.get(e)??null:null,s=i&&r?i.screens.get(r)??null:null,o=((c=l(this,Nt))==null?void 0:c.id)??null,a=(s==null?void 0:s.id)??null;o===a&&((u=l(this,Nt))==null?void 0:u.server)===i||((h=l(this,Nt))==null||h.dispose(),S(this,Nt,i&&s?new U1({screen:s,server:i,localStore:l(this,Le)}):null),i&&i.acpClient.setScreenContext(s?{screenID:s.id,screenName:s.name}:null),this.dispatchEvent(new GA("active-screen-changed")))},Pu=function(e){e!==l(this,Le).get()&&(l(this,Le).set(e),this.dispatchEvent(new qA("tabs-changed")))},oi=function(e,r){const i=be(e),s=l(this,Le).get();return s.activeServerURL===i&&s.activeScreenID===r?!1:(l(this,Le).set({...s,activeServerURL:i,activeScreenID:r}),!0)};function A(n,t,e){function r(a,c){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:c,constr:o,traits:new Set},enumerable:!1}),a._zod.traits.has(n))return;a._zod.traits.add(n),t(a,c);const u=o.prototype,h=Object.keys(u);for(let p=0;p<h.length;p++){const v=h[p];v in a||(a[v]=u[v].bind(a))}}const i=(e==null?void 0:e.Parent)??Object;class s extends i{}Object.defineProperty(s,"name",{value:n});function o(a){var c;const u=e!=null&&e.Parent?new s:this;r(u,a),(c=u._zod).deferred??(c.deferred=[]);for(const h of u._zod.deferred)h();return u}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:a=>{var c,u;return e!=null&&e.Parent&&a instanceof e.Parent?!0:(u=(c=a==null?void 0:a._zod)==null?void 0:c.traits)==null?void 0:u.has(n)}}),Object.defineProperty(o,"name",{value:n}),o}class bi extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Wv extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const Zv={};function jn(n){return Zv}function Vv(n){const t=Object.values(n).filter(r=>typeof r=="number");return Object.entries(n).filter(([r,i])=>t.indexOf(+r)===-1).map(([r,i])=>i)}function Du(n,t){return typeof t=="bigint"?t.toString():t}function ud(n){return{get value(){{const t=n();return Object.defineProperty(this,"value",{value:t}),t}}}}function hd(n){return n==null}function dd(n){const t=n.startsWith("^")?1:0,e=n.endsWith("$")?n.length-1:n.length;return n.slice(t,e)}function W1(n,t){const e=(n.toString().split(".")[1]||"").length,r=t.toString();let i=(r.split(".")[1]||"").length;if(i===0&&/\d?e-\d?/.test(r)){const c=r.match(/\d?e-(\d?)/);c!=null&&c[1]&&(i=Number.parseInt(c[1]))}const s=e>i?e:i,o=Number.parseInt(n.toFixed(s).replace(".","")),a=Number.parseInt(t.toFixed(s).replace(".",""));return o%a/10**s}const Vf=Symbol("evaluating");function ne(n,t,e){let r;Object.defineProperty(n,t,{get(){if(r!==Vf)return r===void 0&&(r=Vf,r=e()),r},set(i){Object.defineProperty(n,t,{value:i})},configurable:!0})}function Vr(n,t,e){Object.defineProperty(n,t,{value:e,writable:!0,enumerable:!0,configurable:!0})}function Jn(...n){const t={};for(const e of n){const r=Object.getOwnPropertyDescriptors(e);Object.assign(t,r)}return Object.defineProperties({},t)}function Bf(n){return JSON.stringify(n)}function Z1(n){return n.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Bv="captureStackTrace"in Error?Error.captureStackTrace:(...n)=>{};function ul(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}const V1=ud(()=>{var n;if(typeof navigator<"u"&&((n=navigator==null?void 0:navigator.userAgent)!=null&&n.includes("Cloudflare")))return!1;try{const t=Function;return new t(""),!0}catch{return!1}});function Gi(n){if(ul(n)===!1)return!1;const t=n.constructor;if(t===void 0||typeof t!="function")return!0;const e=t.prototype;return!(ul(e)===!1||Object.prototype.hasOwnProperty.call(e,"isPrototypeOf")===!1)}function jv(n){return Gi(n)?{...n}:Array.isArray(n)?[...n]:n}const B1=new Set(["string","number","symbol"]);function qi(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Qn(n,t,e){const r=new n._zod.constr(t??n._zod.def);return(!t||e!=null&&e.parent)&&(r._zod.parent=n),r}function M(n){const t=n;if(!t)return{};if(typeof t=="string")return{error:()=>t};if((t==null?void 0:t.message)!==void 0){if((t==null?void 0:t.error)!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function j1(n){return Object.keys(n).filter(t=>n[t]._zod.optin==="optional"&&n[t]._zod.optout==="optional")}const G1={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 q1(n,t){const e=n._zod.def,r=e.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const s=Jn(n._zod.def,{get shape(){const o={};for(const a in t){if(!(a in e.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&(o[a]=e.shape[a])}return Vr(this,"shape",o),o},checks:[]});return Qn(n,s)}function Y1(n,t){const e=n._zod.def,r=e.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const s=Jn(n._zod.def,{get shape(){const o={...n._zod.def.shape};for(const a in t){if(!(a in e.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&delete o[a]}return Vr(this,"shape",o),o},checks:[]});return Qn(n,s)}function X1(n,t){if(!Gi(t))throw new Error("Invalid input to extend: expected a plain object");const e=n._zod.def.checks;if(e&&e.length>0){const s=n._zod.def.shape;for(const o in t)if(Object.getOwnPropertyDescriptor(s,o)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const i=Jn(n._zod.def,{get shape(){const s={...n._zod.def.shape,...t};return Vr(this,"shape",s),s}});return Qn(n,i)}function K1(n,t){if(!Gi(t))throw new Error("Invalid input to safeExtend: expected a plain object");const e=Jn(n._zod.def,{get shape(){const r={...n._zod.def.shape,...t};return Vr(this,"shape",r),r}});return Qn(n,e)}function J1(n,t){const e=Jn(n._zod.def,{get shape(){const r={...n._zod.def.shape,...t._zod.def.shape};return Vr(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:[]});return Qn(n,e)}function Q1(n,t,e){const i=t._zod.def.checks;if(i&&i.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const o=Jn(t._zod.def,{get shape(){const a=t._zod.def.shape,c={...a};if(e)for(const u in e){if(!(u in a))throw new Error(`Unrecognized key: "${u}"`);e[u]&&(c[u]=n?new n({type:"optional",innerType:a[u]}):a[u])}else for(const u in a)c[u]=n?new n({type:"optional",innerType:a[u]}):a[u];return Vr(this,"shape",c),c},checks:[]});return Qn(t,o)}function e$(n,t,e){const r=Jn(t._zod.def,{get shape(){const i=t._zod.def.shape,s={...i};if(e)for(const o in e){if(!(o in s))throw new Error(`Unrecognized key: "${o}"`);e[o]&&(s[o]=new n({type:"nonoptional",innerType:i[o]}))}else for(const o in i)s[o]=new n({type:"nonoptional",innerType:i[o]});return Vr(this,"shape",s),s}});return Qn(t,r)}function mi(n,t=0){var e;if(n.aborted===!0)return!0;for(let r=t;r<n.issues.length;r++)if(((e=n.issues[r])==null?void 0:e.continue)!==!0)return!0;return!1}function vi(n,t){return t.map(e=>{var r;return(r=e).path??(r.path=[]),e.path.unshift(n),e})}function ba(n){return typeof n=="string"?n:n==null?void 0:n.message}function Gn(n,t,e){var i,s,o,a,c,u;const r={...n,path:n.path??[]};if(!n.message){const h=ba((o=(s=(i=n.inst)==null?void 0:i._zod.def)==null?void 0:s.error)==null?void 0:o.call(s,n))??ba((a=t==null?void 0:t.error)==null?void 0:a.call(t,n))??ba((c=e.customError)==null?void 0:c.call(e,n))??ba((u=e.localeError)==null?void 0:u.call(e,n))??"Invalid input";r.message=h}return delete r.inst,delete r.continue,t!=null&&t.reportInput||delete r.input,r}function pd(n){return Array.isArray(n)?"array":typeof n=="string"?"string":"unknown"}function Ws(...n){const[t,e,r]=n;return typeof t=="string"?{message:t,code:"custom",input:e,inst:r}:{...t}}const Gv=(n,t)=>{n.name="$ZodError",Object.defineProperty(n,"_zod",{value:n._zod,enumerable:!1}),Object.defineProperty(n,"issues",{value:t,enumerable:!1}),n.message=JSON.stringify(t,Du,2),Object.defineProperty(n,"toString",{value:()=>n.message,enumerable:!1})},qv=A("$ZodError",Gv),Yv=A("$ZodError",Gv,{Parent:Error});function t$(n,t=e=>e.message){const e={},r=[];for(const i of n.issues)i.path.length>0?(e[i.path[0]]=e[i.path[0]]||[],e[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:e}}function n$(n,t=e=>e.message){const e={_errors:[]},r=i=>{for(const s of i.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(o=>r({issues:o}));else if(s.code==="invalid_key")r({issues:s.issues});else if(s.code==="invalid_element")r({issues:s.issues});else if(s.path.length===0)e._errors.push(t(s));else{let o=e,a=0;for(;a<s.path.length;){const c=s.path[a];a===s.path.length-1?(o[c]=o[c]||{_errors:[]},o[c]._errors.push(t(s))):o[c]=o[c]||{_errors:[]},o=o[c],a++}}};return r(n),e}const fd=n=>(t,e,r,i)=>{const s=r?Object.assign(r,{async:!1}):{async:!1},o=t._zod.run({value:e,issues:[]},s);if(o instanceof Promise)throw new bi;if(o.issues.length){const a=new((i==null?void 0:i.Err)??n)(o.issues.map(c=>Gn(c,s,jn())));throw Bv(a,i==null?void 0:i.callee),a}return o.value},gd=n=>async(t,e,r,i)=>{const s=r?Object.assign(r,{async:!0}):{async:!0};let o=t._zod.run({value:e,issues:[]},s);if(o instanceof Promise&&(o=await o),o.issues.length){const a=new((i==null?void 0:i.Err)??n)(o.issues.map(c=>Gn(c,s,jn())));throw Bv(a,i==null?void 0:i.callee),a}return o.value},Gl=n=>(t,e,r)=>{const i=r?{...r,async:!1}:{async:!1},s=t._zod.run({value:e,issues:[]},i);if(s instanceof Promise)throw new bi;return s.issues.length?{success:!1,error:new(n??qv)(s.issues.map(o=>Gn(o,i,jn())))}:{success:!0,data:s.value}},r$=Gl(Yv),ql=n=>async(t,e,r)=>{const i=r?Object.assign(r,{async:!0}):{async:!0};let s=t._zod.run({value:e,issues:[]},i);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new n(s.issues.map(o=>Gn(o,i,jn())))}:{success:!0,data:s.value}},i$=ql(Yv),s$=n=>(t,e,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return fd(n)(t,e,i)},o$=n=>(t,e,r)=>fd(n)(t,e,r),a$=n=>async(t,e,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return gd(n)(t,e,i)},l$=n=>async(t,e,r)=>gd(n)(t,e,r),c$=n=>(t,e,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Gl(n)(t,e,i)},u$=n=>(t,e,r)=>Gl(n)(t,e,r),h$=n=>async(t,e,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return ql(n)(t,e,i)},d$=n=>async(t,e,r)=>ql(n)(t,e,r),p$=/^[cC][^\s-]{8,}$/,f$=/^[0-9a-z]+$/,g$=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,m$=/^[0-9a-vA-V]{20}$/,v$=/^[A-Za-z0-9]{27}$/,y$=/^[a-zA-Z0-9_-]{21}$/,b$=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,w$=/^([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})$/,jf=n=>n?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${n}[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)$/,S$=/^(?!\.)(?!.*\.\.)([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 k$(){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])$/,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}|:))$/,A$=/^((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])$/,$$=/^(([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])$/,T$=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Xv=/^[A-Za-z0-9_-]*$/,I$=/^\+[1-9]\d{6,14}$/,Kv="(?:(?:\\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(`^${Kv}$`);function Jv(n){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof n.precision=="number"?n.precision===-1?`${t}`:n.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${n.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function R$(n){return new RegExp(`^${Jv(n)}$`)}function P$(n){const t=Jv({precision:n.precision}),e=["Z"];n.local&&e.push(""),n.offset&&e.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${t}(?:${e.join("|")})`;return new RegExp(`^${Kv}T(?:${r})$`)}const D$=n=>{const t=n?`[\\s\\S]{${(n==null?void 0:n.minimum)??0},${(n==null?void 0:n.maximum)??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},L$=/^-?\d+$/,Qv=/^-?\d+(?:\.\d+)?$/,z$=/^(?:true|false)$/i,O$=/^[^A-Z]*$/,M$=/^[^a-z]*$/,it=A("$ZodCheck",(n,t)=>{var e;n._zod??(n._zod={}),n._zod.def=t,(e=n._zod).onattach??(e.onattach=[])}),ey={number:"number",bigint:"bigint",object:"date"},ty=A("$ZodCheckLessThan",(n,t)=>{it.init(n,t);const e=ey[typeof t.value];n._zod.onattach.push(r=>{const i=r._zod.bag,s=(t.inclusive?i.maximum:i.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<s&&(t.inclusive?i.maximum=t.value:i.exclusiveMaximum=t.value)}),n._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:e,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:n,continue:!t.abort})}}),ny=A("$ZodCheckGreaterThan",(n,t)=>{it.init(n,t);const e=ey[typeof t.value];n._zod.onattach.push(r=>{const i=r._zod.bag,s=(t.inclusive?i.minimum:i.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>s&&(t.inclusive?i.minimum=t.value:i.exclusiveMinimum=t.value)}),n._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:e,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:n,continue:!t.abort})}}),N$=A("$ZodCheckMultipleOf",(n,t)=>{it.init(n,t),n._zod.onattach.push(e=>{var r;(r=e._zod.bag).multipleOf??(r.multipleOf=t.value)}),n._zod.check=e=>{if(typeof e.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof e.value=="bigint"?e.value%t.value===BigInt(0):W1(e.value,t.value)===0)||e.issues.push({origin:typeof e.value,code:"not_multiple_of",divisor:t.value,input:e.value,inst:n,continue:!t.abort})}}),U$=A("$ZodCheckNumberFormat",(n,t)=>{var o;it.init(n,t),t.format=t.format||"float64";const e=(o=t.format)==null?void 0:o.includes("int"),r=e?"int":"number",[i,s]=G1[t.format];n._zod.onattach.push(a=>{const c=a._zod.bag;c.format=t.format,c.minimum=i,c.maximum=s,e&&(c.pattern=L$)}),n._zod.check=a=>{const c=a.value;if(e){if(!Number.isInteger(c)){a.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:c,inst:n});return}if(!Number.isSafeInteger(c)){c>0?a.issues.push({input:c,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:n,origin:r,inclusive:!0,continue:!t.abort}):a.issues.push({input:c,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:n,origin:r,inclusive:!0,continue:!t.abort});return}}c<i&&a.issues.push({origin:"number",input:c,code:"too_small",minimum:i,inclusive:!0,inst:n,continue:!t.abort}),c>s&&a.issues.push({origin:"number",input:c,code:"too_big",maximum:s,inclusive:!0,inst:n,continue:!t.abort})}}),F$=A("$ZodCheckMaxLength",(n,t)=>{var e;it.init(n,t),(e=n._zod.def).when??(e.when=r=>{const i=r.value;return!hd(i)&&i.length!==void 0}),n._zod.onattach.push(r=>{const i=r._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<i&&(r._zod.bag.maximum=t.maximum)}),n._zod.check=r=>{const i=r.value;if(i.length<=t.maximum)return;const o=pd(i);r.issues.push({origin:o,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:n,continue:!t.abort})}}),H$=A("$ZodCheckMinLength",(n,t)=>{var e;it.init(n,t),(e=n._zod.def).when??(e.when=r=>{const i=r.value;return!hd(i)&&i.length!==void 0}),n._zod.onattach.push(r=>{const i=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>i&&(r._zod.bag.minimum=t.minimum)}),n._zod.check=r=>{const i=r.value;if(i.length>=t.minimum)return;const o=pd(i);r.issues.push({origin:o,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:n,continue:!t.abort})}}),W$=A("$ZodCheckLengthEquals",(n,t)=>{var e;it.init(n,t),(e=n._zod.def).when??(e.when=r=>{const i=r.value;return!hd(i)&&i.length!==void 0}),n._zod.onattach.push(r=>{const i=r._zod.bag;i.minimum=t.length,i.maximum=t.length,i.length=t.length}),n._zod.check=r=>{const i=r.value,s=i.length;if(s===t.length)return;const o=pd(i),a=s>t.length;r.issues.push({origin:o,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:n,continue:!t.abort})}}),Yl=A("$ZodCheckStringFormat",(n,t)=>{var e,r;it.init(n,t),n._zod.onattach.push(i=>{const s=i._zod.bag;s.format=t.format,t.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(t.pattern))}),t.pattern?(e=n._zod).check??(e.check=i=>{t.pattern.lastIndex=0,!t.pattern.test(i.value)&&i.issues.push({origin:"string",code:"invalid_format",format:t.format,input:i.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:n,continue:!t.abort})}):(r=n._zod).check??(r.check=()=>{})}),Z$=A("$ZodCheckRegex",(n,t)=>{Yl.init(n,t),n._zod.check=e=>{t.pattern.lastIndex=0,!t.pattern.test(e.value)&&e.issues.push({origin:"string",code:"invalid_format",format:"regex",input:e.value,pattern:t.pattern.toString(),inst:n,continue:!t.abort})}}),V$=A("$ZodCheckLowerCase",(n,t)=>{t.pattern??(t.pattern=O$),Yl.init(n,t)}),B$=A("$ZodCheckUpperCase",(n,t)=>{t.pattern??(t.pattern=M$),Yl.init(n,t)}),j$=A("$ZodCheckIncludes",(n,t)=>{it.init(n,t);const e=qi(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position}}${e}`:e);t.pattern=r,n._zod.onattach.push(i=>{const s=i._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(r)}),n._zod.check=i=>{i.value.includes(t.includes,t.position)||i.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:i.value,inst:n,continue:!t.abort})}}),G$=A("$ZodCheckStartsWith",(n,t)=>{it.init(n,t);const e=new RegExp(`^${qi(t.prefix)}.*`);t.pattern??(t.pattern=e),n._zod.onattach.push(r=>{const i=r._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(e)}),n._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:n,continue:!t.abort})}}),q$=A("$ZodCheckEndsWith",(n,t)=>{it.init(n,t);const e=new RegExp(`.*${qi(t.suffix)}$`);t.pattern??(t.pattern=e),n._zod.onattach.push(r=>{const i=r._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(e)}),n._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:n,continue:!t.abort})}}),Y$=A("$ZodCheckOverwrite",(n,t)=>{it.init(n,t),n._zod.check=e=>{e.value=t.tx(e.value)}});class X${constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const r=t.split(`
|
|
5
5
|
`).filter(o=>o),i=Math.min(...r.map(o=>o.length-o.trimStart().length)),s=r.map(o=>o.slice(i)).map(o=>" ".repeat(this.indent*2)+o);for(const o of s)this.content.push(o)}compile(){const t=Function,e=this==null?void 0:this.args,i=[...((this==null?void 0:this.content)??[""]).map(s=>` ${s}`)];return new t(...e,i.join(`
|
|
6
|
-
`))}}const
|
|
6
|
+
`))}}const K$={major:4,minor:3,patch:6},fe=A("$ZodType",(n,t)=>{var i;var e;n??(n={}),n._zod.def=t,n._zod.bag=n._zod.bag||{},n._zod.version=K$;const r=[...n._zod.def.checks??[]];n._zod.traits.has("$ZodCheck")&&r.unshift(n);for(const s of r)for(const o of s._zod.onattach)o(n);if(r.length===0)(e=n._zod).deferred??(e.deferred=[]),(i=n._zod.deferred)==null||i.push(()=>{n._zod.run=n._zod.parse});else{const s=(a,c,u)=>{let h=mi(a),p;for(const v of c){if(v._zod.def.when){if(!v._zod.def.when(a))continue}else if(h)continue;const m=a.issues.length,_=v._zod.check(a);if(_ instanceof Promise&&(u==null?void 0:u.async)===!1)throw new bi;if(p||_ instanceof Promise)p=(p??Promise.resolve()).then(async()=>{await _,a.issues.length!==m&&(h||(h=mi(a,m)))});else{if(a.issues.length===m)continue;h||(h=mi(a,m))}}return p?p.then(()=>a):a},o=(a,c,u)=>{if(mi(a))return a.aborted=!0,a;const h=s(c,r,u);if(h instanceof Promise){if(u.async===!1)throw new bi;return h.then(p=>n._zod.parse(p,u))}return n._zod.parse(h,u)};n._zod.run=(a,c)=>{if(c.skipChecks)return n._zod.parse(a,c);if(c.direction==="backward"){const h=n._zod.parse({value:a.value,issues:[]},{...c,skipChecks:!0});return h instanceof Promise?h.then(p=>o(p,a,c)):o(h,a,c)}const u=n._zod.parse(a,c);if(u instanceof Promise){if(c.async===!1)throw new bi;return u.then(h=>s(h,r,c))}return s(u,r,c)}}ne(n,"~standard",()=>({validate:s=>{var o;try{const a=r$(n,s);return a.success?{value:a.data}:{issues:(o=a.error)==null?void 0:o.issues}}catch{return i$(n,s).then(c=>{var u;return c.success?{value:c.data}:{issues:(u=c.error)==null?void 0:u.issues}})}},vendor:"zod",version:1}))}),md=A("$ZodString",(n,t)=>{var e;fe.init(n,t),n._zod.pattern=[...((e=n==null?void 0:n._zod.bag)==null?void 0:e.patterns)??[]].pop()??D$(n._zod.bag),n._zod.parse=(r,i)=>{if(t.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:n}),r}}),he=A("$ZodStringFormat",(n,t)=>{Yl.init(n,t),md.init(n,t)}),J$=A("$ZodGUID",(n,t)=>{t.pattern??(t.pattern=w$),he.init(n,t)}),Q$=A("$ZodUUID",(n,t)=>{if(t.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(r===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=jf(r))}else t.pattern??(t.pattern=jf());he.init(n,t)}),eT=A("$ZodEmail",(n,t)=>{t.pattern??(t.pattern=S$),he.init(n,t)}),tT=A("$ZodURL",(n,t)=>{he.init(n,t),n._zod.check=e=>{try{const r=e.value.trim(),i=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||e.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:e.value,inst:n,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(":")?i.protocol.slice(0,-1):i.protocol)||e.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:e.value,inst:n,continue:!t.abort})),t.normalize?e.value=i.href:e.value=r;return}catch{e.issues.push({code:"invalid_format",format:"url",input:e.value,inst:n,continue:!t.abort})}}}),nT=A("$ZodEmoji",(n,t)=>{t.pattern??(t.pattern=k$()),he.init(n,t)}),rT=A("$ZodNanoID",(n,t)=>{t.pattern??(t.pattern=y$),he.init(n,t)}),iT=A("$ZodCUID",(n,t)=>{t.pattern??(t.pattern=p$),he.init(n,t)}),sT=A("$ZodCUID2",(n,t)=>{t.pattern??(t.pattern=f$),he.init(n,t)}),oT=A("$ZodULID",(n,t)=>{t.pattern??(t.pattern=g$),he.init(n,t)}),aT=A("$ZodXID",(n,t)=>{t.pattern??(t.pattern=m$),he.init(n,t)}),lT=A("$ZodKSUID",(n,t)=>{t.pattern??(t.pattern=v$),he.init(n,t)}),cT=A("$ZodISODateTime",(n,t)=>{t.pattern??(t.pattern=P$(t)),he.init(n,t)}),uT=A("$ZodISODate",(n,t)=>{t.pattern??(t.pattern=C$),he.init(n,t)}),hT=A("$ZodISOTime",(n,t)=>{t.pattern??(t.pattern=R$(t)),he.init(n,t)}),dT=A("$ZodISODuration",(n,t)=>{t.pattern??(t.pattern=b$),he.init(n,t)}),pT=A("$ZodIPv4",(n,t)=>{t.pattern??(t.pattern=x$),he.init(n,t),n._zod.bag.format="ipv4"}),fT=A("$ZodIPv6",(n,t)=>{t.pattern??(t.pattern=E$),he.init(n,t),n._zod.bag.format="ipv6",n._zod.check=e=>{try{new URL(`http://[${e.value}]`)}catch{e.issues.push({code:"invalid_format",format:"ipv6",input:e.value,inst:n,continue:!t.abort})}}}),gT=A("$ZodCIDRv4",(n,t)=>{t.pattern??(t.pattern=A$),he.init(n,t)}),mT=A("$ZodCIDRv6",(n,t)=>{t.pattern??(t.pattern=$$),he.init(n,t),n._zod.check=e=>{const r=e.value.split("/");try{if(r.length!==2)throw new Error;const[i,s]=r;if(!s)throw new Error;const o=Number(s);if(`${o}`!==s)throw new Error;if(o<0||o>128)throw new Error;new URL(`http://[${i}]`)}catch{e.issues.push({code:"invalid_format",format:"cidrv6",input:e.value,inst:n,continue:!t.abort})}}});function ry(n){if(n==="")return!0;if(n.length%4!==0)return!1;try{return atob(n),!0}catch{return!1}}const vT=A("$ZodBase64",(n,t)=>{t.pattern??(t.pattern=T$),he.init(n,t),n._zod.bag.contentEncoding="base64",n._zod.check=e=>{ry(e.value)||e.issues.push({code:"invalid_format",format:"base64",input:e.value,inst:n,continue:!t.abort})}});function yT(n){if(!Xv.test(n))return!1;const t=n.replace(/[-_]/g,r=>r==="-"?"+":"/"),e=t.padEnd(Math.ceil(t.length/4)*4,"=");return ry(e)}const bT=A("$ZodBase64URL",(n,t)=>{t.pattern??(t.pattern=Xv),he.init(n,t),n._zod.bag.contentEncoding="base64url",n._zod.check=e=>{yT(e.value)||e.issues.push({code:"invalid_format",format:"base64url",input:e.value,inst:n,continue:!t.abort})}}),wT=A("$ZodE164",(n,t)=>{t.pattern??(t.pattern=I$),he.init(n,t)});function ST(n,t=null){try{const e=n.split(".");if(e.length!==3)return!1;const[r]=e;if(!r)return!1;const i=JSON.parse(atob(r));return!("typ"in i&&(i==null?void 0:i.typ)!=="JWT"||!i.alg||t&&(!("alg"in i)||i.alg!==t))}catch{return!1}}const _T=A("$ZodJWT",(n,t)=>{he.init(n,t),n._zod.check=e=>{ST(e.value,t.alg)||e.issues.push({code:"invalid_format",format:"jwt",input:e.value,inst:n,continue:!t.abort})}}),iy=A("$ZodNumber",(n,t)=>{fe.init(n,t),n._zod.pattern=n._zod.bag.pattern??Qv,n._zod.parse=(e,r)=>{if(t.coerce)try{e.value=Number(e.value)}catch{}const i=e.value;if(typeof i=="number"&&!Number.isNaN(i)&&Number.isFinite(i))return e;const s=typeof i=="number"?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:"Infinity":void 0;return e.issues.push({expected:"number",code:"invalid_type",input:i,inst:n,...s?{received:s}:{}}),e}}),kT=A("$ZodNumberFormat",(n,t)=>{U$.init(n,t),iy.init(n,t)}),xT=A("$ZodBoolean",(n,t)=>{fe.init(n,t),n._zod.pattern=z$,n._zod.parse=(e,r)=>{if(t.coerce)try{e.value=!!e.value}catch{}const i=e.value;return typeof i=="boolean"||e.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:n}),e}}),ET=A("$ZodUnknown",(n,t)=>{fe.init(n,t),n._zod.parse=e=>e}),AT=A("$ZodNever",(n,t)=>{fe.init(n,t),n._zod.parse=(e,r)=>(e.issues.push({expected:"never",code:"invalid_type",input:e.value,inst:n}),e)});function Gf(n,t,e){n.issues.length&&t.issues.push(...vi(e,n.issues)),t.value[e]=n.value}const $T=A("$ZodArray",(n,t)=>{fe.init(n,t),n._zod.parse=(e,r)=>{const i=e.value;if(!Array.isArray(i))return e.issues.push({expected:"array",code:"invalid_type",input:i,inst:n}),e;e.value=Array(i.length);const s=[];for(let o=0;o<i.length;o++){const a=i[o],c=t.element._zod.run({value:a,issues:[]},r);c instanceof Promise?s.push(c.then(u=>Gf(u,e,o))):Gf(c,e,o)}return s.length?Promise.all(s).then(()=>e):e}});function hl(n,t,e,r,i){if(n.issues.length){if(i&&!(e in r))return;t.issues.push(...vi(e,n.issues))}n.value===void 0?e in r&&(t.value[e]=void 0):t.value[e]=n.value}function sy(n){var r,i,s,o;const t=Object.keys(n.shape);for(const a of t)if(!((o=(s=(i=(r=n.shape)==null?void 0:r[a])==null?void 0:i._zod)==null?void 0:s.traits)!=null&&o.has("$ZodType")))throw new Error(`Invalid element at key "${a}": expected a Zod schema`);const e=j1(n.shape);return{...n,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(e)}}function oy(n,t,e,r,i,s){const o=[],a=i.keySet,c=i.catchall._zod,u=c.def.type,h=c.optout==="optional";for(const p in t){if(a.has(p))continue;if(u==="never"){o.push(p);continue}const v=c.run({value:t[p],issues:[]},r);v instanceof Promise?n.push(v.then(m=>hl(m,e,p,t,h))):hl(v,e,p,t,h)}return o.length&&e.issues.push({code:"unrecognized_keys",keys:o,input:t,inst:s}),n.length?Promise.all(n).then(()=>e):e}const TT=A("$ZodObject",(n,t)=>{fe.init(n,t);const e=Object.getOwnPropertyDescriptor(t,"shape");if(!(e!=null&&e.get)){const a=t.shape;Object.defineProperty(t,"shape",{get:()=>{const c={...a};return Object.defineProperty(t,"shape",{value:c}),c}})}const r=ud(()=>sy(t));ne(n._zod,"propValues",()=>{const a=t.shape,c={};for(const u in a){const h=a[u]._zod;if(h.values){c[u]??(c[u]=new Set);for(const p of h.values)c[u].add(p)}}return c});const i=ul,s=t.catchall;let o;n._zod.parse=(a,c)=>{o??(o=r.value);const u=a.value;if(!i(u))return a.issues.push({expected:"object",code:"invalid_type",input:u,inst:n}),a;a.value={};const h=[],p=o.shape;for(const v of o.keys){const m=p[v],_=m._zod.optout==="optional",k=m._zod.run({value:u[v],issues:[]},c);k instanceof Promise?h.push(k.then(T=>hl(T,a,v,u,_))):hl(k,a,v,u,_)}return s?oy(h,u,a,c,r.value,n):h.length?Promise.all(h).then(()=>a):a}}),IT=A("$ZodObjectJIT",(n,t)=>{TT.init(n,t);const e=n._zod.parse,r=ud(()=>sy(t)),i=v=>{var W;const m=new X$(["shape","payload","ctx"]),_=r.value,k=N=>{const F=Bf(N);return`shape[${F}]._zod.run({ value: input[${F}], issues: [] }, ctx)`};m.write("const input = payload.value;");const T=Object.create(null);let P=0;for(const N of _.keys)T[N]=`key_${P++}`;m.write("const newResult = {};");for(const N of _.keys){const F=T[N],Y=Bf(N),j=v[N],oe=((W=j==null?void 0:j._zod)==null?void 0:W.optout)==="optional";m.write(`const ${F} = ${k(N)};`),oe?m.write(`
|
|
7
7
|
if (${F}.issues.length) {
|
|
8
8
|
if (${Y} in input) {
|
|
9
9
|
payload.issues = payload.issues.concat(${F}.issues.map(iss => ({
|
|
@@ -37,59 +37,59 @@ var Xw=Object.defineProperty;var rp=n=>{throw TypeError(n)};var Kw=(n,t,e)=>t in
|
|
|
37
37
|
newResult[${Y}] = ${F}.value;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
`)}m.write("payload.value = newResult;"),m.write("return payload;");const R=m.compile();return(N,F)=>R(v,N,F)};let s;const o=ol,a=!Nv.jitless,u=a&&N1.value,h=t.catchall;let p;n._zod.parse=(v,m)=>{p??(p=r.value);const _=v.value;return o(_)?a&&u&&(m==null?void 0:m.async)===!1&&m.jitless!==!0?(s||(s=i(t.shape)),v=s(v,m),h?ty([],_,v,m,p,n):v):e(v,m):(v.issues.push({expected:"object",code:"invalid_type",input:_,inst:n}),v)}});function Zf(n,t,e,r){for(const s of n)if(s.issues.length===0)return t.value=s.value,t;const i=n.filter(s=>!mi(s));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:e,errors:n.map(s=>s.issues.map(o=>Gn(o,r,jn())))}),t)}const ET=A("$ZodUnion",(n,t)=>{fe.init(n,t),ne(n._zod,"optin",()=>t.options.some(i=>i._zod.optin==="optional")?"optional":void 0),ne(n._zod,"optout",()=>t.options.some(i=>i._zod.optout==="optional")?"optional":void 0),ne(n._zod,"values",()=>{if(t.options.every(i=>i._zod.values))return new Set(t.options.flatMap(i=>Array.from(i._zod.values)))}),ne(n._zod,"pattern",()=>{if(t.options.every(i=>i._zod.pattern)){const i=t.options.map(s=>s._zod.pattern);return new RegExp(`^(${i.map(s=>ad(s.source)).join("|")})$`)}});const e=t.options.length===1,r=t.options[0]._zod.run;n._zod.parse=(i,s)=>{if(e)return r(i,s);let o=!1;const a=[];for(const c of t.options){const u=c._zod.run({value:i.value,issues:[]},s);if(u instanceof Promise)a.push(u),o=!0;else{if(u.issues.length===0)return u;a.push(u)}}return o?Promise.all(a).then(c=>Zf(c,i,n,s)):Zf(a,i,n,s)}}),xT=A("$ZodIntersection",(n,t)=>{fe.init(n,t),n._zod.parse=(e,r)=>{const i=e.value,s=t.left._zod.run({value:i,issues:[]},r),o=t.right._zod.run({value:i,issues:[]},r);return s instanceof Promise||o instanceof Promise?Promise.all([s,o]).then(([c,u])=>Vf(e,c,u)):Vf(e,s,o)}});function Cu(n,t){if(n===t)return{valid:!0,data:n};if(n instanceof Date&&t instanceof Date&&+n==+t)return{valid:!0,data:n};if(ji(n)&&ji(t)){const e=Object.keys(t),r=Object.keys(n).filter(s=>e.indexOf(s)!==-1),i={...n,...t};for(const s of r){const o=Cu(n[s],t[s]);if(!o.valid)return{valid:!1,mergeErrorPath:[s,...o.mergeErrorPath]};i[s]=o.data}return{valid:!0,data:i}}if(Array.isArray(n)&&Array.isArray(t)){if(n.length!==t.length)return{valid:!1,mergeErrorPath:[]};const e=[];for(let r=0;r<n.length;r++){const i=n[r],s=t[r],o=Cu(i,s);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};e.push(o.data)}return{valid:!0,data:e}}return{valid:!1,mergeErrorPath:[]}}function Vf(n,t,e){const r=new Map;let i;for(const a of t.issues)if(a.code==="unrecognized_keys"){i??(i=a);for(const c of a.keys)r.has(c)||r.set(c,{}),r.get(c).l=!0}else n.issues.push(a);for(const a of e.issues)if(a.code==="unrecognized_keys")for(const c of a.keys)r.has(c)||r.set(c,{}),r.get(c).r=!0;else n.issues.push(a);const s=[...r].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(s.length&&i&&n.issues.push({...i,keys:s}),mi(n))return n;const o=Cu(t.value,e.value);if(!o.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return n.value=o.data,n}const AT=A("$ZodRecord",(n,t)=>{fe.init(n,t),n._zod.parse=(e,r)=>{const i=e.value;if(!ji(i))return e.issues.push({expected:"record",code:"invalid_type",input:i,inst:n}),e;const s=[],o=t.keyType._zod.values;if(o){e.value={};const a=new Set;for(const u of o)if(typeof u=="string"||typeof u=="number"||typeof u=="symbol"){a.add(typeof u=="number"?u.toString():u);const h=t.valueType._zod.run({value:i[u],issues:[]},r);h instanceof Promise?s.push(h.then(p=>{p.issues.length&&e.issues.push(...vi(u,p.issues)),e.value[u]=p.value})):(h.issues.length&&e.issues.push(...vi(u,h.issues)),e.value[u]=h.value)}let c;for(const u in i)a.has(u)||(c=c??[],c.push(u));c&&c.length>0&&e.issues.push({code:"unrecognized_keys",input:i,inst:n,keys:c})}else{e.value={};for(const a of Reflect.ownKeys(i)){if(a==="__proto__")continue;let c=t.keyType._zod.run({value:a,issues:[]},r);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof a=="string"&&qv.test(a)&&c.issues.length){const p=t.keyType._zod.run({value:Number(a),issues:[]},r);if(p instanceof Promise)throw new Error("Async schemas not supported in object keys currently");p.issues.length===0&&(c=p)}if(c.issues.length){t.mode==="loose"?e.value[a]=i[a]:e.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(p=>Gn(p,r,jn())),input:a,path:[a],inst:n});continue}const h=t.valueType._zod.run({value:i[a],issues:[]},r);h instanceof Promise?s.push(h.then(p=>{p.issues.length&&e.issues.push(...vi(a,p.issues)),e.value[c.value]=p.value})):(h.issues.length&&e.issues.push(...vi(a,h.issues)),e.value[c.value]=h.value)}}return s.length?Promise.all(s).then(()=>e):e}}),$T=A("$ZodEnum",(n,t)=>{fe.init(n,t);const e=Uv(t.entries),r=new Set(e);n._zod.values=r,n._zod.pattern=new RegExp(`^(${e.filter(i=>U1.has(typeof i)).map(i=>typeof i=="string"?Gi(i):i.toString()).join("|")})$`),n._zod.parse=(i,s)=>{const o=i.value;return r.has(o)||i.issues.push({code:"invalid_value",values:e,input:o,inst:n}),i}}),TT=A("$ZodLiteral",(n,t)=>{if(fe.init(n,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");const e=new Set(t.values);n._zod.values=e,n._zod.pattern=new RegExp(`^(${t.values.map(r=>typeof r=="string"?Gi(r):r?Gi(r.toString()):String(r)).join("|")})$`),n._zod.parse=(r,i)=>{const s=r.value;return e.has(s)||r.issues.push({code:"invalid_value",values:t.values,input:s,inst:n}),r}}),IT=A("$ZodTransform",(n,t)=>{fe.init(n,t),n._zod.parse=(e,r)=>{if(r.direction==="backward")throw new Mv(n.constructor.name);const i=t.transform(e.value,e);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(o=>(e.value=o,e));if(i instanceof Promise)throw new bi;return e.value=i,e}});function Bf(n,t){return n.issues.length&&t===void 0?{issues:[],value:void 0}:n}const ny=A("$ZodOptional",(n,t)=>{fe.init(n,t),n._zod.optin="optional",n._zod.optout="optional",ne(n._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),ne(n._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${ad(e.source)})?$`):void 0}),n._zod.parse=(e,r)=>{if(t.innerType._zod.optin==="optional"){const i=t.innerType._zod.run(e,r);return i instanceof Promise?i.then(s=>Bf(s,e.value)):Bf(i,e.value)}return e.value===void 0?e:t.innerType._zod.run(e,r)}}),CT=A("$ZodExactOptional",(n,t)=>{ny.init(n,t),ne(n._zod,"values",()=>t.innerType._zod.values),ne(n._zod,"pattern",()=>t.innerType._zod.pattern),n._zod.parse=(e,r)=>t.innerType._zod.run(e,r)}),RT=A("$ZodNullable",(n,t)=>{fe.init(n,t),ne(n._zod,"optin",()=>t.innerType._zod.optin),ne(n._zod,"optout",()=>t.innerType._zod.optout),ne(n._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${ad(e.source)}|null)$`):void 0}),ne(n._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),n._zod.parse=(e,r)=>e.value===null?e:t.innerType._zod.run(e,r)}),PT=A("$ZodDefault",(n,t)=>{fe.init(n,t),n._zod.optin="optional",ne(n._zod,"values",()=>t.innerType._zod.values),n._zod.parse=(e,r)=>{if(r.direction==="backward")return t.innerType._zod.run(e,r);if(e.value===void 0)return e.value=t.defaultValue,e;const i=t.innerType._zod.run(e,r);return i instanceof Promise?i.then(s=>jf(s,t)):jf(i,t)}});function jf(n,t){return n.value===void 0&&(n.value=t.defaultValue),n}const DT=A("$ZodPrefault",(n,t)=>{fe.init(n,t),n._zod.optin="optional",ne(n._zod,"values",()=>t.innerType._zod.values),n._zod.parse=(e,r)=>(r.direction==="backward"||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,r))}),LT=A("$ZodNonOptional",(n,t)=>{fe.init(n,t),ne(n._zod,"values",()=>{const e=t.innerType._zod.values;return e?new Set([...e].filter(r=>r!==void 0)):void 0}),n._zod.parse=(e,r)=>{const i=t.innerType._zod.run(e,r);return i instanceof Promise?i.then(s=>Gf(s,n)):Gf(i,n)}});function Gf(n,t){return!n.issues.length&&n.value===void 0&&n.issues.push({code:"invalid_type",expected:"nonoptional",input:n.value,inst:t}),n}const zT=A("$ZodCatch",(n,t)=>{fe.init(n,t),ne(n._zod,"optin",()=>t.innerType._zod.optin),ne(n._zod,"optout",()=>t.innerType._zod.optout),ne(n._zod,"values",()=>t.innerType._zod.values),n._zod.parse=(e,r)=>{if(r.direction==="backward")return t.innerType._zod.run(e,r);const i=t.innerType._zod.run(e,r);return i instanceof Promise?i.then(s=>(e.value=s.value,s.issues.length&&(e.value=t.catchValue({...e,error:{issues:s.issues.map(o=>Gn(o,r,jn()))},input:e.value}),e.issues=[]),e)):(e.value=i.value,i.issues.length&&(e.value=t.catchValue({...e,error:{issues:i.issues.map(s=>Gn(s,r,jn()))},input:e.value}),e.issues=[]),e)}}),OT=A("$ZodPipe",(n,t)=>{fe.init(n,t),ne(n._zod,"values",()=>t.in._zod.values),ne(n._zod,"optin",()=>t.in._zod.optin),ne(n._zod,"optout",()=>t.out._zod.optout),ne(n._zod,"propValues",()=>t.in._zod.propValues),n._zod.parse=(e,r)=>{if(r.direction==="backward"){const s=t.out._zod.run(e,r);return s instanceof Promise?s.then(o=>ma(o,t.in,r)):ma(s,t.in,r)}const i=t.in._zod.run(e,r);return i instanceof Promise?i.then(s=>ma(s,t.out,r)):ma(i,t.out,r)}});function ma(n,t,e){return n.issues.length?(n.aborted=!0,n):t._zod.run({value:n.value,issues:n.issues},e)}const MT=A("$ZodReadonly",(n,t)=>{fe.init(n,t),ne(n._zod,"propValues",()=>t.innerType._zod.propValues),ne(n._zod,"values",()=>t.innerType._zod.values),ne(n._zod,"optin",()=>{var e,r;return(r=(e=t.innerType)==null?void 0:e._zod)==null?void 0:r.optin}),ne(n._zod,"optout",()=>{var e,r;return(r=(e=t.innerType)==null?void 0:e._zod)==null?void 0:r.optout}),n._zod.parse=(e,r)=>{if(r.direction==="backward")return t.innerType._zod.run(e,r);const i=t.innerType._zod.run(e,r);return i instanceof Promise?i.then(qf):qf(i)}});function qf(n){return n.value=Object.freeze(n.value),n}const NT=A("$ZodCustom",(n,t)=>{it.init(n,t),fe.init(n,t),n._zod.parse=(e,r)=>e,n._zod.check=e=>{const r=e.value,i=t.fn(r);if(i instanceof Promise)return i.then(s=>Yf(s,e,r,n));Yf(i,e,r,n)}});function Yf(n,t,e,r){if(!n){const i={code:"custom",input:e,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(i.params=r._zod.def.params),t.issues.push(Hs(i))}}var Xf;class UT{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...e){const r=e[0];return this._map.set(t,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const e=this._map.get(t);return e&&typeof e=="object"&&"id"in e&&this._idmap.delete(e.id),this._map.delete(t),this}get(t){const e=t._zod.parent;if(e){const r={...this.get(e)??{}};delete r.id;const i={...r,...this._map.get(t)};return Object.keys(i).length?i:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function FT(){return new UT}(Xf=globalThis).__zod_globalRegistry??(Xf.__zod_globalRegistry=FT());const Es=globalThis.__zod_globalRegistry;function HT(n,t){return new n({type:"string",...M(t)})}function WT(n,t){return new n({type:"string",format:"email",check:"string_format",abort:!1,...M(t)})}function Kf(n,t){return new n({type:"string",format:"guid",check:"string_format",abort:!1,...M(t)})}function ZT(n,t){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,...M(t)})}function VT(n,t){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...M(t)})}function BT(n,t){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...M(t)})}function jT(n,t){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...M(t)})}function GT(n,t){return new n({type:"string",format:"url",check:"string_format",abort:!1,...M(t)})}function qT(n,t){return new n({type:"string",format:"emoji",check:"string_format",abort:!1,...M(t)})}function YT(n,t){return new n({type:"string",format:"nanoid",check:"string_format",abort:!1,...M(t)})}function XT(n,t){return new n({type:"string",format:"cuid",check:"string_format",abort:!1,...M(t)})}function KT(n,t){return new n({type:"string",format:"cuid2",check:"string_format",abort:!1,...M(t)})}function JT(n,t){return new n({type:"string",format:"ulid",check:"string_format",abort:!1,...M(t)})}function QT(n,t){return new n({type:"string",format:"xid",check:"string_format",abort:!1,...M(t)})}function eI(n,t){return new n({type:"string",format:"ksuid",check:"string_format",abort:!1,...M(t)})}function tI(n,t){return new n({type:"string",format:"ipv4",check:"string_format",abort:!1,...M(t)})}function nI(n,t){return new n({type:"string",format:"ipv6",check:"string_format",abort:!1,...M(t)})}function rI(n,t){return new n({type:"string",format:"cidrv4",check:"string_format",abort:!1,...M(t)})}function iI(n,t){return new n({type:"string",format:"cidrv6",check:"string_format",abort:!1,...M(t)})}function sI(n,t){return new n({type:"string",format:"base64",check:"string_format",abort:!1,...M(t)})}function oI(n,t){return new n({type:"string",format:"base64url",check:"string_format",abort:!1,...M(t)})}function aI(n,t){return new n({type:"string",format:"e164",check:"string_format",abort:!1,...M(t)})}function lI(n,t){return new n({type:"string",format:"jwt",check:"string_format",abort:!1,...M(t)})}function cI(n,t){return new n({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...M(t)})}function uI(n,t){return new n({type:"string",format:"date",check:"string_format",...M(t)})}function hI(n,t){return new n({type:"string",format:"time",check:"string_format",precision:null,...M(t)})}function dI(n,t){return new n({type:"string",format:"duration",check:"string_format",...M(t)})}function pI(n,t){return new n({type:"number",checks:[],...M(t)})}function fI(n,t){return new n({type:"number",check:"number_format",abort:!1,format:"safeint",...M(t)})}function gI(n,t){return new n({type:"boolean",...M(t)})}function mI(n){return new n({type:"unknown"})}function vI(n,t){return new n({type:"never",...M(t)})}function Jf(n,t){return new Xv({check:"less_than",...M(t),value:n,inclusive:!1})}function Vc(n,t){return new Xv({check:"less_than",...M(t),value:n,inclusive:!0})}function Qf(n,t){return new Kv({check:"greater_than",...M(t),value:n,inclusive:!1})}function Bc(n,t){return new Kv({check:"greater_than",...M(t),value:n,inclusive:!0})}function eg(n,t){return new P$({check:"multiple_of",...M(t),value:n})}function ry(n,t){return new L$({check:"max_length",...M(t),maximum:n})}function ll(n,t){return new z$({check:"min_length",...M(t),minimum:n})}function iy(n,t){return new O$({check:"length_equals",...M(t),length:n})}function yI(n,t){return new M$({check:"string_format",format:"regex",...M(t),pattern:n})}function bI(n){return new N$({check:"string_format",format:"lowercase",...M(n)})}function wI(n){return new U$({check:"string_format",format:"uppercase",...M(n)})}function SI(n,t){return new F$({check:"string_format",format:"includes",...M(t),includes:n})}function _I(n,t){return new H$({check:"string_format",format:"starts_with",...M(t),prefix:n})}function kI(n,t){return new W$({check:"string_format",format:"ends_with",...M(t),suffix:n})}function is(n){return new Z$({check:"overwrite",tx:n})}function EI(n){return is(t=>t.normalize(n))}function xI(){return is(n=>n.trim())}function AI(){return is(n=>n.toLowerCase())}function $I(){return is(n=>n.toUpperCase())}function TI(){return is(n=>M1(n))}function II(n,t,e){return new n({type:"array",element:t,...M(e)})}function CI(n,t,e){return new n({type:"custom",check:"custom",fn:t,...M(e)})}function RI(n){const t=PI(e=>(e.addIssue=r=>{if(typeof r=="string")e.issues.push(Hs(r,e.value,t._zod.def));else{const i=r;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=e.value),i.inst??(i.inst=t),i.continue??(i.continue=!t._zod.def.abort),e.issues.push(Hs(i))}},n(e.value,e)));return t}function PI(n,t){const e=new it({check:"custom",...M(t)});return e._zod.check=n,e}function sy(n){let t=(n==null?void 0:n.target)??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:n.processors??{},metadataRegistry:(n==null?void 0:n.metadata)??Es,target:t,unrepresentable:(n==null?void 0:n.unrepresentable)??"throw",override:(n==null?void 0:n.override)??(()=>{}),io:(n==null?void 0:n.io)??"output",counter:0,seen:new Map,cycles:(n==null?void 0:n.cycles)??"ref",reused:(n==null?void 0:n.reused)??"inline",external:(n==null?void 0:n.external)??void 0}}function Se(n,t,e={path:[],schemaPath:[]}){var h,p;var r;const i=n._zod.def,s=t.seen.get(n);if(s)return s.count++,e.schemaPath.includes(n)&&(s.cycle=e.path),s.schema;const o={schema:{},count:1,cycle:void 0,path:e.path};t.seen.set(n,o);const a=(p=(h=n._zod).toJSONSchema)==null?void 0:p.call(h);if(a)o.schema=a;else{const v={...e,schemaPath:[...e.schemaPath,n],path:e.path};if(n._zod.processJSONSchema)n._zod.processJSONSchema(t,o.schema,v);else{const _=o.schema,k=t.processors[i.type];if(!k)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);k(n,t,_,v)}const m=n._zod.parent;m&&(o.ref||(o.ref=m),Se(m,t,v),t.seen.get(m).isParent=!0)}const c=t.metadataRegistry.get(n);return c&&Object.assign(o.schema,c),t.io==="input"&&Ze(n)&&(delete o.schema.examples,delete o.schema.default),t.io==="input"&&o.schema._prefault&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(n).schema}function oy(n,t){var o,a,c,u;const e=n.seen.get(t);if(!e)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=new Map;for(const h of n.seen.entries()){const p=(o=n.metadataRegistry.get(h[0]))==null?void 0:o.id;if(p){const v=r.get(p);if(v&&v!==h[0])throw new Error(`Duplicate schema id "${p}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(p,h[0])}}const i=h=>{var k;const p=n.target==="draft-2020-12"?"$defs":"definitions";if(n.external){const T=(k=n.external.registry.get(h[0]))==null?void 0:k.id,P=n.external.uri??(W=>W);if(T)return{ref:P(T)};const R=h[1].defId??h[1].schema.id??`schema${n.counter++}`;return h[1].defId=R,{defId:R,ref:`${P("__shared")}#/${p}/${R}`}}if(h[1]===e)return{ref:"#"};const m=`#/${p}/`,_=h[1].schema.id??`__schema${n.counter++}`;return{defId:_,ref:m+_}},s=h=>{if(h[1].schema.$ref)return;const p=h[1],{ref:v,defId:m}=i(h);p.def={...p.schema},m&&(p.defId=m);const _=p.schema;for(const k in _)delete _[k];_.$ref=v};if(n.cycles==="throw")for(const h of n.seen.entries()){const p=h[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 R=m.compile();return(N,F)=>R(v,N,F)};let s;const o=ul,a=!Zv.jitless,u=a&&V1.value,h=t.catchall;let p;n._zod.parse=(v,m)=>{p??(p=r.value);const _=v.value;return o(_)?a&&u&&(m==null?void 0:m.async)===!1&&m.jitless!==!0?(s||(s=i(t.shape)),v=s(v,m),h?oy([],_,v,m,p,n):v):e(v,m):(v.issues.push({expected:"object",code:"invalid_type",input:_,inst:n}),v)}});function qf(n,t,e,r){for(const s of n)if(s.issues.length===0)return t.value=s.value,t;const i=n.filter(s=>!mi(s));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:e,errors:n.map(s=>s.issues.map(o=>Gn(o,r,jn())))}),t)}const CT=A("$ZodUnion",(n,t)=>{fe.init(n,t),ne(n._zod,"optin",()=>t.options.some(i=>i._zod.optin==="optional")?"optional":void 0),ne(n._zod,"optout",()=>t.options.some(i=>i._zod.optout==="optional")?"optional":void 0),ne(n._zod,"values",()=>{if(t.options.every(i=>i._zod.values))return new Set(t.options.flatMap(i=>Array.from(i._zod.values)))}),ne(n._zod,"pattern",()=>{if(t.options.every(i=>i._zod.pattern)){const i=t.options.map(s=>s._zod.pattern);return new RegExp(`^(${i.map(s=>dd(s.source)).join("|")})$`)}});const e=t.options.length===1,r=t.options[0]._zod.run;n._zod.parse=(i,s)=>{if(e)return r(i,s);let o=!1;const a=[];for(const c of t.options){const u=c._zod.run({value:i.value,issues:[]},s);if(u instanceof Promise)a.push(u),o=!0;else{if(u.issues.length===0)return u;a.push(u)}}return o?Promise.all(a).then(c=>qf(c,i,n,s)):qf(a,i,n,s)}}),RT=A("$ZodIntersection",(n,t)=>{fe.init(n,t),n._zod.parse=(e,r)=>{const i=e.value,s=t.left._zod.run({value:i,issues:[]},r),o=t.right._zod.run({value:i,issues:[]},r);return s instanceof Promise||o instanceof Promise?Promise.all([s,o]).then(([c,u])=>Yf(e,c,u)):Yf(e,s,o)}});function Lu(n,t){if(n===t)return{valid:!0,data:n};if(n instanceof Date&&t instanceof Date&&+n==+t)return{valid:!0,data:n};if(Gi(n)&&Gi(t)){const e=Object.keys(t),r=Object.keys(n).filter(s=>e.indexOf(s)!==-1),i={...n,...t};for(const s of r){const o=Lu(n[s],t[s]);if(!o.valid)return{valid:!1,mergeErrorPath:[s,...o.mergeErrorPath]};i[s]=o.data}return{valid:!0,data:i}}if(Array.isArray(n)&&Array.isArray(t)){if(n.length!==t.length)return{valid:!1,mergeErrorPath:[]};const e=[];for(let r=0;r<n.length;r++){const i=n[r],s=t[r],o=Lu(i,s);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};e.push(o.data)}return{valid:!0,data:e}}return{valid:!1,mergeErrorPath:[]}}function Yf(n,t,e){const r=new Map;let i;for(const a of t.issues)if(a.code==="unrecognized_keys"){i??(i=a);for(const c of a.keys)r.has(c)||r.set(c,{}),r.get(c).l=!0}else n.issues.push(a);for(const a of e.issues)if(a.code==="unrecognized_keys")for(const c of a.keys)r.has(c)||r.set(c,{}),r.get(c).r=!0;else n.issues.push(a);const s=[...r].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(s.length&&i&&n.issues.push({...i,keys:s}),mi(n))return n;const o=Lu(t.value,e.value);if(!o.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return n.value=o.data,n}const PT=A("$ZodRecord",(n,t)=>{fe.init(n,t),n._zod.parse=(e,r)=>{const i=e.value;if(!Gi(i))return e.issues.push({expected:"record",code:"invalid_type",input:i,inst:n}),e;const s=[],o=t.keyType._zod.values;if(o){e.value={};const a=new Set;for(const u of o)if(typeof u=="string"||typeof u=="number"||typeof u=="symbol"){a.add(typeof u=="number"?u.toString():u);const h=t.valueType._zod.run({value:i[u],issues:[]},r);h instanceof Promise?s.push(h.then(p=>{p.issues.length&&e.issues.push(...vi(u,p.issues)),e.value[u]=p.value})):(h.issues.length&&e.issues.push(...vi(u,h.issues)),e.value[u]=h.value)}let c;for(const u in i)a.has(u)||(c=c??[],c.push(u));c&&c.length>0&&e.issues.push({code:"unrecognized_keys",input:i,inst:n,keys:c})}else{e.value={};for(const a of Reflect.ownKeys(i)){if(a==="__proto__")continue;let c=t.keyType._zod.run({value:a,issues:[]},r);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof a=="string"&&Qv.test(a)&&c.issues.length){const p=t.keyType._zod.run({value:Number(a),issues:[]},r);if(p instanceof Promise)throw new Error("Async schemas not supported in object keys currently");p.issues.length===0&&(c=p)}if(c.issues.length){t.mode==="loose"?e.value[a]=i[a]:e.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(p=>Gn(p,r,jn())),input:a,path:[a],inst:n});continue}const h=t.valueType._zod.run({value:i[a],issues:[]},r);h instanceof Promise?s.push(h.then(p=>{p.issues.length&&e.issues.push(...vi(a,p.issues)),e.value[c.value]=p.value})):(h.issues.length&&e.issues.push(...vi(a,h.issues)),e.value[c.value]=h.value)}}return s.length?Promise.all(s).then(()=>e):e}}),DT=A("$ZodEnum",(n,t)=>{fe.init(n,t);const e=Vv(t.entries),r=new Set(e);n._zod.values=r,n._zod.pattern=new RegExp(`^(${e.filter(i=>B1.has(typeof i)).map(i=>typeof i=="string"?qi(i):i.toString()).join("|")})$`),n._zod.parse=(i,s)=>{const o=i.value;return r.has(o)||i.issues.push({code:"invalid_value",values:e,input:o,inst:n}),i}}),LT=A("$ZodLiteral",(n,t)=>{if(fe.init(n,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");const e=new Set(t.values);n._zod.values=e,n._zod.pattern=new RegExp(`^(${t.values.map(r=>typeof r=="string"?qi(r):r?qi(r.toString()):String(r)).join("|")})$`),n._zod.parse=(r,i)=>{const s=r.value;return e.has(s)||r.issues.push({code:"invalid_value",values:t.values,input:s,inst:n}),r}}),zT=A("$ZodTransform",(n,t)=>{fe.init(n,t),n._zod.parse=(e,r)=>{if(r.direction==="backward")throw new Wv(n.constructor.name);const i=t.transform(e.value,e);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(o=>(e.value=o,e));if(i instanceof Promise)throw new bi;return e.value=i,e}});function Xf(n,t){return n.issues.length&&t===void 0?{issues:[],value:void 0}:n}const ay=A("$ZodOptional",(n,t)=>{fe.init(n,t),n._zod.optin="optional",n._zod.optout="optional",ne(n._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),ne(n._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${dd(e.source)})?$`):void 0}),n._zod.parse=(e,r)=>{if(t.innerType._zod.optin==="optional"){const i=t.innerType._zod.run(e,r);return i instanceof Promise?i.then(s=>Xf(s,e.value)):Xf(i,e.value)}return e.value===void 0?e:t.innerType._zod.run(e,r)}}),OT=A("$ZodExactOptional",(n,t)=>{ay.init(n,t),ne(n._zod,"values",()=>t.innerType._zod.values),ne(n._zod,"pattern",()=>t.innerType._zod.pattern),n._zod.parse=(e,r)=>t.innerType._zod.run(e,r)}),MT=A("$ZodNullable",(n,t)=>{fe.init(n,t),ne(n._zod,"optin",()=>t.innerType._zod.optin),ne(n._zod,"optout",()=>t.innerType._zod.optout),ne(n._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${dd(e.source)}|null)$`):void 0}),ne(n._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),n._zod.parse=(e,r)=>e.value===null?e:t.innerType._zod.run(e,r)}),NT=A("$ZodDefault",(n,t)=>{fe.init(n,t),n._zod.optin="optional",ne(n._zod,"values",()=>t.innerType._zod.values),n._zod.parse=(e,r)=>{if(r.direction==="backward")return t.innerType._zod.run(e,r);if(e.value===void 0)return e.value=t.defaultValue,e;const i=t.innerType._zod.run(e,r);return i instanceof Promise?i.then(s=>Kf(s,t)):Kf(i,t)}});function Kf(n,t){return n.value===void 0&&(n.value=t.defaultValue),n}const UT=A("$ZodPrefault",(n,t)=>{fe.init(n,t),n._zod.optin="optional",ne(n._zod,"values",()=>t.innerType._zod.values),n._zod.parse=(e,r)=>(r.direction==="backward"||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,r))}),FT=A("$ZodNonOptional",(n,t)=>{fe.init(n,t),ne(n._zod,"values",()=>{const e=t.innerType._zod.values;return e?new Set([...e].filter(r=>r!==void 0)):void 0}),n._zod.parse=(e,r)=>{const i=t.innerType._zod.run(e,r);return i instanceof Promise?i.then(s=>Jf(s,n)):Jf(i,n)}});function Jf(n,t){return!n.issues.length&&n.value===void 0&&n.issues.push({code:"invalid_type",expected:"nonoptional",input:n.value,inst:t}),n}const HT=A("$ZodCatch",(n,t)=>{fe.init(n,t),ne(n._zod,"optin",()=>t.innerType._zod.optin),ne(n._zod,"optout",()=>t.innerType._zod.optout),ne(n._zod,"values",()=>t.innerType._zod.values),n._zod.parse=(e,r)=>{if(r.direction==="backward")return t.innerType._zod.run(e,r);const i=t.innerType._zod.run(e,r);return i instanceof Promise?i.then(s=>(e.value=s.value,s.issues.length&&(e.value=t.catchValue({...e,error:{issues:s.issues.map(o=>Gn(o,r,jn()))},input:e.value}),e.issues=[]),e)):(e.value=i.value,i.issues.length&&(e.value=t.catchValue({...e,error:{issues:i.issues.map(s=>Gn(s,r,jn()))},input:e.value}),e.issues=[]),e)}}),WT=A("$ZodPipe",(n,t)=>{fe.init(n,t),ne(n._zod,"values",()=>t.in._zod.values),ne(n._zod,"optin",()=>t.in._zod.optin),ne(n._zod,"optout",()=>t.out._zod.optout),ne(n._zod,"propValues",()=>t.in._zod.propValues),n._zod.parse=(e,r)=>{if(r.direction==="backward"){const s=t.out._zod.run(e,r);return s instanceof Promise?s.then(o=>wa(o,t.in,r)):wa(s,t.in,r)}const i=t.in._zod.run(e,r);return i instanceof Promise?i.then(s=>wa(s,t.out,r)):wa(i,t.out,r)}});function wa(n,t,e){return n.issues.length?(n.aborted=!0,n):t._zod.run({value:n.value,issues:n.issues},e)}const ZT=A("$ZodReadonly",(n,t)=>{fe.init(n,t),ne(n._zod,"propValues",()=>t.innerType._zod.propValues),ne(n._zod,"values",()=>t.innerType._zod.values),ne(n._zod,"optin",()=>{var e,r;return(r=(e=t.innerType)==null?void 0:e._zod)==null?void 0:r.optin}),ne(n._zod,"optout",()=>{var e,r;return(r=(e=t.innerType)==null?void 0:e._zod)==null?void 0:r.optout}),n._zod.parse=(e,r)=>{if(r.direction==="backward")return t.innerType._zod.run(e,r);const i=t.innerType._zod.run(e,r);return i instanceof Promise?i.then(Qf):Qf(i)}});function Qf(n){return n.value=Object.freeze(n.value),n}const VT=A("$ZodCustom",(n,t)=>{it.init(n,t),fe.init(n,t),n._zod.parse=(e,r)=>e,n._zod.check=e=>{const r=e.value,i=t.fn(r);if(i instanceof Promise)return i.then(s=>eg(s,e,r,n));eg(i,e,r,n)}});function eg(n,t,e,r){if(!n){const i={code:"custom",input:e,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(i.params=r._zod.def.params),t.issues.push(Ws(i))}}var tg;class BT{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...e){const r=e[0];return this._map.set(t,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const e=this._map.get(t);return e&&typeof e=="object"&&"id"in e&&this._idmap.delete(e.id),this._map.delete(t),this}get(t){const e=t._zod.parent;if(e){const r={...this.get(e)??{}};delete r.id;const i={...r,...this._map.get(t)};return Object.keys(i).length?i:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function jT(){return new BT}(tg=globalThis).__zod_globalRegistry??(tg.__zod_globalRegistry=jT());const Es=globalThis.__zod_globalRegistry;function GT(n,t){return new n({type:"string",...M(t)})}function qT(n,t){return new n({type:"string",format:"email",check:"string_format",abort:!1,...M(t)})}function ng(n,t){return new n({type:"string",format:"guid",check:"string_format",abort:!1,...M(t)})}function YT(n,t){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,...M(t)})}function XT(n,t){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...M(t)})}function KT(n,t){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...M(t)})}function JT(n,t){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...M(t)})}function QT(n,t){return new n({type:"string",format:"url",check:"string_format",abort:!1,...M(t)})}function eI(n,t){return new n({type:"string",format:"emoji",check:"string_format",abort:!1,...M(t)})}function tI(n,t){return new n({type:"string",format:"nanoid",check:"string_format",abort:!1,...M(t)})}function nI(n,t){return new n({type:"string",format:"cuid",check:"string_format",abort:!1,...M(t)})}function rI(n,t){return new n({type:"string",format:"cuid2",check:"string_format",abort:!1,...M(t)})}function iI(n,t){return new n({type:"string",format:"ulid",check:"string_format",abort:!1,...M(t)})}function sI(n,t){return new n({type:"string",format:"xid",check:"string_format",abort:!1,...M(t)})}function oI(n,t){return new n({type:"string",format:"ksuid",check:"string_format",abort:!1,...M(t)})}function aI(n,t){return new n({type:"string",format:"ipv4",check:"string_format",abort:!1,...M(t)})}function lI(n,t){return new n({type:"string",format:"ipv6",check:"string_format",abort:!1,...M(t)})}function cI(n,t){return new n({type:"string",format:"cidrv4",check:"string_format",abort:!1,...M(t)})}function uI(n,t){return new n({type:"string",format:"cidrv6",check:"string_format",abort:!1,...M(t)})}function hI(n,t){return new n({type:"string",format:"base64",check:"string_format",abort:!1,...M(t)})}function dI(n,t){return new n({type:"string",format:"base64url",check:"string_format",abort:!1,...M(t)})}function pI(n,t){return new n({type:"string",format:"e164",check:"string_format",abort:!1,...M(t)})}function fI(n,t){return new n({type:"string",format:"jwt",check:"string_format",abort:!1,...M(t)})}function gI(n,t){return new n({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...M(t)})}function mI(n,t){return new n({type:"string",format:"date",check:"string_format",...M(t)})}function vI(n,t){return new n({type:"string",format:"time",check:"string_format",precision:null,...M(t)})}function yI(n,t){return new n({type:"string",format:"duration",check:"string_format",...M(t)})}function bI(n,t){return new n({type:"number",checks:[],...M(t)})}function wI(n,t){return new n({type:"number",check:"number_format",abort:!1,format:"safeint",...M(t)})}function SI(n,t){return new n({type:"boolean",...M(t)})}function _I(n){return new n({type:"unknown"})}function kI(n,t){return new n({type:"never",...M(t)})}function rg(n,t){return new ty({check:"less_than",...M(t),value:n,inclusive:!1})}function qc(n,t){return new ty({check:"less_than",...M(t),value:n,inclusive:!0})}function ig(n,t){return new ny({check:"greater_than",...M(t),value:n,inclusive:!1})}function Yc(n,t){return new ny({check:"greater_than",...M(t),value:n,inclusive:!0})}function sg(n,t){return new N$({check:"multiple_of",...M(t),value:n})}function ly(n,t){return new F$({check:"max_length",...M(t),maximum:n})}function dl(n,t){return new H$({check:"min_length",...M(t),minimum:n})}function cy(n,t){return new W$({check:"length_equals",...M(t),length:n})}function xI(n,t){return new Z$({check:"string_format",format:"regex",...M(t),pattern:n})}function EI(n){return new V$({check:"string_format",format:"lowercase",...M(n)})}function AI(n){return new B$({check:"string_format",format:"uppercase",...M(n)})}function $I(n,t){return new j$({check:"string_format",format:"includes",...M(t),includes:n})}function TI(n,t){return new G$({check:"string_format",format:"starts_with",...M(t),prefix:n})}function II(n,t){return new q$({check:"string_format",format:"ends_with",...M(t),suffix:n})}function ss(n){return new Y$({check:"overwrite",tx:n})}function CI(n){return ss(t=>t.normalize(n))}function RI(){return ss(n=>n.trim())}function PI(){return ss(n=>n.toLowerCase())}function DI(){return ss(n=>n.toUpperCase())}function LI(){return ss(n=>Z1(n))}function zI(n,t,e){return new n({type:"array",element:t,...M(e)})}function OI(n,t,e){return new n({type:"custom",check:"custom",fn:t,...M(e)})}function MI(n){const t=NI(e=>(e.addIssue=r=>{if(typeof r=="string")e.issues.push(Ws(r,e.value,t._zod.def));else{const i=r;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=e.value),i.inst??(i.inst=t),i.continue??(i.continue=!t._zod.def.abort),e.issues.push(Ws(i))}},n(e.value,e)));return t}function NI(n,t){const e=new it({check:"custom",...M(t)});return e._zod.check=n,e}function uy(n){let t=(n==null?void 0:n.target)??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:n.processors??{},metadataRegistry:(n==null?void 0:n.metadata)??Es,target:t,unrepresentable:(n==null?void 0:n.unrepresentable)??"throw",override:(n==null?void 0:n.override)??(()=>{}),io:(n==null?void 0:n.io)??"output",counter:0,seen:new Map,cycles:(n==null?void 0:n.cycles)??"ref",reused:(n==null?void 0:n.reused)??"inline",external:(n==null?void 0:n.external)??void 0}}function Se(n,t,e={path:[],schemaPath:[]}){var h,p;var r;const i=n._zod.def,s=t.seen.get(n);if(s)return s.count++,e.schemaPath.includes(n)&&(s.cycle=e.path),s.schema;const o={schema:{},count:1,cycle:void 0,path:e.path};t.seen.set(n,o);const a=(p=(h=n._zod).toJSONSchema)==null?void 0:p.call(h);if(a)o.schema=a;else{const v={...e,schemaPath:[...e.schemaPath,n],path:e.path};if(n._zod.processJSONSchema)n._zod.processJSONSchema(t,o.schema,v);else{const _=o.schema,k=t.processors[i.type];if(!k)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);k(n,t,_,v)}const m=n._zod.parent;m&&(o.ref||(o.ref=m),Se(m,t,v),t.seen.get(m).isParent=!0)}const c=t.metadataRegistry.get(n);return c&&Object.assign(o.schema,c),t.io==="input"&&Ze(n)&&(delete o.schema.examples,delete o.schema.default),t.io==="input"&&o.schema._prefault&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(n).schema}function hy(n,t){var o,a,c,u;const e=n.seen.get(t);if(!e)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=new Map;for(const h of n.seen.entries()){const p=(o=n.metadataRegistry.get(h[0]))==null?void 0:o.id;if(p){const v=r.get(p);if(v&&v!==h[0])throw new Error(`Duplicate schema id "${p}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(p,h[0])}}const i=h=>{var k;const p=n.target==="draft-2020-12"?"$defs":"definitions";if(n.external){const T=(k=n.external.registry.get(h[0]))==null?void 0:k.id,P=n.external.uri??(W=>W);if(T)return{ref:P(T)};const R=h[1].defId??h[1].schema.id??`schema${n.counter++}`;return h[1].defId=R,{defId:R,ref:`${P("__shared")}#/${p}/${R}`}}if(h[1]===e)return{ref:"#"};const m=`#/${p}/`,_=h[1].schema.id??`__schema${n.counter++}`;return{defId:_,ref:m+_}},s=h=>{if(h[1].schema.$ref)return;const p=h[1],{ref:v,defId:m}=i(h);p.def={...p.schema},m&&(p.defId=m);const _=p.schema;for(const k in _)delete _[k];_.$ref=v};if(n.cycles==="throw")for(const h of n.seen.entries()){const p=h[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 h of n.seen.entries()){const p=h[1];if(t===h[0]){s(h);continue}if(n.external){const m=(c=n.external.registry.get(h[0]))==null?void 0:c.id;if(t!==h[0]&&m){s(h);continue}}if((u=n.metadataRegistry.get(h[0]))==null?void 0:u.id){s(h);continue}if(p.cycle){s(h);continue}if(p.count>1&&n.reused==="ref"){s(h);continue}}}function ay(n,t){var o,a,c;const e=n.seen.get(t);if(!e)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=u=>{const h=n.seen.get(u);if(h.ref===null)return;const p=h.def??h.schema,v={...p},m=h.ref;if(h.ref=null,m){r(m);const k=n.seen.get(m),T=k.schema;if(T.$ref&&(n.target==="draft-07"||n.target==="draft-04"||n.target==="openapi-3.0")?(p.allOf=p.allOf??[],p.allOf.push(T)):Object.assign(p,T),Object.assign(p,v),u._zod.parent===m)for(const R in p)R==="$ref"||R==="allOf"||R in v||delete p[R];if(T.$ref&&k.def)for(const R in p)R==="$ref"||R==="allOf"||R in k.def&&JSON.stringify(p[R])===JSON.stringify(k.def[R])&&delete p[R]}const _=u._zod.parent;if(_&&_!==m){r(_);const k=n.seen.get(_);if(k!=null&&k.schema.$ref&&(p.$ref=k.schema.$ref,k.def))for(const T in p)T==="$ref"||T==="allOf"||T in k.def&&JSON.stringify(p[T])===JSON.stringify(k.def[T])&&delete p[T]}n.override({zodSchema:u,jsonSchema:p,path:h.path??[]})};for(const u of[...n.seen.entries()].reverse())r(u[0]);const i={};if(n.target==="draft-2020-12"?i.$schema="https://json-schema.org/draft/2020-12/schema":n.target==="draft-07"?i.$schema="http://json-schema.org/draft-07/schema#":n.target==="draft-04"?i.$schema="http://json-schema.org/draft-04/schema#":n.target,(o=n.external)!=null&&o.uri){const u=(a=n.external.registry.get(t))==null?void 0:a.id;if(!u)throw new Error("Schema is missing an `id` property");i.$id=n.external.uri(u)}Object.assign(i,e.def??e.schema);const s=((c=n.external)==null?void 0:c.defs)??{};for(const u of n.seen.entries()){const h=u[1];h.def&&h.defId&&(s[h.defId]=h.def)}n.external||Object.keys(s).length>0&&(n.target==="draft-2020-12"?i.$defs=s:i.definitions=s);try{const u=JSON.parse(JSON.stringify(i));return Object.defineProperty(u,"~standard",{value:{...t["~standard"],jsonSchema:{input:cl(t,"input",n.processors),output:cl(t,"output",n.processors)}},enumerable:!1,writable:!1}),u}catch{throw new Error("Error converting schema to JSON.")}}function Ze(n,t){const e=t??{seen:new Set};if(e.seen.has(n))return!1;e.seen.add(n);const r=n._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return Ze(r.element,e);if(r.type==="set")return Ze(r.valueType,e);if(r.type==="lazy")return Ze(r.getter(),e);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault")return Ze(r.innerType,e);if(r.type==="intersection")return Ze(r.left,e)||Ze(r.right,e);if(r.type==="record"||r.type==="map")return Ze(r.keyType,e)||Ze(r.valueType,e);if(r.type==="pipe")return Ze(r.in,e)||Ze(r.out,e);if(r.type==="object"){for(const i in r.shape)if(Ze(r.shape[i],e))return!0;return!1}if(r.type==="union"){for(const i of r.options)if(Ze(i,e))return!0;return!1}if(r.type==="tuple"){for(const i of r.items)if(Ze(i,e))return!0;return!!(r.rest&&Ze(r.rest,e))}return!1}const DI=(n,t={})=>e=>{const r=sy({...e,processors:t});return Se(n,r),oy(r,n),ay(r,n)},cl=(n,t,e={})=>r=>{const{libraryOptions:i,target:s}=r??{},o=sy({...i??{},target:s,io:t,processors:e});return Se(n,o),oy(o,n),ay(o,n)},LI={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},zI=(n,t,e,r)=>{const i=e;i.type="string";const{minimum:s,maximum:o,format:a,patterns:c,contentEncoding:u}=n._zod.bag;if(typeof s=="number"&&(i.minLength=s),typeof o=="number"&&(i.maxLength=o),a&&(i.format=LI[a]??a,i.format===""&&delete i.format,a==="time"&&delete i.format),u&&(i.contentEncoding=u),c&&c.size>0){const h=[...c];h.length===1?i.pattern=h[0].source:h.length>1&&(i.allOf=[...h.map(p=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:p.source}))])}},OI=(n,t,e,r)=>{const i=e,{minimum:s,maximum:o,format:a,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:h}=n._zod.bag;typeof a=="string"&&a.includes("int")?i.type="integer":i.type="number",typeof h=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(i.minimum=h,i.exclusiveMinimum=!0):i.exclusiveMinimum=h),typeof s=="number"&&(i.minimum=s,typeof h=="number"&&t.target!=="draft-04"&&(h>=s?delete i.minimum:delete i.exclusiveMinimum)),typeof u=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(i.maximum=u,i.exclusiveMaximum=!0):i.exclusiveMaximum=u),typeof o=="number"&&(i.maximum=o,typeof u=="number"&&t.target!=="draft-04"&&(u<=o?delete i.maximum:delete i.exclusiveMaximum)),typeof c=="number"&&(i.multipleOf=c)},MI=(n,t,e,r)=>{e.type="boolean"},NI=(n,t,e,r)=>{e.not={}},UI=(n,t,e,r)=>{},FI=(n,t,e,r)=>{const i=n._zod.def,s=Uv(i.entries);s.every(o=>typeof o=="number")&&(e.type="number"),s.every(o=>typeof o=="string")&&(e.type="string"),e.enum=s},HI=(n,t,e,r)=>{const i=n._zod.def,s=[];for(const o of i.values)if(o===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof o=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");s.push(Number(o))}else s.push(o);if(s.length!==0)if(s.length===1){const o=s[0];e.type=o===null?"null":typeof o,t.target==="draft-04"||t.target==="openapi-3.0"?e.enum=[o]:e.const=o}else s.every(o=>typeof o=="number")&&(e.type="number"),s.every(o=>typeof o=="string")&&(e.type="string"),s.every(o=>typeof o=="boolean")&&(e.type="boolean"),s.every(o=>o===null)&&(e.type="null"),e.enum=s},WI=(n,t,e,r)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},ZI=(n,t,e,r)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},VI=(n,t,e,r)=>{const i=e,s=n._zod.def,{minimum:o,maximum:a}=n._zod.bag;typeof o=="number"&&(i.minItems=o),typeof a=="number"&&(i.maxItems=a),i.type="array",i.items=Se(s.element,t,{...r,path:[...r.path,"items"]})},BI=(n,t,e,r)=>{var u;const i=e,s=n._zod.def;i.type="object",i.properties={};const o=s.shape;for(const h in o)i.properties[h]=Se(o[h],t,{...r,path:[...r.path,"properties",h]});const a=new Set(Object.keys(o)),c=new Set([...a].filter(h=>{const p=s.shape[h]._zod;return t.io==="input"?p.optin===void 0:p.optout===void 0}));c.size>0&&(i.required=Array.from(c)),((u=s.catchall)==null?void 0:u._zod.def.type)==="never"?i.additionalProperties=!1:s.catchall?s.catchall&&(i.additionalProperties=Se(s.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(i.additionalProperties=!1)},jI=(n,t,e,r)=>{const i=n._zod.def,s=i.inclusive===!1,o=i.options.map((a,c)=>Se(a,t,{...r,path:[...r.path,s?"oneOf":"anyOf",c]}));s?e.oneOf=o:e.anyOf=o},GI=(n,t,e,r)=>{const i=n._zod.def,s=Se(i.left,t,{...r,path:[...r.path,"allOf",0]}),o=Se(i.right,t,{...r,path:[...r.path,"allOf",1]}),a=u=>"allOf"in u&&Object.keys(u).length===1,c=[...a(s)?s.allOf:[s],...a(o)?o.allOf:[o]];e.allOf=c},qI=(n,t,e,r)=>{const i=e,s=n._zod.def;i.type="object";const o=s.keyType,a=o._zod.bag,c=a==null?void 0:a.patterns;if(s.mode==="loose"&&c&&c.size>0){const h=Se(s.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});i.patternProperties={};for(const p of c)i.patternProperties[p.source]=h}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(i.propertyNames=Se(s.keyType,t,{...r,path:[...r.path,"propertyNames"]})),i.additionalProperties=Se(s.valueType,t,{...r,path:[...r.path,"additionalProperties"]});const u=o._zod.values;if(u){const h=[...u].filter(p=>typeof p=="string"||typeof p=="number");h.length>0&&(i.required=h)}},YI=(n,t,e,r)=>{const i=n._zod.def,s=Se(i.innerType,t,r),o=t.seen.get(n);t.target==="openapi-3.0"?(o.ref=i.innerType,e.nullable=!0):e.anyOf=[s,{type:"null"}]},XI=(n,t,e,r)=>{const i=n._zod.def;Se(i.innerType,t,r);const s=t.seen.get(n);s.ref=i.innerType},KI=(n,t,e,r)=>{const i=n._zod.def;Se(i.innerType,t,r);const s=t.seen.get(n);s.ref=i.innerType,e.default=JSON.parse(JSON.stringify(i.defaultValue))},JI=(n,t,e,r)=>{const i=n._zod.def;Se(i.innerType,t,r);const s=t.seen.get(n);s.ref=i.innerType,t.io==="input"&&(e._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},QI=(n,t,e,r)=>{const i=n._zod.def;Se(i.innerType,t,r);const s=t.seen.get(n);s.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}e.default=o},eC=(n,t,e,r)=>{const i=n._zod.def,s=t.io==="input"?i.in._zod.def.type==="transform"?i.out:i.in:i.out;Se(s,t,r);const o=t.seen.get(n);o.ref=s},tC=(n,t,e,r)=>{const i=n._zod.def;Se(i.innerType,t,r);const s=t.seen.get(n);s.ref=i.innerType,e.readOnly=!0},ly=(n,t,e,r)=>{const i=n._zod.def;Se(i.innerType,t,r);const s=t.seen.get(n);s.ref=i.innerType},nC=A("ZodISODateTime",(n,t)=>{rT.init(n,t),me.init(n,t)});function rC(n){return cI(nC,n)}const iC=A("ZodISODate",(n,t)=>{iT.init(n,t),me.init(n,t)});function sC(n){return uI(iC,n)}const oC=A("ZodISOTime",(n,t)=>{sT.init(n,t),me.init(n,t)});function aC(n){return hI(oC,n)}const lC=A("ZodISODuration",(n,t)=>{oT.init(n,t),me.init(n,t)});function cC(n){return dI(lC,n)}const cy=(n,t)=>{Zv.init(n,t),n.name="ZodError",Object.defineProperties(n,{format:{value:e=>X1(n,e)},flatten:{value:e=>Y1(n,e)},addIssue:{value:e=>{n.issues.push(e),n.message=JSON.stringify(n.issues,Iu,2)}},addIssues:{value:e=>{n.issues.push(...e),n.message=JSON.stringify(n.issues,Iu,2)}},isEmpty:{get(){return n.issues.length===0}}})},tg=A("ZodError",cy),bt=A("ZodError",cy,{Parent:Error}),uC=cd(bt),hC=ud(bt),dC=Zl(bt),pC=Vl(bt),fC=Q1(bt),gC=e$(bt),mC=t$(bt),vC=n$(bt),yC=r$(bt),bC=i$(bt),wC=s$(bt),SC=o$(bt),ge=A("ZodType",(n,t)=>(fe.init(n,t),Object.assign(n["~standard"],{jsonSchema:{input:cl(n,"input"),output:cl(n,"output")}}),n.toJSONSchema=DI(n,{}),n.def=t,n.type=t.type,Object.defineProperty(n,"_def",{value:t}),n.check=(...e)=>n.clone(Jn(t,{checks:[...t.checks??[],...e.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0}),n.with=n.check,n.clone=(e,r)=>Qn(n,e,r),n.brand=()=>n,n.register=(e,r)=>(e.add(n,r),n),n.parse=(e,r)=>uC(n,e,r,{callee:n.parse}),n.safeParse=(e,r)=>dC(n,e,r),n.parseAsync=async(e,r)=>hC(n,e,r,{callee:n.parseAsync}),n.safeParseAsync=async(e,r)=>pC(n,e,r),n.spa=n.safeParseAsync,n.encode=(e,r)=>fC(n,e,r),n.decode=(e,r)=>gC(n,e,r),n.encodeAsync=async(e,r)=>mC(n,e,r),n.decodeAsync=async(e,r)=>vC(n,e,r),n.safeEncode=(e,r)=>yC(n,e,r),n.safeDecode=(e,r)=>bC(n,e,r),n.safeEncodeAsync=async(e,r)=>wC(n,e,r),n.safeDecodeAsync=async(e,r)=>SC(n,e,r),n.refine=(e,r)=>n.check(dR(e,r)),n.superRefine=e=>n.check(pR(e)),n.overwrite=e=>n.check(is(e)),n.optional=()=>ig(n),n.exactOptional=()=>QC(n),n.nullable=()=>sg(n),n.nullish=()=>ig(sg(n)),n.nonoptional=e=>sR(n,e),n.array=()=>L(n),n.or=e=>B([n,e]),n.and=e=>jl(n,e),n.transform=e=>og(n,KC(e)),n.default=e=>nR(n,e),n.prefault=e=>iR(n,e),n.catch=e=>aR(n,e),n.pipe=e=>og(n,e),n.readonly=()=>uR(n),n.describe=e=>{const r=n.clone();return Es.add(r,{description:e}),r},Object.defineProperty(n,"description",{get(){var e;return(e=Es.get(n))==null?void 0:e.description},configurable:!0}),n.meta=(...e)=>{if(e.length===0)return Es.get(n);const r=n.clone();return Es.add(r,e[0]),r},n.isOptional=()=>n.safeParse(void 0).success,n.isNullable=()=>n.safeParse(null).success,n.apply=e=>e(n),n)),uy=A("_ZodString",(n,t)=>{hd.init(n,t),ge.init(n,t),n._zod.processJSONSchema=(r,i,s)=>zI(n,r,i);const e=n._zod.bag;n.format=e.format??null,n.minLength=e.minimum??null,n.maxLength=e.maximum??null,n.regex=(...r)=>n.check(yI(...r)),n.includes=(...r)=>n.check(SI(...r)),n.startsWith=(...r)=>n.check(_I(...r)),n.endsWith=(...r)=>n.check(kI(...r)),n.min=(...r)=>n.check(ll(...r)),n.max=(...r)=>n.check(ry(...r)),n.length=(...r)=>n.check(iy(...r)),n.nonempty=(...r)=>n.check(ll(1,...r)),n.lowercase=r=>n.check(bI(r)),n.uppercase=r=>n.check(wI(r)),n.trim=()=>n.check(xI()),n.normalize=(...r)=>n.check(EI(...r)),n.toLowerCase=()=>n.check(AI()),n.toUpperCase=()=>n.check($I()),n.slugify=()=>n.check(TI())}),_C=A("ZodString",(n,t)=>{hd.init(n,t),uy.init(n,t),n.email=e=>n.check(WT(kC,e)),n.url=e=>n.check(GT(EC,e)),n.jwt=e=>n.check(lI(UC,e)),n.emoji=e=>n.check(qT(xC,e)),n.guid=e=>n.check(Kf(ng,e)),n.uuid=e=>n.check(ZT(va,e)),n.uuidv4=e=>n.check(VT(va,e)),n.uuidv6=e=>n.check(BT(va,e)),n.uuidv7=e=>n.check(jT(va,e)),n.nanoid=e=>n.check(YT(AC,e)),n.guid=e=>n.check(Kf(ng,e)),n.cuid=e=>n.check(XT($C,e)),n.cuid2=e=>n.check(KT(TC,e)),n.ulid=e=>n.check(JT(IC,e)),n.base64=e=>n.check(sI(OC,e)),n.base64url=e=>n.check(oI(MC,e)),n.xid=e=>n.check(QT(CC,e)),n.ksuid=e=>n.check(eI(RC,e)),n.ipv4=e=>n.check(tI(PC,e)),n.ipv6=e=>n.check(nI(DC,e)),n.cidrv4=e=>n.check(rI(LC,e)),n.cidrv6=e=>n.check(iI(zC,e)),n.e164=e=>n.check(aI(NC,e)),n.datetime=e=>n.check(rC(e)),n.date=e=>n.check(sC(e)),n.time=e=>n.check(aC(e)),n.duration=e=>n.check(cC(e))});function d(n){return HT(_C,n)}const me=A("ZodStringFormat",(n,t)=>{he.init(n,t),uy.init(n,t)}),kC=A("ZodEmail",(n,t)=>{q$.init(n,t),me.init(n,t)}),ng=A("ZodGUID",(n,t)=>{j$.init(n,t),me.init(n,t)}),va=A("ZodUUID",(n,t)=>{G$.init(n,t),me.init(n,t)}),EC=A("ZodURL",(n,t)=>{Y$.init(n,t),me.init(n,t)}),xC=A("ZodEmoji",(n,t)=>{X$.init(n,t),me.init(n,t)}),AC=A("ZodNanoID",(n,t)=>{K$.init(n,t),me.init(n,t)}),$C=A("ZodCUID",(n,t)=>{J$.init(n,t),me.init(n,t)}),TC=A("ZodCUID2",(n,t)=>{Q$.init(n,t),me.init(n,t)}),IC=A("ZodULID",(n,t)=>{eT.init(n,t),me.init(n,t)}),CC=A("ZodXID",(n,t)=>{tT.init(n,t),me.init(n,t)}),RC=A("ZodKSUID",(n,t)=>{nT.init(n,t),me.init(n,t)}),PC=A("ZodIPv4",(n,t)=>{aT.init(n,t),me.init(n,t)}),DC=A("ZodIPv6",(n,t)=>{lT.init(n,t),me.init(n,t)}),LC=A("ZodCIDRv4",(n,t)=>{cT.init(n,t),me.init(n,t)}),zC=A("ZodCIDRv6",(n,t)=>{uT.init(n,t),me.init(n,t)}),OC=A("ZodBase64",(n,t)=>{hT.init(n,t),me.init(n,t)}),MC=A("ZodBase64URL",(n,t)=>{pT.init(n,t),me.init(n,t)}),NC=A("ZodE164",(n,t)=>{fT.init(n,t),me.init(n,t)}),UC=A("ZodJWT",(n,t)=>{mT.init(n,t),me.init(n,t)}),hy=A("ZodNumber",(n,t)=>{Qv.init(n,t),ge.init(n,t),n._zod.processJSONSchema=(r,i,s)=>OI(n,r,i),n.gt=(r,i)=>n.check(Qf(r,i)),n.gte=(r,i)=>n.check(Bc(r,i)),n.min=(r,i)=>n.check(Bc(r,i)),n.lt=(r,i)=>n.check(Jf(r,i)),n.lte=(r,i)=>n.check(Vc(r,i)),n.max=(r,i)=>n.check(Vc(r,i)),n.int=r=>n.check(rg(r)),n.safe=r=>n.check(rg(r)),n.positive=r=>n.check(Qf(0,r)),n.nonnegative=r=>n.check(Bc(0,r)),n.negative=r=>n.check(Jf(0,r)),n.nonpositive=r=>n.check(Vc(0,r)),n.multipleOf=(r,i)=>n.check(eg(r,i)),n.step=(r,i)=>n.check(eg(r,i)),n.finite=()=>n;const e=n._zod.bag;n.minValue=Math.max(e.minimum??Number.NEGATIVE_INFINITY,e.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,n.maxValue=Math.min(e.maximum??Number.POSITIVE_INFINITY,e.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,n.isInt=(e.format??"").includes("int")||Number.isSafeInteger(e.multipleOf??.5),n.isFinite=!0,n.format=e.format??null});function H(n){return pI(hy,n)}const FC=A("ZodNumberFormat",(n,t)=>{vT.init(n,t),hy.init(n,t)});function rg(n){return fI(FC,n)}const HC=A("ZodBoolean",(n,t)=>{yT.init(n,t),ge.init(n,t),n._zod.processJSONSchema=(e,r,i)=>MI(n,e,r)});function Ie(n){return gI(HC,n)}const WC=A("ZodUnknown",(n,t)=>{bT.init(n,t),ge.init(n,t),n._zod.processJSONSchema=(e,r,i)=>UI()});function E(){return mI(WC)}const ZC=A("ZodNever",(n,t)=>{wT.init(n,t),ge.init(n,t),n._zod.processJSONSchema=(e,r,i)=>NI(n,e,r)});function VC(n){return vI(ZC,n)}const BC=A("ZodArray",(n,t)=>{ST.init(n,t),ge.init(n,t),n._zod.processJSONSchema=(e,r,i)=>VI(n,e,r,i),n.element=t.element,n.min=(e,r)=>n.check(ll(e,r)),n.nonempty=e=>n.check(ll(1,e)),n.max=(e,r)=>n.check(ry(e,r)),n.length=(e,r)=>n.check(iy(e,r)),n.unwrap=()=>n.element});function L(n,t){return II(BC,n,t)}const dy=A("ZodObject",(n,t)=>{kT.init(n,t),ge.init(n,t),n._zod.processJSONSchema=(e,r,i)=>BI(n,e,r,i),ne(n,"shape",()=>t.shape),n.keyof=()=>Ws(Object.keys(n._zod.def.shape)),n.catchall=e=>n.clone({...n._zod.def,catchall:e}),n.passthrough=()=>n.clone({...n._zod.def,catchall:E()}),n.loose=()=>n.clone({...n._zod.def,catchall:E()}),n.strict=()=>n.clone({...n._zod.def,catchall:VC()}),n.strip=()=>n.clone({...n._zod.def,catchall:void 0}),n.extend=e=>V1(n,e),n.safeExtend=e=>B1(n,e),n.merge=e=>j1(n,e),n.pick=e=>W1(n,e),n.omit=e=>Z1(n,e),n.partial=(...e)=>G1(fy,n,e[0]),n.required=(...e)=>q1(gy,n,e[0])});function py(n,t){const e={type:"object",shape:n??{},...M(t)};return new dy(e)}function y(n,t){return new dy({type:"object",shape:n,catchall:E(),...M(t)})}const jC=A("ZodUnion",(n,t)=>{ET.init(n,t),ge.init(n,t),n._zod.processJSONSchema=(e,r,i)=>jI(n,e,r,i),n.options=t.options});function B(n,t){return new jC({type:"union",options:n,...M(t)})}const GC=A("ZodIntersection",(n,t)=>{xT.init(n,t),ge.init(n,t),n._zod.processJSONSchema=(e,r,i)=>GI(n,e,r,i)});function jl(n,t){return new GC({type:"intersection",left:n,right:t})}const qC=A("ZodRecord",(n,t)=>{AT.init(n,t),ge.init(n,t),n._zod.processJSONSchema=(e,r,i)=>qI(n,e,r,i),n.keyType=t.keyType,n.valueType=t.valueType});function x(n,t,e){return new qC({type:"record",keyType:n,valueType:t,...M(e)})}const Ru=A("ZodEnum",(n,t)=>{$T.init(n,t),ge.init(n,t),n._zod.processJSONSchema=(r,i,s)=>FI(n,r,i),n.enum=t.entries,n.options=Object.values(t.entries);const e=new Set(Object.keys(t.entries));n.extract=(r,i)=>{const s={};for(const o of r)if(e.has(o))s[o]=t.entries[o];else throw new Error(`Key ${o} not found in enum`);return new Ru({...t,checks:[],...M(i),entries:s})},n.exclude=(r,i)=>{const s={...t.entries};for(const o of r)if(e.has(o))delete s[o];else throw new Error(`Key ${o} not found in enum`);return new Ru({...t,checks:[],...M(i),entries:s})}});function Ws(n,t){const e=Array.isArray(n)?Object.fromEntries(n.map(r=>[r,r])):n;return new Ru({type:"enum",entries:e,...M(t)})}const YC=A("ZodLiteral",(n,t)=>{TT.init(n,t),ge.init(n,t),n._zod.processJSONSchema=(e,r,i)=>HI(n,e,r),n.values=new Set(t.values),Object.defineProperty(n,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function $(n,t){return new YC({type:"literal",values:Array.isArray(n)?n:[n],...M(t)})}const XC=A("ZodTransform",(n,t)=>{IT.init(n,t),ge.init(n,t),n._zod.processJSONSchema=(e,r,i)=>ZI(n,e),n._zod.parse=(e,r)=>{if(r.direction==="backward")throw new Mv(n.constructor.name);e.addIssue=s=>{if(typeof s=="string")e.issues.push(Hs(s,e.value,t));else{const o=s;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=e.value),o.inst??(o.inst=n),e.issues.push(Hs(o))}};const i=t.transform(e.value,e);return i instanceof Promise?i.then(s=>(e.value=s,e)):(e.value=i,e)}});function KC(n){return new XC({type:"transform",transform:n})}const fy=A("ZodOptional",(n,t)=>{ny.init(n,t),ge.init(n,t),n._zod.processJSONSchema=(e,r,i)=>ly(n,e,r,i),n.unwrap=()=>n._zod.def.innerType});function ig(n){return new fy({type:"optional",innerType:n})}const JC=A("ZodExactOptional",(n,t)=>{CT.init(n,t),ge.init(n,t),n._zod.processJSONSchema=(e,r,i)=>ly(n,e,r,i),n.unwrap=()=>n._zod.def.innerType});function QC(n){return new JC({type:"optional",innerType:n})}const eR=A("ZodNullable",(n,t)=>{RT.init(n,t),ge.init(n,t),n._zod.processJSONSchema=(e,r,i)=>YI(n,e,r,i),n.unwrap=()=>n._zod.def.innerType});function sg(n){return new eR({type:"nullable",innerType:n})}const tR=A("ZodDefault",(n,t)=>{PT.init(n,t),ge.init(n,t),n._zod.processJSONSchema=(e,r,i)=>KI(n,e,r,i),n.unwrap=()=>n._zod.def.innerType,n.removeDefault=n.unwrap});function nR(n,t){return new tR({type:"default",innerType:n,get defaultValue(){return typeof t=="function"?t():Hv(t)}})}const rR=A("ZodPrefault",(n,t)=>{DT.init(n,t),ge.init(n,t),n._zod.processJSONSchema=(e,r,i)=>JI(n,e,r,i),n.unwrap=()=>n._zod.def.innerType});function iR(n,t){return new rR({type:"prefault",innerType:n,get defaultValue(){return typeof t=="function"?t():Hv(t)}})}const gy=A("ZodNonOptional",(n,t)=>{LT.init(n,t),ge.init(n,t),n._zod.processJSONSchema=(e,r,i)=>XI(n,e,r,i),n.unwrap=()=>n._zod.def.innerType});function sR(n,t){return new gy({type:"nonoptional",innerType:n,...M(t)})}const oR=A("ZodCatch",(n,t)=>{zT.init(n,t),ge.init(n,t),n._zod.processJSONSchema=(e,r,i)=>QI(n,e,r,i),n.unwrap=()=>n._zod.def.innerType,n.removeCatch=n.unwrap});function aR(n,t){return new oR({type:"catch",innerType:n,catchValue:typeof t=="function"?t:()=>t})}const lR=A("ZodPipe",(n,t)=>{OT.init(n,t),ge.init(n,t),n._zod.processJSONSchema=(e,r,i)=>eC(n,e,r,i),n.in=t.in,n.out=t.out});function og(n,t){return new lR({type:"pipe",in:n,out:t})}const cR=A("ZodReadonly",(n,t)=>{MT.init(n,t),ge.init(n,t),n._zod.processJSONSchema=(e,r,i)=>tC(n,e,r,i),n.unwrap=()=>n._zod.def.innerType});function uR(n){return new cR({type:"readonly",innerType:n})}const hR=A("ZodCustom",(n,t)=>{NT.init(n,t),ge.init(n,t),n._zod.processJSONSchema=(e,r,i)=>WI(n,e)});function dR(n,t={}){return CI(hR,n,t)}function pR(n){return RI(n)}const ln={custom:"custom"},my=["markdown","web-bundle","url"],fR=["committed","pending"];function gR(n){let t;try{t=new URL(n)}catch{return!1}return t.protocol==="http:"||t.protocol==="https:"}py({id:d().min(1),kind:Ws(my),title:d(),status:Ws(fR),externalFilePath:d().optional(),externalURL:d().optional()}).superRefine((n,t)=>{switch(n.externalFilePath!==void 0&&n.externalURL!==void 0&&t.addIssue({code:ln.custom,message:"externalFilePath and externalURL are mutually exclusive",path:["externalURL"]}),n.kind!=="web-bundle"&&n.status!=="committed"&&t.addIssue({code:ln.custom,message:"only web-bundle artifacts can be pending",path:["status"]}),n.kind){case"markdown":n.externalFilePath===void 0&&t.addIssue({code:ln.custom,message:"markdown artifacts require externalFilePath",path:["externalFilePath"]}),n.externalURL!==void 0&&t.addIssue({code:ln.custom,message:"markdown artifacts cannot set externalURL",path:["externalURL"]});break;case"web-bundle":n.externalFilePath!==void 0&&t.addIssue({code:ln.custom,message:"web-bundle artifacts cannot set externalFilePath",path:["externalFilePath"]}),n.externalURL!==void 0&&t.addIssue({code:ln.custom,message:"web-bundle artifacts cannot set externalURL",path:["externalURL"]});break;case"url":if(n.externalURL===void 0){t.addIssue({code:ln.custom,message:"url artifacts require externalURL",path:["externalURL"]});break}n.externalFilePath!==void 0&&t.addIssue({code:ln.custom,message:"url artifacts cannot set externalFilePath",path:["externalFilePath"]}),gR(n.externalURL)||t.addIssue({code:ln.custom,message:"externalURL must be an http(s) URL",path:["externalURL"]});break}});py({name:d().min(1),description:d(),accepts:L(Ws(my)).min(1)});function vy(n){return typeof n=="object"&&n!==null}function mR(n){return!vy(n)||n.type!=="ready"?!1:!("id"in n)}function vR(n){return!(!vy(n)||n.type!=="update-content"||typeof n.id!="string"||typeof n.content!="string")}function yR(n,t){return t.find(e=>e.accepts.includes(n))??null}const ue={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"},cn={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"},bR=1,wR=y({_meta:x(d(),E()).nullish(),terminal:Ie().optional().default(!1)}),SR=y({_meta:x(d(),E()).nullish(),label:d().nullish(),name:d(),optional:Ie().optional().default(!1),secret:Ie().optional().default(!0)}),_R=y({_meta:x(d(),E()).nullish(),description:d().nullish(),id:d(),name:d()}),kR=y({_meta:x(d(),E()).nullish(),description:d().nullish(),id:d(),link:d().nullish(),name:d(),vars:L(SR)}),ER=y({_meta:x(d(),E()).nullish(),args:L(d()).optional(),description:d().nullish(),env:x(d(),d()).optional(),id:d(),name:d()}),xR=B([kR.and(y({type:$("env_var")})),ER.and(y({type:$("terminal")})),_R]),AR=y({_meta:x(d(),E()).nullish(),methodId:d()}),$R=y({_meta:x(d(),E()).nullish()}),TR=y({_meta:x(d(),E()).nullish(),blob:d(),mimeType:d().nullish(),uri:d()}),IR=y({default:Ie().nullish(),description:d().nullish(),title:d().nullish()}),CR=y({_meta:x(d(),E()).nullish()}),RR=y({_meta:x(d(),E()).nullish()}),PR=y({amount:H(),currency:d()}),DR=y({_meta:x(d(),E()).nullish(),terminalId:d()}),LR=y({_meta:x(d(),E()).nullish(),newText:d(),oldText:d().nullish(),path:d()}),zR=B([d(),H(),H(),Ie(),L(d())]),OR=y({content:x(d(),zR).nullish()}),MR=B([OR.and(y({action:$("accept")})),y({action:$("decline")}),y({action:$("cancel")})]),NR=y({_meta:x(d(),E()).nullish()}),yy=d(),UR=y({_meta:x(d(),E()).nullish(),elicitationId:yy}),FR=y({_meta:x(d(),E()).nullish(),action:MR}),HR=$("object"),WR=$("string"),ZR=y({_meta:x(d(),E()).nullish()}),VR=y({_meta:x(d(),E()).nullish(),form:NR.nullish(),url:ZR.nullish()}),BR=y({elicitationId:yy,url:d().url()}),by=y({const:d(),title:d()}),wy=y({_meta:x(d(),E()).nullish(),name:d(),value:d()}),jR=B([$(-32700),$(-32600),$(-32601),$(-32602),$(-32603),$(-32800),$(-32e3),$(-32002),$(-32042),H().int().min(-2147483648,{message:"Invalid value: Expected int32 to be >= -2147483648"}).max(2147483647,{message:"Invalid value: Expected int32 to be <= 2147483647"})]),Sy=y({code:jR,data:E().optional(),message:d()}),_y=E(),ky=E(),Ey=E(),GR=y({_meta:x(d(),E()).nullish(),readTextFile:Ie().optional().default(!1),writeTextFile:Ie().optional().default(!1)}),xy=y({_meta:x(d(),E()).nullish(),name:d(),value:d()}),Ay=y({_meta:x(d(),E()).nullish(),name:d(),title:d().nullish(),version:d()}),qR=y({default:H().nullish(),description:d().nullish(),maximum:H().nullish(),minimum:H().nullish(),title:d().nullish()}),YR=y({_meta:x(d(),E()).nullish()}),XR=y({_meta:x(d(),E()).nullish(),additionalDirectories:L(d()).optional(),cursor:d().nullish(),cwd:d().nullish()}),KR=y({_meta:x(d(),E()).nullish()}),JR=y({_meta:x(d(),E()).nullish(),logout:KR.nullish()}),QR=y({_meta:x(d(),E()).nullish()}),eP=y({_meta:x(d(),E()).nullish()}),tP=y({_meta:x(d(),E()).nullish(),http:Ie().optional().default(!1),sse:Ie().optional().default(!1)}),nP=y({_meta:x(d(),E()).nullish(),headers:L(xy),name:d(),url:d()}),rP=y({_meta:x(d(),E()).nullish(),headers:L(xy),name:d(),url:d()}),iP=y({_meta:x(d(),E()).nullish(),args:L(d()),command:d(),env:L(wy),name:d()}),Gl=B([nP.and(y({type:$("http")})),rP.and(y({type:$("sse")})),iP]),dd=d(),sP=y({_meta:x(d(),E()).nullish(),description:d().nullish(),modelId:dd,name:d()}),oP=B([$("error"),$("warning"),$("information"),$("hint")]),aP=y({_meta:x(d(),E()).nullish()}),lP=y({_meta:x(d(),E()).nullish()}),cP=y({_meta:x(d(),E()).nullish()}),uP=y({_meta:x(d(),E()).nullish()}),hP=y({_meta:x(d(),E()).nullish()}),dP=y({_meta:x(d(),E()).nullish(),maxCount:H().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),pP=y({diff:d(),uri:d()}),fP=y({endLine:H().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),startLine:H().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),text:d()}),gP=y({_meta:x(d(),E()).nullish()}),mP=y({_meta:x(d(),E()).nullish()}),vP=y({languageId:d(),text:d(),uri:d()}),yP=y({_meta:x(d(),E()).nullish(),maxCount:H().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),bP=B([$("rejected"),$("ignored"),$("replaced"),$("cancelled")]),wP=y({excerpts:L(fP),uri:d()}),SP=y({_meta:x(d(),E()).nullish()}),_P=y({_meta:x(d(),E()).nullish()}),kP=y({name:d(),owner:d(),remoteUrl:d()}),EP=y({_meta:x(d(),E()).nullish()}),xP=y({_meta:x(d(),E()).nullish(),jump:gP.nullish(),rename:_P.nullish(),searchAndReplace:EP.nullish()}),AP=y({id:d(),isRegex:Ie().nullish(),replace:d(),search:d(),uri:d()}),$P=B([$("automatic"),$("diagnostic"),$("manual")]),TP=y({_meta:x(d(),E()).nullish(),maxCount:H().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),IP=y({_meta:x(d(),E()).nullish(),diagnostics:aP.nullish(),editHistory:dP.nullish(),openFiles:mP.nullish(),recentFiles:yP.nullish(),relatedSnippets:SP.nullish(),userActions:TP.nullish()}),CP=y({_meta:x(d(),E()).nullish(),additionalDirectories:L(d()).optional(),cwd:d(),mcpServers:L(Gl)}),RP=y({default:H().nullish(),description:d().nullish(),maximum:H().nullish(),minimum:H().nullish(),title:d().nullish()}),$y=d(),PP=B([$("allow_once"),$("allow_always"),$("reject_once"),$("reject_always")]),DP=y({_meta:x(d(),E()).nullish(),kind:PP,name:d(),optionId:$y}),LP=B([$("high"),$("medium"),$("low")]),zP=B([$("pending"),$("in_progress"),$("completed")]),OP=y({_meta:x(d(),E()).nullish(),content:d(),priority:LP,status:zP}),MP=y({_meta:x(d(),E()).nullish(),entries:L(OP)}),qn=y({character:H().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),line:H().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"})}),NP=y({id:d(),position:qn,uri:d()}),UP=y({id:d(),newName:d(),position:qn,uri:d()}),FP=y({action:d(),position:qn,timestampMs:H(),uri:d()}),Ty=B([$("utf-16"),$("utf-32"),$("utf-8")]),HP=y({_meta:x(d(),E()).nullish(),auth:wR.optional().default({terminal:!1}),elicitation:VR.nullish(),fs:GR.optional().default({readTextFile:!1,writeTextFile:!1}),nes:xP.nullish(),positionEncodings:L(Ty).optional(),terminal:Ie().optional().default(!1)}),WP=y({_meta:x(d(),E()).nullish(),audio:Ie().optional().default(!1),embeddedContext:Ie().optional().default(!1),image:Ie().optional().default(!1)}),Iy=H().int().gte(0).lte(65535),ZP=y({_meta:x(d(),E()).nullish(),clientCapabilities:HP.optional().default({auth:{terminal:!1},fs:{readTextFile:!1,writeTextFile:!1},terminal:!1}),clientInfo:Ay.nullish(),protocolVersion:Iy}),ss=y({end:qn,start:qn}),VP=y({message:d(),range:ss,severity:oP,uri:d()}),BP=y({languageId:d(),lastFocusedMs:H().nullish(),uri:d(),visibleRange:ss.nullish()}),jP=y({_meta:x(d(),E()).nullish(),diagnostics:L(VP).nullish(),editHistory:L(pP).nullish(),openFiles:L(BP).nullish(),recentFiles:L(vP).nullish(),relatedSnippets:L(wP).nullish(),userActions:L(FP).nullish()}),GP=y({newText:d(),range:ss}),qP=y({cursorPosition:qn.nullish(),edits:L(GP),id:d(),uri:d()}),YP=B([qP.and(y({kind:$("edit")})),NP.and(y({kind:$("jump")})),UP.and(y({kind:$("rename")})),AP.and(y({kind:$("searchAndReplace")}))]),XP=y({_meta:x(d(),E()).nullish(),content:d()}),KP=y({_meta:x(d(),E()).nullish()}),Or=B([H(),d()]).nullable();y({_meta:x(d(),E()).nullish(),requestId:Or});const JP=Ws(["assistant","user"]),qo=y({_meta:x(d(),E()).nullish(),audience:L(JP).nullish(),lastModified:d().nullish(),priority:H().nullish()}),QP=y({_meta:x(d(),E()).nullish(),annotations:qo.nullish(),data:d(),mimeType:d()}),eD=y({_meta:x(d(),E()).nullish(),annotations:qo.nullish(),data:d(),mimeType:d(),uri:d().nullish()}),tD=y({_meta:x(d(),E()).nullish(),annotations:qo.nullish(),description:d().nullish(),mimeType:d().nullish(),name:d(),size:H().nullish(),title:d().nullish(),uri:d()}),nD=y({_meta:x(d(),E()).nullish(),optionId:$y}),rD=B([y({outcome:$("cancelled")}),nD.and(y({outcome:$("selected")}))]),iD=y({_meta:x(d(),E()).nullish(),outcome:rD}),sD=y({_meta:x(d(),E()).nullish()}),oD=y({_meta:x(d(),E()).nullish()}),aD=y({currentValue:Ie()}),lD=d(),Cy=d(),cD=B([$("mode"),$("model"),$("thought_level"),d()]),pd=d(),Ry=y({_meta:x(d(),E()).nullish(),description:d().nullish(),name:d(),value:pd}),uD=y({_meta:x(d(),E()).nullish(),group:lD,name:d(),options:L(Ry)}),hD=B([L(Ry),L(uD)]),dD=y({currentValue:pd,options:hD}),os=jl(B([dD.and(y({type:$("select")})),aD.and(y({type:$("boolean")}))]),y({_meta:x(d(),E()).nullish(),category:cD.nullish(),description:d().nullish(),id:Cy,name:d()})),pD=y({_meta:x(d(),E()).nullish(),configOptions:L(os)}),fD=y({_meta:x(d(),E()).nullish()}),Q=d(),gD=y({_meta:x(d(),E()).nullish(),id:d(),sessionId:Q}),mD=y({_meta:x(d(),E()).nullish(),sessionId:Q}),vD=y({_meta:x(d(),E()).nullish(),sessionId:Q}),yD=y({_meta:x(d(),E()).nullish(),sessionId:Q}),Py=y({_meta:x(d(),E()).nullish(),args:L(d()).optional(),command:d(),cwd:d().nullish(),env:L(wy).optional(),outputByteLimit:H().nullish(),sessionId:Q}),bD=y({_meta:x(d(),E()).nullish(),sessionId:Q,uri:d()}),wD=y({_meta:x(d(),E()).nullish(),position:qn,sessionId:Q,uri:d(),version:H(),visibleRange:ss}),SD=y({_meta:x(d(),E()).nullish(),languageId:d(),sessionId:Q,text:d(),uri:d(),version:H()}),_D=y({_meta:x(d(),E()).nullish(),sessionId:Q,uri:d()}),kD=y({_meta:x(d(),E()).nullish(),additionalDirectories:L(d()).optional(),cwd:d(),mcpServers:L(Gl).optional(),sessionId:Q}),Dy=y({_meta:x(d(),E()).nullish(),sessionId:Q,terminalId:d()}),ED=y({_meta:x(d(),E()).nullish(),additionalDirectories:L(d()).optional(),cwd:d(),mcpServers:L(Gl),sessionId:Q}),Ly=y({_meta:x(d(),E()).nullish(),limit:H().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),line:H().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:d(),sessionId:Q}),xD=y({_meta:x(d(),E()).nullish(),id:d(),reason:bP.nullish(),sessionId:Q}),zy=y({_meta:x(d(),E()).nullish(),sessionId:Q,terminalId:d()}),AD=y({_meta:x(d(),E()).nullish(),additionalDirectories:L(d()).optional(),cwd:d(),mcpServers:L(Gl).optional(),sessionId:Q}),$D=y({_meta:x(d(),E()).nullish(),additionalDirectories:L(d()).optional(),cwd:d(),sessionId:Q,title:d().nullish(),updatedAt:d().nullish()}),TD=y({_meta:x(d(),E()).nullish(),nextCursor:d().nullish(),sessions:L($D)}),ID=y({_meta:x(d(),E()).nullish(),title:d().nullish(),updatedAt:d().nullish()}),CD=y({_meta:x(d(),E()).nullish()}),ql=d(),RD=y({_meta:x(d(),E()).nullish(),currentModeId:ql}),PD=y({_meta:x(d(),E()).nullish(),description:d().nullish(),id:ql,name:d()}),Yl=y({_meta:x(d(),E()).nullish(),availableModes:L(PD),currentModeId:ql}),Xl=y({_meta:x(d(),E()).nullish(),availableModels:L(sP),currentModelId:dd}),DD=y({_meta:x(d(),E()).nullish(),configOptions:L(os).nullish(),models:Xl.nullish(),modes:Yl.nullish(),sessionId:Q}),LD=y({_meta:x(d(),E()).nullish(),configOptions:L(os).nullish(),models:Xl.nullish(),modes:Yl.nullish()}),zD=y({_meta:x(d(),E()).nullish(),configOptions:L(os).nullish(),models:Xl.nullish(),modes:Yl.nullish(),sessionId:Q}),OD=y({_meta:x(d(),E()).nullish(),configOptions:L(os).nullish(),models:Xl.nullish(),modes:Yl.nullish()}),MD=y({_meta:x(d(),E()).nullish()}),ND=y({_meta:x(d(),E()).nullish(),additionalDirectories:sD.nullish(),close:oD.nullish(),fork:fD.nullish(),list:CD.nullish(),resume:MD.nullish()}),UD=jl(B([y({type:$("boolean"),value:Ie()}),y({value:pd})]),y({_meta:x(d(),E()).nullish(),configId:Cy,sessionId:Q})),FD=y({_meta:x(d(),E()).nullish(),configOptions:L(os)}),HD=y({_meta:x(d(),E()).nullish(),modeId:ql,sessionId:Q}),WD=y({_meta:x(d(),E()).nullish()}),ZD=y({_meta:x(d(),E()).nullish(),modelId:dd,sessionId:Q}),VD=y({_meta:x(d(),E()).nullish()}),BD=y({_meta:x(d(),E()).nullish(),sessionId:Q}),jD=B([$("end_turn"),$("max_tokens"),$("max_turn_requests"),$("refusal"),$("cancelled")]),GD=B([$("email"),$("uri"),$("date"),$("date-time")]),qD=y({default:d().nullish(),description:d().nullish(),enum:L(d()).nullish(),format:GD.nullish(),maxLength:H().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),minLength:H().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),oneOf:L(by).nullish(),pattern:d().nullish(),title:d().nullish()}),YD=y({_meta:x(d(),E()).nullish(),context:jP.nullish(),position:qn,selection:ss.nullish(),sessionId:Q,triggerKind:$P,uri:d(),version:H()}),XD=y({_meta:x(d(),E()).nullish(),suggestions:L(YP)}),KD=y({_meta:x(d(),E()).nullish(),terminalId:d()}),JD=y({_meta:x(d(),E()).nullish(),exitCode:H().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:d().nullish()}),Oy=y({_meta:x(d(),E()).nullish(),sessionId:Q,terminalId:d()}),QD=y({_meta:x(d(),E()).nullish(),exitStatus:JD.nullish(),output:d(),truncated:Ie()}),eL=y({_meta:x(d(),E()).nullish(),annotations:qo.nullish(),text:d()}),tL=y({range:ss.nullish(),text:d()}),nL=y({_meta:x(d(),E()).nullish(),contentChanges:L(tL),sessionId:Q,uri:d(),version:H()});y({method:d(),params:B([mD,SD,nL,bD,_D,wD,gD,xD,_y]).nullish()});const rL=B([$("full"),$("incremental")]),iL=y({_meta:x(d(),E()).nullish(),syncKind:rL}),sL=y({_meta:x(d(),E()).nullish(),didChange:iL.nullish(),didClose:lP.nullish(),didFocus:cP.nullish(),didOpen:uP.nullish(),didSave:hP.nullish()}),oL=y({_meta:x(d(),E()).nullish(),document:sL.nullish()}),aL=y({_meta:x(d(),E()).nullish(),context:IP.nullish(),events:oL.nullish()}),lL=y({_meta:x(d(),E()).nullish(),auth:JR.optional().default({}),loadSession:Ie().optional().default(!1),mcpCapabilities:tP.optional().default({http:!1,sse:!1}),nes:aL.nullish(),positionEncoding:Ty.nullish(),promptCapabilities:WP.optional().default({audio:!1,embeddedContext:!1,image:!1}),sessionCapabilities:ND.optional().default({})}),cL=y({_meta:x(d(),E()).nullish(),agentCapabilities:lL.optional().default({auth:{},loadSession:!1,mcpCapabilities:{http:!1,sse:!1},promptCapabilities:{audio:!1,embeddedContext:!1,image:!1},sessionCapabilities:{}}),agentInfo:Ay.nullish(),authMethods:L(xR).optional().default([]),protocolVersion:Iy}),uL=y({_meta:x(d(),E()).nullish(),mimeType:d().nullish(),text:d(),uri:d()}),hL=B([uL,TR]),dL=y({_meta:x(d(),E()).nullish(),annotations:qo.nullish(),resource:hL}),fd=B([eL.and(y({type:$("text")})),eD.and(y({type:$("image")})),QP.and(y({type:$("audio")})),tD.and(y({type:$("resource_link")})),dL.and(y({type:$("resource")}))]),pL=y({_meta:x(d(),E()).nullish(),content:fd}),jc=y({_meta:x(d(),E()).nullish(),content:fd,messageId:d().nullish()}),fL=y({_meta:x(d(),E()).nullish(),messageId:d().nullish(),prompt:L(fd),sessionId:Q}),gL=y({anyOf:L(by)}),My=B([pL.and(y({type:$("content")})),LR.and(y({type:$("diff")})),KD.and(y({type:$("terminal")}))]),Ny=d(),Uy=y({_meta:x(d(),E()).nullish(),line:H().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:d()}),Fy=B([$("pending"),$("in_progress"),$("completed"),$("failed")]),Hy=B([$("read"),$("edit"),$("delete"),$("move"),$("search"),$("execute"),$("think"),$("fetch"),$("switch_mode"),$("other")]),mL=y({_meta:x(d(),E()).nullish(),content:L(My).optional(),kind:Hy.optional(),locations:L(Uy).optional(),rawInput:E().optional(),rawOutput:E().optional(),status:Fy.optional(),title:d(),toolCallId:Ny}),Wy=y({_meta:x(d(),E()).nullish(),content:L(My).nullish(),kind:Hy.nullish(),locations:L(Uy).nullish(),rawInput:E().optional(),rawOutput:E().optional(),status:Fy.nullish(),title:d().nullish(),toolCallId:Ny}),Zy=y({_meta:x(d(),E()).nullish(),options:L(DP),sessionId:Q,toolCall:Wy}),vL=y({_meta:x(d(),E()).nullish(),hint:d()}),yL=vL,bL=y({_meta:x(d(),E()).nullish(),description:d(),input:yL.nullish(),name:d()}),wL=y({_meta:x(d(),E()).nullish(),availableCommands:L(bL)}),SL=y({enum:L(d()),type:WR}),_L=B([SL,gL]),kL=y({default:L(d()).nullish(),description:d().nullish(),items:_L,maxItems:H().nullish(),minItems:H().nullish(),title:d().nullish()}),EL=B([qD.and(y({type:$("string")})),RP.and(y({type:$("number")})),qR.and(y({type:$("integer")})),IR.and(y({type:$("boolean")})),kL.and(y({type:$("array")}))]),xL=y({description:d().nullish(),properties:x(d(),EL).optional().default({}),required:L(d()).nullish(),title:d().nullish(),type:HR.optional().default("object")}),AL=y({requestedSchema:xL}),$L=jl(B([AL.and(y({mode:$("form")})),BR.and(y({mode:$("url")}))]),y({_meta:x(d(),E()).nullish(),message:d(),sessionId:Q})),TL=y({cachedReadTokens:H().nullish(),cachedWriteTokens:H().nullish(),inputTokens:H(),outputTokens:H(),thoughtTokens:H().nullish(),totalTokens:H()}),IL=y({_meta:x(d(),E()).nullish(),stopReason:jD,usage:TL.nullish(),userMessageId:d().nullish()});B([y({id:Or,result:B([cL,$R,eP,zD,LD,TD,DD,OD,RR,WD,FD,IL,VD,BD,XD,CR,Ey])}),y({error:Sy,id:Or})]);const CL=y({_meta:x(d(),E()).nullish(),cost:PR.nullish(),size:H(),used:H()}),RL=B([jc.and(y({sessionUpdate:$("user_message_chunk")})),jc.and(y({sessionUpdate:$("agent_message_chunk")})),jc.and(y({sessionUpdate:$("agent_thought_chunk")})),mL.and(y({sessionUpdate:$("tool_call")})),Wy.and(y({sessionUpdate:$("tool_call_update")})),MP.and(y({sessionUpdate:$("plan")})),wL.and(y({sessionUpdate:$("available_commands_update")})),RD.and(y({sessionUpdate:$("current_mode_update")})),pD.and(y({sessionUpdate:$("config_option_update")})),ID.and(y({sessionUpdate:$("session_info_update")})),CL.and(y({sessionUpdate:$("usage_update")}))]),Vy=y({_meta:x(d(),E()).nullish(),sessionId:Q,update:RL});y({method:d(),params:B([Vy,UR,_y]).nullish()});const By=y({_meta:x(d(),E()).nullish(),sessionId:Q,terminalId:d()}),PL=y({_meta:x(d(),E()).nullish(),exitCode:H().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:d().nullish()}),DL=y({name:d(),uri:d()}),LL=y({_meta:x(d(),E()).nullish(),repository:kP.nullish(),workspaceFolders:L(DL).nullish(),workspaceUri:d().nullish()});y({id:Or,method:d(),params:B([ZP,AR,QR,CP,ED,XR,kD,AD,yD,HD,UD,fL,ZD,LL,YD,vD,ky]).nullish()});const jy=y({_meta:x(d(),E()).nullish(),content:d(),path:d(),sessionId:Q});y({id:Or,method:d(),params:B([jy,Ly,Zy,Py,Oy,zy,By,Dy,$L,ky]).nullish()});const zL=y({_meta:x(d(),E()).nullish()});B([y({id:Or,result:B([zL,XP,iD,DR,QD,KP,PL,YR,FR,Ey])}),y({error:Sy,id:Or})]);var J;class OL{constructor(t,e){w(this,J);const r=t(this),i=async(o,a)=>{var c,u,h,p,v,m,_;switch(o){case cn.fs_write_text_file:{const k=jy.parse(a);return(c=r.writeTextFile)==null?void 0:c.call(r,k)}case cn.fs_read_text_file:{const k=Ly.parse(a);return(u=r.readTextFile)==null?void 0:u.call(r,k)}case cn.session_request_permission:{const k=Zy.parse(a);return r.requestPermission(k)}case cn.terminal_create:{const k=Py.parse(a);return(h=r.createTerminal)==null?void 0:h.call(r,k)}case cn.terminal_output:{const k=Oy.parse(a);return(p=r.terminalOutput)==null?void 0:p.call(r,k)}case cn.terminal_release:{const k=zy.parse(a);return await((v=r.releaseTerminal)==null?void 0:v.call(r,k))??{}}case cn.terminal_wait_for_exit:{const k=By.parse(a);return(m=r.waitForTerminalExit)==null?void 0:m.call(r,k)}case cn.terminal_kill:{const k=Dy.parse(a);return await((_=r.killTerminal)==null?void 0:_.call(r,k))??{}}default:if(r.extMethod)return r.extMethod(o,a);throw Ae.methodNotFound(o)}},s=async(o,a)=>{switch(o){case cn.session_update:{const c=Vy.parse(a);return r.sessionUpdate(c)}default:if(r.extNotification)return r.extNotification(o,a);throw Ae.methodNotFound(o)}};S(this,J,new ML(i,s,e))}async initialize(t){return await l(this,J).sendRequest(ue.initialize,t)}async newSession(t){return await l(this,J).sendRequest(ue.session_new,t)}async loadSession(t){return await l(this,J).sendRequest(ue.session_load,t)??{}}async unstable_forkSession(t){return await l(this,J).sendRequest(ue.session_fork,t)}async listSessions(t){return await l(this,J).sendRequest(ue.session_list,t)}async unstable_resumeSession(t){return await l(this,J).sendRequest(ue.session_resume,t)}async unstable_closeSession(t){return await l(this,J).sendRequest(ue.session_close,t)}async setSessionMode(t){return await l(this,J).sendRequest(ue.session_set_mode,t)??{}}async unstable_setSessionModel(t){return await l(this,J).sendRequest(ue.session_set_model,t)??{}}async setSessionConfigOption(t){return await l(this,J).sendRequest(ue.session_set_config_option,t)}async authenticate(t){return await l(this,J).sendRequest(ue.authenticate,t)??{}}async unstable_logout(t){return await l(this,J).sendRequest(ue.logout,t)??{}}async prompt(t){return await l(this,J).sendRequest(ue.session_prompt,t)}async cancel(t){return await l(this,J).sendNotification(ue.session_cancel,t)}async unstable_startNes(t){return await l(this,J).sendRequest(ue.nes_start,t)}async unstable_suggestNes(t){return await l(this,J).sendRequest(ue.nes_suggest,t)}async unstable_closeNes(t){return await l(this,J).sendRequest(ue.nes_close,t)??{}}async unstable_didOpenDocument(t){return await l(this,J).sendNotification(ue.document_did_open,t)}async unstable_didChangeDocument(t){return await l(this,J).sendNotification(ue.document_did_change,t)}async unstable_didCloseDocument(t){return await l(this,J).sendNotification(ue.document_did_close,t)}async unstable_didSaveDocument(t){return await l(this,J).sendNotification(ue.document_did_save,t)}async unstable_didFocusDocument(t){return await l(this,J).sendNotification(ue.document_did_focus,t)}async unstable_acceptNes(t){return await l(this,J).sendNotification(ue.nes_accept,t)}async unstable_rejectNes(t){return await l(this,J).sendNotification(ue.nes_reject,t)}async extMethod(t,e){return await l(this,J).sendRequest(t,e)}async extNotification(t,e){return await l(this,J).sendNotification(t,e)}get signal(){return l(this,J).signal}get closed(){return l(this,J).closed}}J=new WeakMap;var Dn,bl,Ks,Js,wi,Si,Ut,Qs,pe,Gy,Pu,qy,Yy,Xy,Ky,Du,xs;class ML{constructor(t,e,r){w(this,pe);w(this,Dn,new Map);w(this,bl,0);w(this,Ks);w(this,Js);w(this,wi);w(this,Si,Promise.resolve());w(this,Ut,new AbortController);w(this,Qs);S(this,Ks,t),S(this,Js,e),S(this,wi,r),S(this,Qs,new Promise(i=>{l(this,Ut).signal.addEventListener("abort",()=>i())})),f(this,pe,Gy).call(this)}get signal(){return l(this,Ut).signal}get closed(){return l(this,Qs)}async sendRequest(t,e){f(this,pe,Du).call(this);const r=ip(this,bl)._++,i=new Promise((s,o)=>{l(this,Dn).set(r,{resolve:s,reject:o})});return await f(this,pe,xs).call(this,{jsonrpc:"2.0",id:r,method:t,params:e}),i}async sendNotification(t,e){f(this,pe,Du).call(this),await f(this,pe,xs).call(this,{jsonrpc:"2.0",method:t,params:e})}}Dn=new WeakMap,bl=new WeakMap,Ks=new WeakMap,Js=new WeakMap,wi=new WeakMap,Si=new WeakMap,Ut=new WeakMap,Qs=new WeakMap,pe=new WeakSet,Gy=async function(){let t;try{const e=l(this,wi).readable.getReader();try{for(;!l(this,Ut).signal.aborted;){const{value:r,done:i}=await e.read();if(i)break;if(r)try{f(this,pe,qy).call(this,r)}catch(s){console.error("Unexpected error during message processing:",r,s),"id"in r&&r.id!==void 0&&f(this,pe,xs).call(this,{jsonrpc:"2.0",id:r.id,error:{code:-32700,message:"Parse error"}})}}}finally{e.releaseLock()}}catch(e){t=e}finally{f(this,pe,Pu).call(this,t)}},Pu=function(t){if(l(this,Ut).signal.aborted)return;const e=t??new Error("ACP connection closed");for(const r of l(this,Dn).values())r.reject(e);l(this,Dn).clear(),l(this,Ut).abort(e)},qy=async function(t){if("method"in t&&"id"in t){const e=await f(this,pe,Yy).call(this,t.method,t.params);"error"in e&&console.error("Error handling request",t,e.error),await f(this,pe,xs).call(this,{jsonrpc:"2.0",id:t.id,...e})}else if("method"in t){const e=await f(this,pe,Xy).call(this,t.method,t.params);"error"in e&&console.error("Error handling notification",t,e.error)}else"id"in t?f(this,pe,Ky).call(this,t):console.error("Invalid message",{message:t})},Yy=async function(t,e){try{return{result:await l(this,Ks).call(this,t,e)??null}}catch(r){if(r instanceof Ae)return r.toResult();if(r instanceof tg)return Ae.invalidParams(r.format()).toResult();let i;(r instanceof Error||typeof r=="object"&&r!=null&&"message"in r&&typeof r.message=="string")&&(i=r.message);try{return Ae.internalError(i?JSON.parse(i):{}).toResult()}catch{return Ae.internalError({details:i}).toResult()}}},Xy=async function(t,e){try{return await l(this,Js).call(this,t,e),{result:null}}catch(r){if(r instanceof Ae)return r.toResult();if(r instanceof tg)return Ae.invalidParams(r.format()).toResult();let i;(r instanceof Error||typeof r=="object"&&r!=null&&"message"in r&&typeof r.message=="string")&&(i=r.message);try{return Ae.internalError(i?JSON.parse(i):{}).toResult()}catch{return Ae.internalError({details:i}).toResult()}}},Ky=function(t){const e=l(this,Dn).get(t.id);if(e){if("result"in t)e.resolve(t.result);else if("error"in t){const{code:r,message:i,data:s}=t.error;e.reject(new Ae(r,i,s))}l(this,Dn).delete(t.id)}else console.error("Got response to unknown request",t.id)},Du=function(){if(l(this,Ut).signal.aborted)throw l(this,Ut).signal.reason??new Error("ACP connection closed")},xs=async function(t){return S(this,Si,l(this,Si).then(async()=>{const e=l(this,wi).writable.getWriter();try{await e.write(t)}finally{e.releaseLock()}}).catch(e=>{f(this,pe,Pu).call(this,e)})),l(this,Si)};class Ae extends Error{constructor(e,r,i){super(r);g(this,"code");g(this,"data");this.code=e,this.name="RequestError",this.data=i}static parseError(e,r){return new Ae(-32700,`Parse error${r?`: ${r}`:""}`,e)}static invalidRequest(e,r){return new Ae(-32600,`Invalid request${r?`: ${r}`:""}`,e)}static methodNotFound(e){return new Ae(-32601,`"Method not found": ${e}`,{method:e})}static invalidParams(e,r){return new Ae(-32602,`Invalid params${r?`: ${r}`:""}`,e)}static internalError(e,r){return new Ae(-32603,`Internal error${r?`: ${r}`:""}`,e)}static authRequired(e,r){return new Ae(-32e3,`Authentication required${r?`: ${r}`:""}`,e)}static resourceNotFound(e){return new Ae(-32002,`Resource not found${e?`: ${e}`:""}`,e&&{uri:e})}toResult(){return{error:{code:this.code,message:this.message,data:this.data}}}toErrorResponse(){return{code:this.code,message:this.message,data:this.data}}}const NL=/^Sender \(untrusted metadata\):\n```json\n[\s\S]*?\n```\n\n?/,UL=/^\[[^\n]*Working directory:[^\n]*\]\n\n?/,FL=/\[Television screen context\][\s\S]*?\[\/Television screen context\]\n*/,HL=/\b(tv|television|screen|artifact|artifacts|viewer|filmstrip|layout|focus)\b/i,WL=/\[\[\s*(?:reply_to_current|reply_to\s*:\s*[^\]\n]+|audio_as_voice)\s*\]\]\s*/gi,ZL="single_session",VL={name:"television-acp-client",version:"0.0.0"},Jy="agent:main:television",BL=Go(tn);var _i,Ft,ot,Ht,Ln,St,fn,Wt,Zt,zn,_t,ki,Ei,Vt,Be,gn,xi,kr,mn,On,eo,kt,Bt,wl,jt,I,Lu,Qy,eb,tb,Da,nb,rb,ib,sb,ob,ab,lb,lr,ai,li,un,cb,ci,zu,Ou,La,ub,za,Mu,Nu,to,no,Oa,ui,Uu,hb;class jL extends BL{constructor(e){super();w(this,I);w(this,_i,"disconnected");w(this,Ft,null);w(this,ot,new Map);w(this,Ht,null);w(this,Ln,null);w(this,St,null);w(this,fn,null);w(this,Wt,null);w(this,Zt,null);w(this,zn);w(this,_t,null);w(this,ki,0);w(this,Ei,1);w(this,Vt,null);w(this,Be,null);w(this,gn,!1);w(this,xi,!1);w(this,kr,!1);w(this,mn,null);w(this,On,new Set);w(this,eo);w(this,kt);w(this,Bt);w(this,wl,e=>{f(this,I,eb).call(this,e)});w(this,jt,null);w(this,to,()=>{f(this,I,ui).call(this,"ACP bridge websocket closed")});w(this,no,()=>{f(this,I,ui).call(this,"ACP bridge websocket error")});S(this,kt,e),S(this,Bt,e.sessionMode??ZL),S(this,zn,e.mappedSessionStore??GL()),S(this,eo,e.createSocket??(r=>new WebSocket(r)))}get status(){return l(this,_i)}get messages(){return[...l(this,ot).values()]}get enabled(){return l(this,kt).enabled??!1}setToken(e){l(this,kt).token=e??""}setEnabled(e){l(this,kt).enabled=e,e||(f(this,I,Oa).call(this),S(this,Ft,null),f(this,I,un).call(this,"disconnected"))}async connect(){if(this.disposed)throw new Error("ACPClient has been disposed");if(this.enabled&&this.status==="disconnected"){l(this,Ln)===null&&(S(this,Ft,null),S(this,Ln,f(this,I,Qy).call(this)));try{await l(this,Ln),await f(this,I,Da).call(this)}catch(e){throw f(this,I,ui).call(this,Gc(e)),e}}}dispose(){f(this,I,Oa).call(this),S(this,Ft,null),f(this,I,un).call(this,"disposed")}async sendMessage(e){if(await this.connect(),(this.status==="running"||this.status==="cancelling")&&(await this.cancel(),await f(this,I,Lu).call(this,"ready")),(l(this,Wt)===null||l(this,_t)!==f(this,I,za).call(this))&&await f(this,I,Da).call(this),this.status!=="ready")throw new Error("ACPClient is not ready to send a new message");const r=e.text.trim();if(!r)throw new Error("Cannot send an empty message");f(this,I,ai).call(this,{id:f(this,I,ci).call(this,"user"),kind:"user",text:r,status:"final"}),f(this,I,un).call(this,"running");try{const i=await f(this,I,La).call(this).prompt({sessionId:f(this,I,Ou).call(this),prompt:[{type:"text",text:f(this,I,cb).call(this,r)}]});f(this,I,lr).call(this,i.stopReason==="cancelled"?"cancelled":"final"),f(this,I,un).call(this,"ready")}catch(i){throw f(this,I,hb).call(this)||(f(this,I,lr).call(this,"error"),f(this,I,un).call(this,"ready")),i}}async startNewSession(){var r;await this.connect(),(this.status==="running"||this.status==="cancelling")&&(await this.cancel(),await f(this,I,Lu).call(this,"ready"));const e=f(this,I,za).call(this);((r=l(this,Zt))==null?void 0:r.sessionIdStrategy)==="mapped"?l(this,zn).clearActualSessionId(e):S(this,ki,l(this,ki)+1),S(this,St,null),S(this,fn,null),S(this,Wt,null),S(this,_t,null),f(this,I,Uu).call(this)}async cancel(){this.status==="running"&&(f(this,I,un).call(this,"cancelling"),await f(this,I,La).call(this).cancel({sessionId:f(this,I,Ou).call(this)}))}setScreenContext(e){var s,o,a;if(e===null){if(l(this,Be)===null)return;S(this,Be,null),S(this,gn,!1);return}const r={screenID:e.screenID,screenName:e.screenName};if(((s=l(this,Be))==null?void 0:s.screenID)===r.screenID&&((o=l(this,Be))==null?void 0:o.screenName)===r.screenName)return;const i=((a=l(this,Be))==null?void 0:a.screenID)??null;if(S(this,Be,r),l(this,Bt)==="single_session"){(!l(this,_t)||i!==r.screenID)&&S(this,gn,!0);return}l(this,_t)!==f(this,I,Mu).call(this,r.screenID)&&(S(this,St,null),S(this,fn,null),l(this,Ht)&&this.status==="ready"&&f(this,I,Da).call(this).catch(c=>{f(this,I,ui).call(this,Gc(c))}))}}_i=new WeakMap,Ft=new WeakMap,ot=new WeakMap,Ht=new WeakMap,Ln=new WeakMap,St=new WeakMap,fn=new WeakMap,Wt=new WeakMap,Zt=new WeakMap,zn=new WeakMap,_t=new WeakMap,ki=new WeakMap,Ei=new WeakMap,Vt=new WeakMap,Be=new WeakMap,gn=new WeakMap,xi=new WeakMap,kr=new WeakMap,mn=new WeakMap,On=new WeakMap,eo=new WeakMap,kt=new WeakMap,Bt=new WeakMap,wl=new WeakMap,jt=new WeakMap,I=new WeakSet,Lu=async function(e){if(this.status!==e){if(this.status==="disposed")throw new Error("ACPClient has been disposed");if(this.status==="disconnected")throw new Error(l(this,Ft)??"ACPClient is disconnected");await new Promise((r,i)=>{const s=()=>{this.removeEventListener("status-changed",o)},o=()=>{if(this.status===e){s(),r();return}if(this.status==="disposed"){s(),i(new Error("ACPClient has been disposed"));return}this.status==="disconnected"&&(s(),i(new Error(l(this,Ft)??"ACPClient is disconnected")))};this.addEventListener("status-changed",o)})}},Qy=async function(){try{const{stream:e,socket:r,metadata:i}=await KL({serverURL:l(this,kt).serverURL,token:l(this,kt).token,createSocket:l(this,eo),onDisconnect:l(this,wl)});S(this,Zt,i),S(this,jt,r),r.addEventListener("close",l(this,to)),r.addEventListener("error",l(this,no)),S(this,Ht,new OL(s=>({connection:s,sessionUpdate:async o=>{await f(this,I,rb).call(this,o)},requestPermission:async o=>f(this,I,ib).call(this,o)}),e)),await l(this,Ht).initialize({protocolVersion:bR,clientCapabilities:{},clientInfo:VL})}catch(e){throw e}},eb=function(e){f(this,I,ui).call(this,Gc(e))},tb=function(e){const r=e==null?void 0:e.models;if(!(r!=null&&r.currentModelId))return;const i=r.availableModels.find(s=>s.modelId===r.currentModelId);console.info("[ACPClient] Current model:",(i==null?void 0:i.name)??r.currentModelId,`(${r.currentModelId})`)},Da=async function(){const e=f(this,I,za).call(this);if(l(this,St)&&l(this,fn)===e){await l(this,St);return}S(this,fn,e),S(this,St,f(this,I,nb).call(this,e)),await l(this,St)},nb=async function(e){var c;const r=f(this,I,La).call(this);f(this,I,Uu).call(this);let i,s=!1,o=null;const a={cwd:f(this,I,ub).call(this),mcpServers:[],_meta:{sessionKey:e}};try{if(S(this,kr,!0),S(this,mn,null),((c=l(this,Zt))==null?void 0:c.sessionIdStrategy)==="mapped"){const u=l(this,zn).getActualSessionId(e);if(u)try{const h=await r.loadSession({...a,sessionId:u});if(qL(h))throw new Error("Mapped ACP session was not found");o=h,i=u,s=!0}catch{const h=await r.newSession(a);o=h,i=h.sessionId,l(this,zn).setActualSessionId(e,i),s=!1}else{const h=await r.newSession(a);o=h,i=h.sessionId,l(this,zn).setActualSessionId(e,i),s=!1}}else try{o=await r.loadSession({...a,sessionId:e}),i=e,s=l(this,ot).size>0}catch{const u=await r.newSession(a);o=u,i=u.sessionId,s=!1}}finally{S(this,kr,!1),S(this,mn,null),f(this,I,lr).call(this,"final")}f(this,I,tb).call(this,o),await r.setSessionConfigOption({sessionId:i,configId:"verbose_level",value:"full"}),S(this,Wt,i),S(this,_t,e),S(this,xi,!0),s?(l(this,On).add(e),l(this,Bt)==="single_session"&&S(this,gn,!1)):(l(this,On).delete(e),S(this,gn,l(this,Bt)==="single_session")),S(this,Ft,null),f(this,I,un).call(this,"ready")},rb=async function(e){const r=e.update;switch(r.sessionUpdate){case"user_message_chunk":r.content.type==="text"&&f(this,I,lb).call(this,r.content.text);return;case"agent_message_chunk":r.content.type==="text"&&f(this,I,sb).call(this,r.content.text);return;case"tool_call":f(this,I,ob).call(this,r);return;case"tool_call_update":f(this,I,ab).call(this,r);return;case"agent_thought_chunk":return;default:return}},ib=async function(e){return{outcome:{outcome:"cancelled"}}},sb=function(e){S(this,mn,null);const r=XL(e);if(!r)return;if(!l(this,Vt)){const s={id:f(this,I,ci).call(this,"assistant"),kind:"assistant",text:r,status:"streaming"};S(this,Vt,s.id),f(this,I,ai).call(this,s);return}const i=l(this,ot).get(l(this,Vt));if(!i||i.kind!=="assistant")throw new Error("Open assistant message invariant violated");f(this,I,li).call(this,{...i,text:`${i.text}${r}`,status:"streaming"})},ob=function(e){f(this,I,lr).call(this,"final");const r=f(this,I,zu).call(this,e.toolCallId),i=lg("content"in e?e.content:void 0),s={id:(r==null?void 0:r.id)??f(this,I,ci).call(this,"tool"),kind:"tool_call",toolCallId:e.toolCallId,title:e.title,toolKind:e.kind??"other",status:e.status==="failed"?"failed":e.status==="completed"?"completed":"in_progress",text:(r==null?void 0:r.text)??i,locations:e.locations??(r==null?void 0:r.locations)};if(r){f(this,I,li).call(this,s);return}f(this,I,ai).call(this,s)},ab=function(e){const r=f(this,I,zu).call(this,e.toolCallId),i=(r==null?void 0:r.text)??"",s=lg(e.content),o=s?`${i}${s}`:i,a={id:(r==null?void 0:r.id)??f(this,I,ci).call(this,"tool"),kind:"tool_call",toolCallId:e.toolCallId,title:(r==null?void 0:r.title)??e.toolCallId,toolKind:(r==null?void 0:r.toolKind)??"other",status:e.status==="failed"?"failed":e.status==="completed"?"completed":"in_progress",text:o,locations:e.locations??(r==null?void 0:r.locations)};if(r){f(this,I,li).call(this,a);return}f(this,I,ai).call(this,a)},lb=function(e){if(f(this,I,lr).call(this,"final"),!e)return;const r=l(this,kr)?l(this,mn):null;if(!r){const s=ag(e);if(!s)return;const o={id:f(this,I,ci).call(this,"user"),kind:"user",text:s,status:"final"};f(this,I,ai).call(this,o),l(this,kr)&&S(this,mn,o.id);return}const i=l(this,ot).get(r);if(!i||i.kind!=="user")throw new Error("Replay user message invariant violated");f(this,I,li).call(this,{...i,text:ag(`${i.text}${e}`)})},lr=function(e){if(!l(this,Vt))return;const r=l(this,ot).get(l(this,Vt));(r==null?void 0:r.kind)==="assistant"&&f(this,I,li).call(this,{...r,status:e}),S(this,Vt,null)},ai=function(e){l(this,ot).set(e.id,e),this.dispatchEvent(new Wc("messages-changed"))},li=function(e){l(this,ot).set(e.id,e),this.dispatchEvent(new Wc("messages-changed"))},un=function(e){l(this,_i)!==e&&(S(this,_i,e),this.dispatchEvent(new VA("status-changed")))},cb=function(e){const r=l(this,_t);if(!r)return e;const i=l(this,Be)?l(this,Bt)==="single_session"?l(this,gn)||!l(this,On).has(r):!l(this,On).has(r):!1,s=l(this,xi)&&(l(this,Be)!==null||HL.test(e));if(!(s||i))return e;s&&S(this,xi,!1),i&&(S(this,gn,!1),l(this,On).add(r));const a=["[Television screen context]","This chat session is coming from a Television client.","Using Television requires the knowledge in the `television` skill. Re-read it only if it is not already in context or you know it changed.","If the skill is not installed, it can be installed via `tv skills install <your agent skills path>`."];return l(this,Be)?(a.push("This conversation is currently attached to the screen below."),a.push(`screen_id: ${l(this,Be).screenID}`),a.push(`screen_name: ${l(this,Be).screenName??""}`),a.push("When the user asks to inspect or change Television state with the tv CLI, use this screen ID with the --screen argument.")):a.push("There is currently no active Television screen."),a.push("[/Television screen context]","",e),a.join(`
|
|
43
|
-
`)},ci=function(e){const r=`${e}-${l(this,Ei)}`;return S(this,Ei,l(this,Ei)+1),r},zu=function(e){for(const r of l(this,ot).values())if((r==null?void 0:r.kind)==="tool_call"&&r.toolCallId===e)return r;return null},Ou=function(){if(!l(this,Wt))throw new Error("ACP session is not ready");return l(this,Wt)},La=function(){if(!l(this,Ht))throw new Error("ACP connection is not ready");return l(this,Ht)},ub=function(){var r;const e=(r=l(this,Zt))==null?void 0:r.sessionCwd;if(!e)throw new Error("ACP bridge session cwd is not ready");return e},za=function(){var r;if(l(this,Bt)==="single_session")return f(this,I,Nu).call(this,`${Jy}-${(l(this,kt).clientGUID??"default-client").toLowerCase()}`);const e=(r=l(this,Be))==null?void 0:r.screenID;if(!e)throw new Error("Screen context is required for per-screen session mode");return f(this,I,Mu).call(this,e)},Mu=function(e){return f(this,I,Nu).call(this,YL(l(this,Bt),e,l(this,kt).clientGUID??"default-client"))},Nu=function(e){var r;return((r=l(this,Zt))==null?void 0:r.sessionIdStrategy)==="deterministic"&&l(this,ki)>0?`${e}:epoch-${l(this,ki)}`:e},to=new WeakMap,no=new WeakMap,Oa=function(){S(this,Ht,null),S(this,Ln,null),S(this,St,null),S(this,fn,null),S(this,Wt,null),S(this,_t,null),S(this,Zt,null),l(this,jt)&&(l(this,jt).removeEventListener("close",l(this,to)),l(this,jt).removeEventListener("error",l(this,no)),l(this,jt).close(),S(this,jt,null))},ui=function(e){const r=l(this,Ht)!==null||l(this,Ln)!==null||l(this,St)!==null||l(this,fn)!==null||l(this,Wt)!==null||l(this,_t)!==null||l(this,Zt)!==null||l(this,jt)!==null;this.disposed||this.status==="disconnected"&&!r||(f(this,I,lr).call(this,"error"),f(this,I,Oa).call(this),S(this,Ft,e??null),f(this,I,un).call(this,"disconnected"))},Uu=function(){const e=l(this,ot).size>0;S(this,Vt,null),S(this,mn,null),S(this,Ei,1),l(this,ot).clear(),e&&this.dispatchEvent(new Wc("messages-changed"))},hb=function(){return this.status==="disconnected"};function GL(){const n=new Map;return{getActualSessionId(t){return n.get(t)??null},setActualSessionId(t,e){n.set(t,e)},clearActualSessionId(t){n.delete(t)}}}function qL(n){return n==null?!0:typeof n=="object"&&Object.keys(n).length===0}function YL(n,t,e){return n==="single_session"?`${Jy}-${e.toLowerCase()}`:`agent:main:television-${e.toLowerCase()}-${t.toLowerCase()}`}function db(n){return n.replace(/^(?:\s*\n)+/,"")}function ag(n){let t=n;return t=t.replace(NL,""),t=t.replace(UL,""),t=t.replace(FL,""),t=db(t),t}function XL(n){let t=n;return t=t.replace(WL,""),t=db(t),t}function lg(n){return!n||n.length===0?"":n.flatMap(t=>t.type==="content"&&t.content.type==="text"?[t.content.text]:[]).join("")}async function KL(n){const t=n.createSocket(e2(n.serverURL,n.token));let e=!1,r,i;const s=new Promise((u,h)=>{r=u,i=h}),o=new ReadableStream({start(u){let h=!1;const p=()=>{t.send(JSON.stringify({type:"acp-bridge-connect"}))},v=k=>{const T=QL(k);if(!T)return;let P;try{P=JSON.parse(T)}catch(R){const W=R instanceof Error?R:new Error(String(R));i(W),u.error(W);return}switch(P.type){case"acp-bridge-status":if(P.status==="ready"){let R;try{R=JL(P)}catch(W){const N=W instanceof Error?W:new Error(String(W));e||i(N),u.error(N);return}e||(e=!0,r(R));return}if(P.status==="error"||P.status==="exited"){const R=new Error(P.error??`ACP bridge ${P.status}`);e||i(R),u.error(R)}return;case"acp-bridge-message":u.enqueue(P.message);return}},m=()=>{var T;if(h)return;h=!0;const k=new Error("ACP bridge websocket closed");e||i(k),(T=n.onDisconnect)==null||T.call(n,k),u.close()},_=()=>{var T;if(h)return;h=!0;const k=new Error("ACP bridge websocket error");e||i(k),(T=n.onDisconnect)==null||T.call(n,k),u.error(k)};t.addEventListener("open",p),t.addEventListener("message",v),t.addEventListener("close",m),t.addEventListener("error",_)}}),a=new WritableStream({async write(u){await s,t.send(JSON.stringify({type:"acp-bridge-message",message:u}))},close(){t.close()},abort(){t.close()}}),c=await s;return{stream:{readable:o,writable:a},socket:t,metadata:c}}function JL(n){const{agent:t,sessionIdStrategy:e,sessionCwd:r}=n;if((t==="openclaw"||t==="hermes")&&(e==="deterministic"||e==="mapped")&&typeof r=="string"&&r.length>0)return{agent:t,sessionIdStrategy:e,sessionCwd:r};throw new Error("ACP bridge ready status missing bootstrap metadata")}function QL(n){if(typeof n=="string")return n;if(n instanceof Uint8Array)return new TextDecoder().decode(n);if(typeof Buffer<"u"&&n instanceof Buffer)return n.toString("utf8");if(typeof n=="object"&&n!==null&&"data"in n){const t=n.data;if(typeof t=="string")return t;if(t instanceof Uint8Array)return new TextDecoder().decode(t);if(Array.isArray(t))return Buffer.concat(t).toString("utf8")}return null}function e2(n,t){const e=new URL(n);return e.protocol=e.protocol==="https:"?"wss:":"ws:",e.pathname="/acp",e.search="",e.searchParams.set("token",t),e.hash="",e.toString()}function Gc(n){return n instanceof Error?n.message:String(n)}const cg="television.acpClientGUID",ug="television.acpMappedSessions",hg=1;var Ai;class t2{constructor(){w(this,Ai,new Map)}getActualSessionId(t){return l(this,Ai).get(t)??null}setActualSessionId(t,e){l(this,Ai).set(t,e)}clearActualSessionId(t){l(this,Ai).delete(t)}}Ai=new WeakMap;var $i,ro,lt,Ma,Na,Fu;class n2{constructor(t,e){w(this,lt);w(this,$i);w(this,ro);S(this,$i,t),S(this,ro,e)}getActualSessionId(t){const e=f(this,lt,Na).call(this)[f(this,lt,Ma).call(this,t)];return typeof e=="string"&&e.length>0?e:null}setActualSessionId(t,e){const r=f(this,lt,Na).call(this);r[f(this,lt,Ma).call(this,t)]=e,f(this,lt,Fu).call(this,r)}clearActualSessionId(t){const e=f(this,lt,Na).call(this);delete e[f(this,lt,Ma).call(this,t)],f(this,lt,Fu).call(this,e)}}$i=new WeakMap,ro=new WeakMap,lt=new WeakSet,Ma=function(t){return JSON.stringify([l(this,ro),t])},Na=function(){const t=l(this,$i).getItem(ug);if(!t)return{};let e;try{e=JSON.parse(t)}catch{return{}}if(typeof e!="object"||e===null||Array.isArray(e))return{};const r=e;return r.version!==hg?{}:typeof r.entries!="object"||r.entries===null||Array.isArray(r.entries)?{}:Object.fromEntries(Object.entries(r.entries).filter(i=>typeof i[1]=="string"))},Fu=function(t){const e={version:hg,entries:t};l(this,$i).setItem(ug,JSON.stringify(e))};function r2(){return typeof window>"u"?null:window.localStorage}function i2(n){const t=n.getItem(cg);if(t)return t;const e=Wl().toLowerCase();return n.setItem(cg,e),e}const dg=4401,s2=401,ya=1e3,o2=3e4;class zs extends Error{constructor(t="Authentication required"){super(t),this.name="AuthError"}}class pb extends tn{constructor(e){var i,s;super();g(this,"url");g(this,"name");g(this,"status","unauthorized");g(this,"screens",new Map);g(this,"views",[]);g(this,"client");g(this,"acpClient");g(this,"_token");g(this,"attempting",!1);g(this,"nextRetryAt",null);g(this,"hasEverConnected",!1);g(this,"createSocket");g(this,"createClient");g(this,"socket",null);g(this,"connectAttempt",0);g(this,"autoReconnect",!1);g(this,"retryTimer",null);g(this,"retryDelay",ya);g(this,"visibilityEventTarget");g(this,"networkEventTarget");g(this,"onVisibilityChange");g(this,"onNetworkOnline");this.url=be(e.url),this.name=e.name,this._token=e.token??null,this.createSocket=e.createSocket??(o=>new WebSocket(o)),this.createClient=e.createClient??((o,a)=>new S1(o,{token:a??void 0})),this.client=this.createClient(this.url,this._token);const r=e.mappedSessionStore??(e.acpStorage?new n2(e.acpStorage,this.url):new t2);this.acpClient=new jL({serverURL:this.url,token:this._token??"",...e.createACPSocket?{createSocket:e.createACPSocket}:e.createSocket?{createSocket:e.createSocket}:{},...e.clientGUID?{clientGUID:e.clientGUID}:{},mappedSessionStore:r}),this.visibilityEventTarget=e.visibilityEventTarget!==void 0?e.visibilityEventTarget:typeof document<"u"?document:null,this.networkEventTarget=e.networkEventTarget!==void 0?e.networkEventTarget:typeof window<"u"?window:null,this.onVisibilityChange=()=>{this.isPageVisible()&&this.kickReconnect()},this.onNetworkOnline=()=>{this.kickReconnect()},(i=this.visibilityEventTarget)==null||i.addEventListener("visibilitychange",this.onVisibilityChange),(s=this.networkEventTarget)==null||s.addEventListener("online",this.onNetworkOnline)}get token(){return this._token}async connect(e){this._token=e,this.acpClient.setToken(e),this.cancelRetryTimer(),this.retryDelay=ya,this.autoReconnect=!0,await this.attempt()}dispose(){var e,r,i;this.autoReconnect=!1,this.connectAttempt+=1,this.cancelRetryTimer(),(e=this.socket)==null||e.close(),this.socket=null,this.setStatus("unauthorized"),(r=this.visibilityEventTarget)==null||r.removeEventListener("visibilitychange",this.onVisibilityChange),(i=this.networkEventTarget)==null||i.removeEventListener("online",this.onNetworkOnline),this.acpClient.dispose()}getViewURL(e){const r=yR(e.kind,this.views);if(!r)return null;const i=`${this.url}/views/${encodeURIComponent(r.id)}/`;return this._token===null?i:`${i}?token=${encodeURIComponent(this._token)}`}getContentURL(e){if(e.kind==="url")return null;const r=`${this.url}/artifacts/${encodeURIComponent(e.id)}/content/`;return this._token===null?r:`${r}?token=${encodeURIComponent(this._token)}`}async createScreen(e){const{screen:r}=await this.client.screens.create({name:e});return this.screens.set(r.id,structuredClone(r)),r}applyServerEvent(e){switch(e.type){case"screen-created":this.screens.set(e.screen.id,structuredClone(e.screen)),this.dispatchEvent(new Ra("screens-changed"));break;case"screen-updated":this.screens.set(e.screen.id,structuredClone(e.screen)),this.dispatchEvent(new Ra("screens-changed"));break;case"screen-removed":this.screens.delete(e.screenID),this.dispatchEvent(new Ra("screens-changed"));break;case"artifact-created":break;case"artifact-attached":{const r=this.screens.get(e.screenID);r&&!Av(r.layout,e.artifact.id)&&(r.layout=[...r.layout,xv(e.artifact.id,{id:e.cardID})]);break}case"artifact-removed":{const r=this.screens.get(e.screenID);r&&(r.layout=mv(r.layout,e.artifactID));break}case"artifact-updated":case"artifact-content-changed":case"screen-changed":case"theme-changed":case"artifact-focus":break;default:return a2(e,"server event")}}async attempt(){var i;this.attempting=!0,this.nextRetryAt=null,this.connectAttempt+=1;const e=this.connectAttempt;(i=this.socket)==null||i.close(),this.client=this.createClient(this.url,this._token),this.setStatus("disconnected"),this.dispatchEvent(new ae("change"));const r=this.createSocket(l2(this.url,this._token));return this.socket=r,await new Promise((s,o)=>{let a=!1;const c=()=>{a||this.connectAttempt!==e||(a=!0,this.retryDelay=ya,this.hasEverConnected=!0,this.setStatus("connected"),s())},u=p=>{a||this.connectAttempt!==e||(a=!0,o(p))},h=async()=>{try{const[{screens:p},v,m]=await Promise.all([this.client.screens.list(),this.client.views.list(),this.client.display.get()]);this.screens=new Map(p.map(_=>[_.id,structuredClone(_)])),this.views=v,this.acpClient.setEnabled(m.acpEnabled),this.dispatchEvent(new ae("change")),this.dispatchEvent(new Eu("server-event",{serverURL:this.url,event:{type:"screen-changed",screenID:m.activeScreenID}})),c()}catch(p){if(h2(p)){u(new zs);return}u(p instanceof Error?p:new Error(String(p)))}};r.addEventListener("open",()=>{h()}),r.addEventListener("message",p=>{const v=u2(p);v&&(this.applyServerEvent(v),this.dispatchEvent(new Eu("server-event",{serverURL:this.url,event:v})))}),r.addEventListener("close",p=>{if(this.connectAttempt!==e)return;this.socket=null;const v=c2(p);if(!a){u(v===dg?new zs:new Error("Connection closed before initialization"));return}if(v===dg){this.autoReconnect=!1,this.cancelRetryTimer(),this.setStatus("unauthorized");return}this.handleTransportFailure(new Error("Connection closed"))}),r.addEventListener("error",()=>{if(this.connectAttempt===e){if(a){this.handleTransportFailure(new Error("WebSocket error"));return}u(new Error("WebSocket connection failed"))}})}).then(()=>{this.attempting=!1},s=>{throw this.attempting=!1,this.handleAttemptFailure(s),s})}handleAttemptFailure(e){if(e instanceof zs){this.autoReconnect=!1,this.cancelRetryTimer(),this.setStatus("unauthorized");return}this.autoReconnect&&this.scheduleRetry()}handleTransportFailure(e){this.autoReconnect&&(this.setStatus("disconnected"),this.scheduleRetry())}scheduleRetry(){this.cancelRetryTimer(),this.connectAttempt+=1;const e=this.retryDelay;this.retryDelay=Math.min(this.retryDelay*2,o2),this.nextRetryAt=Date.now()+e,this.retryTimer=setTimeout(()=>{this.retryTimer=null,this.attempt().catch(()=>{})},e),this.dispatchEvent(new ae("change"))}cancelRetryTimer(){this.retryTimer!==null&&(clearTimeout(this.retryTimer),this.retryTimer=null),this.nextRetryAt!==null&&(this.nextRetryAt=null,this.dispatchEvent(new ae("change")))}kickReconnect(){this.autoReconnect&&this.status!=="connected"&&(this.attempting||(this.cancelRetryTimer(),this.retryDelay=ya,this.attempt().catch(()=>{})))}setStatus(e){this.status!==e&&(this.status=e,this.dispatchEvent(new ae("change")))}isPageVisible(){return this.visibilityEventTarget===null?!0:this.visibilityEventTarget.visibilityState==="visible"}}function a2(n,t){throw new Error(`Unexpected ${t}: ${JSON.stringify(n)}`)}function l2(n,t){const e=new URL(n);return e.protocol=e.protocol==="https:"?"wss:":"ws:",e.pathname="/events",e.search="",t&&e.searchParams.set("token",t),e.hash="",e.toString()}function c2(n){return typeof n=="object"&&n!==null&&"code"in n&&typeof n.code=="number"?n.code:null}function u2(n){const t=typeof n=="string"?n:typeof n=="object"&&n!==null&&"data"in n&&typeof n.data=="string"?n.data:"";if(!t)return null;try{return JSON.parse(t)}catch{return null}}function h2(n){return n instanceof Iv&&n.status===s2}const d2="Local";var io,Hu;class p2 extends tn{constructor(e){super();w(this,io);g(this,"servers",new Map);g(this,"localServerURL");g(this,"clientGUID");g(this,"acpStorage");g(this,"localStore");g(this,"createSocket");g(this,"lastActiveServerURL");g(this,"serverListeners",new Map);g(this,"handleLocalStoreChange",()=>{const e=this.localStore.get().activeServerURL;e!==this.lastActiveServerURL&&(this.lastActiveServerURL=e,this.dispatchEvent(new ae("change")))});this.localStore=e.localStore,this.localServerURL=e.localServerURL?be(e.localServerURL):null,this.createSocket=e.createSocket??(i=>new WebSocket(i)),this.lastActiveServerURL=this.localStore.get().activeServerURL;const r=e.acpStorage===void 0?r2():e.acpStorage;this.acpStorage=r,this.clientGUID=e.clientGUID??(r?i2(r):Wl().toLowerCase()),this.localStore.addEventListener("change",this.handleLocalStoreChange)}get activeServer(){const e=this.localStore.get().activeServerURL;return e===null?null:this.servers.get(e)??null}add(e){const r=be(e.url);this.servers.get(r)&&this.remove(r),this.servers.set(r,e);const s=()=>{this.dispatchEvent(new ae("change"))},o=c=>{this.dispatchEvent(new Eu("server-event",{serverURL:c.serverURL,event:c.event}))},a=()=>{this.dispatchEvent(new Ra("screens-changed"))};e.addEventListener("change",s),e.addEventListener("server-event",o),e.addEventListener("screens-changed",a),this.serverListeners.set(r,{onServerChange:s,onServerEvent:o,onScreensChanged:a}),this.dispatchEvent(new ae("change"))}remove(e){const r=be(e);if(this.localServerURL&&r===this.localServerURL)return;const i=this.servers.get(r);if(!i)return;const s=this.serverListeners.get(r);s&&(i.removeEventListener("change",s.onServerChange),i.removeEventListener("server-event",s.onServerEvent),i.removeEventListener("screens-changed",s.onScreensChanged),this.serverListeners.delete(r)),i.dispose(),this.servers.delete(r);const o=this.localStore.get(),a=o.activeServerURL===r;this.localStore.set({...o,servers:o.servers.filter(c=>c.url!==r),activeServerURL:a?null:o.activeServerURL}),this.dispatchEvent(new ae("change"))}setActive(e){const r=this.localStore.get(),i=e?be(e.url):null;r.activeServerURL!==i&&this.localStore.set({...r,activeServerURL:i})}connectConfiguredServers(e,r){const i=e?be(e):null;if(i){const a=this.localStore.get();a.servers.some(u=>be(u.url)===i)||this.localStore.set({...a,servers:[...a.servers,{url:i,name:d2}]})}const s=this.localStore.get().servers;for(const a of s){const c=be(a.url),h=i!==null&&c===i?r??null:null,p=f(this,io,Hu).call(this,{url:a.url,name:a.name,token:h});this.add(p),p.connect(h).catch(()=>{})}const o=i?this.servers.get(i)??null:null;this.setActive(o??this.servers.values().next().value??null)}addServer(e,r){const i=be(e);this.remove(i);const s=this.localStore.get();this.localStore.set({...s,servers:[...s.servers.filter(a=>be(a.url)!==i),{url:i,name:r}]});const o=f(this,io,Hu).call(this,{url:i,name:r,token:null});this.add(o),this.setActive(o),o.connect(null).catch(()=>{})}removeServer(e){this.remove(e)}}io=new WeakSet,Hu=function(e){return new pb({url:e.url,name:e.name,token:e.token,createSocket:this.createSocket,clientGUID:this.clientGUID,acpStorage:this.acpStorage})};var so;class f2 extends tn{constructor(){super();w(this,so,e=>{const r=g2(e);r!==null&&(e.preventDefault(),this.dispatchEvent(new ZA("shortcut-triggered",{shortcut:r})))});document.addEventListener("keydown",l(this,so))}dispose(){document.removeEventListener("keydown",l(this,so))}}so=new WeakMap;function g2(n){for(const[t,e]of Object.entries(_1))if(m2(n,e.trigger))return t;return null}function m2(n,t){return!(n.key.toLowerCase()!==t.key.toLowerCase()||n.metaKey!==!!t.meta||n.ctrlKey!==!!t.ctrl||n.shiftKey!==!!t.shift||n.altKey!==!!t.alt)}const v2="serverURL",y2="token",b2="mode",w2="electron";function fb(n=window.location.search,t=window.location.origin){const r=new URLSearchParams(n).get(v2);return r?new URL(r).origin:new URL(t).origin}function pg(n=window.location.search){return new URLSearchParams(n).get(y2)}function gd(n=window.location.search){return new URLSearchParams(n).get(b2)===w2}let $n=null;async function gb(n,t){if($n==null||$n.abort(),n===null){$n=null,rl();return}const e=new AbortController;$n=e;try{const r=t.token?{Authorization:`Bearer ${t.token}`}:void 0,i=new URL(`/themes/${n}/theme.css`,t.url).toString(),s=await fetch(i,{signal:e.signal,...r?{headers:r}:{}});if(!s.ok)throw new Error(`Theme fetch failed: ${s.status}`);const o=await s.text();if($n!==e)return;dv(o)}catch(r){if(r.name==="AbortError")return;rl();const i=r instanceof Error?r.message:String(r);console.warn(`applyTheme: ${i}`)}finally{$n===e&&($n=null)}}/**
|
|
42
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const h of n.seen.entries()){const p=h[1];if(t===h[0]){s(h);continue}if(n.external){const m=(c=n.external.registry.get(h[0]))==null?void 0:c.id;if(t!==h[0]&&m){s(h);continue}}if((u=n.metadataRegistry.get(h[0]))==null?void 0:u.id){s(h);continue}if(p.cycle){s(h);continue}if(p.count>1&&n.reused==="ref"){s(h);continue}}}function dy(n,t){var o,a,c;const e=n.seen.get(t);if(!e)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=u=>{const h=n.seen.get(u);if(h.ref===null)return;const p=h.def??h.schema,v={...p},m=h.ref;if(h.ref=null,m){r(m);const k=n.seen.get(m),T=k.schema;if(T.$ref&&(n.target==="draft-07"||n.target==="draft-04"||n.target==="openapi-3.0")?(p.allOf=p.allOf??[],p.allOf.push(T)):Object.assign(p,T),Object.assign(p,v),u._zod.parent===m)for(const R in p)R==="$ref"||R==="allOf"||R in v||delete p[R];if(T.$ref&&k.def)for(const R in p)R==="$ref"||R==="allOf"||R in k.def&&JSON.stringify(p[R])===JSON.stringify(k.def[R])&&delete p[R]}const _=u._zod.parent;if(_&&_!==m){r(_);const k=n.seen.get(_);if(k!=null&&k.schema.$ref&&(p.$ref=k.schema.$ref,k.def))for(const T in p)T==="$ref"||T==="allOf"||T in k.def&&JSON.stringify(p[T])===JSON.stringify(k.def[T])&&delete p[T]}n.override({zodSchema:u,jsonSchema:p,path:h.path??[]})};for(const u of[...n.seen.entries()].reverse())r(u[0]);const i={};if(n.target==="draft-2020-12"?i.$schema="https://json-schema.org/draft/2020-12/schema":n.target==="draft-07"?i.$schema="http://json-schema.org/draft-07/schema#":n.target==="draft-04"?i.$schema="http://json-schema.org/draft-04/schema#":n.target,(o=n.external)!=null&&o.uri){const u=(a=n.external.registry.get(t))==null?void 0:a.id;if(!u)throw new Error("Schema is missing an `id` property");i.$id=n.external.uri(u)}Object.assign(i,e.def??e.schema);const s=((c=n.external)==null?void 0:c.defs)??{};for(const u of n.seen.entries()){const h=u[1];h.def&&h.defId&&(s[h.defId]=h.def)}n.external||Object.keys(s).length>0&&(n.target==="draft-2020-12"?i.$defs=s:i.definitions=s);try{const u=JSON.parse(JSON.stringify(i));return Object.defineProperty(u,"~standard",{value:{...t["~standard"],jsonSchema:{input:pl(t,"input",n.processors),output:pl(t,"output",n.processors)}},enumerable:!1,writable:!1}),u}catch{throw new Error("Error converting schema to JSON.")}}function Ze(n,t){const e=t??{seen:new Set};if(e.seen.has(n))return!1;e.seen.add(n);const r=n._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return Ze(r.element,e);if(r.type==="set")return Ze(r.valueType,e);if(r.type==="lazy")return Ze(r.getter(),e);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault")return Ze(r.innerType,e);if(r.type==="intersection")return Ze(r.left,e)||Ze(r.right,e);if(r.type==="record"||r.type==="map")return Ze(r.keyType,e)||Ze(r.valueType,e);if(r.type==="pipe")return Ze(r.in,e)||Ze(r.out,e);if(r.type==="object"){for(const i in r.shape)if(Ze(r.shape[i],e))return!0;return!1}if(r.type==="union"){for(const i of r.options)if(Ze(i,e))return!0;return!1}if(r.type==="tuple"){for(const i of r.items)if(Ze(i,e))return!0;return!!(r.rest&&Ze(r.rest,e))}return!1}const UI=(n,t={})=>e=>{const r=uy({...e,processors:t});return Se(n,r),hy(r,n),dy(r,n)},pl=(n,t,e={})=>r=>{const{libraryOptions:i,target:s}=r??{},o=uy({...i??{},target:s,io:t,processors:e});return Se(n,o),hy(o,n),dy(o,n)},FI={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},HI=(n,t,e,r)=>{const i=e;i.type="string";const{minimum:s,maximum:o,format:a,patterns:c,contentEncoding:u}=n._zod.bag;if(typeof s=="number"&&(i.minLength=s),typeof o=="number"&&(i.maxLength=o),a&&(i.format=FI[a]??a,i.format===""&&delete i.format,a==="time"&&delete i.format),u&&(i.contentEncoding=u),c&&c.size>0){const h=[...c];h.length===1?i.pattern=h[0].source:h.length>1&&(i.allOf=[...h.map(p=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:p.source}))])}},WI=(n,t,e,r)=>{const i=e,{minimum:s,maximum:o,format:a,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:h}=n._zod.bag;typeof a=="string"&&a.includes("int")?i.type="integer":i.type="number",typeof h=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(i.minimum=h,i.exclusiveMinimum=!0):i.exclusiveMinimum=h),typeof s=="number"&&(i.minimum=s,typeof h=="number"&&t.target!=="draft-04"&&(h>=s?delete i.minimum:delete i.exclusiveMinimum)),typeof u=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(i.maximum=u,i.exclusiveMaximum=!0):i.exclusiveMaximum=u),typeof o=="number"&&(i.maximum=o,typeof u=="number"&&t.target!=="draft-04"&&(u<=o?delete i.maximum:delete i.exclusiveMaximum)),typeof c=="number"&&(i.multipleOf=c)},ZI=(n,t,e,r)=>{e.type="boolean"},VI=(n,t,e,r)=>{e.not={}},BI=(n,t,e,r)=>{},jI=(n,t,e,r)=>{const i=n._zod.def,s=Vv(i.entries);s.every(o=>typeof o=="number")&&(e.type="number"),s.every(o=>typeof o=="string")&&(e.type="string"),e.enum=s},GI=(n,t,e,r)=>{const i=n._zod.def,s=[];for(const o of i.values)if(o===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof o=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");s.push(Number(o))}else s.push(o);if(s.length!==0)if(s.length===1){const o=s[0];e.type=o===null?"null":typeof o,t.target==="draft-04"||t.target==="openapi-3.0"?e.enum=[o]:e.const=o}else s.every(o=>typeof o=="number")&&(e.type="number"),s.every(o=>typeof o=="string")&&(e.type="string"),s.every(o=>typeof o=="boolean")&&(e.type="boolean"),s.every(o=>o===null)&&(e.type="null"),e.enum=s},qI=(n,t,e,r)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},YI=(n,t,e,r)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},XI=(n,t,e,r)=>{const i=e,s=n._zod.def,{minimum:o,maximum:a}=n._zod.bag;typeof o=="number"&&(i.minItems=o),typeof a=="number"&&(i.maxItems=a),i.type="array",i.items=Se(s.element,t,{...r,path:[...r.path,"items"]})},KI=(n,t,e,r)=>{var u;const i=e,s=n._zod.def;i.type="object",i.properties={};const o=s.shape;for(const h in o)i.properties[h]=Se(o[h],t,{...r,path:[...r.path,"properties",h]});const a=new Set(Object.keys(o)),c=new Set([...a].filter(h=>{const p=s.shape[h]._zod;return t.io==="input"?p.optin===void 0:p.optout===void 0}));c.size>0&&(i.required=Array.from(c)),((u=s.catchall)==null?void 0:u._zod.def.type)==="never"?i.additionalProperties=!1:s.catchall?s.catchall&&(i.additionalProperties=Se(s.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(i.additionalProperties=!1)},JI=(n,t,e,r)=>{const i=n._zod.def,s=i.inclusive===!1,o=i.options.map((a,c)=>Se(a,t,{...r,path:[...r.path,s?"oneOf":"anyOf",c]}));s?e.oneOf=o:e.anyOf=o},QI=(n,t,e,r)=>{const i=n._zod.def,s=Se(i.left,t,{...r,path:[...r.path,"allOf",0]}),o=Se(i.right,t,{...r,path:[...r.path,"allOf",1]}),a=u=>"allOf"in u&&Object.keys(u).length===1,c=[...a(s)?s.allOf:[s],...a(o)?o.allOf:[o]];e.allOf=c},eC=(n,t,e,r)=>{const i=e,s=n._zod.def;i.type="object";const o=s.keyType,a=o._zod.bag,c=a==null?void 0:a.patterns;if(s.mode==="loose"&&c&&c.size>0){const h=Se(s.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});i.patternProperties={};for(const p of c)i.patternProperties[p.source]=h}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(i.propertyNames=Se(s.keyType,t,{...r,path:[...r.path,"propertyNames"]})),i.additionalProperties=Se(s.valueType,t,{...r,path:[...r.path,"additionalProperties"]});const u=o._zod.values;if(u){const h=[...u].filter(p=>typeof p=="string"||typeof p=="number");h.length>0&&(i.required=h)}},tC=(n,t,e,r)=>{const i=n._zod.def,s=Se(i.innerType,t,r),o=t.seen.get(n);t.target==="openapi-3.0"?(o.ref=i.innerType,e.nullable=!0):e.anyOf=[s,{type:"null"}]},nC=(n,t,e,r)=>{const i=n._zod.def;Se(i.innerType,t,r);const s=t.seen.get(n);s.ref=i.innerType},rC=(n,t,e,r)=>{const i=n._zod.def;Se(i.innerType,t,r);const s=t.seen.get(n);s.ref=i.innerType,e.default=JSON.parse(JSON.stringify(i.defaultValue))},iC=(n,t,e,r)=>{const i=n._zod.def;Se(i.innerType,t,r);const s=t.seen.get(n);s.ref=i.innerType,t.io==="input"&&(e._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},sC=(n,t,e,r)=>{const i=n._zod.def;Se(i.innerType,t,r);const s=t.seen.get(n);s.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}e.default=o},oC=(n,t,e,r)=>{const i=n._zod.def,s=t.io==="input"?i.in._zod.def.type==="transform"?i.out:i.in:i.out;Se(s,t,r);const o=t.seen.get(n);o.ref=s},aC=(n,t,e,r)=>{const i=n._zod.def;Se(i.innerType,t,r);const s=t.seen.get(n);s.ref=i.innerType,e.readOnly=!0},py=(n,t,e,r)=>{const i=n._zod.def;Se(i.innerType,t,r);const s=t.seen.get(n);s.ref=i.innerType},lC=A("ZodISODateTime",(n,t)=>{cT.init(n,t),me.init(n,t)});function cC(n){return gI(lC,n)}const uC=A("ZodISODate",(n,t)=>{uT.init(n,t),me.init(n,t)});function hC(n){return mI(uC,n)}const dC=A("ZodISOTime",(n,t)=>{hT.init(n,t),me.init(n,t)});function pC(n){return vI(dC,n)}const fC=A("ZodISODuration",(n,t)=>{dT.init(n,t),me.init(n,t)});function gC(n){return yI(fC,n)}const fy=(n,t)=>{qv.init(n,t),n.name="ZodError",Object.defineProperties(n,{format:{value:e=>n$(n,e)},flatten:{value:e=>t$(n,e)},addIssue:{value:e=>{n.issues.push(e),n.message=JSON.stringify(n.issues,Du,2)}},addIssues:{value:e=>{n.issues.push(...e),n.message=JSON.stringify(n.issues,Du,2)}},isEmpty:{get(){return n.issues.length===0}}})},og=A("ZodError",fy),bt=A("ZodError",fy,{Parent:Error}),mC=fd(bt),vC=gd(bt),yC=Gl(bt),bC=ql(bt),wC=s$(bt),SC=o$(bt),_C=a$(bt),kC=l$(bt),xC=c$(bt),EC=u$(bt),AC=h$(bt),$C=d$(bt),ge=A("ZodType",(n,t)=>(fe.init(n,t),Object.assign(n["~standard"],{jsonSchema:{input:pl(n,"input"),output:pl(n,"output")}}),n.toJSONSchema=UI(n,{}),n.def=t,n.type=t.type,Object.defineProperty(n,"_def",{value:t}),n.check=(...e)=>n.clone(Jn(t,{checks:[...t.checks??[],...e.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0}),n.with=n.check,n.clone=(e,r)=>Qn(n,e,r),n.brand=()=>n,n.register=(e,r)=>(e.add(n,r),n),n.parse=(e,r)=>mC(n,e,r,{callee:n.parse}),n.safeParse=(e,r)=>yC(n,e,r),n.parseAsync=async(e,r)=>vC(n,e,r,{callee:n.parseAsync}),n.safeParseAsync=async(e,r)=>bC(n,e,r),n.spa=n.safeParseAsync,n.encode=(e,r)=>wC(n,e,r),n.decode=(e,r)=>SC(n,e,r),n.encodeAsync=async(e,r)=>_C(n,e,r),n.decodeAsync=async(e,r)=>kC(n,e,r),n.safeEncode=(e,r)=>xC(n,e,r),n.safeDecode=(e,r)=>EC(n,e,r),n.safeEncodeAsync=async(e,r)=>AC(n,e,r),n.safeDecodeAsync=async(e,r)=>$C(n,e,r),n.refine=(e,r)=>n.check(yR(e,r)),n.superRefine=e=>n.check(bR(e)),n.overwrite=e=>n.check(ss(e)),n.optional=()=>cg(n),n.exactOptional=()=>sR(n),n.nullable=()=>ug(n),n.nullish=()=>cg(ug(n)),n.nonoptional=e=>hR(n,e),n.array=()=>L(n),n.or=e=>B([n,e]),n.and=e=>Xl(n,e),n.transform=e=>hg(n,rR(e)),n.default=e=>lR(n,e),n.prefault=e=>uR(n,e),n.catch=e=>pR(n,e),n.pipe=e=>hg(n,e),n.readonly=()=>mR(n),n.describe=e=>{const r=n.clone();return Es.add(r,{description:e}),r},Object.defineProperty(n,"description",{get(){var e;return(e=Es.get(n))==null?void 0:e.description},configurable:!0}),n.meta=(...e)=>{if(e.length===0)return Es.get(n);const r=n.clone();return Es.add(r,e[0]),r},n.isOptional=()=>n.safeParse(void 0).success,n.isNullable=()=>n.safeParse(null).success,n.apply=e=>e(n),n)),gy=A("_ZodString",(n,t)=>{md.init(n,t),ge.init(n,t),n._zod.processJSONSchema=(r,i,s)=>HI(n,r,i);const e=n._zod.bag;n.format=e.format??null,n.minLength=e.minimum??null,n.maxLength=e.maximum??null,n.regex=(...r)=>n.check(xI(...r)),n.includes=(...r)=>n.check($I(...r)),n.startsWith=(...r)=>n.check(TI(...r)),n.endsWith=(...r)=>n.check(II(...r)),n.min=(...r)=>n.check(dl(...r)),n.max=(...r)=>n.check(ly(...r)),n.length=(...r)=>n.check(cy(...r)),n.nonempty=(...r)=>n.check(dl(1,...r)),n.lowercase=r=>n.check(EI(r)),n.uppercase=r=>n.check(AI(r)),n.trim=()=>n.check(RI()),n.normalize=(...r)=>n.check(CI(...r)),n.toLowerCase=()=>n.check(PI()),n.toUpperCase=()=>n.check(DI()),n.slugify=()=>n.check(LI())}),TC=A("ZodString",(n,t)=>{md.init(n,t),gy.init(n,t),n.email=e=>n.check(qT(IC,e)),n.url=e=>n.check(QT(CC,e)),n.jwt=e=>n.check(fI(BC,e)),n.emoji=e=>n.check(eI(RC,e)),n.guid=e=>n.check(ng(ag,e)),n.uuid=e=>n.check(YT(Sa,e)),n.uuidv4=e=>n.check(XT(Sa,e)),n.uuidv6=e=>n.check(KT(Sa,e)),n.uuidv7=e=>n.check(JT(Sa,e)),n.nanoid=e=>n.check(tI(PC,e)),n.guid=e=>n.check(ng(ag,e)),n.cuid=e=>n.check(nI(DC,e)),n.cuid2=e=>n.check(rI(LC,e)),n.ulid=e=>n.check(iI(zC,e)),n.base64=e=>n.check(hI(WC,e)),n.base64url=e=>n.check(dI(ZC,e)),n.xid=e=>n.check(sI(OC,e)),n.ksuid=e=>n.check(oI(MC,e)),n.ipv4=e=>n.check(aI(NC,e)),n.ipv6=e=>n.check(lI(UC,e)),n.cidrv4=e=>n.check(cI(FC,e)),n.cidrv6=e=>n.check(uI(HC,e)),n.e164=e=>n.check(pI(VC,e)),n.datetime=e=>n.check(cC(e)),n.date=e=>n.check(hC(e)),n.time=e=>n.check(pC(e)),n.duration=e=>n.check(gC(e))});function d(n){return GT(TC,n)}const me=A("ZodStringFormat",(n,t)=>{he.init(n,t),gy.init(n,t)}),IC=A("ZodEmail",(n,t)=>{eT.init(n,t),me.init(n,t)}),ag=A("ZodGUID",(n,t)=>{J$.init(n,t),me.init(n,t)}),Sa=A("ZodUUID",(n,t)=>{Q$.init(n,t),me.init(n,t)}),CC=A("ZodURL",(n,t)=>{tT.init(n,t),me.init(n,t)}),RC=A("ZodEmoji",(n,t)=>{nT.init(n,t),me.init(n,t)}),PC=A("ZodNanoID",(n,t)=>{rT.init(n,t),me.init(n,t)}),DC=A("ZodCUID",(n,t)=>{iT.init(n,t),me.init(n,t)}),LC=A("ZodCUID2",(n,t)=>{sT.init(n,t),me.init(n,t)}),zC=A("ZodULID",(n,t)=>{oT.init(n,t),me.init(n,t)}),OC=A("ZodXID",(n,t)=>{aT.init(n,t),me.init(n,t)}),MC=A("ZodKSUID",(n,t)=>{lT.init(n,t),me.init(n,t)}),NC=A("ZodIPv4",(n,t)=>{pT.init(n,t),me.init(n,t)}),UC=A("ZodIPv6",(n,t)=>{fT.init(n,t),me.init(n,t)}),FC=A("ZodCIDRv4",(n,t)=>{gT.init(n,t),me.init(n,t)}),HC=A("ZodCIDRv6",(n,t)=>{mT.init(n,t),me.init(n,t)}),WC=A("ZodBase64",(n,t)=>{vT.init(n,t),me.init(n,t)}),ZC=A("ZodBase64URL",(n,t)=>{bT.init(n,t),me.init(n,t)}),VC=A("ZodE164",(n,t)=>{wT.init(n,t),me.init(n,t)}),BC=A("ZodJWT",(n,t)=>{_T.init(n,t),me.init(n,t)}),my=A("ZodNumber",(n,t)=>{iy.init(n,t),ge.init(n,t),n._zod.processJSONSchema=(r,i,s)=>WI(n,r,i),n.gt=(r,i)=>n.check(ig(r,i)),n.gte=(r,i)=>n.check(Yc(r,i)),n.min=(r,i)=>n.check(Yc(r,i)),n.lt=(r,i)=>n.check(rg(r,i)),n.lte=(r,i)=>n.check(qc(r,i)),n.max=(r,i)=>n.check(qc(r,i)),n.int=r=>n.check(lg(r)),n.safe=r=>n.check(lg(r)),n.positive=r=>n.check(ig(0,r)),n.nonnegative=r=>n.check(Yc(0,r)),n.negative=r=>n.check(rg(0,r)),n.nonpositive=r=>n.check(qc(0,r)),n.multipleOf=(r,i)=>n.check(sg(r,i)),n.step=(r,i)=>n.check(sg(r,i)),n.finite=()=>n;const e=n._zod.bag;n.minValue=Math.max(e.minimum??Number.NEGATIVE_INFINITY,e.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,n.maxValue=Math.min(e.maximum??Number.POSITIVE_INFINITY,e.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,n.isInt=(e.format??"").includes("int")||Number.isSafeInteger(e.multipleOf??.5),n.isFinite=!0,n.format=e.format??null});function H(n){return bI(my,n)}const jC=A("ZodNumberFormat",(n,t)=>{kT.init(n,t),my.init(n,t)});function lg(n){return wI(jC,n)}const GC=A("ZodBoolean",(n,t)=>{xT.init(n,t),ge.init(n,t),n._zod.processJSONSchema=(e,r,i)=>ZI(n,e,r)});function Ie(n){return SI(GC,n)}const qC=A("ZodUnknown",(n,t)=>{ET.init(n,t),ge.init(n,t),n._zod.processJSONSchema=(e,r,i)=>BI()});function x(){return _I(qC)}const YC=A("ZodNever",(n,t)=>{AT.init(n,t),ge.init(n,t),n._zod.processJSONSchema=(e,r,i)=>VI(n,e,r)});function XC(n){return kI(YC,n)}const KC=A("ZodArray",(n,t)=>{$T.init(n,t),ge.init(n,t),n._zod.processJSONSchema=(e,r,i)=>XI(n,e,r,i),n.element=t.element,n.min=(e,r)=>n.check(dl(e,r)),n.nonempty=e=>n.check(dl(1,e)),n.max=(e,r)=>n.check(ly(e,r)),n.length=(e,r)=>n.check(cy(e,r)),n.unwrap=()=>n.element});function L(n,t){return zI(KC,n,t)}const vy=A("ZodObject",(n,t)=>{IT.init(n,t),ge.init(n,t),n._zod.processJSONSchema=(e,r,i)=>KI(n,e,r,i),ne(n,"shape",()=>t.shape),n.keyof=()=>Zs(Object.keys(n._zod.def.shape)),n.catchall=e=>n.clone({...n._zod.def,catchall:e}),n.passthrough=()=>n.clone({...n._zod.def,catchall:x()}),n.loose=()=>n.clone({...n._zod.def,catchall:x()}),n.strict=()=>n.clone({...n._zod.def,catchall:XC()}),n.strip=()=>n.clone({...n._zod.def,catchall:void 0}),n.extend=e=>X1(n,e),n.safeExtend=e=>K1(n,e),n.merge=e=>J1(n,e),n.pick=e=>q1(n,e),n.omit=e=>Y1(n,e),n.partial=(...e)=>Q1(by,n,e[0]),n.required=(...e)=>e$(wy,n,e[0])});function yy(n,t){const e={type:"object",shape:n??{},...M(t)};return new vy(e)}function y(n,t){return new vy({type:"object",shape:n,catchall:x(),...M(t)})}const JC=A("ZodUnion",(n,t)=>{CT.init(n,t),ge.init(n,t),n._zod.processJSONSchema=(e,r,i)=>JI(n,e,r,i),n.options=t.options});function B(n,t){return new JC({type:"union",options:n,...M(t)})}const QC=A("ZodIntersection",(n,t)=>{RT.init(n,t),ge.init(n,t),n._zod.processJSONSchema=(e,r,i)=>QI(n,e,r,i)});function Xl(n,t){return new QC({type:"intersection",left:n,right:t})}const eR=A("ZodRecord",(n,t)=>{PT.init(n,t),ge.init(n,t),n._zod.processJSONSchema=(e,r,i)=>eC(n,e,r,i),n.keyType=t.keyType,n.valueType=t.valueType});function E(n,t,e){return new eR({type:"record",keyType:n,valueType:t,...M(e)})}const zu=A("ZodEnum",(n,t)=>{DT.init(n,t),ge.init(n,t),n._zod.processJSONSchema=(r,i,s)=>jI(n,r,i),n.enum=t.entries,n.options=Object.values(t.entries);const e=new Set(Object.keys(t.entries));n.extract=(r,i)=>{const s={};for(const o of r)if(e.has(o))s[o]=t.entries[o];else throw new Error(`Key ${o} not found in enum`);return new zu({...t,checks:[],...M(i),entries:s})},n.exclude=(r,i)=>{const s={...t.entries};for(const o of r)if(e.has(o))delete s[o];else throw new Error(`Key ${o} not found in enum`);return new zu({...t,checks:[],...M(i),entries:s})}});function Zs(n,t){const e=Array.isArray(n)?Object.fromEntries(n.map(r=>[r,r])):n;return new zu({type:"enum",entries:e,...M(t)})}const tR=A("ZodLiteral",(n,t)=>{LT.init(n,t),ge.init(n,t),n._zod.processJSONSchema=(e,r,i)=>GI(n,e,r),n.values=new Set(t.values),Object.defineProperty(n,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function $(n,t){return new tR({type:"literal",values:Array.isArray(n)?n:[n],...M(t)})}const nR=A("ZodTransform",(n,t)=>{zT.init(n,t),ge.init(n,t),n._zod.processJSONSchema=(e,r,i)=>YI(n,e),n._zod.parse=(e,r)=>{if(r.direction==="backward")throw new Wv(n.constructor.name);e.addIssue=s=>{if(typeof s=="string")e.issues.push(Ws(s,e.value,t));else{const o=s;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=e.value),o.inst??(o.inst=n),e.issues.push(Ws(o))}};const i=t.transform(e.value,e);return i instanceof Promise?i.then(s=>(e.value=s,e)):(e.value=i,e)}});function rR(n){return new nR({type:"transform",transform:n})}const by=A("ZodOptional",(n,t)=>{ay.init(n,t),ge.init(n,t),n._zod.processJSONSchema=(e,r,i)=>py(n,e,r,i),n.unwrap=()=>n._zod.def.innerType});function cg(n){return new by({type:"optional",innerType:n})}const iR=A("ZodExactOptional",(n,t)=>{OT.init(n,t),ge.init(n,t),n._zod.processJSONSchema=(e,r,i)=>py(n,e,r,i),n.unwrap=()=>n._zod.def.innerType});function sR(n){return new iR({type:"optional",innerType:n})}const oR=A("ZodNullable",(n,t)=>{MT.init(n,t),ge.init(n,t),n._zod.processJSONSchema=(e,r,i)=>tC(n,e,r,i),n.unwrap=()=>n._zod.def.innerType});function ug(n){return new oR({type:"nullable",innerType:n})}const aR=A("ZodDefault",(n,t)=>{NT.init(n,t),ge.init(n,t),n._zod.processJSONSchema=(e,r,i)=>rC(n,e,r,i),n.unwrap=()=>n._zod.def.innerType,n.removeDefault=n.unwrap});function lR(n,t){return new aR({type:"default",innerType:n,get defaultValue(){return typeof t=="function"?t():jv(t)}})}const cR=A("ZodPrefault",(n,t)=>{UT.init(n,t),ge.init(n,t),n._zod.processJSONSchema=(e,r,i)=>iC(n,e,r,i),n.unwrap=()=>n._zod.def.innerType});function uR(n,t){return new cR({type:"prefault",innerType:n,get defaultValue(){return typeof t=="function"?t():jv(t)}})}const wy=A("ZodNonOptional",(n,t)=>{FT.init(n,t),ge.init(n,t),n._zod.processJSONSchema=(e,r,i)=>nC(n,e,r,i),n.unwrap=()=>n._zod.def.innerType});function hR(n,t){return new wy({type:"nonoptional",innerType:n,...M(t)})}const dR=A("ZodCatch",(n,t)=>{HT.init(n,t),ge.init(n,t),n._zod.processJSONSchema=(e,r,i)=>sC(n,e,r,i),n.unwrap=()=>n._zod.def.innerType,n.removeCatch=n.unwrap});function pR(n,t){return new dR({type:"catch",innerType:n,catchValue:typeof t=="function"?t:()=>t})}const fR=A("ZodPipe",(n,t)=>{WT.init(n,t),ge.init(n,t),n._zod.processJSONSchema=(e,r,i)=>oC(n,e,r,i),n.in=t.in,n.out=t.out});function hg(n,t){return new fR({type:"pipe",in:n,out:t})}const gR=A("ZodReadonly",(n,t)=>{ZT.init(n,t),ge.init(n,t),n._zod.processJSONSchema=(e,r,i)=>aC(n,e,r,i),n.unwrap=()=>n._zod.def.innerType});function mR(n){return new gR({type:"readonly",innerType:n})}const vR=A("ZodCustom",(n,t)=>{VT.init(n,t),ge.init(n,t),n._zod.processJSONSchema=(e,r,i)=>qI(n,e)});function yR(n,t={}){return OI(vR,n,t)}function bR(n){return MI(n)}const ln={custom:"custom"},Sy=["markdown","web-bundle","url"],wR=["committed","pending"];function SR(n){let t;try{t=new URL(n)}catch{return!1}return t.protocol==="http:"||t.protocol==="https:"}yy({id:d().min(1),kind:Zs(Sy),title:d(),status:Zs(wR),externalFilePath:d().optional(),externalURL:d().optional()}).superRefine((n,t)=>{switch(n.externalFilePath!==void 0&&n.externalURL!==void 0&&t.addIssue({code:ln.custom,message:"externalFilePath and externalURL are mutually exclusive",path:["externalURL"]}),n.kind!=="web-bundle"&&n.status!=="committed"&&t.addIssue({code:ln.custom,message:"only web-bundle artifacts can be pending",path:["status"]}),n.kind){case"markdown":n.externalFilePath===void 0&&t.addIssue({code:ln.custom,message:"markdown artifacts require externalFilePath",path:["externalFilePath"]}),n.externalURL!==void 0&&t.addIssue({code:ln.custom,message:"markdown artifacts cannot set externalURL",path:["externalURL"]});break;case"web-bundle":n.externalFilePath!==void 0&&t.addIssue({code:ln.custom,message:"web-bundle artifacts cannot set externalFilePath",path:["externalFilePath"]}),n.externalURL!==void 0&&t.addIssue({code:ln.custom,message:"web-bundle artifacts cannot set externalURL",path:["externalURL"]});break;case"url":if(n.externalURL===void 0){t.addIssue({code:ln.custom,message:"url artifacts require externalURL",path:["externalURL"]});break}n.externalFilePath!==void 0&&t.addIssue({code:ln.custom,message:"url artifacts cannot set externalFilePath",path:["externalFilePath"]}),SR(n.externalURL)||t.addIssue({code:ln.custom,message:"externalURL must be an http(s) URL",path:["externalURL"]});break}});yy({name:d().min(1),description:d(),accepts:L(Zs(Sy)).min(1)});function _y(n){return typeof n=="object"&&n!==null}function _R(n){return!_y(n)||n.type!=="ready"?!1:!("id"in n)}function kR(n){return!(!_y(n)||n.type!=="update-content"||typeof n.id!="string"||typeof n.content!="string")}function xR(n,t){return t.find(e=>e.accepts.includes(n))??null}const ue={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"},cn={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"},ER=1,AR=y({_meta:E(d(),x()).nullish(),terminal:Ie().optional().default(!1)}),$R=y({_meta:E(d(),x()).nullish(),label:d().nullish(),name:d(),optional:Ie().optional().default(!1),secret:Ie().optional().default(!0)}),TR=y({_meta:E(d(),x()).nullish(),description:d().nullish(),id:d(),name:d()}),IR=y({_meta:E(d(),x()).nullish(),description:d().nullish(),id:d(),link:d().nullish(),name:d(),vars:L($R)}),CR=y({_meta:E(d(),x()).nullish(),args:L(d()).optional(),description:d().nullish(),env:E(d(),d()).optional(),id:d(),name:d()}),RR=B([IR.and(y({type:$("env_var")})),CR.and(y({type:$("terminal")})),TR]),PR=y({_meta:E(d(),x()).nullish(),methodId:d()}),DR=y({_meta:E(d(),x()).nullish()}),LR=y({_meta:E(d(),x()).nullish(),blob:d(),mimeType:d().nullish(),uri:d()}),zR=y({default:Ie().nullish(),description:d().nullish(),title:d().nullish()}),OR=y({_meta:E(d(),x()).nullish()}),MR=y({_meta:E(d(),x()).nullish()}),NR=y({amount:H(),currency:d()}),UR=y({_meta:E(d(),x()).nullish(),terminalId:d()}),FR=y({_meta:E(d(),x()).nullish(),newText:d(),oldText:d().nullish(),path:d()}),HR=B([d(),H(),H(),Ie(),L(d())]),WR=y({content:E(d(),HR).nullish()}),ZR=B([WR.and(y({action:$("accept")})),y({action:$("decline")}),y({action:$("cancel")})]),VR=y({_meta:E(d(),x()).nullish()}),ky=d(),BR=y({_meta:E(d(),x()).nullish(),elicitationId:ky}),jR=y({_meta:E(d(),x()).nullish(),action:ZR}),GR=$("object"),qR=$("string"),YR=y({_meta:E(d(),x()).nullish()}),XR=y({_meta:E(d(),x()).nullish(),form:VR.nullish(),url:YR.nullish()}),KR=y({elicitationId:ky,url:d().url()}),xy=y({const:d(),title:d()}),Ey=y({_meta:E(d(),x()).nullish(),name:d(),value:d()}),JR=B([$(-32700),$(-32600),$(-32601),$(-32602),$(-32603),$(-32800),$(-32e3),$(-32002),$(-32042),H().int().min(-2147483648,{message:"Invalid value: Expected int32 to be >= -2147483648"}).max(2147483647,{message:"Invalid value: Expected int32 to be <= 2147483647"})]),Ay=y({code:JR,data:x().optional(),message:d()}),$y=x(),Ty=x(),Iy=x(),QR=y({_meta:E(d(),x()).nullish(),readTextFile:Ie().optional().default(!1),writeTextFile:Ie().optional().default(!1)}),Cy=y({_meta:E(d(),x()).nullish(),name:d(),value:d()}),Ry=y({_meta:E(d(),x()).nullish(),name:d(),title:d().nullish(),version:d()}),eP=y({default:H().nullish(),description:d().nullish(),maximum:H().nullish(),minimum:H().nullish(),title:d().nullish()}),tP=y({_meta:E(d(),x()).nullish()}),nP=y({_meta:E(d(),x()).nullish(),additionalDirectories:L(d()).optional(),cursor:d().nullish(),cwd:d().nullish()}),rP=y({_meta:E(d(),x()).nullish()}),iP=y({_meta:E(d(),x()).nullish(),logout:rP.nullish()}),sP=y({_meta:E(d(),x()).nullish()}),oP=y({_meta:E(d(),x()).nullish()}),aP=y({_meta:E(d(),x()).nullish(),http:Ie().optional().default(!1),sse:Ie().optional().default(!1)}),lP=y({_meta:E(d(),x()).nullish(),headers:L(Cy),name:d(),url:d()}),cP=y({_meta:E(d(),x()).nullish(),headers:L(Cy),name:d(),url:d()}),uP=y({_meta:E(d(),x()).nullish(),args:L(d()),command:d(),env:L(Ey),name:d()}),Kl=B([lP.and(y({type:$("http")})),cP.and(y({type:$("sse")})),uP]),vd=d(),hP=y({_meta:E(d(),x()).nullish(),description:d().nullish(),modelId:vd,name:d()}),dP=B([$("error"),$("warning"),$("information"),$("hint")]),pP=y({_meta:E(d(),x()).nullish()}),fP=y({_meta:E(d(),x()).nullish()}),gP=y({_meta:E(d(),x()).nullish()}),mP=y({_meta:E(d(),x()).nullish()}),vP=y({_meta:E(d(),x()).nullish()}),yP=y({_meta:E(d(),x()).nullish(),maxCount:H().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),bP=y({diff:d(),uri:d()}),wP=y({endLine:H().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),startLine:H().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),text:d()}),SP=y({_meta:E(d(),x()).nullish()}),_P=y({_meta:E(d(),x()).nullish()}),kP=y({languageId:d(),text:d(),uri:d()}),xP=y({_meta:E(d(),x()).nullish(),maxCount:H().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),EP=B([$("rejected"),$("ignored"),$("replaced"),$("cancelled")]),AP=y({excerpts:L(wP),uri:d()}),$P=y({_meta:E(d(),x()).nullish()}),TP=y({_meta:E(d(),x()).nullish()}),IP=y({name:d(),owner:d(),remoteUrl:d()}),CP=y({_meta:E(d(),x()).nullish()}),RP=y({_meta:E(d(),x()).nullish(),jump:SP.nullish(),rename:TP.nullish(),searchAndReplace:CP.nullish()}),PP=y({id:d(),isRegex:Ie().nullish(),replace:d(),search:d(),uri:d()}),DP=B([$("automatic"),$("diagnostic"),$("manual")]),LP=y({_meta:E(d(),x()).nullish(),maxCount:H().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),zP=y({_meta:E(d(),x()).nullish(),diagnostics:pP.nullish(),editHistory:yP.nullish(),openFiles:_P.nullish(),recentFiles:xP.nullish(),relatedSnippets:$P.nullish(),userActions:LP.nullish()}),OP=y({_meta:E(d(),x()).nullish(),additionalDirectories:L(d()).optional(),cwd:d(),mcpServers:L(Kl)}),MP=y({default:H().nullish(),description:d().nullish(),maximum:H().nullish(),minimum:H().nullish(),title:d().nullish()}),Py=d(),NP=B([$("allow_once"),$("allow_always"),$("reject_once"),$("reject_always")]),UP=y({_meta:E(d(),x()).nullish(),kind:NP,name:d(),optionId:Py}),FP=B([$("high"),$("medium"),$("low")]),HP=B([$("pending"),$("in_progress"),$("completed")]),WP=y({_meta:E(d(),x()).nullish(),content:d(),priority:FP,status:HP}),ZP=y({_meta:E(d(),x()).nullish(),entries:L(WP)}),qn=y({character:H().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),line:H().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"})}),VP=y({id:d(),position:qn,uri:d()}),BP=y({id:d(),newName:d(),position:qn,uri:d()}),jP=y({action:d(),position:qn,timestampMs:H(),uri:d()}),Dy=B([$("utf-16"),$("utf-32"),$("utf-8")]),GP=y({_meta:E(d(),x()).nullish(),auth:AR.optional().default({terminal:!1}),elicitation:XR.nullish(),fs:QR.optional().default({readTextFile:!1,writeTextFile:!1}),nes:RP.nullish(),positionEncodings:L(Dy).optional(),terminal:Ie().optional().default(!1)}),qP=y({_meta:E(d(),x()).nullish(),audio:Ie().optional().default(!1),embeddedContext:Ie().optional().default(!1),image:Ie().optional().default(!1)}),Ly=H().int().gte(0).lte(65535),YP=y({_meta:E(d(),x()).nullish(),clientCapabilities:GP.optional().default({auth:{terminal:!1},fs:{readTextFile:!1,writeTextFile:!1},terminal:!1}),clientInfo:Ry.nullish(),protocolVersion:Ly}),os=y({end:qn,start:qn}),XP=y({message:d(),range:os,severity:dP,uri:d()}),KP=y({languageId:d(),lastFocusedMs:H().nullish(),uri:d(),visibleRange:os.nullish()}),JP=y({_meta:E(d(),x()).nullish(),diagnostics:L(XP).nullish(),editHistory:L(bP).nullish(),openFiles:L(KP).nullish(),recentFiles:L(kP).nullish(),relatedSnippets:L(AP).nullish(),userActions:L(jP).nullish()}),QP=y({newText:d(),range:os}),eD=y({cursorPosition:qn.nullish(),edits:L(QP),id:d(),uri:d()}),tD=B([eD.and(y({kind:$("edit")})),VP.and(y({kind:$("jump")})),BP.and(y({kind:$("rename")})),PP.and(y({kind:$("searchAndReplace")}))]),nD=y({_meta:E(d(),x()).nullish(),content:d()}),rD=y({_meta:E(d(),x()).nullish()}),Or=B([H(),d()]).nullable();y({_meta:E(d(),x()).nullish(),requestId:Or});const iD=Zs(["assistant","user"]),Jo=y({_meta:E(d(),x()).nullish(),audience:L(iD).nullish(),lastModified:d().nullish(),priority:H().nullish()}),sD=y({_meta:E(d(),x()).nullish(),annotations:Jo.nullish(),data:d(),mimeType:d()}),oD=y({_meta:E(d(),x()).nullish(),annotations:Jo.nullish(),data:d(),mimeType:d(),uri:d().nullish()}),aD=y({_meta:E(d(),x()).nullish(),annotations:Jo.nullish(),description:d().nullish(),mimeType:d().nullish(),name:d(),size:H().nullish(),title:d().nullish(),uri:d()}),lD=y({_meta:E(d(),x()).nullish(),optionId:Py}),cD=B([y({outcome:$("cancelled")}),lD.and(y({outcome:$("selected")}))]),uD=y({_meta:E(d(),x()).nullish(),outcome:cD}),hD=y({_meta:E(d(),x()).nullish()}),dD=y({_meta:E(d(),x()).nullish()}),pD=y({currentValue:Ie()}),fD=d(),zy=d(),gD=B([$("mode"),$("model"),$("thought_level"),d()]),yd=d(),Oy=y({_meta:E(d(),x()).nullish(),description:d().nullish(),name:d(),value:yd}),mD=y({_meta:E(d(),x()).nullish(),group:fD,name:d(),options:L(Oy)}),vD=B([L(Oy),L(mD)]),yD=y({currentValue:yd,options:vD}),as=Xl(B([yD.and(y({type:$("select")})),pD.and(y({type:$("boolean")}))]),y({_meta:E(d(),x()).nullish(),category:gD.nullish(),description:d().nullish(),id:zy,name:d()})),bD=y({_meta:E(d(),x()).nullish(),configOptions:L(as)}),wD=y({_meta:E(d(),x()).nullish()}),Q=d(),SD=y({_meta:E(d(),x()).nullish(),id:d(),sessionId:Q}),_D=y({_meta:E(d(),x()).nullish(),sessionId:Q}),kD=y({_meta:E(d(),x()).nullish(),sessionId:Q}),xD=y({_meta:E(d(),x()).nullish(),sessionId:Q}),My=y({_meta:E(d(),x()).nullish(),args:L(d()).optional(),command:d(),cwd:d().nullish(),env:L(Ey).optional(),outputByteLimit:H().nullish(),sessionId:Q}),ED=y({_meta:E(d(),x()).nullish(),sessionId:Q,uri:d()}),AD=y({_meta:E(d(),x()).nullish(),position:qn,sessionId:Q,uri:d(),version:H(),visibleRange:os}),$D=y({_meta:E(d(),x()).nullish(),languageId:d(),sessionId:Q,text:d(),uri:d(),version:H()}),TD=y({_meta:E(d(),x()).nullish(),sessionId:Q,uri:d()}),ID=y({_meta:E(d(),x()).nullish(),additionalDirectories:L(d()).optional(),cwd:d(),mcpServers:L(Kl).optional(),sessionId:Q}),Ny=y({_meta:E(d(),x()).nullish(),sessionId:Q,terminalId:d()}),CD=y({_meta:E(d(),x()).nullish(),additionalDirectories:L(d()).optional(),cwd:d(),mcpServers:L(Kl),sessionId:Q}),Uy=y({_meta:E(d(),x()).nullish(),limit:H().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),line:H().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:d(),sessionId:Q}),RD=y({_meta:E(d(),x()).nullish(),id:d(),reason:EP.nullish(),sessionId:Q}),Fy=y({_meta:E(d(),x()).nullish(),sessionId:Q,terminalId:d()}),PD=y({_meta:E(d(),x()).nullish(),additionalDirectories:L(d()).optional(),cwd:d(),mcpServers:L(Kl).optional(),sessionId:Q}),DD=y({_meta:E(d(),x()).nullish(),additionalDirectories:L(d()).optional(),cwd:d(),sessionId:Q,title:d().nullish(),updatedAt:d().nullish()}),LD=y({_meta:E(d(),x()).nullish(),nextCursor:d().nullish(),sessions:L(DD)}),zD=y({_meta:E(d(),x()).nullish(),title:d().nullish(),updatedAt:d().nullish()}),OD=y({_meta:E(d(),x()).nullish()}),Jl=d(),MD=y({_meta:E(d(),x()).nullish(),currentModeId:Jl}),ND=y({_meta:E(d(),x()).nullish(),description:d().nullish(),id:Jl,name:d()}),Ql=y({_meta:E(d(),x()).nullish(),availableModes:L(ND),currentModeId:Jl}),ec=y({_meta:E(d(),x()).nullish(),availableModels:L(hP),currentModelId:vd}),UD=y({_meta:E(d(),x()).nullish(),configOptions:L(as).nullish(),models:ec.nullish(),modes:Ql.nullish(),sessionId:Q}),FD=y({_meta:E(d(),x()).nullish(),configOptions:L(as).nullish(),models:ec.nullish(),modes:Ql.nullish()}),HD=y({_meta:E(d(),x()).nullish(),configOptions:L(as).nullish(),models:ec.nullish(),modes:Ql.nullish(),sessionId:Q}),WD=y({_meta:E(d(),x()).nullish(),configOptions:L(as).nullish(),models:ec.nullish(),modes:Ql.nullish()}),ZD=y({_meta:E(d(),x()).nullish()}),VD=y({_meta:E(d(),x()).nullish(),additionalDirectories:hD.nullish(),close:dD.nullish(),fork:wD.nullish(),list:OD.nullish(),resume:ZD.nullish()}),BD=Xl(B([y({type:$("boolean"),value:Ie()}),y({value:yd})]),y({_meta:E(d(),x()).nullish(),configId:zy,sessionId:Q})),jD=y({_meta:E(d(),x()).nullish(),configOptions:L(as)}),GD=y({_meta:E(d(),x()).nullish(),modeId:Jl,sessionId:Q}),qD=y({_meta:E(d(),x()).nullish()}),YD=y({_meta:E(d(),x()).nullish(),modelId:vd,sessionId:Q}),XD=y({_meta:E(d(),x()).nullish()}),KD=y({_meta:E(d(),x()).nullish(),sessionId:Q}),JD=B([$("end_turn"),$("max_tokens"),$("max_turn_requests"),$("refusal"),$("cancelled")]),QD=B([$("email"),$("uri"),$("date"),$("date-time")]),eL=y({default:d().nullish(),description:d().nullish(),enum:L(d()).nullish(),format:QD.nullish(),maxLength:H().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),minLength:H().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),oneOf:L(xy).nullish(),pattern:d().nullish(),title:d().nullish()}),tL=y({_meta:E(d(),x()).nullish(),context:JP.nullish(),position:qn,selection:os.nullish(),sessionId:Q,triggerKind:DP,uri:d(),version:H()}),nL=y({_meta:E(d(),x()).nullish(),suggestions:L(tD)}),rL=y({_meta:E(d(),x()).nullish(),terminalId:d()}),iL=y({_meta:E(d(),x()).nullish(),exitCode:H().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:d().nullish()}),Hy=y({_meta:E(d(),x()).nullish(),sessionId:Q,terminalId:d()}),sL=y({_meta:E(d(),x()).nullish(),exitStatus:iL.nullish(),output:d(),truncated:Ie()}),oL=y({_meta:E(d(),x()).nullish(),annotations:Jo.nullish(),text:d()}),aL=y({range:os.nullish(),text:d()}),lL=y({_meta:E(d(),x()).nullish(),contentChanges:L(aL),sessionId:Q,uri:d(),version:H()});y({method:d(),params:B([_D,$D,lL,ED,TD,AD,SD,RD,$y]).nullish()});const cL=B([$("full"),$("incremental")]),uL=y({_meta:E(d(),x()).nullish(),syncKind:cL}),hL=y({_meta:E(d(),x()).nullish(),didChange:uL.nullish(),didClose:fP.nullish(),didFocus:gP.nullish(),didOpen:mP.nullish(),didSave:vP.nullish()}),dL=y({_meta:E(d(),x()).nullish(),document:hL.nullish()}),pL=y({_meta:E(d(),x()).nullish(),context:zP.nullish(),events:dL.nullish()}),fL=y({_meta:E(d(),x()).nullish(),auth:iP.optional().default({}),loadSession:Ie().optional().default(!1),mcpCapabilities:aP.optional().default({http:!1,sse:!1}),nes:pL.nullish(),positionEncoding:Dy.nullish(),promptCapabilities:qP.optional().default({audio:!1,embeddedContext:!1,image:!1}),sessionCapabilities:VD.optional().default({})}),gL=y({_meta:E(d(),x()).nullish(),agentCapabilities:fL.optional().default({auth:{},loadSession:!1,mcpCapabilities:{http:!1,sse:!1},promptCapabilities:{audio:!1,embeddedContext:!1,image:!1},sessionCapabilities:{}}),agentInfo:Ry.nullish(),authMethods:L(RR).optional().default([]),protocolVersion:Ly}),mL=y({_meta:E(d(),x()).nullish(),mimeType:d().nullish(),text:d(),uri:d()}),vL=B([mL,LR]),yL=y({_meta:E(d(),x()).nullish(),annotations:Jo.nullish(),resource:vL}),bd=B([oL.and(y({type:$("text")})),oD.and(y({type:$("image")})),sD.and(y({type:$("audio")})),aD.and(y({type:$("resource_link")})),yL.and(y({type:$("resource")}))]),bL=y({_meta:E(d(),x()).nullish(),content:bd}),Xc=y({_meta:E(d(),x()).nullish(),content:bd,messageId:d().nullish()}),wL=y({_meta:E(d(),x()).nullish(),messageId:d().nullish(),prompt:L(bd),sessionId:Q}),SL=y({anyOf:L(xy)}),Wy=B([bL.and(y({type:$("content")})),FR.and(y({type:$("diff")})),rL.and(y({type:$("terminal")}))]),Zy=d(),Vy=y({_meta:E(d(),x()).nullish(),line:H().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:d()}),By=B([$("pending"),$("in_progress"),$("completed"),$("failed")]),jy=B([$("read"),$("edit"),$("delete"),$("move"),$("search"),$("execute"),$("think"),$("fetch"),$("switch_mode"),$("other")]),_L=y({_meta:E(d(),x()).nullish(),content:L(Wy).optional(),kind:jy.optional(),locations:L(Vy).optional(),rawInput:x().optional(),rawOutput:x().optional(),status:By.optional(),title:d(),toolCallId:Zy}),Gy=y({_meta:E(d(),x()).nullish(),content:L(Wy).nullish(),kind:jy.nullish(),locations:L(Vy).nullish(),rawInput:x().optional(),rawOutput:x().optional(),status:By.nullish(),title:d().nullish(),toolCallId:Zy}),qy=y({_meta:E(d(),x()).nullish(),options:L(UP),sessionId:Q,toolCall:Gy}),kL=y({_meta:E(d(),x()).nullish(),hint:d()}),xL=kL,EL=y({_meta:E(d(),x()).nullish(),description:d(),input:xL.nullish(),name:d()}),AL=y({_meta:E(d(),x()).nullish(),availableCommands:L(EL)}),$L=y({enum:L(d()),type:qR}),TL=B([$L,SL]),IL=y({default:L(d()).nullish(),description:d().nullish(),items:TL,maxItems:H().nullish(),minItems:H().nullish(),title:d().nullish()}),CL=B([eL.and(y({type:$("string")})),MP.and(y({type:$("number")})),eP.and(y({type:$("integer")})),zR.and(y({type:$("boolean")})),IL.and(y({type:$("array")}))]),RL=y({description:d().nullish(),properties:E(d(),CL).optional().default({}),required:L(d()).nullish(),title:d().nullish(),type:GR.optional().default("object")}),PL=y({requestedSchema:RL}),DL=Xl(B([PL.and(y({mode:$("form")})),KR.and(y({mode:$("url")}))]),y({_meta:E(d(),x()).nullish(),message:d(),sessionId:Q})),LL=y({cachedReadTokens:H().nullish(),cachedWriteTokens:H().nullish(),inputTokens:H(),outputTokens:H(),thoughtTokens:H().nullish(),totalTokens:H()}),zL=y({_meta:E(d(),x()).nullish(),stopReason:JD,usage:LL.nullish(),userMessageId:d().nullish()});B([y({id:Or,result:B([gL,DR,oP,HD,FD,LD,UD,WD,MR,qD,jD,zL,XD,KD,nL,OR,Iy])}),y({error:Ay,id:Or})]);const OL=y({_meta:E(d(),x()).nullish(),cost:NR.nullish(),size:H(),used:H()}),ML=B([Xc.and(y({sessionUpdate:$("user_message_chunk")})),Xc.and(y({sessionUpdate:$("agent_message_chunk")})),Xc.and(y({sessionUpdate:$("agent_thought_chunk")})),_L.and(y({sessionUpdate:$("tool_call")})),Gy.and(y({sessionUpdate:$("tool_call_update")})),ZP.and(y({sessionUpdate:$("plan")})),AL.and(y({sessionUpdate:$("available_commands_update")})),MD.and(y({sessionUpdate:$("current_mode_update")})),bD.and(y({sessionUpdate:$("config_option_update")})),zD.and(y({sessionUpdate:$("session_info_update")})),OL.and(y({sessionUpdate:$("usage_update")}))]),Yy=y({_meta:E(d(),x()).nullish(),sessionId:Q,update:ML});y({method:d(),params:B([Yy,BR,$y]).nullish()});const Xy=y({_meta:E(d(),x()).nullish(),sessionId:Q,terminalId:d()}),NL=y({_meta:E(d(),x()).nullish(),exitCode:H().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:d().nullish()}),UL=y({name:d(),uri:d()}),FL=y({_meta:E(d(),x()).nullish(),repository:IP.nullish(),workspaceFolders:L(UL).nullish(),workspaceUri:d().nullish()});y({id:Or,method:d(),params:B([YP,PR,sP,OP,CD,nP,ID,PD,xD,GD,BD,wL,YD,FL,tL,kD,Ty]).nullish()});const Ky=y({_meta:E(d(),x()).nullish(),content:d(),path:d(),sessionId:Q});y({id:Or,method:d(),params:B([Ky,Uy,qy,My,Hy,Fy,Xy,Ny,DL,Ty]).nullish()});const HL=y({_meta:E(d(),x()).nullish()});B([y({id:Or,result:B([HL,nD,uD,UR,sL,rD,NL,tP,jR,Iy])}),y({error:Ay,id:Or})]);var J;class WL{constructor(t,e){w(this,J);const r=t(this),i=async(o,a)=>{var c,u,h,p,v,m,_;switch(o){case cn.fs_write_text_file:{const k=Ky.parse(a);return(c=r.writeTextFile)==null?void 0:c.call(r,k)}case cn.fs_read_text_file:{const k=Uy.parse(a);return(u=r.readTextFile)==null?void 0:u.call(r,k)}case cn.session_request_permission:{const k=qy.parse(a);return r.requestPermission(k)}case cn.terminal_create:{const k=My.parse(a);return(h=r.createTerminal)==null?void 0:h.call(r,k)}case cn.terminal_output:{const k=Hy.parse(a);return(p=r.terminalOutput)==null?void 0:p.call(r,k)}case cn.terminal_release:{const k=Fy.parse(a);return await((v=r.releaseTerminal)==null?void 0:v.call(r,k))??{}}case cn.terminal_wait_for_exit:{const k=Xy.parse(a);return(m=r.waitForTerminalExit)==null?void 0:m.call(r,k)}case cn.terminal_kill:{const k=Ny.parse(a);return await((_=r.killTerminal)==null?void 0:_.call(r,k))??{}}default:if(r.extMethod)return r.extMethod(o,a);throw Ae.methodNotFound(o)}},s=async(o,a)=>{switch(o){case cn.session_update:{const c=Yy.parse(a);return r.sessionUpdate(c)}default:if(r.extNotification)return r.extNotification(o,a);throw Ae.methodNotFound(o)}};S(this,J,new ZL(i,s,e))}async initialize(t){return await l(this,J).sendRequest(ue.initialize,t)}async newSession(t){return await l(this,J).sendRequest(ue.session_new,t)}async loadSession(t){return await l(this,J).sendRequest(ue.session_load,t)??{}}async unstable_forkSession(t){return await l(this,J).sendRequest(ue.session_fork,t)}async listSessions(t){return await l(this,J).sendRequest(ue.session_list,t)}async unstable_resumeSession(t){return await l(this,J).sendRequest(ue.session_resume,t)}async unstable_closeSession(t){return await l(this,J).sendRequest(ue.session_close,t)}async setSessionMode(t){return await l(this,J).sendRequest(ue.session_set_mode,t)??{}}async unstable_setSessionModel(t){return await l(this,J).sendRequest(ue.session_set_model,t)??{}}async setSessionConfigOption(t){return await l(this,J).sendRequest(ue.session_set_config_option,t)}async authenticate(t){return await l(this,J).sendRequest(ue.authenticate,t)??{}}async unstable_logout(t){return await l(this,J).sendRequest(ue.logout,t)??{}}async prompt(t){return await l(this,J).sendRequest(ue.session_prompt,t)}async cancel(t){return await l(this,J).sendNotification(ue.session_cancel,t)}async unstable_startNes(t){return await l(this,J).sendRequest(ue.nes_start,t)}async unstable_suggestNes(t){return await l(this,J).sendRequest(ue.nes_suggest,t)}async unstable_closeNes(t){return await l(this,J).sendRequest(ue.nes_close,t)??{}}async unstable_didOpenDocument(t){return await l(this,J).sendNotification(ue.document_did_open,t)}async unstable_didChangeDocument(t){return await l(this,J).sendNotification(ue.document_did_change,t)}async unstable_didCloseDocument(t){return await l(this,J).sendNotification(ue.document_did_close,t)}async unstable_didSaveDocument(t){return await l(this,J).sendNotification(ue.document_did_save,t)}async unstable_didFocusDocument(t){return await l(this,J).sendNotification(ue.document_did_focus,t)}async unstable_acceptNes(t){return await l(this,J).sendNotification(ue.nes_accept,t)}async unstable_rejectNes(t){return await l(this,J).sendNotification(ue.nes_reject,t)}async extMethod(t,e){return await l(this,J).sendRequest(t,e)}async extNotification(t,e){return await l(this,J).sendNotification(t,e)}get signal(){return l(this,J).signal}get closed(){return l(this,J).closed}}J=new WeakMap;var Dn,kl,Js,Qs,wi,Si,Ut,eo,pe,Jy,Ou,Qy,eb,tb,nb,Mu,As;class ZL{constructor(t,e,r){w(this,pe);w(this,Dn,new Map);w(this,kl,0);w(this,Js);w(this,Qs);w(this,wi);w(this,Si,Promise.resolve());w(this,Ut,new AbortController);w(this,eo);S(this,Js,t),S(this,Qs,e),S(this,wi,r),S(this,eo,new Promise(i=>{l(this,Ut).signal.addEventListener("abort",()=>i())})),f(this,pe,Jy).call(this)}get signal(){return l(this,Ut).signal}get closed(){return l(this,eo)}async sendRequest(t,e){f(this,pe,Mu).call(this);const r=cp(this,kl)._++,i=new Promise((s,o)=>{l(this,Dn).set(r,{resolve:s,reject:o})});return await f(this,pe,As).call(this,{jsonrpc:"2.0",id:r,method:t,params:e}),i}async sendNotification(t,e){f(this,pe,Mu).call(this),await f(this,pe,As).call(this,{jsonrpc:"2.0",method:t,params:e})}}Dn=new WeakMap,kl=new WeakMap,Js=new WeakMap,Qs=new WeakMap,wi=new WeakMap,Si=new WeakMap,Ut=new WeakMap,eo=new WeakMap,pe=new WeakSet,Jy=async function(){let t;try{const e=l(this,wi).readable.getReader();try{for(;!l(this,Ut).signal.aborted;){const{value:r,done:i}=await e.read();if(i)break;if(r)try{f(this,pe,Qy).call(this,r)}catch(s){console.error("Unexpected error during message processing:",r,s),"id"in r&&r.id!==void 0&&f(this,pe,As).call(this,{jsonrpc:"2.0",id:r.id,error:{code:-32700,message:"Parse error"}})}}}finally{e.releaseLock()}}catch(e){t=e}finally{f(this,pe,Ou).call(this,t)}},Ou=function(t){if(l(this,Ut).signal.aborted)return;const e=t??new Error("ACP connection closed");for(const r of l(this,Dn).values())r.reject(e);l(this,Dn).clear(),l(this,Ut).abort(e)},Qy=async function(t){if("method"in t&&"id"in t){const e=await f(this,pe,eb).call(this,t.method,t.params);"error"in e&&console.error("Error handling request",t,e.error),await f(this,pe,As).call(this,{jsonrpc:"2.0",id:t.id,...e})}else if("method"in t){const e=await f(this,pe,tb).call(this,t.method,t.params);"error"in e&&console.error("Error handling notification",t,e.error)}else"id"in t?f(this,pe,nb).call(this,t):console.error("Invalid message",{message:t})},eb=async function(t,e){try{return{result:await l(this,Js).call(this,t,e)??null}}catch(r){if(r instanceof Ae)return r.toResult();if(r instanceof og)return Ae.invalidParams(r.format()).toResult();let i;(r instanceof Error||typeof r=="object"&&r!=null&&"message"in r&&typeof r.message=="string")&&(i=r.message);try{return Ae.internalError(i?JSON.parse(i):{}).toResult()}catch{return Ae.internalError({details:i}).toResult()}}},tb=async function(t,e){try{return await l(this,Qs).call(this,t,e),{result:null}}catch(r){if(r instanceof Ae)return r.toResult();if(r instanceof og)return Ae.invalidParams(r.format()).toResult();let i;(r instanceof Error||typeof r=="object"&&r!=null&&"message"in r&&typeof r.message=="string")&&(i=r.message);try{return Ae.internalError(i?JSON.parse(i):{}).toResult()}catch{return Ae.internalError({details:i}).toResult()}}},nb=function(t){const e=l(this,Dn).get(t.id);if(e){if("result"in t)e.resolve(t.result);else if("error"in t){const{code:r,message:i,data:s}=t.error;e.reject(new Ae(r,i,s))}l(this,Dn).delete(t.id)}else console.error("Got response to unknown request",t.id)},Mu=function(){if(l(this,Ut).signal.aborted)throw l(this,Ut).signal.reason??new Error("ACP connection closed")},As=async function(t){return S(this,Si,l(this,Si).then(async()=>{const e=l(this,wi).writable.getWriter();try{await e.write(t)}finally{e.releaseLock()}}).catch(e=>{f(this,pe,Ou).call(this,e)})),l(this,Si)};class Ae extends Error{constructor(e,r,i){super(r);g(this,"code");g(this,"data");this.code=e,this.name="RequestError",this.data=i}static parseError(e,r){return new Ae(-32700,`Parse error${r?`: ${r}`:""}`,e)}static invalidRequest(e,r){return new Ae(-32600,`Invalid request${r?`: ${r}`:""}`,e)}static methodNotFound(e){return new Ae(-32601,`"Method not found": ${e}`,{method:e})}static invalidParams(e,r){return new Ae(-32602,`Invalid params${r?`: ${r}`:""}`,e)}static internalError(e,r){return new Ae(-32603,`Internal error${r?`: ${r}`:""}`,e)}static authRequired(e,r){return new Ae(-32e3,`Authentication required${r?`: ${r}`:""}`,e)}static resourceNotFound(e){return new Ae(-32002,`Resource not found${e?`: ${e}`:""}`,e&&{uri:e})}toResult(){return{error:{code:this.code,message:this.message,data:this.data}}}toErrorResponse(){return{code:this.code,message:this.message,data:this.data}}}const VL=/^Sender \(untrusted metadata\):\n```json\n[\s\S]*?\n```\n\n?/,BL=/^\[[^\n]*Working directory:[^\n]*\]\n\n?/,jL=/\[Television screen context\][\s\S]*?\[\/Television screen context\]\n*/,GL=/\b(tv|television|screen|artifact|artifacts|viewer|filmstrip|layout|focus)\b/i,qL=/\[\[\s*(?:reply_to_current|reply_to\s*:\s*[^\]\n]+|audio_as_voice)\s*\]\]\s*/gi,YL="single_session",XL={name:"television-acp-client",version:"0.0.0"},rb="agent:main:television",KL=Ko(tn);var _i,Ft,ot,Ht,Ln,St,fn,Wt,Zt,zn,_t,ki,xi,Vt,Be,gn,Ei,kr,mn,On,to,kt,Bt,xl,jt,I,Nu,ib,sb,ob,Ma,ab,lb,cb,ub,hb,db,pb,lr,ai,li,un,fb,ci,Uu,Fu,Na,gb,Ua,Hu,Wu,no,ro,Fa,ui,Zu,mb;class JL extends KL{constructor(e){super();w(this,I);w(this,_i,"disconnected");w(this,Ft,null);w(this,ot,new Map);w(this,Ht,null);w(this,Ln,null);w(this,St,null);w(this,fn,null);w(this,Wt,null);w(this,Zt,null);w(this,zn);w(this,_t,null);w(this,ki,0);w(this,xi,1);w(this,Vt,null);w(this,Be,null);w(this,gn,!1);w(this,Ei,!1);w(this,kr,!1);w(this,mn,null);w(this,On,new Set);w(this,to);w(this,kt);w(this,Bt);w(this,xl,e=>{f(this,I,sb).call(this,e)});w(this,jt,null);w(this,no,()=>{f(this,I,ui).call(this,"ACP bridge websocket closed")});w(this,ro,()=>{f(this,I,ui).call(this,"ACP bridge websocket error")});S(this,kt,e),S(this,Bt,e.sessionMode??YL),S(this,zn,e.mappedSessionStore??QL()),S(this,to,e.createSocket??(r=>new WebSocket(r)))}get status(){return l(this,_i)}get messages(){return[...l(this,ot).values()]}get enabled(){return l(this,kt).enabled??!1}setToken(e){l(this,kt).token=e??""}setEnabled(e){l(this,kt).enabled=e,e||(f(this,I,Fa).call(this),S(this,Ft,null),f(this,I,un).call(this,"disconnected"))}async connect(){if(this.disposed)throw new Error("ACPClient has been disposed");if(this.enabled&&this.status==="disconnected"){l(this,Ln)===null&&(S(this,Ft,null),S(this,Ln,f(this,I,ib).call(this)));try{await l(this,Ln),await f(this,I,Ma).call(this)}catch(e){throw f(this,I,ui).call(this,Kc(e)),e}}}dispose(){f(this,I,Fa).call(this),S(this,Ft,null),f(this,I,un).call(this,"disposed")}async sendMessage(e){if(await this.connect(),(this.status==="running"||this.status==="cancelling")&&(await this.cancel(),await f(this,I,Nu).call(this,"ready")),(l(this,Wt)===null||l(this,_t)!==f(this,I,Ua).call(this))&&await f(this,I,Ma).call(this),this.status!=="ready")throw new Error("ACPClient is not ready to send a new message");const r=e.text.trim();if(!r)throw new Error("Cannot send an empty message");f(this,I,ai).call(this,{id:f(this,I,ci).call(this,"user"),kind:"user",text:r,status:"final"}),f(this,I,un).call(this,"running");try{const i=await f(this,I,Na).call(this).prompt({sessionId:f(this,I,Fu).call(this),prompt:[{type:"text",text:f(this,I,fb).call(this,r)}]});f(this,I,lr).call(this,i.stopReason==="cancelled"?"cancelled":"final"),f(this,I,un).call(this,"ready")}catch(i){throw f(this,I,mb).call(this)||(f(this,I,lr).call(this,"error"),f(this,I,un).call(this,"ready")),i}}async startNewSession(){var r;await this.connect(),(this.status==="running"||this.status==="cancelling")&&(await this.cancel(),await f(this,I,Nu).call(this,"ready"));const e=f(this,I,Ua).call(this);((r=l(this,Zt))==null?void 0:r.sessionIdStrategy)==="mapped"?l(this,zn).clearActualSessionId(e):S(this,ki,l(this,ki)+1),S(this,St,null),S(this,fn,null),S(this,Wt,null),S(this,_t,null),f(this,I,Zu).call(this)}async cancel(){this.status==="running"&&(f(this,I,un).call(this,"cancelling"),await f(this,I,Na).call(this).cancel({sessionId:f(this,I,Fu).call(this)}))}setScreenContext(e){var s,o,a;if(e===null){if(l(this,Be)===null)return;S(this,Be,null),S(this,gn,!1);return}const r={screenID:e.screenID,screenName:e.screenName};if(((s=l(this,Be))==null?void 0:s.screenID)===r.screenID&&((o=l(this,Be))==null?void 0:o.screenName)===r.screenName)return;const i=((a=l(this,Be))==null?void 0:a.screenID)??null;if(S(this,Be,r),l(this,Bt)==="single_session"){(!l(this,_t)||i!==r.screenID)&&S(this,gn,!0);return}l(this,_t)!==f(this,I,Hu).call(this,r.screenID)&&(S(this,St,null),S(this,fn,null),l(this,Ht)&&this.status==="ready"&&f(this,I,Ma).call(this).catch(c=>{f(this,I,ui).call(this,Kc(c))}))}}_i=new WeakMap,Ft=new WeakMap,ot=new WeakMap,Ht=new WeakMap,Ln=new WeakMap,St=new WeakMap,fn=new WeakMap,Wt=new WeakMap,Zt=new WeakMap,zn=new WeakMap,_t=new WeakMap,ki=new WeakMap,xi=new WeakMap,Vt=new WeakMap,Be=new WeakMap,gn=new WeakMap,Ei=new WeakMap,kr=new WeakMap,mn=new WeakMap,On=new WeakMap,to=new WeakMap,kt=new WeakMap,Bt=new WeakMap,xl=new WeakMap,jt=new WeakMap,I=new WeakSet,Nu=async function(e){if(this.status!==e){if(this.status==="disposed")throw new Error("ACPClient has been disposed");if(this.status==="disconnected")throw new Error(l(this,Ft)??"ACPClient is disconnected");await new Promise((r,i)=>{const s=()=>{this.removeEventListener("status-changed",o)},o=()=>{if(this.status===e){s(),r();return}if(this.status==="disposed"){s(),i(new Error("ACPClient has been disposed"));return}this.status==="disconnected"&&(s(),i(new Error(l(this,Ft)??"ACPClient is disconnected")))};this.addEventListener("status-changed",o)})}},ib=async function(){try{const{stream:e,socket:r,metadata:i}=await r2({serverURL:l(this,kt).serverURL,token:l(this,kt).token,createSocket:l(this,to),onDisconnect:l(this,xl)});S(this,Zt,i),S(this,jt,r),r.addEventListener("close",l(this,no)),r.addEventListener("error",l(this,ro)),S(this,Ht,new WL(s=>({connection:s,sessionUpdate:async o=>{await f(this,I,lb).call(this,o)},requestPermission:async o=>f(this,I,cb).call(this,o)}),e)),await l(this,Ht).initialize({protocolVersion:ER,clientCapabilities:{},clientInfo:XL})}catch(e){throw e}},sb=function(e){f(this,I,ui).call(this,Kc(e))},ob=function(e){const r=e==null?void 0:e.models;if(!(r!=null&&r.currentModelId))return;const i=r.availableModels.find(s=>s.modelId===r.currentModelId);console.info("[ACPClient] Current model:",(i==null?void 0:i.name)??r.currentModelId,`(${r.currentModelId})`)},Ma=async function(){const e=f(this,I,Ua).call(this);if(l(this,St)&&l(this,fn)===e){await l(this,St);return}S(this,fn,e),S(this,St,f(this,I,ab).call(this,e)),await l(this,St)},ab=async function(e){var c;const r=f(this,I,Na).call(this);f(this,I,Zu).call(this);let i,s=!1,o=null;const a={cwd:f(this,I,gb).call(this),mcpServers:[],_meta:{sessionKey:e}};try{if(S(this,kr,!0),S(this,mn,null),((c=l(this,Zt))==null?void 0:c.sessionIdStrategy)==="mapped"){const u=l(this,zn).getActualSessionId(e);if(u)try{const h=await r.loadSession({...a,sessionId:u});if(e2(h))throw new Error("Mapped ACP session was not found");o=h,i=u,s=!0}catch{const h=await r.newSession(a);o=h,i=h.sessionId,l(this,zn).setActualSessionId(e,i),s=!1}else{const h=await r.newSession(a);o=h,i=h.sessionId,l(this,zn).setActualSessionId(e,i),s=!1}}else try{o=await r.loadSession({...a,sessionId:e}),i=e,s=l(this,ot).size>0}catch{const u=await r.newSession(a);o=u,i=u.sessionId,s=!1}}finally{S(this,kr,!1),S(this,mn,null),f(this,I,lr).call(this,"final")}f(this,I,ob).call(this,o),await r.setSessionConfigOption({sessionId:i,configId:"verbose_level",value:"full"}),S(this,Wt,i),S(this,_t,e),S(this,Ei,!0),s?(l(this,On).add(e),l(this,Bt)==="single_session"&&S(this,gn,!1)):(l(this,On).delete(e),S(this,gn,l(this,Bt)==="single_session")),S(this,Ft,null),f(this,I,un).call(this,"ready")},lb=async function(e){const r=e.update;switch(r.sessionUpdate){case"user_message_chunk":r.content.type==="text"&&f(this,I,pb).call(this,r.content.text);return;case"agent_message_chunk":r.content.type==="text"&&f(this,I,ub).call(this,r.content.text);return;case"tool_call":f(this,I,hb).call(this,r);return;case"tool_call_update":f(this,I,db).call(this,r);return;case"agent_thought_chunk":return;default:return}},cb=async function(e){return{outcome:{outcome:"cancelled"}}},ub=function(e){S(this,mn,null);const r=n2(e);if(!r)return;if(!l(this,Vt)){const s={id:f(this,I,ci).call(this,"assistant"),kind:"assistant",text:r,status:"streaming"};S(this,Vt,s.id),f(this,I,ai).call(this,s);return}const i=l(this,ot).get(l(this,Vt));if(!i||i.kind!=="assistant")throw new Error("Open assistant message invariant violated");f(this,I,li).call(this,{...i,text:`${i.text}${r}`,status:"streaming"})},hb=function(e){f(this,I,lr).call(this,"final");const r=f(this,I,Uu).call(this,e.toolCallId),i=pg("content"in e?e.content:void 0),s={id:(r==null?void 0:r.id)??f(this,I,ci).call(this,"tool"),kind:"tool_call",toolCallId:e.toolCallId,title:e.title,toolKind:e.kind??"other",status:e.status==="failed"?"failed":e.status==="completed"?"completed":"in_progress",text:(r==null?void 0:r.text)??i,locations:e.locations??(r==null?void 0:r.locations)};if(r){f(this,I,li).call(this,s);return}f(this,I,ai).call(this,s)},db=function(e){const r=f(this,I,Uu).call(this,e.toolCallId),i=(r==null?void 0:r.text)??"",s=pg(e.content),o=s?`${i}${s}`:i,a={id:(r==null?void 0:r.id)??f(this,I,ci).call(this,"tool"),kind:"tool_call",toolCallId:e.toolCallId,title:(r==null?void 0:r.title)??e.toolCallId,toolKind:(r==null?void 0:r.toolKind)??"other",status:e.status==="failed"?"failed":e.status==="completed"?"completed":"in_progress",text:o,locations:e.locations??(r==null?void 0:r.locations)};if(r){f(this,I,li).call(this,a);return}f(this,I,ai).call(this,a)},pb=function(e){if(f(this,I,lr).call(this,"final"),!e)return;const r=l(this,kr)?l(this,mn):null;if(!r){const s=dg(e);if(!s)return;const o={id:f(this,I,ci).call(this,"user"),kind:"user",text:s,status:"final"};f(this,I,ai).call(this,o),l(this,kr)&&S(this,mn,o.id);return}const i=l(this,ot).get(r);if(!i||i.kind!=="user")throw new Error("Replay user message invariant violated");f(this,I,li).call(this,{...i,text:dg(`${i.text}${e}`)})},lr=function(e){if(!l(this,Vt))return;const r=l(this,ot).get(l(this,Vt));(r==null?void 0:r.kind)==="assistant"&&f(this,I,li).call(this,{...r,status:e}),S(this,Vt,null)},ai=function(e){l(this,ot).set(e.id,e),this.dispatchEvent(new jc("messages-changed"))},li=function(e){l(this,ot).set(e.id,e),this.dispatchEvent(new jc("messages-changed"))},un=function(e){l(this,_i)!==e&&(S(this,_i,e),this.dispatchEvent(new XA("status-changed")))},fb=function(e){const r=l(this,_t);if(!r)return e;const i=l(this,Be)?l(this,Bt)==="single_session"?l(this,gn)||!l(this,On).has(r):!l(this,On).has(r):!1,s=l(this,Ei)&&(l(this,Be)!==null||GL.test(e));if(!(s||i))return e;s&&S(this,Ei,!1),i&&(S(this,gn,!1),l(this,On).add(r));const a=["[Television screen context]","This chat session is coming from a Television client.","Using Television requires the knowledge in the `television` skill. Re-read it only if it is not already in context or you know it changed.","If the skill is not installed, it can be installed via `tv skills install <your agent skills path>`."];return l(this,Be)?(a.push("This conversation is currently attached to the screen below."),a.push(`screen_id: ${l(this,Be).screenID}`),a.push(`screen_name: ${l(this,Be).screenName??""}`),a.push("When the user asks to inspect or change Television state with the tv CLI, use this screen ID with the --screen argument.")):a.push("There is currently no active Television screen."),a.push("[/Television screen context]","",e),a.join(`
|
|
43
|
+
`)},ci=function(e){const r=`${e}-${l(this,xi)}`;return S(this,xi,l(this,xi)+1),r},Uu=function(e){for(const r of l(this,ot).values())if((r==null?void 0:r.kind)==="tool_call"&&r.toolCallId===e)return r;return null},Fu=function(){if(!l(this,Wt))throw new Error("ACP session is not ready");return l(this,Wt)},Na=function(){if(!l(this,Ht))throw new Error("ACP connection is not ready");return l(this,Ht)},gb=function(){var r;const e=(r=l(this,Zt))==null?void 0:r.sessionCwd;if(!e)throw new Error("ACP bridge session cwd is not ready");return e},Ua=function(){var r;if(l(this,Bt)==="single_session")return f(this,I,Wu).call(this,`${rb}-${(l(this,kt).clientGUID??"default-client").toLowerCase()}`);const e=(r=l(this,Be))==null?void 0:r.screenID;if(!e)throw new Error("Screen context is required for per-screen session mode");return f(this,I,Hu).call(this,e)},Hu=function(e){return f(this,I,Wu).call(this,t2(l(this,Bt),e,l(this,kt).clientGUID??"default-client"))},Wu=function(e){var r;return((r=l(this,Zt))==null?void 0:r.sessionIdStrategy)==="deterministic"&&l(this,ki)>0?`${e}:epoch-${l(this,ki)}`:e},no=new WeakMap,ro=new WeakMap,Fa=function(){S(this,Ht,null),S(this,Ln,null),S(this,St,null),S(this,fn,null),S(this,Wt,null),S(this,_t,null),S(this,Zt,null),l(this,jt)&&(l(this,jt).removeEventListener("close",l(this,no)),l(this,jt).removeEventListener("error",l(this,ro)),l(this,jt).close(),S(this,jt,null))},ui=function(e){const r=l(this,Ht)!==null||l(this,Ln)!==null||l(this,St)!==null||l(this,fn)!==null||l(this,Wt)!==null||l(this,_t)!==null||l(this,Zt)!==null||l(this,jt)!==null;this.disposed||this.status==="disconnected"&&!r||(f(this,I,lr).call(this,"error"),f(this,I,Fa).call(this),S(this,Ft,e??null),f(this,I,un).call(this,"disconnected"))},Zu=function(){const e=l(this,ot).size>0;S(this,Vt,null),S(this,mn,null),S(this,xi,1),l(this,ot).clear(),e&&this.dispatchEvent(new jc("messages-changed"))},mb=function(){return this.status==="disconnected"};function QL(){const n=new Map;return{getActualSessionId(t){return n.get(t)??null},setActualSessionId(t,e){n.set(t,e)},clearActualSessionId(t){n.delete(t)}}}function e2(n){return n==null?!0:typeof n=="object"&&Object.keys(n).length===0}function t2(n,t,e){return n==="single_session"?`${rb}-${e.toLowerCase()}`:`agent:main:television-${e.toLowerCase()}-${t.toLowerCase()}`}function vb(n){return n.replace(/^(?:\s*\n)+/,"")}function dg(n){let t=n;return t=t.replace(VL,""),t=t.replace(BL,""),t=t.replace(jL,""),t=vb(t),t}function n2(n){let t=n;return t=t.replace(qL,""),t=vb(t),t}function pg(n){return!n||n.length===0?"":n.flatMap(t=>t.type==="content"&&t.content.type==="text"?[t.content.text]:[]).join("")}async function r2(n){const t=n.createSocket(o2(n.serverURL,n.token));let e=!1,r,i;const s=new Promise((u,h)=>{r=u,i=h}),o=new ReadableStream({start(u){let h=!1;const p=()=>{t.send(JSON.stringify({type:"acp-bridge-connect"}))},v=k=>{const T=s2(k);if(!T)return;let P;try{P=JSON.parse(T)}catch(R){const W=R instanceof Error?R:new Error(String(R));i(W),u.error(W);return}switch(P.type){case"acp-bridge-status":if(P.status==="ready"){let R;try{R=i2(P)}catch(W){const N=W instanceof Error?W:new Error(String(W));e||i(N),u.error(N);return}e||(e=!0,r(R));return}if(P.status==="error"||P.status==="exited"){const R=new Error(P.error??`ACP bridge ${P.status}`);e||i(R),u.error(R)}return;case"acp-bridge-message":u.enqueue(P.message);return}},m=()=>{var T;if(h)return;h=!0;const k=new Error("ACP bridge websocket closed");e||i(k),(T=n.onDisconnect)==null||T.call(n,k),u.close()},_=()=>{var T;if(h)return;h=!0;const k=new Error("ACP bridge websocket error");e||i(k),(T=n.onDisconnect)==null||T.call(n,k),u.error(k)};t.addEventListener("open",p),t.addEventListener("message",v),t.addEventListener("close",m),t.addEventListener("error",_)}}),a=new WritableStream({async write(u){await s,t.send(JSON.stringify({type:"acp-bridge-message",message:u}))},close(){t.close()},abort(){t.close()}}),c=await s;return{stream:{readable:o,writable:a},socket:t,metadata:c}}function i2(n){const{agent:t,sessionIdStrategy:e,sessionCwd:r}=n;if((t==="openclaw"||t==="hermes")&&(e==="deterministic"||e==="mapped")&&typeof r=="string"&&r.length>0)return{agent:t,sessionIdStrategy:e,sessionCwd:r};throw new Error("ACP bridge ready status missing bootstrap metadata")}function s2(n){if(typeof n=="string")return n;if(n instanceof Uint8Array)return new TextDecoder().decode(n);if(typeof Buffer<"u"&&n instanceof Buffer)return n.toString("utf8");if(typeof n=="object"&&n!==null&&"data"in n){const t=n.data;if(typeof t=="string")return t;if(t instanceof Uint8Array)return new TextDecoder().decode(t);if(Array.isArray(t))return Buffer.concat(t).toString("utf8")}return null}function o2(n,t){const e=new URL(n);return e.protocol=e.protocol==="https:"?"wss:":"ws:",e.pathname="/acp",e.search="",e.searchParams.set("token",t),e.hash="",e.toString()}function Kc(n){return n instanceof Error?n.message:String(n)}const fg="television.acpClientGUID",gg="television.acpMappedSessions",mg=1;var Ai;class a2{constructor(){w(this,Ai,new Map)}getActualSessionId(t){return l(this,Ai).get(t)??null}setActualSessionId(t,e){l(this,Ai).set(t,e)}clearActualSessionId(t){l(this,Ai).delete(t)}}Ai=new WeakMap;var $i,io,lt,Ha,Wa,Vu;class l2{constructor(t,e){w(this,lt);w(this,$i);w(this,io);S(this,$i,t),S(this,io,e)}getActualSessionId(t){const e=f(this,lt,Wa).call(this)[f(this,lt,Ha).call(this,t)];return typeof e=="string"&&e.length>0?e:null}setActualSessionId(t,e){const r=f(this,lt,Wa).call(this);r[f(this,lt,Ha).call(this,t)]=e,f(this,lt,Vu).call(this,r)}clearActualSessionId(t){const e=f(this,lt,Wa).call(this);delete e[f(this,lt,Ha).call(this,t)],f(this,lt,Vu).call(this,e)}}$i=new WeakMap,io=new WeakMap,lt=new WeakSet,Ha=function(t){return JSON.stringify([l(this,io),t])},Wa=function(){const t=l(this,$i).getItem(gg);if(!t)return{};let e;try{e=JSON.parse(t)}catch{return{}}if(typeof e!="object"||e===null||Array.isArray(e))return{};const r=e;return r.version!==mg?{}:typeof r.entries!="object"||r.entries===null||Array.isArray(r.entries)?{}:Object.fromEntries(Object.entries(r.entries).filter(i=>typeof i[1]=="string"))},Vu=function(t){const e={version:mg,entries:t};l(this,$i).setItem(gg,JSON.stringify(e))};function c2(){return typeof window>"u"?null:window.localStorage}function u2(n){const t=n.getItem(fg);if(t)return t;const e=jl().toLowerCase();return n.setItem(fg,e),e}const vg=4401,h2=401,_a=1e3,d2=3e4;class Os extends Error{constructor(t="Authentication required"){super(t),this.name="AuthError"}}class yb extends tn{constructor(e){var i,s;super();g(this,"url");g(this,"name");g(this,"status","unauthorized");g(this,"screens",new Map);g(this,"views",[]);g(this,"client");g(this,"acpClient");g(this,"_token");g(this,"attempting",!1);g(this,"nextRetryAt",null);g(this,"hasEverConnected",!1);g(this,"createSocket");g(this,"createClient");g(this,"socket",null);g(this,"connectAttempt",0);g(this,"autoReconnect",!1);g(this,"retryTimer",null);g(this,"retryDelay",_a);g(this,"visibilityEventTarget");g(this,"networkEventTarget");g(this,"onVisibilityChange");g(this,"onNetworkOnline");this.url=be(e.url),this.name=e.name,this._token=e.token??null,this.createSocket=e.createSocket??(o=>new WebSocket(o)),this.createClient=e.createClient??((o,a)=>new $1(o,{token:a??void 0})),this.client=this.createClient(this.url,this._token);const r=e.mappedSessionStore??(e.acpStorage?new l2(e.acpStorage,this.url):new a2);this.acpClient=new JL({serverURL:this.url,token:this._token??"",...e.createACPSocket?{createSocket:e.createACPSocket}:e.createSocket?{createSocket:e.createSocket}:{},...e.clientGUID?{clientGUID:e.clientGUID}:{},mappedSessionStore:r}),this.visibilityEventTarget=e.visibilityEventTarget!==void 0?e.visibilityEventTarget:typeof document<"u"?document:null,this.networkEventTarget=e.networkEventTarget!==void 0?e.networkEventTarget:typeof window<"u"?window:null,this.onVisibilityChange=()=>{this.isPageVisible()&&this.kickReconnect()},this.onNetworkOnline=()=>{this.kickReconnect()},(i=this.visibilityEventTarget)==null||i.addEventListener("visibilitychange",this.onVisibilityChange),(s=this.networkEventTarget)==null||s.addEventListener("online",this.onNetworkOnline)}get token(){return this._token}async connect(e){this._token=e,this.acpClient.setToken(e),this.cancelRetryTimer(),this.retryDelay=_a,this.autoReconnect=!0,await this.attempt()}dispose(){var e,r,i;this.autoReconnect=!1,this.connectAttempt+=1,this.cancelRetryTimer(),(e=this.socket)==null||e.close(),this.socket=null,this.setStatus("unauthorized"),(r=this.visibilityEventTarget)==null||r.removeEventListener("visibilitychange",this.onVisibilityChange),(i=this.networkEventTarget)==null||i.removeEventListener("online",this.onNetworkOnline),this.acpClient.dispose()}getViewURL(e){const r=xR(e.kind,this.views);if(!r)return null;const i=`${this.url}/views/${encodeURIComponent(r.id)}/`;return this._token===null?i:`${i}?token=${encodeURIComponent(this._token)}`}getContentURL(e){if(e.kind==="url")return null;const r=`${this.url}/artifacts/${encodeURIComponent(e.id)}/content/`;return this._token===null?r:`${r}?token=${encodeURIComponent(this._token)}`}async createScreen(e){const{screen:r}=await this.client.screens.create({name:e});return this.screens.set(r.id,structuredClone(r)),r}applyServerEvent(e){switch(e.type){case"screen-created":this.screens.set(e.screen.id,structuredClone(e.screen)),this.dispatchEvent(new za("screens-changed"));break;case"screen-updated":this.screens.set(e.screen.id,structuredClone(e.screen)),this.dispatchEvent(new za("screens-changed"));break;case"screen-removed":this.screens.delete(e.screenID),this.dispatchEvent(new za("screens-changed"));break;case"artifact-created":break;case"artifact-attached":{const r=this.screens.get(e.screenID);r&&!Rv(r.layout,e.artifact.id)&&(r.layout=[...r.layout,Cv(e.artifact.id,{id:e.cardID})]);break}case"artifact-removed":{const r=this.screens.get(e.screenID);r&&(r.layout=Sv(r.layout,e.artifactID));break}case"artifact-updated":case"artifact-content-changed":case"screen-changed":case"theme-changed":case"artifact-focus":break;default:return p2(e,"server event")}}async attempt(){var i;this.attempting=!0,this.nextRetryAt=null,this.connectAttempt+=1;const e=this.connectAttempt;(i=this.socket)==null||i.close(),this.client=this.createClient(this.url,this._token),this.setStatus("disconnected"),this.dispatchEvent(new ae("change"));const r=this.createSocket(f2(this.url,this._token));return this.socket=r,await new Promise((s,o)=>{let a=!1;const c=()=>{a||this.connectAttempt!==e||(a=!0,this.retryDelay=_a,this.hasEverConnected=!0,this.setStatus("connected"),s())},u=p=>{a||this.connectAttempt!==e||(a=!0,o(p))},h=async()=>{try{const[{screens:p},v,m]=await Promise.all([this.client.screens.list(),this.client.views.list(),this.client.display.get()]);this.screens=new Map(p.map(_=>[_.id,structuredClone(_)])),this.views=v,this.acpClient.setEnabled(m.acpEnabled),this.dispatchEvent(new ae("change")),this.dispatchEvent(new Tu("server-event",{serverURL:this.url,event:{type:"screen-changed",screenID:m.activeScreenID}})),c()}catch(p){if(v2(p)){u(new Os);return}u(p instanceof Error?p:new Error(String(p)))}};r.addEventListener("open",()=>{h()}),r.addEventListener("message",p=>{const v=m2(p);v&&(this.applyServerEvent(v),this.dispatchEvent(new Tu("server-event",{serverURL:this.url,event:v})))}),r.addEventListener("close",p=>{if(this.connectAttempt!==e)return;this.socket=null;const v=g2(p);if(!a){u(v===vg?new Os:new Error("Connection closed before initialization"));return}if(v===vg){this.autoReconnect=!1,this.cancelRetryTimer(),this.setStatus("unauthorized");return}this.handleTransportFailure(new Error("Connection closed"))}),r.addEventListener("error",()=>{if(this.connectAttempt===e){if(a){this.handleTransportFailure(new Error("WebSocket error"));return}u(new Error("WebSocket connection failed"))}})}).then(()=>{this.attempting=!1},s=>{throw this.attempting=!1,this.handleAttemptFailure(s),s})}handleAttemptFailure(e){if(e instanceof Os){this.autoReconnect=!1,this.cancelRetryTimer(),this.setStatus("unauthorized");return}this.autoReconnect&&this.scheduleRetry()}handleTransportFailure(e){this.autoReconnect&&(this.setStatus("disconnected"),this.scheduleRetry())}scheduleRetry(){this.cancelRetryTimer(),this.connectAttempt+=1;const e=this.retryDelay;this.retryDelay=Math.min(this.retryDelay*2,d2),this.nextRetryAt=Date.now()+e,this.retryTimer=setTimeout(()=>{this.retryTimer=null,this.attempt().catch(()=>{})},e),this.dispatchEvent(new ae("change"))}cancelRetryTimer(){this.retryTimer!==null&&(clearTimeout(this.retryTimer),this.retryTimer=null),this.nextRetryAt!==null&&(this.nextRetryAt=null,this.dispatchEvent(new ae("change")))}kickReconnect(){this.autoReconnect&&this.status!=="connected"&&(this.attempting||(this.cancelRetryTimer(),this.retryDelay=_a,this.attempt().catch(()=>{})))}setStatus(e){this.status!==e&&(this.status=e,this.dispatchEvent(new ae("change")))}isPageVisible(){return this.visibilityEventTarget===null?!0:this.visibilityEventTarget.visibilityState==="visible"}}function p2(n,t){throw new Error(`Unexpected ${t}: ${JSON.stringify(n)}`)}function f2(n,t){const e=new URL(n);return e.protocol=e.protocol==="https:"?"wss:":"ws:",e.pathname="/events",e.search="",t&&e.searchParams.set("token",t),e.hash="",e.toString()}function g2(n){return typeof n=="object"&&n!==null&&"code"in n&&typeof n.code=="number"?n.code:null}function m2(n){const t=typeof n=="string"?n:typeof n=="object"&&n!==null&&"data"in n&&typeof n.data=="string"?n.data:"";if(!t)return null;try{return JSON.parse(t)}catch{return null}}function v2(n){return n instanceof Lv&&n.status===h2}const y2="Local";var so,Bu;class b2 extends tn{constructor(e){super();w(this,so);g(this,"servers",new Map);g(this,"localServerURL");g(this,"clientGUID");g(this,"acpStorage");g(this,"localStore");g(this,"createSocket");g(this,"lastActiveServerURL");g(this,"serverListeners",new Map);g(this,"handleLocalStoreChange",()=>{const e=this.localStore.get().activeServerURL;e!==this.lastActiveServerURL&&(this.lastActiveServerURL=e,this.dispatchEvent(new ae("change")))});this.localStore=e.localStore,this.localServerURL=e.localServerURL?be(e.localServerURL):null,this.createSocket=e.createSocket??(i=>new WebSocket(i)),this.lastActiveServerURL=this.localStore.get().activeServerURL;const r=e.acpStorage===void 0?c2():e.acpStorage;this.acpStorage=r,this.clientGUID=e.clientGUID??(r?u2(r):jl().toLowerCase()),this.localStore.addEventListener("change",this.handleLocalStoreChange)}get activeServer(){const e=this.localStore.get().activeServerURL;return e===null?null:this.servers.get(e)??null}add(e){const r=be(e.url);this.servers.get(r)&&this.remove(r),this.servers.set(r,e);const s=()=>{this.dispatchEvent(new ae("change"))},o=c=>{this.dispatchEvent(new Tu("server-event",{serverURL:c.serverURL,event:c.event}))},a=()=>{this.dispatchEvent(new za("screens-changed"))};e.addEventListener("change",s),e.addEventListener("server-event",o),e.addEventListener("screens-changed",a),this.serverListeners.set(r,{onServerChange:s,onServerEvent:o,onScreensChanged:a}),this.dispatchEvent(new ae("change"))}remove(e){const r=be(e);if(this.localServerURL&&r===this.localServerURL)return;const i=this.servers.get(r);if(!i)return;const s=this.serverListeners.get(r);s&&(i.removeEventListener("change",s.onServerChange),i.removeEventListener("server-event",s.onServerEvent),i.removeEventListener("screens-changed",s.onScreensChanged),this.serverListeners.delete(r)),i.dispose(),this.servers.delete(r);const o=this.localStore.get(),a=o.activeServerURL===r;this.localStore.set({...o,servers:o.servers.filter(c=>c.url!==r),activeServerURL:a?null:o.activeServerURL}),this.dispatchEvent(new ae("change"))}setActive(e){const r=this.localStore.get(),i=e?be(e.url):null;r.activeServerURL!==i&&this.localStore.set({...r,activeServerURL:i})}connectConfiguredServers(e,r){const i=e?be(e):null;if(i){const a=this.localStore.get();a.servers.some(u=>be(u.url)===i)||this.localStore.set({...a,servers:[...a.servers,{url:i,name:y2}]})}const s=this.localStore.get().servers;for(const a of s){const c=be(a.url),h=i!==null&&c===i?r??null:null,p=f(this,so,Bu).call(this,{url:a.url,name:a.name,token:h});this.add(p),p.connect(h).catch(()=>{})}const o=i?this.servers.get(i)??null:null;this.setActive(o??this.servers.values().next().value??null)}addServer(e,r){const i=be(e);this.remove(i);const s=this.localStore.get();this.localStore.set({...s,servers:[...s.servers.filter(a=>be(a.url)!==i),{url:i,name:r}]});const o=f(this,so,Bu).call(this,{url:i,name:r,token:null});this.add(o),this.setActive(o),o.connect(null).catch(()=>{})}removeServer(e){this.remove(e)}}so=new WeakSet,Bu=function(e){return new yb({url:e.url,name:e.name,token:e.token,createSocket:this.createSocket,clientGUID:this.clientGUID,acpStorage:this.acpStorage})};var oo;class w2 extends tn{constructor(){super();w(this,oo,e=>{const r=S2(e);r!==null&&(e.preventDefault(),this.dispatchEvent(new YA("shortcut-triggered",{shortcut:r})))});document.addEventListener("keydown",l(this,oo))}dispose(){document.removeEventListener("keydown",l(this,oo))}}oo=new WeakMap;function S2(n){for(const[t,e]of Object.entries(T1))if(_2(n,e.trigger))return t;return null}function _2(n,t){return!(n.key.toLowerCase()!==t.key.toLowerCase()||n.metaKey!==!!t.meta||n.ctrlKey!==!!t.ctrl||n.shiftKey!==!!t.shift||n.altKey!==!!t.alt)}const k2="serverURL",x2="token",E2="mode",A2="electron";function bb(n=window.location.search,t=window.location.origin){const r=new URLSearchParams(n).get(k2);return r?new URL(r).origin:new URL(t).origin}function yg(n=window.location.search){return new URLSearchParams(n).get(x2)}function wd(n=window.location.search){return new URLSearchParams(n).get(E2)===A2}let $n=null;async function wb(n,t){if($n==null||$n.abort(),n===null){$n=null,al();return}const e=new AbortController;$n=e;try{const r=t.token?{Authorization:`Bearer ${t.token}`}:void 0,i=new URL(`/themes/${n}/theme.css`,t.url).toString(),s=await fetch(i,{signal:e.signal,...r?{headers:r}:{}});if(!s.ok)throw new Error(`Theme fetch failed: ${s.status}`);const o=await s.text();if($n!==e)return;vv(o)}catch(r){if(r.name==="AbortError")return;al();const i=r instanceof Error?r.message:String(r);console.warn(`applyTheme: ${i}`)}finally{$n===e&&($n=null)}}/**
|
|
44
44
|
* @license
|
|
45
45
|
* Copyright 2017 Google LLC
|
|
46
46
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
47
|
-
*/const
|
|
48
|
-
\f\r]`,
|
|
49
|
-
\f\r"'\`<>=]|("|')|))|$)`,"g"),
|
|
47
|
+
*/const Ms=globalThis,bg=n=>n,fl=Ms.trustedTypes,wg=fl?fl.createPolicy("lit-html",{createHTML:n=>n}):void 0,Sb="$lit$",Cn=`lit$${Math.random().toFixed(9).slice(2)}$`,_b="?"+Cn,$2=`<${_b}>`,Mr=document,Vs=()=>Mr.createComment(""),Bs=n=>n===null||typeof n!="object"&&typeof n!="function",Sd=Array.isArray,T2=n=>Sd(n)||typeof(n==null?void 0:n[Symbol.iterator])=="function",Jc=`[
|
|
48
|
+
\f\r]`,gs=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Sg=/-->/g,_g=/>/g,ir=RegExp(`>|${Jc}(?:([^\\s"'>=/]+)(${Jc}*=${Jc}*(?:[^
|
|
49
|
+
\f\r"'\`<>=]|("|')|))|$)`,"g"),kg=/'/g,xg=/"/g,kb=/^(?:script|style|textarea|title)$/i,I2=n=>(t,...e)=>({_$litType$:n,strings:t,values:e}),z=I2(1),Nr=Symbol.for("lit-noChange"),se=Symbol.for("lit-nothing"),Eg=new WeakMap,mr=Mr.createTreeWalker(Mr,129);function xb(n,t){if(!Sd(n)||!n.hasOwnProperty("raw"))throw Error("invalid template strings array");return wg!==void 0?wg.createHTML(t):t}const C2=(n,t)=>{const e=n.length-1,r=[];let i,s=t===2?"<svg>":t===3?"<math>":"",o=gs;for(let a=0;a<e;a++){const c=n[a];let u,h,p=-1,v=0;for(;v<c.length&&(o.lastIndex=v,h=o.exec(c),h!==null);)v=o.lastIndex,o===gs?h[1]==="!--"?o=Sg:h[1]!==void 0?o=_g:h[2]!==void 0?(kb.test(h[2])&&(i=RegExp("</"+h[2],"g")),o=ir):h[3]!==void 0&&(o=ir):o===ir?h[0]===">"?(o=i??gs,p=-1):h[1]===void 0?p=-2:(p=o.lastIndex-h[2].length,u=h[1],o=h[3]===void 0?ir:h[3]==='"'?xg:kg):o===xg||o===kg?o=ir:o===Sg||o===_g?o=gs:(o=ir,i=void 0);const m=o===ir&&n[a+1].startsWith("/>")?" ":"";s+=o===gs?c+$2:p>=0?(r.push(u),c.slice(0,p)+Sb+c.slice(p)+Cn+m):c+Cn+(p===-2?a:m)}return[xb(n,s+(n[e]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),r]};class js{constructor({strings:t,_$litType$:e},r){let i;this.parts=[];let s=0,o=0;const a=t.length-1,c=this.parts,[u,h]=C2(t,e);if(this.el=js.createElement(u,r),mr.currentNode=this.el.content,e===2||e===3){const p=this.el.content.firstChild;p.replaceWith(...p.childNodes)}for(;(i=mr.nextNode())!==null&&c.length<a;){if(i.nodeType===1){if(i.hasAttributes())for(const p of i.getAttributeNames())if(p.endsWith(Sb)){const v=h[o++],m=i.getAttribute(p).split(Cn),_=/([.?@])?(.*)/.exec(v);c.push({type:1,index:s,name:_[2],strings:m,ctor:_[1]==="."?P2:_[1]==="?"?D2:_[1]==="@"?L2:nc}),i.removeAttribute(p)}else p.startsWith(Cn)&&(c.push({type:6,index:s}),i.removeAttribute(p));if(kb.test(i.tagName)){const p=i.textContent.split(Cn),v=p.length-1;if(v>0){i.textContent=fl?fl.emptyScript:"";for(let m=0;m<v;m++)i.append(p[m],Vs()),mr.nextNode(),c.push({type:2,index:++s});i.append(p[v],Vs())}}}else if(i.nodeType===8)if(i.data===_b)c.push({type:2,index:s});else{let p=-1;for(;(p=i.data.indexOf(Cn,p+1))!==-1;)c.push({type:7,index:s}),p+=Cn.length-1}s++}}static createElement(t,e){const r=Mr.createElement("template");return r.innerHTML=t,r}}function Yi(n,t,e=n,r){var o,a;if(t===Nr)return t;let i=r!==void 0?(o=e._$Co)==null?void 0:o[r]:e._$Cl;const s=Bs(t)?void 0:t._$litDirective$;return(i==null?void 0:i.constructor)!==s&&((a=i==null?void 0:i._$AO)==null||a.call(i,!1),s===void 0?i=void 0:(i=new s(n),i._$AT(n,e,r)),r!==void 0?(e._$Co??(e._$Co=[]))[r]=i:e._$Cl=i),i!==void 0&&(t=Yi(n,i._$AS(n,t.values),i,r)),t}class R2{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:e},parts:r}=this._$AD,i=((t==null?void 0:t.creationScope)??Mr).importNode(e,!0);mr.currentNode=i;let s=mr.nextNode(),o=0,a=0,c=r[0];for(;c!==void 0;){if(o===c.index){let u;c.type===2?u=new tc(s,s.nextSibling,this,t):c.type===1?u=new c.ctor(s,c.name,c.strings,this,t):c.type===6&&(u=new z2(s,this,t)),this._$AV.push(u),c=r[++a]}o!==(c==null?void 0:c.index)&&(s=mr.nextNode(),o++)}return mr.currentNode=Mr,i}p(t){let e=0;for(const r of this._$AV)r!==void 0&&(r.strings!==void 0?(r._$AI(t,r,e),e+=r.strings.length-2):r._$AI(t[e])),e++}}let tc=class Eb{get _$AU(){var t;return((t=this._$AM)==null?void 0:t._$AU)??this._$Cv}constructor(t,e,r,i){this.type=2,this._$AH=se,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=r,this.options=i,this._$Cv=(i==null?void 0:i.isConnected)??!0}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return e!==void 0&&(t==null?void 0:t.nodeType)===11&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=Yi(this,t,e),Bs(t)?t===se||t==null||t===""?(this._$AH!==se&&this._$AR(),this._$AH=se):t!==this._$AH&&t!==Nr&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):T2(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==se&&Bs(this._$AH)?this._$AA.nextSibling.data=t:this.T(Mr.createTextNode(t)),this._$AH=t}$(t){var s;const{values:e,_$litType$:r}=t,i=typeof r=="number"?this._$AC(t):(r.el===void 0&&(r.el=js.createElement(xb(r.h,r.h[0]),this.options)),r);if(((s=this._$AH)==null?void 0:s._$AD)===i)this._$AH.p(e);else{const o=new R2(i,this),a=o.u(this.options);o.p(e),this.T(a),this._$AH=o}}_$AC(t){let e=Eg.get(t.strings);return e===void 0&&Eg.set(t.strings,e=new js(t)),e}k(t){Sd(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let r,i=0;for(const s of t)i===e.length?e.push(r=new Eb(this.O(Vs()),this.O(Vs()),this,this.options)):r=e[i],r._$AI(s),i++;i<e.length&&(this._$AR(r&&r._$AB.nextSibling,i),e.length=i)}_$AR(t=this._$AA.nextSibling,e){var r;for((r=this._$AP)==null?void 0:r.call(this,!1,!0,e);t!==this._$AB;){const i=bg(t).nextSibling;bg(t).remove(),t=i}}setConnected(t){var e;this._$AM===void 0&&(this._$Cv=t,(e=this._$AP)==null||e.call(this,t))}},nc=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,r,i,s){this.type=1,this._$AH=se,this._$AN=void 0,this.element=t,this.name=e,this._$AM=i,this.options=s,r.length>2||r[0]!==""||r[1]!==""?(this._$AH=Array(r.length-1).fill(new String),this.strings=r):this._$AH=se}_$AI(t,e=this,r,i){const s=this.strings;let o=!1;if(s===void 0)t=Yi(this,t,e,0),o=!Bs(t)||t!==this._$AH&&t!==Nr,o&&(this._$AH=t);else{const a=t;let c,u;for(t=s[0],c=0;c<s.length-1;c++)u=Yi(this,a[r+c],e,c),u===Nr&&(u=this._$AH[c]),o||(o=!Bs(u)||u!==this._$AH[c]),u===se?t=se:t!==se&&(t+=(u??"")+s[c+1]),this._$AH[c]=u}o&&!i&&this.j(t)}j(t){t===se?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}},P2=class extends nc{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===se?void 0:t}},D2=class extends nc{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==se)}},L2=class extends nc{constructor(t,e,r,i,s){super(t,e,r,i,s),this.type=5}_$AI(t,e=this){if((t=Yi(this,t,e,0)??se)===Nr)return;const r=this._$AH,i=t===se&&r!==se||t.capture!==r.capture||t.once!==r.once||t.passive!==r.passive,s=t!==se&&(r===se||i);i&&this.element.removeEventListener(this.name,this,r),s&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var e;typeof this._$AH=="function"?this._$AH.call(((e=this.options)==null?void 0:e.host)??this.element,t):this._$AH.handleEvent(t)}};class z2{constructor(t,e,r){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=r}get _$AU(){return this._$AM._$AU}_$AI(t){Yi(this,t)}}const O2={I:tc},Qc=Ms.litHtmlPolyfillSupport;Qc==null||Qc(js,tc),(Ms.litHtmlVersions??(Ms.litHtmlVersions=[])).push("3.3.2");const Ce=(n,t,e)=>{const r=t;let i=r._$litPart$;return i===void 0&&(r._$litPart$=i=new tc(t.insertBefore(Vs(),null),null,void 0,{})),i._$AI(n),i};/**
|
|
50
50
|
* @license
|
|
51
51
|
* Copyright 2017 Google LLC
|
|
52
52
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
53
|
-
*/const
|
|
53
|
+
*/const _d={CHILD:2},rc=n=>(...t)=>({_$litDirective$:n,values:t});let kd=class{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,r){this._$Ct=t,this._$AM=e,this._$Ci=r}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}};/**
|
|
54
54
|
* @license
|
|
55
55
|
* Copyright 2017 Google LLC
|
|
56
56
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
57
|
-
*/let
|
|
57
|
+
*/let gl=class extends kd{constructor(t){if(super(t),this.it=se,t.type!==_d.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(t){if(t===se||t==null)return this._t=void 0,this.it=t;if(t===Nr)return t;if(typeof t!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(t===this.it)return this._t;this.it=t;const e=[t];return e.raw=e,this._t={_$litType$:this.constructor.resultType,strings:e,values:[]}}};gl.directiveName="unsafeHTML",gl.resultType=1;const M2=rc(gl);/**
|
|
58
58
|
* @license
|
|
59
59
|
* Copyright 2017 Google LLC
|
|
60
60
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
61
|
-
*/let
|
|
61
|
+
*/let ju=class extends gl{};ju.directiveName="unsafeSVG",ju.resultType=2;const Ab=rc(ju),N2={size:16,color:"currentColor",weight:"regular"};function U2(n){return typeof n=="string"?{regular:n}:n}function nn(n,t="0 0 256 256"){const e=U2(n);return r=>{const{size:i,color:s,weight:o}={...N2,...r},a=e[o]??e.regular;return z`<svg
|
|
62
62
|
xmlns="http://www.w3.org/2000/svg"
|
|
63
63
|
data-ui-icon=""
|
|
64
64
|
width="${i}"
|
|
65
65
|
height="${i}"
|
|
66
66
|
viewBox="${t}"
|
|
67
67
|
fill="${s}"
|
|
68
|
-
>${
|
|
68
|
+
>${Ab(a)}</svg>`}}/**
|
|
69
69
|
* @license
|
|
70
70
|
* Copyright 2020 Google LLC
|
|
71
71
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
72
|
-
*/const{I:
|
|
72
|
+
*/const{I:F2}=O2,Ag=n=>n,H2=n=>n.strings===void 0,$g=()=>document.createComment(""),ms=(n,t,e)=>{var s;const r=n._$AA.parentNode,i=t===void 0?n._$AB:t._$AA;if(e===void 0){const o=r.insertBefore($g(),i),a=r.insertBefore($g(),i);e=new F2(o,a,n,n.options)}else{const o=e._$AB.nextSibling,a=e._$AM,c=a!==n;if(c){let u;(s=e._$AQ)==null||s.call(e,n),e._$AM=n,e._$AP!==void 0&&(u=n._$AU)!==a._$AU&&e._$AP(u)}if(o!==i||c){let u=e._$AA;for(;u!==o;){const h=Ag(u).nextSibling;Ag(r).insertBefore(u,i),u=h}}}return e},sr=(n,t,e=n)=>(n._$AI(t,e),n),W2={},Z2=(n,t=W2)=>n._$AH=t,V2=n=>n._$AH,eu=n=>{n._$AR(),n._$AA.remove()};/**
|
|
73
73
|
* @license
|
|
74
74
|
* Copyright 2017 Google LLC
|
|
75
75
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
76
|
-
*/const
|
|
76
|
+
*/const Ns=(n,t)=>{var r;const e=n._$AN;if(e===void 0)return!1;for(const i of e)(r=i._$AO)==null||r.call(i,t,!1),Ns(i,t);return!0},ml=n=>{let t,e;do{if((t=n._$AM)===void 0)break;e=t._$AN,e.delete(n),n=t}while((e==null?void 0:e.size)===0)},$b=n=>{for(let t;t=n._$AM;n=t){let e=t._$AN;if(e===void 0)t._$AN=e=new Set;else if(e.has(n))break;e.add(n),G2(t)}};function B2(n){this._$AN!==void 0?(ml(this),this._$AM=n,$b(this)):this._$AM=n}function j2(n,t=!1,e=0){const r=this._$AH,i=this._$AN;if(i!==void 0&&i.size!==0)if(t)if(Array.isArray(r))for(let s=e;s<r.length;s++)Ns(r[s],!1),ml(r[s]);else r!=null&&(Ns(r,!1),ml(r));else Ns(this,n)}const G2=n=>{n.type==_d.CHILD&&(n._$AP??(n._$AP=j2),n._$AQ??(n._$AQ=B2))};class q2 extends kd{constructor(){super(...arguments),this._$AN=void 0}_$AT(t,e,r){super._$AT(t,e,r),$b(this),this.isConnected=t._$AU}_$AO(t,e=!0){var r,i;t!==this.isConnected&&(this.isConnected=t,t?(r=this.reconnected)==null||r.call(this):(i=this.disconnected)==null||i.call(this)),e&&(Ns(this,t),ml(this))}setValue(t){if(H2(this._$Ct))this._$Ct._$AI(t,this);else{const e=[...this._$Ct._$AH];e[this._$Ci]=t,this._$Ct._$AI(e,this,0)}}disconnected(){}reconnected(){}}/**
|
|
77
77
|
* @license
|
|
78
78
|
* Copyright 2020 Google LLC
|
|
79
79
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
80
|
-
*/const
|
|
80
|
+
*/const Za=()=>new Y2;class Y2{}const tu=new WeakMap,Va=rc(class extends q2{render(n){return se}update(n,[t]){var r;const e=t!==this.G;return e&&this.G!==void 0&&this.rt(void 0),(e||this.lt!==this.ct)&&(this.G=t,this.ht=(r=n.options)==null?void 0:r.host,this.rt(this.ct=n.element)),se}rt(n){if(this.isConnected||(n=void 0),typeof this.G=="function"){const t=this.ht??globalThis;let e=tu.get(t);e===void 0&&(e=new WeakMap,tu.set(t,e)),e.get(this.G)!==void 0&&this.G.call(this.ht,void 0),e.set(this.G,n),n!==void 0&&this.G.call(this.ht,n)}else this.G.value=n}get lt(){var n,t;return typeof this.G=="function"?(n=tu.get(this.ht??globalThis))==null?void 0:n.get(this.G):(t=this.G)==null?void 0:t.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}}),X2=nn('<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"/>'),xd=nn('<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"/>'),K2=nn('<path d="M216,56V200a16,16,0,0,1-16,16H56a16,16,0,0,1-16-16V56A16,16,0,0,1,56,40H200A16,16,0,0,1,216,56Z"/>'),vl=nn('<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"/>'),J2=nn('<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"/>'),Q2=nn({regular:'<path d="M216,64H147.31l34.35-34.34a8,8,0,1,0-11.32-11.32L128,60.69,85.66,18.34A8,8,0,0,0,74.34,29.66L108.69,64H40A16,16,0,0,0,24,80V200a16,16,0,0,0,16,16H216a16,16,0,0,0,16-16V80A16,16,0,0,0,216,64Zm0,136H40V80H216V200Z"/>',bold:'<path d="M216,60H157l27.52-27.52a12,12,0,0,0-17-17L128,55,88.49,15.51a12,12,0,0,0-17,17L99,60H40A20,20,0,0,0,20,80V200a20,20,0,0,0,20,20H216a20,20,0,0,0,20-20V80A20,20,0,0,0,216,60Zm-4,136H44V84H212Z"/>'}),ez=nn({regular:'<path d="M104,40H56A16,16,0,0,0,40,56v48a16,16,0,0,0,16,16h48a16,16,0,0,0,16-16V56A16,16,0,0,0,104,40Zm0,64H56V56h48v48Zm96-64H152a16,16,0,0,0-16,16v48a16,16,0,0,0,16,16h48a16,16,0,0,0,16-16V56A16,16,0,0,0,200,40Zm0,64H152V56h48v48Zm-96,32H56a16,16,0,0,0-16,16v48a16,16,0,0,0,16,16h48a16,16,0,0,0,16-16V152A16,16,0,0,0,104,136Zm0,64H56V152h48v48Zm96-64H152a16,16,0,0,0-16,16v48a16,16,0,0,0,16,16h48a16,16,0,0,0,16-16V152A16,16,0,0,0,200,136Zm0,64H152V152h48v48Z"/>',bold:'<path d="M100,36H56A20,20,0,0,0,36,56v44a20,20,0,0,0,20,20h44a20,20,0,0,0,20-20V56A20,20,0,0,0,100,36ZM96,96H60V60H96ZM200,36H156a20,20,0,0,0-20,20v44a20,20,0,0,0,20,20h44a20,20,0,0,0,20-20V56A20,20,0,0,0,200,36Zm-4,60H160V60h36Zm-96,40H56a20,20,0,0,0-20,20v44a20,20,0,0,0,20,20h44a20,20,0,0,0,20-20V156A20,20,0,0,0,100,136Zm-4,60H60V160H96Zm104-60H156a20,20,0,0,0-20,20v44a20,20,0,0,0,20,20h44a20,20,0,0,0,20-20V156A20,20,0,0,0,200,136Zm-4,60H160V160h36Z"/>'}),tz=nn('<path d="M224,128a8,8,0,0,1-8,8H136v80a8,8,0,0,1-16,0V136H40a8,8,0,0,1,0-16h80V40a8,8,0,0,1,16,0v80h80A8,8,0,0,1,224,128Z"/>'),Tb=nn({regular:'<path d="M136,32V64a8,8,0,0,1-16,0V32a8,8,0,0,1,16,0Zm88,88H192a8,8,0,0,0,0,16h32a8,8,0,0,0,0-16Zm-45.09,47.6a8,8,0,0,0-11.31,11.31l22.62,22.63a8,8,0,0,0,11.32-11.32ZM128,184a8,8,0,0,0-8,8v32a8,8,0,0,0,16,0V192A8,8,0,0,0,128,184ZM77.09,167.6,54.46,190.22a8,8,0,0,0,11.32,11.32L88.4,178.91A8,8,0,0,0,77.09,167.6ZM72,128a8,8,0,0,0-8-8H32a8,8,0,0,0,0,16H64A8,8,0,0,0,72,128ZM65.78,54.46A8,8,0,0,0,54.46,65.78L77.09,88.4A8,8,0,0,0,88.4,77.09Z"/>',bold:'<path d="M140,32V64a12,12,0,0,1-24,0V32a12,12,0,0,1,24,0Zm84,84H192a12,12,0,0,0,0,24h32a12,12,0,0,0,0-24Zm-42.26,48.77a12,12,0,1,0-17,17l22.63,22.63a12,12,0,0,0,17-17ZM128,180a12,12,0,0,0-12,12v32a12,12,0,0,0,24,0V192A12,12,0,0,0,128,180ZM74.26,164.77,51.63,187.4a12,12,0,0,0,17,17l22.63-22.63a12,12,0,1,0-17-17ZM76,128a12,12,0,0,0-12-12H32a12,12,0,0,0,0,24H64A12,12,0,0,0,76,128ZM68.6,51.63a12,12,0,1,0-17,17L74.26,91.23a12,12,0,0,0,17-17Z"/>'}),nz=nn('<path d="M173.66,98.34a8,8,0,0,1,0,11.32l-56,56a8,8,0,0,1-11.32,0l-24-24a8,8,0,0,1,11.32-11.32L112,148.69l50.34-50.35A8,8,0,0,1,173.66,98.34ZM232,128A104,104,0,1,1,128,24,104.11,104.11,0,0,1,232,128Zm-16,0a88,88,0,1,0-88,88A88.1,88.1,0,0,0,216,128Z"/>');class rz extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}const Tg='a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])',nu=4;var ze,Qe,xr,et,ao,Ti,Ii,V,Gu,qu,Cb,Ba,Rb,Yu,Xu,lo,co,Er,Pb,Ku,Db,Lb,ja,hi;class Ib extends HTMLElement{constructor(){super();w(this,V);w(this,ze,!1);w(this,Qe,null);w(this,xr);w(this,et,null);w(this,ao,"bottom-start");w(this,Ti,!1);w(this,Ii,!1);w(this,lo,e=>{l(this,ze)&&(l(this,Ti)||e.composedPath().includes(this)||(this.open=!1))});w(this,co,e=>{if(l(this,ze)){if(e.key==="Escape"){e.preventDefault(),this.open=!1;return}e.key==="Tab"&&f(this,V,Pb).call(this,e)}});w(this,Er,()=>{l(this,ze)&&f(this,V,ja).call(this)});S(this,xr,this.attachShadow({mode:"open"})),od(l(this,xr)),f(this,V,qu).call(this,"anchor")}connectedCallback(){this.removeAttribute("popover"),this.hasAttribute("tone")||this.setAttribute("tone","light"),f(this,V,qu).call(this,"open"),f(this,V,hi).call(this),l(this,ze)&&(f(this,V,Yu).call(this),f(this,V,Ba).call(this))}disconnectedCallback(){var e;f(this,V,Xu).call(this),(e=l(this,Qe))==null||e.removeAttribute("aria-expanded")}attributeChangedCallback(e){e==="open"?f(this,V,Cb).call(this,this.hasAttribute("open")):e==="material"&&l(this,ze)&&(f(this,V,hi).call(this),f(this,V,Ba).call(this))}get open(){return l(this,ze)}set open(e){this.toggleAttribute("open",e)}get anchor(){return l(this,Qe)}set anchor(e){l(this,Qe)!==e&&(l(this,Qe)&&l(this,Qe).removeAttribute("aria-expanded"),S(this,Qe,e),f(this,V,Gu).call(this),l(this,ze)&&f(this,V,ja).call(this))}}ze=new WeakMap,Qe=new WeakMap,xr=new WeakMap,et=new WeakMap,ao=new WeakMap,Ti=new WeakMap,Ii=new WeakMap,V=new WeakSet,Gu=function(){l(this,Qe)&&l(this,Qe).setAttribute("aria-expanded",l(this,ze)?"true":"false")},qu=function(e){if(!Object.prototype.hasOwnProperty.call(this,e))return;const r=this,i=r[e];delete r[e],r[e]=i},Cb=function(e){var r,i,s;if(l(this,ze)!==e){if(S(this,ze,e),f(this,V,Gu).call(this),!this.isConnected){f(this,V,hi).call(this);return}e?(S(this,Ti,!0),setTimeout(()=>{S(this,Ti,!1)},0),f(this,V,hi).call(this),f(this,V,Yu).call(this),f(this,V,Ba).call(this)):(f(this,V,Xu).call(this),(i=(r=l(this,et))==null?void 0:r.hidePopover)==null||i.call(r),f(this,V,hi).call(this),(s=l(this,Qe))==null||s.focus(),this.dispatchEvent(new rz))}},Ba=function(){l(this,Ii)||(S(this,Ii,!0),queueMicrotask(()=>{S(this,Ii,!1),!(!l(this,ze)||!this.isConnected)&&(f(this,V,Rb).call(this),f(this,V,Lb).call(this))}))},Rb=function(){var e,r;if(l(this,et)){try{(r=(e=l(this,et)).showPopover)==null||r.call(e)}catch{}f(this,V,ja).call(this)}},Yu=function(){document.addEventListener("click",l(this,lo)),document.addEventListener("keydown",l(this,co),!0),window.addEventListener("resize",l(this,Er)),window.addEventListener("scroll",l(this,Er),!0)},Xu=function(){document.removeEventListener("click",l(this,lo)),document.removeEventListener("keydown",l(this,co),!0),window.removeEventListener("resize",l(this,Er)),window.removeEventListener("scroll",l(this,Er),!0)},lo=new WeakMap,co=new WeakMap,Er=new WeakMap,Pb=function(e){const r=f(this,V,Ku).call(this);if(r.length===0){e.preventDefault();return}const i=r[0],s=r[r.length-1],o=f(this,V,Db).call(this),a=o instanceof HTMLElement&&r.includes(o);e.shiftKey?(!a||o===i)&&(e.preventDefault(),s.focus()):(!a||o===s)&&(e.preventDefault(),i.focus())},Ku=function(){if(!l(this,et))return[];const e=l(this,et).querySelector("slot");if(!(e instanceof HTMLSlotElement))return[];const r=[];for(const i of e.assignedElements({flatten:!0}))if(i instanceof HTMLElement){i.matches(Tg)&&r.push(i);for(const s of i.querySelectorAll(Tg))r.push(s)}return r},Db=function(){var r;let e=document.activeElement;for(;e&&((r=e.shadowRoot)!=null&&r.activeElement);)e=e.shadowRoot.activeElement;return e},Lb=function(){var r;const e=f(this,V,Ku).call(this);e.length>0?e[0].focus():(r=l(this,et))==null||r.focus()},ja=function(){if(!l(this,ze)||!l(this,Qe)||!l(this,et))return;const e=l(this,Qe).getBoundingClientRect(),r=l(this,et).getBoundingClientRect(),s=window.innerHeight-e.bottom,o=r.height+nu,a=s<o&&e.top>o?"top-start":"bottom-start";S(this,ao,a);const c=a==="bottom-start"?e.bottom+nu:e.top-r.height-nu,u=e.left;l(this,et).style.transform=`translate(${u}px, ${c}px)`,l(this,et).setAttribute("data-placement",a)},hi=function(){this.toggleAttribute("open",l(this,ze));const e=this.getAttribute("material")??"paper";Ce(l(this,ze)?z`<div
|
|
81
81
|
class="panel"
|
|
82
82
|
part="panel"
|
|
83
83
|
popover="manual"
|
|
84
|
-
data-placement=${l(this,
|
|
84
|
+
data-placement=${l(this,ao)}
|
|
85
85
|
tabindex="-1"
|
|
86
86
|
role="dialog"
|
|
87
87
|
material=${e}
|
|
88
88
|
level="1"
|
|
89
89
|
>
|
|
90
90
|
<slot></slot>
|
|
91
|
-
</div>`:se,l(this,
|
|
92
|
-
<slot name="trigger" @slotchange=${l(this,
|
|
91
|
+
</div>`:se,l(this,xr)),S(this,et,l(this,xr).querySelector(".panel"))},g(Ib,"observedAttributes",["open","material"]);customElements.get("ui-popover")||customElements.define("ui-popover",Ib);class zb extends Event{constructor(e){super("dropdown-item-select",{bubbles:!0,composed:!0});g(this,"value");this.value=e}}class iz extends Event{constructor(e){super("select",{bubbles:!0,composed:!0});g(this,"value");this.value=e}}var tt,xt,Mn,Nn,re,uo,ho,O,Mb,$s,Nb,Ub,Ju,Fb,Ts,cr,Ar,po,El,fo,Al,Hb,Wb,Qu,Is,eh,th,hn;class Ob extends HTMLElement{constructor(){super();w(this,O);w(this,tt,!1);w(this,xt,null);w(this,Mn,null);w(this,Nn);w(this,re,null);w(this,uo,Za());w(this,ho,new MutationObserver(e=>f(this,O,Hb).call(this,e)));w(this,Ar,()=>{f(this,O,Ts).call(this,!l(this,tt))});w(this,po,e=>{e.key!=="Enter"&&e.key!==" "||(e.preventDefault(),l(this,Ar).call(this))});w(this,El,()=>{l(this,tt)&&f(this,O,Ts).call(this,!1)});w(this,fo,e=>{e instanceof zb&&(e.stopPropagation(),S(this,tt,!1),f(this,O,$s).call(this,e.value),f(this,O,hn).call(this),this.dispatchEvent(new iz(e.value)))});w(this,Al,()=>{f(this,O,Qu).call(this)});S(this,Nn,this.attachShadow({mode:"open"})),od(l(this,Nn))}connectedCallback(){this.addEventListener("dropdown-item-select",l(this,fo)),f(this,O,Mb).call(this),l(this,ho).observe(this,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["selected","value","slot"]}),f(this,O,hn).call(this)}disconnectedCallback(){this.removeEventListener("dropdown-item-select",l(this,fo)),l(this,ho).disconnect(),f(this,O,th).call(this)}attributeChangedCallback(e){if(e==="open"){f(this,O,Ts).call(this,this.hasAttribute("open"));return}f(this,O,hn).call(this)}get open(){return l(this,tt)}set open(e){this.toggleAttribute("open",e)}get title(){return this.getAttribute("title")??""}get value(){return l(this,xt)}set value(e){e===null?(f(this,O,cr).call(this,null,null),f(this,O,Nb).call(this)):f(this,O,$s).call(this,e),f(this,O,hn).call(this)}close(){f(this,O,Ts).call(this,!1)}}tt=new WeakMap,xt=new WeakMap,Mn=new WeakMap,Nn=new WeakMap,re=new WeakMap,uo=new WeakMap,ho=new WeakMap,O=new WeakSet,Mb=function(){var r;const e=this.querySelector("dropdown-item[selected]");e&&f(this,O,cr).call(this,e.value,((r=e.textContent)==null?void 0:r.trim())??null)},$s=function(e){var r;for(const i of l(this,O,Ju))i.value===e?(f(this,O,cr).call(this,e,((r=i.textContent)==null?void 0:r.trim())??null),i.hasAttribute("selected")||i.setAttribute("selected","")):i.hasAttribute("selected")&&i.removeAttribute("selected")},Nb=function(){const e=this.querySelectorAll("dropdown-item[selected]");for(const r of e)r.removeAttribute("selected")},Ub=function(e){for(const r of l(this,O,Ju))if(r.value===e)return r;return null},Ju=function(){return this.querySelectorAll("dropdown-item")},Fb=function(){return l(this,Mn)??this.title},Ts=function(e){l(this,tt)!==e&&(S(this,tt,e),f(this,O,hn).call(this))},cr=function(e,r){S(this,xt,e),S(this,Mn,r)},Ar=new WeakMap,po=new WeakMap,El=new WeakMap,fo=new WeakMap,Al=new WeakMap,Hb=function(e){e.every(i=>i.target instanceof Element?i.target.closest('[slot="trigger"]')!==null:!1)||f(this,O,Wb).call(this)},Wb=function(){var r,i;const e=this.querySelector("dropdown-item[selected]");if(e){const s=e.value,o=((r=e.textContent)==null?void 0:r.trim())??null,a=l(this,xt)!==s||l(this,Mn)!==o;f(this,O,cr).call(this,s,o),f(this,O,$s).call(this,s),a?f(this,O,hn).call(this):f(this,O,Is).call(this);return}if(l(this,xt)!==null){const s=f(this,O,Ub).call(this,l(this,xt));if(s){const o=((i=s.textContent)==null?void 0:i.trim())??null,a=l(this,Mn)!==o;f(this,O,cr).call(this,l(this,xt),o),f(this,O,$s).call(this,l(this,xt)),a?f(this,O,hn).call(this):f(this,O,Is).call(this);return}}if(l(this,xt)!==null||l(this,Mn)!==null){f(this,O,cr).call(this,null,null),f(this,O,hn).call(this);return}f(this,O,Is).call(this)},Qu=function(){const e=l(this,Nn).querySelector('slot[name="trigger"]'),r=e instanceof HTMLSlotElement?e.assignedElements()[0]??null:null;l(this,re)!==r&&(f(this,O,th).call(this),S(this,re,r),l(this,re)&&(l(this,re).addEventListener("click",l(this,Ar)),l(this,re)instanceof HTMLButtonElement?l(this,re).hasAttribute("type")||(l(this,re).type="button"):(l(this,re).hasAttribute("role")||l(this,re).setAttribute("role","button"),l(this,re).hasAttribute("tabindex")||(l(this,re).tabIndex=0),l(this,re).addEventListener("keydown",l(this,po))))),f(this,O,Is).call(this),f(this,O,eh).call(this)},Is=function(){l(this,re)&&(l(this,re).setAttribute("data-dropdown-trigger",""),l(this,re).setAttribute("aria-haspopup","listbox"),l(this,re).setAttribute("aria-expanded",l(this,tt)?"true":"false"))},eh=function(){const e=l(this,uo).value;if(!e)return;const r=l(this,Nn).querySelector("button.fallback-trigger");e.anchor=l(this,re)??r??null},th=function(){l(this,re)&&(l(this,re).removeEventListener("click",l(this,Ar)),l(this,re).removeEventListener("keydown",l(this,po)),l(this,re).removeAttribute("data-dropdown-trigger"),l(this,re).removeAttribute("aria-haspopup"),l(this,re).removeAttribute("aria-expanded"),S(this,re,null))},hn=function(){this.toggleAttribute("open",l(this,tt)),Ce(z`
|
|
92
|
+
<slot name="trigger" @slotchange=${l(this,Al)}>
|
|
93
93
|
<button
|
|
94
94
|
class="fallback-trigger"
|
|
95
95
|
part="trigger"
|
|
@@ -98,9 +98,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
98
98
|
aria-expanded=${l(this,tt)?"true":"false"}
|
|
99
99
|
@click=${l(this,Ar)}
|
|
100
100
|
>
|
|
101
|
-
<span class="trigger-label" part="trigger-label">${l(this,O,
|
|
101
|
+
<span class="trigger-label" part="trigger-label">${l(this,O,Fb)}</span>
|
|
102
102
|
<span class="trigger-icon" part="trigger-icon" aria-hidden="true">
|
|
103
|
-
${
|
|
103
|
+
${vl({size:16})}
|
|
104
104
|
</span>
|
|
105
105
|
</button>
|
|
106
106
|
</slot>
|
|
@@ -108,20 +108,20 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
108
108
|
class="dropdown-popover"
|
|
109
109
|
material="glass-frosted"
|
|
110
110
|
?open=${l(this,tt)}
|
|
111
|
-
@close=${l(this,
|
|
112
|
-
${
|
|
111
|
+
@close=${l(this,El)}
|
|
112
|
+
${Va(l(this,uo))}
|
|
113
113
|
>
|
|
114
114
|
${l(this,tt)?z`<div class="dropdown-list" part="list" role="listbox">
|
|
115
115
|
<slot></slot>
|
|
116
116
|
</div>`:se}
|
|
117
117
|
</ui-popover>
|
|
118
|
-
`,l(this,Nn)),f(this,O,
|
|
118
|
+
`,l(this,Nn)),f(this,O,eh).call(this),queueMicrotask(()=>f(this,O,Qu).call(this))},g(Ob,"observedAttributes",["title","open"]);class sz extends HTMLElement{}class oz extends HTMLElement{}class az extends HTMLElement{}var Hr,nh,Vb,go,mo;class Zb extends HTMLElement{constructor(){super(...arguments);w(this,Hr);w(this,go,()=>{this.action||f(this,Hr,Vb).call(this)});w(this,mo,e=>{e.key!=="Enter"&&e.key!==" "||(e.preventDefault(),this.click())})}connectedCallback(){this.hasAttribute("role")||this.setAttribute("role","option"),this.hasAttribute("tabindex")||(this.tabIndex=0),this.addEventListener("click",l(this,go)),this.addEventListener("keydown",l(this,mo)),f(this,Hr,nh).call(this)}disconnectedCallback(){this.removeEventListener("click",l(this,go)),this.removeEventListener("keydown",l(this,mo))}attributeChangedCallback(){f(this,Hr,nh).call(this)}get value(){return this.getAttribute("value")??""}get selected(){return this.hasAttribute("selected")}get action(){return this.hasAttribute("action")}}Hr=new WeakSet,nh=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")},Vb=function(){this.dispatchEvent(new zb(this.value))},go=new WeakMap,mo=new WeakMap,g(Zb,"observedAttributes",["action","selected","value"]);customElements.get("dropdown-menu")||customElements.define("dropdown-menu",Ob);customElements.get("dropdown-group")||customElements.define("dropdown-group",sz);customElements.get("dropdown-label")||customElements.define("dropdown-label",oz);customElements.get("dropdown-divider")||customElements.define("dropdown-divider",az);customElements.get("dropdown-item")||customElements.define("dropdown-item",Zb);class lz extends Event{constructor(e){super("rename",{bubbles:!0,composed:!0});g(this,"value");this.value=e}}var Gt,Et,ie,Oe,Cs,vo,rh,Ga,ih,yo,bo,wo;class Bb extends HTMLElement{constructor(){super(...arguments);w(this,Oe);w(this,Gt,"");w(this,Et,!1);w(this,ie,null);w(this,vo,e=>{l(this,Et)||(e.preventDefault(),f(this,Oe,rh).call(this))});w(this,yo,e=>{e.stopPropagation()});w(this,bo,e=>{var r,i;e.key==="Enter"?(e.preventDefault(),f(this,Oe,Ga).call(this,!0),(r=l(this,ie))==null||r.blur()):e.key==="Escape"&&(e.preventDefault(),f(this,Oe,Ga).call(this,!1),(i=l(this,ie))==null||i.blur())});w(this,wo,()=>{f(this,Oe,Ga).call(this,!0)})}connectedCallback(){l(this,ie)||(S(this,ie,document.createElement("span")),l(this,ie).className="editable-text-span",this.append(l(this,ie)));const e=this.getAttribute("value");e!==null&&S(this,Gt,e),f(this,Oe,Cs).call(this),this.addEventListener("dblclick",l(this,vo))}disconnectedCallback(){this.removeEventListener("dblclick",l(this,vo)),l(this,Et)&&f(this,Oe,ih).call(this)}attributeChangedCallback(e){if(e==="value"){const r=this.getAttribute("value")??"";S(this,Gt,r),l(this,Et)||f(this,Oe,Cs).call(this)}}get value(){return l(this,Gt)}set value(e){S(this,Gt,e),l(this,Et)||f(this,Oe,Cs).call(this)}startEditing(){l(this,Et)||f(this,Oe,rh).call(this)}}Gt=new WeakMap,Et=new WeakMap,ie=new WeakMap,Oe=new WeakSet,Cs=function(){l(this,ie)&&(l(this,ie).textContent=l(this,Gt))},vo=new WeakMap,rh=function(){l(this,ie)&&(S(this,Et,!0),l(this,ie).setAttribute("contenteditable","plaintext-only"),l(this,ie).setAttribute("spellcheck","false"),l(this,ie).addEventListener("keydown",l(this,bo)),l(this,ie).addEventListener("blur",l(this,wo)),l(this,ie).addEventListener("mousedown",l(this,yo)),this.toggleAttribute("data-editing",!0),queueMicrotask(()=>{var r;if(!l(this,ie))return;l(this,ie).focus();const e=(r=this.ownerDocument.defaultView)==null?void 0:r.getSelection();e==null||e.selectAllChildren(l(this,ie))}))},Ga=function(e){if(!l(this,Et)||!l(this,ie))return;const r=(l(this,ie).textContent??"").trim();S(this,Et,!1),l(this,ie).removeAttribute("contenteditable"),l(this,ie).removeAttribute("spellcheck"),this.toggleAttribute("data-editing",!1),f(this,Oe,ih).call(this),e&&r.length>0&&r!==l(this,Gt)&&(S(this,Gt,r),this.dispatchEvent(new lz(r))),f(this,Oe,Cs).call(this)},ih=function(){var e,r,i;(e=l(this,ie))==null||e.removeEventListener("keydown",l(this,bo)),(r=l(this,ie))==null||r.removeEventListener("blur",l(this,wo)),(i=l(this,ie))==null||i.removeEventListener("mousedown",l(this,yo))},yo=new WeakMap,bo=new WeakMap,wo=new WeakMap,g(Bb,"observedAttributes",["value"]);customElements.get("editable-text")||customElements.define("editable-text",Bb);class cz extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}var So,Yn,sh,$l,_o,oh;class jb extends HTMLElement{constructor(){super();w(this,Yn);w(this,So);w(this,$l,e=>{e.target===e.currentTarget&&f(this,Yn,sh).call(this)});w(this,_o,e=>{this.open&&e.key==="Escape"&&f(this,Yn,sh).call(this)});S(this,So,this.attachShadow({mode:"open"}))}connectedCallback(){document.addEventListener("keydown",l(this,_o)),f(this,Yn,oh).call(this)}disconnectedCallback(){document.removeEventListener("keydown",l(this,_o))}attributeChangedCallback(){f(this,Yn,oh).call(this)}get open(){return this.hasAttribute("open")}}So=new WeakMap,Yn=new WeakSet,sh=function(){this.dispatchEvent(new cz)},$l=new WeakMap,_o=new WeakMap,oh=function(){Ce(z`
|
|
119
119
|
${this.open?z`
|
|
120
|
-
<div class="backdrop" part="backdrop" @click=${l(this
|
|
120
|
+
<div class="backdrop" part="backdrop" @click=${l(this,$l)}>
|
|
121
121
|
<slot></slot>
|
|
122
122
|
</div>
|
|
123
123
|
`:null}
|
|
124
|
-
`,l(this,
|
|
124
|
+
`,l(this,So))},g(jb,"observedAttributes",["open"]);customElements.get("modal-overlay")||customElements.define("modal-overlay",jb);const uz=16,ru=24,hz=32;var Ci;class Gb extends HTMLElement{constructor(){super();w(this,Ci);S(this,Ci,this.attachShadow({mode:"open"})),od(l(this,Ci))}connectedCallback(){this.render()}attributeChangedCallback(){this.render()}getSize(){const e=this.getAttribute("size");if(e===null)return ru;const r=Number(e);return r===uz||r===ru||r===hz?r:ru}getWeight(){return this.getAttribute("weight")==="bold"?"bold":"regular"}render(){Ce(z`<span class="spin">${Tb({size:this.getSize(),weight:this.getWeight()})}</span>`,l(this,Ci))}}Ci=new WeakMap,g(Gb,"observedAttributes",["size","weight"]);customElements.get("ui-spinner")||customElements.define("ui-spinner",Gb);class dz extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}class pz extends HTMLElement{}var ko,xo,ah;class qb extends HTMLElement{constructor(){super();w(this,xo);w(this,ko);S(this,ko,this.attachShadow({mode:"open"}))}connectedCallback(){f(this,xo,ah).call(this)}attributeChangedCallback(){f(this,xo,ah).call(this)}get closable(){return this.hasAttribute("closable")}}ko=new WeakMap,xo=new WeakSet,ah=function(){const e=this.querySelector("panel-page");Ce(z`
|
|
125
125
|
<section class="panel" part="panel">
|
|
126
126
|
<header class="title-bar" part="header">
|
|
127
127
|
<h2 class="title" part="title">${(e==null?void 0:e.getAttribute("title"))??""}</h2>
|
|
@@ -131,16 +131,118 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
131
131
|
class="title-button"
|
|
132
132
|
part="button close-button"
|
|
133
133
|
aria-label="Close"
|
|
134
|
-
@click=${()=>this.dispatchEvent(new
|
|
134
|
+
@click=${()=>this.dispatchEvent(new dz)}
|
|
135
135
|
>
|
|
136
|
-
<span class="close-icon" part="icon close-icon">${
|
|
136
|
+
<span class="close-icon" part="icon close-icon">${xd({size:16})}</span>
|
|
137
137
|
</button>
|
|
138
138
|
`:null}
|
|
139
139
|
</header>
|
|
140
140
|
<slot></slot>
|
|
141
141
|
</section>
|
|
142
|
-
`,l(this,
|
|
143
|
-
|
|
142
|
+
`,l(this,ko))},g(qb,"observedAttributes",["closable"]);customElements.get("panel-view")||customElements.define("panel-view",qb);customElements.get("panel-page")||customElements.define("panel-page",pz);const fz=`
|
|
143
|
+
<svg viewBox="0 0 12 12" aria-hidden="true" focusable="false">
|
|
144
|
+
<path d="M10.2 3.1 5.1 8.2 2.4 5.5" />
|
|
145
|
+
</svg>
|
|
146
|
+
`,gz=`
|
|
147
|
+
:host {
|
|
148
|
+
display: block;
|
|
149
|
+
margin: var(--checkbox-list-margin, var(--space-12) 0);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
[part~="list"] {
|
|
153
|
+
display: grid;
|
|
154
|
+
gap: var(--checkbox-list-gap, var(--space-6));
|
|
155
|
+
}
|
|
156
|
+
`,mz=`
|
|
157
|
+
:host {
|
|
158
|
+
display: block;
|
|
159
|
+
--checkbox-size: 1em;
|
|
160
|
+
--checkbox-gap: var(--space-8);
|
|
161
|
+
--checkbox-color: var(--color-primary);
|
|
162
|
+
--checkbox-border-color: var(--color-border);
|
|
163
|
+
--checkbox-bg: transparent;
|
|
164
|
+
--checkbox-check-color: var(--color-bg);
|
|
165
|
+
--checkbox-checked-content-color: var(--color-text-muted);
|
|
166
|
+
--checkbox-checked-decoration: line-through;
|
|
167
|
+
--checkbox-checked-decoration-thickness: 0.08em;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
[part~="label"] {
|
|
171
|
+
display: grid;
|
|
172
|
+
grid-template-columns: var(--checkbox-size) minmax(0, 1fr);
|
|
173
|
+
gap: var(--checkbox-gap);
|
|
174
|
+
align-items: baseline;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
input {
|
|
178
|
+
position: absolute;
|
|
179
|
+
opacity: 0;
|
|
180
|
+
pointer-events: none;
|
|
181
|
+
width: 1px;
|
|
182
|
+
height: 1px;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
[part~="box"] {
|
|
186
|
+
display: inline-grid;
|
|
187
|
+
place-items: center;
|
|
188
|
+
width: var(--checkbox-size);
|
|
189
|
+
height: var(--checkbox-size);
|
|
190
|
+
border: 1px solid var(--checkbox-border-color);
|
|
191
|
+
border-radius: var(--checkbox-radius, var(--radius-4));
|
|
192
|
+
background: var(--checkbox-bg);
|
|
193
|
+
color: var(--checkbox-check-color);
|
|
194
|
+
transform: translateY(0.12em);
|
|
195
|
+
cursor: not-allowed;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
[part~="check"] {
|
|
199
|
+
display: block;
|
|
200
|
+
width: calc(var(--checkbox-size) * 0.72);
|
|
201
|
+
height: calc(var(--checkbox-size) * 0.72);
|
|
202
|
+
opacity: 0;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
[part~="check"] svg {
|
|
206
|
+
display: block;
|
|
207
|
+
width: 100%;
|
|
208
|
+
height: 100%;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
[part~="check"] path {
|
|
212
|
+
fill: none;
|
|
213
|
+
stroke: currentColor;
|
|
214
|
+
stroke-width: 2;
|
|
215
|
+
stroke-linecap: round;
|
|
216
|
+
stroke-linejoin: round;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
[part~="content"] {
|
|
220
|
+
min-width: 0;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
:host([checked]) [part~="box"] {
|
|
224
|
+
border-color: var(--checkbox-color);
|
|
225
|
+
background: var(--checkbox-color);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
:host([checked]) [part~="check"] {
|
|
229
|
+
opacity: 1;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
:host([checked]) [part~="content"] {
|
|
233
|
+
color: var(--checkbox-checked-content-color);
|
|
234
|
+
text-decoration-line: var(--checkbox-checked-decoration);
|
|
235
|
+
text-decoration-thickness: var(--checkbox-checked-decoration-thickness);
|
|
236
|
+
}
|
|
237
|
+
`;var Eo;class vz extends HTMLElement{constructor(){super();w(this,Eo);S(this,Eo,this.attachShadow({mode:"open"})),l(this,Eo).innerHTML=`<style>${gz}</style><div part="list"><slot></slot></div>`}connectedCallback(){this.hasAttribute("role")||this.setAttribute("role","list")}}Eo=new WeakMap;var Ri,Ao,$o,lh;class Yb extends HTMLElement{constructor(){super();w(this,$o);w(this,Ri);w(this,Ao);S(this,Ri,this.attachShadow({mode:"open"})),l(this,Ri).innerHTML=`
|
|
238
|
+
<style>${mz}</style>
|
|
239
|
+
<label part="label">
|
|
240
|
+
<input type="checkbox" disabled tabindex="-1">
|
|
241
|
+
<span part="box"><span part="check">${fz}</span></span>
|
|
242
|
+
<span part="content"><slot></slot></span>
|
|
243
|
+
</label>
|
|
244
|
+
`;const e=l(this,Ri).querySelector("input");if(!(e instanceof HTMLInputElement))throw new Error("checkbox-item failed to initialize input");S(this,Ao,e)}connectedCallback(){this.hasAttribute("role")||this.setAttribute("role","listitem"),this.setAttribute("aria-disabled","true"),f(this,$o,lh).call(this)}attributeChangedCallback(){f(this,$o,lh).call(this)}}Ri=new WeakMap,Ao=new WeakMap,$o=new WeakSet,lh=function(){const e=this.hasAttribute("checked");l(this,Ao).checked=e,this.setAttribute("aria-checked",e?"true":"false")},g(Yb,"observedAttributes",["checked"]);customElements.get("checkbox-list")||customElements.define("checkbox-list",vz);customElements.get("checkbox-item")||customElements.define("checkbox-item",Yb);function ic(n){return typeof n=="object"&&n!==null}function yz(n){return!ic(n)||n.type!=="wheel"||typeof n.deltaX!="number"||typeof n.deltaY!="number"||typeof n.shiftKey!="boolean"?!1:!("id"in n)}function bz(n){return!ic(n)||n.type!=="swipe-move"||typeof n.deltaX!="number"?!1:!("id"in n)}function wz(n){return!ic(n)||n.type!=="swipe-end"||typeof n.velocityX!="number"?!1:!("id"in n)}function Xb(n){return!ic(n)||n.type!=="open-artifact"||typeof n.artifactID!="string"?!1:!("id"in n)}function Sz(n=window){if(n.parent===n)return;let t=0,e=0;n.document.documentElement&&(n.document.documentElement.style.touchAction="pan-y"),n.addEventListener("wheel",u=>{const h=u;t=h.clientX,e=h.clientY,n.parent.postMessage({type:"wheel",deltaX:h.deltaX,deltaY:h.deltaY,shiftKey:h.shiftKey},"*"),h.preventDefault()},{passive:!1});const r=8,i=100,s=1e3,o=new Map;n.addEventListener("pointerdown",u=>{const h=u;h.pointerType==="touch"&&o.set(h.pointerId,{startX:h.clientX,startY:h.clientY,lastX:h.clientX,offset:0,active:!1,discarded:!1,samples:[{time:h.timeStamp,offset:0}]})},{passive:!0}),n.addEventListener("pointermove",u=>{const h=u,p=o.get(h.pointerId);if(!p||p.discarded)return;if(!p.active){const k=h.clientX-p.startX,T=h.clientY-p.startY,P=Math.abs(k),R=Math.abs(T);if(P<r&&R<r)return;if(R>=P){p.discarded=!0;return}p.active=!0}const v=h.clientX-p.lastX;p.lastX=h.clientX,p.offset+=v,p.samples.push({time:h.timeStamp,offset:p.offset});const m=h.timeStamp-i;let _=0;for(let k=0;k<p.samples.length;k+=1){if(p.samples[k].time>=m){_=k;break}_=k+1}if(_>0){const k=Math.max(0,_-1);p.samples.splice(0,k)}n.parent.postMessage({type:"swipe-move",deltaX:v},"*"),h.preventDefault()},{passive:!1}),n.addEventListener("pointerup",u=>{const h=u,p=o.get(h.pointerId);if(!p||(o.delete(h.pointerId),!p.active))return;let v=0;if(p.samples.length>=2){const m=p.samples[0],_=p.samples[p.samples.length-1],k=_.time-m.time;k>0&&(v=(_.offset-m.offset)/k*s)}n.parent.postMessage({type:"swipe-end",velocityX:v},"*")}),n.addEventListener("pointercancel",u=>{const h=u,p=o.get(h.pointerId);p&&(o.delete(h.pointerId),p.active&&n.parent.postMessage({type:"swipe-end",velocityX:0},"*"))}),n.addEventListener("message",u=>{var k,T;const h=u.data;if(h===null||typeof h!="object"||h.type!=="scroll")return;const p=h,v=typeof p.deltaX=="number"?p.deltaX:0,m=typeof p.deltaY=="number"?p.deltaY:0;let _=((T=(k=n.document).elementFromPoint)==null?void 0:T.call(k,t,e))??null;for(;_!==null;){const P=n.getComputedStyle(_);if(m!==0){const R=(P.overflowY==="auto"||P.overflowY==="scroll")&&_.scrollHeight>_.clientHeight,W=m>0?_.scrollTop+_.clientHeight<_.scrollHeight:_.scrollTop>0;if(R&&W){_.scrollBy(v,m);return}}if(v!==0){const R=(P.overflowX==="auto"||P.overflowX==="scroll")&&_.scrollWidth>_.clientWidth,W=v>0?_.scrollLeft+_.clientWidth<_.scrollWidth:_.scrollLeft>0;if(R&&W){_.scrollBy(v,m);return}}_=_.parentElement}n.scrollBy(v,m)});function a(u){if(typeof u!="string")return!1;let h;try{h=new URL(u)}catch{return!1}if(h.protocol!=="artifact:")return!1;const p=h.hostname||h.pathname.replace(/^\/+/,"");return p===""?!1:(n.parent.postMessage({type:"open-artifact",artifactID:p},"*"),!0)}n.document.addEventListener("click",u=>{const h=u,p=typeof h.composedPath=="function"?h.composedPath():[];let v=null;for(const k of p)if(k instanceof HTMLAnchorElement||k&&k.tagName==="A"){v=k;break}if(v===null)return;const m=v.getAttribute("href");if(m===null)return;let _;try{_=new URL(m,n.document.baseURI).toString()}catch{return}a(_)&&u.preventDefault()},!0);const c=n.navigation;c&&c.addEventListener("navigate",u=>{var p;a((p=u.destination)==null?void 0:p.url)&&u.preventDefault()})}function _z(){return`(${Sz.toString()})(window);`}const kz=He(),xz=He(),Ez="No handler registered for update-content",Az="handleUpdateContent: handler already registered";function $z(n){return n instanceof Error&&typeof n.message=="string"?n.message:String(n)}const Tz=Ko(tn);var Pi,Di,Li,$r,Tr,To,Me,ch,Kb,Jb,Rs,uh,hm;let Iz=(hm=class extends Tz{constructor(e){super();w(this,Me);w(this,Pi);w(this,Di);w(this,Li);w(this,$r,null);w(this,Tr,null);w(this,To,!1);S(this,Pi,e);const r=e.ownerDocument.defaultView;if(!r)throw new Error("ArtifactView: iframe has no owner window");S(this,Di,r),S(this,Li,i=>f(this,Me,Kb).call(this,i)),l(this,Di).addEventListener("message",l(this,Li))}get content(){return l(this,Tr)}set content(e){f(this,Me,uh).call(this),S(this,Tr,e),l(this,To)&&f(this,Me,ch).call(this,e)}handleUpdateContent(e){if(f(this,Me,uh).call(this),l(this,$r)!==null)throw new Error(Az);S(this,$r,e)}dispose(){l(this,Di).removeEventListener("message",l(this,Li)),S(this,$r,null)}},Pi=new WeakMap,Di=new WeakMap,Li=new WeakMap,$r=new WeakMap,Tr=new WeakMap,To=new WeakMap,Me=new WeakSet,ch=function(e){const r={type:"content-updated",content:e};f(this,Me,Rs).call(this,r)},Kb=function(e){if(this.disposed||e.source!==l(this,Pi).contentWindow)return;const r=e.data;if(_R(r)){S(this,To,!0),this.dispatchEvent(new kz("ready")),l(this,Tr)!==null&&f(this,Me,ch).call(this,l(this,Tr));return}if(kR(r)){f(this,Me,Jb).call(this,r);return}if(Xb(r)){this.dispatchEvent(new xz("open-artifact",{artifactID:r.artifactID}));return}},Jb=async function(e){const r=l(this,$r);if(r===null){f(this,Me,Rs).call(this,{type:"response",id:e.id,error:{message:Ez}});return}try{await r(e.content)}catch(i){if(this.disposed)return;f(this,Me,Rs).call(this,{type:"response",id:e.id,error:{message:$z(i)}});return}this.disposed||f(this,Me,Rs).call(this,{type:"response",id:e.id,result:{}})},Rs=function(e){const r=l(this,Pi).contentWindow;r&&r.postMessage(e,"*")},uh=function(){if(this.disposed)throw new Error("ArtifactView is disposed")},hm);const Cz="text/html";async function Rz(n){const t=await fetch(n);if(!t.ok)throw new Error(`Failed to fetch artifact content: ${t.status}`);const e=await t.text(),r=new DOMParser().parseFromString(e,"text/html"),i=r.createElement("base");i.href=new URL(n,window.location.href).href,r.head.insertBefore(i,r.head.firstChild);const s=r.createElement("script");s.textContent=_z(),r.head.appendChild(s);const o=new Blob([`<!DOCTYPE html>
|
|
245
|
+
${r.documentElement.outerHTML}`],{type:Cz});return URL.createObjectURL(o)}const Ig="television-artifact-bridge",Pz="_tvThemeBuster",Qb=He(),Dz=He();class Lz extends HTMLElement{constructor(){super(...arguments);g(this,"_artifact",null);g(this,"_viewURL",null);g(this,"_contentURL",null);g(this,"_screen",null);g(this,"_subscribedScreen",null);g(this,"_subscribedServer",null);g(this,"_activeView",null);g(this,"_contentState",{kind:"idle"});g(this,"_fetchSequence",0);g(this,"_blobSequence",0);g(this,"_themeReloadSequence",0);g(this,"_mountedViewURL",null);g(this,"_mountedDirectRenderURL",null);g(this,"_mountedDirectRenderStatus",null);g(this,"_directRender",!1);g(this,"_standaloneScroll",!1);g(this,"_blobURL",null);g(this,"_subscribedWebview",null);g(this,"_directRenderMessageListener",null);g(this,"handleScreenContentChanged",e=>{if(!(!this._artifact||e.artifactID!==this._artifact.id)){if(this._activeView!==null){this.refetchContent();return}this._directRender&&this._contentURL!==null&&this._artifact.status==="committed"&&this.loadBlobFrame(this._contentURL)}});g(this,"handleServerEvent",e=>{const r=this._screen;if(!r||e.event.type!=="theme-changed"||e.serverURL!==r.server.url)return;const i=this.themeReloadSourceURL();i!==null&&(this._themeReloadSequence+=1,this.loadBlobFrame(this.withThemeBuster(i,this._themeReloadSequence)))});g(this,"handleOpenArtifact",e=>{this.requestFocus(e.artifactID)});g(this,"handleIframeMessage",e=>{const r=this.querySelector("iframe.artifact-frame");!r||r.contentWindow!==e.source||yz(e.data)&&this.dispatchArtifactWheel({deltaX:e.data.deltaX,deltaY:e.data.deltaY,shiftKey:e.data.shiftKey},i=>{var o;const s={type:"scroll",deltaX:0,deltaY:i};(o=r.contentWindow)==null||o.postMessage(s,this.iframeTargetOrigin(r))})});g(this,"handleWebviewIpcMessage",e=>{var o;const r=e.detail??e;if(!r||r.channel!==Ig)return;const i=(o=r.args)==null?void 0:o[0];if(!i||i.type!=="wheel")return;const s=this._subscribedWebview;s&&this.dispatchArtifactWheel({deltaX:i.deltaX??0,deltaY:i.deltaY??0,shiftKey:i.shiftKey??!1},a=>{var c;(c=s.send)==null||c.call(s,Ig,{type:"scroll",deltaX:0,deltaY:a})})})}set artifact(e){const r=this._artifact;this._artifact=e,this.render(),r!==null&&r!==e&&this.syncView()}get artifact(){return this._artifact}set viewURL(e){this._viewURL!==e&&(this._viewURL=e,this.syncView())}get viewURL(){return this._viewURL}set contentURL(e){this._contentURL!==e&&(this._contentURL=e,this.syncView())}get contentURL(){return this._contentURL}set screen(e){this._screen!==e&&(this._screen=e,this.syncScreenSubscription(),this.syncServerSubscription())}get screen(){return this._screen}get activeView(){return this._activeView}set standaloneScroll(e){this._standaloneScroll=e}get standaloneScroll(){return this._standaloneScroll}connectedCallback(){this.setAttribute("level","2"),this.render(),this.syncView(),this.syncScreenSubscription(),this.syncServerSubscription(),window.addEventListener("message",this.handleIframeMessage)}disconnectedCallback(){this.teardownView(),this.unsubscribeFromScreen(),this.unsubscribeFromServer(),window.removeEventListener("message",this.handleIframeMessage),this.unsubscribeFromWebview()}handleClose(){this._artifact&&this.dispatchEvent(new Qb("close-artifact",{artifactID:this._artifact.id,bubbles:!0,composed:!0}))}syncView(){if(!this.isConnected)return;const e=this._artifact;if(!e){this.teardownView(),this._contentState={kind:"idle"},this.render();return}switch(e.kind){case"url":this.teardownView(),this._contentState={kind:"ready"},this.render();return}if(this._viewURL!==null){if(this._directRender&&this.teardownView(),this._mountedViewURL!==this._viewURL){this.teardownView(),this._contentState={kind:"loading"},this._mountedViewURL=this._viewURL,this.render();const r=this.querySelector("iframe.artifact-frame");if(!r){this._contentState={kind:"error"},this.render();return}this._activeView=new Iz(r),this._activeView.handleUpdateContent(async i=>{await this.saveContent(i)}),this._activeView.addEventListener("open-artifact",this.handleOpenArtifact),this.loadBlobFrame(this._viewURL),this.startContentFetch();return}this._activeView!==null&&this.startContentFetch();return}if(this._contentURL!==null){if(!this._directRender||this._mountedDirectRenderURL!==this._contentURL){this.teardownView(),this._directRender=!0,this._mountedDirectRenderURL=this._contentURL,this._contentState={kind:"idle"},this.render(),this.installDirectRenderMessageListener(),e.status==="committed"&&(this._mountedDirectRenderStatus="committed",this.loadBlobFrame(this._contentURL));return}this.installDirectRenderMessageListener(),e.status==="committed"&&this._mountedDirectRenderStatus!=="committed"&&(this._mountedDirectRenderStatus="committed",this.loadBlobFrame(this._contentURL));return}this.teardownView(),this._contentState={kind:"idle"},this.render()}async saveContent(e){const r=this._screen,i=this._artifact;if(!r||!i)throw new Error("artifact-view: cannot save without a screen and artifact");await r.server.client.artifacts.putContent({artifactID:i.id,content:e})}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))}syncServerSubscription(){var r;if(!this.isConnected){this.unsubscribeFromServer();return}const e=((r=this._screen)==null?void 0:r.server)??null;this._subscribedServer!==e&&(this.unsubscribeFromServer(),e!==null&&(e.addEventListener("server-event",this.handleServerEvent),this._subscribedServer=e))}unsubscribeFromScreen(){this._subscribedScreen!==null&&(this._subscribedScreen.removeEventListener("artifact-content-changed",this.handleScreenContentChanged),this._subscribedScreen=null)}unsubscribeFromServer(){this._subscribedServer!==null&&(this._subscribedServer.removeEventListener("server-event",this.handleServerEvent),this._subscribedServer=null)}themeReloadSourceURL(){var e;return this._viewURL!==null?this._activeView!==null?this._viewURL:null:this._directRender&&this._contentURL!==null&&((e=this._artifact)==null?void 0:e.status)==="committed"?this._contentURL:null}withThemeBuster(e,r){const i=new URL(e,window.location.href);return i.searchParams.set(Pz,String(r)),i.toString()}startContentFetch(){this._fetchSequence+=1;const e=this._fetchSequence,r=this._contentURL,i=this._activeView;if(!i||r===null){this._contentState={kind:"error"},this.render();return}this._contentState={kind:"loading"},(async()=>{try{const s=await fetch(r);if(e!==this._fetchSequence)return;if(!s.ok){this._contentState={kind:"error"},this.teardownView(),this.render();return}const o=await s.text();if(e!==this._fetchSequence||this._activeView!==i)return;this._activeView.content=o,this._contentState={kind:"ready"}}catch{if(e!==this._fetchSequence)return;this._contentState={kind:"error"},this.teardownView(),this.render()}})()}refetchContent(){this._fetchSequence+=1;const e=this._fetchSequence,r=this._contentURL,i=this._activeView;!i||r===null||(async()=>{try{const s=await fetch(r);if(e!==this._fetchSequence||!s.ok)return;const o=await s.text();if(e!==this._fetchSequence||this._activeView!==i)return;this._activeView.content=o}catch{}})()}loadBlobFrame(e){this._blobSequence+=1;const r=this._blobSequence;(async()=>{try{const i=await Rz(e);if(r!==this._blobSequence){URL.revokeObjectURL(i);return}const s=this._blobURL;this._blobURL=i,this.render();const o=this.querySelector("iframe.artifact-frame");o&&(o.src=i),s!==null&&s!==i&&URL.revokeObjectURL(s)}catch{if(r!==this._blobSequence)return;this._contentState={kind:"error"},this.teardownView(),this.render()}})()}teardownView(){this._activeView!==null&&(this._activeView.removeEventListener("open-artifact",this.handleOpenArtifact),this._activeView.dispose(),this._activeView=null),this.removeDirectRenderMessageListener(),this._blobURL!==null&&(URL.revokeObjectURL(this._blobURL),this._blobURL=null),this._mountedViewURL=null,this._mountedDirectRenderURL=null,this._mountedDirectRenderStatus=null,this._directRender=!1,this._fetchSequence+=1,this._blobSequence+=1}installDirectRenderMessageListener(){if(this._directRenderMessageListener!==null)return;const e=r=>{const i=this.querySelector("iframe.artifact-frame");i&&r.source===i.contentWindow&&Xb(r.data)&&this.requestFocus(r.data.artifactID)};this._directRenderMessageListener=e,window.addEventListener("message",e)}removeDirectRenderMessageListener(){this._directRenderMessageListener!==null&&(window.removeEventListener("message",this._directRenderMessageListener),this._directRenderMessageListener=null)}requestFocus(e){const r=this._screen;r&&r.server.client.display.focus({artifactID:e}).catch(i=>{console.warn("artifact-view: display.focus failed",i)})}contentTemplate(){const e=this._artifact;if((e==null?void 0:e.kind)==="url"){const r=e.externalURL;if(!r)throw new Error(`URL artifact ${e.id} is missing externalURL`);return wd()?z`
|
|
144
246
|
<webview
|
|
145
247
|
class="artifact-frame artifact-content"
|
|
146
248
|
src=${r}
|
|
@@ -170,7 +272,7 @@ ${r.documentElement.outerHTML}`],{type:wz});return URL.createObjectURL(o)}const
|
|
|
170
272
|
${this.contentTemplate()}
|
|
171
273
|
<footer class="artifact-title-bar" drag-handle material="glass-frosted">
|
|
172
274
|
<div class="artifact-title-group">
|
|
173
|
-
<span class="artifact-title-icon">${
|
|
275
|
+
<span class="artifact-title-icon">${X2({size:16})}</span>
|
|
174
276
|
<span class="artifact-title">${e.title}</span>
|
|
175
277
|
</div>
|
|
176
278
|
<button
|
|
@@ -180,14 +282,14 @@ ${r.documentElement.outerHTML}`],{type:wz});return URL.createObjectURL(o)}const
|
|
|
180
282
|
@click=${()=>this.handleClose()}
|
|
181
283
|
aria-label="Close"
|
|
182
284
|
>
|
|
183
|
-
${
|
|
285
|
+
${xd({size:16})}
|
|
184
286
|
</button>
|
|
185
287
|
</footer>
|
|
186
|
-
`}render(){this._artifact&&(this.setAttribute("kind",this._artifact.kind),Ce(this.template(),this),this.syncWebviewSubscription())}dispatchArtifactWheel(e,r){if(this._standaloneScroll){r(e.deltaY);return}this.dispatchEvent(new
|
|
288
|
+
`}render(){this._artifact&&(this.setAttribute("kind",this._artifact.kind),Ce(this.template(),this),this.syncWebviewSubscription())}dispatchArtifactWheel(e,r){if(this._standaloneScroll){r(e.deltaY);return}this.dispatchEvent(new Dz("artifact-wheel",{bubbles:!0,composed:!0,deltaX:e.deltaX,deltaY:e.deltaY,shiftKey:e.shiftKey,scrollNative:r}))}syncWebviewSubscription(){const e=this.querySelector("webview");e!==this._subscribedWebview&&(this.unsubscribeFromWebview(),e&&(e.addEventListener("ipc-message",this.handleWebviewIpcMessage),this._subscribedWebview=e))}unsubscribeFromWebview(){this._subscribedWebview&&(this._subscribedWebview.removeEventListener("ipc-message",this.handleWebviewIpcMessage),this._subscribedWebview=null)}iframeTargetOrigin(e){const r=e.getAttribute("sandbox")??"";if(!new Set(r.split(/\s+/).filter(Boolean)).has("allow-same-origin"))return"*";const s=e.getAttribute("src")??e.src;if(!s)return"*";try{return new URL(s,window.location.href).origin}catch{return"*"}}}customElements.define("artifact-view",Lz);/**
|
|
187
289
|
* @license
|
|
188
290
|
* Copyright 2017 Google LLC
|
|
189
291
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
190
|
-
*/const xg=(n,t,e)=>{const r=new Map;for(let i=t;i<=e;i++)r.set(n[i],i);return r},Ag=Ql(class extends yd{constructor(n){if(super(n),n.type!==vd.CHILD)throw Error("repeat() can only be used in text expressions")}dt(n,t,e){let r;e===void 0?e=t:t!==void 0&&(r=t);const i=[],s=[];let o=0;for(const a of n)i[o]=r?r(a,o):o,s[o]=e(a,o),o++;return{values:s,keys:i}}render(n,t,e){return this.dt(n,t,e).values}update(n,[t,e,r]){const i=N2(n),{values:s,keys:o}=this.dt(t,e,r);if(!Array.isArray(i))return this.ut=o,s;const a=this.ut??(this.ut=[]),c=[];let u,h,p=0,v=i.length-1,m=0,_=s.length-1;for(;p<=v&&m<=_;)if(i[p]===null)p++;else if(i[v]===null)v--;else if(a[p]===o[m])c[m]=sr(i[p],s[m]),p++,m++;else if(a[v]===o[_])c[_]=sr(i[v],s[_]),v--,_--;else if(a[p]===o[_])c[_]=sr(i[p],s[_]),gs(n,c[_+1],i[p]),p++,_--;else if(a[v]===o[m])c[m]=sr(i[v],s[m]),gs(n,i[p],i[v]),v--,m++;else if(u===void 0&&(u=xg(o,m,_),h=xg(a,p,v)),u.has(a[p]))if(u.has(a[v])){const k=h.get(o[m]),T=k!==void 0?i[k]:null;if(T===null){const P=gs(n,i[p]);sr(P,s[m]),c[m]=P}else c[m]=sr(T,s[m]),gs(n,i[p],T),i[k]=null;m++}else Xc(i[v]),v--;else Xc(i[p]),p++;for(;m<=_;){const k=gs(n,c[_+1]);sr(k,s[m]),c[m++]=k}for(;p<=v;){const k=i[p++];k!==null&&Xc(k)}return this.ut=o,M2(n,c),Nr}}),xe=n=>({type:"px",...n}),Ee=n=>({type:"unit",...n}),ba=2;class xz{constructor(t){g(this,"basis");g(this,"min");g(this,"_gap");g(this,"_viewport");g(this,"_unit");this.basis=t.basis,this.min=t.min,this._viewport=t.viewport,this._gap=t.gap??xe({x:le,y:le});const e=this._viewport.x??zr,r=this._viewport.y??sl,i=this._gap.x??le,s=this._gap.y??le,o=e<=QA,a=o?e-i*ba:Math.min(zr,e-i*ba),c=o?r-s*ba:Math.min(sl,r-s*ba),u=(a-i*(Fe-1))/Fe,h=(c-s*(ct-1))/ct,p=this.basis.x??0,v=this.basis.y??0,m=this.min.x??0,_=this.min.y??0;this._unit=xe(o?{x:Math.max(m,u),y:Math.max(_,h)}:{x:Math.max(m,Math.min(p,u)),y:Math.max(_,Math.min(v,h))})}get unit(){return this._unit}get viewport(){return this._viewport}get gap(){return this._gap}toUnits(t){return Ee({x:t.x==null?void 0:t.x/(this._unit.x??1),y:t.y==null?void 0:t.y/(this._unit.y??1)})}toPixels(t){const e=this._unit.x??0,r=this._unit.y??0,i=this._gap.x??le,s=this._gap.y??le,o=t.x==null?void 0:t.x*e+Math.max(0,t.x-1)*i,a=t.y==null?void 0:t.y*r+Math.max(0,t.y-1)*s;return xe({x:o,y:a})}}const Ur=1e-4,$t=1e-6,Az=40,$z=24;function qb(n,t){return Math.max(0,n-t*2)}function Yb(n){const t=[0];for(const e of n)t.push((t[t.length-1]??0)+e);return t}function Xb(n){const t=[0];for(let e=0;e<n.length;e+=1){const r=t[e]??0;t.push(r+n[e]+le)}return t}function Kb(n,t,e){if(t<0||t>=n.length)return 0;let r=0,i=0;for(let s=t;s<n.length;s+=1){const o=n[s],a=i===0?o:r+le+o;if(a>e+Ur)break;r=a,i+=1}return Math.max(1,i)}function Tz(n,t,e){if(t<0||t>=n.length)return 0;let r=0,i=0;for(let s=t;s>=0;s-=1){const o=n[s],a=i===0?o:r+le+o;if(a>e+Ur)break;r=a,i+=1}return Math.max(1,i)}function Iz(n,t){if(n.length===0)return 0;let e=0,r=0;for(let i=n.length-1;i>=0;i-=1){const s=n[i],o=r===0?s:e+le+s;if(o>t+Ur)break;e=o,r+=1}return Math.max(1,r)}function wd(n,t){if(n.length===0)return 0;const e=Iz(n,t);return Math.max(0,n.length-e)}function $g(n,t,e){if(n.length===0)return 0;const r=Kb(n,t,e),i=Math.min(n.length,t+r);if(i<=t)return 0;const s=n.slice(t,i);return s.reduce((o,a)=>o+a,0)+Math.max(0,s.length-1)*le}function oh(n,t,e){const r=n[t]??0;return e-r}function di(n,t,e,r,i){if(n.length===0)return 0;const s=wd(n,i),o=t[s]??0,a=Math.max(0,Math.min(o,e));let c=0;for(let F=0;F<s;F+=1){const Y=t[F]??0,j=t[F+1]??Y;if(a>=Y&&a<=j+Ur){c=F;break}c=F+1}const u=Math.min(c+1,s),h=t[c]??0,p=t[u]??h,v=Math.max(p-h,Ur),m=u===c?0:(a-h)/v,_=Xb(n),k=$g(n,c,i),T=$g(n,u,i),P=(r-k)/2,R=(r-T)/2,W=oh(_,c,P),N=oh(_,u,R);return W+(N-W)*m}function Cz(n,t,e,r,i){const s=wd(n,r),o=t[s]??0;let a=0,c=o;for(let u=0;u<Az;u+=1){const h=(a+c)/2;di(n,t,h,e,r)>i?a=h:c=h}return(a+c)/2}function Rz(n,t,e){const r=Xb(n),[i,s]=t,o=n.slice(i,s+1),a=o.reduce((u,h)=>u+h,0)+Math.max(0,o.length-1)*le,c=(e-a)/2;return oh(r,i,c)}function Pz(n,t,e){const r=Kb(n,t,e);return[t,Math.min(n.length-1,t+r-1)]}function Dz(n,t,e){const r=Tz(n,t,e);return[Math.max(0,t-r+1),t]}function Lz(n,t){return n[0]===t[0]&&n[1]===t[1]}function zz(n){const{nodeCols:t,nodeWidthsPx:e,viewportWidthPx:r}=n;if(t.length===0||e.length===0)return{viewspans:[],minScroll:0,maxScroll:0};const i=e.length,s=n.gapPx??le,o=qb(r,s),a=Yb(t),c=wd(e,o),u=a[c]??0;function h(T){const P=Rz(e,T,r),R=Cz(e,a,r,o,P);return{nodeRange:T,anchor:Math.max(0,Math.min(u,R))}}const p=[];for(let T=0;T<i;){const P=Pz(e,T,o);p.push(h(P)),T=P[1]+1}const v=h(Dz(e,i-1,o)),m=p.filter(T=>T.nodeRange[0]<v.nodeRange[0]),_=m[m.length-1];return{viewspans:_&&Lz(_.nodeRange,v.nodeRange)?m:[...m,v],minScroll:0,maxScroll:u}}function ri(n,t){var i;let e=0,r=Number.POSITIVE_INFINITY;for(let s=0;s<n.length;s+=1){const o=Math.abs((((i=n[s])==null?void 0:i.anchor)??0)-t);if(o+$t<r){r=o,e=s;continue}Math.abs(o-r)<=$t&&s<e&&(e=s)}return e}function Oz(n,t,e){return e<=0?0:Math.max(0,Math.min(e-1,n+t))}function or(n,t,e){return Math.max(t,Math.min(e,n))}function Mz(n,t){var e;for(let r=0;r<n.length;r+=1)if(Math.abs((((e=n[r])==null?void 0:e.anchor)??0)-t)<=$t)return r;return-1}function Nz(n,t,e){var i,s;if(n.length===0)return t;const r=Mz(n,t);if(r>=0){const o=n[r+e];return(o==null?void 0:o.anchor)??n[e>0?n.length-1:0].anchor}if(e>0){for(const o of n)if(o.anchor>t+$t)return o.anchor;return((i=n[n.length-1])==null?void 0:i.anchor)??t}for(let o=n.length-1;o>=0;o-=1){const a=n[o];if(a&&a.anchor<t-$t)return a.anchor}return((s=n[0])==null?void 0:s.anchor)??t}class Uz extends tn{constructor(e){super();g(this,"_scroll",0);g(this,"_minScroll",0);g(this,"_maxScroll",0);g(this,"_viewspans",[]);g(this,"_activeViewspanIndex",0);g(this,"_nodeWidthsPx",[]);g(this,"_boundaryCols",[0]);g(this,"_viewportWidthPx",0);g(this,"_framedViewportWidthPx",0);this._scroll=(e==null?void 0:e.x)??0}get scroll(){return Ee({x:this._scroll})}get translate(){return xe({x:di(this._nodeWidthsPx,this._boundaryCols,this._scroll,this._viewportWidthPx,this._framedViewportWidthPx)})}get activeViewspan(){return this._viewspans[this._activeViewspanIndex]??null}get viewspans(){return this._viewspans}set scroll(e){const r=or(e.x??this._scroll,this._minScroll,this._maxScroll);Math.abs(r-this._scroll)<=$t||(this._scroll=r,this._activeViewspanIndex=ri(this._viewspans,this._scroll),this.dispatchEvent(new ni("layout-scroll",{scroll:this.scroll})))}rebuild(e){var v;const r=e.nodeWidths.map(m=>Math.max(0,m.x??0)),i=r.map(m=>e.grid.toPixels(Ee({x:m})).x??0),s=e.grid.viewport.x??0,o=e.grid.gap.x??le,a=zz({nodeCols:r,nodeWidthsPx:i,viewportWidthPx:s,gapPx:o});this._nodeWidthsPx=i,this._boundaryCols=Yb(r),this._viewportWidthPx=s,this._framedViewportWidthPx=qb(s,o),this._viewspans=a.viewspans,this._minScroll=a.minScroll,this._maxScroll=a.maxScroll;const c=or(this._scroll,this._minScroll,this._maxScroll);this._activeViewspanIndex=ri(this._viewspans,c);const h=e.snap!==!1?((v=this._viewspans[this._activeViewspanIndex])==null?void 0:v.anchor)??c:c,p=or(h,this._minScroll,this._maxScroll);Math.abs(p-this._scroll)>$t&&(this._scroll=p,this.dispatchEvent(new ni("layout-scroll",{scroll:this.scroll})))}step(e){var o;if(this._viewspans.length===0)return;const r=Oz(this._activeViewspanIndex,e,this._viewspans.length),i=((o=this._viewspans[r])==null?void 0:o.anchor)??this._scroll,s=or(i,this._minScroll,this._maxScroll);this._activeViewspanIndex=r,!(Math.abs(s-this._scroll)<=$t)&&(this._scroll=s,this.dispatchEvent(new ni("layout-scroll",{scroll:this.scroll})))}snap(e){var s;if(this._viewspans.length===0)return;const r=e===void 0?((s=this._viewspans[ri(this._viewspans,this._scroll)])==null?void 0:s.anchor)??this._scroll:Nz(this._viewspans,this._scroll,e),i=or(r,this._minScroll,this._maxScroll);this._activeViewspanIndex=ri(this._viewspans,i),!(Math.abs(i-this._scroll)<=$t)&&(this._scroll=i,this.dispatchEvent(new ni("layout-scroll",{scroll:this.scroll})))}wheel(e){const r=or(this._scroll+(e.x??0),this._minScroll,this._maxScroll);Math.abs(r-this._scroll)<=$t||(this._scroll=r,this._activeViewspanIndex=ri(this._viewspans,this._scroll),this.dispatchEvent(new ni("layout-scroll",{scroll:this.scroll})))}wheelPixels(e){const r=e.x??0;if(Math.abs(r)<=Ur)return;const i=di(this._nodeWidthsPx,this._boundaryCols,this._scroll,this._viewportWidthPx,this._framedViewportWidthPx),s=i-r,o=di(this._nodeWidthsPx,this._boundaryCols,this._maxScroll,this._viewportWidthPx,this._framedViewportWidthPx),a=di(this._nodeWidthsPx,this._boundaryCols,this._minScroll,this._viewportWidthPx,this._framedViewportWidthPx),c=Math.max(o,Math.min(a,s));if(Math.abs(c-i)<=Ur)return;let u=this._minScroll,h=this._maxScroll;for(let v=0;v<$z;v+=1){const m=(u+h)/2;di(this._nodeWidthsPx,this._boundaryCols,m,this._viewportWidthPx,this._framedViewportWidthPx)>c?u=m:h=m}const p=or((u+h)/2,this._minScroll,this._maxScroll);Math.abs(p-this._scroll)<=$t||(this._scroll=p,this._activeViewspanIndex=ri(this._viewspans,this._scroll),this.dispatchEvent(new ni("layout-scroll",{scroll:this.scroll})))}}const eu={"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}},Fz=["stack-above","stack-below","reorder-before","reorder-after"];function tu(n,t){return{left:n.left+n.width*t.left,top:n.top+n.height*t.top,width:n.width*t.width,height:n.height*t.height}}function ar(n,t,e){return n>=e.left&&n<e.left+e.width&&t>=e.top&&t<e.top+e.height}function ah(n){return Number.isFinite(n)?Math.max(Fs,Math.min(nd,Math.round(n))):Fs}function Hz(n,t,e){const r=n.findIndex(a=>a.type==="card"&&a.id===t);if(r===-1)return n;const i=n[r];if(!i||i.type!=="card")return n;const s=ah(e);if(i.width===s)return n;const o=[...n];return o[r]={...i,width:s},o}function Jb(n,t){for(const e of n){if(e.type==="card"&&e.id===t)return e;if(e.type==="stack")for(const r of e.children){if(r.type==="card"&&r.id===t)return r;if(r.type==="row"){for(const i of r.children)if(i.id===t)return i}}}return null}function lh(n){const t=n.height===ct||n.height===Bn?Bn:n.height;return n.width===Fe&&n.height===t?n:{...n,width:Fe,height:t}}function ch(n){return n.height===Bn?{...n,height:ct}:n}function Wz(n,t,e,r){const i=n.findIndex(h=>h.type==="stack"&&h.id===t);if(i===-1)return n;const s=n[i];if(!s||s.type!=="stack")return n;const o=s.children.find(h=>h.type==="card"&&h.id===e);if(!o||o.type!=="card")return n;const a=s.children.filter(h=>h.id!==e);if(a.length===s.children.length||a.length<1)return n;const c=[...n];if(a.length===1){const[h]=a;c[i]=h.type==="card"?ch(h):h}else c[i]={...s,children:a};const u=Math.max(0,Math.min(r,c.length));return c.splice(u,0,ch(o)),c}const Zz=He(),Vz=He(),Bz=50;function jz(n,t){if(n.type!==t.type)return!1;switch(n.type){case"reorder":return t.index===n.index;case"stack":return t.targetCardId===n.targetCardId&&t.position===n.position;case"stack-child-noop":return!0;case"stack-child-extract":return t.toIndex===n.toIndex;case"stack-child-reorder":return t.position===n.position;default:return!1}}function Yo(n){return{id:n.id,type:"drop-target",width:n.width,height:n.height}}function Tg(n){return n.map(qz)}function Gz(n){return n.type==="drop-target"?{id:n.id,type:"card",artifactID:n.id,width:n.width,height:n.height}:n}function qz(n){return n.type==="drop-target"?{id:n.id,type:"card",artifactID:n.id,width:n.width,height:n.height}:n.type==="stack"?{...n,children:n.children.map(Gz)}:n}function Qb(n,t){return n.find(r=>r.type==="card"&&r.id===t)??null}function Ig(n,t){return n.find(r=>r.type==="stack"&&r.id===t)??null}function Yz(n,t){const e=[...t],r=e.findIndex(a=>a.type==="card"&&a.id===n.nodeId);if(r===-1)return null;const i=e[r];if(!i||i.type!=="card")return null;e.splice(r,1);const s=Math.max(0,Math.min(n.lastReorderIndex,e.length));e.splice(s,0,i);const o=e.findIndex(a=>a.type==="card"&&a.id===n.nodeId);return o===-1?null:{base:e,visualDraggedIndex:o}}function Xz(n,t,e,r){const i=[...n.base];i.splice(n.visualDraggedIndex,1);const s=i.findIndex(v=>v.type==="card"&&v.id===e.targetCardId),o=s===-1?null:i[s];if(!o||o.type!=="card")return null;const a=Qb(r,t.nodeId);if(!a)return null;const c=lh(a),u=lh(o),h=Yo(c),p=e.position==="above"?[h,u]:[u,h];return i[s]={id:o.id,type:"stack",children:p},i}function nu(n,t){return n.parentStackId?Jz(n,t):Kz(n,t)}function Kz(n,t){const e=n.hitTarget;if(e.type==="reorder"){const r=t[n.sourceIndex];if(!r||r.type!=="card")return[...t];const i=[...t];return i.splice(n.sourceIndex,1),i.splice(e.index,0,Yo(r)),i}if(e.type==="stack"){const r=Yz(n,t);return r?Xz(r,n,e,t)??[...t]:[...t]}return[...t]}function Jz(n,t){const e=n.hitTarget;switch(e.type){case"stack-child-reorder":return Qz(n,t,e.position);case"stack-child-extract":return eO(n,t,e.toIndex);case"stack-child-noop":return tO(n,t);default:return[...t]}}function Qz(n,t,e){const r=t.findIndex(v=>v.type==="stack"&&v.id===n.parentStackId);if(r===-1)return[...t];const i=t[r];if(!i||i.type!=="stack")return[...t];if(!i.children.every(v=>v.type==="card"))return[...t];const s=i.children,o=s.findIndex(v=>v.id===n.nodeId);if(o===-1)return[...t];const a=s[o],c=s.filter(v=>v.id!==n.nodeId),u=Yo(a),h=e==="above"?[u,...c]:[...c,u],p=[...t];return p[r]={...i,children:h},p}function eO(n,t,e){if(!n.parentStackId)return[...t];const r=Wz(t,n.parentStackId,n.nodeId,e);if(r===t)return[...t];const i=r.findIndex(a=>a.type==="card"&&a.id===n.nodeId);if(i===-1)return[...t];const s=r[i];if(!s||s.type!=="card")return[...t];const o=[...r];return o[i]=Yo(s),o}function tO(n,t){const e=t.findIndex(c=>c.type==="stack"&&c.id===n.parentStackId);if(e===-1)return[...t];const r=t[e];if(!r||r.type!=="stack")return[...t];const i=r.children.findIndex(c=>c.type==="card"&&c.id===n.nodeId);if(i===-1)return[...t];const s=r.children[i];if(!s||s.type!=="card")return[...t];const o=[...t],a=[...r.children];return a[i]=Yo(s),o[e]={...r,children:a},o}function nO(n,t){return t.find(r=>r.type==="stack"&&r.id===n.id)?n.id:Wl()}function rO(n,t,e){if(n.type==="drop-target"){const r=Jb(t,e);if(!r)throw new Error(`finalize: missing dragged card ${e}`);return lh(r)}return n}function iO(n,t,e){const r=n.children.map(s=>rO(s,t,e));return{id:nO(n,t),type:"stack",children:r}}function sO(n,t,e){if(n.type==="drop-target"){const r=Jb(t,e);if(!r)throw new Error(`finalize: missing dragged card ${e}`);return Qb(t,e)!==null?r:ch(r)}return n.type==="card"||n.type==="row"?n:iO(n,t,e)}function oO(n,t,e){return n.map(r=>sO(r,t,e))}function aO(n,t){return JSON.stringify(n)===JSON.stringify(t)}const lO=Go(tn);class cO extends lO{constructor(e={}){super();g(this,"pending",null);g(this,"active",null)}start(e){if(this.pending||this.active)return;const r=e.pointer.x??0,i=e.pointer.y??0;this.pending={startX:r,startY:i,grabOffsetX:e.grabOffset.x??0,grabOffsetY:e.grabOffset.y??0,nodeId:e.nodeId,sourceIndex:e.source.index,parentStackId:e.source.parentId,width:e.size.x??0,height:e.size.y??0,baseLayout:e.layout}}update(e){const r=e.pointer.x??0,i=e.pointer.y??0,s=this.pending;if(s){const u=r-s.startX,h=i-s.startY;Math.hypot(u,h)>=t1&&(this.pending=null,this.active={...s,pointerX:r,pointerY:i,hitTarget:{type:"reorder",index:s.sourceIndex},lastReorderIndex:s.sourceIndex},this.emitDrag(),this.dispatchEvent(new ae("change")));return}if(!this.active)return;const o=nu(this.active,this.active.baseLayout),a=this.getHitTargetForPointer(r,i,e,o),c=a.type==="reorder"?a.index:this.active.lastReorderIndex;this.active.pointerX===r&&this.active.pointerY===i&&jz(this.active.hitTarget,a)&&this.active.lastReorderIndex===c||(this.active={...this.active,pointerX:r,pointerY:i,hitTarget:a,lastReorderIndex:c},this.emitDrag(),this.dispatchEvent(new ae("change")))}drop(){if(this.pending){this.cancel();return}if(!this.active)return;const e=this.active.baseLayout;let r=null;try{const i=nu(this.active,e),s=oO(i,e,this.active.nodeId);aO(s,e)||(r=s)}catch{r=null}this.reset(),r&&this.dispatchEvent(new Vz("drop",{layout:r})),this.dispatchEvent(new ae("change"))}cancel(){!this.pending&&!this.active||(this.reset(),this.dispatchEvent(new ae("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 e=nu(this.active,this.active.baseLayout);this.dispatchEvent(new Zz("drag",{nodeId:this.active.nodeId,source:{index:this.active.sourceIndex,parentId:this.active.parentStackId},grabOffset:xe({x:this.active.grabOffsetX,y:this.active.grabOffsetY}),pointer:xe({x:this.active.pointerX,y:this.active.pointerY}),size:xe({x:this.active.width,y:this.active.height}),projectedLayout:e}))}getHitTargetForPointer(e,r,i,s){return this.active?this.isPointerInsideDragBounds(e,r,i.viewport)?this.active.parentStackId?this.getStackChildHitTarget(e,r,i,s):this.getTopLevelCardHitTarget(e,r,i,s):{type:"reorder",index:this.active.sourceIndex}:{type:"reorder",index:0}}getStackChildHitTarget(e,r,i,s){var u;if(!((u=this.active)!=null&&u.parentStackId))return{type:"stack-child-noop"};const o=this.getSourceStackInteractionRect(i.geometry);if(o&&ar(e,r,o)){const h=o.top+o.height/2;return{type:"stack-child-reorder",position:r<h?"above":"below"}}const a=this.getSourceRemainingSiblingRect(i.geometry);if(a&&ar(e,r,a)){const h=a.top+a.height/2;return{type:"stack-child-reorder",position:r<h?"above":"below"}}return{type:"stack-child-extract",toIndex:this.getTopLevelReorderIndexForPointer(e,r,i,s)}}getSourceRemainingSiblingRect(e){var s,o;if(!((s=this.active)!=null&&s.parentStackId))return;const r=Ig(this.active.baseLayout,this.active.parentStackId);if(!r)return;const i=r.children.find(a=>{var c;return a.type==="card"&&a.id!==((c=this.active)==null?void 0:c.nodeId)});if(i)return(o=e.find(a=>a.id===i.id))==null?void 0:o.rect}getSourceStackInteractionRect(e){var o;if(!((o=this.active)!=null&&o.parentStackId))return;const r=e.find(a=>{var c;return a.id===((c=this.active)==null?void 0:c.parentStackId)});if(r)return this.active.sourceStackRect=r.rect,r.rect;const i=Ig(this.active.baseLayout,this.active.parentStackId);if(!i)return this.active.sourceStackRect;const s=i.children.find(a=>{var c;return a.type==="card"&&a.id!==((c=this.active)==null?void 0:c.nodeId)});if(s){const a=e.find(c=>c.id===s.id);if(a)return a.rect}return this.active.sourceStackRect}getTopLevelCardHitTarget(e,r,i,s){var m,_,k;const o=this.getTopLevelZoneNodes(i.geometry,s);if(o.length===0)return{type:"reorder",index:((m=this.active)==null?void 0:m.sourceIndex)??0};const c=(i.effectiveVelocity??0)<=Bz;for(const T of o){const P=T.rect;if(!ar(e,r,P))continue;const R=this.resolveTopLevelTargetForCard(e,r,T,T.logicalIndex,c);if(R)return R;if(!c&&((_=this.active)!=null&&_.hitTarget))return this.active.hitTarget.type==="reorder"?this.active.hitTarget:this.active.hitTarget.type==="stack"&&this.active.hitTarget.targetCardId===T.id?this.active.hitTarget:{type:"reorder",index:e<this.active.pointerX?T.logicalIndex:T.logicalIndex+1}}const u=this.getNearestTargetableZone(e,o);if(!u)return{type:"reorder",index:((k=this.active)==null?void 0:k.sourceIndex)??0};const h=Math.max(u.rect.left,Math.min(u.rect.left+u.rect.width,e)),p=this.resolveTopLevelTargetForCard(h,r,u,u.logicalIndex,c);if(p)return p;const v=u.rect.left+u.rect.width/2;return{type:"reorder",index:e<v?u.logicalIndex:u.logicalIndex+1}}getTopLevelReorderIndexForPointer(e,r,i,s){var u,h;const o=this.getTopLevelZoneNodes(i.geometry,s);if(o.length===0)return((u=this.active)==null?void 0:u.sourceIndex)??0;for(const p of o){if(!ar(e,r,p.rect))continue;const v=tu(p.rect,eu["reorder-before"]);if(ar(e,r,v))return p.logicalIndex;const m=tu(p.rect,eu["reorder-after"]);if(ar(e,r,m))return p.logicalIndex+1}const a=this.getNearestTargetableZone(e,o);if(!a)return((h=this.active)==null?void 0:h.sourceIndex)??0;const c=a.rect.left+a.rect.width/2;return e<c?a.logicalIndex:a.logicalIndex+1}getTopLevelZoneNodes(e,r){const i=new Map(r.map(a=>[a.id,a])),s=[];let o=0;for(const a of e){const c=i.get(a.id);c&&c.type!=="drop-target"&&(c.type==="card"||c.type==="stack")&&(s.push({id:c.id,rect:a.rect,logicalIndex:o}),o+=1)}return s}resolveTopLevelTargetForCard(e,r,i,s,o){const a=i.rect;for(const c of Fz){if(!o&&(c==="stack-above"||c==="stack-below"))continue;const u=eu[c],h=tu(a,u);if(ar(e,r,h))return c==="stack-above"?{type:"stack",targetCardId:i.id,position:"above"}:c==="stack-below"?{type:"stack",targetCardId:i.id,position:"below"}:c==="reorder-before"?{type:"reorder",index:s}:{type:"reorder",index:s+1}}return null}getNearestTargetableZone(e,r){let i=null,s=Number.POSITIVE_INFINITY;for(const o of r){const a=o.rect.left,c=o.rect.left+o.rect.width,u=e<a?a-e:e>c?e-c:0;u<s&&(s=u,i=o)}return i}isPointerInsideDragBounds(e,r,i){return e>=i.left&&e<=i.left+i.width&&r>=i.top&&r<=i.top+i.height}}const Cg=60,uO=80,Rg=.5,Pg=10;class hO{constructor(){g(this,"awaitingFreshWheelGesture",!1);g(this,"lastWheelEventAt",Number.NEGATIVE_INFINITY);g(this,"lastWheelDeltaX",0);g(this,"activeGestureType","none");g(this,"lastWheelGestureAt",Number.NEGATIVE_INFINITY)}markKeyboardNavigation(t){this.awaitingFreshWheelGesture=!0,this.lastWheelEventAt=t,this.activeGestureType="none"}reset(){this.awaitingFreshWheelGesture=!1,this.lastWheelEventAt=Number.NEGATIVE_INFINITY,this.lastWheelDeltaX=0,this.activeGestureType="none",this.lastWheelGestureAt=Number.NEGATIVE_INFINITY}decide(t){const{now:e,shiftKey:r,deltaX:i,deltaY:s,overArtifactContent:o}=t;e-this.lastWheelGestureAt>=Cg&&(this.activeGestureType="none");const c=r&&s!==0,u=c?s:i,h=Math.abs(u),p=Math.abs(s);return this.activeGestureType==="vertical-artifact"&&o?h>=Rg&&h>=p*Pg?this.classifyHorizontal(e,u):(this.lastWheelGestureAt=e,{type:"scroll-native"}):this.activeGestureType==="horizontal-filmstrip"?!c&&o&&p>0&&p>=h*Pg?(this.activeGestureType="vertical-artifact",this.lastWheelGestureAt=e,{type:"scroll-native"}):this.classifyHorizontal(e,u):h<Rg?(o&&(this.activeGestureType="vertical-artifact"),this.lastWheelGestureAt=e,{type:"scroll-native"}):c||h>p?this.classifyHorizontal(e,u):p>h?(o&&(this.activeGestureType="vertical-artifact"),this.lastWheelGestureAt=e,{type:"scroll-native"}):o?(this.activeGestureType="vertical-artifact",this.lastWheelGestureAt=e,{type:"scroll-native"}):this.classifyHorizontal(e,u)}classifyHorizontal(t,e){const r=t-this.lastWheelEventAt,i=Math.sign(this.lastWheelDeltaX),s=Math.sign(e),o=i!==0&&s!==0&&i!==s,a=i!==0&&Math.abs(e)>=Math.abs(this.lastWheelDeltaX)+uO;return this.awaitingFreshWheelGesture&&r<Cg&&!o&&!a?{type:"ignore"}:(this.lastWheelEventAt=t,this.lastWheelDeltaX=e,this.lastWheelGestureAt=t,this.awaitingFreshWheelGesture=!1,this.activeGestureType="horizontal-filmstrip",{type:"scroll-horizontal",horizontalDelta:e})}}const dO=100,pO=1e3;class fO{constructor(t,e){g(this,"_status","idle");g(this,"cumulativeOffset",0);g(this,"samples",[]);g(this,"scroll");g(this,"setAnimating");this.scroll=t,this.setAnimating=e}get status(){return this._status}start(t){this._status="active",this.cumulativeOffset=0,this.samples=[{time:t,offset:0}]}move(t,e){this._status==="active"&&(this.cumulativeOffset+=e,this.samples.push({time:t,offset:this.cumulativeOffset}),this.pruneSamples(t),this.setAnimating(!1),this.scroll.wheelPixels(xe({x:-e})))}end(){if(this._status!=="active")return;const t=this.computeVelocityPxPerSec();this.setAnimating(!0),Math.abs(t)<r1?this.scroll.snap():this.scroll.snap(t>0?-1:1),this.reset()}cancel(){this._status==="active"&&(this.setAnimating(!0),this.scroll.snap(),this.reset())}reset(){this._status="idle",this.cumulativeOffset=0,this.samples=[]}pruneSamples(t){const e=t-dO;let r=0;for(let i=0;i<this.samples.length;i+=1){if(this.samples[i].time>=e){r=i;break}r=i+1}if(r>0){const i=Math.max(0,r-1);this.samples=this.samples.slice(i)}}computeVelocityPxPerSec(){if(this.samples.length<2)return 0;const t=this.samples[0],e=this.samples[this.samples.length-1],r=e.time-t.time;return r<=0?0:(e.offset-t.offset)/r*pO}}function gO({baseLayout:n,visibleLayout:t,resolved:e,cardsByID:r,grid:i,dragState:s,isForeground:o}){var _;const a=new Map(t.map(k=>[k.id,k])),c=e.nodes.map((k,T)=>{const P=a.get(k.id),R=[];for(const N of k.cards){if(s&&N.id===s.nodeId){R.push({key:`placeholder:${N.id}`,kind:"placeholder",card:null,placement:N,isTopLevelCard:!1,isDragged:!1,sourceStackId:s.source.parentId??null});continue}const F=r.get(N.id);F&&R.push({key:F.id,kind:"card",card:F,placement:N,isTopLevelCard:(P==null?void 0:P.type)==="card",isDragged:!1,sourceStackId:null})}if(s!=null&&s.source.parentId&&k.id===s.source.parentId){const N=r.get(s.nodeId);if(N){const F={key:N.id,kind:"card",card:N,placement:null,isTopLevelCard:!1,isDragged:!0,sourceStackId:s.source.parentId},Y=mO(n,s.source.parentId,s.nodeId),j=Y<0?R.length:Math.min(Y,R.length);R.splice(j,0,F)}}const W=!!(s&&(P==null?void 0:P.type)==="card"&&P.id===s.nodeId&&P.artifactID===s.nodeId);return{key:W?`placeholder:${k.id}`:k.id,kind:"visible",nodeId:k.id,widthPx:i.toPixels(Ee({x:k.width})).x??0,widthUnits:k.width,layoutIndex:T,isForeground:o(T),isPlaceholder:W,slots:R}});if(!s||s.source.parentId&&a.has(s.source.parentId))return c;const u=r.get(s.nodeId);if(!u)return c;const h=s.source.parentId??s.nodeId,p=((_=gr(n).nodes[s.source.index])==null?void 0:_.width)??Fe,v={key:h,kind:"ghost",nodeId:h,widthPx:0,widthUnits:p,layoutIndex:null,isForeground:!1,isPlaceholder:!1,slots:[{key:u.id,kind:"card",card:u,placement:null,isTopLevelCard:!s.source.parentId,isDragged:!0,sourceStackId:s.source.parentId??null}]},m=Math.max(0,Math.min(s.source.index,c.length));return c.splice(m,0,v),c}function Dg(n){if(!n)return null;const t=n.projectedLayout,e=n.source.parentId;for(const i of t){if(i.type!=="stack")continue;const s=i.children.findIndex(u=>u.type==="drop-target");if(s===-1)continue;const o=s===0?"above":"below";if(e&&e===i.id)return`stack-child-reorder:${o}`;const a=i.children.find(u=>u.type!=="drop-target");return`stack:${(a==null?void 0:a.type)==="card"?a.artifactID:(a==null?void 0:a.id)??""}:${o}`}const r=t.findIndex(i=>i.type==="drop-target");return r===-1?"none":e?`stack-child-extract:${r}`:`reorder:${r}`}function mO(n,t,e){const r=n.find(i=>i.type==="stack"&&i.id===t);return!r||r.type!=="stack"?-1:r.children.findIndex(i=>i.type==="card"&&i.id===e)}const vO=2,Lg=1e3,Tn=1e-4,yO=120,zg=300,Og=!1;function Mg(n){return n.replace(/["\\]/g,"\\$&")}function Ng(n,t,e){if(n===0)return 0;const r=t.toPixels(Ee({y:ct})).y??0;return(e-r)/vO}function ru(n){const t=n.clientWidth>0?n.clientWidth:zr,e=n.clientHeight>0?n.clientHeight:sl;let r=0,i=0;if(n.isConnected){const o=getComputedStyle(n);r=parseFloat(o.paddingTop)||0,i=parseFloat(o.paddingBottom)||0}const s=Math.max(1,e-r-i);return{width:t,height:s,offsetY:r}}class bO extends Event{constructor(e){super("scroll",{bubbles:!0,composed:!0});g(this,"scrollPosition");this.scrollPosition=e}}class ew extends Event{constructor(e){super("layout-change",{bubbles:!0,composed:!0});g(this,"layout");this.layout=e}}class wO extends HTMLElement{constructor(){super();g(this,"_layout",[]);g(this,"_scrollPosition",0);g(this,"layoutGrid",null);g(this,"layoutScroll",new Uz(Ee({x:0})));g(this,"scrollModelKey","");g(this,"resizeObserver",null);g(this,"renderPending",!1);g(this,"animateNextRender",!0);g(this,"wheelGesture",new hO);g(this,"filmstripWheelHandoffUntil",0);g(this,"filmstripWheelDirection",0);g(this,"swipeGesture",new fO(this.layoutScroll,e=>{this.animateNextRender=e}));g(this,"swipePointerId",null);g(this,"swipeStartX",0);g(this,"swipeStartY",0);g(this,"swipeLastX",0);g(this,"swipeActive",!1);g(this,"swipeShouldSuppressClick",!1);g(this,"swipeListenersAttached",!1);g(this,"wheelIdleSnapTimer",null);g(this,"wheelPointerEventsTimer",null);g(this,"dragController",new cO);g(this,"dragState",null);g(this,"activeDragPointerId",null);g(this,"dragListenersAttached",!1);g(this,"dragFrame",0);g(this,"lastDragFrameTime",0);g(this,"lastPointerX",0);g(this,"lastPointerY",0);g(this,"pointerVelocityPxPerSec",0);g(this,"scrollVelocityPxPerSec",0);g(this,"motionSampleTime",0);g(this,"motionSampleX",0);g(this,"motionSampleY",0);g(this,"lastDragControllerStatus","idle");g(this,"lastProjectedDragLayoutSignature","");g(this,"lastDragDropIntent",null);g(this,"lastActivePlaceholderId",null);g(this,"draggedSlotElement",null);g(this,"draggedSlotContainingBlock",null);g(this,"currentDragPreviewSize",null);g(this,"dragTrackOffsetXPx",0);g(this,"previousProjectedLayoutForOffset",null);g(this,"resizeState",null);g(this,"resizeListenersAttached",!1);g(this,"_cards",new Map);g(this,"onDragControllerChange",()=>{const e=this.dragController.status;e!==this.lastDragControllerStatus&&(this.lastDragControllerStatus=e,e==="idle"&&(this.dragState=null,this.resetDragPreviewState()),this.scheduleRender())});g(this,"onDragControllerDrag",e=>{var c;const r=JSON.stringify(e.projectedLayout),i=Dg(e),s=_O(e.projectedLayout);if(r!==this.lastProjectedDragLayoutSignature||i!==this.lastDragDropIntent||s!==this.lastActivePlaceholderId){const u=Tg(e.projectedLayout),h=this.shouldApplyTrackOffset(e.projectedLayout,e.source.parentId),p=e.source.parentId?this.getStackChildAnchorCardId(e.source.parentId,e.nodeId):null;this.dragTrackOffsetXPx=h?this.computeDragTrackOffset(this.previousProjectedLayoutForOffset,u,e.nodeId,e.source.parentId,p,this.dragTrackOffsetXPx):0,this.previousProjectedLayoutForOffset=u,this.lastProjectedDragLayoutSignature=r,this.lastDragDropIntent=i,this.lastActivePlaceholderId=s,this.dragState={nodeId:e.nodeId,source:e.source,grabOffset:e.grabOffset,pointer:e.pointer,size:e.size,projectedLayout:e.projectedLayout},this.scheduleRender();return}this.dragState={nodeId:e.nodeId,source:e.source,grabOffset:e.grabOffset,pointer:e.pointer,size:e.size,projectedLayout:((c=this.dragState)==null?void 0:c.projectedLayout)??e.projectedLayout};const a=this.getCachedDraggedSlotElement(e.nodeId);a&&this.writeDraggedSlotPosition(a,this.dragState)});g(this,"onDragControllerDrop",e=>{this.dragState=null,this.resetDragPreviewState(),this.commitLayout(e.layout)});g(this,"onLayoutScrollInternal",e=>{const i=e.scroll.x??0;Math.abs(i-this._scrollPosition)<Tn||(this._scrollPosition=i,this.emitScrollPositionChanged(i),this.scheduleRender())});g(this,"handleKeyDown",e=>{if(e.key==="Escape"&&this.dragController.status!=="idle"){e.preventDefault(),this.stopDragFrameLoop(),this.releaseActiveDragPointerCapture(),this.dragController.cancel(),this.detachDragListeners();return}this.dragController.status==="idle"&&(e.key==="ArrowRight"?(e.preventDefault(),this.wheelGesture.markKeyboardNavigation(Date.now()),this.shiftWindow(1)):e.key==="ArrowLeft"&&(e.preventDefault(),this.wheelGesture.markKeyboardNavigation(Date.now()),this.shiftWindow(-1)))});g(this,"handleWindowWheelHandoff",e=>{if(this._layout.length===0||Date.now()>this.filmstripWheelHandoffUntil||this.contains(e.target))return;const r=this.getHandoffHorizontalDelta(e);Math.abs(r)<Tn||(e.preventDefault(),e.stopPropagation(),this.applyHorizontalWheel(r))});g(this,"handleWheel",e=>{if(this._layout.length===0)return;const r=Date.now(),i=r<=this.filmstripWheelHandoffUntil,s=this.wheelGesture.decide({now:r,shiftKey:e.shiftKey,deltaX:e.deltaX,deltaY:e.deltaY,overArtifactContent:!1});if(s.type!=="scroll-horizontal"&&!i)return;const o=s.type==="scroll-horizontal"?s.horizontalDelta:0,a=Math.abs(o)>=Tn?o:i?this.getHandoffHorizontalDelta(e):0;Math.abs(a)<Tn||(e.preventDefault(),this.applyHorizontalWheel(a))});g(this,"handleWindowMessage",e=>{if(this._layout.length===0)return;const r=this.findManagedArtifactFrame(e.source);if(r&&this.isTrustedArtifactFrameMessage(e,r)){if(cz(e.data)){const i=typeof performance<"u"?performance.now():Date.now();this.swipeGesture.status==="idle"&&this.swipeGesture.start(i),this.swipeGesture.move(i,e.data.deltaX);return}if(uz(e.data)){this.swipeGesture.status==="active"&&this.swipeGesture.end();return}}});g(this,"handleArtifactWheel",e=>{if(this._layout.length===0)return;const r=this.wheelGesture.decide({now:Date.now(),shiftKey:e.shiftKey,deltaX:e.deltaX,deltaY:e.deltaY,overArtifactContent:!0});if(r.type==="scroll-horizontal"){this.applyHorizontalWheel(r.horizontalDelta);return}r.type==="scroll-native"&&e.scrollNative(e.deltaY)});g(this,"handlePointerDown",e=>{if(e.button!==0||this.dragController.status!=="idle"||this.resizeState)return;const r=e.target;if(!(r instanceof Element))return;const i=r.closest("[data-resize-handle]");if(i){this.beginResize(e,i);return}const s=r.closest("[drag-handle]")!==null,o=r.closest("button, input, textarea, select, a, [role='button']")!==null;if(e.pointerType==="touch"&&!s&&!o&&this._layout.length>0){this.beginSwipeTracking(e);return}if(!s){if(!o){const p=r.closest(".node");if(p&&!p.hasAttribute("data-foreground")){const v=p.getAttribute("layout-node");if(v!==null){const m=parseInt(v,10);if(!isNaN(m)){const _=this.findViewspanContainingNode(m);if(_){this.clearWheelIdleSnap(),this.animateNextRender=!0,this.layoutScroll.scroll=Ee({x:_.anchor}),e.preventDefault(),e.stopPropagation();return}}}}}return}if(o)return;const a=r.closest(".card-slot");if(!a)return;const c=a.getAttribute("data-layout-node-id");if(!c)return;const u=kO(this._layout,c);if(!u)return;const h=a.getBoundingClientRect();this.lastPointerX=e.clientX,this.lastPointerY=e.clientY,this.resetMotionTracking(e.clientX,e.clientY),this.focus(),this.dragController.start({nodeId:c,source:{index:u.topLevelIndex,parentId:u.sourceStackId},pointer:xe({x:e.clientX,y:e.clientY}),grabOffset:xe({x:e.clientX-h.left,y:e.clientY-h.top}),size:xe({x:h.width,y:h.height}),layout:this._layout}),this.attachDragListeners(),this.activeDragPointerId=e.pointerId;try{this.setPointerCapture(e.pointerId)}catch{}e.preventDefault()});g(this,"handleResizePointerMove",e=>{const r=this.resizeState;if(!r||e.pointerId!==r.pointerId)return;const i=this.layoutGrid,s=((i==null?void 0:i.unit.x)??In)+le;if(s<=0)return;const o=e.clientX-r.startClientX,a=ah(r.startWidth+o/s);a!==r.currentWidth&&(r.currentWidth=a,this.scheduleRender())});g(this,"handleResizePointerUp",e=>{const r=this.resizeState;if(!r||e.pointerId!==r.pointerId)return;const i=r.currentWidth,s=r.startWidth,o=r.cardId;this.endResize(e.pointerId),i!==s?this.commitLayout(Hz(this._layout,o,i)):this.scheduleRender()});g(this,"handleResizePointerCancel",e=>{!this.resizeState||e.pointerId!==this.resizeState.pointerId||(this.endResize(e.pointerId),this.scheduleRender())});g(this,"handleResizeWindowBlur",()=>{this.resizeState&&(this.endResize(this.resizeState.pointerId),this.scheduleRender())});g(this,"handleResizeKeyDown",e=>{this.resizeState&&e.key==="Escape"&&(e.preventDefault(),this.endResize(this.resizeState.pointerId),this.scheduleRender())});g(this,"handleSwipePointerMove",e=>{if(this.swipePointerId===null||e.pointerId!==this.swipePointerId)return;if(!this.swipeActive){const i=e.clientX-this.swipeStartX,s=e.clientY-this.swipeStartY,o=Math.abs(i),a=Math.abs(s);if(o<Mf&&a<Mf)return;if(a>=o){this.endSwipeTracking();return}this.swipeActive=!0,this.swipeShouldSuppressClick=!0;try{this.setPointerCapture(e.pointerId)}catch{}this.swipeGesture.start(e.timeStamp)}const r=e.clientX-this.swipeLastX;this.swipeLastX=e.clientX,this.swipeGesture.move(e.timeStamp,r),e.preventDefault()});g(this,"handleSwipePointerUp",e=>{this.swipePointerId===null||e.pointerId!==this.swipePointerId||(this.swipeActive&&this.swipeGesture.end(),this.releaseSwipePointerCapture(e.pointerId),this.endSwipeTracking())});g(this,"handleSwipePointerCancel",e=>{this.swipePointerId===null||e.pointerId!==this.swipePointerId||(this.swipeActive&&this.swipeGesture.cancel(),this.releaseSwipePointerCapture(e.pointerId),this.endSwipeTracking())});g(this,"handleSwipeWindowBlur",()=>{this.swipePointerId!==null&&this.swipeActive&&this.swipeGesture.cancel(),this.swipePointerId!==null&&this.releaseSwipePointerCapture(this.swipePointerId),this.endSwipeTracking()});g(this,"handleSwipeClick",e=>{this.swipeShouldSuppressClick&&(this.swipeShouldSuppressClick=!1,e.preventDefault(),e.stopPropagation(),typeof e.stopImmediatePropagation=="function"&&e.stopImmediatePropagation())});g(this,"handleWindowPointerMove",e=>{this.activeDragPointerId!==null&&e.pointerId!==this.activeDragPointerId||(this.lastPointerX=e.clientX,this.lastPointerY=e.clientY,this.updatePointerVelocity(e.clientX,e.clientY),this.syncDragTargetForLatestPointer(),this.ensureDragFrameLoop())});g(this,"handleWindowPointerUp",e=>{this.activeDragPointerId!==null&&e.pointerId!==this.activeDragPointerId||(this.stopDragFrameLoop(),this.releasePointerCaptureForEvent(e.pointerId),this.dragController.drop(),this.clearMotionTracking(),this.detachDragListeners())});g(this,"handleWindowPointerCancel",e=>{if(!(this.activeDragPointerId!==null&&e.pointerId!==this.activeDragPointerId)){if(this.dragController.status==="active"){this.ensureDragFrameLoop();return}this.stopDragFrameLoop(),this.releasePointerCaptureForEvent(e.pointerId),this.dragController.cancel(),this.clearMotionTracking(),this.detachDragListeners()}});g(this,"handleWindowBlur",()=>{this.releaseActiveDragPointerCapture(),this.stopDragFrameLoop(),this.dragController.cancel(),this.clearMotionTracking(),this.detachDragListeners()});g(this,"runDragFrame",e=>{if(this.dragController.status==="idle"){this.dragFrame=0;return}const r=Math.max(0,e-this.lastDragFrameTime)/Lg;this.lastDragFrameTime=e,this.samplePointerVelocityAt(e,this.lastPointerX,this.lastPointerY);const i=this.getBoundingClientRect(),s=this.clampPointerToViewport(this.lastPointerX,this.lastPointerY,i),o=this.getDragEdgeScrollDeltaPixels(s.x,i,r);this.scrollVelocityPxPerSec=r>Tn?Math.abs(o)/r:0,Math.abs(o)>Tn&&(this.animateNextRender=!1,this.layoutScroll.wheelPixels(xe({x:o}))),this.dragController.status==="active"&&this.syncDragTarget(s.x,s.y,i),this.dragFrame=requestAnimationFrame(this.runDragFrame)});this.dragController.addEventListener("change",this.onDragControllerChange),this.dragController.addEventListener("drag",this.onDragControllerDrag),this.dragController.addEventListener("drop",this.onDragControllerDrop),this.layoutScroll.addEventListener("layout-scroll",this.onLayoutScrollInternal)}set cards(e){this._cards!==e&&(this._cards=e,this.scheduleRender())}get cards(){return this._cards}set layout(e){const r=[...e];this.dragController.status!=="idle"&&JSON.stringify(r)===JSON.stringify(this._layout)||(this._layout=r,this.stopDragFrameLoop(),this.dragController.cancel(),this.resizeState&&this.endResize(this.resizeState.pointerId),this.scrollModelKey="",this.syncScrollModel(),this.layoutScroll.scroll=Ee({x:this._scrollPosition}),this.scheduleRender())}get layout(){return this._layout}commitLayout(e){this.layout=e,this.emitLayoutChanged()}set scrollPosition(e){Math.abs(e-this._scrollPosition)<Tn||(this.animateNextRender=!1,this.syncScrollModel(),this.layoutScroll.scroll=Ee({x:e}))}get scrollPosition(){return this._scrollPosition}focusArtifact(e){const r=gr(this._layout),i=r.nodes.findIndex(o=>o.cards.some(a=>a.artifactID===e));if(i<0)return;let s=0;for(let o=0;o<i;o+=1)s+=r.nodes[o].width;this.scrollPosition=s,queueMicrotask(()=>{const o=this.querySelector(`.card-slot[data-layout-card-id="${Mg(e)}"]`);if(!o)return;o.classList.remove("card-focus-pulse"),o.offsetHeight,o.classList.add("card-focus-pulse");const a=()=>{o.classList.remove("card-focus-pulse"),o.removeEventListener("animationend",a)};o.addEventListener("animationend",a)})}connectedCallback(){this.hasAttribute("tabindex")||(this.tabIndex=0),this.focus(),this.addEventListener("keydown",this.handleKeyDown),this.addEventListener("wheel",this.handleWheel,{passive:!1}),this.addEventListener("pointerdown",this.handlePointerDown),this.addEventListener("artifact-wheel",this.handleArtifactWheel),window.addEventListener("wheel",this.handleWindowWheelHandoff,{capture:!0,passive:!1}),window.addEventListener("message",this.handleWindowMessage),typeof ResizeObserver<"u"&&(this.resizeObserver=new ResizeObserver(()=>this.render()),this.resizeObserver.observe(this)),this.render()}disconnectedCallback(){var e;this.removeEventListener("keydown",this.handleKeyDown),this.removeEventListener("wheel",this.handleWheel),this.removeEventListener("pointerdown",this.handlePointerDown),this.removeEventListener("artifact-wheel",this.handleArtifactWheel),window.removeEventListener("wheel",this.handleWindowWheelHandoff,{capture:!0}),window.removeEventListener("message",this.handleWindowMessage),(e=this.resizeObserver)==null||e.disconnect(),this.resizeObserver=null,this.clearWheelIdleSnap(),this.clearWheelPointerEventsSuppression(),this.wheelGesture.reset(),this.detachDragListeners(),this.swipeGesture.status==="active"&&this.swipeGesture.cancel(),this.swipePointerId!==null&&this.releaseSwipePointerCapture(this.swipePointerId),this.endSwipeTracking(),this.dragController.removeEventListener("change",this.onDragControllerChange),this.dragController.removeEventListener("drag",this.onDragControllerDrag),this.dragController.removeEventListener("drop",this.onDragControllerDrop),this.layoutScroll.removeEventListener("layout-scroll",this.onLayoutScrollInternal),this.dragController.dispose(),this.stopDragFrameLoop(),this.resizeState&&this.endResize(this.resizeState.pointerId)}scheduleRender(){this.renderPending||(this.renderPending=!0,queueMicrotask(()=>{this.renderPending=!1,this.render()}))}createGrid(e,r){return new xz({basis:xe({x:In,y:In}),min:xe({x:zf,y:zf}),viewport:xe({x:e,y:r}),gap:xe({x:le,y:le})})}syncScrollModel(){const e=ru(this),i=gr(this._layout).nodes.map(o=>o.width),s=`${e.width}x${e.height}:${i.join(",")}`;s===this.scrollModelKey&&this.layoutGrid||(this.scrollModelKey=s,this.layoutGrid=this.createGrid(e.width,e.height),this.layoutScroll.rebuild({grid:this.layoutGrid,nodeWidths:i.map(o=>Ee({x:o})),snap:Og}))}emitScrollPositionChanged(e){this.dispatchEvent(new bO(e))}emitLayoutChanged(){this.dispatchEvent(new ew([...this._layout]))}shiftWindow(e){this.clearWheelIdleSnap(),this.syncScrollModel(),this.animateNextRender=!0,this.layoutScroll.step(e)}getHandoffHorizontalDelta(e){return e.shiftKey&&e.deltaY!==0?e.deltaY:Math.abs(e.deltaX)>=Tn?e.deltaX:this.filmstripWheelDirection*Math.abs(e.deltaY)}applyHorizontalWheel(e){const r=Math.sign(e);r!==0&&(this.filmstripWheelDirection=r),this.filmstripWheelHandoffUntil=Date.now()+zg,this.suppressArtifactPointerEventsDuringWheel(),this.syncScrollModel();const i=this.layoutGrid;if(!i)return;this.animateNextRender=!1;const s=i.toUnits(xe({x:e}));this.layoutScroll.wheel(Ee({x:s.x??0}))}suppressArtifactPointerEventsDuringWheel(){this.setAttribute("data-wheel-scrolling",""),this.wheelPointerEventsTimer&&clearTimeout(this.wheelPointerEventsTimer),this.wheelPointerEventsTimer=setTimeout(()=>{this.wheelPointerEventsTimer=null,this.removeAttribute("data-wheel-scrolling")},zg)}clearWheelPointerEventsSuppression(){this.wheelPointerEventsTimer&&(clearTimeout(this.wheelPointerEventsTimer),this.wheelPointerEventsTimer=null),this.removeAttribute("data-wheel-scrolling")}scheduleWheelIdleSnap(){this.clearWheelIdleSnap(),this.wheelIdleSnapTimer=setTimeout(()=>{this.wheelIdleSnapTimer=null,this.animateNextRender=!0,this.layoutScroll.snap()},yO)}clearWheelIdleSnap(){this.wheelIdleSnapTimer!==null&&(clearTimeout(this.wheelIdleSnapTimer),this.wheelIdleSnapTimer=null)}findViewspanContainingNode(e){const r=this.layoutScroll.viewspans,i=this._scrollPosition;let s=null,o=Number.POSITIVE_INFINITY;for(const a of r)if(e>=a.nodeRange[0]&&e<=a.nodeRange[1]){const c=Math.abs(a.anchor-i);c<o&&(o=c,s=a)}return s}findManagedArtifactFrame(e){if(!e)return null;const r=this.querySelectorAll("iframe.artifact-frame");for(const i of r)if(i.contentWindow===e)return i;return null}isTrustedArtifactFrameMessage(e,r){if(e.origin==="null")return!0;const i=this.getArtifactFrameOrigin(r);return i===null||e.origin===i}getArtifactFrameOrigin(e){const r=e.getAttribute("src")??e.src;if(!r)return null;try{return new URL(r,window.location.href).origin}catch{return null}}beginResize(e,r){const i=r.getAttribute("data-resize-handle");if(!i)return;const s=this._layout.find(a=>a.type==="card"&&a.id===i);if(!s)return;const o=ah(typeof s.width=="number"?s.width:Fe);this.resizeState={cardId:i,pointerId:e.pointerId,startClientX:e.clientX,startWidth:o,currentWidth:o},this.attachResizeListeners();try{this.setPointerCapture(e.pointerId)}catch{}e.preventDefault(),e.stopPropagation()}attachResizeListeners(){this.resizeListenersAttached||(window.addEventListener("pointermove",this.handleResizePointerMove),window.addEventListener("pointerup",this.handleResizePointerUp),window.addEventListener("pointercancel",this.handleResizePointerCancel),window.addEventListener("blur",this.handleResizeWindowBlur),this.addEventListener("keydown",this.handleResizeKeyDown),this.resizeListenersAttached=!0)}detachResizeListeners(){this.resizeListenersAttached&&(window.removeEventListener("pointermove",this.handleResizePointerMove),window.removeEventListener("pointerup",this.handleResizePointerUp),window.removeEventListener("pointercancel",this.handleResizePointerCancel),window.removeEventListener("blur",this.handleResizeWindowBlur),this.removeEventListener("keydown",this.handleResizeKeyDown),this.resizeListenersAttached=!1)}endResize(e){this.resizeState=null,this.detachResizeListeners();try{this.hasPointerCapture(e)&&this.releasePointerCapture(e)}catch{}}beginSwipeTracking(e){this.swipePointerId=e.pointerId,this.swipeStartX=e.clientX,this.swipeStartY=e.clientY,this.swipeLastX=e.clientX,this.swipeActive=!1,this.swipeShouldSuppressClick=!1,this.attachSwipeListeners()}attachSwipeListeners(){this.swipeListenersAttached||(window.addEventListener("pointermove",this.handleSwipePointerMove),window.addEventListener("pointerup",this.handleSwipePointerUp),window.addEventListener("pointercancel",this.handleSwipePointerCancel),this.addEventListener("pointermove",this.handleSwipePointerMove),this.addEventListener("pointerup",this.handleSwipePointerUp),this.addEventListener("pointercancel",this.handleSwipePointerCancel),window.addEventListener("blur",this.handleSwipeWindowBlur),this.addEventListener("click",this.handleSwipeClick,{capture:!0}),this.swipeListenersAttached=!0)}detachSwipeListeners(){this.swipeListenersAttached&&(window.removeEventListener("pointermove",this.handleSwipePointerMove),window.removeEventListener("pointerup",this.handleSwipePointerUp),window.removeEventListener("pointercancel",this.handleSwipePointerCancel),this.removeEventListener("pointermove",this.handleSwipePointerMove),this.removeEventListener("pointerup",this.handleSwipePointerUp),this.removeEventListener("pointercancel",this.handleSwipePointerCancel),window.removeEventListener("blur",this.handleSwipeWindowBlur),this.removeEventListener("click",this.handleSwipeClick,{capture:!0}),this.swipeListenersAttached=!1)}endSwipeTracking(){this.swipePointerId=null,this.swipeActive=!1,this.detachSwipeListeners()}releaseSwipePointerCapture(e){try{this.hasPointerCapture(e)&&this.releasePointerCapture(e)}catch{}}releaseActiveDragPointerCapture(){this.activeDragPointerId!==null&&this.releasePointerCaptureForEvent(this.activeDragPointerId)}releasePointerCaptureForEvent(e){try{this.hasPointerCapture(e)&&this.releasePointerCapture(e)}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)}getVisibleLayout(){return this.dragController.status!=="active"||!this.dragState?this.applyResizeOverride(this._layout):Tg(this.dragState.projectedLayout)}applyResizeOverride(e){const r=this.resizeState;if(!r)return e;const i=e.findIndex(a=>a.type==="card"&&a.id===r.cardId);if(i===-1)return e;const s=e[i];if(!s||s.type!=="card"||s.width===r.currentWidth)return e;const o=[...e];return o[i]={...s,width:r.currentWidth},o}getGridSlotStyle(e){return`grid-column: ${e.col} / span ${e.width}; grid-row: ${e.row} / span ${e.height};`}findContainingBlock(e){let r=e.parentElement;for(;r;){const i=getComputedStyle(r);if(i.transform!=="none"||i.perspective!=="none"||i.filter!=="none")return r;const s=i.willChange;if(s.includes("transform")||s.includes("perspective")||s.includes("filter"))return r;const o=i.contain;if(o.includes("layout")||o.includes("paint")||o.includes("strict"))return r;r=r.parentElement}return document.documentElement}getDraggedSlotStyle(e){const r=this.currentDragPreviewSize??{width:e.size.x??0,height:e.size.y??0};return["position: fixed;",`width: ${r.width}px;`,`height: ${r.height}px;`,"pointer-events: none;","z-index: 10;"].join(" ")}writeDraggedSlotPosition(e,r){(!this.draggedSlotContainingBlock||!this.draggedSlotContainingBlock.isConnected||!this.draggedSlotContainingBlock.contains(e))&&(this.draggedSlotContainingBlock=this.findContainingBlock(e));const i=this.draggedSlotContainingBlock.getBoundingClientRect(),s=r.pointer.x??0,o=r.pointer.y??0,a=r.grabOffset.x??0,c=r.grabOffset.y??0,u=this.currentDragPreviewSize??{width:r.size.x??0,height:r.size.y??0},h=r.size.x??0,p=r.size.y??0,v=h>0?a*(u.width/h):a,m=p>0?c*(u.height/p):c;e.style.left=`${s-v-i.left}px`,e.style.top=`${o-m-i.top}px`,e.style.width=`${u.width}px`,e.style.height=`${u.height}px`}renderSlot(e,r){var o,a;if(e.kind==="placeholder")return e.placement?z`
|
|
292
|
+
*/const Cg=(n,t,e)=>{const r=new Map;for(let i=t;i<=e;i++)r.set(n[i],i);return r},Rg=rc(class extends kd{constructor(n){if(super(n),n.type!==_d.CHILD)throw Error("repeat() can only be used in text expressions")}dt(n,t,e){let r;e===void 0?e=t:t!==void 0&&(r=t);const i=[],s=[];let o=0;for(const a of n)i[o]=r?r(a,o):o,s[o]=e(a,o),o++;return{values:s,keys:i}}render(n,t,e){return this.dt(n,t,e).values}update(n,[t,e,r]){const i=V2(n),{values:s,keys:o}=this.dt(t,e,r);if(!Array.isArray(i))return this.ut=o,s;const a=this.ut??(this.ut=[]),c=[];let u,h,p=0,v=i.length-1,m=0,_=s.length-1;for(;p<=v&&m<=_;)if(i[p]===null)p++;else if(i[v]===null)v--;else if(a[p]===o[m])c[m]=sr(i[p],s[m]),p++,m++;else if(a[v]===o[_])c[_]=sr(i[v],s[_]),v--,_--;else if(a[p]===o[_])c[_]=sr(i[p],s[_]),ms(n,c[_+1],i[p]),p++,_--;else if(a[v]===o[m])c[m]=sr(i[v],s[m]),ms(n,i[p],i[v]),v--,m++;else if(u===void 0&&(u=Cg(o,m,_),h=Cg(a,p,v)),u.has(a[p]))if(u.has(a[v])){const k=h.get(o[m]),T=k!==void 0?i[k]:null;if(T===null){const P=ms(n,i[p]);sr(P,s[m]),c[m]=P}else c[m]=sr(T,s[m]),ms(n,i[p],T),i[k]=null;m++}else eu(i[v]),v--;else eu(i[p]),p++;for(;m<=_;){const k=ms(n,c[_+1]);sr(k,s[m]),c[m++]=k}for(;p<=v;){const k=i[p++];k!==null&&eu(k)}return this.ut=o,Z2(n,c),Nr}}),Ee=n=>({type:"px",...n}),xe=n=>({type:"unit",...n}),ka=2;class zz{constructor(t){g(this,"basis");g(this,"min");g(this,"_gap");g(this,"_viewport");g(this,"_unit");this.basis=t.basis,this.min=t.min,this._viewport=t.viewport,this._gap=t.gap??Ee({x:le,y:le});const e=this._viewport.x??zr,r=this._viewport.y??cl,i=this._gap.x??le,s=this._gap.y??le,o=e<=s1,a=o?e-i*ka:Math.min(zr,e-i*ka),c=o?r-s*ka:Math.min(cl,r-s*ka),u=(a-i*(Fe-1))/Fe,h=(c-s*(ct-1))/ct,p=this.basis.x??0,v=this.basis.y??0,m=this.min.x??0,_=this.min.y??0;this._unit=Ee(o?{x:Math.max(m,u),y:Math.max(_,h)}:{x:Math.max(m,Math.min(p,u)),y:Math.max(_,Math.min(v,h))})}get unit(){return this._unit}get viewport(){return this._viewport}get gap(){return this._gap}toUnits(t){return xe({x:t.x==null?void 0:t.x/(this._unit.x??1),y:t.y==null?void 0:t.y/(this._unit.y??1)})}toPixels(t){const e=this._unit.x??0,r=this._unit.y??0,i=this._gap.x??le,s=this._gap.y??le,o=t.x==null?void 0:t.x*e+Math.max(0,t.x-1)*i,a=t.y==null?void 0:t.y*r+Math.max(0,t.y-1)*s;return Ee({x:o,y:a})}}const Ur=1e-4,$t=1e-6,Oz=40,Mz=24;function ew(n,t){return Math.max(0,n-t*2)}function tw(n){const t=[0];for(const e of n)t.push((t[t.length-1]??0)+e);return t}function nw(n){const t=[0];for(let e=0;e<n.length;e+=1){const r=t[e]??0;t.push(r+n[e]+le)}return t}function rw(n,t,e){if(t<0||t>=n.length)return 0;let r=0,i=0;for(let s=t;s<n.length;s+=1){const o=n[s],a=i===0?o:r+le+o;if(a>e+Ur)break;r=a,i+=1}return Math.max(1,i)}function Nz(n,t,e){if(t<0||t>=n.length)return 0;let r=0,i=0;for(let s=t;s>=0;s-=1){const o=n[s],a=i===0?o:r+le+o;if(a>e+Ur)break;r=a,i+=1}return Math.max(1,i)}function Uz(n,t){if(n.length===0)return 0;let e=0,r=0;for(let i=n.length-1;i>=0;i-=1){const s=n[i],o=r===0?s:e+le+s;if(o>t+Ur)break;e=o,r+=1}return Math.max(1,r)}function Ed(n,t){if(n.length===0)return 0;const e=Uz(n,t);return Math.max(0,n.length-e)}function Pg(n,t,e){if(n.length===0)return 0;const r=rw(n,t,e),i=Math.min(n.length,t+r);if(i<=t)return 0;const s=n.slice(t,i);return s.reduce((o,a)=>o+a,0)+Math.max(0,s.length-1)*le}function hh(n,t,e){const r=n[t]??0;return e-r}function di(n,t,e,r,i){if(n.length===0)return 0;const s=Ed(n,i),o=t[s]??0,a=Math.max(0,Math.min(o,e));let c=0;for(let F=0;F<s;F+=1){const Y=t[F]??0,j=t[F+1]??Y;if(a>=Y&&a<=j+Ur){c=F;break}c=F+1}const u=Math.min(c+1,s),h=t[c]??0,p=t[u]??h,v=Math.max(p-h,Ur),m=u===c?0:(a-h)/v,_=nw(n),k=Pg(n,c,i),T=Pg(n,u,i),P=(r-k)/2,R=(r-T)/2,W=hh(_,c,P),N=hh(_,u,R);return W+(N-W)*m}function Fz(n,t,e,r,i){const s=Ed(n,r),o=t[s]??0;let a=0,c=o;for(let u=0;u<Oz;u+=1){const h=(a+c)/2;di(n,t,h,e,r)>i?a=h:c=h}return(a+c)/2}function Hz(n,t,e){const r=nw(n),[i,s]=t,o=n.slice(i,s+1),a=o.reduce((u,h)=>u+h,0)+Math.max(0,o.length-1)*le,c=(e-a)/2;return hh(r,i,c)}function Wz(n,t,e){const r=rw(n,t,e);return[t,Math.min(n.length-1,t+r-1)]}function Zz(n,t,e){const r=Nz(n,t,e);return[Math.max(0,t-r+1),t]}function Vz(n,t){return n[0]===t[0]&&n[1]===t[1]}function Bz(n){const{nodeCols:t,nodeWidthsPx:e,viewportWidthPx:r}=n;if(t.length===0||e.length===0)return{viewspans:[],minScroll:0,maxScroll:0};const i=e.length,s=n.gapPx??le,o=ew(r,s),a=tw(t),c=Ed(e,o),u=a[c]??0;function h(T){const P=Hz(e,T,r),R=Fz(e,a,r,o,P);return{nodeRange:T,anchor:Math.max(0,Math.min(u,R))}}const p=[];for(let T=0;T<i;){const P=Wz(e,T,o);p.push(h(P)),T=P[1]+1}const v=h(Zz(e,i-1,o)),m=p.filter(T=>T.nodeRange[0]<v.nodeRange[0]),_=m[m.length-1];return{viewspans:_&&Vz(_.nodeRange,v.nodeRange)?m:[...m,v],minScroll:0,maxScroll:u}}function ri(n,t){var i;let e=0,r=Number.POSITIVE_INFINITY;for(let s=0;s<n.length;s+=1){const o=Math.abs((((i=n[s])==null?void 0:i.anchor)??0)-t);if(o+$t<r){r=o,e=s;continue}Math.abs(o-r)<=$t&&s<e&&(e=s)}return e}function jz(n,t,e){return e<=0?0:Math.max(0,Math.min(e-1,n+t))}function or(n,t,e){return Math.max(t,Math.min(e,n))}function Gz(n,t){var e;for(let r=0;r<n.length;r+=1)if(Math.abs((((e=n[r])==null?void 0:e.anchor)??0)-t)<=$t)return r;return-1}function qz(n,t,e){var i,s;if(n.length===0)return t;const r=Gz(n,t);if(r>=0){const o=n[r+e];return(o==null?void 0:o.anchor)??n[e>0?n.length-1:0].anchor}if(e>0){for(const o of n)if(o.anchor>t+$t)return o.anchor;return((i=n[n.length-1])==null?void 0:i.anchor)??t}for(let o=n.length-1;o>=0;o-=1){const a=n[o];if(a&&a.anchor<t-$t)return a.anchor}return((s=n[0])==null?void 0:s.anchor)??t}class Yz extends tn{constructor(e){super();g(this,"_scroll",0);g(this,"_minScroll",0);g(this,"_maxScroll",0);g(this,"_viewspans",[]);g(this,"_activeViewspanIndex",0);g(this,"_nodeWidthsPx",[]);g(this,"_boundaryCols",[0]);g(this,"_viewportWidthPx",0);g(this,"_framedViewportWidthPx",0);this._scroll=(e==null?void 0:e.x)??0}get scroll(){return xe({x:this._scroll})}get translate(){return Ee({x:di(this._nodeWidthsPx,this._boundaryCols,this._scroll,this._viewportWidthPx,this._framedViewportWidthPx)})}get activeViewspan(){return this._viewspans[this._activeViewspanIndex]??null}get viewspans(){return this._viewspans}set scroll(e){const r=or(e.x??this._scroll,this._minScroll,this._maxScroll);Math.abs(r-this._scroll)<=$t||(this._scroll=r,this._activeViewspanIndex=ri(this._viewspans,this._scroll),this.dispatchEvent(new ni("layout-scroll",{scroll:this.scroll})))}rebuild(e){var v;const r=e.nodeWidths.map(m=>Math.max(0,m.x??0)),i=r.map(m=>e.grid.toPixels(xe({x:m})).x??0),s=e.grid.viewport.x??0,o=e.grid.gap.x??le,a=Bz({nodeCols:r,nodeWidthsPx:i,viewportWidthPx:s,gapPx:o});this._nodeWidthsPx=i,this._boundaryCols=tw(r),this._viewportWidthPx=s,this._framedViewportWidthPx=ew(s,o),this._viewspans=a.viewspans,this._minScroll=a.minScroll,this._maxScroll=a.maxScroll;const c=or(this._scroll,this._minScroll,this._maxScroll);this._activeViewspanIndex=ri(this._viewspans,c);const h=e.snap!==!1?((v=this._viewspans[this._activeViewspanIndex])==null?void 0:v.anchor)??c:c,p=or(h,this._minScroll,this._maxScroll);Math.abs(p-this._scroll)>$t&&(this._scroll=p,this.dispatchEvent(new ni("layout-scroll",{scroll:this.scroll})))}step(e){var o;if(this._viewspans.length===0)return;const r=jz(this._activeViewspanIndex,e,this._viewspans.length),i=((o=this._viewspans[r])==null?void 0:o.anchor)??this._scroll,s=or(i,this._minScroll,this._maxScroll);this._activeViewspanIndex=r,!(Math.abs(s-this._scroll)<=$t)&&(this._scroll=s,this.dispatchEvent(new ni("layout-scroll",{scroll:this.scroll})))}snap(e){var s;if(this._viewspans.length===0)return;const r=e===void 0?((s=this._viewspans[ri(this._viewspans,this._scroll)])==null?void 0:s.anchor)??this._scroll:qz(this._viewspans,this._scroll,e),i=or(r,this._minScroll,this._maxScroll);this._activeViewspanIndex=ri(this._viewspans,i),!(Math.abs(i-this._scroll)<=$t)&&(this._scroll=i,this.dispatchEvent(new ni("layout-scroll",{scroll:this.scroll})))}wheel(e){const r=or(this._scroll+(e.x??0),this._minScroll,this._maxScroll);Math.abs(r-this._scroll)<=$t||(this._scroll=r,this._activeViewspanIndex=ri(this._viewspans,this._scroll),this.dispatchEvent(new ni("layout-scroll",{scroll:this.scroll})))}wheelPixels(e){const r=e.x??0;if(Math.abs(r)<=Ur)return;const i=di(this._nodeWidthsPx,this._boundaryCols,this._scroll,this._viewportWidthPx,this._framedViewportWidthPx),s=i-r,o=di(this._nodeWidthsPx,this._boundaryCols,this._maxScroll,this._viewportWidthPx,this._framedViewportWidthPx),a=di(this._nodeWidthsPx,this._boundaryCols,this._minScroll,this._viewportWidthPx,this._framedViewportWidthPx),c=Math.max(o,Math.min(a,s));if(Math.abs(c-i)<=Ur)return;let u=this._minScroll,h=this._maxScroll;for(let v=0;v<Mz;v+=1){const m=(u+h)/2;di(this._nodeWidthsPx,this._boundaryCols,m,this._viewportWidthPx,this._framedViewportWidthPx)>c?u=m:h=m}const p=or((u+h)/2,this._minScroll,this._maxScroll);Math.abs(p-this._scroll)<=$t||(this._scroll=p,this._activeViewspanIndex=ri(this._viewspans,this._scroll),this.dispatchEvent(new ni("layout-scroll",{scroll:this.scroll})))}}const iu={"stack-above":{left:.25,top:0,width:.5,height:.5},"stack-below":{left:.25,top:.5,width:.5,height:.5},"reorder-before":{left:0,top:0,width:.25,height:1},"reorder-after":{left:.75,top:0,width:.25,height:1}},Xz=["stack-above","stack-below","reorder-before","reorder-after"];function su(n,t){return{left:n.left+n.width*t.left,top:n.top+n.height*t.top,width:n.width*t.width,height:n.height*t.height}}function ar(n,t,e){return n>=e.left&&n<e.left+e.width&&t>=e.top&&t<e.top+e.height}function dh(n){return Number.isFinite(n)?Math.max(Hs,Math.min(ad,Math.round(n))):Hs}function Kz(n,t,e){const r=n.findIndex(a=>a.type==="card"&&a.id===t);if(r===-1)return n;const i=n[r];if(!i||i.type!=="card")return n;const s=dh(e);if(i.width===s)return n;const o=[...n];return o[r]={...i,width:s},o}function iw(n,t){for(const e of n){if(e.type==="card"&&e.id===t)return e;if(e.type==="stack")for(const r of e.children){if(r.type==="card"&&r.id===t)return r;if(r.type==="row"){for(const i of r.children)if(i.id===t)return i}}}return null}function ph(n){const t=n.height===ct||n.height===Bn?Bn:n.height;return n.width===Fe&&n.height===t?n:{...n,width:Fe,height:t}}function fh(n){return n.height===Bn?{...n,height:ct}:n}function Jz(n,t,e,r){const i=n.findIndex(h=>h.type==="stack"&&h.id===t);if(i===-1)return n;const s=n[i];if(!s||s.type!=="stack")return n;const o=s.children.find(h=>h.type==="card"&&h.id===e);if(!o||o.type!=="card")return n;const a=s.children.filter(h=>h.id!==e);if(a.length===s.children.length||a.length<1)return n;const c=[...n];if(a.length===1){const[h]=a;c[i]=h.type==="card"?fh(h):h}else c[i]={...s,children:a};const u=Math.max(0,Math.min(r,c.length));return c.splice(u,0,fh(o)),c}const Qz=He(),eO=He(),tO=50;function nO(n,t){if(n.type!==t.type)return!1;switch(n.type){case"reorder":return t.index===n.index;case"stack":return t.targetCardId===n.targetCardId&&t.position===n.position;case"stack-child-noop":return!0;case"stack-child-extract":return t.toIndex===n.toIndex;case"stack-child-reorder":return t.position===n.position;default:return!1}}function Qo(n){return{id:n.id,type:"drop-target",width:n.width,height:n.height}}function Dg(n){return n.map(iO)}function rO(n){return n.type==="drop-target"?{id:n.id,type:"card",artifactID:n.id,width:n.width,height:n.height}:n}function iO(n){return n.type==="drop-target"?{id:n.id,type:"card",artifactID:n.id,width:n.width,height:n.height}:n.type==="stack"?{...n,children:n.children.map(rO)}:n}function sw(n,t){return n.find(r=>r.type==="card"&&r.id===t)??null}function Lg(n,t){return n.find(r=>r.type==="stack"&&r.id===t)??null}function sO(n,t){const e=[...t],r=e.findIndex(a=>a.type==="card"&&a.id===n.nodeId);if(r===-1)return null;const i=e[r];if(!i||i.type!=="card")return null;e.splice(r,1);const s=Math.max(0,Math.min(n.lastReorderIndex,e.length));e.splice(s,0,i);const o=e.findIndex(a=>a.type==="card"&&a.id===n.nodeId);return o===-1?null:{base:e,visualDraggedIndex:o}}function oO(n,t,e,r){const i=[...n.base];i.splice(n.visualDraggedIndex,1);const s=i.findIndex(v=>v.type==="card"&&v.id===e.targetCardId),o=s===-1?null:i[s];if(!o||o.type!=="card")return null;const a=sw(r,t.nodeId);if(!a)return null;const c=ph(a),u=ph(o),h=Qo(c),p=e.position==="above"?[h,u]:[u,h];return i[s]={id:o.id,type:"stack",children:p},i}function ou(n,t){return n.parentStackId?lO(n,t):aO(n,t)}function aO(n,t){const e=n.hitTarget;if(e.type==="reorder"){const r=t[n.sourceIndex];if(!r||r.type!=="card")return[...t];const i=[...t];return i.splice(n.sourceIndex,1),i.splice(e.index,0,Qo(r)),i}if(e.type==="stack"){const r=sO(n,t);return r?oO(r,n,e,t)??[...t]:[...t]}return[...t]}function lO(n,t){const e=n.hitTarget;switch(e.type){case"stack-child-reorder":return cO(n,t,e.position);case"stack-child-extract":return uO(n,t,e.toIndex);case"stack-child-noop":return hO(n,t);default:return[...t]}}function cO(n,t,e){const r=t.findIndex(v=>v.type==="stack"&&v.id===n.parentStackId);if(r===-1)return[...t];const i=t[r];if(!i||i.type!=="stack")return[...t];if(!i.children.every(v=>v.type==="card"))return[...t];const s=i.children,o=s.findIndex(v=>v.id===n.nodeId);if(o===-1)return[...t];const a=s[o],c=s.filter(v=>v.id!==n.nodeId),u=Qo(a),h=e==="above"?[u,...c]:[...c,u],p=[...t];return p[r]={...i,children:h},p}function uO(n,t,e){if(!n.parentStackId)return[...t];const r=Jz(t,n.parentStackId,n.nodeId,e);if(r===t)return[...t];const i=r.findIndex(a=>a.type==="card"&&a.id===n.nodeId);if(i===-1)return[...t];const s=r[i];if(!s||s.type!=="card")return[...t];const o=[...r];return o[i]=Qo(s),o}function hO(n,t){const e=t.findIndex(c=>c.type==="stack"&&c.id===n.parentStackId);if(e===-1)return[...t];const r=t[e];if(!r||r.type!=="stack")return[...t];const i=r.children.findIndex(c=>c.type==="card"&&c.id===n.nodeId);if(i===-1)return[...t];const s=r.children[i];if(!s||s.type!=="card")return[...t];const o=[...t],a=[...r.children];return a[i]=Qo(s),o[e]={...r,children:a},o}function dO(n,t){return t.find(r=>r.type==="stack"&&r.id===n.id)?n.id:jl()}function pO(n,t,e){if(n.type==="drop-target"){const r=iw(t,e);if(!r)throw new Error(`finalize: missing dragged card ${e}`);return ph(r)}return n}function fO(n,t,e){const r=n.children.map(s=>pO(s,t,e));return{id:dO(n,t),type:"stack",children:r}}function gO(n,t,e){if(n.type==="drop-target"){const r=iw(t,e);if(!r)throw new Error(`finalize: missing dragged card ${e}`);return sw(t,e)!==null?r:fh(r)}return n.type==="card"||n.type==="row"?n:fO(n,t,e)}function mO(n,t,e){return n.map(r=>gO(r,t,e))}function vO(n,t){return JSON.stringify(n)===JSON.stringify(t)}const yO=Ko(tn);class bO extends yO{constructor(e={}){super();g(this,"pending",null);g(this,"active",null)}start(e){if(this.pending||this.active)return;const r=e.pointer.x??0,i=e.pointer.y??0;this.pending={startX:r,startY:i,grabOffsetX:e.grabOffset.x??0,grabOffsetY:e.grabOffset.y??0,nodeId:e.nodeId,sourceIndex:e.source.index,parentStackId:e.source.parentId,width:e.size.x??0,height:e.size.y??0,baseLayout:e.layout}}update(e){const r=e.pointer.x??0,i=e.pointer.y??0,s=this.pending;if(s){const u=r-s.startX,h=i-s.startY;Math.hypot(u,h)>=a1&&(this.pending=null,this.active={...s,pointerX:r,pointerY:i,hitTarget:{type:"reorder",index:s.sourceIndex},lastReorderIndex:s.sourceIndex},this.emitDrag(),this.dispatchEvent(new ae("change")));return}if(!this.active)return;const o=ou(this.active,this.active.baseLayout),a=this.getHitTargetForPointer(r,i,e,o),c=a.type==="reorder"?a.index:this.active.lastReorderIndex;this.active.pointerX===r&&this.active.pointerY===i&&nO(this.active.hitTarget,a)&&this.active.lastReorderIndex===c||(this.active={...this.active,pointerX:r,pointerY:i,hitTarget:a,lastReorderIndex:c},this.emitDrag(),this.dispatchEvent(new ae("change")))}drop(){if(this.pending){this.cancel();return}if(!this.active)return;const e=this.active.baseLayout;let r=null;try{const i=ou(this.active,e),s=mO(i,e,this.active.nodeId);vO(s,e)||(r=s)}catch{r=null}this.reset(),r&&this.dispatchEvent(new eO("drop",{layout:r})),this.dispatchEvent(new ae("change"))}cancel(){!this.pending&&!this.active||(this.reset(),this.dispatchEvent(new ae("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 e=ou(this.active,this.active.baseLayout);this.dispatchEvent(new Qz("drag",{nodeId:this.active.nodeId,source:{index:this.active.sourceIndex,parentId:this.active.parentStackId},grabOffset:Ee({x:this.active.grabOffsetX,y:this.active.grabOffsetY}),pointer:Ee({x:this.active.pointerX,y:this.active.pointerY}),size:Ee({x:this.active.width,y:this.active.height}),projectedLayout:e}))}getHitTargetForPointer(e,r,i,s){return this.active?this.isPointerInsideDragBounds(e,r,i.viewport)?this.active.parentStackId?this.getStackChildHitTarget(e,r,i,s):this.getTopLevelCardHitTarget(e,r,i,s):{type:"reorder",index:this.active.sourceIndex}:{type:"reorder",index:0}}getStackChildHitTarget(e,r,i,s){var u;if(!((u=this.active)!=null&&u.parentStackId))return{type:"stack-child-noop"};const o=this.getSourceStackInteractionRect(i.geometry);if(o&&ar(e,r,o)){const h=o.top+o.height/2;return{type:"stack-child-reorder",position:r<h?"above":"below"}}const a=this.getSourceRemainingSiblingRect(i.geometry);if(a&&ar(e,r,a)){const h=a.top+a.height/2;return{type:"stack-child-reorder",position:r<h?"above":"below"}}return{type:"stack-child-extract",toIndex:this.getTopLevelReorderIndexForPointer(e,r,i,s)}}getSourceRemainingSiblingRect(e){var s,o;if(!((s=this.active)!=null&&s.parentStackId))return;const r=Lg(this.active.baseLayout,this.active.parentStackId);if(!r)return;const i=r.children.find(a=>{var c;return a.type==="card"&&a.id!==((c=this.active)==null?void 0:c.nodeId)});if(i)return(o=e.find(a=>a.id===i.id))==null?void 0:o.rect}getSourceStackInteractionRect(e){var o;if(!((o=this.active)!=null&&o.parentStackId))return;const r=e.find(a=>{var c;return a.id===((c=this.active)==null?void 0:c.parentStackId)});if(r)return this.active.sourceStackRect=r.rect,r.rect;const i=Lg(this.active.baseLayout,this.active.parentStackId);if(!i)return this.active.sourceStackRect;const s=i.children.find(a=>{var c;return a.type==="card"&&a.id!==((c=this.active)==null?void 0:c.nodeId)});if(s){const a=e.find(c=>c.id===s.id);if(a)return a.rect}return this.active.sourceStackRect}getTopLevelCardHitTarget(e,r,i,s){var m,_,k;const o=this.getTopLevelZoneNodes(i.geometry,s);if(o.length===0)return{type:"reorder",index:((m=this.active)==null?void 0:m.sourceIndex)??0};const c=(i.effectiveVelocity??0)<=tO;for(const T of o){const P=T.rect;if(!ar(e,r,P))continue;const R=this.resolveTopLevelTargetForCard(e,r,T,T.logicalIndex,c);if(R)return R;if(!c&&((_=this.active)!=null&&_.hitTarget))return this.active.hitTarget.type==="reorder"?this.active.hitTarget:this.active.hitTarget.type==="stack"&&this.active.hitTarget.targetCardId===T.id?this.active.hitTarget:{type:"reorder",index:e<this.active.pointerX?T.logicalIndex:T.logicalIndex+1}}const u=this.getNearestTargetableZone(e,o);if(!u)return{type:"reorder",index:((k=this.active)==null?void 0:k.sourceIndex)??0};const h=Math.max(u.rect.left,Math.min(u.rect.left+u.rect.width,e)),p=this.resolveTopLevelTargetForCard(h,r,u,u.logicalIndex,c);if(p)return p;const v=u.rect.left+u.rect.width/2;return{type:"reorder",index:e<v?u.logicalIndex:u.logicalIndex+1}}getTopLevelReorderIndexForPointer(e,r,i,s){var u,h;const o=this.getTopLevelZoneNodes(i.geometry,s);if(o.length===0)return((u=this.active)==null?void 0:u.sourceIndex)??0;for(const p of o){if(!ar(e,r,p.rect))continue;const v=su(p.rect,iu["reorder-before"]);if(ar(e,r,v))return p.logicalIndex;const m=su(p.rect,iu["reorder-after"]);if(ar(e,r,m))return p.logicalIndex+1}const a=this.getNearestTargetableZone(e,o);if(!a)return((h=this.active)==null?void 0:h.sourceIndex)??0;const c=a.rect.left+a.rect.width/2;return e<c?a.logicalIndex:a.logicalIndex+1}getTopLevelZoneNodes(e,r){const i=new Map(r.map(a=>[a.id,a])),s=[];let o=0;for(const a of e){const c=i.get(a.id);c&&c.type!=="drop-target"&&(c.type==="card"||c.type==="stack")&&(s.push({id:c.id,rect:a.rect,logicalIndex:o}),o+=1)}return s}resolveTopLevelTargetForCard(e,r,i,s,o){const a=i.rect;for(const c of Xz){if(!o&&(c==="stack-above"||c==="stack-below"))continue;const u=iu[c],h=su(a,u);if(ar(e,r,h))return c==="stack-above"?{type:"stack",targetCardId:i.id,position:"above"}:c==="stack-below"?{type:"stack",targetCardId:i.id,position:"below"}:c==="reorder-before"?{type:"reorder",index:s}:{type:"reorder",index:s+1}}return null}getNearestTargetableZone(e,r){let i=null,s=Number.POSITIVE_INFINITY;for(const o of r){const a=o.rect.left,c=o.rect.left+o.rect.width,u=e<a?a-e:e>c?e-c:0;u<s&&(s=u,i=o)}return i}isPointerInsideDragBounds(e,r,i){return e>=i.left&&e<=i.left+i.width&&r>=i.top&&r<=i.top+i.height}}const zg=60,wO=80,Og=.5,Mg=10;class SO{constructor(){g(this,"awaitingFreshWheelGesture",!1);g(this,"lastWheelEventAt",Number.NEGATIVE_INFINITY);g(this,"lastWheelDeltaX",0);g(this,"activeGestureType","none");g(this,"lastWheelGestureAt",Number.NEGATIVE_INFINITY)}markKeyboardNavigation(t){this.awaitingFreshWheelGesture=!0,this.lastWheelEventAt=t,this.activeGestureType="none"}reset(){this.awaitingFreshWheelGesture=!1,this.lastWheelEventAt=Number.NEGATIVE_INFINITY,this.lastWheelDeltaX=0,this.activeGestureType="none",this.lastWheelGestureAt=Number.NEGATIVE_INFINITY}decide(t){const{now:e,shiftKey:r,deltaX:i,deltaY:s,overArtifactContent:o}=t;e-this.lastWheelGestureAt>=zg&&(this.activeGestureType="none");const c=r&&s!==0,u=c?s:i,h=Math.abs(u),p=Math.abs(s);return this.activeGestureType==="vertical-artifact"&&o?h>=Og&&h>=p*Mg?this.classifyHorizontal(e,u):(this.lastWheelGestureAt=e,{type:"scroll-native"}):this.activeGestureType==="horizontal-filmstrip"?!c&&o&&p>0&&p>=h*Mg?(this.activeGestureType="vertical-artifact",this.lastWheelGestureAt=e,{type:"scroll-native"}):this.classifyHorizontal(e,u):h<Og?(o&&(this.activeGestureType="vertical-artifact"),this.lastWheelGestureAt=e,{type:"scroll-native"}):c||h>p?this.classifyHorizontal(e,u):p>h?(o&&(this.activeGestureType="vertical-artifact"),this.lastWheelGestureAt=e,{type:"scroll-native"}):o?(this.activeGestureType="vertical-artifact",this.lastWheelGestureAt=e,{type:"scroll-native"}):this.classifyHorizontal(e,u)}classifyHorizontal(t,e){const r=t-this.lastWheelEventAt,i=Math.sign(this.lastWheelDeltaX),s=Math.sign(e),o=i!==0&&s!==0&&i!==s,a=i!==0&&Math.abs(e)>=Math.abs(this.lastWheelDeltaX)+wO;return this.awaitingFreshWheelGesture&&r<zg&&!o&&!a?{type:"ignore"}:(this.lastWheelEventAt=t,this.lastWheelDeltaX=e,this.lastWheelGestureAt=t,this.awaitingFreshWheelGesture=!1,this.activeGestureType="horizontal-filmstrip",{type:"scroll-horizontal",horizontalDelta:e})}}const _O=100,kO=1e3;class xO{constructor(t,e){g(this,"_status","idle");g(this,"cumulativeOffset",0);g(this,"samples",[]);g(this,"scroll");g(this,"setAnimating");this.scroll=t,this.setAnimating=e}get status(){return this._status}start(t){this._status="active",this.cumulativeOffset=0,this.samples=[{time:t,offset:0}]}move(t,e){this._status==="active"&&(this.cumulativeOffset+=e,this.samples.push({time:t,offset:this.cumulativeOffset}),this.pruneSamples(t),this.setAnimating(!1),this.scroll.wheelPixels(Ee({x:-e})))}end(){if(this._status!=="active")return;const t=this.computeVelocityPxPerSec();this.setAnimating(!0),Math.abs(t)<c1?this.scroll.snap():this.scroll.snap(t>0?-1:1),this.reset()}cancel(){this._status==="active"&&(this.setAnimating(!0),this.scroll.snap(),this.reset())}reset(){this._status="idle",this.cumulativeOffset=0,this.samples=[]}pruneSamples(t){const e=t-_O;let r=0;for(let i=0;i<this.samples.length;i+=1){if(this.samples[i].time>=e){r=i;break}r=i+1}if(r>0){const i=Math.max(0,r-1);this.samples=this.samples.slice(i)}}computeVelocityPxPerSec(){if(this.samples.length<2)return 0;const t=this.samples[0],e=this.samples[this.samples.length-1],r=e.time-t.time;return r<=0?0:(e.offset-t.offset)/r*kO}}function EO({baseLayout:n,visibleLayout:t,resolved:e,cardsByID:r,grid:i,dragState:s,isForeground:o}){var _;const a=new Map(t.map(k=>[k.id,k])),c=e.nodes.map((k,T)=>{const P=a.get(k.id),R=[];for(const N of k.cards){if(s&&N.id===s.nodeId){R.push({key:`placeholder:${N.id}`,kind:"placeholder",card:null,placement:N,isTopLevelCard:!1,isDragged:!1,sourceStackId:s.source.parentId??null});continue}const F=r.get(N.id);F&&R.push({key:F.id,kind:"card",card:F,placement:N,isTopLevelCard:(P==null?void 0:P.type)==="card",isDragged:!1,sourceStackId:null})}if(s!=null&&s.source.parentId&&k.id===s.source.parentId){const N=r.get(s.nodeId);if(N){const F={key:N.id,kind:"card",card:N,placement:null,isTopLevelCard:!1,isDragged:!0,sourceStackId:s.source.parentId},Y=AO(n,s.source.parentId,s.nodeId),j=Y<0?R.length:Math.min(Y,R.length);R.splice(j,0,F)}}const W=!!(s&&(P==null?void 0:P.type)==="card"&&P.id===s.nodeId&&P.artifactID===s.nodeId);return{key:W?`placeholder:${k.id}`:k.id,kind:"visible",nodeId:k.id,widthPx:i.toPixels(xe({x:k.width})).x??0,widthUnits:k.width,layoutIndex:T,isForeground:o(T),isPlaceholder:W,slots:R}});if(!s||s.source.parentId&&a.has(s.source.parentId))return c;const u=r.get(s.nodeId);if(!u)return c;const h=s.source.parentId??s.nodeId,p=((_=gr(n).nodes[s.source.index])==null?void 0:_.width)??Fe,v={key:h,kind:"ghost",nodeId:h,widthPx:0,widthUnits:p,layoutIndex:null,isForeground:!1,isPlaceholder:!1,slots:[{key:u.id,kind:"card",card:u,placement:null,isTopLevelCard:!s.source.parentId,isDragged:!0,sourceStackId:s.source.parentId??null}]},m=Math.max(0,Math.min(s.source.index,c.length));return c.splice(m,0,v),c}function Ng(n){if(!n)return null;const t=n.projectedLayout,e=n.source.parentId;for(const i of t){if(i.type!=="stack")continue;const s=i.children.findIndex(u=>u.type==="drop-target");if(s===-1)continue;const o=s===0?"above":"below";if(e&&e===i.id)return`stack-child-reorder:${o}`;const a=i.children.find(u=>u.type!=="drop-target");return`stack:${(a==null?void 0:a.type)==="card"?a.artifactID:(a==null?void 0:a.id)??""}:${o}`}const r=t.findIndex(i=>i.type==="drop-target");return r===-1?"none":e?`stack-child-extract:${r}`:`reorder:${r}`}function AO(n,t,e){const r=n.find(i=>i.type==="stack"&&i.id===t);return!r||r.type!=="stack"?-1:r.children.findIndex(i=>i.type==="card"&&i.id===e)}const $O=2,Ug=1e3,Tn=1e-4,TO=120,Fg=300,Hg=!1;function Wg(n){return n.replace(/["\\]/g,"\\$&")}function Zg(n,t,e){if(n===0)return 0;const r=t.toPixels(xe({y:ct})).y??0;return(e-r)/$O}function au(n){const t=n.clientWidth>0?n.clientWidth:zr,e=n.clientHeight>0?n.clientHeight:cl;let r=0,i=0;if(n.isConnected){const o=getComputedStyle(n);r=parseFloat(o.paddingTop)||0,i=parseFloat(o.paddingBottom)||0}const s=Math.max(1,e-r-i);return{width:t,height:s,offsetY:r}}class IO extends Event{constructor(e){super("scroll",{bubbles:!0,composed:!0});g(this,"scrollPosition");this.scrollPosition=e}}class ow extends Event{constructor(e){super("layout-change",{bubbles:!0,composed:!0});g(this,"layout");this.layout=e}}class CO extends HTMLElement{constructor(){super();g(this,"_layout",[]);g(this,"_scrollPosition",0);g(this,"layoutGrid",null);g(this,"layoutScroll",new Yz(xe({x:0})));g(this,"scrollModelKey","");g(this,"resizeObserver",null);g(this,"renderPending",!1);g(this,"animateNextRender",!0);g(this,"wheelGesture",new SO);g(this,"filmstripWheelHandoffUntil",0);g(this,"filmstripWheelDirection",0);g(this,"swipeGesture",new xO(this.layoutScroll,e=>{this.animateNextRender=e}));g(this,"swipePointerId",null);g(this,"swipeStartX",0);g(this,"swipeStartY",0);g(this,"swipeLastX",0);g(this,"swipeActive",!1);g(this,"swipeShouldSuppressClick",!1);g(this,"swipeListenersAttached",!1);g(this,"wheelIdleSnapTimer",null);g(this,"wheelPointerEventsTimer",null);g(this,"dragController",new bO);g(this,"dragState",null);g(this,"activeDragPointerId",null);g(this,"dragListenersAttached",!1);g(this,"dragFrame",0);g(this,"lastDragFrameTime",0);g(this,"lastPointerX",0);g(this,"lastPointerY",0);g(this,"pointerVelocityPxPerSec",0);g(this,"scrollVelocityPxPerSec",0);g(this,"motionSampleTime",0);g(this,"motionSampleX",0);g(this,"motionSampleY",0);g(this,"lastDragControllerStatus","idle");g(this,"lastProjectedDragLayoutSignature","");g(this,"lastDragDropIntent",null);g(this,"lastActivePlaceholderId",null);g(this,"draggedSlotElement",null);g(this,"draggedSlotContainingBlock",null);g(this,"currentDragPreviewSize",null);g(this,"dragTrackOffsetXPx",0);g(this,"previousProjectedLayoutForOffset",null);g(this,"resizeState",null);g(this,"resizeListenersAttached",!1);g(this,"_cards",new Map);g(this,"onDragControllerChange",()=>{const e=this.dragController.status;e!==this.lastDragControllerStatus&&(this.lastDragControllerStatus=e,e==="idle"&&(this.dragState=null,this.resetDragPreviewState()),this.scheduleRender())});g(this,"onDragControllerDrag",e=>{var c;const r=JSON.stringify(e.projectedLayout),i=Ng(e),s=PO(e.projectedLayout);if(r!==this.lastProjectedDragLayoutSignature||i!==this.lastDragDropIntent||s!==this.lastActivePlaceholderId){const u=Dg(e.projectedLayout),h=this.shouldApplyTrackOffset(e.projectedLayout,e.source.parentId),p=e.source.parentId?this.getStackChildAnchorCardId(e.source.parentId,e.nodeId):null;this.dragTrackOffsetXPx=h?this.computeDragTrackOffset(this.previousProjectedLayoutForOffset,u,e.nodeId,e.source.parentId,p,this.dragTrackOffsetXPx):0,this.previousProjectedLayoutForOffset=u,this.lastProjectedDragLayoutSignature=r,this.lastDragDropIntent=i,this.lastActivePlaceholderId=s,this.dragState={nodeId:e.nodeId,source:e.source,grabOffset:e.grabOffset,pointer:e.pointer,size:e.size,projectedLayout:e.projectedLayout},this.scheduleRender();return}this.dragState={nodeId:e.nodeId,source:e.source,grabOffset:e.grabOffset,pointer:e.pointer,size:e.size,projectedLayout:((c=this.dragState)==null?void 0:c.projectedLayout)??e.projectedLayout};const a=this.getCachedDraggedSlotElement(e.nodeId);a&&this.writeDraggedSlotPosition(a,this.dragState)});g(this,"onDragControllerDrop",e=>{this.dragState=null,this.resetDragPreviewState(),this.commitLayout(e.layout)});g(this,"onLayoutScrollInternal",e=>{const i=e.scroll.x??0;Math.abs(i-this._scrollPosition)<Tn||(this._scrollPosition=i,this.emitScrollPositionChanged(i),this.scheduleRender())});g(this,"handleKeyDown",e=>{if(e.key==="Escape"&&this.dragController.status!=="idle"){e.preventDefault(),this.stopDragFrameLoop(),this.releaseActiveDragPointerCapture(),this.dragController.cancel(),this.detachDragListeners();return}this.dragController.status==="idle"&&(e.key==="ArrowRight"?(e.preventDefault(),this.wheelGesture.markKeyboardNavigation(Date.now()),this.shiftWindow(1)):e.key==="ArrowLeft"&&(e.preventDefault(),this.wheelGesture.markKeyboardNavigation(Date.now()),this.shiftWindow(-1)))});g(this,"handleWindowWheelHandoff",e=>{if(this._layout.length===0||Date.now()>this.filmstripWheelHandoffUntil||this.contains(e.target))return;const r=this.getHandoffHorizontalDelta(e);Math.abs(r)<Tn||(e.preventDefault(),e.stopPropagation(),this.applyHorizontalWheel(r))});g(this,"handleWheel",e=>{if(this._layout.length===0)return;const r=Date.now(),i=r<=this.filmstripWheelHandoffUntil,s=this.wheelGesture.decide({now:r,shiftKey:e.shiftKey,deltaX:e.deltaX,deltaY:e.deltaY,overArtifactContent:!1});if(s.type!=="scroll-horizontal"&&!i)return;const o=s.type==="scroll-horizontal"?s.horizontalDelta:0,a=Math.abs(o)>=Tn?o:i?this.getHandoffHorizontalDelta(e):0;Math.abs(a)<Tn||(e.preventDefault(),this.applyHorizontalWheel(a))});g(this,"handleWindowMessage",e=>{if(this._layout.length===0)return;const r=this.findManagedArtifactFrame(e.source);if(r&&this.isTrustedArtifactFrameMessage(e,r)){if(bz(e.data)){const i=typeof performance<"u"?performance.now():Date.now();this.swipeGesture.status==="idle"&&this.swipeGesture.start(i),this.swipeGesture.move(i,e.data.deltaX);return}if(wz(e.data)){this.swipeGesture.status==="active"&&this.swipeGesture.end();return}}});g(this,"handleArtifactWheel",e=>{if(this._layout.length===0)return;const r=this.wheelGesture.decide({now:Date.now(),shiftKey:e.shiftKey,deltaX:e.deltaX,deltaY:e.deltaY,overArtifactContent:!0});if(r.type==="scroll-horizontal"){this.applyHorizontalWheel(r.horizontalDelta);return}r.type==="scroll-native"&&e.scrollNative(e.deltaY)});g(this,"handlePointerDown",e=>{if(e.button!==0||this.dragController.status!=="idle"||this.resizeState)return;const r=e.target;if(!(r instanceof Element))return;const i=r.closest("[data-resize-handle]");if(i){this.beginResize(e,i);return}const s=r.closest("[drag-handle]")!==null,o=r.closest("button, input, textarea, select, a, [role='button']")!==null;if(e.pointerType==="touch"&&!s&&!o&&this._layout.length>0){this.beginSwipeTracking(e);return}if(!s){if(!o){const p=r.closest(".node");if(p&&!p.hasAttribute("data-foreground")){const v=p.getAttribute("layout-node");if(v!==null){const m=parseInt(v,10);if(!isNaN(m)){const _=this.findViewspanContainingNode(m);if(_){this.clearWheelIdleSnap(),this.animateNextRender=!0,this.layoutScroll.scroll=xe({x:_.anchor}),e.preventDefault(),e.stopPropagation();return}}}}}return}if(o)return;const a=r.closest(".card-slot");if(!a)return;const c=a.getAttribute("data-layout-node-id");if(!c)return;const u=DO(this._layout,c);if(!u)return;const h=a.getBoundingClientRect();this.lastPointerX=e.clientX,this.lastPointerY=e.clientY,this.resetMotionTracking(e.clientX,e.clientY),this.focus(),this.dragController.start({nodeId:c,source:{index:u.topLevelIndex,parentId:u.sourceStackId},pointer:Ee({x:e.clientX,y:e.clientY}),grabOffset:Ee({x:e.clientX-h.left,y:e.clientY-h.top}),size:Ee({x:h.width,y:h.height}),layout:this._layout}),this.attachDragListeners(),this.activeDragPointerId=e.pointerId;try{this.setPointerCapture(e.pointerId)}catch{}e.preventDefault()});g(this,"handleResizePointerMove",e=>{const r=this.resizeState;if(!r||e.pointerId!==r.pointerId)return;const i=this.layoutGrid,s=((i==null?void 0:i.unit.x)??In)+le;if(s<=0)return;const o=e.clientX-r.startClientX,a=dh(r.startWidth+o/s);a!==r.currentWidth&&(r.currentWidth=a,this.scheduleRender())});g(this,"handleResizePointerUp",e=>{const r=this.resizeState;if(!r||e.pointerId!==r.pointerId)return;const i=r.currentWidth,s=r.startWidth,o=r.cardId;this.endResize(e.pointerId),i!==s?this.commitLayout(Kz(this._layout,o,i)):this.scheduleRender()});g(this,"handleResizePointerCancel",e=>{!this.resizeState||e.pointerId!==this.resizeState.pointerId||(this.endResize(e.pointerId),this.scheduleRender())});g(this,"handleResizeWindowBlur",()=>{this.resizeState&&(this.endResize(this.resizeState.pointerId),this.scheduleRender())});g(this,"handleResizeKeyDown",e=>{this.resizeState&&e.key==="Escape"&&(e.preventDefault(),this.endResize(this.resizeState.pointerId),this.scheduleRender())});g(this,"handleSwipePointerMove",e=>{if(this.swipePointerId===null||e.pointerId!==this.swipePointerId)return;if(!this.swipeActive){const i=e.clientX-this.swipeStartX,s=e.clientY-this.swipeStartY,o=Math.abs(i),a=Math.abs(s);if(o<Wf&&a<Wf)return;if(a>=o){this.endSwipeTracking();return}this.swipeActive=!0,this.swipeShouldSuppressClick=!0;try{this.setPointerCapture(e.pointerId)}catch{}this.swipeGesture.start(e.timeStamp)}const r=e.clientX-this.swipeLastX;this.swipeLastX=e.clientX,this.swipeGesture.move(e.timeStamp,r),e.preventDefault()});g(this,"handleSwipePointerUp",e=>{this.swipePointerId===null||e.pointerId!==this.swipePointerId||(this.swipeActive&&this.swipeGesture.end(),this.releaseSwipePointerCapture(e.pointerId),this.endSwipeTracking())});g(this,"handleSwipePointerCancel",e=>{this.swipePointerId===null||e.pointerId!==this.swipePointerId||(this.swipeActive&&this.swipeGesture.cancel(),this.releaseSwipePointerCapture(e.pointerId),this.endSwipeTracking())});g(this,"handleSwipeWindowBlur",()=>{this.swipePointerId!==null&&this.swipeActive&&this.swipeGesture.cancel(),this.swipePointerId!==null&&this.releaseSwipePointerCapture(this.swipePointerId),this.endSwipeTracking()});g(this,"handleSwipeClick",e=>{this.swipeShouldSuppressClick&&(this.swipeShouldSuppressClick=!1,e.preventDefault(),e.stopPropagation(),typeof e.stopImmediatePropagation=="function"&&e.stopImmediatePropagation())});g(this,"handleWindowPointerMove",e=>{this.activeDragPointerId!==null&&e.pointerId!==this.activeDragPointerId||(this.lastPointerX=e.clientX,this.lastPointerY=e.clientY,this.updatePointerVelocity(e.clientX,e.clientY),this.syncDragTargetForLatestPointer(),this.ensureDragFrameLoop())});g(this,"handleWindowPointerUp",e=>{this.activeDragPointerId!==null&&e.pointerId!==this.activeDragPointerId||(this.stopDragFrameLoop(),this.releasePointerCaptureForEvent(e.pointerId),this.dragController.drop(),this.clearMotionTracking(),this.detachDragListeners())});g(this,"handleWindowPointerCancel",e=>{if(!(this.activeDragPointerId!==null&&e.pointerId!==this.activeDragPointerId)){if(this.dragController.status==="active"){this.ensureDragFrameLoop();return}this.stopDragFrameLoop(),this.releasePointerCaptureForEvent(e.pointerId),this.dragController.cancel(),this.clearMotionTracking(),this.detachDragListeners()}});g(this,"handleWindowBlur",()=>{this.releaseActiveDragPointerCapture(),this.stopDragFrameLoop(),this.dragController.cancel(),this.clearMotionTracking(),this.detachDragListeners()});g(this,"runDragFrame",e=>{if(this.dragController.status==="idle"){this.dragFrame=0;return}const r=Math.max(0,e-this.lastDragFrameTime)/Ug;this.lastDragFrameTime=e,this.samplePointerVelocityAt(e,this.lastPointerX,this.lastPointerY);const i=this.getBoundingClientRect(),s=this.clampPointerToViewport(this.lastPointerX,this.lastPointerY,i),o=this.getDragEdgeScrollDeltaPixels(s.x,i,r);this.scrollVelocityPxPerSec=r>Tn?Math.abs(o)/r:0,Math.abs(o)>Tn&&(this.animateNextRender=!1,this.layoutScroll.wheelPixels(Ee({x:o}))),this.dragController.status==="active"&&this.syncDragTarget(s.x,s.y,i),this.dragFrame=requestAnimationFrame(this.runDragFrame)});this.dragController.addEventListener("change",this.onDragControllerChange),this.dragController.addEventListener("drag",this.onDragControllerDrag),this.dragController.addEventListener("drop",this.onDragControllerDrop),this.layoutScroll.addEventListener("layout-scroll",this.onLayoutScrollInternal)}set cards(e){this._cards!==e&&(this._cards=e,this.scheduleRender())}get cards(){return this._cards}set layout(e){const r=[...e];this.dragController.status!=="idle"&&JSON.stringify(r)===JSON.stringify(this._layout)||(this._layout=r,this.stopDragFrameLoop(),this.dragController.cancel(),this.resizeState&&this.endResize(this.resizeState.pointerId),this.scrollModelKey="",this.syncScrollModel(),this.layoutScroll.scroll=xe({x:this._scrollPosition}),this.scheduleRender())}get layout(){return this._layout}commitLayout(e){this.layout=e,this.emitLayoutChanged()}set scrollPosition(e){Math.abs(e-this._scrollPosition)<Tn||(this.animateNextRender=!1,this.syncScrollModel(),this.layoutScroll.scroll=xe({x:e}))}get scrollPosition(){return this._scrollPosition}focusArtifact(e){const r=gr(this._layout),i=r.nodes.findIndex(o=>o.cards.some(a=>a.artifactID===e));if(i<0)return;let s=0;for(let o=0;o<i;o+=1)s+=r.nodes[o].width;this.scrollPosition=s,queueMicrotask(()=>{const o=this.querySelector(`.card-slot[data-layout-card-id="${Wg(e)}"]`);if(!o)return;o.classList.remove("card-focus-pulse"),o.offsetHeight,o.classList.add("card-focus-pulse");const a=()=>{o.classList.remove("card-focus-pulse"),o.removeEventListener("animationend",a)};o.addEventListener("animationend",a)})}connectedCallback(){this.hasAttribute("tabindex")||(this.tabIndex=0),this.focus(),this.addEventListener("keydown",this.handleKeyDown),this.addEventListener("wheel",this.handleWheel,{passive:!1}),this.addEventListener("pointerdown",this.handlePointerDown),this.addEventListener("artifact-wheel",this.handleArtifactWheel),window.addEventListener("wheel",this.handleWindowWheelHandoff,{capture:!0,passive:!1}),window.addEventListener("message",this.handleWindowMessage),typeof ResizeObserver<"u"&&(this.resizeObserver=new ResizeObserver(()=>this.render()),this.resizeObserver.observe(this)),this.render()}disconnectedCallback(){var e;this.removeEventListener("keydown",this.handleKeyDown),this.removeEventListener("wheel",this.handleWheel),this.removeEventListener("pointerdown",this.handlePointerDown),this.removeEventListener("artifact-wheel",this.handleArtifactWheel),window.removeEventListener("wheel",this.handleWindowWheelHandoff,{capture:!0}),window.removeEventListener("message",this.handleWindowMessage),(e=this.resizeObserver)==null||e.disconnect(),this.resizeObserver=null,this.clearWheelIdleSnap(),this.clearWheelPointerEventsSuppression(),this.wheelGesture.reset(),this.detachDragListeners(),this.swipeGesture.status==="active"&&this.swipeGesture.cancel(),this.swipePointerId!==null&&this.releaseSwipePointerCapture(this.swipePointerId),this.endSwipeTracking(),this.dragController.removeEventListener("change",this.onDragControllerChange),this.dragController.removeEventListener("drag",this.onDragControllerDrag),this.dragController.removeEventListener("drop",this.onDragControllerDrop),this.layoutScroll.removeEventListener("layout-scroll",this.onLayoutScrollInternal),this.dragController.dispose(),this.stopDragFrameLoop(),this.resizeState&&this.endResize(this.resizeState.pointerId)}scheduleRender(){this.renderPending||(this.renderPending=!0,queueMicrotask(()=>{this.renderPending=!1,this.render()}))}createGrid(e,r){return new zz({basis:Ee({x:In,y:In}),min:Ee({x:Ff,y:Ff}),viewport:Ee({x:e,y:r}),gap:Ee({x:le,y:le})})}syncScrollModel(){const e=au(this),i=gr(this._layout).nodes.map(o=>o.width),s=`${e.width}x${e.height}:${i.join(",")}`;s===this.scrollModelKey&&this.layoutGrid||(this.scrollModelKey=s,this.layoutGrid=this.createGrid(e.width,e.height),this.layoutScroll.rebuild({grid:this.layoutGrid,nodeWidths:i.map(o=>xe({x:o})),snap:Hg}))}emitScrollPositionChanged(e){this.dispatchEvent(new IO(e))}emitLayoutChanged(){this.dispatchEvent(new ow([...this._layout]))}shiftWindow(e){this.clearWheelIdleSnap(),this.syncScrollModel(),this.animateNextRender=!0,this.layoutScroll.step(e)}getHandoffHorizontalDelta(e){return e.shiftKey&&e.deltaY!==0?e.deltaY:Math.abs(e.deltaX)>=Tn?e.deltaX:this.filmstripWheelDirection*Math.abs(e.deltaY)}applyHorizontalWheel(e){const r=Math.sign(e);r!==0&&(this.filmstripWheelDirection=r),this.filmstripWheelHandoffUntil=Date.now()+Fg,this.suppressArtifactPointerEventsDuringWheel(),this.syncScrollModel();const i=this.layoutGrid;if(!i)return;this.animateNextRender=!1;const s=i.toUnits(Ee({x:e}));this.layoutScroll.wheel(xe({x:s.x??0}))}suppressArtifactPointerEventsDuringWheel(){this.setAttribute("data-wheel-scrolling",""),this.wheelPointerEventsTimer&&clearTimeout(this.wheelPointerEventsTimer),this.wheelPointerEventsTimer=setTimeout(()=>{this.wheelPointerEventsTimer=null,this.removeAttribute("data-wheel-scrolling")},Fg)}clearWheelPointerEventsSuppression(){this.wheelPointerEventsTimer&&(clearTimeout(this.wheelPointerEventsTimer),this.wheelPointerEventsTimer=null),this.removeAttribute("data-wheel-scrolling")}scheduleWheelIdleSnap(){this.clearWheelIdleSnap(),this.wheelIdleSnapTimer=setTimeout(()=>{this.wheelIdleSnapTimer=null,this.animateNextRender=!0,this.layoutScroll.snap()},TO)}clearWheelIdleSnap(){this.wheelIdleSnapTimer!==null&&(clearTimeout(this.wheelIdleSnapTimer),this.wheelIdleSnapTimer=null)}findViewspanContainingNode(e){const r=this.layoutScroll.viewspans,i=this._scrollPosition;let s=null,o=Number.POSITIVE_INFINITY;for(const a of r)if(e>=a.nodeRange[0]&&e<=a.nodeRange[1]){const c=Math.abs(a.anchor-i);c<o&&(o=c,s=a)}return s}findManagedArtifactFrame(e){if(!e)return null;const r=this.querySelectorAll("iframe.artifact-frame");for(const i of r)if(i.contentWindow===e)return i;return null}isTrustedArtifactFrameMessage(e,r){if(e.origin==="null")return!0;const i=this.getArtifactFrameOrigin(r);return i===null||e.origin===i}getArtifactFrameOrigin(e){const r=e.getAttribute("src")??e.src;if(!r)return null;try{return new URL(r,window.location.href).origin}catch{return null}}beginResize(e,r){const i=r.getAttribute("data-resize-handle");if(!i)return;const s=this._layout.find(a=>a.type==="card"&&a.id===i);if(!s)return;const o=dh(typeof s.width=="number"?s.width:Fe);this.resizeState={cardId:i,pointerId:e.pointerId,startClientX:e.clientX,startWidth:o,currentWidth:o},this.attachResizeListeners();try{this.setPointerCapture(e.pointerId)}catch{}e.preventDefault(),e.stopPropagation()}attachResizeListeners(){this.resizeListenersAttached||(window.addEventListener("pointermove",this.handleResizePointerMove),window.addEventListener("pointerup",this.handleResizePointerUp),window.addEventListener("pointercancel",this.handleResizePointerCancel),window.addEventListener("blur",this.handleResizeWindowBlur),this.addEventListener("keydown",this.handleResizeKeyDown),this.resizeListenersAttached=!0)}detachResizeListeners(){this.resizeListenersAttached&&(window.removeEventListener("pointermove",this.handleResizePointerMove),window.removeEventListener("pointerup",this.handleResizePointerUp),window.removeEventListener("pointercancel",this.handleResizePointerCancel),window.removeEventListener("blur",this.handleResizeWindowBlur),this.removeEventListener("keydown",this.handleResizeKeyDown),this.resizeListenersAttached=!1)}endResize(e){this.resizeState=null,this.detachResizeListeners();try{this.hasPointerCapture(e)&&this.releasePointerCapture(e)}catch{}}beginSwipeTracking(e){this.swipePointerId=e.pointerId,this.swipeStartX=e.clientX,this.swipeStartY=e.clientY,this.swipeLastX=e.clientX,this.swipeActive=!1,this.swipeShouldSuppressClick=!1,this.attachSwipeListeners()}attachSwipeListeners(){this.swipeListenersAttached||(window.addEventListener("pointermove",this.handleSwipePointerMove),window.addEventListener("pointerup",this.handleSwipePointerUp),window.addEventListener("pointercancel",this.handleSwipePointerCancel),this.addEventListener("pointermove",this.handleSwipePointerMove),this.addEventListener("pointerup",this.handleSwipePointerUp),this.addEventListener("pointercancel",this.handleSwipePointerCancel),window.addEventListener("blur",this.handleSwipeWindowBlur),this.addEventListener("click",this.handleSwipeClick,{capture:!0}),this.swipeListenersAttached=!0)}detachSwipeListeners(){this.swipeListenersAttached&&(window.removeEventListener("pointermove",this.handleSwipePointerMove),window.removeEventListener("pointerup",this.handleSwipePointerUp),window.removeEventListener("pointercancel",this.handleSwipePointerCancel),this.removeEventListener("pointermove",this.handleSwipePointerMove),this.removeEventListener("pointerup",this.handleSwipePointerUp),this.removeEventListener("pointercancel",this.handleSwipePointerCancel),window.removeEventListener("blur",this.handleSwipeWindowBlur),this.removeEventListener("click",this.handleSwipeClick,{capture:!0}),this.swipeListenersAttached=!1)}endSwipeTracking(){this.swipePointerId=null,this.swipeActive=!1,this.detachSwipeListeners()}releaseSwipePointerCapture(e){try{this.hasPointerCapture(e)&&this.releasePointerCapture(e)}catch{}}releaseActiveDragPointerCapture(){this.activeDragPointerId!==null&&this.releasePointerCaptureForEvent(this.activeDragPointerId)}releasePointerCaptureForEvent(e){try{this.hasPointerCapture(e)&&this.releasePointerCapture(e)}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)}getVisibleLayout(){return this.dragController.status!=="active"||!this.dragState?this.applyResizeOverride(this._layout):Dg(this.dragState.projectedLayout)}applyResizeOverride(e){const r=this.resizeState;if(!r)return e;const i=e.findIndex(a=>a.type==="card"&&a.id===r.cardId);if(i===-1)return e;const s=e[i];if(!s||s.type!=="card"||s.width===r.currentWidth)return e;const o=[...e];return o[i]={...s,width:r.currentWidth},o}getGridSlotStyle(e){return`grid-column: ${e.col} / span ${e.width}; grid-row: ${e.row} / span ${e.height};`}findContainingBlock(e){let r=e.parentElement;for(;r;){const i=getComputedStyle(r);if(i.transform!=="none"||i.perspective!=="none"||i.filter!=="none")return r;const s=i.willChange;if(s.includes("transform")||s.includes("perspective")||s.includes("filter"))return r;const o=i.contain;if(o.includes("layout")||o.includes("paint")||o.includes("strict"))return r;r=r.parentElement}return document.documentElement}getDraggedSlotStyle(e){const r=this.currentDragPreviewSize??{width:e.size.x??0,height:e.size.y??0};return["position: fixed;",`width: ${r.width}px;`,`height: ${r.height}px;`,"pointer-events: none;","z-index: 10;"].join(" ")}writeDraggedSlotPosition(e,r){(!this.draggedSlotContainingBlock||!this.draggedSlotContainingBlock.isConnected||!this.draggedSlotContainingBlock.contains(e))&&(this.draggedSlotContainingBlock=this.findContainingBlock(e));const i=this.draggedSlotContainingBlock.getBoundingClientRect(),s=r.pointer.x??0,o=r.pointer.y??0,a=r.grabOffset.x??0,c=r.grabOffset.y??0,u=this.currentDragPreviewSize??{width:r.size.x??0,height:r.size.y??0},h=r.size.x??0,p=r.size.y??0,v=h>0?a*(u.width/h):a,m=p>0?c*(u.height/p):c;e.style.left=`${s-v-i.left}px`,e.style.top=`${o-m-i.top}px`,e.style.width=`${u.width}px`,e.style.height=`${u.height}px`}renderSlot(e,r){var o,a;if(e.kind==="placeholder")return e.placement?z`
|
|
191
293
|
<div
|
|
192
294
|
class="card-slot card-placeholder"
|
|
193
295
|
data-layout-placeholder-for=${(r==null?void 0:r.nodeId)??""}
|
|
@@ -223,14 +325,14 @@ ${r.documentElement.outerHTML}`],{type:wz});return URL.createObjectURL(o)}const
|
|
|
223
325
|
style=${e.kind==="visible"?`width: ${e.widthPx}px; --card-width-px: ${e.widthPx};`:""}
|
|
224
326
|
>
|
|
225
327
|
<div class="node-inner" style=${`grid-template-columns: repeat(${e.widthUnits}, var(--layout-unit-x));`}>
|
|
226
|
-
${
|
|
328
|
+
${Rg(e.slots,i=>i.key,i=>this.renderSlot(i,r))}
|
|
227
329
|
</div>
|
|
228
330
|
</div>
|
|
229
|
-
`}render(){var Y;const e=
|
|
331
|
+
`}render(){var Y;const e=au(this),r=this.createGrid(e.width,e.height);this.layoutGrid=r;const i=this.getVisibleLayout(),s=this.dragController.status==="active",o=gr(i),a=o.nodes.map(j=>j.width),c=`${e.width}x${e.height}:${a.join(",")}`;!s&&c!==this.scrollModelKey&&(this.scrollModelKey=c,this.layoutScroll.rebuild({grid:r,nodeWidths:a.map(j=>xe({x:j})),snap:Hg}),this._scrollPosition=this.layoutScroll.scroll.x??this._scrollPosition);const u=RO(this._layout),h=r.unit.x??In,p=r.unit.y??In,v=s?this.dragTrackOffsetXPx:0,m=(this.layoutScroll.translate.x??0)+v,_=Zg(o.nodes.length,r,e.height),k=this.animateNextRender&&!s,T=[`transform: translate(${m}px, ${_}px);`,`transition-duration: ${k?o1:0}ms;`,`pointer-events: ${s?"none":"auto"};`].join(" ");this.animateNextRender=!0,this.style.setProperty("--layout-unit-x",`${h}px`),this.style.setProperty("--layout-unit-y",`${p}px`),this.style.setProperty("--layout-gap",`${le}px`);const P=this.dragState,R=new Set;{let j=m;for(let oe=0;oe<o.nodes.length;oe+=1){const wt=r.toPixels(xe({x:o.nodes[oe].width})).x??0,er=j+wt;j>=-1&&er<=e.width+1&&R.add(oe),j=er+le}}const W=j=>R.has(j),N=EO({baseLayout:this._layout,visibleLayout:i,resolved:o,cardsByID:u,grid:r,dragState:this.dragState,isForeground:W}),F=Ng(this.dragState);if(F?this.setAttribute("data-test-drop-intent",F):this.removeAttribute("data-test-drop-intent"),this.dragState){let j=null;for(const oe of o.nodes){for(const wt of oe.cards)if(wt.id===this.dragState.nodeId){j={width:r.toPixels(xe({x:wt.width})).x??0,height:r.toPixels(xe({y:wt.height})).y??0};break}if(j)break}this.currentDragPreviewSize=j??{width:this.dragState.size.x??0,height:this.dragState.size.y??0}}else this.currentDragPreviewSize=null;Ce(z`
|
|
230
332
|
<div class="track" style=${T}>
|
|
231
|
-
${
|
|
333
|
+
${Rg(N,j=>j.key,j=>this.renderNode(j,P))}
|
|
232
334
|
</div>
|
|
233
|
-
`,this),this.syncCardElements(u,P?((Y=u.get(P.nodeId))==null?void 0:Y.artifactID)??null:null),this.syncDraggedSlotElement(P)}syncCardElements(e,r){var o;const i=new Map;for(const a of this.querySelectorAll(".card-content-mount[data-mount-for]")){const c=a.getAttribute("data-mount-for");c&&i.set(c,a)}const s=new Set;for(const a of e.values()){const c=this._cards.get(a.artifactID);if(!c)continue;s.add(a.artifactID);const u=i.get(a.id);if(!u){c.removeAttribute("data-dragging");continue}const h=(o=u.parentElement)==null?void 0:o.getAttribute("data-layout-node-id");console.assert(h===a.id,`layout-view: mount mismatch for ${a.id}`),c.parentElement!==u&&u.appendChild(c),console.assert(u.children.length<=1,`layout-view: multiple children for ${a.id}`),c.toggleAttribute("data-dragging",a.artifactID===r)}for(const[a,c]of this._cards)s.has(a)||c.removeAttribute("data-dragging")}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 e=this.getBoundingClientRect();if(this.dragController.status==="active"){const i=this.clampPointerToViewport(this.lastPointerX,this.lastPointerY,e);this.syncDragTarget(i.x,i.y,e);return}if(this.syncDragTarget(this.lastPointerX,this.lastPointerY,e),this.dragController.status==="pending")return;const r=this.clampPointerToViewport(this.lastPointerX,this.lastPointerY,e);(r.x!==this.lastPointerX||r.y!==this.lastPointerY)&&this.syncDragTarget(r.x,r.y,e)}syncDragTarget(e,r,i=this.getBoundingClientRect()){if(this.dragController.status==="idle")return;const s=this.getVisibleLayout(),o=this.dragController.status==="active"?this.dragTrackOffsetXPx:0,a=this.measureLayoutGeometry(s,o);this.dragController.update({pointer:
|
|
335
|
+
`,this),this.syncCardElements(u,P?((Y=u.get(P.nodeId))==null?void 0:Y.artifactID)??null:null),this.syncDraggedSlotElement(P)}syncCardElements(e,r){var o;const i=new Map;for(const a of this.querySelectorAll(".card-content-mount[data-mount-for]")){const c=a.getAttribute("data-mount-for");c&&i.set(c,a)}const s=new Set;for(const a of e.values()){const c=this._cards.get(a.artifactID);if(!c)continue;s.add(a.artifactID);const u=i.get(a.id);if(!u){c.removeAttribute("data-dragging");continue}const h=(o=u.parentElement)==null?void 0:o.getAttribute("data-layout-node-id");console.assert(h===a.id,`layout-view: mount mismatch for ${a.id}`),c.parentElement!==u&&u.appendChild(c),console.assert(u.children.length<=1,`layout-view: multiple children for ${a.id}`),c.toggleAttribute("data-dragging",a.artifactID===r)}for(const[a,c]of this._cards)s.has(a)||c.removeAttribute("data-dragging")}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 e=this.getBoundingClientRect();if(this.dragController.status==="active"){const i=this.clampPointerToViewport(this.lastPointerX,this.lastPointerY,e);this.syncDragTarget(i.x,i.y,e);return}if(this.syncDragTarget(this.lastPointerX,this.lastPointerY,e),this.dragController.status==="pending")return;const r=this.clampPointerToViewport(this.lastPointerX,this.lastPointerY,e);(r.x!==this.lastPointerX||r.y!==this.lastPointerY)&&this.syncDragTarget(r.x,r.y,e)}syncDragTarget(e,r,i=this.getBoundingClientRect()){if(this.dragController.status==="idle")return;const s=this.getVisibleLayout(),o=this.dragController.status==="active"?this.dragTrackOffsetXPx:0,a=this.measureLayoutGeometry(s,o);this.dragController.update({pointer:Ee({x:e,y:r}),viewport:{left:i.left,top:i.top,width:i.width,height:i.height},geometry:a,effectiveVelocity:Math.max(this.pointerVelocityPxPerSec,this.scrollVelocityPxPerSec)})}resetMotionTracking(e,r){this.pointerVelocityPxPerSec=0,this.scrollVelocityPxPerSec=0,this.motionSampleTime=performance.now(),this.motionSampleX=e,this.motionSampleY=r}clearMotionTracking(){this.pointerVelocityPxPerSec=0,this.scrollVelocityPxPerSec=0,this.motionSampleTime=0}updatePointerVelocity(e,r){this.samplePointerVelocityAt(performance.now(),e,r)}samplePointerVelocityAt(e,r,i){if(this.motionSampleTime===0){this.motionSampleTime=e,this.motionSampleX=r,this.motionSampleY=i,this.pointerVelocityPxPerSec=0;return}const s=e-this.motionSampleTime;if(s<100)return;const o=r-this.motionSampleX;this.pointerVelocityPxPerSec=Math.abs(o)/s*Ug,this.motionSampleTime=e,this.motionSampleX=r,this.motionSampleY=i}clampPointerToViewport(e,r,i){return{x:Math.max(i.left,Math.min(i.left+i.width,e)),y:Math.max(i.top,Math.min(i.top+i.height,r))}}getDragEdgeScrollDeltaPixels(e,r,i){var u;const s=r.left+ya,o=r.left+r.width-ya,a=((u=this.layoutGrid)==null?void 0:u.unit.x)??In,c=l1*a;if(e<s){const h=Math.max(0,Math.min(1,(s-e)/ya));return-(c*h**Hf)*i}if(e>o){const h=Math.max(0,Math.min(1,(e-o)/ya));return c*h**Hf*i}return 0}measureLayoutGeometry(e,r=0){const i=this.layoutGrid;if(!i)return[];const s=gr(e),o=new Map(s.nodes.map(_=>[_.id,_.width])),a=i.toPixels(xe({y:ct})).y??cl,c=au(this),u=(this.layoutScroll.translate.x??0)+r,h=Zg(s.nodes.length,i,c.height),p=c.offsetY+h,v=[];let m=u;for(const _ of e){const k=o.get(_.id)??Fe,T=i.toPixels(xe({x:k})).x??zr,P={left:m,top:p,width:T,height:a};v.push({id:_.id,rect:P}),m+=T+le}return v}resetDragPreviewState(){this.dragTrackOffsetXPx=0,this.previousProjectedLayoutForOffset=null,this.lastProjectedDragLayoutSignature="",this.lastDragDropIntent=null,this.lastActivePlaceholderId=null,this.draggedSlotElement=null,this.draggedSlotContainingBlock=null,this.currentDragPreviewSize=null}getCachedDraggedSlotElement(e){var r;return(r=this.draggedSlotElement)!=null&&r.isConnected&&this.draggedSlotElement.getAttribute("data-layout-node-id")===e&&this.draggedSlotElement.getAttribute("data-layout-drag-source")==="true"?this.draggedSlotElement:(this.draggedSlotElement=this.querySelector(`.card-slot[data-layout-node-id="${Wg(e)}"][data-layout-drag-source="true"]`),this.draggedSlotElement)}syncDraggedSlotElement(e){if(!e||this.dragController.status!=="active"){this.draggedSlotElement=null;return}const r=this.getCachedDraggedSlotElement(e.nodeId);r&&this.writeDraggedSlotPosition(r,e)}shouldApplyTrackOffset(e,r){if(r)return!0;for(const i of e){if(i.type!=="stack")continue;if(i.children.some(o=>o.type==="drop-target")&&r!==i.id)return!0}return!1}computeDragTrackOffset(e,r,i,s,o,a){if(!e)return a;const c=s?o??this.getStableAnchorCardId(e,r,i):this.getStableAnchorNodeId(e,r,i);if(!c)return a;const u=s?Bg(e,c,this.layoutGrid):jg(e,c,this.layoutGrid),h=s?Bg(r,c,this.layoutGrid):jg(r,c,this.layoutGrid);return u===null||h===null?a:a+(u-h)}getStableAnchorCardId(e,r,i){const s=Vg(e),o=new Set(Vg(r));for(const a of s)if(a!==i&&o.has(a))return a;return null}getStableAnchorNodeId(e,r,i){const s=new Set(r.map(o=>o.id));for(const o of e)if(o.id!==i&&s.has(o.id))return o.id;return null}getStackChildAnchorCardId(e,r){const i=this._layout.find(o=>o.type==="stack"&&o.id===e);if(!i||i.type!=="stack")return null;const s=i.children.find(o=>o.type==="card"&&o.id!==r);return(s==null?void 0:s.id)??null}}function RO(n){const t=new Map;for(const e of n){if(e.type==="card"){t.set(e.id,e);continue}for(const r of e.children)if(r.type==="card")t.set(r.id,r);else for(const i of r.children)t.set(i.id,i)}return t}function PO(n){for(const t of n)if(t.type==="drop-target"||t.type==="stack"&&t.children.some(e=>e.type==="drop-target"))return t.id;return null}function DO(n,t){const e=n.findIndex(r=>r.type==="card"&&r.id===t);if(e!==-1)return{topLevelIndex:e};for(let r=0;r<n.length;r+=1){const i=n[r];if(!(!i||i.type!=="stack")&&i.children.some(s=>s.type==="card"&&s.id===t))return{topLevelIndex:r,sourceStackId:i.id}}return null}function Vg(n){const t=[];for(const e of n){if(e.type==="card"){t.push(e.id);continue}if(e.type==="stack"){const r=e.children.find(i=>i.type==="card");r&&t.push(r.id)}}return t}function Bg(n,t,e){if(!e)return null;const r=gr(n),i=new Map(r.nodes.map(o=>[o.id,o.width]));let s=0;for(const o of n){if(o.type==="card"&&o.id===t||o.type==="stack"&&o.children.some(u=>u.type==="card"&&u.id===t))return s;const a=i.get(o.id)??Fe,c=e.toPixels(xe({x:a})).x??zr;s+=c+le}return null}function jg(n,t,e){if(!e)return null;const r=gr(n),i=new Map(r.nodes.map(o=>[o.id,o.width]));let s=0;for(const o of n){if(o.id===t)return s;const a=i.get(o.id)??Fe,c=e.toPixels(xe({x:a})).x??zr;s+=c+le}return null}customElements.get("layout-view")||customElements.define("layout-view",CO);class LO extends HTMLElement{constructor(){super(...arguments);g(this,"screenManager",en.resolve("ScreenManager"));g(this,"boundModel",null);g(this,"cardEls",new Map);g(this,"handleActiveScreenChanged",()=>{this.rebindModel(),this.render()});g(this,"handleModelChange",()=>{this.render()});g(this,"handleCloseArtifact",e=>{e instanceof Qb&&this.screenManager.activeScreen&&this.screenManager.activeScreen.removeArtifact(e.artifactID)});g(this,"handleScrollPositionChanged",e=>{const r=e;typeof r.scrollPosition=="number"&&Number.isFinite(r.scrollPosition)&&this.screenManager.activeScreen&&this.screenManager.activeScreen.setScrollPosition(r.scrollPosition)});g(this,"handleLayoutChanged",e=>{e instanceof ow&&this.screenManager.activeScreen&&this.screenManager.activeScreen.setLayout(e.layout)});g(this,"handleServerEvent",e=>{const r=e.event;if(r.type!=="artifact-focus"||!this.boundModel||r.screenID!==this.boundModel.id)return;const i=this.querySelector("layout-view");i&&i.focusArtifact(r.artifactID)})}connectedCallback(){this.screenManager.addEventListener("active-screen-changed",this.handleActiveScreenChanged),this.rebindModel(),this.render()}disconnectedCallback(){this.screenManager.removeEventListener("active-screen-changed",this.handleActiveScreenChanged),this.unbindModel(),this.disposeCardElements()}rebindModel(){const e=this.screenManager.activeScreen;this.boundModel!==e&&(this.unbindModel(),this.boundModel=e,e&&(e.addEventListener("change",this.handleModelChange),e.server.addEventListener("server-event",this.handleServerEvent)))}unbindModel(){this.boundModel&&(this.boundModel.removeEventListener("change",this.handleModelChange),this.boundModel.server.removeEventListener("server-event",this.handleServerEvent),this.boundModel=null)}buildCards(e){if(!e)return this.disposeCardElements(),new Map;const r=new Map;for(const i of e.artifacts.values()){let s=this.cardEls.get(i.id);s||(s=document.createElement("artifact-view"),this.cardEls.set(i.id,s)),s.artifact=i,s.screen=e,s.viewURL=e.server.getViewURL(i),s.contentURL=e.server.getContentURL(i),r.set(i.id,s)}for(const[i,s]of this.cardEls)r.has(i)||(s.remove(),this.cardEls.delete(i));return r}disposeCardElements(){for(const e of this.cardEls.values())e.remove();this.cardEls.clear()}render(){const e=this.screenManager.activeScreen,r=(e==null?void 0:e.layout)??[],i=this.buildCards(e);if(r.length===0){Ce(z``,this);return}Ce(z`
|
|
234
336
|
<layout-view
|
|
235
337
|
.layout=${r}
|
|
236
338
|
.cards=${i}
|
|
@@ -239,33 +341,33 @@ ${r.documentElement.outerHTML}`],{type:wz});return URL.createObjectURL(o)}const
|
|
|
239
341
|
@layout-change=${this.handleLayoutChanged}
|
|
240
342
|
@close-artifact=${this.handleCloseArtifact}
|
|
241
343
|
></layout-view>
|
|
242
|
-
`,this)}}customElements.define("screen-view",
|
|
243
|
-
${f(this,Z,
|
|
344
|
+
`,this)}}customElements.define("screen-view",LO);function yl(n){return typeof n=="object"&&n!==null}const lu=new WeakMap,Gg=Object.prototype.hasOwnProperty,zO=(()=>{const n=new Set;let t=HTMLElement.prototype;for(;t;){for(const e of Object.getOwnPropertyNames(t))n.add(e);if(t===Node.prototype)break;t=Object.getPrototypeOf(t)}return n})();function OO(n,t){if(yl(n))return t===null?void 0:n.parse(t);if(n===Boolean)return t!==null;if(t!==null)return n===Number?Number(t):t}function MO(n,t){return yl(n)?t==null?null:n.serialize(t):n===Boolean?t?"":null:t==null?null:String(t)}var Io,gh,Ir,ut,qt,zi,Cr,Oi,we,pi,aw,lw,cw,uw,qa;const dr=class dr extends HTMLElement{constructor(){var i;super();w(this,we);w(this,Ir,new Map);w(this,ut,new Map);w(this,qt,new Map);w(this,zi,!1);w(this,Cr,!1);w(this,Oi,!1);const e=f(i=dr,Io,gh).call(i,this.constructor),r=this;for(const s of e.properties)Gg.call(r,s)&&(l(this,qt).set(s,r[s]),delete r[s])}static get observedAttributes(){var e;return f(e=dr,Io,gh).call(e,this).observedAttributes}connected(){}disconnected(){}changed(e){}connectedCallback(){if(f(this,we,uw).call(this),!l(this,Cr))for(const e of f(this,we,pi).call(this).properties)l(this,ut).has(e)||l(this,ut).set(e,void 0);this.dispatchEvent(new Event("reactive:connect")),this.connected(),f(this,we,qa).call(this)}disconnectedCallback(){this.dispatchEvent(new Event("reactive:disconnect")),this.disconnected()}attributeChangedCallback(e,r,i){if(r===i)return;const s=f(this,we,pi).call(this).byAttr.get(e);s&&(l(this,qt).has(s.property)||(this[s.property]=OO(s.type,i)))}};Io=new WeakSet,gh=function(e){const r=lu.get(e);if(r)return r;const i=[...e.properties??[]],s=e.attributes??{},o=new Map,a=new Map;for(const u of i)if(zO.has(u))throw new Error(`Reactive property "${u}" collides with a built-in DOM property. Rename it to avoid shadowing the platform API.`);for(const[u,h]of Object.entries(s)){if(u.includes("-")&&h.property===void 0)throw new Error(`Attribute "${u}" must declare a "property" name because kebab-case cannot be a property.`);const p=h.property??u;if(!i.includes(p))throw new Error(`Attribute '${u}' references property '${p}', which isn't declared in \`static properties\`. Add it to \`properties\` to make it reactive.`);if(yl(h.type)){if(typeof h.type.parse!="function")throw new Error(`Attribute "${u}" custom coercer is missing a \`parse\` function.`);if(typeof h.type.serialize!="function")throw new Error(`Attribute "${u}" custom coercer is missing a \`serialize\` function.`)}const v={attribute:u,property:p,type:h.type};o.set(u,v),a.set(p,v)}for(const u of i){const h=Object.getOwnPropertyDescriptor(e.prototype,u);if((h==null?void 0:h.get)!==void 0||(h==null?void 0:h.set)!==void 0)throw new Error(`Observed property "${u}" cannot define a custom getter/setter. Use changed() for side effects instead.`);h===void 0&&Object.defineProperty(e.prototype,u,{configurable:!0,enumerable:!0,get(){return l(this,Ir).get(u)},set(p){f(this,we,aw).call(this,u,p)}})}const c={properties:i,observedAttributes:Object.keys(s),byAttr:o,byProp:a};return lu.set(e,c),c},Ir=new WeakMap,ut=new WeakMap,qt=new WeakMap,zi=new WeakMap,Cr=new WeakMap,Oi=new WeakMap,we=new WeakSet,pi=function(){return lu.get(this.constructor)},aw=function(e,r){if(!l(this,Oi)&&l(this,qt).has(e))return;const i=l(this,Ir).get(e);f(this,we,lw).call(this,e,i,r)||(l(this,ut).has(e)||l(this,ut).set(e,i),l(this,Ir).set(e,r),l(this,qt).delete(e),f(this,we,cw).call(this,e,r),this.isConnected&&f(this,we,qa).call(this))},lw=function(e,r,i){if(Object.is(r,i))return!0;const s=f(this,we,pi).call(this).byProp.get(e);if(!s||!yl(s.type))return!1;const o=r==null,a=i==null;if(o||a)return o&&a;try{return s.type.serialize(r)===s.type.serialize(i)}catch{return!1}},cw=function(e,r){const i=f(this,we,pi).call(this).byProp.get(e);if(!i)return;const{attribute:s,type:o}=i;if(o===Boolean){const c=this.hasAttribute(s);r&&!c?this.setAttribute(s,""):!r&&c&&this.removeAttribute(s);return}const a=MO(o,r);if(a===null){this.hasAttribute(s)&&this.removeAttribute(s);return}this.getAttribute(s)!==a&&this.setAttribute(s,a)},uw=function(){const e=this,r=f(this,we,pi).call(this);for(const i of r.properties){if(!Gg.call(e,i))continue;const s=e[i];delete e[i],!(l(this,qt).has(i)||l(this,Ir).has(i))&&(e[i]=s)}S(this,Oi,!0);try{for(const[i,s]of l(this,qt))e[i]=s;l(this,qt).clear()}finally{S(this,Oi,!1)}},qa=function(){l(this,zi)||!this.isConnected||l(this,Cr)&&l(this,ut).size===0||(S(this,zi,!0),queueMicrotask(()=>{if(S(this,zi,!1),!this.isConnected||l(this,Cr)&&l(this,ut).size===0)return;const e=new Map(l(this,ut));l(this,ut).clear(),S(this,Cr,!0);try{this.changed(e)}catch(r){console.error(r)}this.isConnected&&l(this,ut).size>0&&f(this,we,qa).call(this)}))},w(dr,Io),g(dr,"properties"),g(dr,"attributes");let Xi=dr;var de,vn,Un,Mi,Ni,yn,Co,ke,Ui,Yt,Z,hw,Ro,Po,Do,Lo,mh,vh,yh,dw,pw,fw,gw,Tl,Il,Cl,Rl,bh,mw,Ya,Pl,Xa,Dl,vw,yw,bw,ww,Sw,at;class NO extends Xi{constructor(){super(...arguments);w(this,Z);w(this,de,en.resolve("ScreenManager"));w(this,vn,en.resolve("ServerManager"));w(this,Un,null);w(this,Mi,new DisposableStack);w(this,Ni,Za());w(this,yn,Za());w(this,Co,Za());w(this,ke,{kind:"none"});w(this,Ui,!1);w(this,Yt,[]);w(this,Ro,()=>{f(this,Z,mh).call(this),S(this,ke,{kind:"none"}),l(this,at).call(this)});w(this,Po,()=>{l(this,at).call(this)});w(this,Do,()=>{l(this,at).call(this)});w(this,Lo,()=>{l(this,at).call(this)});w(this,Tl,()=>{var i,s;if(l(this,ke).kind==="picker"){f(this,Z,Xa).call(this);return}S(this,Yt,f(this,Z,mw).call(this));const e=((i=l(this,de).activeScreen)==null?void 0:i.id)??null,r=e&&l(this,Yt).some(o=>o.screenID===e)?e:((s=l(this,Yt)[0])==null?void 0:s.screenID)??null;S(this,ke,{kind:"picker",filter:"",highlightedID:r}),l(this,at).call(this),queueMicrotask(()=>{var o;(o=l(this,Co).value)==null||o.focus()})});w(this,Il,e=>{var u;const r=l(this,ke);if(r.kind!=="picker")return;const i=e.target;if(!(i instanceof HTMLInputElement))return;const s=i.value,o=f(this,Z,Ya).call(this,l(this,Yt),s),c=r.highlightedID!==null&&o.some(h=>h.screenID===r.highlightedID)?r.highlightedID:((u=o[0])==null?void 0:u.screenID)??null;S(this,ke,{kind:"picker",filter:s,highlightedID:c}),l(this,at).call(this)});w(this,Cl,e=>{var s;const r=l(this,ke);if(r.kind!=="picker")return;if(e.key==="Escape"){e.preventDefault(),f(this,Z,Xa).call(this),(s=l(this,Ni).value)==null||s.focus();return}const i=f(this,Z,Ya).call(this,l(this,Yt),r.filter);if(e.key==="ArrowDown"||e.key==="ArrowUp"){if(e.preventDefault(),i.length===0)return;const o=i.findIndex(u=>u.screenID===r.highlightedID),a=e.key==="ArrowDown"?1:-1,c=o<0?0:Math.max(0,Math.min(i.length-1,o+a));S(this,ke,{kind:"picker",filter:r.filter,highlightedID:i[c].screenID}),l(this,at).call(this);return}if(e.key==="Enter"){e.preventDefault();const o=i.find(a=>a.screenID===r.highlightedID);o&&f(this,Z,bh).call(this,o)}});w(this,Rl,e=>{f(this,Z,bh).call(this,e)});w(this,Pl,e=>{l(this,ke).kind==="picker"&&e.target===l(this,yn).value&&(S(this,ke,{kind:"none"}),l(this,at).call(this))});w(this,Dl,async()=>{if(l(this,Ui))return;const e=f(this,Z,vw).call(this);if(e){S(this,Ui,!0);try{const r=await e.createScreen(UO(new Date));l(this,de).addTab(e.url,r.id),l(this,de).setActive(e.url,r.id)}catch{}finally{S(this,Ui,!1)}}});w(this,at,()=>{const e=f(this,Z,fw).call(this);Ce(z`
|
|
345
|
+
${f(this,Z,yw).call(this)}
|
|
244
346
|
<div class="pills" role="group" aria-label="Open tabs">
|
|
245
|
-
${e.map(r=>f(this,Z,
|
|
347
|
+
${e.map(r=>f(this,Z,bw).call(this,r))}
|
|
246
348
|
</div>
|
|
247
|
-
${f(this,Z,
|
|
248
|
-
`,this),l(this,yn).value&&(l(this,yn).value.anchor=l(this,
|
|
349
|
+
${f(this,Z,ww).call(this)}
|
|
350
|
+
`,this),l(this,yn).value&&(l(this,yn).value.anchor=l(this,Ni).value??null)})}connected(){l(this,de).addEventListener("active-screen-changed",l(this,Ro)),l(this,de).addEventListener("tabs-changed",l(this,Po)),l(this,vn).addEventListener("screens-changed",l(this,Do)),f(this,Z,mh).call(this),l(this,at).call(this),f(this,Z,hw).call(this),l(this,Mi).defer(()=>{l(this,de).removeEventListener("active-screen-changed",l(this,Ro)),l(this,de).removeEventListener("tabs-changed",l(this,Po)),l(this,vn).removeEventListener("screens-changed",l(this,Do)),f(this,Z,vh).call(this)})}disconnected(){l(this,Mi).dispose(),S(this,Mi,new DisposableStack)}}de=new WeakMap,vn=new WeakMap,Un=new WeakMap,Mi=new WeakMap,Ni=new WeakMap,yn=new WeakMap,Co=new WeakMap,ke=new WeakMap,Ui=new WeakMap,Yt=new WeakMap,Z=new WeakSet,hw=async function(){const e=await gv(this);this.setAttribute("tone",e)},Ro=new WeakMap,Po=new WeakMap,Do=new WeakMap,Lo=new WeakMap,mh=function(){var r;const e=l(this,de).activeScreen;l(this,Un)!==e&&(f(this,Z,vh).call(this),S(this,Un,e),(r=l(this,Un))==null||r.addEventListener("change",l(this,Lo)))},vh=function(){var e;(e=l(this,Un))==null||e.removeEventListener("change",l(this,Lo)),S(this,Un,null)},yh=function(e,r){l(this,de).setActive(e,r)},dw=function(e,r,i){i.stopPropagation();const s=l(this,de).getTabs(e),o=f(this,Z,gw).call(this,s,r),a=l(this,de).activeScreen,c=(a==null?void 0:a.id)===r&&a.server.url===e;l(this,de).removeTab(e,r),c&&(o?l(this,de).setActive(e,o):l(this,de).clearActive())},pw=function(e,r,i){const s=l(this,de).activeScreen;if((s==null?void 0:s.id)===r){s.rename(i.value);return}const o=l(this,vn).servers.get(e),a=o==null?void 0:o.screens.get(r);!o||!a||o.client.screens.update({screenID:r,name:i.value}).catch(()=>{})},fw=function(){const e=l(this,de).activeScreen,r=[];for(const i of l(this,vn).servers.values())for(const s of l(this,de).getTabs(i.url)){const o=i.screens.get(s);o&&r.push({serverURL:i.url,screenID:o.id,name:o.name,isActive:(e==null?void 0:e.id)===o.id&&e.server.url===i.url})}return r},gw=function(e,r){const i=e.indexOf(r);if(i<0)return null;const s=e.filter(a=>a!==r);if(s.length===0)return null;const o=Math.max(0,i-1);return s[o]??null},Tl=new WeakMap,Il=new WeakMap,Cl=new WeakMap,Rl=new WeakMap,bh=function(e){l(this,de).addTab(e.serverURL,e.screenID),l(this,de).setActive(e.serverURL,e.screenID),f(this,Z,Xa).call(this)},mw=function(){const e=[];for(const r of l(this,vn).servers.values())for(const i of r.screens.values())e.push({serverURL:r.url,screenID:i.id,name:i.name});return e},Ya=function(e,r){const i=r.trim().toLowerCase();return i.length===0?e:e.filter(s=>s.name.toLowerCase().includes(i))},Pl=new WeakMap,Xa=function(){l(this,ke).kind==="picker"&&(l(this,yn).value&&(l(this,yn).value.open=!1),S(this,ke,{kind:"none"}),l(this,at).call(this))},Dl=new WeakMap,vw=function(){for(const e of l(this,vn).servers.values())return e;return null},yw=function(){return z`
|
|
249
351
|
<segmented-control variant="glass" role="group" aria-label="Screens">
|
|
250
352
|
<button
|
|
251
353
|
type="button"
|
|
252
354
|
?icon-only=${!0}
|
|
253
355
|
aria-label="Choose screen"
|
|
254
|
-
@click=${l(this,
|
|
255
|
-
${
|
|
356
|
+
@click=${l(this,Tl)}
|
|
357
|
+
${Va(l(this,Ni))}
|
|
256
358
|
>
|
|
257
|
-
${
|
|
359
|
+
${ez({size:16,weight:"regular"})}
|
|
258
360
|
</button>
|
|
259
361
|
<button
|
|
260
362
|
type="button"
|
|
261
363
|
?icon-only=${!0}
|
|
262
364
|
aria-label="New screen"
|
|
263
|
-
@click=${l(this,
|
|
365
|
+
@click=${l(this,Dl)}
|
|
264
366
|
>
|
|
265
|
-
${
|
|
367
|
+
${tz({size:16,weight:"regular"})}
|
|
266
368
|
</button>
|
|
267
369
|
</segmented-control>
|
|
268
|
-
`},
|
|
370
|
+
`},bw=function(e){return z`
|
|
269
371
|
<span class="tab" ?data-active=${e.isActive}>
|
|
270
372
|
<button
|
|
271
373
|
type="button"
|
|
@@ -274,16 +376,16 @@ ${r.documentElement.outerHTML}`],{type:wz});return URL.createObjectURL(o)}const
|
|
|
274
376
|
aria-pressed=${e.isActive?"true":"false"}
|
|
275
377
|
aria-current=${e.isActive?"page":se}
|
|
276
378
|
aria-label=${e.isActive?`Current tab: ${e.name}`:`Switch to ${e.name}`}
|
|
277
|
-
@mousedown=${r=>{r.button===0&&f(this,Z,
|
|
278
|
-
@click=${()=>f(this,Z,
|
|
379
|
+
@mousedown=${r=>{r.button===0&&f(this,Z,yh).call(this,e.serverURL,e.screenID)}}
|
|
380
|
+
@click=${()=>f(this,Z,yh).call(this,e.serverURL,e.screenID)}
|
|
279
381
|
>
|
|
280
382
|
<span class="tab-leading">
|
|
281
|
-
${
|
|
383
|
+
${Q2({weight:"bold"})}
|
|
282
384
|
</span>
|
|
283
385
|
<editable-text
|
|
284
386
|
class="tab-name"
|
|
285
387
|
.value=${e.name}
|
|
286
|
-
@rename=${r=>f(this,Z,
|
|
388
|
+
@rename=${r=>f(this,Z,pw).call(this,e.serverURL,e.screenID,r)}
|
|
287
389
|
></editable-text>
|
|
288
390
|
</button>
|
|
289
391
|
<button
|
|
@@ -293,19 +395,19 @@ ${r.documentElement.outerHTML}`],{type:wz});return URL.createObjectURL(o)}const
|
|
|
293
395
|
icon-only
|
|
294
396
|
class="tab-close"
|
|
295
397
|
aria-label=${`Close ${e.name}`}
|
|
296
|
-
@click=${r=>f(this,Z,
|
|
398
|
+
@click=${r=>f(this,Z,dw).call(this,e.serverURL,e.screenID,r)}
|
|
297
399
|
>
|
|
298
|
-
${
|
|
400
|
+
${xd({weight:"bold"})}
|
|
299
401
|
</button>
|
|
300
402
|
</span>
|
|
301
|
-
`},
|
|
403
|
+
`},ww=function(){var o;const e=l(this,ke).kind==="picker"?l(this,ke).filter:"",r=l(this,ke).kind==="picker"?l(this,ke).highlightedID:null,i=((o=l(this,de).activeScreen)==null?void 0:o.id)??null,s=f(this,Z,Ya).call(this,l(this,Yt),e);return z`
|
|
302
404
|
<ui-popover
|
|
303
405
|
class="picker-popover"
|
|
304
406
|
material="glass-frosted"
|
|
305
407
|
?open=${l(this,ke).kind==="picker"}
|
|
306
|
-
@close=${l(this,
|
|
307
|
-
@keydown=${l(this,
|
|
308
|
-
${
|
|
408
|
+
@close=${l(this,Pl)}
|
|
409
|
+
@keydown=${l(this,Cl)}
|
|
410
|
+
${Va(l(this,yn))}
|
|
309
411
|
>
|
|
310
412
|
<div class="picker">
|
|
311
413
|
<input
|
|
@@ -314,15 +416,15 @@ ${r.documentElement.outerHTML}`],{type:wz});return URL.createObjectURL(o)}const
|
|
|
314
416
|
placeholder="Filter screens"
|
|
315
417
|
aria-label="Filter screens"
|
|
316
418
|
.value=${e}
|
|
317
|
-
@input=${l(this,
|
|
318
|
-
${
|
|
419
|
+
@input=${l(this,Il)}
|
|
420
|
+
${Va(l(this,Co))}
|
|
319
421
|
/>
|
|
320
422
|
${s.length===0?z`<p class="picker-empty">
|
|
321
423
|
${l(this,Yt).length===0?"No screens":"No matches"}
|
|
322
|
-
</p>`:f(this,Z,
|
|
424
|
+
</p>`:f(this,Z,Sw).call(this,s,r,i)}
|
|
323
425
|
</div>
|
|
324
426
|
</ui-popover>
|
|
325
|
-
`},
|
|
427
|
+
`},Sw=function(e,r,i){return z`
|
|
326
428
|
<ul class="picker-list" role="listbox">
|
|
327
429
|
<li class="picker-section-label" role="presentation">Recent</li>
|
|
328
430
|
${e.map(s=>{const o=s.screenID===i;return z`
|
|
@@ -333,19 +435,19 @@ ${r.documentElement.outerHTML}`],{type:wz});return URL.createObjectURL(o)}const
|
|
|
333
435
|
aria-current=${o?"true":se}
|
|
334
436
|
?data-highlighted=${s.screenID===r}
|
|
335
437
|
?data-active=${o}
|
|
336
|
-
@click=${()=>l(this
|
|
438
|
+
@click=${()=>l(this,Rl).call(this,s)}
|
|
337
439
|
>
|
|
338
440
|
<span class="picker-name">${s.name}</span>
|
|
339
441
|
</li>
|
|
340
442
|
`})}
|
|
341
443
|
</ul>
|
|
342
|
-
`},at=new WeakMap;customElements.define("screen-select",TO);function IO(n){const t=n.toLocaleDateString("en-US",{month:"long",day:"numeric",year:"numeric"}),e=12,r=n.getHours(),i=r%e===0?e:r%e,s=n.getMinutes().toString().padStart(2,"0"),o=r>=e?"pm":"am";return`${t} at ${i}:${s}${o}`}const su=6e4;var Fn,Rr,Ui,Ga;class CO extends HTMLElement{constructor(){super(...arguments);w(this,Ui);w(this,Fn,null);w(this,Rr,null)}connectedCallback(){this.hasAttribute("material")||this.setAttribute("material","glass"),f(this,Ui,Ga).call(this);const e=su-Date.now()%su;S(this,Fn,window.setTimeout(()=>{S(this,Fn,null),f(this,Ui,Ga).call(this),S(this,Rr,window.setInterval(()=>f(this,Ui,Ga).call(this),su))},e))}disconnectedCallback(){l(this,Fn)!==null&&clearTimeout(l(this,Fn)),l(this,Rr)!==null&&clearInterval(l(this,Rr)),S(this,Fn,null),S(this,Rr,null)}}Fn=new WeakMap,Rr=new WeakMap,Ui=new WeakSet,Ga=function(){const e=new Date,r=new Intl.DateTimeFormat(void 0,{weekday:"short",month:"short",day:"numeric"}).format(e),i=new Intl.DateTimeFormat(void 0,{hour:"numeric",minute:"2-digit"}).format(e);Ce(z`<span class="date">${r}</span><span class="time">${i}</span>`,this)};customElements.get("menu-bar-clock")||customElements.define("menu-bar-clock",CO);/*! @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:mw,setPrototypeOf:Zg,isFrozen:RO,getPrototypeOf:PO,getOwnPropertyDescriptor:DO}=Object;let{freeze:qe,seal:mt,create:qa}=Object,{apply:gh,construct:mh}=typeof Reflect<"u"&&Reflect;qe||(qe=function(t){return t});mt||(mt=function(t){return t});gh||(gh=function(t,e){for(var r=arguments.length,i=new Array(r>2?r-2:0),s=2;s<r;s++)i[s-2]=arguments[s];return t.apply(e,i)});mh||(mh=function(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),i=1;i<e;i++)r[i-1]=arguments[i];return new t(...r)});const wa=Ye(Array.prototype.forEach),LO=Ye(Array.prototype.lastIndexOf),Vg=Ye(Array.prototype.pop),ms=Ye(Array.prototype.push),zO=Ye(Array.prototype.splice),Ya=Ye(String.prototype.toLowerCase),ou=Ye(String.prototype.toString),au=Ye(String.prototype.match),vs=Ye(String.prototype.replace),OO=Ye(String.prototype.indexOf),MO=Ye(String.prototype.trim),st=Ye(Object.prototype.hasOwnProperty),We=Ye(RegExp.prototype.test),ys=NO(TypeError);function Ye(n){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var e=arguments.length,r=new Array(e>1?e-1:0),i=1;i<e;i++)r[i-1]=arguments[i];return gh(n,t,r)}}function NO(n){return function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return mh(n,e)}}function G(n,t){let e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Ya;Zg&&Zg(n,null);let r=t.length;for(;r--;){let i=t[r];if(typeof i=="string"){const s=e(i);s!==i&&(RO(t)||(t[r]=s),i=s)}n[i]=!0}return n}function UO(n){for(let t=0;t<n.length;t++)st(n,t)||(n[t]=null);return n}function zt(n){const t=qa(null);for(const[e,r]of mw(n))st(n,e)&&(Array.isArray(r)?t[e]=UO(r):r&&typeof r=="object"&&r.constructor===Object?t[e]=zt(r):t[e]=r);return t}function bs(n,t){for(;n!==null;){const r=DO(n,t);if(r){if(r.get)return Ye(r.get);if(typeof r.value=="function")return Ye(r.value)}n=PO(n)}function e(){return null}return e}const Bg=qe(["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"]),lu=qe(["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"]),cu=qe(["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"]),FO=qe(["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"]),uu=qe(["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"]),HO=qe(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),jg=qe(["#text"]),Gg=qe(["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"]),hu=qe(["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"]),qg=qe(["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"]),Sa=qe(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),WO=mt(/\{\{[\w\W]*|[\w\W]*\}\}/gm),ZO=mt(/<%[\w\W]*|[\w\W]*%>/gm),VO=mt(/\$\{[\w\W]*/gm),BO=mt(/^data-[\-\w.\u00B7-\uFFFF]+$/),jO=mt(/^aria-[\-\w]+$/),vw=mt(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),GO=mt(/^(?:\w+script|data):/i),qO=mt(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),yw=mt(/^html$/i),YO=mt(/^[a-z][.\w]*(-[.\w]+)+$/i);var Yg=Object.freeze({__proto__:null,ARIA_ATTR:jO,ATTR_WHITESPACE:qO,CUSTOM_ELEMENT:YO,DATA_ATTR:BO,DOCTYPE_NAME:yw,ERB_EXPR:ZO,IS_ALLOWED_URI:vw,IS_SCRIPT_OR_DATA:GO,MUSTACHE_EXPR:WO,TMPLIT_EXPR:VO});const ws={element:1,text:3,progressingInstruction:7,comment:8,document:9},XO=function(){return typeof window>"u"?null:window},KO=function(t,e){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let r=null;const i="data-tt-policy-suffix";e&&e.hasAttribute(i)&&(r=e.getAttribute(i));const s="dompurify"+(r?"#"+r:"");try{return t.createPolicy(s,{createHTML(o){return o},createScriptURL(o){return o}})}catch{return console.warn("TrustedTypes policy "+s+" could not be created."),null}},Xg=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function bw(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:XO();const t=U=>bw(U);if(t.version="3.3.3",t.removed=[],!n||!n.document||n.document.nodeType!==ws.document||!n.Element)return t.isSupported=!1,t;let{document:e}=n;const r=e,i=r.currentScript,{DocumentFragment:s,HTMLTemplateElement:o,Node:a,Element:c,NodeFilter:u,NamedNodeMap:h=n.NamedNodeMap||n.MozNamedAttrMap,HTMLFormElement:p,DOMParser:v,trustedTypes:m}=n,_=c.prototype,k=bs(_,"cloneNode"),T=bs(_,"remove"),P=bs(_,"nextSibling"),R=bs(_,"childNodes"),W=bs(_,"parentNode");if(typeof o=="function"){const U=e.createElement("template");U.content&&U.content.ownerDocument&&(e=U.content.ownerDocument)}let N,F="";const{implementation:Y,createNodeIterator:j,createDocumentFragment:oe,getElementsByTagName:wt}=e,{importNode:er}=r;let Re=Xg();t.isSupported=typeof mw=="function"&&typeof W=="function"&&Y&&Y.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:tr,ERB_EXPR:Ct,TMPLIT_EXPR:xn,DATA_ATTR:rc,ARIA_ATTR:Ko,IS_SCRIPT_OR_DATA:Fw,ATTR_WHITESPACE:Dd,CUSTOM_ELEMENT:Hw}=Yg;let{IS_ALLOWED_URI:Ld}=Yg,$e=null;const zd=G({},[...Bg,...lu,...cu,...uu,...jg]);let Pe=null;const Od=G({},[...Gg,...hu,...qg,...Sa]);let ve=Object.seal(qa(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}})),ls=null,Jo=null;const An=Object.seal(qa(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Md=!0,ic=!0,Nd=!1,Ud=!0,jr=!1,Qo=!0,nr=!1,sc=!1,oc=!1,Gr=!1,ea=!1,ta=!1,Fd=!0,Hd=!1;const Ww="user-content-";let ac=!0,cs=!1,qr={},Rt=null;const lc=G({},["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 Wd=null;const Zd=G({},["audio","video","img","source","image","track"]);let cc=null;const Vd=G({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),na="http://www.w3.org/1998/Math/MathML",ra="http://www.w3.org/2000/svg",rn="http://www.w3.org/1999/xhtml";let Yr=rn,uc=!1,hc=null;const Zw=G({},[na,ra,rn],ou);let ia=G({},["mi","mo","mn","ms","mtext"]),sa=G({},["annotation-xml"]);const Vw=G({},["title","style","font","a","script"]);let us=null;const Bw=["application/xhtml+xml","text/html"],jw="text/html";let _e=null,Xr=null;const Gw=e.createElement("form"),Bd=function(b){return b instanceof RegExp||b instanceof Function},dc=function(){let b=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(Xr&&Xr===b)){if((!b||typeof b!="object")&&(b={}),b=zt(b),us=Bw.indexOf(b.PARSER_MEDIA_TYPE)===-1?jw:b.PARSER_MEDIA_TYPE,_e=us==="application/xhtml+xml"?ou:Ya,$e=st(b,"ALLOWED_TAGS")?G({},b.ALLOWED_TAGS,_e):zd,Pe=st(b,"ALLOWED_ATTR")?G({},b.ALLOWED_ATTR,_e):Od,hc=st(b,"ALLOWED_NAMESPACES")?G({},b.ALLOWED_NAMESPACES,ou):Zw,cc=st(b,"ADD_URI_SAFE_ATTR")?G(zt(Vd),b.ADD_URI_SAFE_ATTR,_e):Vd,Wd=st(b,"ADD_DATA_URI_TAGS")?G(zt(Zd),b.ADD_DATA_URI_TAGS,_e):Zd,Rt=st(b,"FORBID_CONTENTS")?G({},b.FORBID_CONTENTS,_e):lc,ls=st(b,"FORBID_TAGS")?G({},b.FORBID_TAGS,_e):zt({}),Jo=st(b,"FORBID_ATTR")?G({},b.FORBID_ATTR,_e):zt({}),qr=st(b,"USE_PROFILES")?b.USE_PROFILES:!1,Md=b.ALLOW_ARIA_ATTR!==!1,ic=b.ALLOW_DATA_ATTR!==!1,Nd=b.ALLOW_UNKNOWN_PROTOCOLS||!1,Ud=b.ALLOW_SELF_CLOSE_IN_ATTR!==!1,jr=b.SAFE_FOR_TEMPLATES||!1,Qo=b.SAFE_FOR_XML!==!1,nr=b.WHOLE_DOCUMENT||!1,Gr=b.RETURN_DOM||!1,ea=b.RETURN_DOM_FRAGMENT||!1,ta=b.RETURN_TRUSTED_TYPE||!1,oc=b.FORCE_BODY||!1,Fd=b.SANITIZE_DOM!==!1,Hd=b.SANITIZE_NAMED_PROPS||!1,ac=b.KEEP_CONTENT!==!1,cs=b.IN_PLACE||!1,Ld=b.ALLOWED_URI_REGEXP||vw,Yr=b.NAMESPACE||rn,ia=b.MATHML_TEXT_INTEGRATION_POINTS||ia,sa=b.HTML_INTEGRATION_POINTS||sa,ve=b.CUSTOM_ELEMENT_HANDLING||{},b.CUSTOM_ELEMENT_HANDLING&&Bd(b.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(ve.tagNameCheck=b.CUSTOM_ELEMENT_HANDLING.tagNameCheck),b.CUSTOM_ELEMENT_HANDLING&&Bd(b.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(ve.attributeNameCheck=b.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),b.CUSTOM_ELEMENT_HANDLING&&typeof b.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(ve.allowCustomizedBuiltInElements=b.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),jr&&(ic=!1),ea&&(Gr=!0),qr&&($e=G({},jg),Pe=qa(null),qr.html===!0&&(G($e,Bg),G(Pe,Gg)),qr.svg===!0&&(G($e,lu),G(Pe,hu),G(Pe,Sa)),qr.svgFilters===!0&&(G($e,cu),G(Pe,hu),G(Pe,Sa)),qr.mathMl===!0&&(G($e,uu),G(Pe,qg),G(Pe,Sa))),st(b,"ADD_TAGS")||(An.tagCheck=null),st(b,"ADD_ATTR")||(An.attributeCheck=null),b.ADD_TAGS&&(typeof b.ADD_TAGS=="function"?An.tagCheck=b.ADD_TAGS:($e===zd&&($e=zt($e)),G($e,b.ADD_TAGS,_e))),b.ADD_ATTR&&(typeof b.ADD_ATTR=="function"?An.attributeCheck=b.ADD_ATTR:(Pe===Od&&(Pe=zt(Pe)),G(Pe,b.ADD_ATTR,_e))),b.ADD_URI_SAFE_ATTR&&G(cc,b.ADD_URI_SAFE_ATTR,_e),b.FORBID_CONTENTS&&(Rt===lc&&(Rt=zt(Rt)),G(Rt,b.FORBID_CONTENTS,_e)),b.ADD_FORBID_CONTENTS&&(Rt===lc&&(Rt=zt(Rt)),G(Rt,b.ADD_FORBID_CONTENTS,_e)),ac&&($e["#text"]=!0),nr&&G($e,["html","head","body"]),$e.table&&(G($e,["tbody"]),delete ls.tbody),b.TRUSTED_TYPES_POLICY){if(typeof b.TRUSTED_TYPES_POLICY.createHTML!="function")throw ys('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof b.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw ys('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');N=b.TRUSTED_TYPES_POLICY,F=N.createHTML("")}else N===void 0&&(N=KO(m,i)),N!==null&&typeof F=="string"&&(F=N.createHTML(""));qe&&qe(b),Xr=b}},jd=G({},[...lu,...cu,...FO]),Gd=G({},[...uu,...HO]),qw=function(b){let C=W(b);(!C||!C.tagName)&&(C={namespaceURI:Yr,tagName:"template"});const D=Ya(b.tagName),ce=Ya(C.tagName);return hc[b.namespaceURI]?b.namespaceURI===ra?C.namespaceURI===rn?D==="svg":C.namespaceURI===na?D==="svg"&&(ce==="annotation-xml"||ia[ce]):!!jd[D]:b.namespaceURI===na?C.namespaceURI===rn?D==="math":C.namespaceURI===ra?D==="math"&&sa[ce]:!!Gd[D]:b.namespaceURI===rn?C.namespaceURI===ra&&!sa[ce]||C.namespaceURI===na&&!ia[ce]?!1:!Gd[D]&&(Vw[D]||!jd[D]):!!(us==="application/xhtml+xml"&&hc[b.namespaceURI]):!1},Pt=function(b){ms(t.removed,{element:b});try{W(b).removeChild(b)}catch{T(b)}},rr=function(b,C){try{ms(t.removed,{attribute:C.getAttributeNode(b),from:C})}catch{ms(t.removed,{attribute:null,from:C})}if(C.removeAttribute(b),b==="is")if(Gr||ea)try{Pt(C)}catch{}else try{C.setAttribute(b,"")}catch{}},qd=function(b){let C=null,D=null;if(oc)b="<remove></remove>"+b;else{const ye=au(b,/^[\r\n\t ]+/);D=ye&&ye[0]}us==="application/xhtml+xml"&&Yr===rn&&(b='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+b+"</body></html>");const ce=N?N.createHTML(b):b;if(Yr===rn)try{C=new v().parseFromString(ce,us)}catch{}if(!C||!C.documentElement){C=Y.createDocument(Yr,"template",null);try{C.documentElement.innerHTML=uc?F:ce}catch{}}const Ne=C.body||C.documentElement;return b&&D&&Ne.insertBefore(e.createTextNode(D),Ne.childNodes[0]||null),Yr===rn?wt.call(C,nr?"html":"body")[0]:nr?C.documentElement:Ne},Yd=function(b){return j.call(b.ownerDocument||b,b,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},pc=function(b){return b instanceof p&&(typeof b.nodeName!="string"||typeof b.textContent!="string"||typeof b.removeChild!="function"||!(b.attributes instanceof h)||typeof b.removeAttribute!="function"||typeof b.setAttribute!="function"||typeof b.namespaceURI!="string"||typeof b.insertBefore!="function"||typeof b.hasChildNodes!="function")},Xd=function(b){return typeof a=="function"&&b instanceof a};function sn(U,b,C){wa(U,D=>{D.call(t,b,C,Xr)})}const Kd=function(b){let C=null;if(sn(Re.beforeSanitizeElements,b,null),pc(b))return Pt(b),!0;const D=_e(b.nodeName);if(sn(Re.uponSanitizeElement,b,{tagName:D,allowedTags:$e}),Qo&&b.hasChildNodes()&&!Xd(b.firstElementChild)&&We(/<[/\w!]/g,b.innerHTML)&&We(/<[/\w!]/g,b.textContent)||b.nodeType===ws.progressingInstruction||Qo&&b.nodeType===ws.comment&&We(/<[/\w]/g,b.data))return Pt(b),!0;if(!(An.tagCheck instanceof Function&&An.tagCheck(D))&&(!$e[D]||ls[D])){if(!ls[D]&&Qd(D)&&(ve.tagNameCheck instanceof RegExp&&We(ve.tagNameCheck,D)||ve.tagNameCheck instanceof Function&&ve.tagNameCheck(D)))return!1;if(ac&&!Rt[D]){const ce=W(b)||b.parentNode,Ne=R(b)||b.childNodes;if(Ne&&ce){const ye=Ne.length;for(let Xe=ye-1;Xe>=0;--Xe){const on=k(Ne[Xe],!0);on.__removalCount=(b.__removalCount||0)+1,ce.insertBefore(on,P(b))}}}return Pt(b),!0}return b instanceof c&&!qw(b)||(D==="noscript"||D==="noembed"||D==="noframes")&&We(/<\/no(script|embed|frames)/i,b.innerHTML)?(Pt(b),!0):(jr&&b.nodeType===ws.text&&(C=b.textContent,wa([tr,Ct,xn],ce=>{C=vs(C,ce," ")}),b.textContent!==C&&(ms(t.removed,{element:b.cloneNode()}),b.textContent=C)),sn(Re.afterSanitizeElements,b,null),!1)},Jd=function(b,C,D){if(Jo[C]||Fd&&(C==="id"||C==="name")&&(D in e||D in Gw))return!1;if(!(ic&&!Jo[C]&&We(rc,C))){if(!(Md&&We(Ko,C))){if(!(An.attributeCheck instanceof Function&&An.attributeCheck(C,b))){if(!Pe[C]||Jo[C]){if(!(Qd(b)&&(ve.tagNameCheck instanceof RegExp&&We(ve.tagNameCheck,b)||ve.tagNameCheck instanceof Function&&ve.tagNameCheck(b))&&(ve.attributeNameCheck instanceof RegExp&&We(ve.attributeNameCheck,C)||ve.attributeNameCheck instanceof Function&&ve.attributeNameCheck(C,b))||C==="is"&&ve.allowCustomizedBuiltInElements&&(ve.tagNameCheck instanceof RegExp&&We(ve.tagNameCheck,D)||ve.tagNameCheck instanceof Function&&ve.tagNameCheck(D))))return!1}else if(!cc[C]){if(!We(Ld,vs(D,Dd,""))){if(!((C==="src"||C==="xlink:href"||C==="href")&&b!=="script"&&OO(D,"data:")===0&&Wd[b])){if(!(Nd&&!We(Fw,vs(D,Dd,"")))){if(D)return!1}}}}}}}return!0},Qd=function(b){return b!=="annotation-xml"&&au(b,Hw)},ep=function(b){sn(Re.beforeSanitizeAttributes,b,null);const{attributes:C}=b;if(!C||pc(b))return;const D={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Pe,forceKeepAttr:void 0};let ce=C.length;for(;ce--;){const Ne=C[ce],{name:ye,namespaceURI:Xe,value:on}=Ne,Kr=_e(ye),fc=on;let De=ye==="value"?fc:MO(fc);if(D.attrName=Kr,D.attrValue=De,D.keepAttr=!0,D.forceKeepAttr=void 0,sn(Re.uponSanitizeAttribute,b,D),De=D.attrValue,Hd&&(Kr==="id"||Kr==="name")&&(rr(ye,b),De=Ww+De),Qo&&We(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,De)){rr(ye,b);continue}if(Kr==="attributename"&&au(De,"href")){rr(ye,b);continue}if(D.forceKeepAttr)continue;if(!D.keepAttr){rr(ye,b);continue}if(!Ud&&We(/\/>/i,De)){rr(ye,b);continue}jr&&wa([tr,Ct,xn],np=>{De=vs(De,np," ")});const tp=_e(b.nodeName);if(!Jd(tp,Kr,De)){rr(ye,b);continue}if(N&&typeof m=="object"&&typeof m.getAttributeType=="function"&&!Xe)switch(m.getAttributeType(tp,Kr)){case"TrustedHTML":{De=N.createHTML(De);break}case"TrustedScriptURL":{De=N.createScriptURL(De);break}}if(De!==fc)try{Xe?b.setAttributeNS(Xe,ye,De):b.setAttribute(ye,De),pc(b)?Pt(b):Vg(t.removed)}catch{rr(ye,b)}}sn(Re.afterSanitizeAttributes,b,null)},Yw=function U(b){let C=null;const D=Yd(b);for(sn(Re.beforeSanitizeShadowDOM,b,null);C=D.nextNode();)sn(Re.uponSanitizeShadowNode,C,null),Kd(C),ep(C),C.content instanceof s&&U(C.content);sn(Re.afterSanitizeShadowDOM,b,null)};return t.sanitize=function(U){let b=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},C=null,D=null,ce=null,Ne=null;if(uc=!U,uc&&(U="<!-->"),typeof U!="string"&&!Xd(U))if(typeof U.toString=="function"){if(U=U.toString(),typeof U!="string")throw ys("dirty is not a string, aborting")}else throw ys("toString is not a function");if(!t.isSupported)return U;if(sc||dc(b),t.removed=[],typeof U=="string"&&(cs=!1),cs){if(U.nodeName){const on=_e(U.nodeName);if(!$e[on]||ls[on])throw ys("root node is forbidden and cannot be sanitized in-place")}}else if(U instanceof a)C=qd("<!---->"),D=C.ownerDocument.importNode(U,!0),D.nodeType===ws.element&&D.nodeName==="BODY"||D.nodeName==="HTML"?C=D:C.appendChild(D);else{if(!Gr&&!jr&&!nr&&U.indexOf("<")===-1)return N&&ta?N.createHTML(U):U;if(C=qd(U),!C)return Gr?null:ta?F:""}C&&oc&&Pt(C.firstChild);const ye=Yd(cs?U:C);for(;ce=ye.nextNode();)Kd(ce),ep(ce),ce.content instanceof s&&Yw(ce.content);if(cs)return U;if(Gr){if(ea)for(Ne=oe.call(C.ownerDocument);C.firstChild;)Ne.appendChild(C.firstChild);else Ne=C;return(Pe.shadowroot||Pe.shadowrootmode)&&(Ne=er.call(r,Ne,!0)),Ne}let Xe=nr?C.outerHTML:C.innerHTML;return nr&&$e["!doctype"]&&C.ownerDocument&&C.ownerDocument.doctype&&C.ownerDocument.doctype.name&&We(yw,C.ownerDocument.doctype.name)&&(Xe="<!DOCTYPE "+C.ownerDocument.doctype.name+`>
|
|
343
|
-
`+Xe),jr&&
|
|
344
|
-
]`).replace("lheading",
|
|
444
|
+
`},at=new WeakMap;customElements.define("screen-select",NO);function UO(n){const t=n.toLocaleDateString("en-US",{month:"long",day:"numeric",year:"numeric"}),e=12,r=n.getHours(),i=r%e===0?e:r%e,s=n.getMinutes().toString().padStart(2,"0"),o=r>=e?"pm":"am";return`${t} at ${i}:${s}${o}`}const cu=6e4;var Fn,Rr,Fi,Ka;class FO extends HTMLElement{constructor(){super(...arguments);w(this,Fi);w(this,Fn,null);w(this,Rr,null)}connectedCallback(){this.hasAttribute("material")||this.setAttribute("material","glass"),f(this,Fi,Ka).call(this);const e=cu-Date.now()%cu;S(this,Fn,window.setTimeout(()=>{S(this,Fn,null),f(this,Fi,Ka).call(this),S(this,Rr,window.setInterval(()=>f(this,Fi,Ka).call(this),cu))},e))}disconnectedCallback(){l(this,Fn)!==null&&clearTimeout(l(this,Fn)),l(this,Rr)!==null&&clearInterval(l(this,Rr)),S(this,Fn,null),S(this,Rr,null)}}Fn=new WeakMap,Rr=new WeakMap,Fi=new WeakSet,Ka=function(){const e=new Date,r=new Intl.DateTimeFormat(void 0,{weekday:"short",month:"short",day:"numeric"}).format(e),i=new Intl.DateTimeFormat(void 0,{hour:"numeric",minute:"2-digit"}).format(e);Ce(z`<span class="date">${r}</span><span class="time">${i}</span>`,this)};customElements.get("menu-bar-clock")||customElements.define("menu-bar-clock",FO);/*! @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:_w,setPrototypeOf:qg,isFrozen:HO,getPrototypeOf:WO,getOwnPropertyDescriptor:ZO}=Object;let{freeze:qe,seal:mt,create:Ja}=Object,{apply:wh,construct:Sh}=typeof Reflect<"u"&&Reflect;qe||(qe=function(t){return t});mt||(mt=function(t){return t});wh||(wh=function(t,e){for(var r=arguments.length,i=new Array(r>2?r-2:0),s=2;s<r;s++)i[s-2]=arguments[s];return t.apply(e,i)});Sh||(Sh=function(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),i=1;i<e;i++)r[i-1]=arguments[i];return new t(...r)});const xa=Ye(Array.prototype.forEach),VO=Ye(Array.prototype.lastIndexOf),Yg=Ye(Array.prototype.pop),vs=Ye(Array.prototype.push),BO=Ye(Array.prototype.splice),Qa=Ye(String.prototype.toLowerCase),uu=Ye(String.prototype.toString),hu=Ye(String.prototype.match),ys=Ye(String.prototype.replace),jO=Ye(String.prototype.indexOf),GO=Ye(String.prototype.trim),st=Ye(Object.prototype.hasOwnProperty),We=Ye(RegExp.prototype.test),bs=qO(TypeError);function Ye(n){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var e=arguments.length,r=new Array(e>1?e-1:0),i=1;i<e;i++)r[i-1]=arguments[i];return wh(n,t,r)}}function qO(n){return function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return Sh(n,e)}}function G(n,t){let e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Qa;qg&&qg(n,null);let r=t.length;for(;r--;){let i=t[r];if(typeof i=="string"){const s=e(i);s!==i&&(HO(t)||(t[r]=s),i=s)}n[i]=!0}return n}function YO(n){for(let t=0;t<n.length;t++)st(n,t)||(n[t]=null);return n}function zt(n){const t=Ja(null);for(const[e,r]of _w(n))st(n,e)&&(Array.isArray(r)?t[e]=YO(r):r&&typeof r=="object"&&r.constructor===Object?t[e]=zt(r):t[e]=r);return t}function ws(n,t){for(;n!==null;){const r=ZO(n,t);if(r){if(r.get)return Ye(r.get);if(typeof r.value=="function")return Ye(r.value)}n=WO(n)}function e(){return null}return e}const Xg=qe(["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"]),du=qe(["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"]),pu=qe(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),XO=qe(["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"]),fu=qe(["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"]),KO=qe(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Kg=qe(["#text"]),Jg=qe(["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"]),gu=qe(["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"]),Qg=qe(["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"]),Ea=qe(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),JO=mt(/\{\{[\w\W]*|[\w\W]*\}\}/gm),QO=mt(/<%[\w\W]*|[\w\W]*%>/gm),eM=mt(/\$\{[\w\W]*/gm),tM=mt(/^data-[\-\w.\u00B7-\uFFFF]+$/),nM=mt(/^aria-[\-\w]+$/),kw=mt(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),rM=mt(/^(?:\w+script|data):/i),iM=mt(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),xw=mt(/^html$/i),sM=mt(/^[a-z][.\w]*(-[.\w]+)+$/i);var em=Object.freeze({__proto__:null,ARIA_ATTR:nM,ATTR_WHITESPACE:iM,CUSTOM_ELEMENT:sM,DATA_ATTR:tM,DOCTYPE_NAME:xw,ERB_EXPR:QO,IS_ALLOWED_URI:kw,IS_SCRIPT_OR_DATA:rM,MUSTACHE_EXPR:JO,TMPLIT_EXPR:eM});const Ss={element:1,text:3,progressingInstruction:7,comment:8,document:9},oM=function(){return typeof window>"u"?null:window},aM=function(t,e){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let r=null;const i="data-tt-policy-suffix";e&&e.hasAttribute(i)&&(r=e.getAttribute(i));const s="dompurify"+(r?"#"+r:"");try{return t.createPolicy(s,{createHTML(o){return o},createScriptURL(o){return o}})}catch{return console.warn("TrustedTypes policy "+s+" could not be created."),null}},tm=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Ew(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:oM();const t=U=>Ew(U);if(t.version="3.3.3",t.removed=[],!n||!n.document||n.document.nodeType!==Ss.document||!n.Element)return t.isSupported=!1,t;let{document:e}=n;const r=e,i=r.currentScript,{DocumentFragment:s,HTMLTemplateElement:o,Node:a,Element:c,NodeFilter:u,NamedNodeMap:h=n.NamedNodeMap||n.MozNamedAttrMap,HTMLFormElement:p,DOMParser:v,trustedTypes:m}=n,_=c.prototype,k=ws(_,"cloneNode"),T=ws(_,"remove"),P=ws(_,"nextSibling"),R=ws(_,"childNodes"),W=ws(_,"parentNode");if(typeof o=="function"){const U=e.createElement("template");U.content&&U.content.ownerDocument&&(e=U.content.ownerDocument)}let N,F="";const{implementation:Y,createNodeIterator:j,createDocumentFragment:oe,getElementsByTagName:wt}=e,{importNode:er}=r;let Re=tm();t.isSupported=typeof _w=="function"&&typeof W=="function"&&Y&&Y.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:tr,ERB_EXPR:Ct,TMPLIT_EXPR:En,DATA_ATTR:ac,ARIA_ATTR:ta,IS_SCRIPT_OR_DATA:jw,ATTR_WHITESPACE:Nd,CUSTOM_ELEMENT:Gw}=em;let{IS_ALLOWED_URI:Ud}=em,$e=null;const Fd=G({},[...Xg,...du,...pu,...fu,...Kg]);let Pe=null;const Hd=G({},[...Jg,...gu,...Qg,...Ea]);let ve=Object.seal(Ja(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}})),cs=null,na=null;const An=Object.seal(Ja(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Wd=!0,lc=!0,Zd=!1,Vd=!0,jr=!1,ra=!0,nr=!1,cc=!1,uc=!1,Gr=!1,ia=!1,sa=!1,Bd=!0,jd=!1;const qw="user-content-";let hc=!0,us=!1,qr={},Rt=null;const dc=G({},["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 Gd=null;const qd=G({},["audio","video","img","source","image","track"]);let pc=null;const Yd=G({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),oa="http://www.w3.org/1998/Math/MathML",aa="http://www.w3.org/2000/svg",rn="http://www.w3.org/1999/xhtml";let Yr=rn,fc=!1,gc=null;const Yw=G({},[oa,aa,rn],uu);let la=G({},["mi","mo","mn","ms","mtext"]),ca=G({},["annotation-xml"]);const Xw=G({},["title","style","font","a","script"]);let hs=null;const Kw=["application/xhtml+xml","text/html"],Jw="text/html";let _e=null,Xr=null;const Qw=e.createElement("form"),Xd=function(b){return b instanceof RegExp||b instanceof Function},mc=function(){let b=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(Xr&&Xr===b)){if((!b||typeof b!="object")&&(b={}),b=zt(b),hs=Kw.indexOf(b.PARSER_MEDIA_TYPE)===-1?Jw:b.PARSER_MEDIA_TYPE,_e=hs==="application/xhtml+xml"?uu:Qa,$e=st(b,"ALLOWED_TAGS")?G({},b.ALLOWED_TAGS,_e):Fd,Pe=st(b,"ALLOWED_ATTR")?G({},b.ALLOWED_ATTR,_e):Hd,gc=st(b,"ALLOWED_NAMESPACES")?G({},b.ALLOWED_NAMESPACES,uu):Yw,pc=st(b,"ADD_URI_SAFE_ATTR")?G(zt(Yd),b.ADD_URI_SAFE_ATTR,_e):Yd,Gd=st(b,"ADD_DATA_URI_TAGS")?G(zt(qd),b.ADD_DATA_URI_TAGS,_e):qd,Rt=st(b,"FORBID_CONTENTS")?G({},b.FORBID_CONTENTS,_e):dc,cs=st(b,"FORBID_TAGS")?G({},b.FORBID_TAGS,_e):zt({}),na=st(b,"FORBID_ATTR")?G({},b.FORBID_ATTR,_e):zt({}),qr=st(b,"USE_PROFILES")?b.USE_PROFILES:!1,Wd=b.ALLOW_ARIA_ATTR!==!1,lc=b.ALLOW_DATA_ATTR!==!1,Zd=b.ALLOW_UNKNOWN_PROTOCOLS||!1,Vd=b.ALLOW_SELF_CLOSE_IN_ATTR!==!1,jr=b.SAFE_FOR_TEMPLATES||!1,ra=b.SAFE_FOR_XML!==!1,nr=b.WHOLE_DOCUMENT||!1,Gr=b.RETURN_DOM||!1,ia=b.RETURN_DOM_FRAGMENT||!1,sa=b.RETURN_TRUSTED_TYPE||!1,uc=b.FORCE_BODY||!1,Bd=b.SANITIZE_DOM!==!1,jd=b.SANITIZE_NAMED_PROPS||!1,hc=b.KEEP_CONTENT!==!1,us=b.IN_PLACE||!1,Ud=b.ALLOWED_URI_REGEXP||kw,Yr=b.NAMESPACE||rn,la=b.MATHML_TEXT_INTEGRATION_POINTS||la,ca=b.HTML_INTEGRATION_POINTS||ca,ve=b.CUSTOM_ELEMENT_HANDLING||{},b.CUSTOM_ELEMENT_HANDLING&&Xd(b.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(ve.tagNameCheck=b.CUSTOM_ELEMENT_HANDLING.tagNameCheck),b.CUSTOM_ELEMENT_HANDLING&&Xd(b.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(ve.attributeNameCheck=b.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),b.CUSTOM_ELEMENT_HANDLING&&typeof b.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(ve.allowCustomizedBuiltInElements=b.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),jr&&(lc=!1),ia&&(Gr=!0),qr&&($e=G({},Kg),Pe=Ja(null),qr.html===!0&&(G($e,Xg),G(Pe,Jg)),qr.svg===!0&&(G($e,du),G(Pe,gu),G(Pe,Ea)),qr.svgFilters===!0&&(G($e,pu),G(Pe,gu),G(Pe,Ea)),qr.mathMl===!0&&(G($e,fu),G(Pe,Qg),G(Pe,Ea))),st(b,"ADD_TAGS")||(An.tagCheck=null),st(b,"ADD_ATTR")||(An.attributeCheck=null),b.ADD_TAGS&&(typeof b.ADD_TAGS=="function"?An.tagCheck=b.ADD_TAGS:($e===Fd&&($e=zt($e)),G($e,b.ADD_TAGS,_e))),b.ADD_ATTR&&(typeof b.ADD_ATTR=="function"?An.attributeCheck=b.ADD_ATTR:(Pe===Hd&&(Pe=zt(Pe)),G(Pe,b.ADD_ATTR,_e))),b.ADD_URI_SAFE_ATTR&&G(pc,b.ADD_URI_SAFE_ATTR,_e),b.FORBID_CONTENTS&&(Rt===dc&&(Rt=zt(Rt)),G(Rt,b.FORBID_CONTENTS,_e)),b.ADD_FORBID_CONTENTS&&(Rt===dc&&(Rt=zt(Rt)),G(Rt,b.ADD_FORBID_CONTENTS,_e)),hc&&($e["#text"]=!0),nr&&G($e,["html","head","body"]),$e.table&&(G($e,["tbody"]),delete cs.tbody),b.TRUSTED_TYPES_POLICY){if(typeof b.TRUSTED_TYPES_POLICY.createHTML!="function")throw bs('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof b.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw bs('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');N=b.TRUSTED_TYPES_POLICY,F=N.createHTML("")}else N===void 0&&(N=aM(m,i)),N!==null&&typeof F=="string"&&(F=N.createHTML(""));qe&&qe(b),Xr=b}},Kd=G({},[...du,...pu,...XO]),Jd=G({},[...fu,...KO]),e0=function(b){let C=W(b);(!C||!C.tagName)&&(C={namespaceURI:Yr,tagName:"template"});const D=Qa(b.tagName),ce=Qa(C.tagName);return gc[b.namespaceURI]?b.namespaceURI===aa?C.namespaceURI===rn?D==="svg":C.namespaceURI===oa?D==="svg"&&(ce==="annotation-xml"||la[ce]):!!Kd[D]:b.namespaceURI===oa?C.namespaceURI===rn?D==="math":C.namespaceURI===aa?D==="math"&&ca[ce]:!!Jd[D]:b.namespaceURI===rn?C.namespaceURI===aa&&!ca[ce]||C.namespaceURI===oa&&!la[ce]?!1:!Jd[D]&&(Xw[D]||!Kd[D]):!!(hs==="application/xhtml+xml"&&gc[b.namespaceURI]):!1},Pt=function(b){vs(t.removed,{element:b});try{W(b).removeChild(b)}catch{T(b)}},rr=function(b,C){try{vs(t.removed,{attribute:C.getAttributeNode(b),from:C})}catch{vs(t.removed,{attribute:null,from:C})}if(C.removeAttribute(b),b==="is")if(Gr||ia)try{Pt(C)}catch{}else try{C.setAttribute(b,"")}catch{}},Qd=function(b){let C=null,D=null;if(uc)b="<remove></remove>"+b;else{const ye=hu(b,/^[\r\n\t ]+/);D=ye&&ye[0]}hs==="application/xhtml+xml"&&Yr===rn&&(b='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+b+"</body></html>");const ce=N?N.createHTML(b):b;if(Yr===rn)try{C=new v().parseFromString(ce,hs)}catch{}if(!C||!C.documentElement){C=Y.createDocument(Yr,"template",null);try{C.documentElement.innerHTML=fc?F:ce}catch{}}const Ne=C.body||C.documentElement;return b&&D&&Ne.insertBefore(e.createTextNode(D),Ne.childNodes[0]||null),Yr===rn?wt.call(C,nr?"html":"body")[0]:nr?C.documentElement:Ne},ep=function(b){return j.call(b.ownerDocument||b,b,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},vc=function(b){return b instanceof p&&(typeof b.nodeName!="string"||typeof b.textContent!="string"||typeof b.removeChild!="function"||!(b.attributes instanceof h)||typeof b.removeAttribute!="function"||typeof b.setAttribute!="function"||typeof b.namespaceURI!="string"||typeof b.insertBefore!="function"||typeof b.hasChildNodes!="function")},tp=function(b){return typeof a=="function"&&b instanceof a};function sn(U,b,C){xa(U,D=>{D.call(t,b,C,Xr)})}const np=function(b){let C=null;if(sn(Re.beforeSanitizeElements,b,null),vc(b))return Pt(b),!0;const D=_e(b.nodeName);if(sn(Re.uponSanitizeElement,b,{tagName:D,allowedTags:$e}),ra&&b.hasChildNodes()&&!tp(b.firstElementChild)&&We(/<[/\w!]/g,b.innerHTML)&&We(/<[/\w!]/g,b.textContent)||b.nodeType===Ss.progressingInstruction||ra&&b.nodeType===Ss.comment&&We(/<[/\w]/g,b.data))return Pt(b),!0;if(!(An.tagCheck instanceof Function&&An.tagCheck(D))&&(!$e[D]||cs[D])){if(!cs[D]&&ip(D)&&(ve.tagNameCheck instanceof RegExp&&We(ve.tagNameCheck,D)||ve.tagNameCheck instanceof Function&&ve.tagNameCheck(D)))return!1;if(hc&&!Rt[D]){const ce=W(b)||b.parentNode,Ne=R(b)||b.childNodes;if(Ne&&ce){const ye=Ne.length;for(let Xe=ye-1;Xe>=0;--Xe){const on=k(Ne[Xe],!0);on.__removalCount=(b.__removalCount||0)+1,ce.insertBefore(on,P(b))}}}return Pt(b),!0}return b instanceof c&&!e0(b)||(D==="noscript"||D==="noembed"||D==="noframes")&&We(/<\/no(script|embed|frames)/i,b.innerHTML)?(Pt(b),!0):(jr&&b.nodeType===Ss.text&&(C=b.textContent,xa([tr,Ct,En],ce=>{C=ys(C,ce," ")}),b.textContent!==C&&(vs(t.removed,{element:b.cloneNode()}),b.textContent=C)),sn(Re.afterSanitizeElements,b,null),!1)},rp=function(b,C,D){if(na[C]||Bd&&(C==="id"||C==="name")&&(D in e||D in Qw))return!1;if(!(lc&&!na[C]&&We(ac,C))){if(!(Wd&&We(ta,C))){if(!(An.attributeCheck instanceof Function&&An.attributeCheck(C,b))){if(!Pe[C]||na[C]){if(!(ip(b)&&(ve.tagNameCheck instanceof RegExp&&We(ve.tagNameCheck,b)||ve.tagNameCheck instanceof Function&&ve.tagNameCheck(b))&&(ve.attributeNameCheck instanceof RegExp&&We(ve.attributeNameCheck,C)||ve.attributeNameCheck instanceof Function&&ve.attributeNameCheck(C,b))||C==="is"&&ve.allowCustomizedBuiltInElements&&(ve.tagNameCheck instanceof RegExp&&We(ve.tagNameCheck,D)||ve.tagNameCheck instanceof Function&&ve.tagNameCheck(D))))return!1}else if(!pc[C]){if(!We(Ud,ys(D,Nd,""))){if(!((C==="src"||C==="xlink:href"||C==="href")&&b!=="script"&&jO(D,"data:")===0&&Gd[b])){if(!(Zd&&!We(jw,ys(D,Nd,"")))){if(D)return!1}}}}}}}return!0},ip=function(b){return b!=="annotation-xml"&&hu(b,Gw)},sp=function(b){sn(Re.beforeSanitizeAttributes,b,null);const{attributes:C}=b;if(!C||vc(b))return;const D={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Pe,forceKeepAttr:void 0};let ce=C.length;for(;ce--;){const Ne=C[ce],{name:ye,namespaceURI:Xe,value:on}=Ne,Kr=_e(ye),yc=on;let De=ye==="value"?yc:GO(yc);if(D.attrName=Kr,D.attrValue=De,D.keepAttr=!0,D.forceKeepAttr=void 0,sn(Re.uponSanitizeAttribute,b,D),De=D.attrValue,jd&&(Kr==="id"||Kr==="name")&&(rr(ye,b),De=qw+De),ra&&We(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,De)){rr(ye,b);continue}if(Kr==="attributename"&&hu(De,"href")){rr(ye,b);continue}if(D.forceKeepAttr)continue;if(!D.keepAttr){rr(ye,b);continue}if(!Vd&&We(/\/>/i,De)){rr(ye,b);continue}jr&&xa([tr,Ct,En],ap=>{De=ys(De,ap," ")});const op=_e(b.nodeName);if(!rp(op,Kr,De)){rr(ye,b);continue}if(N&&typeof m=="object"&&typeof m.getAttributeType=="function"&&!Xe)switch(m.getAttributeType(op,Kr)){case"TrustedHTML":{De=N.createHTML(De);break}case"TrustedScriptURL":{De=N.createScriptURL(De);break}}if(De!==yc)try{Xe?b.setAttributeNS(Xe,ye,De):b.setAttribute(ye,De),vc(b)?Pt(b):Yg(t.removed)}catch{rr(ye,b)}}sn(Re.afterSanitizeAttributes,b,null)},t0=function U(b){let C=null;const D=ep(b);for(sn(Re.beforeSanitizeShadowDOM,b,null);C=D.nextNode();)sn(Re.uponSanitizeShadowNode,C,null),np(C),sp(C),C.content instanceof s&&U(C.content);sn(Re.afterSanitizeShadowDOM,b,null)};return t.sanitize=function(U){let b=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},C=null,D=null,ce=null,Ne=null;if(fc=!U,fc&&(U="<!-->"),typeof U!="string"&&!tp(U))if(typeof U.toString=="function"){if(U=U.toString(),typeof U!="string")throw bs("dirty is not a string, aborting")}else throw bs("toString is not a function");if(!t.isSupported)return U;if(cc||mc(b),t.removed=[],typeof U=="string"&&(us=!1),us){if(U.nodeName){const on=_e(U.nodeName);if(!$e[on]||cs[on])throw bs("root node is forbidden and cannot be sanitized in-place")}}else if(U instanceof a)C=Qd("<!---->"),D=C.ownerDocument.importNode(U,!0),D.nodeType===Ss.element&&D.nodeName==="BODY"||D.nodeName==="HTML"?C=D:C.appendChild(D);else{if(!Gr&&!jr&&!nr&&U.indexOf("<")===-1)return N&&sa?N.createHTML(U):U;if(C=Qd(U),!C)return Gr?null:sa?F:""}C&&uc&&Pt(C.firstChild);const ye=ep(us?U:C);for(;ce=ye.nextNode();)np(ce),sp(ce),ce.content instanceof s&&t0(ce.content);if(us)return U;if(Gr){if(ia)for(Ne=oe.call(C.ownerDocument);C.firstChild;)Ne.appendChild(C.firstChild);else Ne=C;return(Pe.shadowroot||Pe.shadowrootmode)&&(Ne=er.call(r,Ne,!0)),Ne}let Xe=nr?C.outerHTML:C.innerHTML;return nr&&$e["!doctype"]&&C.ownerDocument&&C.ownerDocument.doctype&&C.ownerDocument.doctype.name&&We(xw,C.ownerDocument.doctype.name)&&(Xe="<!DOCTYPE "+C.ownerDocument.doctype.name+`>
|
|
445
|
+
`+Xe),jr&&xa([tr,Ct,En],on=>{Xe=ys(Xe,on," ")}),N&&sa?N.createHTML(Xe):Xe},t.setConfig=function(){let U=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};mc(U),cc=!0},t.clearConfig=function(){Xr=null,cc=!1},t.isValidAttribute=function(U,b,C){Xr||mc({});const D=_e(U),ce=_e(b);return rp(D,ce,C)},t.addHook=function(U,b){typeof b=="function"&&vs(Re[U],b)},t.removeHook=function(U,b){if(b!==void 0){const C=VO(Re[U],b);return C===-1?void 0:BO(Re[U],C,1)[0]}return Yg(Re[U])},t.removeHooks=function(U){Re[U]=[]},t.removeAllHooks=function(){Re=tm()},t}var Aw=Ew();function Ad(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Br=Ad();function $w(n){Br=n}var hr={exec:()=>null};function K(n,t=""){let e=typeof n=="string"?n:n.source,r={replace:(i,s)=>{let o=typeof s=="string"?s:s.source;return o=o.replace(Ge.caret,"$1"),e=e.replace(i,o),r},getRegex:()=>new RegExp(e,t)};return r}var lM=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),Ge={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:n=>new RegExp(`^( {0,3}${n})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}#`),htmlBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}<(?:[a-z].*>|!--)`,"i"),blockquoteBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}>`)},cM=/^(?:[ \t]*(?:\n|$))+/,uM=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,hM=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,ea=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,dM=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,$d=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Tw=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Iw=K(Tw).replace(/bull/g,$d).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(),pM=K(Tw).replace(/bull/g,$d).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(),Td=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,fM=/^[^\n]+/,Id=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,gM=K(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Id).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),mM=K(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,$d).getRegex(),sc="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",Cd=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,vM=K("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",Cd).replace("tag",sc).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Cw=K(Td).replace("hr",ea).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",sc).getRegex(),yM=K(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Cw).getRegex(),Rd={blockquote:yM,code:uM,def:gM,fences:hM,heading:dM,hr:ea,html:vM,lheading:Iw,list:mM,newline:cM,paragraph:Cw,table:hr,text:fM},nm=K("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",ea).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",sc).getRegex(),bM={...Rd,lheading:pM,table:nm,paragraph:K(Td).replace("hr",ea).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",nm).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",sc).getRegex()},wM={...Rd,html:K(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Cd).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:hr,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:K(Td).replace("hr",ea).replace("heading",` *#{1,6} *[^
|
|
446
|
+
]`).replace("lheading",Iw).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},SM=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,_M=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Rw=/^( {2,}|\\)\n(?!\s*$)/,kM=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,ls=/[\p{P}\p{S}]/u,oc=/[\s\p{P}\p{S}]/u,Pd=/[^\s\p{P}\p{S}]/u,xM=K(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,oc).getRegex(),Pw=/(?!~)[\p{P}\p{S}]/u,EM=/(?!~)[\s\p{P}\p{S}]/u,AM=/(?:[^\s\p{P}\p{S}]|~)/u,$M=K(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",lM?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Dw=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,TM=K(Dw,"u").replace(/punct/g,ls).getRegex(),IM=K(Dw,"u").replace(/punct/g,Pw).getRegex(),Lw="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",CM=K(Lw,"gu").replace(/notPunctSpace/g,Pd).replace(/punctSpace/g,oc).replace(/punct/g,ls).getRegex(),RM=K(Lw,"gu").replace(/notPunctSpace/g,AM).replace(/punctSpace/g,EM).replace(/punct/g,Pw).getRegex(),PM=K("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Pd).replace(/punctSpace/g,oc).replace(/punct/g,ls).getRegex(),DM=K(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,ls).getRegex(),LM="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",zM=K(LM,"gu").replace(/notPunctSpace/g,Pd).replace(/punctSpace/g,oc).replace(/punct/g,ls).getRegex(),OM=K(/\\(punct)/,"gu").replace(/punct/g,ls).getRegex(),MM=K(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),NM=K(Cd).replace("(?:-->|$)","-->").getRegex(),UM=K("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",NM).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),bl=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,FM=K(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",bl).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),zw=K(/^!?\[(label)\]\[(ref)\]/).replace("label",bl).replace("ref",Id).getRegex(),Ow=K(/^!?\[(ref)\](?:\[\])?/).replace("ref",Id).getRegex(),HM=K("reflink|nolink(?!\\()","g").replace("reflink",zw).replace("nolink",Ow).getRegex(),rm=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Dd={_backpedal:hr,anyPunctuation:OM,autolink:MM,blockSkip:$M,br:Rw,code:_M,del:hr,delLDelim:hr,delRDelim:hr,emStrongLDelim:TM,emStrongRDelimAst:CM,emStrongRDelimUnd:PM,escape:SM,link:FM,nolink:Ow,punctuation:xM,reflink:zw,reflinkSearch:HM,tag:UM,text:kM,url:hr},WM={...Dd,link:K(/^!?\[(label)\]\((.*?)\)/).replace("label",bl).getRegex(),reflink:K(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",bl).getRegex()},_h={...Dd,emStrongRDelimAst:RM,emStrongLDelim:IM,delLDelim:DM,delRDelim:zM,url:K(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",rm).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:K(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",rm).getRegex()},ZM={..._h,br:K(Rw).replace("{2,}","*").getRegex(),text:K(_h.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Aa={normal:Rd,gfm:bM,pedantic:wM},_s={normal:Dd,gfm:_h,breaks:ZM,pedantic:WM},VM={"&":"&","<":"<",">":">",'"':""","'":"'"},im=n=>VM[n];function Ot(n,t){if(t){if(Ge.escapeTest.test(n))return n.replace(Ge.escapeReplace,im)}else if(Ge.escapeTestNoEncode.test(n))return n.replace(Ge.escapeReplaceNoEncode,im);return n}function sm(n){try{n=encodeURI(n).replace(Ge.percentDecode,"%")}catch{return null}return n}function om(n,t){var s;let e=n.replace(Ge.findPipe,(o,a,c)=>{let u=!1,h=a;for(;--h>=0&&c[h]==="\\";)u=!u;return u?"|":" |"}),r=e.split(Ge.splitPipe),i=0;if(r[0].trim()||r.shift(),r.length>0&&!((s=r.at(-1))!=null&&s.trim())&&r.pop(),t)if(r.length>t)r.splice(t);else for(;r.length<t;)r.push("");for(;i<r.length;i++)r[i]=r[i].trim().replace(Ge.slashPipe,"|");return r}function ks(n,t,e){let r=n.length;if(r===0)return"";let i=0;for(;i<r&&n.charAt(r-i-1)===t;)i++;return n.slice(0,r-i)}function BM(n,t){if(n.indexOf(t[1])===-1)return-1;let e=0;for(let r=0;r<n.length;r++)if(n[r]==="\\")r++;else if(n[r]===t[0])e++;else if(n[r]===t[1]&&(e--,e<0))return r;return e>0?-2:-1}function jM(n,t=0){let e=t,r="";for(let i of n)if(i===" "){let s=4-e%4;r+=" ".repeat(s),e+=s}else r+=i,e++;return r}function am(n,t,e,r,i){let s=t.href,o=t.title||null,a=n[1].replace(i.other.outputLinkReplace,"$1");r.state.inLink=!0;let c={type:n[0].charAt(0)==="!"?"image":"link",raw:e,href:s,title:o,text:a,tokens:r.inlineTokens(a)};return r.state.inLink=!1,c}function GM(n,t,e){let r=n.match(e.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
|
|
345
447
|
`).map(s=>{let o=s.match(e.other.beginningSpace);if(o===null)return s;let[a]=o;return a.length>=i.length?s.slice(i.length):s}).join(`
|
|
346
|
-
`)}var
|
|
347
|
-
`)}}}fences(n){let t=this.rules.block.fences.exec(n);if(t){let e=t[0],r=
|
|
348
|
-
`)}}blockquote(n){let t=this.rules.block.blockquote.exec(n);if(t){let e=
|
|
448
|
+
`)}var wl=class{constructor(n){g(this,"options");g(this,"rules");g(this,"lexer");this.options=n||Br}space(n){let t=this.rules.block.newline.exec(n);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(n){let t=this.rules.block.code.exec(n);if(t){let e=t[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?e:ks(e,`
|
|
449
|
+
`)}}}fences(n){let t=this.rules.block.fences.exec(n);if(t){let e=t[0],r=GM(e,t[3]||"",this.rules);return{type:"code",raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:r}}}heading(n){let t=this.rules.block.heading.exec(n);if(t){let e=t[2].trim();if(this.rules.other.endingHash.test(e)){let r=ks(e,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(e=r.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(n){let t=this.rules.block.hr.exec(n);if(t)return{type:"hr",raw:ks(t[0],`
|
|
450
|
+
`)}}blockquote(n){let t=this.rules.block.blockquote.exec(n);if(t){let e=ks(t[0],`
|
|
349
451
|
`).split(`
|
|
350
452
|
`),r="",i="",s=[];for(;e.length>0;){let o=!1,a=[],c;for(c=0;c<e.length;c++)if(this.rules.other.blockquoteStart.test(e[c]))a.push(e[c]),o=!0;else if(!o)a.push(e[c]);else break;e=e.slice(c);let u=a.join(`
|
|
351
453
|
`),h=u.replace(this.rules.other.blockquoteSetextReplace,`
|
|
@@ -356,16 +458,16 @@ ${h}`:h;let p=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTo
|
|
|
356
458
|
`),k=this.blockquote(_);s[s.length-1]=k,r=r.substring(0,r.length-m.raw.length)+k.raw,i=i.substring(0,i.length-m.text.length)+k.text;break}else if((v==null?void 0:v.type)==="list"){let m=v,_=m.raw+`
|
|
357
459
|
`+e.join(`
|
|
358
460
|
`),k=this.list(_);s[s.length-1]=k,r=r.substring(0,r.length-v.raw.length)+k.raw,i=i.substring(0,i.length-m.raw.length)+k.raw,e=_.substring(s.at(-1).raw.length).split(`
|
|
359
|
-
`);continue}}return{type:"blockquote",raw:r,tokens:s,text:i}}}list(n){var e,r;let t=this.rules.block.list.exec(n);if(t){let i=t[1].trim(),s=i.length>1,o={type:"list",raw:"",ordered:s,start:s?+i.slice(0,-1):"",loose:!1,items:[]};i=s?`\\d{1,9}\\${i.slice(-1)}`:`\\${i}`,this.options.pedantic&&(i=s?i:"[*+-]");let a=this.rules.other.listItemRegex(i),c=!1;for(;n;){let h=!1,p="",v="";if(!(t=a.exec(n))||this.rules.block.hr.test(n))break;p=t[0],n=n.substring(p.length);let m=
|
|
461
|
+
`);continue}}return{type:"blockquote",raw:r,tokens:s,text:i}}}list(n){var e,r;let t=this.rules.block.list.exec(n);if(t){let i=t[1].trim(),s=i.length>1,o={type:"list",raw:"",ordered:s,start:s?+i.slice(0,-1):"",loose:!1,items:[]};i=s?`\\d{1,9}\\${i.slice(-1)}`:`\\${i}`,this.options.pedantic&&(i=s?i:"[*+-]");let a=this.rules.other.listItemRegex(i),c=!1;for(;n;){let h=!1,p="",v="";if(!(t=a.exec(n))||this.rules.block.hr.test(n))break;p=t[0],n=n.substring(p.length);let m=jM(t[2].split(`
|
|
360
462
|
`,1)[0],t[1].length),_=n.split(`
|
|
361
463
|
`,1)[0],k=!m.trim(),T=0;if(this.options.pedantic?(T=2,v=m.trimStart()):k?T=t[1].length+1:(T=m.search(this.rules.other.nonSpaceChar),T=T>4?1:T,v=m.slice(T),T+=t[1].length),k&&this.rules.other.blankLine.test(_)&&(p+=_+`
|
|
362
464
|
`,n=n.substring(_.length+1),h=!0),!h){let P=this.rules.other.nextBulletRegex(T),R=this.rules.other.hrRegex(T),W=this.rules.other.fencesBeginRegex(T),N=this.rules.other.headingBeginRegex(T),F=this.rules.other.htmlBeginRegex(T),Y=this.rules.other.blockquoteBeginRegex(T);for(;n;){let j=n.split(`
|
|
363
465
|
`,1)[0],oe;if(_=j,this.options.pedantic?(_=_.replace(this.rules.other.listReplaceNesting," "),oe=_):oe=_.replace(this.rules.other.tabCharGlobal," "),W.test(_)||N.test(_)||F.test(_)||Y.test(_)||P.test(_)||R.test(_))break;if(oe.search(this.rules.other.nonSpaceChar)>=T||!_.trim())v+=`
|
|
364
466
|
`+oe.slice(T);else{if(k||m.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||W.test(m)||N.test(m)||R.test(m))break;v+=`
|
|
365
467
|
`+_}k=!_.trim(),p+=j+`
|
|
366
|
-
`,n=n.substring(j.length+1),m=oe.slice(T)}}o.loose||(c?o.loose=!0:this.rules.other.doubleBlankLine.test(p)&&(c=!0)),o.items.push({type:"list_item",raw:p,task:!!this.options.gfm&&this.rules.other.listIsTask.test(v),loose:!1,text:v,tokens:[]}),o.raw+=p}let u=o.items.at(-1);if(u)u.raw=u.raw.trimEnd(),u.text=u.text.trimEnd();else return;o.raw=o.raw.trimEnd();for(let h of o.items){if(this.lexer.state.top=!1,h.tokens=this.lexer.blockTokens(h.text,[]),h.task){if(h.text=h.text.replace(this.rules.other.listReplaceTask,""),((e=h.tokens[0])==null?void 0:e.type)==="text"||((r=h.tokens[0])==null?void 0:r.type)==="paragraph"){h.tokens[0].raw=h.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),h.tokens[0].text=h.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let v=this.lexer.inlineQueue.length-1;v>=0;v--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[v].src)){this.lexer.inlineQueue[v].src=this.lexer.inlineQueue[v].src.replace(this.rules.other.listReplaceTask,"");break}}let p=this.rules.other.listTaskCheckbox.exec(h.raw);if(p){let v={type:"checkbox",raw:p[0]+" ",checked:p[0]!=="[ ]"};h.checked=v.checked,o.loose?h.tokens[0]&&["paragraph","text"].includes(h.tokens[0].type)&&"tokens"in h.tokens[0]&&h.tokens[0].tokens?(h.tokens[0].raw=v.raw+h.tokens[0].raw,h.tokens[0].text=v.raw+h.tokens[0].text,h.tokens[0].tokens.unshift(v)):h.tokens.unshift({type:"paragraph",raw:v.raw,text:v.raw,tokens:[v]}):h.tokens.unshift(v)}}if(!o.loose){let p=h.tokens.filter(m=>m.type==="space"),v=p.length>0&&p.some(m=>this.rules.other.anyLine.test(m.raw));o.loose=v}}if(o.loose)for(let h of o.items){h.loose=!0;for(let p of h.tokens)p.type==="text"&&(p.type="paragraph")}return o}}html(n){let t=this.rules.block.html.exec(n);if(t)return{type:"html",block:!0,raw:t[0],pre:t[1]==="pre"||t[1]==="script"||t[1]==="style",text:t[0]}}def(n){let t=this.rules.block.def.exec(n);if(t){let e=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),r=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",i=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:e,raw:t[0],href:r,title:i}}}table(n){var o;let t=this.rules.block.table.exec(n);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let e=
|
|
367
|
-
`):[],s={type:"table",raw:t[0],header:[],align:[],rows:[]};if(e.length===r.length){for(let a of r)this.rules.other.tableAlignRight.test(a)?s.align.push("right"):this.rules.other.tableAlignCenter.test(a)?s.align.push("center"):this.rules.other.tableAlignLeft.test(a)?s.align.push("left"):s.align.push(null);for(let a=0;a<e.length;a++)s.header.push({text:e[a],tokens:this.lexer.inline(e[a]),header:!0,align:s.align[a]});for(let a of i)s.rows.push(
|
|
368
|
-
`?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(n){let t=this.rules.block.text.exec(n);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(n){let t=this.rules.inline.escape.exec(n);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(n){let t=this.rules.inline.tag.exec(n);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(n){let t=this.rules.inline.link.exec(n);if(t){let e=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(e)){if(!this.rules.other.endAngleBracket.test(e))return;let s=
|
|
468
|
+
`,n=n.substring(j.length+1),m=oe.slice(T)}}o.loose||(c?o.loose=!0:this.rules.other.doubleBlankLine.test(p)&&(c=!0)),o.items.push({type:"list_item",raw:p,task:!!this.options.gfm&&this.rules.other.listIsTask.test(v),loose:!1,text:v,tokens:[]}),o.raw+=p}let u=o.items.at(-1);if(u)u.raw=u.raw.trimEnd(),u.text=u.text.trimEnd();else return;o.raw=o.raw.trimEnd();for(let h of o.items){if(this.lexer.state.top=!1,h.tokens=this.lexer.blockTokens(h.text,[]),h.task){if(h.text=h.text.replace(this.rules.other.listReplaceTask,""),((e=h.tokens[0])==null?void 0:e.type)==="text"||((r=h.tokens[0])==null?void 0:r.type)==="paragraph"){h.tokens[0].raw=h.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),h.tokens[0].text=h.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let v=this.lexer.inlineQueue.length-1;v>=0;v--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[v].src)){this.lexer.inlineQueue[v].src=this.lexer.inlineQueue[v].src.replace(this.rules.other.listReplaceTask,"");break}}let p=this.rules.other.listTaskCheckbox.exec(h.raw);if(p){let v={type:"checkbox",raw:p[0]+" ",checked:p[0]!=="[ ]"};h.checked=v.checked,o.loose?h.tokens[0]&&["paragraph","text"].includes(h.tokens[0].type)&&"tokens"in h.tokens[0]&&h.tokens[0].tokens?(h.tokens[0].raw=v.raw+h.tokens[0].raw,h.tokens[0].text=v.raw+h.tokens[0].text,h.tokens[0].tokens.unshift(v)):h.tokens.unshift({type:"paragraph",raw:v.raw,text:v.raw,tokens:[v]}):h.tokens.unshift(v)}}if(!o.loose){let p=h.tokens.filter(m=>m.type==="space"),v=p.length>0&&p.some(m=>this.rules.other.anyLine.test(m.raw));o.loose=v}}if(o.loose)for(let h of o.items){h.loose=!0;for(let p of h.tokens)p.type==="text"&&(p.type="paragraph")}return o}}html(n){let t=this.rules.block.html.exec(n);if(t)return{type:"html",block:!0,raw:t[0],pre:t[1]==="pre"||t[1]==="script"||t[1]==="style",text:t[0]}}def(n){let t=this.rules.block.def.exec(n);if(t){let e=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),r=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",i=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:e,raw:t[0],href:r,title:i}}}table(n){var o;let t=this.rules.block.table.exec(n);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let e=om(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),i=(o=t[3])!=null&&o.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
469
|
+
`):[],s={type:"table",raw:t[0],header:[],align:[],rows:[]};if(e.length===r.length){for(let a of r)this.rules.other.tableAlignRight.test(a)?s.align.push("right"):this.rules.other.tableAlignCenter.test(a)?s.align.push("center"):this.rules.other.tableAlignLeft.test(a)?s.align.push("left"):s.align.push(null);for(let a=0;a<e.length;a++)s.header.push({text:e[a],tokens:this.lexer.inline(e[a]),header:!0,align:s.align[a]});for(let a of i)s.rows.push(om(a,s.header.length).map((c,u)=>({text:c,tokens:this.lexer.inline(c),header:!1,align:s.align[u]})));return s}}lheading(n){let t=this.rules.block.lheading.exec(n);if(t){let e=t[1].trim();return{type:"heading",raw:t[0],depth:t[2].charAt(0)==="="?1:2,text:e,tokens:this.lexer.inline(e)}}}paragraph(n){let t=this.rules.block.paragraph.exec(n);if(t){let e=t[1].charAt(t[1].length-1)===`
|
|
470
|
+
`?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(n){let t=this.rules.block.text.exec(n);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(n){let t=this.rules.inline.escape.exec(n);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(n){let t=this.rules.inline.tag.exec(n);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(n){let t=this.rules.inline.link.exec(n);if(t){let e=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(e)){if(!this.rules.other.endAngleBracket.test(e))return;let s=ks(e.slice(0,-1),"\\");if((e.length-s.length)%2===0)return}else{let s=BM(t[2],"()");if(s===-2)return;if(s>-1){let o=(t[0].indexOf("!")===0?5:4)+t[1].length+s;t[2]=t[2].substring(0,s),t[0]=t[0].substring(0,o).trim(),t[3]=""}}let r=t[2],i="";if(this.options.pedantic){let s=this.rules.other.pedanticHrefTitle.exec(r);s&&(r=s[1],i=s[3])}else i=t[3]?t[3].slice(1,-1):"";return r=r.trim(),this.rules.other.startAngleBracket.test(r)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(e)?r=r.slice(1):r=r.slice(1,-1)),am(t,{href:r&&r.replace(this.rules.inline.anyPunctuation,"$1"),title:i&&i.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(n,t){let e;if((e=this.rules.inline.reflink.exec(n))||(e=this.rules.inline.nolink.exec(n))){let r=(e[2]||e[1]).replace(this.rules.other.multipleSpaceGlobal," "),i=t[r.toLowerCase()];if(!i){let s=e[0].charAt(0);return{type:"text",raw:s,text:s}}return am(e,i,e[0],this.lexer,this.rules)}}emStrong(n,t,e=""){let r=this.rules.inline.emStrongLDelim.exec(n);if(!(!r||!r[1]&&!r[2]&&!r[3]&&!r[4]||r[4]&&e.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[3])||!e||this.rules.inline.punctuation.exec(e))){let i=[...r[0]].length-1,s,o,a=i,c=0,u=r[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(u.lastIndex=0,t=t.slice(-1*n.length+i);(r=u.exec(t))!=null;){if(s=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!s)continue;if(o=[...s].length,r[3]||r[4]){a+=o;continue}else if((r[5]||r[6])&&i%3&&!((i+o)%3)){c+=o;continue}if(a-=o,a>0)continue;o=Math.min(o,o+a+c);let h=[...r[0]][0].length,p=n.slice(0,i+r.index+h+o);if(Math.min(i,o)%2){let m=p.slice(1,-1);return{type:"em",raw:p,text:m,tokens:this.lexer.inlineTokens(m)}}let v=p.slice(2,-2);return{type:"strong",raw:p,text:v,tokens:this.lexer.inlineTokens(v)}}}}codespan(n){let t=this.rules.inline.code.exec(n);if(t){let e=t[2].replace(this.rules.other.newLineCharGlobal," "),r=this.rules.other.nonSpaceChar.test(e),i=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return r&&i&&(e=e.substring(1,e.length-1)),{type:"codespan",raw:t[0],text:e}}}br(n){let t=this.rules.inline.br.exec(n);if(t)return{type:"br",raw:t[0]}}del(n,t,e=""){let r=this.rules.inline.delLDelim.exec(n);if(r&&(!r[1]||!e||this.rules.inline.punctuation.exec(e))){let i=[...r[0]].length-1,s,o,a=i,c=this.rules.inline.delRDelim;for(c.lastIndex=0,t=t.slice(-1*n.length+i);(r=c.exec(t))!=null;){if(s=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!s||(o=[...s].length,o!==i))continue;if(r[3]||r[4]){a+=o;continue}if(a-=o,a>0)continue;o=Math.min(o,o+a);let u=[...r[0]][0].length,h=n.slice(0,i+r.index+u+o),p=h.slice(i,-i);return{type:"del",raw:h,text:p,tokens:this.lexer.inlineTokens(p)}}}}autolink(n){let t=this.rules.inline.autolink.exec(n);if(t){let e,r;return t[2]==="@"?(e=t[1],r="mailto:"+e):(e=t[1],r=e),{type:"link",raw:t[0],text:e,href:r,tokens:[{type:"text",raw:e,text:e}]}}}url(n){var e;let t;if(t=this.rules.inline.url.exec(n)){let r,i;if(t[2]==="@")r=t[0],i="mailto:"+r;else{let s;do s=t[0],t[0]=((e=this.rules.inline._backpedal.exec(t[0]))==null?void 0:e[0])??"";while(s!==t[0]);r=t[0],t[1]==="www."?i="http://"+t[0]:i=t[0]}return{type:"link",raw:t[0],text:r,href:i,tokens:[{type:"text",raw:r,text:r}]}}}inlineText(n){let t=this.rules.inline.text.exec(n);if(t){let e=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:e}}}},Tt=class kh{constructor(t){g(this,"tokens");g(this,"options");g(this,"state");g(this,"inlineQueue");g(this,"tokenizer");this.tokens=[],this.tokens.links=Object.create(null),this.options=t||Br,this.options.tokenizer=this.options.tokenizer||new wl,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 e={other:Ge,block:Aa.normal,inline:_s.normal};this.options.pedantic?(e.block=Aa.pedantic,e.inline=_s.pedantic):this.options.gfm&&(e.block=Aa.gfm,this.options.breaks?e.inline=_s.breaks:e.inline=_s.gfm),this.tokenizer.rules=e}static get rules(){return{block:Aa,inline:_s}}static lex(t,e){return new kh(e).lex(t)}static lexInline(t,e){return new kh(e).inlineTokens(t)}lex(t){t=t.replace(Ge.carriageReturn,`
|
|
369
471
|
`),this.blockTokens(t,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){let r=this.inlineQueue[e];this.inlineTokens(r.src,r.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(t,e=[],r=!1){var i,s,o;for(this.tokenizer.lexer=this,this.options.pedantic&&(t=t.replace(Ge.tabCharGlobal," ").replace(Ge.spaceLine,""));t;){let a;if((s=(i=this.options.extensions)==null?void 0:i.block)!=null&&s.some(u=>(a=u.call({lexer:this},t,e))?(t=t.substring(a.raw.length),e.push(a),!0):!1))continue;if(a=this.tokenizer.space(t)){t=t.substring(a.raw.length);let u=e.at(-1);a.raw.length===1&&u!==void 0?u.raw+=`
|
|
370
472
|
`:e.push(a);continue}if(a=this.tokenizer.code(t)){t=t.substring(a.raw.length);let u=e.at(-1);(u==null?void 0:u.type)==="paragraph"||(u==null?void 0:u.type)==="text"?(u.raw+=(u.raw.endsWith(`
|
|
371
473
|
`)?"":`
|
|
@@ -379,7 +481,7 @@ ${h}`:h;let p=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTo
|
|
|
379
481
|
`+a.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=u.text):e.push(a),r=c.length!==t.length,t=t.substring(a.raw.length);continue}if(a=this.tokenizer.text(t)){t=t.substring(a.raw.length);let u=e.at(-1);(u==null?void 0:u.type)==="text"?(u.raw+=(u.raw.endsWith(`
|
|
380
482
|
`)?"":`
|
|
381
483
|
`)+a.raw,u.text+=`
|
|
382
|
-
`+a.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=u.text):e.push(a);continue}if(t){let u="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(u);break}else throw new Error(u)}}return this.state.top=!0,e}inline(t,e=[]){return this.inlineQueue.push({src:t,tokens:e}),e}inlineTokens(t,e=[]){var c,u,h,p,v;this.tokenizer.lexer=this;let r=t,i=null;if(this.tokens.links){let m=Object.keys(this.tokens.links);if(m.length>0)for(;(i=this.tokenizer.rules.inline.reflinkSearch.exec(r))!=null;)m.includes(i[0].slice(i[0].lastIndexOf("[")+1,-1))&&(r=r.slice(0,i.index)+"["+"a".repeat(i[0].length-2)+"]"+r.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(i=this.tokenizer.rules.inline.anyPunctuation.exec(r))!=null;)r=r.slice(0,i.index)+"++"+r.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let s;for(;(i=this.tokenizer.rules.inline.blockSkip.exec(r))!=null;)s=i[2]?i[2].length:0,r=r.slice(0,i.index+s)+"["+"a".repeat(i[0].length-s-2)+"]"+r.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);r=((u=(c=this.options.hooks)==null?void 0:c.emStrongMask)==null?void 0:u.call({lexer:this},r))??r;let o=!1,a="";for(;t;){o||(a=""),o=!1;let m;if((p=(h=this.options.extensions)==null?void 0:h.inline)!=null&&p.some(k=>(m=k.call({lexer:this},t,e))?(t=t.substring(m.raw.length),e.push(m),!0):!1))continue;if(m=this.tokenizer.escape(t)){t=t.substring(m.raw.length),e.push(m);continue}if(m=this.tokenizer.tag(t)){t=t.substring(m.raw.length),e.push(m);continue}if(m=this.tokenizer.link(t)){t=t.substring(m.raw.length),e.push(m);continue}if(m=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(m.raw.length);let k=e.at(-1);m.type==="text"&&(k==null?void 0:k.type)==="text"?(k.raw+=m.raw,k.text+=m.text):e.push(m);continue}if(m=this.tokenizer.emStrong(t,r,a)){t=t.substring(m.raw.length),e.push(m);continue}if(m=this.tokenizer.codespan(t)){t=t.substring(m.raw.length),e.push(m);continue}if(m=this.tokenizer.br(t)){t=t.substring(m.raw.length),e.push(m);continue}if(m=this.tokenizer.del(t,r,a)){t=t.substring(m.raw.length),e.push(m);continue}if(m=this.tokenizer.autolink(t)){t=t.substring(m.raw.length),e.push(m);continue}if(!this.state.inLink&&(m=this.tokenizer.url(t))){t=t.substring(m.raw.length),e.push(m);continue}let _=t;if((v=this.options.extensions)!=null&&v.startInline){let k=1/0,T=t.slice(1),P;this.options.extensions.startInline.forEach(R=>{P=R.call({lexer:this},T),typeof P=="number"&&P>=0&&(k=Math.min(k,P))}),k<1/0&&k>=0&&(_=t.substring(0,k+1))}if(m=this.tokenizer.inlineText(_)){t=t.substring(m.raw.length),m.raw.slice(-1)!=="_"&&(a=m.raw.slice(-1)),o=!0;let k=e.at(-1);(k==null?void 0:k.type)==="text"?(k.raw+=m.raw,k.text+=m.text):e.push(m);continue}if(t){let k="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(k);break}else throw new Error(k)}}return e}},
|
|
484
|
+
`+a.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=u.text):e.push(a);continue}if(t){let u="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(u);break}else throw new Error(u)}}return this.state.top=!0,e}inline(t,e=[]){return this.inlineQueue.push({src:t,tokens:e}),e}inlineTokens(t,e=[]){var c,u,h,p,v;this.tokenizer.lexer=this;let r=t,i=null;if(this.tokens.links){let m=Object.keys(this.tokens.links);if(m.length>0)for(;(i=this.tokenizer.rules.inline.reflinkSearch.exec(r))!=null;)m.includes(i[0].slice(i[0].lastIndexOf("[")+1,-1))&&(r=r.slice(0,i.index)+"["+"a".repeat(i[0].length-2)+"]"+r.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(i=this.tokenizer.rules.inline.anyPunctuation.exec(r))!=null;)r=r.slice(0,i.index)+"++"+r.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let s;for(;(i=this.tokenizer.rules.inline.blockSkip.exec(r))!=null;)s=i[2]?i[2].length:0,r=r.slice(0,i.index+s)+"["+"a".repeat(i[0].length-s-2)+"]"+r.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);r=((u=(c=this.options.hooks)==null?void 0:c.emStrongMask)==null?void 0:u.call({lexer:this},r))??r;let o=!1,a="";for(;t;){o||(a=""),o=!1;let m;if((p=(h=this.options.extensions)==null?void 0:h.inline)!=null&&p.some(k=>(m=k.call({lexer:this},t,e))?(t=t.substring(m.raw.length),e.push(m),!0):!1))continue;if(m=this.tokenizer.escape(t)){t=t.substring(m.raw.length),e.push(m);continue}if(m=this.tokenizer.tag(t)){t=t.substring(m.raw.length),e.push(m);continue}if(m=this.tokenizer.link(t)){t=t.substring(m.raw.length),e.push(m);continue}if(m=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(m.raw.length);let k=e.at(-1);m.type==="text"&&(k==null?void 0:k.type)==="text"?(k.raw+=m.raw,k.text+=m.text):e.push(m);continue}if(m=this.tokenizer.emStrong(t,r,a)){t=t.substring(m.raw.length),e.push(m);continue}if(m=this.tokenizer.codespan(t)){t=t.substring(m.raw.length),e.push(m);continue}if(m=this.tokenizer.br(t)){t=t.substring(m.raw.length),e.push(m);continue}if(m=this.tokenizer.del(t,r,a)){t=t.substring(m.raw.length),e.push(m);continue}if(m=this.tokenizer.autolink(t)){t=t.substring(m.raw.length),e.push(m);continue}if(!this.state.inLink&&(m=this.tokenizer.url(t))){t=t.substring(m.raw.length),e.push(m);continue}let _=t;if((v=this.options.extensions)!=null&&v.startInline){let k=1/0,T=t.slice(1),P;this.options.extensions.startInline.forEach(R=>{P=R.call({lexer:this},T),typeof P=="number"&&P>=0&&(k=Math.min(k,P))}),k<1/0&&k>=0&&(_=t.substring(0,k+1))}if(m=this.tokenizer.inlineText(_)){t=t.substring(m.raw.length),m.raw.slice(-1)!=="_"&&(a=m.raw.slice(-1)),o=!0;let k=e.at(-1);(k==null?void 0:k.type)==="text"?(k.raw+=m.raw,k.text+=m.text):e.push(m);continue}if(t){let k="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(k);break}else throw new Error(k)}}return e}},Sl=class{constructor(n){g(this,"options");g(this,"parser");this.options=n||Br}space(n){return""}code({text:n,lang:t,escaped:e}){var s;let r=(s=(t||"").match(Ge.notSpaceStart))==null?void 0:s[0],i=n.replace(Ge.endingNewline,"")+`
|
|
383
485
|
`;return r?'<pre><code class="language-'+Ot(r)+'">'+(e?i:Ot(i,!0))+`</code></pre>
|
|
384
486
|
`:"<pre><code>"+(e?i:Ot(i,!0))+`</code></pre>
|
|
385
487
|
`}blockquote({tokens:n}){return`<blockquote>
|
|
@@ -397,8 +499,8 @@ ${this.parser.parse(n)}</blockquote>
|
|
|
397
499
|
`}tablerow({text:n}){return`<tr>
|
|
398
500
|
${n}</tr>
|
|
399
501
|
`}tablecell(n){let t=this.parser.parseInline(n.tokens),e=n.header?"th":"td";return(n.align?`<${e} align="${n.align}">`:`<${e}>`)+t+`</${e}>
|
|
400
|
-
`}strong({tokens:n}){return`<strong>${this.parser.parseInline(n)}</strong>`}em({tokens:n}){return`<em>${this.parser.parseInline(n)}</em>`}codespan({text:n}){return`<code>${Ot(n,!0)}</code>`}br(n){return"<br>"}del({tokens:n}){return`<del>${this.parser.parseInline(n)}</del>`}link({href:n,title:t,tokens:e}){let r=this.parser.parseInline(e),i=
|
|
401
|
-
Please report this to https://github.com/markedjs/marked.`,n){let r="<p>An error occurred:</p><pre>"+Ot(e.message+"",!0)+"</pre>";return t?Promise.resolve(r):r}if(t)return Promise.reject(e);throw e}}},Fr=new
|
|
502
|
+
`}strong({tokens:n}){return`<strong>${this.parser.parseInline(n)}</strong>`}em({tokens:n}){return`<em>${this.parser.parseInline(n)}</em>`}codespan({text:n}){return`<code>${Ot(n,!0)}</code>`}br(n){return"<br>"}del({tokens:n}){return`<del>${this.parser.parseInline(n)}</del>`}link({href:n,title:t,tokens:e}){let r=this.parser.parseInline(e),i=sm(n);if(i===null)return r;n=i;let s='<a href="'+n+'"';return t&&(s+=' title="'+Ot(t)+'"'),s+=">"+r+"</a>",s}image({href:n,title:t,text:e,tokens:r}){r&&(e=this.parser.parseInline(r,this.parser.textRenderer));let i=sm(n);if(i===null)return Ot(e);n=i;let s=`<img src="${n}" alt="${Ot(e)}"`;return t&&(s+=` title="${Ot(t)}"`),s+=">",s}text(n){return"tokens"in n&&n.tokens?this.parser.parseInline(n.tokens):"escaped"in n&&n.escaped?n.text:Ot(n.text)}},Ld=class{strong({text:n}){return n}em({text:n}){return n}codespan({text:n}){return n}del({text:n}){return n}html({text:n}){return n}text({text:n}){return n}link({text:n}){return""+n}image({text:n}){return""+n}br(){return""}checkbox({raw:n}){return n}},It=class xh{constructor(t){g(this,"options");g(this,"renderer");g(this,"textRenderer");this.options=t||Br,this.options.renderer=this.options.renderer||new Sl,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Ld}static parse(t,e){return new xh(e).parse(t)}static parseInline(t,e){return new xh(e).parseInline(t)}parse(t){var r,i;this.renderer.parser=this;let e="";for(let s=0;s<t.length;s++){let o=t[s];if((i=(r=this.options.extensions)==null?void 0:r.renderers)!=null&&i[o.type]){let c=o,u=this.options.extensions.renderers[c.type].call({parser:this},c);if(u!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(c.type)){e+=u||"";continue}}let a=o;switch(a.type){case"space":{e+=this.renderer.space(a);break}case"hr":{e+=this.renderer.hr(a);break}case"heading":{e+=this.renderer.heading(a);break}case"code":{e+=this.renderer.code(a);break}case"table":{e+=this.renderer.table(a);break}case"blockquote":{e+=this.renderer.blockquote(a);break}case"list":{e+=this.renderer.list(a);break}case"checkbox":{e+=this.renderer.checkbox(a);break}case"html":{e+=this.renderer.html(a);break}case"def":{e+=this.renderer.def(a);break}case"paragraph":{e+=this.renderer.paragraph(a);break}case"text":{e+=this.renderer.text(a);break}default:{let c='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(c),"";throw new Error(c)}}}return e}parseInline(t,e=this.renderer){var i,s;this.renderer.parser=this;let r="";for(let o=0;o<t.length;o++){let a=t[o];if((s=(i=this.options.extensions)==null?void 0:i.renderers)!=null&&s[a.type]){let u=this.options.extensions.renderers[a.type].call({parser:this},a);if(u!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(a.type)){r+=u||"";continue}}let c=a;switch(c.type){case"escape":{r+=e.text(c);break}case"html":{r+=e.html(c);break}case"link":{r+=e.link(c);break}case"image":{r+=e.image(c);break}case"checkbox":{r+=e.checkbox(c);break}case"strong":{r+=e.strong(c);break}case"em":{r+=e.em(c);break}case"codespan":{r+=e.codespan(c);break}case"br":{r+=e.br(c);break}case"del":{r+=e.del(c);break}case"text":{r+=e.text(c);break}default:{let u='Token with "'+c.type+'" type was not found.';if(this.options.silent)return console.error(u),"";throw new Error(u)}}}return r}},$a,Ps=($a=class{constructor(n){g(this,"options");g(this,"block");this.options=n||Br}preprocess(n){return n}postprocess(n){return n}processAllTokens(n){return n}emStrongMask(n){return n}provideLexer(){return this.block?Tt.lex:Tt.lexInline}provideParser(){return this.block?It.parse:It.parseInline}},g($a,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),g($a,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),$a),qM=class{constructor(...n){g(this,"defaults",Ad());g(this,"options",this.setOptions);g(this,"parse",this.parseMarkdown(!0));g(this,"parseInline",this.parseMarkdown(!1));g(this,"Parser",It);g(this,"Renderer",Sl);g(this,"TextRenderer",Ld);g(this,"Lexer",Tt);g(this,"Tokenizer",wl);g(this,"Hooks",Ps);this.use(...n)}walkTokens(n,t){var r,i;let e=[];for(let s of n)switch(e=e.concat(t.call(this,s)),s.type){case"table":{let o=s;for(let a of o.header)e=e.concat(this.walkTokens(a.tokens,t));for(let a of o.rows)for(let c of a)e=e.concat(this.walkTokens(c.tokens,t));break}case"list":{let o=s;e=e.concat(this.walkTokens(o.items,t));break}default:{let o=s;(i=(r=this.defaults.extensions)==null?void 0:r.childTokens)!=null&&i[o.type]?this.defaults.extensions.childTokens[o.type].forEach(a=>{let c=o[a].flat(1/0);e=e.concat(this.walkTokens(c,t))}):o.tokens&&(e=e.concat(this.walkTokens(o.tokens,t)))}}return e}use(...n){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return n.forEach(e=>{let r={...e};if(r.async=this.defaults.async||r.async||!1,e.extensions&&(e.extensions.forEach(i=>{if(!i.name)throw new Error("extension name required");if("renderer"in i){let s=t.renderers[i.name];s?t.renderers[i.name]=function(...o){let a=i.renderer.apply(this,o);return a===!1&&(a=s.apply(this,o)),a}:t.renderers[i.name]=i.renderer}if("tokenizer"in i){if(!i.level||i.level!=="block"&&i.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let s=t[i.level];s?s.unshift(i.tokenizer):t[i.level]=[i.tokenizer],i.start&&(i.level==="block"?t.startBlock?t.startBlock.push(i.start):t.startBlock=[i.start]:i.level==="inline"&&(t.startInline?t.startInline.push(i.start):t.startInline=[i.start]))}"childTokens"in i&&i.childTokens&&(t.childTokens[i.name]=i.childTokens)}),r.extensions=t),e.renderer){let i=this.defaults.renderer||new Sl(this.defaults);for(let s in e.renderer){if(!(s in i))throw new Error(`renderer '${s}' does not exist`);if(["options","parser"].includes(s))continue;let o=s,a=e.renderer[o],c=i[o];i[o]=(...u)=>{let h=a.apply(i,u);return h===!1&&(h=c.apply(i,u)),h||""}}r.renderer=i}if(e.tokenizer){let i=this.defaults.tokenizer||new wl(this.defaults);for(let s in e.tokenizer){if(!(s in i))throw new Error(`tokenizer '${s}' does not exist`);if(["options","rules","lexer"].includes(s))continue;let o=s,a=e.tokenizer[o],c=i[o];i[o]=(...u)=>{let h=a.apply(i,u);return h===!1&&(h=c.apply(i,u)),h}}r.tokenizer=i}if(e.hooks){let i=this.defaults.hooks||new Ps;for(let s in e.hooks){if(!(s in i))throw new Error(`hook '${s}' does not exist`);if(["options","block"].includes(s))continue;let o=s,a=e.hooks[o],c=i[o];Ps.passThroughHooks.has(s)?i[o]=u=>{if(this.defaults.async&&Ps.passThroughHooksRespectAsync.has(s))return(async()=>{let p=await a.call(i,u);return c.call(i,p)})();let h=a.call(i,u);return c.call(i,h)}:i[o]=(...u)=>{if(this.defaults.async)return(async()=>{let p=await a.apply(i,u);return p===!1&&(p=await c.apply(i,u)),p})();let h=a.apply(i,u);return h===!1&&(h=c.apply(i,u)),h}}r.hooks=i}if(e.walkTokens){let i=this.defaults.walkTokens,s=e.walkTokens;r.walkTokens=function(o){let a=[];return a.push(s.call(this,o)),i&&(a=a.concat(i.call(this,o))),a}}this.defaults={...this.defaults,...r}}),this}setOptions(n){return this.defaults={...this.defaults,...n},this}lexer(n,t){return Tt.lex(n,t??this.defaults)}parser(n,t){return It.parse(n,t??this.defaults)}parseMarkdown(n){return(t,e)=>{let r={...e},i={...this.defaults,...r},s=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return s(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof t>"u"||t===null)return s(new Error("marked(): input parameter is undefined or null"));if(typeof t!="string")return s(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(i.hooks&&(i.hooks.options=i,i.hooks.block=n),i.async)return(async()=>{let o=i.hooks?await i.hooks.preprocess(t):t,a=await(i.hooks?await i.hooks.provideLexer():n?Tt.lex:Tt.lexInline)(o,i),c=i.hooks?await i.hooks.processAllTokens(a):a;i.walkTokens&&await Promise.all(this.walkTokens(c,i.walkTokens));let u=await(i.hooks?await i.hooks.provideParser():n?It.parse:It.parseInline)(c,i);return i.hooks?await i.hooks.postprocess(u):u})().catch(s);try{i.hooks&&(t=i.hooks.preprocess(t));let o=(i.hooks?i.hooks.provideLexer():n?Tt.lex:Tt.lexInline)(t,i);i.hooks&&(o=i.hooks.processAllTokens(o)),i.walkTokens&&this.walkTokens(o,i.walkTokens);let a=(i.hooks?i.hooks.provideParser():n?It.parse:It.parseInline)(o,i);return i.hooks&&(a=i.hooks.postprocess(a)),a}catch(o){return s(o)}}}onError(n,t){return e=>{if(e.message+=`
|
|
503
|
+
Please report this to https://github.com/markedjs/marked.`,n){let r="<p>An error occurred:</p><pre>"+Ot(e.message+"",!0)+"</pre>";return t?Promise.resolve(r):r}if(t)return Promise.reject(e);throw e}}},Fr=new qM;function ee(n,t){return Fr.parse(n,t)}ee.options=ee.setOptions=function(n){return Fr.setOptions(n),ee.defaults=Fr.defaults,$w(ee.defaults),ee};ee.getDefaults=Ad;ee.defaults=Br;ee.use=function(...n){return Fr.use(...n),ee.defaults=Fr.defaults,$w(ee.defaults),ee};ee.walkTokens=function(n,t){return Fr.walkTokens(n,t)};ee.parseInline=Fr.parseInline;ee.Parser=It;ee.parser=It.parse;ee.Renderer=Sl;ee.TextRenderer=Ld;ee.Lexer=Tt;ee.lexer=Tt.lex;ee.Tokenizer=wl;ee.Hooks=Ps;ee.parse=ee;ee.options;ee.setOptions;ee.use;ee.walkTokens;ee.parseInline;It.parse;Tt.lex;Aw.addHook("afterSanitizeAttributes",n=>{n.tagName==="A"&&(n.setAttribute("target","_blank"),n.setAttribute("rel","noopener noreferrer"))});function YM(n){const t=ee.parse(n,{async:!1});return Aw.sanitize(t,{USE_PROFILES:{html:!0}})}var zo,bn,Xt,Kt,Zn,Mw,el;class Eh extends Xi{constructor(){super(...arguments);w(this,Zn);g(this,"phase","thinking");g(this,"toolCalls",[]);g(this,"expanded",!1);g(this,"expandedTexts",new Set);w(this,zo,`agent-activity-panel-${++JM}`);g(this,"overflowingTexts",new Set);w(this,bn,null);w(this,Xt,null);w(this,Kt,null);g(this,"handleToggle",()=>{this.toolCalls.length!==0&&(this.expanded=!this.expanded)})}changed(e){Ce(this.template(),this),f(this,Zn,Mw).call(this),l(this,Xt)!==null&&cancelAnimationFrame(l(this,Xt)),S(this,Xt,requestAnimationFrame(()=>{S(this,Xt,null),f(this,Zn,el).call(this)})),e.has("expanded")&&(l(this,Kt)!==null&&clearTimeout(l(this,Kt)),S(this,Kt,window.setTimeout(()=>{S(this,Kt,null),f(this,Zn,el).call(this)},KM)))}disconnected(){var e;(e=l(this,bn))==null||e.disconnect(),S(this,bn,null),l(this,Xt)!==null&&(cancelAnimationFrame(l(this,Xt)),S(this,Xt,null)),l(this,Kt)!==null&&(clearTimeout(l(this,Kt)),S(this,Kt,null))}template(){const e=this.toolCalls.length>0;return z`
|
|
402
504
|
${this.barTemplate()}
|
|
403
505
|
${e?this.panelTemplate():null}
|
|
404
506
|
`}barTemplate(){return this.phase==="thinking"?z`<div class="bar bar-static" unselectable>${this.indicator()}${this.label({expanded:this.expanded})}</div>`:z`
|
|
@@ -408,7 +510,7 @@ Please report this to https://github.com/markedjs/marked.`,n){let r="<p>An error
|
|
|
408
510
|
class="bar"
|
|
409
511
|
unselectable
|
|
410
512
|
aria-expanded=${this.expanded?"true":"false"}
|
|
411
|
-
aria-controls=${l(this,
|
|
513
|
+
aria-controls=${l(this,zo)}
|
|
412
514
|
@click=${this.handleToggle}
|
|
413
515
|
>
|
|
414
516
|
${this.indicator()}${this.label({expanded:this.expanded})}
|
|
@@ -416,7 +518,7 @@ Please report this to https://github.com/markedjs/marked.`,n){let r="<p>An error
|
|
|
416
518
|
`}panelTemplate(){return z`
|
|
417
519
|
<div
|
|
418
520
|
class="panel"
|
|
419
|
-
id=${l(this,
|
|
521
|
+
id=${l(this,zo)}
|
|
420
522
|
role="region"
|
|
421
523
|
?inert=${!this.expanded}
|
|
422
524
|
aria-hidden=${this.expanded?"false":"true"}
|
|
@@ -433,7 +535,7 @@ Please report this to https://github.com/markedjs/marked.`,n){let r="<p>An error
|
|
|
433
535
|
class="tool-dot"
|
|
434
536
|
data-status=${e.status}
|
|
435
537
|
role="img"
|
|
436
|
-
aria-label=${
|
|
538
|
+
aria-label=${QM(e.status)}
|
|
437
539
|
></span>
|
|
438
540
|
<span class="tool-title">${e.title}</span>
|
|
439
541
|
${e.text?z`
|
|
@@ -450,21 +552,21 @@ Please report this to https://github.com/markedjs/marked.`,n){let r="<p>An error
|
|
|
450
552
|
@click=${()=>this.toggleTextExpand(e.toolCallId)}
|
|
451
553
|
>
|
|
452
554
|
<span>${s}</span>
|
|
453
|
-
${r?
|
|
555
|
+
${r?J2({size:16}):vl({size:16})}
|
|
454
556
|
</button>`:null}
|
|
455
557
|
</div>
|
|
456
558
|
`:null}
|
|
457
559
|
</li>
|
|
458
|
-
`}toggleTextExpand(e){const r=new Set(this.expandedTexts);r.has(e)?r.delete(e):r.add(e),this.expandedTexts=r}indicator(){if(this.expanded)return z`<span class="indicator">${
|
|
459
|
-
>${e?
|
|
460
|
-
<div class="history-scroll" @scroll=${l(this,
|
|
560
|
+
`}toggleTextExpand(e){const r=new Set(this.expandedTexts);r.has(e)?r.delete(e):r.add(e),this.expandedTexts=r}indicator(){if(this.expanded)return z`<span class="indicator">${vl({size:16})}</span>`;const e=this.phase==="thinking"||this.phase==="using";return z`<span class=${e?"indicator indicator-active":"indicator"}
|
|
561
|
+
>${e?Tb({size:16}):nz({size:16})}</span>`}label(e){var s;if(this.phase==="thinking")return"Thinking…";const r=this.toolCalls.length;if(this.phase==="using"){if(e.expanded)return`Using ${r} ${r===1?"tool":"tools"}…`;const o=[...this.toolCalls].reverse().find(c=>c.status==="in_progress"),a=(o==null?void 0:o.toolKind)??((s=this.toolCalls.at(-1))==null?void 0:s.toolKind)??"other";return XM(a)}return`${e.expanded?"Showing":"Used"} ${r} ${r===1?"tool":"tools"}`}}zo=new WeakMap,bn=new WeakMap,Xt=new WeakMap,Kt=new WeakMap,Zn=new WeakSet,Mw=function(){if(!(typeof ResizeObserver>"u")){l(this,bn)||S(this,bn,new ResizeObserver(()=>f(this,Zn,el).call(this))),l(this,bn).disconnect();for(const e of this.querySelectorAll(".tool-text"))l(this,bn).observe(e)}},el=function(){const e=new Set;for(const r of this.querySelectorAll(".tool-text")){const i=r.dataset.toolCallId;if(i){if(this.expandedTexts.has(i)){e.add(i);continue}r.scrollHeight>r.clientHeight+1&&e.add(i)}}eN(this.overflowingTexts,e)||(this.overflowingTexts=e)},g(Eh,"properties",["phase","toolCalls","expanded","expandedTexts","overflowingTexts"]),g(Eh,"attributes",{expanded:{type:Boolean}});function XM(n){switch(n){case"read":return"Reading files…";case"edit":return"Editing files…";case"delete":return"Deleting files…";case"move":return"Moving files…";case"search":return"Searching files…";case"execute":return"Running commands…";case"think":return"Thinking…";case"fetch":return"Fetching content…";case"switch_mode":return"Switching modes…";default:return"Working…"}}const KM=160;let JM=0;function QM(n){switch(n){case"completed":return"Completed";case"failed":return"Failed";case"in_progress":return"In progress";default:return"Pending"}}function eN(n,t){if(n.size!==t.size)return!1;for(const e of n)if(!t.has(e))return!1;return!0}customElements.define("agent-activity",Eh);function tN(n){const t=[];let e=0;for(;e<n.length;)if(n[e].kind==="tool_call"){const i=[];for(;e<n.length&&n[e].kind==="tool_call";)i.push(n[e]),e+=1;const s=e>=n.length;t.push({kind:"tool-run",toolCalls:i,live:s})}else t.push({kind:"message",message:n[e]}),e+=1;const r=n[n.length-1];return r&&r.kind==="user"&&t.push({kind:"thinking"}),t}const lm=8,cm=new WeakMap;function nN(n){const t=cm.get(n);if(t&&t.text===n.text)return t.html;const e=YM(n.text);return cm.set(n,{text:n.text,html:e}),e}function um(n){for(let t=n.length-1;t>=0;t-=1){const e=n[t];if(e&&e.kind==="user")return e.id}return null}var ht,dt,Pr,Dr,Hn,vt,Uw,Ah,Fw,Ll,zl,$h;class Nw extends Xi{constructor(){super(...arguments);w(this,vt);g(this,"messages",[]);w(this,ht,!0);w(this,dt,null);w(this,Pr,null);w(this,Dr,null);w(this,Hn,!1);w(this,Ll,()=>{if(l(this,Hn))return;const e=l(this,dt);if(!e)return;const i=e.scrollHeight-e.clientHeight-e.scrollTop<=lm;i!==l(this,ht)&&(S(this,ht,i),this.toggleAttribute("data-pinned",i))});w(this,zl,()=>{S(this,ht,!0),this.toggleAttribute("data-pinned",!0),f(this,vt,$h).call(this,!0)})}changed(e){let r=!1;if(e.has("messages")){const i=e.get("messages")??[],s=um(this.messages);r=s!==null&&s!==um(i),r&&S(this,ht,!0)}Ce(this.template(),this),l(this,dt)||(S(this,dt,this.querySelector(".history-scroll")),l(this,dt)&&f(this,vt,Uw).call(this)),this.toggleAttribute("data-pinned",l(this,ht)),f(this,vt,Ah).call(this),f(this,vt,$h).call(this,r)}disconnected(){var e,r;(e=l(this,Pr))==null||e.disconnect(),S(this,Pr,null),(r=l(this,Dr))==null||r.disconnect(),S(this,Dr,null)}template(){const e=tN(this.messages);return z`
|
|
562
|
+
<div class="history-scroll" @scroll=${l(this,Ll)}>
|
|
461
563
|
${e.map(r=>{if(r.kind==="tool-run")return z`<agent-activity
|
|
462
564
|
.phase=${r.live?"using":"final"}
|
|
463
565
|
.toolCalls=${r.toolCalls}
|
|
464
566
|
></agent-activity>`;if(r.kind==="thinking")return z`<agent-activity
|
|
465
567
|
.phase=${"thinking"}
|
|
466
568
|
.toolCalls=${[]}
|
|
467
|
-
></agent-activity>`;const i=r.message,s=i.kind==="assistant"?
|
|
569
|
+
></agent-activity>`;const i=r.message,s=i.kind==="assistant"?M2(nN(i)):i.text;return z`<div
|
|
468
570
|
class="message message-${i.kind}"
|
|
469
571
|
data-message-id=${i.id}
|
|
470
572
|
>${s}</div>`})}
|
|
@@ -473,11 +575,11 @@ Please report this to https://github.com/markedjs/marked.`,n){let r="<p>An error
|
|
|
473
575
|
type="button"
|
|
474
576
|
class="history-jump"
|
|
475
577
|
aria-label="Jump to latest message"
|
|
476
|
-
@click=${l(this,
|
|
578
|
+
@click=${l(this,zl)}
|
|
477
579
|
>
|
|
478
|
-
${
|
|
580
|
+
${vl({size:16})}
|
|
479
581
|
</button>
|
|
480
|
-
`}}ht=new WeakMap,dt=new WeakMap,Pr=new WeakMap,Dr=new WeakMap,Hn=new WeakMap,vt=new WeakSet,
|
|
582
|
+
`}}ht=new WeakMap,dt=new WeakMap,Pr=new WeakMap,Dr=new WeakMap,Hn=new WeakMap,vt=new WeakSet,Uw=function(){l(this,dt)&&(typeof ResizeObserver>"u"||(S(this,Pr,new ResizeObserver(()=>f(this,vt,Fw).call(this))),S(this,Dr,new MutationObserver(()=>f(this,vt,Ah).call(this))),l(this,Dr).observe(l(this,dt),{childList:!0})))},Ah=function(){const e=l(this,dt),r=l(this,Pr);if(!(!e||!r)){r.disconnect();for(const i of Array.from(e.children))r.observe(i)}},Fw=function(){const e=l(this,dt);if(!e)return;if(l(this,ht)){S(this,Hn,!0),e.scrollTop=e.scrollHeight-e.clientHeight,requestAnimationFrame(()=>{S(this,Hn,!1)});return}const i=e.scrollHeight-e.clientHeight-e.scrollTop<=lm;i!==l(this,ht)&&(S(this,ht,i),this.toggleAttribute("data-pinned",i))},Ll=new WeakMap,zl=new WeakMap,$h=function(e){requestAnimationFrame(()=>{const r=l(this,dt);r&&(!l(this,ht)&&!e||(S(this,Hn,!0),r.scrollTop=r.scrollHeight-r.clientHeight,requestAnimationFrame(()=>{S(this,Hn,!1)})))})},g(Nw,"properties",["messages"]);customElements.define("message-history",Nw);var At,Oo,Hi,Jt,Wi,Zi,Mo,Vi,Ol,Ml,Nl,pt,tl,No,Ih,Ch,Uo,Fo;class Th extends Xi{constructor(){super(...arguments);w(this,pt);g(this,"placeholder","What do you want to do?");g(this,"open",!1);g(this,"messages",[]);g(this,"status","disconnected");w(this,At,en.resolve("ServerManager"));w(this,Oo,en.resolve("ShortcutService"));w(this,Hi,null);w(this,Jt,null);w(this,Wi,()=>{var e;this.status=((e=l(this,Jt))==null?void 0:e.status)??"disconnected"});w(this,Zi,()=>{var e;this.messages=((e=l(this,Jt))==null?void 0:e.messages)??[]});w(this,Mo,()=>{var e,r;(e=l(this,Jt))==null||e.removeEventListener("status-changed",l(this,Wi)),(r=l(this,Jt))==null||r.removeEventListener("messages-changed",l(this,Zi)),S(this,Jt,null)});w(this,Vi,()=>{var r;const e=((r=l(this,At).activeServer)==null?void 0:r.acpClient)??null;e!==l(this,Jt)&&(l(this,Mo).call(this),S(this,Jt,e),e==null||e.addEventListener("status-changed",l(this,Wi)),e==null||e.addEventListener("messages-changed",l(this,Zi)),l(this,Wi).call(this),l(this,Zi).call(this),e!=null&&e.enabled&&e.status==="disconnected"&&e.connect().catch(i=>{console.error("ACPClient.connect() failed",i)}))});g(this,"handleTriggerActivate",()=>{var r;const e=(r=l(this,At).activeServer)==null?void 0:r.acpClient;e&&!e.enabled||(this.open=!0)});g(this,"handleKeydown",e=>{var o;if(e.key!=="Enter"||e.shiftKey)return;const r=e.currentTarget,i=r.value.trim();if(e.preventDefault(),!i)return;r.value="",f(this,pt,tl).call(this,r);const s=(o=l(this,At).activeServer)==null?void 0:o.acpClient;if(s!=null&&s.enabled){if(i==="/new"){s.startNewSession().catch(a=>{console.error("ACPClient.startNewSession() failed",a)});return}s.sendMessage({text:i}).catch(a=>{console.error("ACPClient.sendMessage() failed",a)})}});w(this,Ol,e=>{f(this,pt,tl).call(this,e.currentTarget)});w(this,Ml,e=>{var i;e.stopPropagation();const r=(i=l(this,At).activeServer)==null?void 0:i.acpClient;r&&r.cancel().catch(s=>{console.error("ACPClient.cancel() failed",s)})});w(this,Nl,e=>{if(e.target instanceof HTMLTextAreaElement)return;const r=e.currentTarget.querySelector("textarea");r==null||r.focus()});w(this,No,e=>{var s;if(e.shortcut!=="focusCommandInput")return;const r=(s=l(this,At).activeServer)==null?void 0:s.acpClient;if(r&&!r.enabled)return;if(!this.open){this.open=!0;return}const i=this.querySelector("textarea");if(i){if(document.activeElement===i){this.open=!1;return}i.focus()}});w(this,Uo,e=>{e.target instanceof Node&&(this.contains(e.target)||(this.open=!1))});w(this,Fo,e=>{e.key==="Escape"&&(this.open=!1)})}connected(){const e=new DisposableStack;S(this,Hi,e),l(this,At).addEventListener("change",l(this,Vi)),e.defer(()=>{l(this,At).removeEventListener("change",l(this,Vi)),l(this,Mo).call(this)}),l(this,Vi).call(this),l(this,Oo).addEventListener("shortcut-triggered",l(this,No)),e.defer(()=>l(this,Oo).removeEventListener("shortcut-triggered",l(this,No))),this.open&&f(this,pt,Ih).call(this)}disconnected(){var e;(e=l(this,Hi))==null||e.dispose(),S(this,Hi,null),f(this,pt,Ch).call(this)}changed(e){if(this.open&&this.status!=="disconnected"?(this.removeAttribute("material"),this.removeAttribute("tone"),this.removeAttribute("level")):(this.setAttribute("material","paper"),this.setAttribute("tone","dark"),this.setAttribute("level","overlay")),Ce(this.template(),this),e.has("open"))if(this.open){f(this,pt,Ih).call(this);const r=this.querySelector("textarea");r&&(f(this,pt,tl).call(this,r),r.focus())}else f(this,pt,Ch).call(this)}template(){var i;const e=(i=l(this,At).activeServer)==null?void 0:i.acpClient;if(e&&!e.enabled||this.status==="disposed")return null;if(this.status==="disconnected")return z`
|
|
481
583
|
<div class="connecting" aria-disabled="true">
|
|
482
584
|
<ui-spinner size="16" weight="bold"></ui-spinner>
|
|
483
585
|
<span class="label">Connecting<span class="dots" aria-hidden="true"></span></span>
|
|
@@ -497,13 +599,13 @@ Please report this to https://github.com/markedjs/marked.`,n){let r="<p>An error
|
|
|
497
599
|
material="paper"
|
|
498
600
|
tone="dark"
|
|
499
601
|
level="overlay"
|
|
500
|
-
@click=${l(this,
|
|
602
|
+
@click=${l(this,Nl)}
|
|
501
603
|
>
|
|
502
604
|
<textarea
|
|
503
605
|
class="textarea"
|
|
504
606
|
rows="1"
|
|
505
607
|
@keydown=${this.handleKeydown}
|
|
506
|
-
@input=${l(this,
|
|
608
|
+
@input=${l(this,Ol)}
|
|
507
609
|
></textarea>
|
|
508
610
|
${s?z`
|
|
509
611
|
<button
|
|
@@ -512,9 +614,9 @@ Please report this to https://github.com/markedjs/marked.`,n){let r="<p>An error
|
|
|
512
614
|
variant="ghost"
|
|
513
615
|
aria-label=${o?"Cancelling…":"Stop generating"}
|
|
514
616
|
?disabled=${o}
|
|
515
|
-
@click=${l(this,
|
|
617
|
+
@click=${l(this,Ml)}
|
|
516
618
|
>
|
|
517
|
-
${o?z`<ui-spinner size="16" weight="bold"></ui-spinner>`:
|
|
619
|
+
${o?z`<ui-spinner size="16" weight="bold"></ui-spinner>`:K2({size:16})}
|
|
518
620
|
</button>
|
|
519
621
|
`:null}
|
|
520
622
|
</div>
|
|
@@ -530,13 +632,13 @@ Please report this to https://github.com/markedjs/marked.`,n){let r="<p>An error
|
|
|
530
632
|
<span class="label">${this.placeholder}</span>
|
|
531
633
|
<span class="kbd" aria-hidden="true">⌘K</span>
|
|
532
634
|
</div>
|
|
533
|
-
`}}At=new WeakMap,
|
|
635
|
+
`}}At=new WeakMap,Oo=new WeakMap,Hi=new WeakMap,Jt=new WeakMap,Wi=new WeakMap,Zi=new WeakMap,Mo=new WeakMap,Vi=new WeakMap,Ol=new WeakMap,Ml=new WeakMap,Nl=new WeakMap,pt=new WeakSet,tl=function(e){e.style.height="auto",e.style.height=`${e.scrollHeight}px`},No=new WeakMap,Ih=function(){document.addEventListener("mousedown",l(this,Uo)),document.addEventListener("keydown",l(this,Fo))},Ch=function(){document.removeEventListener("mousedown",l(this,Uo)),document.removeEventListener("keydown",l(this,Fo))},Uo=new WeakMap,Fo=new WeakMap,g(Th,"properties",["placeholder","open","messages","status"]),g(Th,"attributes",{placeholder:{type:String},open:{type:Boolean}});customElements.define("command-panel",Th);const rN='<path d="M128,112a28,28,0,0,0-8,54.83V184a8,8,0,0,0,16,0V166.83A28,28,0,0,0,128,112Zm0,40a12,12,0,1,1,12-12A12,12,0,0,1,128,152Zm80-72H176V56a48,48,0,0,0-96,0V80H48A16,16,0,0,0,32,96V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V96A16,16,0,0,0,208,80ZM96,56a32,32,0,0,1,64,0V80H96ZM208,208H48V96H208V208Z"/>';class Hw extends Event{constructor(e){super("auth-submit",{bubbles:!0,composed:!0});g(this,"token");this.token=e}}class iN extends HTMLElement{constructor(){super(...arguments);g(this,"_invalid",!1);g(this,"_tokenValue","")}set invalid(e){this._invalid=e,this.render()}get invalid(){return this._invalid}set tokenValue(e){this._tokenValue=e,this.render()}get tokenValue(){return this._tokenValue}connectedCallback(){this.render()}handleInput(e){const r=e.currentTarget;this._tokenValue=r.value}handleSubmit(e){e.preventDefault();const r=this._tokenValue.trim();r&&this.dispatchEvent(new Hw(r))}render(){Ce(z`
|
|
534
636
|
<modal-overlay open>
|
|
535
637
|
<system-modal material="glass-frosted" level="1" class="auth-modal">
|
|
536
638
|
<form class="auth-form" @submit=${r=>this.handleSubmit(r)}>
|
|
537
639
|
<header>
|
|
538
640
|
<span class="auth-modal-icon" aria-hidden="true">
|
|
539
|
-
<svg width="32" height="32" viewBox="0 0 256 256" fill="currentColor">${
|
|
641
|
+
<svg width="32" height="32" viewBox="0 0 256 256" fill="currentColor">${Ab(rN)}</svg>
|
|
540
642
|
</span>
|
|
541
643
|
<hgroup>
|
|
542
644
|
<h2>Enter access token</h2>
|
|
@@ -565,7 +667,7 @@ Please report this to https://github.com/markedjs/marked.`,n){let r="<p>An error
|
|
|
565
667
|
</form>
|
|
566
668
|
</system-modal>
|
|
567
669
|
</modal-overlay>
|
|
568
|
-
`,this)}}customElements.get("auth-modal")||customElements.define("auth-modal",
|
|
670
|
+
`,this)}}customElements.get("auth-modal")||customElements.define("auth-modal",iN);const sN=250,oN=1e3;class Ww extends HTMLElement{constructor(){super(...arguments);g(this,"_nextRetryAt",null);g(this,"_hasEverConnected",!1);g(this,"tickHandle",null)}set nextRetryAt(e){e!==this._nextRetryAt&&(this._nextRetryAt=e,this.updateTickerState(),this.render())}get nextRetryAt(){return this._nextRetryAt}set hasEverConnected(e){e!==this._hasEverConnected&&(this._hasEverConnected=e,this.render())}get hasEverConnected(){return this._hasEverConnected}connectedCallback(){if(this._nextRetryAt===null&&this.hasAttribute("next-retry-at")){const e=Number(this.getAttribute("next-retry-at"));this._nextRetryAt=Number.isFinite(e)?e:null}this.updateTickerState(),this.render()}disconnectedCallback(){this.stopTicker()}attributeChangedCallback(e,r,i){if(e==="next-retry-at"){if(i===null||i==="")this._nextRetryAt=null;else{const s=Number(i);this._nextRetryAt=Number.isFinite(s)?s:null}this.updateTickerState()}else e==="has-ever-connected"&&(this._hasEverConnected=i!==null&&i!=="false");this.render()}updateTickerState(){this._nextRetryAt!==null?this.startTicker():this.stopTicker()}startTicker(){this.tickHandle===null&&(this.tickHandle=setInterval(()=>{this.render()},sN))}stopTicker(){this.tickHandle!==null&&(clearInterval(this.tickHandle),this.tickHandle=null)}render(){const e=this._hasEverConnected,r=e?"Disconnected":"Connecting",i=this._nextRetryAt!==null?this.formatCountdown(this._nextRetryAt):"Reattempting now…";Ce(z`
|
|
569
671
|
<modal-overlay open role="status" aria-live="polite">
|
|
570
672
|
<system-modal material="glass-frosted" level="1" class="connecting-overlay-panel">
|
|
571
673
|
<header>
|
|
@@ -577,7 +679,7 @@ Please report this to https://github.com/markedjs/marked.`,n){let r="<p>An error
|
|
|
577
679
|
</header>
|
|
578
680
|
</system-modal>
|
|
579
681
|
</modal-overlay>
|
|
580
|
-
`,this)}formatCountdown(e){const r=e-Date.now();return r<=0?"Reattempting now…":`Reattempting in ${Math.ceil(r/
|
|
682
|
+
`,this)}formatCountdown(e){const r=e-Date.now();return r<=0?"Reattempting now…":`Reattempting in ${Math.ceil(r/oN)}s…`}}g(Ww,"observedAttributes",["next-retry-at","has-ever-connected"]);customElements.get("connecting-overlay")||customElements.define("connecting-overlay",Ww);class aN extends HTMLElement{constructor(){super(...arguments);g(this,"runtimeServerURL",bb());g(this,"electronMode",wd());g(this,"serverManager",en.resolve("ServerManager"));g(this,"screenManager",en.resolve("ScreenManager"));g(this,"connectError",null);g(this,"handleServerManagerChange",()=>{var e;this.connectError!==null&&((e=this.serverManager.activeServer)==null?void 0:e.status)==="connected"&&(this.connectError=null),this.render()});g(this,"handleScreenManagerChange",()=>{this.render()})}connectedCallback(){this.serverManager.addEventListener("change",this.handleServerManagerChange),this.screenManager.addEventListener("active-screen-changed",this.handleScreenManagerChange),this.screenManager.addEventListener("tabs-changed",this.handleScreenManagerChange),this.addEventListener("auth-submit",e=>{var i;const r=e instanceof Hw?e.token:e instanceof CustomEvent&&typeof((i=e.detail)==null?void 0:i.token)=="string"?e.detail.token:null;r&&this.handleAuthSubmit(r)}),this.initializeConnection(),this.render()}disconnectedCallback(){this.serverManager.removeEventListener("change",this.handleServerManagerChange),this.screenManager.removeEventListener("active-screen-changed",this.handleScreenManagerChange),this.screenManager.removeEventListener("tabs-changed",this.handleScreenManagerChange)}async initializeConnection(){if(this.electronMode){this.serverManager.connectConfiguredServers(this.runtimeServerURL,yg());return}if(this.serverManager.activeServer)return;const e=yg(),r=new yb({url:this.runtimeServerURL,name:"Server",token:e});this.serverManager.add(r),this.serverManager.setActive(r);try{await r.connect(e),this.connectError=null}catch(i){this.connectError=i instanceof Error&&!(i instanceof Os)?i.message:null}this.render()}async handleAuthSubmit(e){const r=this.serverManager.activeServer;if(r){this.connectError=null,this.updateTokenQueryParam(e);try{await r.connect(e)}catch(i){i instanceof Os||(this.connectError=i instanceof Error?i.message:String(i))}this.render()}}updateTokenQueryParam(e){const r=new URL(window.location.href);r.searchParams.set("token",e),window.history.replaceState({},"",`${r.pathname}${r.search}${r.hash}`)}render(){const e=this.serverManager.activeServer,r=(e==null?void 0:e.status)??null,i=this.screenManager.activeScreen,s=!!(e&&i&&this.screenManager.hasTab(e.url,i.id));if(r==="unauthorized"){const h=e;if(!h)return;Ce(z`
|
|
581
683
|
<main class="auth-gate">
|
|
582
684
|
<auth-modal
|
|
583
685
|
.invalid=${!!h.token}
|
|
@@ -603,4 +705,4 @@ Please report this to https://github.com/markedjs/marked.`,n){let r="<p>An error
|
|
|
603
705
|
.hasEverConnected=${(e==null?void 0:e.hasEverConnected)??!1}
|
|
604
706
|
></connecting-overlay>`:null}
|
|
605
707
|
</main>
|
|
606
|
-
`,this)}}customElements.get("television-app")||customElements.define("television-app",
|
|
708
|
+
`,this)}}customElements.get("television-app")||customElements.define("television-app",aN);const zd=wd(),Od=bb(),Zw=new z1(zd?"television-electron":"television-browser",R1(Od)),Sn=new b2({localStore:Zw,localServerURL:Od}),Vw=new H1({localStore:Zw,serverManager:Sn}),lN=new w2,Bw=()=>{const n=Sn.activeServer;if(!n||n.status!=="connected"){al();return}n.client.display.get().then(t=>{if(!(Sn.activeServer!==n||n.status!=="connected"))return wb(t.activeThemeName,n)}).catch(()=>{Sn.activeServer===n&&al()})};Bw();Sn.addEventListener("change",Bw);Sn.addEventListener("server-event",n=>{if(n.event.type!=="theme-changed")return;const t=Sn.activeServer;!t||t.url!==n.serverURL||wb(n.event.themeName,t)});en.register("ServerManager",()=>Sn);en.register("ScreenManager",()=>Vw);en.register("ShortcutService",()=>lN);globalThis.__telepath={screenManager:Vw,serverManager:Sn};const Md=document.createElement("television-app");Md.runtimeServerURL=Od;Md.electronMode=zd;zd&&document.body.classList.add("electron");document.body.appendChild(Md);
|