@telepath-computer/television 0.1.103 → 0.1.105
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/styles.css +15 -1
- package/dist/cli.cjs +1122 -134
- package/dist/skills/television/SKILL.md +10 -0
- package/dist/views/markdown/index.html +8 -8
- package/dist/web/assets/{index-c7jcA0yZ.css → index-BbSTSxZQ.css} +1 -1
- package/dist/web/assets/index-BsrZ1FgH.js +559 -0
- package/dist/web/index.html +2 -2
- package/package.json +4 -4
- package/dist/web/assets/index-l_Cxuh1M.js +0 -503
|
@@ -1,503 +0,0 @@
|
|
|
1
|
-
var pw=Object.defineProperty;var Td=r=>{throw TypeError(r)};var fw=(r,t,e)=>t in r?pw(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var y=(r,t,e)=>fw(r,typeof t!="symbol"?t+"":t,e),jl=(r,t,e)=>t.has(r)||Td("Cannot "+e);var l=(r,t,e)=>(jl(r,t,"read from private field"),e?e.call(r):t.get(r)),w=(r,t,e)=>t.has(r)?Td("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(r):t.set(r,e),x=(r,t,e,n)=>(jl(r,t,"write to private field"),n?n.call(r,e):t.set(r,e),e),f=(r,t,e)=>(jl(r,t,"access private method"),e);var Cd=(r,t,e,n)=>({set _(i){x(r,t,i,e)},get _(){return l(r,t,n)}});(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))n(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"&&n(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 n(i){if(i.ep)return;i.ep=!0;const s=e(i);fetch(i.href,s)}})();var Vr=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function gw(r){if(r.__esModule)return r;var t=r.default;if(typeof t=="function"){var e=function n(){return this instanceof n?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(r).forEach(function(n){var i=Object.getOwnPropertyDescriptor(r,n);Object.defineProperty(e,n,i.get?i:{enumerable:!0,get:function(){return r[n]}})}),e}var Rd=Object.prototype.toString,Cg=function(t){var e=Rd.call(t),n=e==="[object Arguments]";return n||(n=e!=="[object Array]"&&t!==null&&typeof t=="object"&&typeof t.length=="number"&&t.length>=0&&Rd.call(t.callee)==="[object Function]"),n},Vl,Pd;function mw(){if(Pd)return Vl;Pd=1;var r;if(!Object.keys){var t=Object.prototype.hasOwnProperty,e=Object.prototype.toString,n=Cg,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(m){var g=m.constructor;return g&&g.prototype===m},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 m in window)try{if(!u["$"+m]&&t.call(window,m)&&window[m]!==null&&typeof window[m]=="object")try{c(window[m])}catch{return!0}}catch{return!0}return!1}(),p=function(m){if(typeof window>"u"||!h)return c(m);try{return c(m)}catch{return!1}};r=function(g){var S=g!==null&&typeof g=="object",_=e.call(g)==="[object Function]",I=n(g),P=S&&e.call(g)==="[object String]",R=[];if(!S&&!_&&!I)throw new TypeError("Object.keys called on a non-object");var W=o&&_;if(P&&g.length>0&&!t.call(g,0))for(var M=0;M<g.length;++M)R.push(String(M));if(I&&g.length>0)for(var U=0;U<g.length;++U)R.push(String(U));else for(var Y in g)!(W&&Y==="prototype")&&t.call(g,Y)&&R.push(String(Y));if(s)for(var V=p(g),le=0;le<a.length;++le)!(V&&a[le]==="constructor")&&t.call(g,a[le])&&R.push(a[le]);return R}}return Vl=r,Vl}var vw=Array.prototype.slice,yw=Cg,Dd=Object.keys,oa=Dd?function(t){return Dd(t)}:mw(),Ld=Object.keys;oa.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(n){return yw(n)?Ld(vw.call(n)):Ld(n)})}else Object.keys=oa;return Object.keys||oa};var bw=oa,aa=Object.defineProperty||!1;if(aa)try{aa({},"a",{value:1})}catch{aa=!1}var yo=aa,lr=SyntaxError,X=TypeError,ww=Object.getOwnPropertyDescriptor,la=ww;if(la)try{la([],"length")}catch{la=null}var Ci=la,zd=yo,Sw=lr,Un=X,Od=Ci,Rg=function(t,e,n){if(!t||typeof t!="object"&&typeof t!="function")throw new Un("`obj` must be an object or a function`");if(typeof e!="string"&&typeof e!="symbol")throw new Un("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new Un("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new Un("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new Un("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new Un("`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=!!Od&&Od(t,e);if(zd)zd(t,e,{configurable:o===null&&c?c.configurable:!o,enumerable:i===null&&c?c.enumerable:!i,value:n,writable:s===null&&c?c.writable:!s});else if(a||!i&&!s&&!o)t[e]=n;else throw new Sw("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},Hc=yo,Pg=function(){return!!Hc};Pg.hasArrayLengthDefineBug=function(){if(!Hc)return null;try{return Hc([],"length",{value:1}).length!==1}catch{return!0}};var hl=Pg,_w=bw,kw=typeof Symbol=="function"&&typeof Symbol("foo")=="symbol",Ew=Object.prototype.toString,xw=Array.prototype.concat,Md=Rg,Aw=function(r){return typeof r=="function"&&Ew.call(r)==="[object Function]"},Dg=hl(),$w=function(r,t,e,n){if(t in r){if(n===!0){if(r[t]===e)return}else if(!Aw(n)||!n())return}Dg?Md(r,t,e,!0):Md(r,t,e)},Lg=function(r,t){var e=arguments.length>2?arguments[2]:{},n=_w(t);kw&&(n=xw.call(n,Object.getOwnPropertySymbols(t)));for(var i=0;i<n.length;i+=1)$w(r,n[i],t[n[i]],e[n[i]])};Lg.supportsDescriptors=!!Dg;var Tn=Lg,ca={exports:{}};typeof self<"u"?ca.exports=self:typeof window<"u"?ca.exports=window:ca.exports=Function("return this")();var zg=ca.exports,Iw=zg,Og=function(){return typeof Vr!="object"||!Vr||Vr.Math!==Math||Vr.Array!==Array?Iw:Vr},Tw=Tn,Cw=Ci,Rw=Og,Pw=function(){var t=Rw();if(Tw.supportsDescriptors){var e=Cw(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},Dw=Tn,Lw=zg,Mg=Og,zw=Pw,Ow=Mg(),Ng=function(){return Ow};Dw(Ng,{getPolyfill:Mg,implementation:Lw,shim:zw});var Qu=Ng,cr=function(t){return!!t&&(typeof t=="function"||typeof t=="object")},eh=Object,Ug=Error,Mw=EvalError,Nw=RangeError,th=ReferenceError,Uw=URIError,Fw=Math.abs,Ww=Math.floor,Hw=Math.max,Zw=Math.min,Bw=Math.pow,jw=Math.round,rh=Number.isNaN||function(t){return t!==t},Vw=rh,Gw=function(t){return Vw(t)||t===0?t:t<0?-1:1},Ri=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var t={},e=Symbol("test"),n=Object(e);if(typeof e=="string"||Object.prototype.toString.call(e)!=="[object Symbol]"||Object.prototype.toString.call(n)!=="[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},Nd=typeof Symbol<"u"&&Symbol,qw=Ri,nh=function(){return typeof Nd!="function"||typeof Symbol!="function"||typeof Nd("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:qw()},Gl,Ud;function Fg(){return Ud||(Ud=1,Gl=typeof Reflect<"u"&&Reflect.getPrototypeOf||null),Gl}var ql,Fd;function Wg(){if(Fd)return ql;Fd=1;var r=eh;return ql=r.getPrototypeOf||null,ql}var Yw="Function.prototype.bind called on incompatible ",Xw=Object.prototype.toString,Kw=Math.max,Jw="[object Function]",Wd=function(t,e){for(var n=[],i=0;i<t.length;i+=1)n[i]=t[i];for(var s=0;s<e.length;s+=1)n[s+t.length]=e[s];return n},Qw=function(t,e){for(var n=[],i=e,s=0;i<t.length;i+=1,s+=1)n[s]=t[i];return n},eS=function(r,t){for(var e="",n=0;n<r.length;n+=1)e+=r[n],n+1<r.length&&(e+=t);return e},tS=function(t){var e=this;if(typeof e!="function"||Xw.apply(e)!==Jw)throw new TypeError(Yw+e);for(var n=Qw(arguments,1),i,s=function(){if(this instanceof i){var h=e.apply(this,Wd(n,arguments));return Object(h)===h?h:this}return e.apply(t,Wd(n,arguments))},o=Kw(0,e.length-n.length),a=[],c=0;c<o;c++)a[c]="$"+c;if(i=Function("binder","return function ("+eS(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},rS=tS,bo=Function.prototype.bind||rS,ih=Function.prototype.call,sh=Function.prototype.apply,nS=typeof Reflect<"u"&&Reflect&&Reflect.apply,iS=bo,sS=sh,oS=ih,aS=nS,Hg=aS||iS.call(oS,sS),lS=bo,cS=X,uS=ih,hS=Hg,dl=function(t){if(t.length<1||typeof t[0]!="function")throw new cS("a function is required");return hS(lS,uS,t)},Yl,Hd;function dS(){if(Hd)return Yl;Hd=1;var r=dl,t=Ci,e;try{e=[].__proto__===Array.prototype}catch(o){if(!o||typeof o!="object"||!("code"in o)||o.code!=="ERR_PROTO_ACCESS")throw o}var n=!!e&&t&&t(Object.prototype,"__proto__"),i=Object,s=i.getPrototypeOf;return Yl=n&&typeof n.get=="function"?r([n.get]):typeof s=="function"?function(a){return s(a==null?a:i(a))}:!1,Yl}var Xl,Zd;function Zg(){if(Zd)return Xl;Zd=1;var r=Fg(),t=Wg(),e=dS();return Xl=r?function(i){return r(i)}:t?function(i){if(!i||typeof i!="object"&&typeof i!="function")throw new TypeError("getProto: not an object");return t(i)}:e?function(i){return e(i)}:null,Xl}var pS=Function.prototype.call,fS=Object.prototype.hasOwnProperty,gS=bo,ur=gS.call(pS,fS),q,mS=eh,vS=Ug,yS=Mw,bS=Nw,wS=th,xi=lr,ii=X,SS=Uw,_S=Fw,kS=Ww,ES=Hw,xS=Zw,AS=Bw,$S=jw,IS=Gw,Bg=Function,Kl=function(r){try{return Bg('"use strict"; return ('+r+").constructor;")()}catch{}},ys=Ci,TS=yo,Jl=function(){throw new ii},CS=ys?function(){try{return arguments.callee,Jl}catch{try{return ys(arguments,"callee").get}catch{return Jl}}}():Jl,Fn=nh(),Te=Zg(),RS=Wg(),PS=Fg(),jg=sh,wo=ih,jn={},DS=typeof Uint8Array>"u"||!Te?q:Te(Uint8Array),Sn={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?q:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?q:ArrayBuffer,"%ArrayIteratorPrototype%":Fn&&Te?Te([][Symbol.iterator]()):q,"%AsyncFromSyncIteratorPrototype%":q,"%AsyncFunction%":jn,"%AsyncGenerator%":jn,"%AsyncGeneratorFunction%":jn,"%AsyncIteratorPrototype%":jn,"%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%":vS,"%eval%":eval,"%EvalError%":yS,"%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%":Bg,"%GeneratorFunction%":jn,"%Int8Array%":typeof Int8Array>"u"?q:Int8Array,"%Int16Array%":typeof Int16Array>"u"?q:Int16Array,"%Int32Array%":typeof Int32Array>"u"?q:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":Fn&&Te?Te(Te([][Symbol.iterator]())):q,"%JSON%":typeof JSON=="object"?JSON:q,"%Map%":typeof Map>"u"?q:Map,"%MapIteratorPrototype%":typeof Map>"u"||!Fn||!Te?q:Te(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":mS,"%Object.getOwnPropertyDescriptor%":ys,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?q:Promise,"%Proxy%":typeof Proxy>"u"?q:Proxy,"%RangeError%":bS,"%ReferenceError%":wS,"%Reflect%":typeof Reflect>"u"?q:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?q:Set,"%SetIteratorPrototype%":typeof Set>"u"||!Fn||!Te?q:Te(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?q:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":Fn&&Te?Te(""[Symbol.iterator]()):q,"%Symbol%":Fn?Symbol:q,"%SyntaxError%":xi,"%ThrowTypeError%":CS,"%TypedArray%":DS,"%TypeError%":ii,"%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%":SS,"%WeakMap%":typeof WeakMap>"u"?q:WeakMap,"%WeakRef%":typeof WeakRef>"u"?q:WeakRef,"%WeakSet%":typeof WeakSet>"u"?q:WeakSet,"%Function.prototype.call%":wo,"%Function.prototype.apply%":jg,"%Object.defineProperty%":TS,"%Object.getPrototypeOf%":RS,"%Math.abs%":_S,"%Math.floor%":kS,"%Math.max%":ES,"%Math.min%":xS,"%Math.pow%":AS,"%Math.round%":$S,"%Math.sign%":IS,"%Reflect.getPrototypeOf%":PS};if(Te)try{null.error}catch(r){var LS=Te(Te(r));Sn["%Error.prototype%"]=LS}var zS=function r(t){var e;if(t==="%AsyncFunction%")e=Kl("async function () {}");else if(t==="%GeneratorFunction%")e=Kl("function* () {}");else if(t==="%AsyncGeneratorFunction%")e=Kl("async function* () {}");else if(t==="%AsyncGenerator%"){var n=r("%AsyncGeneratorFunction%");n&&(e=n.prototype)}else if(t==="%AsyncIteratorPrototype%"){var i=r("%AsyncGenerator%");i&&Te&&(e=Te(i.prototype))}return Sn[t]=e,e},Bd={__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"]},So=bo,Ca=ur,OS=So.call(wo,Array.prototype.concat),MS=So.call(jg,Array.prototype.splice),jd=So.call(wo,String.prototype.replace),Ra=So.call(wo,String.prototype.slice),NS=So.call(wo,RegExp.prototype.exec),US=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,FS=/\\(\\)?/g,WS=function(t){var e=Ra(t,0,1),n=Ra(t,-1);if(e==="%"&&n!=="%")throw new xi("invalid intrinsic syntax, expected closing `%`");if(n==="%"&&e!=="%")throw new xi("invalid intrinsic syntax, expected opening `%`");var i=[];return jd(t,US,function(s,o,a,c){i[i.length]=a?jd(c,FS,"$1"):o||s}),i},HS=function(t,e){var n=t,i;if(Ca(Bd,n)&&(i=Bd[n],n="%"+i[0]+"%"),Ca(Sn,n)){var s=Sn[n];if(s===jn&&(s=zS(n)),typeof s>"u"&&!e)throw new ii("intrinsic "+t+" exists, but is not available. Please file an issue!");return{alias:i,name:n,value:s}}throw new xi("intrinsic "+t+" does not exist!")},mt=function(t,e){if(typeof t!="string"||t.length===0)throw new ii("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof e!="boolean")throw new ii('"allowMissing" argument must be a boolean');if(NS(/^%?[^%]*%?$/,t)===null)throw new xi("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var n=WS(t),i=n.length>0?n[0]:"",s=HS("%"+i+"%",e),o=s.name,a=s.value,c=!1,u=s.alias;u&&(i=u[0],MS(n,OS([0,1],u)));for(var h=1,p=!0;h<n.length;h+=1){var m=n[h],g=Ra(m,0,1),S=Ra(m,-1);if((g==='"'||g==="'"||g==="`"||S==='"'||S==="'"||S==="`")&&g!==S)throw new xi("property names with quotes must have matching quotes");if((m==="constructor"||!p)&&(c=!0),i+="."+m,o="%"+i+"%",Ca(Sn,o))a=Sn[o];else if(a!=null){if(!(m in a)){if(!e)throw new ii("base intrinsic for "+t+" exists, but the property is not available.");return}if(ys&&h+1>=n.length){var _=ys(a,m);p=!!_,p&&"get"in _&&!("originalValue"in _.get)?a=_.get:a=a[m]}else p=Ca(a,m),a=a[m];p&&!c&&(Sn[o]=a)}}return a},Ql,Vd;function Pr(){if(Vd)return Ql;Vd=1;var r=mt,t=dl,e=t([r("%String.prototype.indexOf%")]);return Ql=function(i,s){var o=r(i,!!s);return typeof o=="function"&&e(i,".prototype.")>-1?t([o]):o},Ql}var ec,Gd;function oh(){if(Gd)return ec;Gd=1;var r=mt,t=r("%Array%"),e=!t.isArray&&Pr()("Object.prototype.toString");return ec=t.isArray||function(i){return e(i)==="[object Array]"},ec}var ZS=hl,qd=yo,Vg=ZS.hasArrayLengthDefineBug(),BS=Vg&&oh(),jS=Pr(),VS=jS("Object.prototype.propertyIsEnumerable"),ah=function(t,e,n,i,s,o){if(!qd){if(!t(o)||!o["[[Configurable]]"]||!o["[[Writable]]"]||s in i&&VS(i,s)!==!!o["[[Enumerable]]"])return!1;var a=o["[[Value]]"];return i[s]=a,e(i[s],a)}return Vg&&s==="length"&&"[[Value]]"in o&&BS(i)&&i.length!==o["[[Value]]"]?(i.length=o["[[Value]]"],i.length===o["[[Value]]"]):(qd(i,s,n(o)),!0)},GS=X,Vi=ur,qS={__proto__:null,"[[Configurable]]":!0,"[[Enumerable]]":!0,"[[Get]]":!0,"[[Set]]":!0,"[[Value]]":!0,"[[Writable]]":!0},Pi=function(t){if(!t||typeof t!="object")return!1;for(var e in t)if(Vi(t,e)&&!qS[e])return!1;var n=Vi(t,"[[Value]]")||Vi(t,"[[Writable]]"),i=Vi(t,"[[Get]]")||Vi(t,"[[Set]]");if(n&&i)throw new GS("Property Descriptors may not be both accessor and data descriptors");return!0},Gg=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},YS=X,XS=Pi,KS=Gg,qg=function(t){if(typeof t<"u"&&!XS(t))throw new YS("Assertion failed: `Desc` must be a Property Descriptor");return KS(t)},JS=X,Yd=ur,QS=Pi,Yg=function(t){if(typeof t>"u")return!1;if(!QS(t))throw new JS("Assertion failed: `Desc` must be a Property Descriptor");return!(!Yd(t,"[[Value]]")&&!Yd(t,"[[Writable]]"))},Di=function(t){return typeof t=="string"||typeof t=="symbol"},Xd=rh,Xg=function(t,e){return t===e?t===0?1/t===1/e:!0:Xd(t)&&Xd(e)},Kd=X,e0=cr,t0=ah,r0=qg,n0=Yg,i0=Di,s0=Xg,lh=function(t,e,n){if(!e0(t))throw new Kd("Assertion failed: Type(O) is not Object");if(!i0(e))throw new Kd("Assertion failed: P is not a Property Key");var i={"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Value]]":n,"[[Writable]]":!0};return t0(n0,s0,r0,t,e,i)},Kg=Function.prototype.toString,ti=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,Zc,ua;if(typeof ti=="function"&&typeof Object.defineProperty=="function")try{Zc=Object.defineProperty({},"length",{get:function(){throw ua}}),ua={},ti(function(){throw 42},null,Zc)}catch(r){r!==ua&&(ti=null)}else ti=null;var o0=/^\s*class\b/,Bc=function(t){try{var e=Kg.call(t);return o0.test(e)}catch{return!1}},tc=function(t){try{return Bc(t)?!1:(Kg.call(t),!0)}catch{return!1}},ha=Object.prototype.toString,a0="[object Object]",l0="[object Function]",c0="[object GeneratorFunction]",u0="[object HTMLAllCollection]",h0="[object HTML document.all class]",d0="[object HTMLCollection]",p0=typeof Symbol=="function"&&!!Symbol.toStringTag,f0=!(0 in[,]),jc=function(){return!1};if(typeof document=="object"){var g0=document.all;ha.call(g0)===ha.call(document.all)&&(jc=function(t){if((f0||!t)&&(typeof t>"u"||typeof t=="object"))try{var e=ha.call(t);return(e===u0||e===h0||e===d0||e===a0)&&t("")==null}catch{}return!1})}var Jg=ti?function(t){if(jc(t))return!0;if(!t||typeof t!="function"&&typeof t!="object")return!1;try{ti(t,null,Zc)}catch(e){if(e!==ua)return!1}return!Bc(t)&&tc(t)}:function(t){if(jc(t))return!0;if(!t||typeof t!="function"&&typeof t!="object")return!1;if(p0)return tc(t);if(Bc(t))return!1;var e=ha.call(t);return e!==l0&&e!==c0&&!/^\[object HTML/.test(e)?!1:tc(t)},m0=Jg,v0=function(t){return!!t},It=ur,Wo=X,y0=cr,Jd=m0,rc=v0,b0=function(t){if(!y0(t))throw new Wo("ToPropertyDescriptor requires an object");var e={};if(It(t,"enumerable")&&(e["[[Enumerable]]"]=rc(t.enumerable)),It(t,"configurable")&&(e["[[Configurable]]"]=rc(t.configurable)),It(t,"value")&&(e["[[Value]]"]=t.value),It(t,"writable")&&(e["[[Writable]]"]=rc(t.writable)),It(t,"get")){var n=t.get;if(typeof n<"u"&&!Jd(n))throw new Wo("getter must be a function");e["[[Get]]"]=n}if(It(t,"set")){var i=t.set;if(typeof i<"u"&&!Jd(i))throw new Wo("setter must be a function");e["[[Set]]"]=i}if((It(e,"[[Get]]")||It(e,"[[Set]]"))&&(It(e,"[[Value]]")||It(e,"[[Writable]]")))throw new Wo("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute");return e},nc=X,w0=cr,Qd=Pi,S0=ah,_0=qg,k0=Yg,E0=Di,x0=Xg,A0=b0,$0=function(t,e,n){if(!w0(t))throw new nc("Assertion failed: Type(O) is not Object");if(!E0(e))throw new nc("Assertion failed: P is not a Property Key");var i=Qd(n)?n:A0(n);if(!Qd(i))throw new nc("Assertion failed: Desc is not a valid Property Descriptor");return S0(k0,x0,_0,t,e,i)},ep=X,I0=cr,T0=$0,C0=Di,R0=function(t,e,n){if(!I0(t))throw new ep("Assertion failed: Type(O) is not Object");if(!C0(e))throw new ep("Assertion failed: P is not a Property Key");var i={"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Value]]":n,"[[Writable]]":!0};return T0(t,e,i)},P0=typeof Reflect<"u"&&Reflect.setPrototypeOf||null,D0=eh,L0=D0.setPrototypeOf||null,z0=dl,tp=Ci,O0=X,Qg={};try{Qg.__proto__=null}catch(r){if(!r||typeof r!="object"||!("code"in r)||r.code!=="ERR_PROTO_ACCESS")throw r}var M0=!("toString"in Qg),ic=tp&&tp(Object.prototype,"__proto__"),N0=M0&&(!!ic&&typeof ic.set=="function"&&z0([ic.set])||function(t,e){if(t==null)throw new O0("set Object.prototype.__proto__ called on null or undefined");return t.__proto__=e,e}),rp=P0,U0=L0,np=N0,F0=X,W0=rp?function(t,e){if(rp(t,e))return t;throw new F0("Reflect.setPrototypeOf: failed to set [[Prototype]]")}:U0||(np?function(t,e){return np(t,e),t}:null),ip=X,H0=cr,sp=Zg(),Z0=function(t){if(!H0(t))throw new ip("Assertion failed: O must be an Object");if(!sp)throw new ip("This environment does not support fetching prototypes.");return sp(t)},B0=X,j0=W0,V0=cr,G0=Z0,q0=function(t,e){if(e!==null&&!V0(e))throw new B0("Assertion failed: V must be Object or Null");try{j0(t,e)}catch{return!1}return G0(t)===e},sc=lh,op=R0,em=q0,Y0=hl(),ch=Ug;function _o(r,t,e){var n=new ch(e);return em(n,da),delete n.constructor,op(n,"error",r),op(n,"suppressed",t),n}Y0&&Object.defineProperty(_o,"prototype",{writable:!1});var da=_o.prototype;if(!sc(da,"constructor",_o)||!sc(da,"message","")||!sc(da,"name","SuppressedError"))throw new ch("unable to install SuppressedError.prototype properties; please report this!");em(_o.prototype,ch.prototype);var X0=_o,K0=X0,tm=function(){return typeof SuppressedError=="function"?SuppressedError:K0},J0=Tn,ap=Qu(),Q0=tm,e_=function(){var t=Q0();return J0(ap,{SuppressedError:t},{SuppressedError:function(){return ap.SuppressedError!==t}}),t};e_();var t_=X,r_=Pi,n_=Gg,i_=function(t){if(typeof t<"u"&&!r_(t))throw new t_("Assertion failed: `Desc` must be a Property Descriptor");return n_(t)},s_=X,lp=ur,o_=Pi,a_=function(t){if(typeof t>"u")return!1;if(!o_(t))throw new s_("Assertion failed: `Desc` must be a Property Descriptor");return!(!lp(t,"[[Value]]")&&!lp(t,"[[Writable]]"))},cp=rh,l_=function(t,e){return t===e?t===0?1/t===1/e:!0:cp(t)&&cp(e)},Li=Jg,c_=function(t){return!!t},Tt=ur,Ho=X,u_=cr,up=Li,oc=c_,h_=function(t){if(!u_(t))throw new Ho("ToPropertyDescriptor requires an object");var e={};if(Tt(t,"enumerable")&&(e["[[Enumerable]]"]=oc(t.enumerable)),Tt(t,"configurable")&&(e["[[Configurable]]"]=oc(t.configurable)),Tt(t,"value")&&(e["[[Value]]"]=t.value),Tt(t,"writable")&&(e["[[Writable]]"]=oc(t.writable)),Tt(t,"get")){var n=t.get;if(typeof n<"u"&&!up(n))throw new Ho("getter must be a function");e["[[Get]]"]=n}if(Tt(t,"set")){var i=t.set;if(typeof i<"u"&&!up(i))throw new Ho("setter must be a function");e["[[Set]]"]=i}if((Tt(e,"[[Get]]")||Tt(e,"[[Set]]"))&&(Tt(e,"[[Value]]")||Tt(e,"[[Writable]]")))throw new Ho("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute");return e},ac=X,d_=cr,hp=Pi,p_=ah,f_=i_,g_=a_,m_=Di,v_=l_,y_=h_,ko=function(t,e,n){if(!d_(t))throw new ac("Assertion failed: Type(O) is not Object");if(!m_(e))throw new ac("Assertion failed: P is not a Property Key");var i=hp(n)?n:y_(n);if(!hp(i))throw new ac("Assertion failed: Desc is not a valid Property Descriptor");return p_(g_,v_,f_,t,e,i)},b_=Ri(),w_=b_?Symbol.dispose||Symbol("Symbol.dispose"):null,S_=Ri,__=w_,uh=function(){return S_()&&Symbol.dispose||__},k_=nh,E_=ko,x_=uh,A_=function(){var t=x_();return k_()&&E_(Symbol,"dispose",{"[[Configurable]]":!1,"[[Enumerable]]":!1,"[[Writable]]":!1,"[[Value]]":t}),t},$_=Ri(),I_=$_?Symbol.asyncDispose||Symbol("Symbol.asyncDispose"):null,T_=Ri,C_=I_,hh=function(){return T_()&&Symbol.asyncDispose||C_},R_=nh,P_=ko,D_=hh,L_=function(){var t=D_();return R_()&&P_(Symbol,"asyncDispose",{"[[Configurable]]":!1,"[[Enumerable]]":!1,"[[Writable]]":!1,"[[Value]]":t}),t},z_=oh(),O_=mt,M_=Pr(),N_=X,U_=z_,F_=O_("%Reflect.apply%",!0)||M_("Function.prototype.apply"),pl=function(t,e){var n=arguments.length>2?arguments[2]:[];if(!U_(n))throw new N_("Assertion failed: optional `argumentsList`, if provided, must be a List");return F_(t,e,n)};const W_={},H_=Object.freeze(Object.defineProperty({__proto__:null,default:W_},Symbol.toStringTag,{value:"Module"})),Z_=gw(H_);var dh=typeof Map=="function"&&Map.prototype,lc=Object.getOwnPropertyDescriptor&&dh?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,Pa=dh&&lc&&typeof lc.get=="function"?lc.get:null,dp=dh&&Map.prototype.forEach,ph=typeof Set=="function"&&Set.prototype,cc=Object.getOwnPropertyDescriptor&&ph?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,Da=ph&&cc&&typeof cc.get=="function"?cc.get:null,pp=ph&&Set.prototype.forEach,B_=typeof WeakMap=="function"&&WeakMap.prototype,ps=B_?WeakMap.prototype.has:null,j_=typeof WeakSet=="function"&&WeakSet.prototype,fs=j_?WeakSet.prototype.has:null,V_=typeof WeakRef=="function"&&WeakRef.prototype,fp=V_?WeakRef.prototype.deref:null,G_=Boolean.prototype.valueOf,q_=Object.prototype.toString,Y_=Function.prototype.toString,X_=String.prototype.match,fh=String.prototype.slice,xr=String.prototype.replace,K_=String.prototype.toUpperCase,gp=String.prototype.toLowerCase,rm=RegExp.prototype.test,mp=Array.prototype.concat,Ut=Array.prototype.join,J_=Array.prototype.slice,vp=Math.floor,Vc=typeof BigInt=="function"?BigInt.prototype.valueOf:null,uc=Object.getOwnPropertySymbols,Gc=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,Ai=typeof Symbol=="function"&&typeof Symbol.iterator=="object",gs=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===Ai||!0)?Symbol.toStringTag:null,nm=Object.prototype.propertyIsEnumerable,yp=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(r){return r.__proto__}:null);function bp(r,t){if(r===1/0||r===-1/0||r!==r||r&&r>-1e3&&r<1e3||rm.call(/e/,t))return t;var e=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof r=="number"){var n=r<0?-vp(-r):vp(r);if(n!==r){var i=String(n),s=fh.call(t,i.length+1);return xr.call(i,e,"$&_")+"."+xr.call(xr.call(s,/([0-9]{3})/g,"$&_"),/_$/,"")}}return xr.call(t,e,"$&_")}var qc=Z_,wp=qc.custom,Sp=om(wp)?wp:null,im={__proto__:null,double:'"',single:"'"},Q_={__proto__:null,double:/(["\\])/g,single:/(['\\])/g},zi=function r(t,e,n,i){var s=e||{};if(Yt(s,"quoteStyle")&&!Yt(im,s.quoteStyle))throw new TypeError('option "quoteStyle" must be "single" or "double"');if(Yt(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=Yt(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(Yt(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(Yt(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 lm(t,s);if(typeof t=="number"){if(t===0)return 1/0/t>0?"0":"-0";var c=String(t);return a?bp(t,c):c}if(typeof t=="bigint"){var u=String(t)+"n";return a?bp(t,u):u}var h=typeof s.depth>"u"?5:s.depth;if(typeof n>"u"&&(n=0),n>=h&&h>0&&typeof t=="object")return Yc(t)?"[Array]":"[Object]";var p=vk(s,n);if(typeof i>"u")i=[];else if(am(i,t)>=0)return"[Circular]";function m(xt,hr,Dl){if(hr&&(i=J_.call(i),i.push(hr)),Dl){var Po={depth:s.depth};return Yt(s,"quoteStyle")&&(Po.quoteStyle=s.quoteStyle),r(xt,Po,n+1,i)}return r(xt,s,n+1,i)}if(typeof t=="function"&&!_p(t)){var g=lk(t),S=Zo(t,m);return"[Function"+(g?": "+g:" (anonymous)")+"]"+(S.length>0?" { "+Ut.call(S,", ")+" }":"")}if(om(t)){var _=Ai?xr.call(String(t),/^(Symbol\(.*\))_[^)]*$/,"$1"):Gc.call(t);return typeof t=="object"&&!Ai?Gi(_):_}if(fk(t)){for(var I="<"+gp.call(String(t.nodeName)),P=t.attributes||[],R=0;R<P.length;R++)I+=" "+P[R].name+"="+sm(ek(P[R].value),"double",s);return I+=">",t.childNodes&&t.childNodes.length&&(I+="..."),I+="</"+gp.call(String(t.nodeName))+">",I}if(Yc(t)){if(t.length===0)return"[]";var W=Zo(t,m);return p&&!mk(W)?"["+Xc(W,p)+"]":"[ "+Ut.call(W,", ")+" ]"}if(rk(t)){var M=Zo(t,m);return!("cause"in Error.prototype)&&"cause"in t&&!nm.call(t,"cause")?"{ ["+String(t)+"] "+Ut.call(mp.call("[cause]: "+m(t.cause),M),", ")+" }":M.length===0?"["+String(t)+"]":"{ ["+String(t)+"] "+Ut.call(M,", ")+" }"}if(typeof t=="object"&&o){if(Sp&&typeof t[Sp]=="function"&&qc)return qc(t,{depth:h-n});if(o!=="symbol"&&typeof t.inspect=="function")return t.inspect()}if(ck(t)){var U=[];return dp&&dp.call(t,function(xt,hr){U.push(m(hr,t,!0)+" => "+m(xt,t))}),kp("Map",Pa.call(t),U,p)}if(dk(t)){var Y=[];return pp&&pp.call(t,function(xt){Y.push(m(xt,t))}),kp("Set",Da.call(t),Y,p)}if(uk(t))return hc("WeakMap");if(pk(t))return hc("WeakSet");if(hk(t))return hc("WeakRef");if(ik(t))return Gi(m(Number(t)));if(ok(t))return Gi(m(Vc.call(t)));if(sk(t))return Gi(G_.call(t));if(nk(t))return Gi(m(String(t)));if(typeof window<"u"&&t===window)return"{ [object Window] }";if(typeof globalThis<"u"&&t===globalThis||typeof Vr<"u"&&t===Vr)return"{ [object globalThis] }";if(!tk(t)&&!_p(t)){var V=Zo(t,m),le=yp?yp(t)===Object.prototype:t instanceof Object||t.constructor===Object,yt=t instanceof Object?"":"null prototype",Or=!le&&gs&&Object(t)===t&&gs in t?fh.call(Dr(t),8,-1):yt?"Object":"",Re=le||typeof t.constructor!="function"?"":t.constructor.name?t.constructor.name+" ":"",Mr=Re+(Or||yt?"["+Ut.call(mp.call([],Or||[],yt||[]),": ")+"] ":"");return V.length===0?Mr+"{}":p?Mr+"{"+Xc(V,p)+"}":Mr+"{ "+Ut.call(V,", ")+" }"}return String(t)};function sm(r,t,e){var n=e.quoteStyle||t,i=im[n];return i+r+i}function ek(r){return xr.call(String(r),/"/g,""")}function Cn(r){return!gs||!(typeof r=="object"&&(gs in r||typeof r[gs]<"u"))}function Yc(r){return Dr(r)==="[object Array]"&&Cn(r)}function tk(r){return Dr(r)==="[object Date]"&&Cn(r)}function _p(r){return Dr(r)==="[object RegExp]"&&Cn(r)}function rk(r){return Dr(r)==="[object Error]"&&Cn(r)}function nk(r){return Dr(r)==="[object String]"&&Cn(r)}function ik(r){return Dr(r)==="[object Number]"&&Cn(r)}function sk(r){return Dr(r)==="[object Boolean]"&&Cn(r)}function om(r){if(Ai)return r&&typeof r=="object"&&r instanceof Symbol;if(typeof r=="symbol")return!0;if(!r||typeof r!="object"||!Gc)return!1;try{return Gc.call(r),!0}catch{}return!1}function ok(r){if(!r||typeof r!="object"||!Vc)return!1;try{return Vc.call(r),!0}catch{}return!1}var ak=Object.prototype.hasOwnProperty||function(r){return r in this};function Yt(r,t){return ak.call(r,t)}function Dr(r){return q_.call(r)}function lk(r){if(r.name)return r.name;var t=X_.call(Y_.call(r),/^function\s*([\w$]+)/);return t?t[1]:null}function am(r,t){if(r.indexOf)return r.indexOf(t);for(var e=0,n=r.length;e<n;e++)if(r[e]===t)return e;return-1}function ck(r){if(!Pa||!r||typeof r!="object")return!1;try{Pa.call(r);try{Da.call(r)}catch{return!0}return r instanceof Map}catch{}return!1}function uk(r){if(!ps||!r||typeof r!="object")return!1;try{ps.call(r,ps);try{fs.call(r,fs)}catch{return!0}return r instanceof WeakMap}catch{}return!1}function hk(r){if(!fp||!r||typeof r!="object")return!1;try{return fp.call(r),!0}catch{}return!1}function dk(r){if(!Da||!r||typeof r!="object")return!1;try{Da.call(r);try{Pa.call(r)}catch{return!0}return r instanceof Set}catch{}return!1}function pk(r){if(!fs||!r||typeof r!="object")return!1;try{fs.call(r,fs);try{ps.call(r,ps)}catch{return!0}return r instanceof WeakSet}catch{}return!1}function fk(r){return!r||typeof r!="object"?!1:typeof HTMLElement<"u"&&r instanceof HTMLElement?!0:typeof r.nodeName=="string"&&typeof r.getAttribute=="function"}function lm(r,t){if(r.length>t.maxStringLength){var e=r.length-t.maxStringLength,n="... "+e+" more character"+(e>1?"s":"");return lm(fh.call(r,0,t.maxStringLength),t)+n}var i=Q_[t.quoteStyle||"single"];i.lastIndex=0;var s=xr.call(xr.call(r,i,"\\$1"),/[\x00-\x1f]/g,gk);return sm(s,"single",t)}function gk(r){var t=r.charCodeAt(0),e={8:"b",9:"t",10:"n",12:"f",13:"r"}[t];return e?"\\"+e:"\\x"+(t<16?"0":"")+K_.call(t.toString(16))}function Gi(r){return"Object("+r+")"}function hc(r){return r+" { ? }"}function kp(r,t,e,n){var i=n?Xc(e,n):Ut.call(e,", ");return r+" ("+t+") {"+i+"}"}function mk(r){for(var t=0;t<r.length;t++)if(am(r[t],`
|
|
2
|
-
`)>=0)return!1;return!0}function vk(r,t){var e;if(r.indent===" ")e=" ";else if(typeof r.indent=="number"&&r.indent>0)e=Ut.call(Array(r.indent+1)," ");else return null;return{base:e,prev:Ut.call(Array(t+1),e)}}function Xc(r,t){if(r.length===0)return"";var e=`
|
|
3
|
-
`+t.prev+t.base;return e+Ut.call(r,","+e)+`
|
|
4
|
-
`+t.prev}function Zo(r,t){var e=Yc(r),n=[];if(e){n.length=r.length;for(var i=0;i<r.length;i++)n[i]=Yt(r,i)?t(r[i],r):""}var s=typeof uc=="function"?uc(r):[],o;if(Ai){o={};for(var a=0;a<s.length;a++)o["$"+s[a]]=s[a]}for(var c in r)Yt(r,c)&&(e&&String(Number(c))===c&&c<r.length||Ai&&o["$"+c]instanceof Symbol||(rm.call(/[^\w$]/,c)?n.push(t(c,r)+": "+t(r[c],r)):n.push(c+": "+t(r[c],r))));if(typeof uc=="function")for(var u=0;u<s.length;u++)nm.call(r,s[u])&&n.push("["+t(s[u])+"]: "+t(r[s[u]],r));return n}var yk=zi,bk=X,fl=function(r,t,e){for(var n=r,i;(i=n.next)!=null;n=i)if(i.key===t)return n.next=i.next,e||(i.next=r.next,r.next=i),i},wk=function(r,t){if(r){var e=fl(r,t);return e&&e.value}},Sk=function(r,t,e){var n=fl(r,t);n?n.value=e:r.next={key:t,next:r.next,value:e}},_k=function(r,t){return r?!!fl(r,t):!1},kk=function(r,t){if(r)return fl(r,t,!0)},Ek=function(){var t,e={assert:function(n){if(!e.has(n))throw new bk("Side channel does not contain "+yk(n))},delete:function(n){var i=t&&t.next,s=kk(t,n);return s&&i&&i===s&&(t=void 0),!!s},get:function(n){return wk(t,n)},has:function(n){return _k(t,n)},set:function(n,i){t||(t={next:void 0}),Sk(t,n,i)}};return e},xk=mt,Eo=Pr(),Ak=zi,$k=X,Ep=xk("%Map%",!0),Ik=Eo("Map.prototype.get",!0),Tk=Eo("Map.prototype.set",!0),Ck=Eo("Map.prototype.has",!0),Rk=Eo("Map.prototype.delete",!0),Pk=Eo("Map.prototype.size",!0),cm=!!Ep&&function(){var t,e={assert:function(n){if(!e.has(n))throw new $k("Side channel does not contain "+Ak(n))},delete:function(n){if(t){var i=Rk(t,n);return Pk(t)===0&&(t=void 0),i}return!1},get:function(n){if(t)return Ik(t,n)},has:function(n){return t?Ck(t,n):!1},set:function(n,i){t||(t=new Ep),Tk(t,n,i)}};return e},Dk=mt,gl=Pr(),Lk=zi,Bo=cm,zk=X,Wn=Dk("%WeakMap%",!0),Ok=gl("WeakMap.prototype.get",!0),Mk=gl("WeakMap.prototype.set",!0),Nk=gl("WeakMap.prototype.has",!0),Uk=gl("WeakMap.prototype.delete",!0),Fk=Wn?function(){var t,e,n={assert:function(i){if(!n.has(i))throw new zk("Side channel does not contain "+Lk(i))},delete:function(i){if(Wn&&i&&(typeof i=="object"||typeof i=="function")){if(t)return Uk(t,i)}else if(Bo&&e)return e.delete(i);return!1},get:function(i){return Wn&&i&&(typeof i=="object"||typeof i=="function")&&t?Ok(t,i):e&&e.get(i)},has:function(i){return Wn&&i&&(typeof i=="object"||typeof i=="function")&&t?Nk(t,i):!!e&&e.has(i)},set:function(i,s){Wn&&i&&(typeof i=="object"||typeof i=="function")?(t||(t=new Wn),Mk(t,i,s)):Bo&&(e||(e=Bo()),e.set(i,s))}};return n}:Bo,Wk=X,Hk=zi,Zk=Ek,Bk=cm,jk=Fk,Vk=jk||Bk||Zk,Gk=function(){var t,e={assert:function(n){if(!e.has(n))throw new Wk("Side channel does not contain "+Hk(n))},delete:function(n){return!!t&&t.delete(n)},get:function(n){return t&&t.get(n)},has:function(n){return!!t&&t.has(n)},set:function(n,i){t||(t=Vk()),t.set(n,i)}};return e},qk=ur,qi=Gk(),jt=X,gh={assert:function(r,t){if(!r||typeof r!="object"&&typeof r!="function")throw new jt("`O` is not an object");if(typeof t!="string")throw new jt("`slot` must be a string");if(qi.assert(r),!gh.has(r,t))throw new jt("`"+t+"` is not present on `O`")},get:function(r,t){if(!r||typeof r!="object"&&typeof r!="function")throw new jt("`O` is not an object");if(typeof t!="string")throw new jt("`slot` must be a string");var e=qi.get(r);return e&&e["$"+t]},has:function(r,t){if(!r||typeof r!="object"&&typeof r!="function")throw new jt("`O` is not an object");if(typeof t!="string")throw new jt("`slot` must be a string");var e=qi.get(r);return!!e&&qk(e,"$"+t)},set:function(r,t,e){if(!r||typeof r!="object"&&typeof r!="function")throw new jt("`O` is not an object");if(typeof t!="string")throw new jt("`slot` must be a string");var n=qi.get(r);n||(n={},qi.set(r,n)),n["$"+t]=e}};Object.freeze&&Object.freeze(gh);var mh=gh,um=lr,Ar=mh,xo=function r(t,e){if(!(this instanceof r))return new r(t,e);if(t!=="normal"&&t!=="break"&&t!=="continue"&&t!=="return"&&t!=="throw")throw new um('Assertion failed: `type` must be one of "normal", "break", "continue", "return", or "throw"');Ar.set(this,"[[Type]]",t),Ar.set(this,"[[Value]]",e)};xo.prototype.type=function(){return Ar.get(this,"[[Type]]")};xo.prototype.value=function(){return Ar.get(this,"[[Value]]")};xo.prototype["?"]=function(){var t=Ar.get(this,"[[Type]]"),e=Ar.get(this,"[[Value]]");if(t==="throw")throw e;return e};xo.prototype["!"]=function(){var t=Ar.get(this,"[[Type]]");if(t!=="normal")throw new um('Assertion failed: Completion Record is not of type "normal"');return Ar.get(this,"[[Value]]")};var vh=xo,Yk=vh,yh=function(t){return new Yk("normal",t)},dc,xp;function Xk(){if(xp)return dc;xp=1;var r=Ri;return dc=function(){return r()&&!!Symbol.toStringTag},dc}var Kk=mt,Ap=Kk("%Object.defineProperty%",!0),Jk=Xk()(),Qk=ur,eE=X,jo=Jk?Symbol.toStringTag:null,hm=function(t,e){var n=arguments.length>2&&!!arguments[2]&&arguments[2].force,i=arguments.length>2&&!!arguments[2]&&arguments[2].nonConfigurable;if(typeof n<"u"&&typeof n!="boolean"||typeof i<"u"&&typeof i!="boolean")throw new eE("if provided, the `overrideIfSet` and `nonConfigurable` options must be booleans");jo&&(n||!Qk(t,jo))&&(Ap?Ap(t,jo,{configurable:!i,enumerable:!1,value:e,writable:!1}):t[jo]=e)},dm={exports:{}},tE=mt,$p=Rg,rE=hl(),Ip=Ci,Tp=X,nE=tE("%Math.floor%"),iE=function(t,e){if(typeof t!="function")throw new Tp("`fn` is not a function");if(typeof e!="number"||e<0||e>4294967295||nE(e)!==e)throw new Tp("`length` must be a positive 32-bit integer");var n=arguments.length>2&&!!arguments[2],i=!0,s=!0;if("length"in t&&Ip){var o=Ip(t,"length");o&&!o.configurable&&(i=!1),o&&!o.writable&&(s=!1)}return(i||s||!n)&&(rE?$p(t,"length",e,!0,!0):$p(t,"length",e)),t},sE=bo,oE=sh,aE=Hg,lE=function(){return aE(sE,oE,arguments)};(function(r){var t=iE,e=yo,n=dl,i=lE;r.exports=function(o){var a=n(arguments),c=1+o.length-(arguments.length-1);return t(a,c>0?c:0,!0)},e?e(r.exports,"apply",{value:i}):r.exports.apply=i})(dm);var bh=dm.exports,cE=function(t,e){for(var n=0;n<t.length;n+=1)if(!e(t[n],n,t))return!1;return!0},uE=Object,hE=function(t){return t&&typeof t=="object"&&(typeof t["[[ResourceValue]]"]>"u"||uE(t["[[ResourceValue]]"])===t["[[ResourceValue]]"])&&(t["[[Hint]]"]==="SYNC-DISPOSE"||t["[[Hint]]"]==="ASYNC-DISPOSE")&&(typeof t["[[DisposeMethod]]"]=="function"||typeof t["[[DisposeMethod]]"]>"u")},dE=ur,pE=oh(),fE=cE,gE=hE,mE=function(t){return t&&typeof t=="object"&&dE(t,"[[DisposableResourceStack]]")&&pE(t["[[DisposableResourceStack]]"])&&(t["[[DisposableResourceStack]]"].length===0||fE(t["[[DisposableResourceStack]]"],gE))},vE=cr,yE=function(t){if(t===null)return"Null";if(typeof t>"u")return"Undefined";if(vE(t))return"Object";if(typeof t=="number")return"Number";if(typeof t=="boolean")return"Boolean";if(typeof t=="string")return"String"},bE=yE,wh=function(t){return typeof t=="symbol"?"Symbol":typeof t=="bigint"?"BigInt":bE(t)},wE=X,SE=zi,_E=Di,kE=function(t,e){if(!_E(e))throw new wE("Assertion failed: P is not a Property Key, got "+SE(e));return t[e]},Cp=X,EE=kE,xE=Li,AE=Di,Rp=zi,$E=function(t,e){if(!AE(e))throw new Cp("Assertion failed: P is not a Property Key");var n=EE(t,e);if(n!=null){if(!xE(n))throw new Cp(Rp(e)+" is not a function: "+Rp(n));return n}},Kc={exports:{}},IE=mt,TE=IE,Pp=TE("%Reflect.construct%",!0),La=ko;try{La({},"",{"[[Get]]":function(){}})}catch{La=null}if(La&&Pp){var Dp={},Lp={};La(Lp,"length",{"[[Get]]":function(){throw Dp},"[[Enumerable]]":!0}),Kc.exports=function(t){try{Pp(t,Lp)}catch(e){return e===Dp}}}else Kc.exports=function(t){return typeof t=="function"&&!!t.prototype};var CE=Kc.exports,pc=X,zp=Li,RE=CE,PE=function(t){if(!RE(t))throw new pc("C must be a constructor");var e={"[[Resolve]]":void 0,"[[Reject]]":void 0},n=new t(function(i,s){if(typeof e["[[Resolve]]"]<"u"||typeof e["[[Reject]]"]<"u")throw new pc("executor has already been called");e["[[Resolve]]"]=i,e["[[Reject]]"]=s});if(!zp(e["[[Resolve]]"])||!zp(e["[[Reject]]"]))throw new pc("executor must provide valid resolve and reject functions");return{"[[Promise]]":n,"[[Resolve]]":e["[[Resolve]]"],"[[Reject]]":e["[[Reject]]"]}},Op=lr,DE=X,fc=pl,Mp=$E,LE=PE,zE=wh,Np=uh(),Up=hh(),OE=function(t,e){if(zE(t)!=="Object")throw new DE("`V` must be an Object");if(e!=="SYNC-DISPOSE"&&e!=="ASYNC-DISPOSE")throw new Op("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");var n;if(e==="ASYNC-DISPOSE"&&Up&&(n=Mp(t,Up)),!n){if(!Np)throw new Op("`Symbol.dispose` is not supported");if(n=Mp(t,Np),typeof n<"u")return function(){var i=this;if(e==="ASYNC-DISPOSE"){var s=LE(Promise);try{fc(n,i),fc(s["[[Resolve]]"],void 0,[void 0])}catch(o){s["[[Reject]]"](o)}return s["[[Promise]]"]}fc(n,i)}}return n},ME=lr,gc=X,NE=Li,UE=wh,FE=OE,WE=function(t,e){if(e!=="SYNC-DISPOSE"&&e!=="ASYNC-DISPOSE")throw new ME("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");var n;if(arguments.length<3)if(t==null)t=void 0,n=void 0;else{if(typeof t<"u"&&UE(t)!=="Object")throw new gc("`V` must be an Object, or `null` or `undefined`");if(n=FE(t,e),typeof n>"u")throw new gc("dispose method must not be `undefined` on `V` when an object `V` is provided")}else if(n=arguments[2],!NE(n))throw new gc("`method`, when provided, must be a function");return{"[[ResourceValue]]":t,"[[Hint]]":e,"[[DisposeMethod]]":n}},HE=lr,Vo=X,ZE=mE,Fp=WE,BE=Pr(),jE=BE("Array.prototype.push"),pm=function(t,e,n){if(!ZE(t))throw new Vo("Assertion failed: `disposeCapability` must be a DisposeCapability Record");if(n!=="SYNC-DISPOSE"&&n!=="ASYNC-DISPOSE")throw new HE("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 Vo("Assertion failed: `method`, when present, must be a function");if(!t["[[DisposableResourceStack]]"])throw new Vo("Assertion failed: `disposeCapability.[[DisposableResourceStack]]` must not be ~EMPTY~");var s;if(arguments.length<4){if(e==null&&n==="SYNC_DISPOSE")return"UNUSED";s=Fp(e,n)}else{if(typeof e<"u")throw new Vo("Assertion failed: `V` must be undefined when `method` is present");s=Fp(void 0,n,i)}return jE(t["[[DisposableResourceStack]]"],s),"UNUSED"},mc,Wp;function Sh(){if(Wp)return mc;Wp=1;var r=mt,t=bh,e=lr,n=r("%Promise.resolve%",!0),i=n&&t(n);return mc=function(o,a){if(!i)throw new e("This environment does not support Promises.");return i(o,a)},mc}var vc,Hp;function VE(){if(Hp)return vc;Hp=1;var r=mt,t=lr,e=r("%Promise%",!0),n=pl,i=Sh(),s=wh;return vc=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:n(u,a);if(c==="ASYNC-DISPOSE")return i(e,h)},vc}var yc,Zp;function GE(){if(Zp)return yc;Zp=1;var r=vh;return yc=function(e){return new r("throw",e)},yc}var qE=mt,bc=lr,Bp=X,YE=qE("%Promise%",!0),XE=Pr(),jp=XE("Promise.prototype.then",!0),KE=vh,Vp=VE(),JE=yh,QE=Sh(),Gp=GE(),ex=tm(),fm=function(t,e){if(!(e instanceof KE))throw new Bp("`completion` must be a Completion Record");var n=t["[[DisposableResourceStack]]"];if(!n)throw new Bp("Assertion failed: `disposeCapability.[[DisposableResourceStack]]` must not be ~EMPTY~");for(var i,s=n.length-1;s>=0;s-=1)if(!i)i=n[s]["[[Hint]]"];else if(i!==n[s]["[[Hint]]"])throw new bc("mixed hint stacks are not supported");for(var o=i==="ASYNC-DISPOSE"&&QE(YE,e),a=function(m){if(e.type()==="throw"){var g=e.value(),S=new ex(m,g);e=Gp(S)}else e=Gp(m)},c=i==="ASYNC-DISPOSE"&&function(g){return jp(o,function(){var S=Vp(g["[[ResourceValue]]"],g["[[Hint]]"],g["[[DisposeMethod]]"]);if(!S)throw new bc("Assertion failed: non-`~ASYNC-DISPOSE~` resource returned a promise from Dispose");return jp(S,JE)},a)},u=n.length-1;u>=0;u-=1)if(i==="ASYNC-DISPOSE")o=c(n[u]);else{var h=n[u];try{var p=Vp(h["[[ResourceValue]]"],h["[[Hint]]"],h["[[DisposeMethod]]"]);if(p)throw new bc("Assertion failed: `~SYNC-DISPOSE~` resource returned something from Dispose")}catch(m){a(m)}}return t["[[DisposableResourceStack]]"]=null,i==="ASYNC-DISPOSE"?o:e},gm=function(){var t=[];return{"[[DisposableResourceStack]]":t}},ml=th,_h=X,tx=pl,Oi=lh,rx=ko,mm=Li,nx=yh,rt=mh,ix=hm,vm=Tn.supportsDescriptors,sx=bh,kh=pm,ox=fm,ym=gm,qp=uh(),dt=function r(){if(!(this instanceof r)||rt.has(this,"[[DisposableState]]")||rt.has(this,"[[DisposeCapability]]"))throw new _h("can only be used with new");rt.set(this,"[[DisposableState]]","PENDING"),rt.set(this,"[[DisposeCapability]]",ym())},bm=function(){var t=this;return rt.assert(t,"[[DisposableState]]"),rt.get(t,"[[DisposableState]]")==="DISPOSED"},Ao=sx(bm);vm?rx(dt.prototype,"disposed",{"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Get]]":bm}):dt.prototype.disposed=!1;var wm=function(t){rt.set(t,"[[DisposableState]]","DISPOSED"),vm||(t.disposed=!0)};Oi(dt.prototype,"dispose",function(){var t=this;if(!Ao(t))return wm(t),ox(rt.get(t,"[[DisposeCapability]]"),nx())["?"]()});Oi(dt.prototype,"use",function(t){var e=this;if(Ao(e))throw new ml("a disposed stack can not use anything new");return kh(rt.get(e,"[[DisposeCapability]]"),t,"SYNC-DISPOSE"),t});Oi(dt.prototype,"adopt",function(t,e){var n=this;if(Ao(n))throw new ml("a disposed stack can not use anything new");if(!mm(e))throw new _h("`onDispose` must be a function");var i=function(){return tx(e,void 0,[t])};return kh(rt.get(n,"[[DisposeCapability]]"),void 0,"SYNC-DISPOSE",i),t});Oi(dt.prototype,"defer",function(t){var e=this;if(Ao(e))throw new ml("a disposed stack can not defer anything new");if(!mm(t))throw new _h("`onDispose` must be a function");kh(rt.get(e,"[[DisposeCapability]]"),void 0,"SYNC-DISPOSE",t)});Oi(dt.prototype,"move",function(){var t=this;if(Ao(t))throw new ml("a disposed stack can not use anything new");var e=new dt;return rt.set(e,"[[DisposeCapability]]",rt.get(t,"[[DisposeCapability]]")),rt.set(t,"[[DisposeCapability]]",ym()),wm(t),e});qp&&Oi(dt.prototype,qp,dt.prototype.dispose);ix(dt.prototype,"DisposableStack");var ax=dt,lx=ax,cx=function(){return typeof DisposableStack=="function"?DisposableStack:lx},ux=Tn,hx=Qu(),dx=cx,px=function(){var t=dx();return ux(hx,{DisposableStack:t},{DisposableStack:!0}),t},fx=mt,vl=th,Eh=X,Yp=fx("%Promise%",!0),xh=pm,gx=pl,Mi=lh,mx=ko,vx=fm,Sm=Li,_m=gm,yx=yh,Xp=Sh(),nt=mh,bx=hm,km=Tn.supportsDescriptors,wx=bh,Sx=Pr(),_x=Sx("Promise.prototype.then",!0),Kp=hh(),pt=function r(){if(!(this instanceof r)||nt.has(this,"[[AsyncDisposableState]]")||nt.has(this,"[[DisposeCapability]]"))throw new Eh("can only be used with new");nt.set(this,"[[AsyncDisposableState]]","pending"),nt.set(this,"[[DisposeCapability]]",_m())},Em=function(){var t=this;return nt.assert(t,"[[AsyncDisposableState]]"),nt.get(t,"[[AsyncDisposableState]]")==="disposed"},$o=wx(Em);km?mx(pt.prototype,"disposed",{"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Get]]":Em}):pt.prototype.disposed=!1;var xm=function(t){nt.set(t,"[[AsyncDisposableState]]","disposed"),km||(t.disposed=!0)};Mi(pt.prototype,"disposeAsync",function(){var t=this;return $o(t)?Xp(Yp):(xm(t),_x(Xp(Yp,vx(nt.get(t,"[[DisposeCapability]]"),yx())),function(e){return e["?"]()}))});Mi(pt.prototype,"use",function(t){var e=this;if($o(e))throw new vl("a disposed stack can not use anything new");return xh(nt.get(e,"[[DisposeCapability]]"),t,"ASYNC-DISPOSE"),t});Mi(pt.prototype,"adopt",function(t,e){var n=this;if($o(n))throw new vl("a disposed stack can not use anything new");if(!Sm(e))throw new Eh("`onDisposeAsync` must be a function");var i=function(){return gx(e,void 0,[t])};return i.value=t,xh(nt.get(n,"[[DisposeCapability]]"),void 0,"ASYNC-DISPOSE",i),t});Mi(pt.prototype,"defer",function(t){var e=this;if($o(e))throw new vl("a disposed stack can not defer anything new");if(!Sm(t))throw new Eh("`onDispose` must be a function");xh(nt.get(e,"[[DisposeCapability]]"),void 0,"ASYNC-DISPOSE",t)});Mi(pt.prototype,"move",function(){var t=this;if($o(t))throw new vl("a disposed stack can not use anything new");var e=new pt;return nt.set(e,"[[DisposeCapability]]",nt.get(t,"[[DisposeCapability]]")),nt.set(t,"[[DisposeCapability]]",_m()),xm(t),e});Kp&&Mi(pt.prototype,Kp,pt.prototype.disposeAsync);bx(pt.prototype,"AsyncDisposableStack");var kx=pt,Ex=kx,xx=function(){return typeof AsyncDisposableStack=="function"?AsyncDisposableStack:Ex},Ax=Tn,$x=Qu(),Ix=xx,Tx=function(){var t=Ix();return Ax($x,{AsyncDisposableStack:t},{AsyncDisposableStack:!0}),t},Cx=A_,Rx=L_,Px=px,Dx=Tx,Lx=function(){Cx(),Rx(),Px(),Dx()};Lx();const Jp=new WeakMap;function zx(r){return(typeof r=="object"||typeof r=="function")&&r!==null&&"then"in r&&typeof r.then=="function"}function Hn(r){return typeof r=="string"?r:typeof r=="symbol"?r.description??r.toString():r.name||"(anonymous class)"}function Qp(){return new Error("register(Key, factory) requires a factory function. Wrap existing instances as () => instance.")}function Ox(){return new Error("register(Key, factory) does not accept async factories. Await setup before registering.")}class Mx{constructor(){y(this,"entries",new Map);y(this,"constructionStack",[])}register(t,e){if(e===void 0){if(typeof t!="function")throw Qp();this.validateClassRegistration(t),this.storeFactory(t,()=>this.instantiateClass(t));return}if(typeof e!="function")throw Qp();if(e.constructor.name==="AsyncFunction")throw Ox();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 n=this.getOrCreateEntry(t);n.factory=e,n.instance=void 0,n.error=void 0}validateClassRegistration(t){const e=Jp.get(t);if(e){if(t.length!==e.length)throw new Error(`${Hn(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(`${Hn(t)} cannot be registered with register(Class). Undecorated classes must have zero required constructor parameters. Use register(Key, () => value) instead.`)}instantiateClass(t){const e=Jp.get(t);if(!e)return new t;const n=e.map(i=>this.resolveAny(i));return new t(...n)}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,n)=>{if(n==="then")return;const i=this.getInstance(t),s=Reflect.get(i,n,i);return typeof s=="function"?s.bind(i):s},set:(e,n,i)=>{const s=this.getInstance(t);return Reflect.set(s,n,i,s)},has:(e,n)=>{const i=this.getInstance(t);return n in i}})}getInstance(t){if(t.instance)return t.instance;if(t.error)throw t.error;if(!t.factory)throw new Error(`${Hn(t.key)} was resolved but never registered`);const e=this.constructionStack.indexOf(t.key);if(e!==-1){const n=[...this.constructionStack.slice(e),t.key].map(i=>Hn(i)).join(" -> ");throw new Error(`Circular dependency detected: ${n}`)}this.constructionStack.push(t.key);try{const n=t.factory();if(zx(n))throw new Error(`Factory for ${Hn(t.key)} returned a Promise. Await setup before registering.`);if(typeof n!="object"||n===null)throw new Error(`Factory for ${Hn(t.key)} returned a non-object value. Wrap primitives in an object.`);return t.instance=n,n}catch(n){throw t.error=n,n}finally{this.constructionStack.pop()}}}const Ft=new Mx,Nx=.5,ef=.1,tf=8,Ux=4,Am=3,$m=3,Fx=4,Xr=255,Im=.2126,Tm=.7152,Cm=.0722;async function Rm(r){const t=Wx(r);if(!t)return"light";try{return await Bx(r,t)>=Nx?"light":"dark"}catch{return"light"}}function Wx(r){if(typeof document.elementsFromPoint!="function")return null;const t=r.getBoundingClientRect(),e=t.left+t.width/2,n=t.top+t.height/2,i=document.elementsFromPoint(e,n);for(const s of i){if(!(s instanceof HTMLElement)||s===r||r.contains(s))continue;const o=window.getComputedStyle(s);if(Hx(o))return s}return null}function Hx(r){return r.backgroundImage&&r.backgroundImage!=="none"?!0:Zx(r.backgroundColor)>0}function Zx(r){if(!r)return 0;const t=r.match(/rgba?\(([^)]+)\)/);if(!t)return 0;const e=t[1].split(/[\s,/]+/).filter(Boolean);return e.length===Fx?parseFloat(e[Am]):e.length===$m?1:0}async function Bx(r,t){const e=r.getBoundingClientRect(),n=t.getBoundingClientRect(),i={x:Go((e.left-n.left)/n.width),y:Go((e.top-n.top)/n.height),width:Go(e.width/n.width),height:Go(e.height/n.height)},s=window.getComputedStyle(t),o=jx(s.backgroundImage);return o?Gx({url:o,surfaceWidth:n.width,surfaceHeight:n.height,region:i}):qx(s.backgroundColor)}function jx(r){const t=r.match(/url\(\s*["']?([^"')]+)["']?\s*\)/);return t?t[1]:null}const rf=new Map;function Vx(r){let t=rf.get(r);return t||(t=new Promise((e,n)=>{const i=new Image;i.crossOrigin="anonymous",i.onload=()=>e(i),i.onerror=()=>n(new Error(`Failed to load ${r}`)),i.src=r}),rf.set(r,t),t)}async function Gx(r){const t=await Vx(r.url),e=Math.max(tf,Math.ceil(r.surfaceWidth*ef)),n=Math.max(tf,Math.ceil(r.surfaceHeight*ef)),i=document.createElement("canvas");i.width=e,i.height=n;const s=i.getContext("2d",{willReadFrequently:!0});if(!s)return 1;const o=r.surfaceWidth/r.surfaceHeight,a=t.naturalWidth/t.naturalHeight;let c,u;a>o?(u=n,c=n*a):(c=e,u=e/a);const h=(e-c)/2,p=(n-u)/2;s.drawImage(t,h,p,c,u);const m=Math.max(0,Math.floor(r.region.x*e)),g=Math.max(0,Math.floor(r.region.y*n)),S=Math.max(1,Math.min(e-m,Math.floor(r.region.width*e))),_=Math.max(1,Math.min(n-g,Math.floor(r.region.height*n))),I=s.getImageData(m,g,S,_).data;let P=0,R=0;for(let W=0;W<I.length;W+=Ux){const M=I[W]/Xr,U=I[W+1]/Xr,Y=I[W+2]/Xr,V=I[W+Am]/Xr;P+=V*(Im*M+Tm*U+Cm*Y),R+=1}return R>0?P/R:1}function qx(r){const t=r.match(/rgba?\(([^)]+)\)/);if(!t)return 1;const e=t[1].split(/[\s,/]+/).filter(Boolean).map(parseFloat);if(e.length<$m)return 1;const n=e[0]/Xr,i=e[1]/Xr,s=e[2]/Xr;return Im*n+Tm*i+Cm*s}function Go(r){return r<0?0:r>1?1:r}const Yx=["ghost","glass"],bs=[...Yx.flatMap(r=>[`button[variant="${r}"]`,`segmented-control[variant="${r}"]`]),'[material="glass"]'].join(", "),qo=new WeakSet,nf=new WeakSet;function Pm(r){if(nf.has(r))return;nf.add(r);for(const e of r.querySelectorAll(bs))wc(e);if(typeof MutationObserver!="function")return;new MutationObserver(e=>{for(const n of e)if(n.type==="childList")for(const i of n.addedNodes)Xx(i,wc);else n.type==="attributes"&&n.target instanceof HTMLElement&&n.target.matches(bs)&&wc(n.target)}).observe(r,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["variant","material"]})}function Xx(r,t){if(r instanceof Element){r instanceof HTMLElement&&r.matches(bs)&&t(r);for(const e of r.querySelectorAll(bs))t(e)}}async function wc(r){if(qo.has(r)||r.hasAttribute("tone"))return;qo.add(r);const t=await Rm(r);if(!r.matches(bs)){qo.delete(r);return}if(r.hasAttribute("tone")){qo.delete(r);return}r.setAttribute("tone",t)}const Kx="*,*: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;--space-2: 2px;--space-4: 4px;--space-6: 6px;--space-8: 8px;--space-12: 12px;--space-16: 16px;--space-20: 20px;--space-24: 24px;--space-32: 32px;--space-48: 48px;--space-64: 64px;--radius-4: 4px;--radius-8: 8px;--radius-12: 12px;--radius-16: 16px;--radius-24: 24px;--radius-full: 9999px;--shadow-hairline: 0 0 0 .5px var(--color-border);--shadow-control: 0 1px 1px rgb(0 0 0 / .04), 0 2px 6px rgb(0 0 0 / .06);--alpha-50: 4%;--alpha-100: 8%;--alpha-200: 15%;--alpha-300: 22%;--alpha-400: 30%;--alpha-500: 40%;--alpha-600: 50%;--alpha-700: 65%;--alpha-800: 80%;--alpha-900: 90%;--alpha-950: 95%;--tint-50: color-mix(in srgb, currentColor var(--alpha-50), transparent);--tint-100: color-mix(in srgb, currentColor var(--alpha-100), transparent);--tint-200: color-mix(in srgb, currentColor var(--alpha-200), transparent);--tint-300: color-mix(in srgb, currentColor var(--alpha-300), transparent);--tint-400: color-mix(in srgb, currentColor var(--alpha-400), transparent);--tint-500: color-mix(in srgb, currentColor var(--alpha-500), transparent);--tint-600: color-mix(in srgb, currentColor var(--alpha-600), transparent);--tint-700: color-mix(in srgb, currentColor var(--alpha-700), transparent);--tint-800: color-mix(in srgb, currentColor var(--alpha-800), transparent);--tint-900: color-mix(in srgb, currentColor var(--alpha-900), transparent);--tint-950: color-mix(in srgb, currentColor var(--alpha-950), transparent);--color-overlay-hover: color-mix(in srgb, var(--black) var(--alpha-100), transparent);--color-overlay-active: color-mix(in srgb, var(--black) var(--alpha-300), transparent);--backdrop-blur-glass: blur(20px) saturate(1.4);--black: #000000;--white: #ffffff;--neutral-50: oklch(.985 0 0);--neutral-100: oklch(.97 0 0);--neutral-200: oklch(.923 0 0);--neutral-300: oklch(.869 0 0);--neutral-350: oklch(.79 0 0);--neutral-400: oklch(.709 0 0);--neutral-500: oklch(.553 0 0);--neutral-600: oklch(.444 0 0);--neutral-700: oklch(.374 0 0);--neutral-800: oklch(.268 0 0);--neutral-900: oklch(.216 0 0);--neutral-950: oklch(.147 0 0);--red-50: oklch(.969 .015 12.422);--red-100: oklch(.941 .03 12.58);--red-200: oklch(.892 .058 10.001);--red-300: oklch(.81 .117 11.638);--red-400: oklch(.712 .194 13.428);--red-500: oklch(.645 .246 16.439);--red-600: oklch(.586 .253 17.585);--red-700: oklch(.514 .222 16.935);--red-800: oklch(.455 .188 13.697);--red-900: oklch(.41 .159 10.272);--red-950: oklch(.271 .105 12.094);--orange-50: oklch(.98 .016 73.684);--orange-100: oklch(.954 .038 75.164);--orange-200: oklch(.901 .076 70.697);--orange-300: oklch(.837 .128 66.29);--orange-400: oklch(.75 .183 55.934);--orange-500: oklch(.705 .213 47.604);--orange-600: oklch(.646 .222 41.116);--orange-700: oklch(.553 .195 38.402);--orange-800: oklch(.47 .157 37.304);--orange-900: oklch(.408 .123 38.172);--orange-950: oklch(.266 .079 36.259);--yellow-50: oklch(.987 .026 102.212);--yellow-100: oklch(.973 .071 103.193);--yellow-200: oklch(.945 .129 101.54);--yellow-300: oklch(.905 .182 98.111);--yellow-400: oklch(.852 .199 91.936);--yellow-500: oklch(.795 .184 86.047);--yellow-600: oklch(.681 .162 75.834);--yellow-700: oklch(.554 .135 66.442);--yellow-800: oklch(.476 .114 61.907);--yellow-900: oklch(.421 .095 57.708);--yellow-950: oklch(.286 .066 53.813);--green-50: oklch(.979 .021 166.113);--green-100: oklch(.95 .052 163.051);--green-200: oklch(.905 .093 164.15);--green-300: oklch(.845 .143 164.978);--green-400: oklch(.765 .177 163.223);--green-500: oklch(.696 .17 162.48);--green-600: oklch(.596 .145 163.225);--green-700: oklch(.508 .118 165.612);--green-800: oklch(.432 .095 166.913);--green-900: oklch(.378 .077 168.94);--green-950: oklch(.262 .051 172.552);--blue-50: oklch(.97 .014 254.604);--blue-100: oklch(.932 .032 255.585);--blue-200: oklch(.882 .059 254.128);--blue-300: oklch(.809 .105 251.813);--blue-400: oklch(.707 .165 254.624);--blue-500: oklch(.623 .214 259.815);--blue-600: oklch(.546 .245 262.881);--blue-700: oklch(.488 .243 264.376);--blue-800: oklch(.424 .199 265.638);--blue-900: oklch(.379 .146 265.522);--blue-950: oklch(.282 .091 267.935);--purple-50: oklch(.969 .016 293.756);--purple-100: oklch(.943 .029 294.588);--purple-200: oklch(.894 .057 293.283);--purple-300: oklch(.811 .111 293.571);--purple-400: oklch(.702 .183 293.541);--purple-500: oklch(.606 .25 292.717);--purple-600: oklch(.541 .281 293.009);--purple-700: oklch(.491 .27 292.581);--purple-800: oklch(.432 .232 292.759);--purple-900: oklch(.38 .189 293.745);--purple-950: oklch(.283 .141 291.089)}@supports (corner-shape: squircle){:root{--radius-8: 10px;--radius-12: 15px;--radius-16: 20px;--radius-24: 30px}}:root[data-font=system]{--font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif}:root{--color-bg: var(--neutral-50);--color-bg-muted: var(--neutral-100);--color-surface: var(--white);--color-surface-muted: var(--neutral-100);--color-interactive: var(--neutral-200);--color-interactive-hover: var(--neutral-300);--color-border: rgba(0, 0, 0, .1);--color-border-muted: rgba(0, 0, 0, .06);--color-text: var(--neutral-900);--color-text-muted: var(--neutral-500);--color-link: inherit;--color-focus-ring: var(--neutral-500);--color-overlay-backdrop: rgb(0 0 0 / .5);--color-highlight: rgb(255 255 255 / .5);--color-primary: var(--blue-500);--color-danger: var(--red-600);color-scheme:light}body{font-family:var(--font-sans);font-size:var(--text-base);font-weight:var(--font-weight-body);line-height:var(--leading-base);letter-spacing:.015em;color:var(--color-text);background:var(--color-bg);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}a{color:var(--color-link);text-underline-offset:.15em;text-decoration-thickness:.08em}h1,h2,h3,h4,h5,h6{font-weight:600;color:inherit}code{font-family:var(--font-mono);font-size:.9em;background:var(--color-bg-muted);padding:var(--space-2) var(--space-4);border-radius:var(--radius-4)}pre{font-family:var(--font-mono);background:var(--color-bg-muted);padding:var(--space-12);border-radius:var(--radius-8);overflow-x:auto}pre code{background:none;padding:0}blockquote{padding-left:var(--space-16);border-left:3px solid var(--color-border);color:var(--color-text-muted)}hr{border:none;border-top:1px solid var(--color-border)}table{border-collapse:collapse}th,td{padding:var(--space-8) var(--space-12);border:1px solid var(--color-border);text-align:left}th{background:var(--color-bg-muted);font-weight:600}input,textarea{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-md);padding:0 10px}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(--color-overlay-hover);backdrop-filter:saturate(1.2);-webkit-backdrop-filter:saturate(1.2)}button[variant=ghost]:active:not(:disabled){background:var(--color-overlay-active);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}: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}.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:var(--color-overlay-backdrop)}panel-view{display:block}panel-view::part(panel){display:flex;flex-direction:column;gap:var(--space-16);color:var(--color-text)}panel-view::part(header){display:flex;align-items:center;justify-content:space-between;gap:var(--space-12)}panel-view::part(title){margin:0;font:inherit;font-size:var(--text-lg);font-weight:600;color:var(--color-text)}panel-view::part(button){display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;margin:0;border:1px solid var(--color-border);border-radius:var(--radius-4);background:var(--color-surface);color:var(--color-text);box-shadow:none}panel-view::part(button):hover{background:var(--color-interactive-hover)}panel-view::part(button):focus-visible{outline:2px solid var(--color-focus-ring);outline-offset:2px}panel-view::part(icon){display:inline-flex;align-items:center;justify-content:center;flex:none}ui-popover{display:contents}ui-popover::part(panel){position:fixed;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-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)}',Ah=new CSSStyleSheet;Ah.replaceSync(Kx);const $h=new CSSStyleSheet;try{document.adoptedStyleSheets=[...document.adoptedStyleSheets,Ah,$h]}catch{}Pm(document);function Dm(r){$h.replaceSync(r)}function za(){Dm("")}function Lm(r){try{r.adoptedStyleSheets=[...r.adoptedStyleSheets,Ah,$h]}catch{}Pm(r)}const Jx=new Set(["target","currentTarget","eventPhase","defaultPrevented","isTrusted","timeStamp","srcElement","returnValue","cancelBubble","NONE","CAPTURING_PHASE","AT_TARGET","BUBBLING_PHASE","composedPath","stopPropagation","stopImmediatePropagation","preventDefault","initEvent"]);function Qx(r){for(const t of Object.keys(r))if(Jx.has(t))throw new Error(`Event payload key "${t}" is reserved; choose a different property name`)}function eA(r,t){Qx(t);for(const e of Object.keys(t))Object.defineProperty(r,e,{value:t[e],writable:!0,enumerable:!0,configurable:!0})}function it(){class r extends Event{constructor(e,n){const{type:i,bubbles:s,cancelable:o,composed:a,...c}=n??{};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}),eA(this,c)}}return r}class Wt extends globalThis.EventTarget{}function tA(r,t,e){const n=r.dispose.bind(r);r.dispose=()=>{if(!t())return e(),n()}}function Io(r){var e;class t extends r{constructor(...s){super(...s);w(this,e,!1);tA(this,()=>l(this,e),()=>{x(this,e,!0)})}[Symbol.dispose](){this.dispose()}get disposed(){return l(this,e)}}return e=new WeakMap,t}const rA=it(),nA=it(),iA=it(),pa=it(),zm="0123456789ABCDEFGHJKMNPQRSTVWXYZ",Oa=32,sA=16,Om=10,sf=0xffffffffffff;var Kr;(function(r){r.Base32IncorrectEncoding="B32_ENC_INVALID",r.DecodeTimeInvalidCharacter="DEC_TIME_CHAR",r.DecodeTimeValueMalformed="DEC_TIME_MALFORMED",r.EncodeTimeNegative="ENC_TIME_NEG",r.EncodeTimeSizeExceeded="ENC_TIME_SIZE_EXCEED",r.EncodeTimeValueMalformed="ENC_TIME_MALFORMED",r.PRNGDetectFailure="PRNG_DETECT",r.ULIDInvalid="ULID_INVALID",r.Unexpected="UNEXPECTED",r.UUIDInvalid="UUID_INVALID"})(Kr||(Kr={}));class is extends Error{constructor(t,e){super(`${e} (${t})`),this.name="ULIDError",this.code=t}}function oA(r){const t=Math.floor(r()*Oa)%Oa;return zm.charAt(t)}function aA(r){const t=lA(),e=t&&(t.crypto||t.msCrypto)||null;if(typeof(e==null?void 0:e.getRandomValues)=="function")return()=>{const n=new Uint8Array(1);return e.getRandomValues(n),n[0]/256};if(typeof(e==null?void 0:e.randomBytes)=="function")return()=>e.randomBytes(1).readUInt8()/256;throw new is(Kr.PRNGDetectFailure,"Failed to find a reliable PRNG")}function lA(){return hA()?self:typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:null}function cA(r,t){let e="";for(;r>0;r--)e=oA(t)+e;return e}function uA(r,t=Om){if(isNaN(r))throw new is(Kr.EncodeTimeValueMalformed,`Time must be a number: ${r}`);if(r>sf)throw new is(Kr.EncodeTimeSizeExceeded,`Cannot encode a time larger than ${sf}: ${r}`);if(r<0)throw new is(Kr.EncodeTimeNegative,`Time must be positive: ${r}`);if(Number.isInteger(r)===!1)throw new is(Kr.EncodeTimeValueMalformed,`Time must be an integer: ${r}`);let e,n="";for(let i=t;i>0;i--)e=r%Oa,n=zm.charAt(e)+n,r=(r-e)/Oa;return n}function hA(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}function yl(r,t){const e=aA(),n=Date.now();return uA(n,Om)+cA(sA,e)}const ft=4,ct=6,ws=2,Jc=2,Ih=8,dA=ct,Th="auto",$r="auto",fr=120,of=50,ce=16,_n=fr*ft+ce*(ft-1),Ma=fr*ct+ce*(ct-1),pA=_n+ce*2,fA=200,gA=4,Yo=150,mA=10,af=2,lf=8,vA=300,yA=4;function Mm(r){return Fm(r)}function Nm(r,t){return Fm(r.flatMap(e=>Hm(e,t)))}function Um(r){const t=[],e=new Set;for(const n of r){if(n.type==="row"){t.push(`Top-level rows are invalid: ${n.id}`);continue}Zm(n,"strip",t,e)}return{valid:t.length===0,errors:t}}function Jr(r){const t=Mm(r),e=Um(t);if(!e.valid)throw new Error(`Invalid layout: ${e.errors.join("; ")}`);return{totalNodes:t.length,nodes:t.filter(n=>n.type!=="row").map(_A)}}function Fm(r){const t=[];for(const e of r){const n=Wm(e);for(const i of n){if(i.type==="row"){t.push(...i.children.map(or));continue}t.push(i)}}return t}function Wm(r){switch(r.type){case"card":return[or(r)];case"row":{const t=r.children.map(or);return t.length===0?[]:t.length===1?[t[0]]:[{...r,children:t}]}case"stack":{const t=[];for(const e of r.children){const n=Wm(e);for(const i of n){if(i.type==="stack"){t.push(...i.children.map(Qc));continue}if(i.type==="row"){t.push({...i,children:i.children.map(or)});continue}t.push(or(i))}}return t.length===0?[]:t.length===1?[Qc(t[0])]:[{...r,children:t}]}}}function Hm(r,t){switch(r.type){case"card":return r.artifactID===t?[]:[or(r)];case"row":{const e=r.children.filter(n=>n.artifactID!==t).map(or);return e.length===0?[]:e.length===1?[e[0]]:[{...r,children:e}]}case"stack":{const e=r.children.flatMap(n=>Hm(n,t).filter(s=>s.type!=="stack"));return e.length===0?[]:e.length===1?[Qc(e[0])]:[{...r,children:e}]}}}function Zm(r,t,e,n){switch(r.type){case"card":Bm(r,t,e,n);return;case"row":bA(r,t,e,n);return;case"stack":wA(r,t,e,n);return}}function Bm(r,t,e,n){Ch(r.id,e),typeof r.artifactID!="string"||r.artifactID.length===0?e.push(`Card ${r.id} is missing artifactID`):n.has(r.artifactID)?e.push(`Duplicate artifactID in layout: ${r.artifactID}`):n.add(r.artifactID),SA(r.width)||e.push(`Card ${r.id} width must be an integer in the range ${ws}-${Ih}`),jm(r.height)||e.push(`Card ${r.id} height must be an integer in the range 2-6 or "auto"`);const i=Gr(r.width);t==="row"&&i<ws&&e.push(`Row child ${r.id} must be at least 2 columns wide`)}function bA(r,t,e,n){if(Ch(r.id,e),t!=="stack"&&e.push(`Row ${r.id} may only appear inside a stack`),jm(r.height,yA)||e.push(`Row ${r.id} height must be an integer in the range 2-4 or "auto"`),!Array.isArray(r.children)||r.children.length===0){e.push(`Row ${r.id} must contain card nodes`);return}let i=0;for(const s of r.children){if(s.type!=="card"){e.push(`Row ${r.id} must contain only card nodes`);continue}Bm(s,"row",e,n),i+=Gr(s.width)}i!==ft&&e.push(`Row ${r.id} children must sum to 4 columns`)}function wA(r,t,e,n){if(Ch(r.id,e),t!=="strip"&&e.push(`Invalid nested stack at ${r.id}; stack children cannot contain another nested stack`),!Array.isArray(r.children)||r.children.length===0){e.push(`Stack ${r.id} must contain at least one child`);return}let i=0,s=0;for(const a of r.children){if(a.type==="stack"){e.push(`Stack ${r.id} cannot contain another nested stack`);continue}if(Zm(a,"stack",e,n),a.height===$r){s+=1;continue}i+=a.height}if(i>ct&&e.push(`Stack ${r.id} exceeds the 6-row budget`),s===0)return;const o=ct-i;if(o<s*Jc||o%s!==0){e.push(`Stack ${r.id} has auto-height children that cannot resolve to whole height >= 2`);return}o/s<Jc&&e.push(`Stack ${r.id} has auto-height children below the minimum row size`)}function Ch(r,t){(typeof r!="string"||r.length===0)&&t.push(`Node id must be a non-empty string: ${String(r)}`)}function SA(r){return r===Th||Number.isInteger(r)&&r>=ws&&r<=Ih}function jm(r,t=dA){return r===$r||Number.isInteger(r)&&r>=Jc&&r<=t}function Gr(r){return r===Th?ft:r}function _A(r){if(r.type==="card")return{id:r.id,type:"card",width:Gr(r.width),cards:[{id:r.id,artifactID:r.artifactID,col:1,row:1,width:Gr(r.width),height:Vm(r.height,ct)}]};const t=kA(r.children),e=[];let n=1;for(let i=0;i<r.children.length;i+=1){const s=r.children[i],o=t[i];if(s.type==="card")e.push({id:s.id,artifactID:s.artifactID,col:1,row:n,width:Math.min(ft,Gr(s.width)),height:o});else{let a=1;for(const c of s.children)e.push({id:c.id,artifactID:c.artifactID,col:a,row:n,width:Gr(c.width),height:o}),a+=Gr(c.width)}n+=o}return{id:r.id,type:"stack",width:e.reduce((i,s)=>Math.max(i,s.col+s.width-1),1),cards:e}}function kA(r){let t=0,e=0;for(const i of r)i.height===$r?e+=1:t+=i.height;const n=e>0?(ct-t)/e:0;return r.map(i=>Vm(i.height,n))}function Vm(r,t){return r===$r?t:r}function or(r){return{...r}}function Qc(r){return r.type==="card"?or(r):{...r,children:r.children.map(or)}}function Gm(r,t={}){return{id:t.id??yl(),type:"card",artifactID:r,width:t.width??Th,height:t.height??$r}}function qm(r,t){return r.some(e=>Ym(e,t))}function Ym(r,t){switch(r.type){case"card":return r.artifactID===t;case"row":return r.children.some(e=>e.artifactID===t);case"stack":return r.children.some(e=>Ym(e,t))}}function cf(r){return r.layout.flatMap(Xm)}function Xm(r){switch(r.type){case"card":return[r.artifactID];case"row":return r.children.map(t=>t.artifactID);case"stack":return r.children.flatMap(Xm)}}const oe=it(),eu=it(),Zn=it(),EA=it();function xA(r){class t extends Error{constructor(n,i){super(n),this.name=r,i&&Object.assign(this,i)}}return t}const AA=xA("RequestError"),$A=200,IA=300;class TA{constructor(t,e){y(this,"serverURL");y(this,"token");this.serverURL=t.replace(/\/$/,""),this.token=e.token}async requestJSON(t,e,n){const i=await this.request(t,e,n!==void 0?JSON.stringify(n):void 0,n!==void 0?{"content-type":"application/json"}:void 0),s=await CA(i);if(!i.ok||i.status<$A||i.status>=IA)throw this.createError(typeof s.error=="string"?s.error:i.statusText,i.status);return s}async requestVoid(t,e,n){const i=await this.request(t,e,n!==void 0?JSON.stringify(n):void 0,n!==void 0?{"content-type":"application/json"}:void 0);if(!i.ok)throw this.createError(await Sc(i,i.statusText),i.status)}async requestText(t,e){const n=await this.request(t,e);if(!n.ok)throw this.createError(await Sc(n,n.statusText),n.status);return n.text()}async requestRawVoid(t,e,n){const i=await this.request(t,e,n,{"content-type":"text/plain"});if(!i.ok)throw this.createError(await Sc(i,i.statusText),i.status)}createError(t,e){const n={serverURL:this.serverURL};return e!==void 0&&(n.status=e),new AA(t,n)}async request(t,e,n,i){const s=`${this.serverURL}${e}`;try{return await fetch(s,{method:t,headers:this.buildHeaders(i),body:n})}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 CA(r){try{return await r.json()}catch{const t=await r.text().catch(()=>"");return t?{message:t}:{}}}async function Sc(r,t){try{const e=await r.json();if(typeof e.error=="string")return e.error;if(typeof e.message=="string")return e.message}catch{}return t}function RA(r){return r.map(t=>`${t.name} (${t.id})`).join(", ")}var Pt,Ya,Km;class PA{constructor(t){w(this,Ya);w(this,Pt);x(this,Pt,t)}list(){return l(this,Pt).requestJSON("GET","/screens")}async get(t={}){const e=await f(this,Ya,Km).call(this,t.screenID);return l(this,Pt).requestJSON("GET",`/screens/${encodeURIComponent(e)}`)}create(t){const e={name:t.name};return t.id!==void 0&&(e.id=t.id),l(this,Pt).requestJSON("POST","/screens",e)}update(t){const{screenID:e,...n}=t;return l(this,Pt).requestJSON("PATCH",`/screens/${encodeURIComponent(e)}`,n)}remove(t){return l(this,Pt).requestJSON("DELETE",`/screens/${encodeURIComponent(t.screenID)}`)}}Pt=new WeakMap,Ya=new WeakSet,Km=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,Pt).createError(`screenID is required when multiple screens exist. Available screens: ${RA(e)}`)};var Ue;class DA{constructor(t){w(this,Ue);x(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 n=e.toString();return l(this,Ue).requestJSON("GET",n?`/artifacts?${n}`:"/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 en;class LA{constructor(t){w(this,en);x(this,en,t)}get(){return l(this,en).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,en).requestVoid("PATCH","/display",e)}focus(t){const e={artifactID:t.artifactID};return t.screenID!==void 0&&(e.screenID=t.screenID),l(this,en).requestJSON("POST","/display/focus",e)}}en=new WeakMap;var $s;class zA{constructor(t){w(this,$s);x(this,$s,t)}async list(){const{views:t}=await l(this,$s).requestJSON("GET","/views");return t}}$s=new WeakMap;var Xt;class OA{constructor(t,e={}){y(this,"screens");y(this,"artifacts");y(this,"display");y(this,"views");w(this,Xt);x(this,Xt,new TA(t,e)),this.screens=new PA(l(this,Xt)),this.artifacts=new DA(l(this,Xt)),this.display=new LA(l(this,Xt)),this.views=new zA(l(this,Xt))}health(){return l(this,Xt).requestJSON("GET","/health")}}Xt=new WeakMap;const MA={focusCommandInput:{label:"Focus Command Input",trigger:{key:"k",meta:!0}}},NA="Local",UA="store-";function we(r){return new URL(r).origin}function FA(r){return{servers:[{url:we(r),name:NA}],activeServerURL:null,activeScreenID:null,tabs:{},screens:{}}}function WA(r,t){return[...r.tabs[we(t)]??[]]}function HA(r,t,e){const n=we(t),i=r.tabs[n]??[];return i.includes(e)?r:{...r,tabs:{...r.tabs,[n]:[...i,e]}}}function ZA(r,t,e){const n=we(t),i=r.tabs[n]??[],s=i.filter(a=>a!==e);if(s.length===i.length)return r;const o={...r.tabs};return s.length===0?delete o[n]:o[n]=s,{...r,tabs:o}}var tn,rn,nn;class BA extends Wt{constructor(e,n,i={}){super();w(this,tn);w(this,rn);w(this,nn);x(this,tn,`${UA}${e}`),x(this,rn,i.storage??jA());const s=l(this,rn).getItem(l(this,tn));s===null?(x(this,nn,n),l(this,rn).setItem(l(this,tn),JSON.stringify(n))):x(this,nn,VA(JSON.parse(s),n))}get(){return l(this,nn)}set(e){x(this,nn,e),l(this,rn).setItem(l(this,tn),JSON.stringify(e)),this.dispatchEvent(new oe("change"))}}tn=new WeakMap,rn=new WeakMap,nn=new WeakMap;function jA(){const r=globalThis.localStorage;if(!r)throw new Error("LocalStore: no storage adapter supplied and window.localStorage is unavailable");return r}function VA(r,t){return{servers:Array.isArray(r.servers)?r.servers:t.servers,activeServerURL:typeof r.activeServerURL=="string"||r.activeServerURL===null?r.activeServerURL:t.activeServerURL,activeScreenID:typeof r.activeScreenID=="string"||r.activeScreenID===null?r.activeScreenID:t.activeScreenID,tabs:r.tabs&&typeof r.tabs=="object"?r.tabs:t.tabs,screens:r.screens&&typeof r.screens=="object"?r.screens:t.screens}}const GA=Io(Wt);var sn,Ke,on,Ze,mr,vr,te,Vn,Jm,Is,Qm,ev,tv,rv,tu,ru,nu,nv;class qA extends GA{constructor(e){var i;super();w(this,te);y(this,"id");y(this,"server");w(this,sn);w(this,Ke,new Map);w(this,on);w(this,Ze);w(this,mr);w(this,vr,null);w(this,Is,e=>{if(this.disposed)return;const n=e.event;switch(n.type){case"screen-updated":n.screen.id===this.id&&f(this,te,Qm).call(this,n.screen);break;case"artifact-created":break;case"artifact-attached":n.screenID===this.id&&f(this,te,ev).call(this,n.cardID,n.artifact);break;case"artifact-updated":f(this,te,tv).call(this,n.artifact);break;case"artifact-removed":n.screenID===this.id&&f(this,te,rv).call(this,n.artifactID);break;case"artifact-content-changed":l(this,Ke).has(n.artifactID)&&this.dispatchEvent(new EA("artifact-content-changed",{artifactID:n.artifactID}));break}});this.id=e.screen.id,this.server=e.server,x(this,sn,e.localStore),x(this,on,e.screen.name),x(this,Ze,structuredClone(e.screen.layout));const n=((i=l(this,sn).get().screens[this.id])==null?void 0:i.scrollPosition)??0;x(this,mr,Math.max(0,n)),this.server.addEventListener("server-event",l(this,Is)),f(this,te,Jm).call(this)}get name(){return l(this,on)}get layout(){return l(this,Ze)}get scrollPosition(){return l(this,mr)}get artifacts(){return l(this,Ke)}setScrollPosition(e){f(this,te,Vn).call(this);const n=Math.max(0,e);n!==l(this,mr)&&(x(this,mr,n),f(this,te,nv).call(this),this.dispatchEvent(new oe("change")))}setLayout(e){f(this,te,Vn).call(this);const n=Mm(e);if(!Um(n).valid)return;const s=f(this,te,ru).call(this);x(this,Ze,n),x(this,vr,{layout:n,snapshot:s}),this.dispatchEvent(new oe("change")),this.server.client.screens.update({screenID:this.id,layout:n.map(o=>structuredClone(o))}).catch(()=>{var o;this.disposed||((o=l(this,vr))==null?void 0:o.layout)===n&&(x(this,vr,null),f(this,te,nu).call(this,s),this.dispatchEvent(new oe("change")))})}rename(e){f(this,te,Vn).call(this),x(this,on,e),this.dispatchEvent(new oe("change")),this.server.client.screens.update({screenID:this.id,name:e}).catch(()=>{})}async remove(){f(this,te,Vn).call(this),await this.server.client.screens.remove({screenID:this.id})}removeArtifact(e){if(f(this,te,Vn).call(this),!l(this,Ke).has(e))return;const n=f(this,te,ru).call(this);f(this,te,tu).call(this,e),this.dispatchEvent(new oe("change")),this.server.client.artifacts.detach({artifactID:e,screenID:this.id}).catch(()=>{this.disposed||(f(this,te,nu).call(this,n),this.dispatchEvent(new oe("change")))})}dispose(){this.server.removeEventListener("server-event",l(this,Is))}}sn=new WeakMap,Ke=new WeakMap,on=new WeakMap,Ze=new WeakMap,mr=new WeakMap,vr=new WeakMap,te=new WeakSet,Vn=function(){if(this.disposed)throw new Error("ScreenModel is disposed")},Jm=async function(){try{const e=await this.server.client.screens.get({screenID:this.id});if(this.disposed)return;for(const n of e.artifacts)l(this,Ke).set(n.id,n);this.dispatchEvent(new oe("change"))}catch{}},Is=new WeakMap,Qm=function(e){l(this,vr)&&x(this,vr,null),x(this,on,e.name),x(this,Ze,structuredClone(e.layout)),this.dispatchEvent(new oe("change"))},ev=function(e,n){qm(l(this,Ze),n.id)||x(this,Ze,[...l(this,Ze),Gm(n.id,{id:e})]),l(this,Ke).set(n.id,n),this.dispatchEvent(new oe("change"))},tv=function(e){const n=l(this,Ke).get(e.id);n&&(l(this,Ke).set(e.id,{...n,...e}),this.dispatchEvent(new oe("change")))},rv=function(e){f(this,te,tu).call(this,e)&&this.dispatchEvent(new oe("change"))},tu=function(e){const n=l(this,Ke).delete(e),i=cf({layout:l(this,Ze)}).length,s=Nm(l(this,Ze),e),o=cf({layout:s}).length;return x(this,Ze,s),n||i!==o},ru=function(){return{layout:structuredClone(l(this,Ze)),artifacts:new Map([...l(this,Ke).entries()].map(([e,n])=>[e,structuredClone(n)]))}},nu=function(e){x(this,Ze,structuredClone(e.layout)),l(this,Ke).clear();for(const[n,i]of e.artifacts)l(this,Ke).set(n,structuredClone(i))},nv=function(){const e=l(this,sn).get();l(this,sn).set({...e,screens:{...e.screens,[this.id]:{scrollPosition:l(this,mr)}}})};const YA=Io(Wt);var Le,Je,Dt,Ts,Cs,Rs,je,fa,iu,Gn;class XA extends YA{constructor(e){super();w(this,je);w(this,Le);w(this,Je);w(this,Dt,null);w(this,Ts,()=>{this.disposed||f(this,je,fa).call(this)});w(this,Cs,()=>{this.disposed||f(this,je,fa).call(this)});w(this,Rs,e=>{if(this.disposed)return;const n=e.event;if(n.type==="screen-removed"){this.removeTab(e.serverURL,n.screenID);const i=l(this,Le).get();i.activeServerURL===we(e.serverURL)&&i.activeScreenID===n.screenID&&f(this,je,Gn).call(this,e.serverURL,null);return}if(n.type==="screen-changed"){if(n.screenID===null){f(this,je,Gn).call(this,e.serverURL,null);return}const i=l(this,Je).servers.get(we(e.serverURL));if(!i||!i.screens.has(n.screenID))return;this.addTab(e.serverURL,n.screenID),f(this,je,Gn).call(this,e.serverURL,n.screenID)}});x(this,Le,e.localStore),x(this,Je,e.serverManager),l(this,Le).addEventListener("change",l(this,Ts)),l(this,Je).addEventListener("change",l(this,Cs)),l(this,Je).addEventListener("server-event",l(this,Rs)),f(this,je,fa).call(this)}get activeScreen(){return l(this,Dt)}getTabs(e){const n=we(e),i=WA(l(this,Le).get(),n),s=l(this,Je).servers.get(n);return s?i.filter(o=>s.screens.has(o)):i}hasTab(e,n){return this.getTabs(e).includes(n)}addTab(e,n){const i=we(e),s=l(this,Je).servers.get(i);s&&!s.screens.has(n)||f(this,je,iu).call(this,HA(l(this,Le).get(),i,n))}removeTab(e,n){f(this,je,iu).call(this,ZA(l(this,Le).get(),e,n))}setActive(e,n){const i=we(e),s=l(this,Je).servers.get(i);!s||!s.screens.has(n)||f(this,je,Gn).call(this,i,n)&&s.client.display.patch({activeScreenID:n}).catch(()=>{})}clearActive(){const e=l(this,Le).get().activeServerURL;if(!e||!f(this,je,Gn).call(this,e,null))return;const n=l(this,Je).servers.get(e);n==null||n.client.display.patch({activeScreenID:null}).catch(()=>{})}dispose(){var e;l(this,Le).removeEventListener("change",l(this,Ts)),l(this,Je).removeEventListener("change",l(this,Cs)),l(this,Je).removeEventListener("server-event",l(this,Rs)),(e=l(this,Dt))==null||e.dispose(),x(this,Dt,null)}}Le=new WeakMap,Je=new WeakMap,Dt=new WeakMap,Ts=new WeakMap,Cs=new WeakMap,Rs=new WeakMap,je=new WeakSet,fa=function(){var c,u,h;const{activeServerURL:e,activeScreenID:n}=l(this,Le).get(),i=e?l(this,Je).servers.get(e)??null:null,s=i&&n?i.screens.get(n)??null:null,o=((c=l(this,Dt))==null?void 0:c.id)??null,a=(s==null?void 0:s.id)??null;o===a&&((u=l(this,Dt))==null?void 0:u.server)===i||((h=l(this,Dt))==null||h.dispose(),x(this,Dt,i&&s?new qA({screen:s,server:i,localStore:l(this,Le)}):null),i&&i.acpClient.setScreenContext(s?{screenID:s.id,screenName:s.name}:null),this.dispatchEvent(new rA("active-screen-changed")))},iu=function(e){e!==l(this,Le).get()&&(l(this,Le).set(e),this.dispatchEvent(new nA("tabs-changed")))},Gn=function(e,n){const i=we(e),s=l(this,Le).get();return s.activeServerURL===i&&s.activeScreenID===n?!1:(l(this,Le).set({...s,activeServerURL:i,activeScreenID:n}),!0)};function A(r,t,e){function n(a,c){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:c,constr:o,traits:new Set},enumerable:!1}),a._zod.traits.has(r))return;a._zod.traits.add(r),t(a,c);const u=o.prototype,h=Object.keys(u);for(let p=0;p<h.length;p++){const m=h[p];m in a||(a[m]=u[m].bind(a))}}const i=(e==null?void 0:e.Parent)??Object;class s extends i{}Object.defineProperty(s,"name",{value:r});function o(a){var c;const u=e!=null&&e.Parent?new s:this;n(u,a),(c=u._zod).deferred??(c.deferred=[]);for(const h of u._zod.deferred)h();return u}return Object.defineProperty(o,"init",{value:n}),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(r)}}),Object.defineProperty(o,"name",{value:r}),o}class si extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class iv extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const sv={};function Ir(r){return sv}function ov(r){const t=Object.values(r).filter(n=>typeof n=="number");return Object.entries(r).filter(([n,i])=>t.indexOf(+n)===-1).map(([n,i])=>i)}function su(r,t){return typeof t=="bigint"?t.toString():t}function Rh(r){return{get value(){{const t=r();return Object.defineProperty(this,"value",{value:t}),t}}}}function Ph(r){return r==null}function Dh(r){const t=r.startsWith("^")?1:0,e=r.endsWith("$")?r.length-1:r.length;return r.slice(t,e)}function KA(r,t){const e=(r.toString().split(".")[1]||"").length,n=t.toString();let i=(n.split(".")[1]||"").length;if(i===0&&/\d?e-\d?/.test(n)){const c=n.match(/\d?e-(\d?)/);c!=null&&c[1]&&(i=Number.parseInt(c[1]))}const s=e>i?e:i,o=Number.parseInt(r.toFixed(s).replace(".","")),a=Number.parseInt(t.toFixed(s).replace(".",""));return o%a/10**s}const uf=Symbol("evaluating");function re(r,t,e){let n;Object.defineProperty(r,t,{get(){if(n!==uf)return n===void 0&&(n=uf,n=e()),n},set(i){Object.defineProperty(r,t,{value:i})},configurable:!0})}function Rn(r,t,e){Object.defineProperty(r,t,{value:e,writable:!0,enumerable:!0,configurable:!0})}function Lr(...r){const t={};for(const e of r){const n=Object.getOwnPropertyDescriptors(e);Object.assign(t,n)}return Object.defineProperties({},t)}function hf(r){return JSON.stringify(r)}function JA(r){return r.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const av="captureStackTrace"in Error?Error.captureStackTrace:(...r)=>{};function Na(r){return typeof r=="object"&&r!==null&&!Array.isArray(r)}const QA=Rh(()=>{var r;if(typeof navigator<"u"&&((r=navigator==null?void 0:navigator.userAgent)!=null&&r.includes("Cloudflare")))return!1;try{const t=Function;return new t(""),!0}catch{return!1}});function $i(r){if(Na(r)===!1)return!1;const t=r.constructor;if(t===void 0||typeof t!="function")return!0;const e=t.prototype;return!(Na(e)===!1||Object.prototype.hasOwnProperty.call(e,"isPrototypeOf")===!1)}function lv(r){return $i(r)?{...r}:Array.isArray(r)?[...r]:r}const e$=new Set(["string","number","symbol"]);function Ii(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function zr(r,t,e){const n=new r._zod.constr(t??r._zod.def);return(!t||e!=null&&e.parent)&&(n._zod.parent=r),n}function O(r){const t=r;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 t$(r){return Object.keys(r).filter(t=>r[t]._zod.optin==="optional"&&r[t]._zod.optout==="optional")}const r$={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 n$(r,t){const e=r._zod.def,n=e.checks;if(n&&n.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const s=Lr(r._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 Rn(this,"shape",o),o},checks:[]});return zr(r,s)}function i$(r,t){const e=r._zod.def,n=e.checks;if(n&&n.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const s=Lr(r._zod.def,{get shape(){const o={...r._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 Rn(this,"shape",o),o},checks:[]});return zr(r,s)}function s$(r,t){if(!$i(t))throw new Error("Invalid input to extend: expected a plain object");const e=r._zod.def.checks;if(e&&e.length>0){const s=r._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=Lr(r._zod.def,{get shape(){const s={...r._zod.def.shape,...t};return Rn(this,"shape",s),s}});return zr(r,i)}function o$(r,t){if(!$i(t))throw new Error("Invalid input to safeExtend: expected a plain object");const e=Lr(r._zod.def,{get shape(){const n={...r._zod.def.shape,...t};return Rn(this,"shape",n),n}});return zr(r,e)}function a$(r,t){const e=Lr(r._zod.def,{get shape(){const n={...r._zod.def.shape,...t._zod.def.shape};return Rn(this,"shape",n),n},get catchall(){return t._zod.def.catchall},checks:[]});return zr(r,e)}function l$(r,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=Lr(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]=r?new r({type:"optional",innerType:a[u]}):a[u])}else for(const u in a)c[u]=r?new r({type:"optional",innerType:a[u]}):a[u];return Rn(this,"shape",c),c},checks:[]});return zr(t,o)}function c$(r,t,e){const n=Lr(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 r({type:"nonoptional",innerType:i[o]}))}else for(const o in i)s[o]=new r({type:"nonoptional",innerType:i[o]});return Rn(this,"shape",s),s}});return zr(t,n)}function ri(r,t=0){var e;if(r.aborted===!0)return!0;for(let n=t;n<r.issues.length;n++)if(((e=r.issues[n])==null?void 0:e.continue)!==!0)return!0;return!1}function ni(r,t){return t.map(e=>{var n;return(n=e).path??(n.path=[]),e.path.unshift(r),e})}function Xo(r){return typeof r=="string"?r:r==null?void 0:r.message}function Tr(r,t,e){var i,s,o,a,c,u;const n={...r,path:r.path??[]};if(!r.message){const h=Xo((o=(s=(i=r.inst)==null?void 0:i._zod.def)==null?void 0:s.error)==null?void 0:o.call(s,r))??Xo((a=t==null?void 0:t.error)==null?void 0:a.call(t,r))??Xo((c=e.customError)==null?void 0:c.call(e,r))??Xo((u=e.localeError)==null?void 0:u.call(e,r))??"Invalid input";n.message=h}return delete n.inst,delete n.continue,t!=null&&t.reportInput||delete n.input,n}function Lh(r){return Array.isArray(r)?"array":typeof r=="string"?"string":"unknown"}function Ss(...r){const[t,e,n]=r;return typeof t=="string"?{message:t,code:"custom",input:e,inst:n}:{...t}}const cv=(r,t)=>{r.name="$ZodError",Object.defineProperty(r,"_zod",{value:r._zod,enumerable:!1}),Object.defineProperty(r,"issues",{value:t,enumerable:!1}),r.message=JSON.stringify(t,su,2),Object.defineProperty(r,"toString",{value:()=>r.message,enumerable:!1})},uv=A("$ZodError",cv),hv=A("$ZodError",cv,{Parent:Error});function u$(r,t=e=>e.message){const e={},n=[];for(const i of r.issues)i.path.length>0?(e[i.path[0]]=e[i.path[0]]||[],e[i.path[0]].push(t(i))):n.push(t(i));return{formErrors:n,fieldErrors:e}}function h$(r,t=e=>e.message){const e={_errors:[]},n=i=>{for(const s of i.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(o=>n({issues:o}));else if(s.code==="invalid_key")n({issues:s.issues});else if(s.code==="invalid_element")n({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 n(r),e}const zh=r=>(t,e,n,i)=>{const s=n?Object.assign(n,{async:!1}):{async:!1},o=t._zod.run({value:e,issues:[]},s);if(o instanceof Promise)throw new si;if(o.issues.length){const a=new((i==null?void 0:i.Err)??r)(o.issues.map(c=>Tr(c,s,Ir())));throw av(a,i==null?void 0:i.callee),a}return o.value},Oh=r=>async(t,e,n,i)=>{const s=n?Object.assign(n,{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)??r)(o.issues.map(c=>Tr(c,s,Ir())));throw av(a,i==null?void 0:i.callee),a}return o.value},bl=r=>(t,e,n)=>{const i=n?{...n,async:!1}:{async:!1},s=t._zod.run({value:e,issues:[]},i);if(s instanceof Promise)throw new si;return s.issues.length?{success:!1,error:new(r??uv)(s.issues.map(o=>Tr(o,i,Ir())))}:{success:!0,data:s.value}},d$=bl(hv),wl=r=>async(t,e,n)=>{const i=n?Object.assign(n,{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 r(s.issues.map(o=>Tr(o,i,Ir())))}:{success:!0,data:s.value}},p$=wl(hv),f$=r=>(t,e,n)=>{const i=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return zh(r)(t,e,i)},g$=r=>(t,e,n)=>zh(r)(t,e,n),m$=r=>async(t,e,n)=>{const i=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return Oh(r)(t,e,i)},v$=r=>async(t,e,n)=>Oh(r)(t,e,n),y$=r=>(t,e,n)=>{const i=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return bl(r)(t,e,i)},b$=r=>(t,e,n)=>bl(r)(t,e,n),w$=r=>async(t,e,n)=>{const i=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return wl(r)(t,e,i)},S$=r=>async(t,e,n)=>wl(r)(t,e,n),_$=/^[cC][^\s-]{8,}$/,k$=/^[0-9a-z]+$/,E$=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,x$=/^[0-9a-vA-V]{20}$/,A$=/^[A-Za-z0-9]{27}$/,$$=/^[a-zA-Z0-9_-]{21}$/,I$=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,T$=/^([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})$/,df=r=>r?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${r}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,C$=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,R$="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function P$(){return new RegExp(R$,"u")}const D$=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,L$=/^(([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}|:))$/,z$=/^((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])$/,O$=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,M$=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,dv=/^[A-Za-z0-9_-]*$/,N$=/^\+[1-9]\d{6,14}$/,pv="(?:(?:\\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])))",U$=new RegExp(`^${pv}$`);function fv(r){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof r.precision=="number"?r.precision===-1?`${t}`:r.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${r.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function F$(r){return new RegExp(`^${fv(r)}$`)}function W$(r){const t=fv({precision:r.precision}),e=["Z"];r.local&&e.push(""),r.offset&&e.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const n=`${t}(?:${e.join("|")})`;return new RegExp(`^${pv}T(?:${n})$`)}const H$=r=>{const t=r?`[\\s\\S]{${(r==null?void 0:r.minimum)??0},${(r==null?void 0:r.maximum)??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},Z$=/^-?\d+$/,gv=/^-?\d+(?:\.\d+)?$/,B$=/^(?:true|false)$/i,j$=/^[^A-Z]*$/,V$=/^[^a-z]*$/,st=A("$ZodCheck",(r,t)=>{var e;r._zod??(r._zod={}),r._zod.def=t,(e=r._zod).onattach??(e.onattach=[])}),mv={number:"number",bigint:"bigint",object:"date"},vv=A("$ZodCheckLessThan",(r,t)=>{st.init(r,t);const e=mv[typeof t.value];r._zod.onattach.push(n=>{const i=n._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)}),r._zod.check=n=>{(t.inclusive?n.value<=t.value:n.value<t.value)||n.issues.push({origin:e,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:r,continue:!t.abort})}}),yv=A("$ZodCheckGreaterThan",(r,t)=>{st.init(r,t);const e=mv[typeof t.value];r._zod.onattach.push(n=>{const i=n._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)}),r._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:e,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:r,continue:!t.abort})}}),G$=A("$ZodCheckMultipleOf",(r,t)=>{st.init(r,t),r._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),r._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):KA(e.value,t.value)===0)||e.issues.push({origin:typeof e.value,code:"not_multiple_of",divisor:t.value,input:e.value,inst:r,continue:!t.abort})}}),q$=A("$ZodCheckNumberFormat",(r,t)=>{var o;st.init(r,t),t.format=t.format||"float64";const e=(o=t.format)==null?void 0:o.includes("int"),n=e?"int":"number",[i,s]=r$[t.format];r._zod.onattach.push(a=>{const c=a._zod.bag;c.format=t.format,c.minimum=i,c.maximum=s,e&&(c.pattern=Z$)}),r._zod.check=a=>{const c=a.value;if(e){if(!Number.isInteger(c)){a.issues.push({expected:n,format:t.format,code:"invalid_type",continue:!1,input:c,inst:r});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:r,origin:n,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:r,origin:n,inclusive:!0,continue:!t.abort});return}}c<i&&a.issues.push({origin:"number",input:c,code:"too_small",minimum:i,inclusive:!0,inst:r,continue:!t.abort}),c>s&&a.issues.push({origin:"number",input:c,code:"too_big",maximum:s,inclusive:!0,inst:r,continue:!t.abort})}}),Y$=A("$ZodCheckMaxLength",(r,t)=>{var e;st.init(r,t),(e=r._zod.def).when??(e.when=n=>{const i=n.value;return!Ph(i)&&i.length!==void 0}),r._zod.onattach.push(n=>{const i=n._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<i&&(n._zod.bag.maximum=t.maximum)}),r._zod.check=n=>{const i=n.value;if(i.length<=t.maximum)return;const o=Lh(i);n.issues.push({origin:o,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:r,continue:!t.abort})}}),X$=A("$ZodCheckMinLength",(r,t)=>{var e;st.init(r,t),(e=r._zod.def).when??(e.when=n=>{const i=n.value;return!Ph(i)&&i.length!==void 0}),r._zod.onattach.push(n=>{const i=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>i&&(n._zod.bag.minimum=t.minimum)}),r._zod.check=n=>{const i=n.value;if(i.length>=t.minimum)return;const o=Lh(i);n.issues.push({origin:o,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:r,continue:!t.abort})}}),K$=A("$ZodCheckLengthEquals",(r,t)=>{var e;st.init(r,t),(e=r._zod.def).when??(e.when=n=>{const i=n.value;return!Ph(i)&&i.length!==void 0}),r._zod.onattach.push(n=>{const i=n._zod.bag;i.minimum=t.length,i.maximum=t.length,i.length=t.length}),r._zod.check=n=>{const i=n.value,s=i.length;if(s===t.length)return;const o=Lh(i),a=s>t.length;n.issues.push({origin:o,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:r,continue:!t.abort})}}),Sl=A("$ZodCheckStringFormat",(r,t)=>{var e,n;st.init(r,t),r._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=r._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:r,continue:!t.abort})}):(n=r._zod).check??(n.check=()=>{})}),J$=A("$ZodCheckRegex",(r,t)=>{Sl.init(r,t),r._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:r,continue:!t.abort})}}),Q$=A("$ZodCheckLowerCase",(r,t)=>{t.pattern??(t.pattern=j$),Sl.init(r,t)}),eI=A("$ZodCheckUpperCase",(r,t)=>{t.pattern??(t.pattern=V$),Sl.init(r,t)}),tI=A("$ZodCheckIncludes",(r,t)=>{st.init(r,t);const e=Ii(t.includes),n=new RegExp(typeof t.position=="number"?`^.{${t.position}}${e}`:e);t.pattern=n,r._zod.onattach.push(i=>{const s=i._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(n)}),r._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:r,continue:!t.abort})}}),rI=A("$ZodCheckStartsWith",(r,t)=>{st.init(r,t);const e=new RegExp(`^${Ii(t.prefix)}.*`);t.pattern??(t.pattern=e),r._zod.onattach.push(n=>{const i=n._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(e)}),r._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:r,continue:!t.abort})}}),nI=A("$ZodCheckEndsWith",(r,t)=>{st.init(r,t);const e=new RegExp(`.*${Ii(t.suffix)}$`);t.pattern??(t.pattern=e),r._zod.onattach.push(n=>{const i=n._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(e)}),r._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:r,continue:!t.abort})}}),iI=A("$ZodCheckOverwrite",(r,t)=>{st.init(r,t),r._zod.check=e=>{e.value=t.tx(e.value)}});class sI{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 n=t.split(`
|
|
5
|
-
`).filter(o=>o),i=Math.min(...n.map(o=>o.length-o.trimStart().length)),s=n.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 oI={major:4,minor:3,patch:6},ge=A("$ZodType",(r,t)=>{var i;var e;r??(r={}),r._zod.def=t,r._zod.bag=r._zod.bag||{},r._zod.version=oI;const n=[...r._zod.def.checks??[]];r._zod.traits.has("$ZodCheck")&&n.unshift(r);for(const s of n)for(const o of s._zod.onattach)o(r);if(n.length===0)(e=r._zod).deferred??(e.deferred=[]),(i=r._zod.deferred)==null||i.push(()=>{r._zod.run=r._zod.parse});else{const s=(a,c,u)=>{let h=ri(a),p;for(const m of c){if(m._zod.def.when){if(!m._zod.def.when(a))continue}else if(h)continue;const g=a.issues.length,S=m._zod.check(a);if(S instanceof Promise&&(u==null?void 0:u.async)===!1)throw new si;if(p||S instanceof Promise)p=(p??Promise.resolve()).then(async()=>{await S,a.issues.length!==g&&(h||(h=ri(a,g)))});else{if(a.issues.length===g)continue;h||(h=ri(a,g))}}return p?p.then(()=>a):a},o=(a,c,u)=>{if(ri(a))return a.aborted=!0,a;const h=s(c,n,u);if(h instanceof Promise){if(u.async===!1)throw new si;return h.then(p=>r._zod.parse(p,u))}return r._zod.parse(h,u)};r._zod.run=(a,c)=>{if(c.skipChecks)return r._zod.parse(a,c);if(c.direction==="backward"){const h=r._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=r._zod.parse(a,c);if(u instanceof Promise){if(c.async===!1)throw new si;return u.then(h=>s(h,n,c))}return s(u,n,c)}}re(r,"~standard",()=>({validate:s=>{var o;try{const a=d$(r,s);return a.success?{value:a.data}:{issues:(o=a.error)==null?void 0:o.issues}}catch{return p$(r,s).then(c=>{var u;return c.success?{value:c.data}:{issues:(u=c.error)==null?void 0:u.issues}})}},vendor:"zod",version:1}))}),Mh=A("$ZodString",(r,t)=>{var e;ge.init(r,t),r._zod.pattern=[...((e=r==null?void 0:r._zod.bag)==null?void 0:e.patterns)??[]].pop()??H$(r._zod.bag),r._zod.parse=(n,i)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:r}),n}}),de=A("$ZodStringFormat",(r,t)=>{Sl.init(r,t),Mh.init(r,t)}),aI=A("$ZodGUID",(r,t)=>{t.pattern??(t.pattern=T$),de.init(r,t)}),lI=A("$ZodUUID",(r,t)=>{if(t.version){const n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(n===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=df(n))}else t.pattern??(t.pattern=df());de.init(r,t)}),cI=A("$ZodEmail",(r,t)=>{t.pattern??(t.pattern=C$),de.init(r,t)}),uI=A("$ZodURL",(r,t)=>{de.init(r,t),r._zod.check=e=>{try{const n=e.value.trim(),i=new URL(n);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:r,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:r,continue:!t.abort})),t.normalize?e.value=i.href:e.value=n;return}catch{e.issues.push({code:"invalid_format",format:"url",input:e.value,inst:r,continue:!t.abort})}}}),hI=A("$ZodEmoji",(r,t)=>{t.pattern??(t.pattern=P$()),de.init(r,t)}),dI=A("$ZodNanoID",(r,t)=>{t.pattern??(t.pattern=$$),de.init(r,t)}),pI=A("$ZodCUID",(r,t)=>{t.pattern??(t.pattern=_$),de.init(r,t)}),fI=A("$ZodCUID2",(r,t)=>{t.pattern??(t.pattern=k$),de.init(r,t)}),gI=A("$ZodULID",(r,t)=>{t.pattern??(t.pattern=E$),de.init(r,t)}),mI=A("$ZodXID",(r,t)=>{t.pattern??(t.pattern=x$),de.init(r,t)}),vI=A("$ZodKSUID",(r,t)=>{t.pattern??(t.pattern=A$),de.init(r,t)}),yI=A("$ZodISODateTime",(r,t)=>{t.pattern??(t.pattern=W$(t)),de.init(r,t)}),bI=A("$ZodISODate",(r,t)=>{t.pattern??(t.pattern=U$),de.init(r,t)}),wI=A("$ZodISOTime",(r,t)=>{t.pattern??(t.pattern=F$(t)),de.init(r,t)}),SI=A("$ZodISODuration",(r,t)=>{t.pattern??(t.pattern=I$),de.init(r,t)}),_I=A("$ZodIPv4",(r,t)=>{t.pattern??(t.pattern=D$),de.init(r,t),r._zod.bag.format="ipv4"}),kI=A("$ZodIPv6",(r,t)=>{t.pattern??(t.pattern=L$),de.init(r,t),r._zod.bag.format="ipv6",r._zod.check=e=>{try{new URL(`http://[${e.value}]`)}catch{e.issues.push({code:"invalid_format",format:"ipv6",input:e.value,inst:r,continue:!t.abort})}}}),EI=A("$ZodCIDRv4",(r,t)=>{t.pattern??(t.pattern=z$),de.init(r,t)}),xI=A("$ZodCIDRv6",(r,t)=>{t.pattern??(t.pattern=O$),de.init(r,t),r._zod.check=e=>{const n=e.value.split("/");try{if(n.length!==2)throw new Error;const[i,s]=n;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:r,continue:!t.abort})}}});function bv(r){if(r==="")return!0;if(r.length%4!==0)return!1;try{return atob(r),!0}catch{return!1}}const AI=A("$ZodBase64",(r,t)=>{t.pattern??(t.pattern=M$),de.init(r,t),r._zod.bag.contentEncoding="base64",r._zod.check=e=>{bv(e.value)||e.issues.push({code:"invalid_format",format:"base64",input:e.value,inst:r,continue:!t.abort})}});function $I(r){if(!dv.test(r))return!1;const t=r.replace(/[-_]/g,n=>n==="-"?"+":"/"),e=t.padEnd(Math.ceil(t.length/4)*4,"=");return bv(e)}const II=A("$ZodBase64URL",(r,t)=>{t.pattern??(t.pattern=dv),de.init(r,t),r._zod.bag.contentEncoding="base64url",r._zod.check=e=>{$I(e.value)||e.issues.push({code:"invalid_format",format:"base64url",input:e.value,inst:r,continue:!t.abort})}}),TI=A("$ZodE164",(r,t)=>{t.pattern??(t.pattern=N$),de.init(r,t)});function CI(r,t=null){try{const e=r.split(".");if(e.length!==3)return!1;const[n]=e;if(!n)return!1;const i=JSON.parse(atob(n));return!("typ"in i&&(i==null?void 0:i.typ)!=="JWT"||!i.alg||t&&(!("alg"in i)||i.alg!==t))}catch{return!1}}const RI=A("$ZodJWT",(r,t)=>{de.init(r,t),r._zod.check=e=>{CI(e.value,t.alg)||e.issues.push({code:"invalid_format",format:"jwt",input:e.value,inst:r,continue:!t.abort})}}),wv=A("$ZodNumber",(r,t)=>{ge.init(r,t),r._zod.pattern=r._zod.bag.pattern??gv,r._zod.parse=(e,n)=>{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:r,...s?{received:s}:{}}),e}}),PI=A("$ZodNumberFormat",(r,t)=>{q$.init(r,t),wv.init(r,t)}),DI=A("$ZodBoolean",(r,t)=>{ge.init(r,t),r._zod.pattern=B$,r._zod.parse=(e,n)=>{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:r}),e}}),LI=A("$ZodUnknown",(r,t)=>{ge.init(r,t),r._zod.parse=e=>e}),zI=A("$ZodNever",(r,t)=>{ge.init(r,t),r._zod.parse=(e,n)=>(e.issues.push({expected:"never",code:"invalid_type",input:e.value,inst:r}),e)});function pf(r,t,e){r.issues.length&&t.issues.push(...ni(e,r.issues)),t.value[e]=r.value}const OI=A("$ZodArray",(r,t)=>{ge.init(r,t),r._zod.parse=(e,n)=>{const i=e.value;if(!Array.isArray(i))return e.issues.push({expected:"array",code:"invalid_type",input:i,inst:r}),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:[]},n);c instanceof Promise?s.push(c.then(u=>pf(u,e,o))):pf(c,e,o)}return s.length?Promise.all(s).then(()=>e):e}});function Ua(r,t,e,n,i){if(r.issues.length){if(i&&!(e in n))return;t.issues.push(...ni(e,r.issues))}r.value===void 0?e in n&&(t.value[e]=void 0):t.value[e]=r.value}function Sv(r){var n,i,s,o;const t=Object.keys(r.shape);for(const a of t)if(!((o=(s=(i=(n=r.shape)==null?void 0:n[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=t$(r.shape);return{...r,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(e)}}function _v(r,t,e,n,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 m=c.run({value:t[p],issues:[]},n);m instanceof Promise?r.push(m.then(g=>Ua(g,e,p,t,h))):Ua(m,e,p,t,h)}return o.length&&e.issues.push({code:"unrecognized_keys",keys:o,input:t,inst:s}),r.length?Promise.all(r).then(()=>e):e}const MI=A("$ZodObject",(r,t)=>{ge.init(r,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 n=Rh(()=>Sv(t));re(r._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=Na,s=t.catchall;let o;r._zod.parse=(a,c)=>{o??(o=n.value);const u=a.value;if(!i(u))return a.issues.push({expected:"object",code:"invalid_type",input:u,inst:r}),a;a.value={};const h=[],p=o.shape;for(const m of o.keys){const g=p[m],S=g._zod.optout==="optional",_=g._zod.run({value:u[m],issues:[]},c);_ instanceof Promise?h.push(_.then(I=>Ua(I,a,m,u,S))):Ua(_,a,m,u,S)}return s?_v(h,u,a,c,n.value,r):h.length?Promise.all(h).then(()=>a):a}}),NI=A("$ZodObjectJIT",(r,t)=>{MI.init(r,t);const e=r._zod.parse,n=Rh(()=>Sv(t)),i=m=>{var W;const g=new sI(["shape","payload","ctx"]),S=n.value,_=M=>{const U=hf(M);return`shape[${U}]._zod.run({ value: input[${U}], issues: [] }, ctx)`};g.write("const input = payload.value;");const I=Object.create(null);let P=0;for(const M of S.keys)I[M]=`key_${P++}`;g.write("const newResult = {};");for(const M of S.keys){const U=I[M],Y=hf(M),V=m[M],le=((W=V==null?void 0:V._zod)==null?void 0:W.optout)==="optional";g.write(`const ${U} = ${_(M)};`),le?g.write(`
|
|
7
|
-
if (${U}.issues.length) {
|
|
8
|
-
if (${Y} in input) {
|
|
9
|
-
payload.issues = payload.issues.concat(${U}.issues.map(iss => ({
|
|
10
|
-
...iss,
|
|
11
|
-
path: iss.path ? [${Y}, ...iss.path] : [${Y}]
|
|
12
|
-
})));
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
if (${U}.value === undefined) {
|
|
17
|
-
if (${Y} in input) {
|
|
18
|
-
newResult[${Y}] = undefined;
|
|
19
|
-
}
|
|
20
|
-
} else {
|
|
21
|
-
newResult[${Y}] = ${U}.value;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
`):g.write(`
|
|
25
|
-
if (${U}.issues.length) {
|
|
26
|
-
payload.issues = payload.issues.concat(${U}.issues.map(iss => ({
|
|
27
|
-
...iss,
|
|
28
|
-
path: iss.path ? [${Y}, ...iss.path] : [${Y}]
|
|
29
|
-
})));
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if (${U}.value === undefined) {
|
|
33
|
-
if (${Y} in input) {
|
|
34
|
-
newResult[${Y}] = undefined;
|
|
35
|
-
}
|
|
36
|
-
} else {
|
|
37
|
-
newResult[${Y}] = ${U}.value;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
`)}g.write("payload.value = newResult;"),g.write("return payload;");const R=g.compile();return(M,U)=>R(m,M,U)};let s;const o=Na,a=!sv.jitless,u=a&&QA.value,h=t.catchall;let p;r._zod.parse=(m,g)=>{p??(p=n.value);const S=m.value;return o(S)?a&&u&&(g==null?void 0:g.async)===!1&&g.jitless!==!0?(s||(s=i(t.shape)),m=s(m,g),h?_v([],S,m,g,p,r):m):e(m,g):(m.issues.push({expected:"object",code:"invalid_type",input:S,inst:r}),m)}});function ff(r,t,e,n){for(const s of r)if(s.issues.length===0)return t.value=s.value,t;const i=r.filter(s=>!ri(s));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:e,errors:r.map(s=>s.issues.map(o=>Tr(o,n,Ir())))}),t)}const UI=A("$ZodUnion",(r,t)=>{ge.init(r,t),re(r._zod,"optin",()=>t.options.some(i=>i._zod.optin==="optional")?"optional":void 0),re(r._zod,"optout",()=>t.options.some(i=>i._zod.optout==="optional")?"optional":void 0),re(r._zod,"values",()=>{if(t.options.every(i=>i._zod.values))return new Set(t.options.flatMap(i=>Array.from(i._zod.values)))}),re(r._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=>Dh(s.source)).join("|")})$`)}});const e=t.options.length===1,n=t.options[0]._zod.run;r._zod.parse=(i,s)=>{if(e)return n(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=>ff(c,i,r,s)):ff(a,i,r,s)}}),FI=A("$ZodIntersection",(r,t)=>{ge.init(r,t),r._zod.parse=(e,n)=>{const i=e.value,s=t.left._zod.run({value:i,issues:[]},n),o=t.right._zod.run({value:i,issues:[]},n);return s instanceof Promise||o instanceof Promise?Promise.all([s,o]).then(([c,u])=>gf(e,c,u)):gf(e,s,o)}});function ou(r,t){if(r===t)return{valid:!0,data:r};if(r instanceof Date&&t instanceof Date&&+r==+t)return{valid:!0,data:r};if($i(r)&&$i(t)){const e=Object.keys(t),n=Object.keys(r).filter(s=>e.indexOf(s)!==-1),i={...r,...t};for(const s of n){const o=ou(r[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(r)&&Array.isArray(t)){if(r.length!==t.length)return{valid:!1,mergeErrorPath:[]};const e=[];for(let n=0;n<r.length;n++){const i=r[n],s=t[n],o=ou(i,s);if(!o.valid)return{valid:!1,mergeErrorPath:[n,...o.mergeErrorPath]};e.push(o.data)}return{valid:!0,data:e}}return{valid:!1,mergeErrorPath:[]}}function gf(r,t,e){const n=new Map;let i;for(const a of t.issues)if(a.code==="unrecognized_keys"){i??(i=a);for(const c of a.keys)n.has(c)||n.set(c,{}),n.get(c).l=!0}else r.issues.push(a);for(const a of e.issues)if(a.code==="unrecognized_keys")for(const c of a.keys)n.has(c)||n.set(c,{}),n.get(c).r=!0;else r.issues.push(a);const s=[...n].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(s.length&&i&&r.issues.push({...i,keys:s}),ri(r))return r;const o=ou(t.value,e.value);if(!o.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return r.value=o.data,r}const WI=A("$ZodRecord",(r,t)=>{ge.init(r,t),r._zod.parse=(e,n)=>{const i=e.value;if(!$i(i))return e.issues.push({expected:"record",code:"invalid_type",input:i,inst:r}),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:[]},n);h instanceof Promise?s.push(h.then(p=>{p.issues.length&&e.issues.push(...ni(u,p.issues)),e.value[u]=p.value})):(h.issues.length&&e.issues.push(...ni(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:r,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:[]},n);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof a=="string"&&gv.test(a)&&c.issues.length){const p=t.keyType._zod.run({value:Number(a),issues:[]},n);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=>Tr(p,n,Ir())),input:a,path:[a],inst:r});continue}const h=t.valueType._zod.run({value:i[a],issues:[]},n);h instanceof Promise?s.push(h.then(p=>{p.issues.length&&e.issues.push(...ni(a,p.issues)),e.value[c.value]=p.value})):(h.issues.length&&e.issues.push(...ni(a,h.issues)),e.value[c.value]=h.value)}}return s.length?Promise.all(s).then(()=>e):e}}),HI=A("$ZodEnum",(r,t)=>{ge.init(r,t);const e=ov(t.entries),n=new Set(e);r._zod.values=n,r._zod.pattern=new RegExp(`^(${e.filter(i=>e$.has(typeof i)).map(i=>typeof i=="string"?Ii(i):i.toString()).join("|")})$`),r._zod.parse=(i,s)=>{const o=i.value;return n.has(o)||i.issues.push({code:"invalid_value",values:e,input:o,inst:r}),i}}),ZI=A("$ZodLiteral",(r,t)=>{if(ge.init(r,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");const e=new Set(t.values);r._zod.values=e,r._zod.pattern=new RegExp(`^(${t.values.map(n=>typeof n=="string"?Ii(n):n?Ii(n.toString()):String(n)).join("|")})$`),r._zod.parse=(n,i)=>{const s=n.value;return e.has(s)||n.issues.push({code:"invalid_value",values:t.values,input:s,inst:r}),n}}),BI=A("$ZodTransform",(r,t)=>{ge.init(r,t),r._zod.parse=(e,n)=>{if(n.direction==="backward")throw new iv(r.constructor.name);const i=t.transform(e.value,e);if(n.async)return(i instanceof Promise?i:Promise.resolve(i)).then(o=>(e.value=o,e));if(i instanceof Promise)throw new si;return e.value=i,e}});function mf(r,t){return r.issues.length&&t===void 0?{issues:[],value:void 0}:r}const kv=A("$ZodOptional",(r,t)=>{ge.init(r,t),r._zod.optin="optional",r._zod.optout="optional",re(r._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),re(r._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${Dh(e.source)})?$`):void 0}),r._zod.parse=(e,n)=>{if(t.innerType._zod.optin==="optional"){const i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(s=>mf(s,e.value)):mf(i,e.value)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),jI=A("$ZodExactOptional",(r,t)=>{kv.init(r,t),re(r._zod,"values",()=>t.innerType._zod.values),re(r._zod,"pattern",()=>t.innerType._zod.pattern),r._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),VI=A("$ZodNullable",(r,t)=>{ge.init(r,t),re(r._zod,"optin",()=>t.innerType._zod.optin),re(r._zod,"optout",()=>t.innerType._zod.optout),re(r._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${Dh(e.source)}|null)$`):void 0}),re(r._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),r._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),GI=A("$ZodDefault",(r,t)=>{ge.init(r,t),r._zod.optin="optional",re(r._zod,"values",()=>t.innerType._zod.values),r._zod.parse=(e,n)=>{if(n.direction==="backward")return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;const i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(s=>vf(s,t)):vf(i,t)}});function vf(r,t){return r.value===void 0&&(r.value=t.defaultValue),r}const qI=A("$ZodPrefault",(r,t)=>{ge.init(r,t),r._zod.optin="optional",re(r._zod,"values",()=>t.innerType._zod.values),r._zod.parse=(e,n)=>(n.direction==="backward"||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),YI=A("$ZodNonOptional",(r,t)=>{ge.init(r,t),re(r._zod,"values",()=>{const e=t.innerType._zod.values;return e?new Set([...e].filter(n=>n!==void 0)):void 0}),r._zod.parse=(e,n)=>{const i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(s=>yf(s,r)):yf(i,r)}});function yf(r,t){return!r.issues.length&&r.value===void 0&&r.issues.push({code:"invalid_type",expected:"nonoptional",input:r.value,inst:t}),r}const XI=A("$ZodCatch",(r,t)=>{ge.init(r,t),re(r._zod,"optin",()=>t.innerType._zod.optin),re(r._zod,"optout",()=>t.innerType._zod.optout),re(r._zod,"values",()=>t.innerType._zod.values),r._zod.parse=(e,n)=>{if(n.direction==="backward")return t.innerType._zod.run(e,n);const i=t.innerType._zod.run(e,n);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=>Tr(o,n,Ir()))},input:e.value}),e.issues=[]),e)):(e.value=i.value,i.issues.length&&(e.value=t.catchValue({...e,error:{issues:i.issues.map(s=>Tr(s,n,Ir()))},input:e.value}),e.issues=[]),e)}}),KI=A("$ZodPipe",(r,t)=>{ge.init(r,t),re(r._zod,"values",()=>t.in._zod.values),re(r._zod,"optin",()=>t.in._zod.optin),re(r._zod,"optout",()=>t.out._zod.optout),re(r._zod,"propValues",()=>t.in._zod.propValues),r._zod.parse=(e,n)=>{if(n.direction==="backward"){const s=t.out._zod.run(e,n);return s instanceof Promise?s.then(o=>Ko(o,t.in,n)):Ko(s,t.in,n)}const i=t.in._zod.run(e,n);return i instanceof Promise?i.then(s=>Ko(s,t.out,n)):Ko(i,t.out,n)}});function Ko(r,t,e){return r.issues.length?(r.aborted=!0,r):t._zod.run({value:r.value,issues:r.issues},e)}const JI=A("$ZodReadonly",(r,t)=>{ge.init(r,t),re(r._zod,"propValues",()=>t.innerType._zod.propValues),re(r._zod,"values",()=>t.innerType._zod.values),re(r._zod,"optin",()=>{var e,n;return(n=(e=t.innerType)==null?void 0:e._zod)==null?void 0:n.optin}),re(r._zod,"optout",()=>{var e,n;return(n=(e=t.innerType)==null?void 0:e._zod)==null?void 0:n.optout}),r._zod.parse=(e,n)=>{if(n.direction==="backward")return t.innerType._zod.run(e,n);const i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(bf):bf(i)}});function bf(r){return r.value=Object.freeze(r.value),r}const QI=A("$ZodCustom",(r,t)=>{st.init(r,t),ge.init(r,t),r._zod.parse=(e,n)=>e,r._zod.check=e=>{const n=e.value,i=t.fn(n);if(i instanceof Promise)return i.then(s=>wf(s,e,n,r));wf(i,e,n,r)}});function wf(r,t,e,n){if(!r){const i={code:"custom",input:e,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(i.params=n._zod.def.params),t.issues.push(Ss(i))}}var Sf;class eT{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...e){const n=e[0];return this._map.set(t,n),n&&typeof n=="object"&&"id"in n&&this._idmap.set(n.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 n={...this.get(e)??{}};delete n.id;const i={...n,...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 tT(){return new eT}(Sf=globalThis).__zod_globalRegistry??(Sf.__zod_globalRegistry=tT());const ss=globalThis.__zod_globalRegistry;function rT(r,t){return new r({type:"string",...O(t)})}function nT(r,t){return new r({type:"string",format:"email",check:"string_format",abort:!1,...O(t)})}function _f(r,t){return new r({type:"string",format:"guid",check:"string_format",abort:!1,...O(t)})}function iT(r,t){return new r({type:"string",format:"uuid",check:"string_format",abort:!1,...O(t)})}function sT(r,t){return new r({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...O(t)})}function oT(r,t){return new r({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...O(t)})}function aT(r,t){return new r({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...O(t)})}function lT(r,t){return new r({type:"string",format:"url",check:"string_format",abort:!1,...O(t)})}function cT(r,t){return new r({type:"string",format:"emoji",check:"string_format",abort:!1,...O(t)})}function uT(r,t){return new r({type:"string",format:"nanoid",check:"string_format",abort:!1,...O(t)})}function hT(r,t){return new r({type:"string",format:"cuid",check:"string_format",abort:!1,...O(t)})}function dT(r,t){return new r({type:"string",format:"cuid2",check:"string_format",abort:!1,...O(t)})}function pT(r,t){return new r({type:"string",format:"ulid",check:"string_format",abort:!1,...O(t)})}function fT(r,t){return new r({type:"string",format:"xid",check:"string_format",abort:!1,...O(t)})}function gT(r,t){return new r({type:"string",format:"ksuid",check:"string_format",abort:!1,...O(t)})}function mT(r,t){return new r({type:"string",format:"ipv4",check:"string_format",abort:!1,...O(t)})}function vT(r,t){return new r({type:"string",format:"ipv6",check:"string_format",abort:!1,...O(t)})}function yT(r,t){return new r({type:"string",format:"cidrv4",check:"string_format",abort:!1,...O(t)})}function bT(r,t){return new r({type:"string",format:"cidrv6",check:"string_format",abort:!1,...O(t)})}function wT(r,t){return new r({type:"string",format:"base64",check:"string_format",abort:!1,...O(t)})}function ST(r,t){return new r({type:"string",format:"base64url",check:"string_format",abort:!1,...O(t)})}function _T(r,t){return new r({type:"string",format:"e164",check:"string_format",abort:!1,...O(t)})}function kT(r,t){return new r({type:"string",format:"jwt",check:"string_format",abort:!1,...O(t)})}function ET(r,t){return new r({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...O(t)})}function xT(r,t){return new r({type:"string",format:"date",check:"string_format",...O(t)})}function AT(r,t){return new r({type:"string",format:"time",check:"string_format",precision:null,...O(t)})}function $T(r,t){return new r({type:"string",format:"duration",check:"string_format",...O(t)})}function IT(r,t){return new r({type:"number",checks:[],...O(t)})}function TT(r,t){return new r({type:"number",check:"number_format",abort:!1,format:"safeint",...O(t)})}function CT(r,t){return new r({type:"boolean",...O(t)})}function RT(r){return new r({type:"unknown"})}function PT(r,t){return new r({type:"never",...O(t)})}function kf(r,t){return new vv({check:"less_than",...O(t),value:r,inclusive:!1})}function _c(r,t){return new vv({check:"less_than",...O(t),value:r,inclusive:!0})}function Ef(r,t){return new yv({check:"greater_than",...O(t),value:r,inclusive:!1})}function kc(r,t){return new yv({check:"greater_than",...O(t),value:r,inclusive:!0})}function xf(r,t){return new G$({check:"multiple_of",...O(t),value:r})}function Ev(r,t){return new Y$({check:"max_length",...O(t),maximum:r})}function Fa(r,t){return new X$({check:"min_length",...O(t),minimum:r})}function xv(r,t){return new K$({check:"length_equals",...O(t),length:r})}function DT(r,t){return new J$({check:"string_format",format:"regex",...O(t),pattern:r})}function LT(r){return new Q$({check:"string_format",format:"lowercase",...O(r)})}function zT(r){return new eI({check:"string_format",format:"uppercase",...O(r)})}function OT(r,t){return new tI({check:"string_format",format:"includes",...O(t),includes:r})}function MT(r,t){return new rI({check:"string_format",format:"starts_with",...O(t),prefix:r})}function NT(r,t){return new nI({check:"string_format",format:"ends_with",...O(t),suffix:r})}function Ni(r){return new iI({check:"overwrite",tx:r})}function UT(r){return Ni(t=>t.normalize(r))}function FT(){return Ni(r=>r.trim())}function WT(){return Ni(r=>r.toLowerCase())}function HT(){return Ni(r=>r.toUpperCase())}function ZT(){return Ni(r=>JA(r))}function BT(r,t,e){return new r({type:"array",element:t,...O(e)})}function jT(r,t,e){return new r({type:"custom",check:"custom",fn:t,...O(e)})}function VT(r){const t=GT(e=>(e.addIssue=n=>{if(typeof n=="string")e.issues.push(Ss(n,e.value,t._zod.def));else{const i=n;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(Ss(i))}},r(e.value,e)));return t}function GT(r,t){const e=new st({check:"custom",...O(t)});return e._zod.check=r,e}function Av(r){let t=(r==null?void 0:r.target)??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:r.processors??{},metadataRegistry:(r==null?void 0:r.metadata)??ss,target:t,unrepresentable:(r==null?void 0:r.unrepresentable)??"throw",override:(r==null?void 0:r.override)??(()=>{}),io:(r==null?void 0:r.io)??"output",counter:0,seen:new Map,cycles:(r==null?void 0:r.cycles)??"ref",reused:(r==null?void 0:r.reused)??"inline",external:(r==null?void 0:r.external)??void 0}}function _e(r,t,e={path:[],schemaPath:[]}){var h,p;var n;const i=r._zod.def,s=t.seen.get(r);if(s)return s.count++,e.schemaPath.includes(r)&&(s.cycle=e.path),s.schema;const o={schema:{},count:1,cycle:void 0,path:e.path};t.seen.set(r,o);const a=(p=(h=r._zod).toJSONSchema)==null?void 0:p.call(h);if(a)o.schema=a;else{const m={...e,schemaPath:[...e.schemaPath,r],path:e.path};if(r._zod.processJSONSchema)r._zod.processJSONSchema(t,o.schema,m);else{const S=o.schema,_=t.processors[i.type];if(!_)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);_(r,t,S,m)}const g=r._zod.parent;g&&(o.ref||(o.ref=g),_e(g,t,m),t.seen.get(g).isParent=!0)}const c=t.metadataRegistry.get(r);return c&&Object.assign(o.schema,c),t.io==="input"&&He(r)&&(delete o.schema.examples,delete o.schema.default),t.io==="input"&&o.schema._prefault&&((n=o.schema).default??(n.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(r).schema}function $v(r,t){var o,a,c,u;const e=r.seen.get(t);if(!e)throw new Error("Unprocessed schema. This is a bug in Zod.");const n=new Map;for(const h of r.seen.entries()){const p=(o=r.metadataRegistry.get(h[0]))==null?void 0:o.id;if(p){const m=n.get(p);if(m&&m!==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.`);n.set(p,h[0])}}const i=h=>{var _;const p=r.target==="draft-2020-12"?"$defs":"definitions";if(r.external){const I=(_=r.external.registry.get(h[0]))==null?void 0:_.id,P=r.external.uri??(W=>W);if(I)return{ref:P(I)};const R=h[1].defId??h[1].schema.id??`schema${r.counter++}`;return h[1].defId=R,{defId:R,ref:`${P("__shared")}#/${p}/${R}`}}if(h[1]===e)return{ref:"#"};const g=`#/${p}/`,S=h[1].schema.id??`__schema${r.counter++}`;return{defId:S,ref:g+S}},s=h=>{if(h[1].schema.$ref)return;const p=h[1],{ref:m,defId:g}=i(h);p.def={...p.schema},g&&(p.defId=g);const S=p.schema;for(const _ in S)delete S[_];S.$ref=m};if(r.cycles==="throw")for(const h of r.seen.entries()){const p=h[1];if(p.cycle)throw new Error(`Cycle detected: #/${(a=p.cycle)==null?void 0:a.join("/")}/<root>
|
|
41
|
-
|
|
42
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const h of r.seen.entries()){const p=h[1];if(t===h[0]){s(h);continue}if(r.external){const g=(c=r.external.registry.get(h[0]))==null?void 0:c.id;if(t!==h[0]&&g){s(h);continue}}if((u=r.metadataRegistry.get(h[0]))==null?void 0:u.id){s(h);continue}if(p.cycle){s(h);continue}if(p.count>1&&r.reused==="ref"){s(h);continue}}}function Iv(r,t){var o,a,c;const e=r.seen.get(t);if(!e)throw new Error("Unprocessed schema. This is a bug in Zod.");const n=u=>{const h=r.seen.get(u);if(h.ref===null)return;const p=h.def??h.schema,m={...p},g=h.ref;if(h.ref=null,g){n(g);const _=r.seen.get(g),I=_.schema;if(I.$ref&&(r.target==="draft-07"||r.target==="draft-04"||r.target==="openapi-3.0")?(p.allOf=p.allOf??[],p.allOf.push(I)):Object.assign(p,I),Object.assign(p,m),u._zod.parent===g)for(const R in p)R==="$ref"||R==="allOf"||R in m||delete p[R];if(I.$ref&&_.def)for(const R in p)R==="$ref"||R==="allOf"||R in _.def&&JSON.stringify(p[R])===JSON.stringify(_.def[R])&&delete p[R]}const S=u._zod.parent;if(S&&S!==g){n(S);const _=r.seen.get(S);if(_!=null&&_.schema.$ref&&(p.$ref=_.schema.$ref,_.def))for(const I in p)I==="$ref"||I==="allOf"||I in _.def&&JSON.stringify(p[I])===JSON.stringify(_.def[I])&&delete p[I]}r.override({zodSchema:u,jsonSchema:p,path:h.path??[]})};for(const u of[...r.seen.entries()].reverse())n(u[0]);const i={};if(r.target==="draft-2020-12"?i.$schema="https://json-schema.org/draft/2020-12/schema":r.target==="draft-07"?i.$schema="http://json-schema.org/draft-07/schema#":r.target==="draft-04"?i.$schema="http://json-schema.org/draft-04/schema#":r.target,(o=r.external)!=null&&o.uri){const u=(a=r.external.registry.get(t))==null?void 0:a.id;if(!u)throw new Error("Schema is missing an `id` property");i.$id=r.external.uri(u)}Object.assign(i,e.def??e.schema);const s=((c=r.external)==null?void 0:c.defs)??{};for(const u of r.seen.entries()){const h=u[1];h.def&&h.defId&&(s[h.defId]=h.def)}r.external||Object.keys(s).length>0&&(r.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:Wa(t,"input",r.processors),output:Wa(t,"output",r.processors)}},enumerable:!1,writable:!1}),u}catch{throw new Error("Error converting schema to JSON.")}}function He(r,t){const e=t??{seen:new Set};if(e.seen.has(r))return!1;e.seen.add(r);const n=r._zod.def;if(n.type==="transform")return!0;if(n.type==="array")return He(n.element,e);if(n.type==="set")return He(n.valueType,e);if(n.type==="lazy")return He(n.getter(),e);if(n.type==="promise"||n.type==="optional"||n.type==="nonoptional"||n.type==="nullable"||n.type==="readonly"||n.type==="default"||n.type==="prefault")return He(n.innerType,e);if(n.type==="intersection")return He(n.left,e)||He(n.right,e);if(n.type==="record"||n.type==="map")return He(n.keyType,e)||He(n.valueType,e);if(n.type==="pipe")return He(n.in,e)||He(n.out,e);if(n.type==="object"){for(const i in n.shape)if(He(n.shape[i],e))return!0;return!1}if(n.type==="union"){for(const i of n.options)if(He(i,e))return!0;return!1}if(n.type==="tuple"){for(const i of n.items)if(He(i,e))return!0;return!!(n.rest&&He(n.rest,e))}return!1}const qT=(r,t={})=>e=>{const n=Av({...e,processors:t});return _e(r,n),$v(n,r),Iv(n,r)},Wa=(r,t,e={})=>n=>{const{libraryOptions:i,target:s}=n??{},o=Av({...i??{},target:s,io:t,processors:e});return _e(r,o),$v(o,r),Iv(o,r)},YT={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},XT=(r,t,e,n)=>{const i=e;i.type="string";const{minimum:s,maximum:o,format:a,patterns:c,contentEncoding:u}=r._zod.bag;if(typeof s=="number"&&(i.minLength=s),typeof o=="number"&&(i.maxLength=o),a&&(i.format=YT[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}))])}},KT=(r,t,e,n)=>{const i=e,{minimum:s,maximum:o,format:a,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:h}=r._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)},JT=(r,t,e,n)=>{e.type="boolean"},QT=(r,t,e,n)=>{e.not={}},eC=(r,t,e,n)=>{},tC=(r,t,e,n)=>{const i=r._zod.def,s=ov(i.entries);s.every(o=>typeof o=="number")&&(e.type="number"),s.every(o=>typeof o=="string")&&(e.type="string"),e.enum=s},rC=(r,t,e,n)=>{const i=r._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},nC=(r,t,e,n)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},iC=(r,t,e,n)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},sC=(r,t,e,n)=>{const i=e,s=r._zod.def,{minimum:o,maximum:a}=r._zod.bag;typeof o=="number"&&(i.minItems=o),typeof a=="number"&&(i.maxItems=a),i.type="array",i.items=_e(s.element,t,{...n,path:[...n.path,"items"]})},oC=(r,t,e,n)=>{var u;const i=e,s=r._zod.def;i.type="object",i.properties={};const o=s.shape;for(const h in o)i.properties[h]=_e(o[h],t,{...n,path:[...n.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=_e(s.catchall,t,{...n,path:[...n.path,"additionalProperties"]})):t.io==="output"&&(i.additionalProperties=!1)},aC=(r,t,e,n)=>{const i=r._zod.def,s=i.inclusive===!1,o=i.options.map((a,c)=>_e(a,t,{...n,path:[...n.path,s?"oneOf":"anyOf",c]}));s?e.oneOf=o:e.anyOf=o},lC=(r,t,e,n)=>{const i=r._zod.def,s=_e(i.left,t,{...n,path:[...n.path,"allOf",0]}),o=_e(i.right,t,{...n,path:[...n.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},cC=(r,t,e,n)=>{const i=e,s=r._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=_e(s.valueType,t,{...n,path:[...n.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=_e(s.keyType,t,{...n,path:[...n.path,"propertyNames"]})),i.additionalProperties=_e(s.valueType,t,{...n,path:[...n.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)}},uC=(r,t,e,n)=>{const i=r._zod.def,s=_e(i.innerType,t,n),o=t.seen.get(r);t.target==="openapi-3.0"?(o.ref=i.innerType,e.nullable=!0):e.anyOf=[s,{type:"null"}]},hC=(r,t,e,n)=>{const i=r._zod.def;_e(i.innerType,t,n);const s=t.seen.get(r);s.ref=i.innerType},dC=(r,t,e,n)=>{const i=r._zod.def;_e(i.innerType,t,n);const s=t.seen.get(r);s.ref=i.innerType,e.default=JSON.parse(JSON.stringify(i.defaultValue))},pC=(r,t,e,n)=>{const i=r._zod.def;_e(i.innerType,t,n);const s=t.seen.get(r);s.ref=i.innerType,t.io==="input"&&(e._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},fC=(r,t,e,n)=>{const i=r._zod.def;_e(i.innerType,t,n);const s=t.seen.get(r);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},gC=(r,t,e,n)=>{const i=r._zod.def,s=t.io==="input"?i.in._zod.def.type==="transform"?i.out:i.in:i.out;_e(s,t,n);const o=t.seen.get(r);o.ref=s},mC=(r,t,e,n)=>{const i=r._zod.def;_e(i.innerType,t,n);const s=t.seen.get(r);s.ref=i.innerType,e.readOnly=!0},Tv=(r,t,e,n)=>{const i=r._zod.def;_e(i.innerType,t,n);const s=t.seen.get(r);s.ref=i.innerType},vC=A("ZodISODateTime",(r,t)=>{yI.init(r,t),ve.init(r,t)});function yC(r){return ET(vC,r)}const bC=A("ZodISODate",(r,t)=>{bI.init(r,t),ve.init(r,t)});function wC(r){return xT(bC,r)}const SC=A("ZodISOTime",(r,t)=>{wI.init(r,t),ve.init(r,t)});function _C(r){return AT(SC,r)}const kC=A("ZodISODuration",(r,t)=>{SI.init(r,t),ve.init(r,t)});function EC(r){return $T(kC,r)}const Cv=(r,t)=>{uv.init(r,t),r.name="ZodError",Object.defineProperties(r,{format:{value:e=>h$(r,e)},flatten:{value:e=>u$(r,e)},addIssue:{value:e=>{r.issues.push(e),r.message=JSON.stringify(r.issues,su,2)}},addIssues:{value:e=>{r.issues.push(...e),r.message=JSON.stringify(r.issues,su,2)}},isEmpty:{get(){return r.issues.length===0}}})},Af=A("ZodError",Cv),vt=A("ZodError",Cv,{Parent:Error}),xC=zh(vt),AC=Oh(vt),$C=bl(vt),IC=wl(vt),TC=f$(vt),CC=g$(vt),RC=m$(vt),PC=v$(vt),DC=y$(vt),LC=b$(vt),zC=w$(vt),OC=S$(vt),me=A("ZodType",(r,t)=>(ge.init(r,t),Object.assign(r["~standard"],{jsonSchema:{input:Wa(r,"input"),output:Wa(r,"output")}}),r.toJSONSchema=qT(r,{}),r.def=t,r.type=t.type,Object.defineProperty(r,"_def",{value:t}),r.check=(...e)=>r.clone(Lr(t,{checks:[...t.checks??[],...e.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0}),r.with=r.check,r.clone=(e,n)=>zr(r,e,n),r.brand=()=>r,r.register=(e,n)=>(e.add(r,n),r),r.parse=(e,n)=>xC(r,e,n,{callee:r.parse}),r.safeParse=(e,n)=>$C(r,e,n),r.parseAsync=async(e,n)=>AC(r,e,n,{callee:r.parseAsync}),r.safeParseAsync=async(e,n)=>IC(r,e,n),r.spa=r.safeParseAsync,r.encode=(e,n)=>TC(r,e,n),r.decode=(e,n)=>CC(r,e,n),r.encodeAsync=async(e,n)=>RC(r,e,n),r.decodeAsync=async(e,n)=>PC(r,e,n),r.safeEncode=(e,n)=>DC(r,e,n),r.safeDecode=(e,n)=>LC(r,e,n),r.safeEncodeAsync=async(e,n)=>zC(r,e,n),r.safeDecodeAsync=async(e,n)=>OC(r,e,n),r.refine=(e,n)=>r.check($R(e,n)),r.superRefine=e=>r.check(IR(e)),r.overwrite=e=>r.check(Ni(e)),r.optional=()=>Tf(r),r.exactOptional=()=>fR(r),r.nullable=()=>Cf(r),r.nullish=()=>Tf(Cf(r)),r.nonoptional=e=>wR(r,e),r.array=()=>L(r),r.or=e=>j([r,e]),r.and=e=>_l(r,e),r.transform=e=>Rf(r,dR(e)),r.default=e=>vR(r,e),r.prefault=e=>bR(r,e),r.catch=e=>_R(r,e),r.pipe=e=>Rf(r,e),r.readonly=()=>xR(r),r.describe=e=>{const n=r.clone();return ss.add(n,{description:e}),n},Object.defineProperty(r,"description",{get(){var e;return(e=ss.get(r))==null?void 0:e.description},configurable:!0}),r.meta=(...e)=>{if(e.length===0)return ss.get(r);const n=r.clone();return ss.add(n,e[0]),n},r.isOptional=()=>r.safeParse(void 0).success,r.isNullable=()=>r.safeParse(null).success,r.apply=e=>e(r),r)),Rv=A("_ZodString",(r,t)=>{Mh.init(r,t),me.init(r,t),r._zod.processJSONSchema=(n,i,s)=>XT(r,n,i);const e=r._zod.bag;r.format=e.format??null,r.minLength=e.minimum??null,r.maxLength=e.maximum??null,r.regex=(...n)=>r.check(DT(...n)),r.includes=(...n)=>r.check(OT(...n)),r.startsWith=(...n)=>r.check(MT(...n)),r.endsWith=(...n)=>r.check(NT(...n)),r.min=(...n)=>r.check(Fa(...n)),r.max=(...n)=>r.check(Ev(...n)),r.length=(...n)=>r.check(xv(...n)),r.nonempty=(...n)=>r.check(Fa(1,...n)),r.lowercase=n=>r.check(LT(n)),r.uppercase=n=>r.check(zT(n)),r.trim=()=>r.check(FT()),r.normalize=(...n)=>r.check(UT(...n)),r.toLowerCase=()=>r.check(WT()),r.toUpperCase=()=>r.check(HT()),r.slugify=()=>r.check(ZT())}),MC=A("ZodString",(r,t)=>{Mh.init(r,t),Rv.init(r,t),r.email=e=>r.check(nT(NC,e)),r.url=e=>r.check(lT(UC,e)),r.jwt=e=>r.check(kT(eR,e)),r.emoji=e=>r.check(cT(FC,e)),r.guid=e=>r.check(_f($f,e)),r.uuid=e=>r.check(iT(Jo,e)),r.uuidv4=e=>r.check(sT(Jo,e)),r.uuidv6=e=>r.check(oT(Jo,e)),r.uuidv7=e=>r.check(aT(Jo,e)),r.nanoid=e=>r.check(uT(WC,e)),r.guid=e=>r.check(_f($f,e)),r.cuid=e=>r.check(hT(HC,e)),r.cuid2=e=>r.check(dT(ZC,e)),r.ulid=e=>r.check(pT(BC,e)),r.base64=e=>r.check(wT(KC,e)),r.base64url=e=>r.check(ST(JC,e)),r.xid=e=>r.check(fT(jC,e)),r.ksuid=e=>r.check(gT(VC,e)),r.ipv4=e=>r.check(mT(GC,e)),r.ipv6=e=>r.check(vT(qC,e)),r.cidrv4=e=>r.check(yT(YC,e)),r.cidrv6=e=>r.check(bT(XC,e)),r.e164=e=>r.check(_T(QC,e)),r.datetime=e=>r.check(yC(e)),r.date=e=>r.check(wC(e)),r.time=e=>r.check(_C(e)),r.duration=e=>r.check(EC(e))});function d(r){return rT(MC,r)}const ve=A("ZodStringFormat",(r,t)=>{de.init(r,t),Rv.init(r,t)}),NC=A("ZodEmail",(r,t)=>{cI.init(r,t),ve.init(r,t)}),$f=A("ZodGUID",(r,t)=>{aI.init(r,t),ve.init(r,t)}),Jo=A("ZodUUID",(r,t)=>{lI.init(r,t),ve.init(r,t)}),UC=A("ZodURL",(r,t)=>{uI.init(r,t),ve.init(r,t)}),FC=A("ZodEmoji",(r,t)=>{hI.init(r,t),ve.init(r,t)}),WC=A("ZodNanoID",(r,t)=>{dI.init(r,t),ve.init(r,t)}),HC=A("ZodCUID",(r,t)=>{pI.init(r,t),ve.init(r,t)}),ZC=A("ZodCUID2",(r,t)=>{fI.init(r,t),ve.init(r,t)}),BC=A("ZodULID",(r,t)=>{gI.init(r,t),ve.init(r,t)}),jC=A("ZodXID",(r,t)=>{mI.init(r,t),ve.init(r,t)}),VC=A("ZodKSUID",(r,t)=>{vI.init(r,t),ve.init(r,t)}),GC=A("ZodIPv4",(r,t)=>{_I.init(r,t),ve.init(r,t)}),qC=A("ZodIPv6",(r,t)=>{kI.init(r,t),ve.init(r,t)}),YC=A("ZodCIDRv4",(r,t)=>{EI.init(r,t),ve.init(r,t)}),XC=A("ZodCIDRv6",(r,t)=>{xI.init(r,t),ve.init(r,t)}),KC=A("ZodBase64",(r,t)=>{AI.init(r,t),ve.init(r,t)}),JC=A("ZodBase64URL",(r,t)=>{II.init(r,t),ve.init(r,t)}),QC=A("ZodE164",(r,t)=>{TI.init(r,t),ve.init(r,t)}),eR=A("ZodJWT",(r,t)=>{RI.init(r,t),ve.init(r,t)}),Pv=A("ZodNumber",(r,t)=>{wv.init(r,t),me.init(r,t),r._zod.processJSONSchema=(n,i,s)=>KT(r,n,i),r.gt=(n,i)=>r.check(Ef(n,i)),r.gte=(n,i)=>r.check(kc(n,i)),r.min=(n,i)=>r.check(kc(n,i)),r.lt=(n,i)=>r.check(kf(n,i)),r.lte=(n,i)=>r.check(_c(n,i)),r.max=(n,i)=>r.check(_c(n,i)),r.int=n=>r.check(If(n)),r.safe=n=>r.check(If(n)),r.positive=n=>r.check(Ef(0,n)),r.nonnegative=n=>r.check(kc(0,n)),r.negative=n=>r.check(kf(0,n)),r.nonpositive=n=>r.check(_c(0,n)),r.multipleOf=(n,i)=>r.check(xf(n,i)),r.step=(n,i)=>r.check(xf(n,i)),r.finite=()=>r;const e=r._zod.bag;r.minValue=Math.max(e.minimum??Number.NEGATIVE_INFINITY,e.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,r.maxValue=Math.min(e.maximum??Number.POSITIVE_INFINITY,e.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,r.isInt=(e.format??"").includes("int")||Number.isSafeInteger(e.multipleOf??.5),r.isFinite=!0,r.format=e.format??null});function F(r){return IT(Pv,r)}const tR=A("ZodNumberFormat",(r,t)=>{PI.init(r,t),Pv.init(r,t)});function If(r){return TT(tR,r)}const rR=A("ZodBoolean",(r,t)=>{DI.init(r,t),me.init(r,t),r._zod.processJSONSchema=(e,n,i)=>JT(r,e,n)});function Ce(r){return CT(rR,r)}const nR=A("ZodUnknown",(r,t)=>{LI.init(r,t),me.init(r,t),r._zod.processJSONSchema=(e,n,i)=>eC()});function k(){return RT(nR)}const iR=A("ZodNever",(r,t)=>{zI.init(r,t),me.init(r,t),r._zod.processJSONSchema=(e,n,i)=>QT(r,e,n)});function sR(r){return PT(iR,r)}const oR=A("ZodArray",(r,t)=>{OI.init(r,t),me.init(r,t),r._zod.processJSONSchema=(e,n,i)=>sC(r,e,n,i),r.element=t.element,r.min=(e,n)=>r.check(Fa(e,n)),r.nonempty=e=>r.check(Fa(1,e)),r.max=(e,n)=>r.check(Ev(e,n)),r.length=(e,n)=>r.check(xv(e,n)),r.unwrap=()=>r.element});function L(r,t){return BT(oR,r,t)}const Dv=A("ZodObject",(r,t)=>{NI.init(r,t),me.init(r,t),r._zod.processJSONSchema=(e,n,i)=>oC(r,e,n,i),re(r,"shape",()=>t.shape),r.keyof=()=>_s(Object.keys(r._zod.def.shape)),r.catchall=e=>r.clone({...r._zod.def,catchall:e}),r.passthrough=()=>r.clone({...r._zod.def,catchall:k()}),r.loose=()=>r.clone({...r._zod.def,catchall:k()}),r.strict=()=>r.clone({...r._zod.def,catchall:sR()}),r.strip=()=>r.clone({...r._zod.def,catchall:void 0}),r.extend=e=>s$(r,e),r.safeExtend=e=>o$(r,e),r.merge=e=>a$(r,e),r.pick=e=>n$(r,e),r.omit=e=>i$(r,e),r.partial=(...e)=>l$(zv,r,e[0]),r.required=(...e)=>c$(Ov,r,e[0])});function Lv(r,t){const e={type:"object",shape:r??{},...O(t)};return new Dv(e)}function v(r,t){return new Dv({type:"object",shape:r,catchall:k(),...O(t)})}const aR=A("ZodUnion",(r,t)=>{UI.init(r,t),me.init(r,t),r._zod.processJSONSchema=(e,n,i)=>aC(r,e,n,i),r.options=t.options});function j(r,t){return new aR({type:"union",options:r,...O(t)})}const lR=A("ZodIntersection",(r,t)=>{FI.init(r,t),me.init(r,t),r._zod.processJSONSchema=(e,n,i)=>lC(r,e,n,i)});function _l(r,t){return new lR({type:"intersection",left:r,right:t})}const cR=A("ZodRecord",(r,t)=>{WI.init(r,t),me.init(r,t),r._zod.processJSONSchema=(e,n,i)=>cC(r,e,n,i),r.keyType=t.keyType,r.valueType=t.valueType});function E(r,t,e){return new cR({type:"record",keyType:r,valueType:t,...O(e)})}const au=A("ZodEnum",(r,t)=>{HI.init(r,t),me.init(r,t),r._zod.processJSONSchema=(n,i,s)=>tC(r,n,i),r.enum=t.entries,r.options=Object.values(t.entries);const e=new Set(Object.keys(t.entries));r.extract=(n,i)=>{const s={};for(const o of n)if(e.has(o))s[o]=t.entries[o];else throw new Error(`Key ${o} not found in enum`);return new au({...t,checks:[],...O(i),entries:s})},r.exclude=(n,i)=>{const s={...t.entries};for(const o of n)if(e.has(o))delete s[o];else throw new Error(`Key ${o} not found in enum`);return new au({...t,checks:[],...O(i),entries:s})}});function _s(r,t){const e=Array.isArray(r)?Object.fromEntries(r.map(n=>[n,n])):r;return new au({type:"enum",entries:e,...O(t)})}const uR=A("ZodLiteral",(r,t)=>{ZI.init(r,t),me.init(r,t),r._zod.processJSONSchema=(e,n,i)=>rC(r,e,n),r.values=new Set(t.values),Object.defineProperty(r,"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 $(r,t){return new uR({type:"literal",values:Array.isArray(r)?r:[r],...O(t)})}const hR=A("ZodTransform",(r,t)=>{BI.init(r,t),me.init(r,t),r._zod.processJSONSchema=(e,n,i)=>iC(r,e),r._zod.parse=(e,n)=>{if(n.direction==="backward")throw new iv(r.constructor.name);e.addIssue=s=>{if(typeof s=="string")e.issues.push(Ss(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=r),e.issues.push(Ss(o))}};const i=t.transform(e.value,e);return i instanceof Promise?i.then(s=>(e.value=s,e)):(e.value=i,e)}});function dR(r){return new hR({type:"transform",transform:r})}const zv=A("ZodOptional",(r,t)=>{kv.init(r,t),me.init(r,t),r._zod.processJSONSchema=(e,n,i)=>Tv(r,e,n,i),r.unwrap=()=>r._zod.def.innerType});function Tf(r){return new zv({type:"optional",innerType:r})}const pR=A("ZodExactOptional",(r,t)=>{jI.init(r,t),me.init(r,t),r._zod.processJSONSchema=(e,n,i)=>Tv(r,e,n,i),r.unwrap=()=>r._zod.def.innerType});function fR(r){return new pR({type:"optional",innerType:r})}const gR=A("ZodNullable",(r,t)=>{VI.init(r,t),me.init(r,t),r._zod.processJSONSchema=(e,n,i)=>uC(r,e,n,i),r.unwrap=()=>r._zod.def.innerType});function Cf(r){return new gR({type:"nullable",innerType:r})}const mR=A("ZodDefault",(r,t)=>{GI.init(r,t),me.init(r,t),r._zod.processJSONSchema=(e,n,i)=>dC(r,e,n,i),r.unwrap=()=>r._zod.def.innerType,r.removeDefault=r.unwrap});function vR(r,t){return new mR({type:"default",innerType:r,get defaultValue(){return typeof t=="function"?t():lv(t)}})}const yR=A("ZodPrefault",(r,t)=>{qI.init(r,t),me.init(r,t),r._zod.processJSONSchema=(e,n,i)=>pC(r,e,n,i),r.unwrap=()=>r._zod.def.innerType});function bR(r,t){return new yR({type:"prefault",innerType:r,get defaultValue(){return typeof t=="function"?t():lv(t)}})}const Ov=A("ZodNonOptional",(r,t)=>{YI.init(r,t),me.init(r,t),r._zod.processJSONSchema=(e,n,i)=>hC(r,e,n,i),r.unwrap=()=>r._zod.def.innerType});function wR(r,t){return new Ov({type:"nonoptional",innerType:r,...O(t)})}const SR=A("ZodCatch",(r,t)=>{XI.init(r,t),me.init(r,t),r._zod.processJSONSchema=(e,n,i)=>fC(r,e,n,i),r.unwrap=()=>r._zod.def.innerType,r.removeCatch=r.unwrap});function _R(r,t){return new SR({type:"catch",innerType:r,catchValue:typeof t=="function"?t:()=>t})}const kR=A("ZodPipe",(r,t)=>{KI.init(r,t),me.init(r,t),r._zod.processJSONSchema=(e,n,i)=>gC(r,e,n,i),r.in=t.in,r.out=t.out});function Rf(r,t){return new kR({type:"pipe",in:r,out:t})}const ER=A("ZodReadonly",(r,t)=>{JI.init(r,t),me.init(r,t),r._zod.processJSONSchema=(e,n,i)=>mC(r,e,n,i),r.unwrap=()=>r._zod.def.innerType});function xR(r){return new ER({type:"readonly",innerType:r})}const AR=A("ZodCustom",(r,t)=>{QI.init(r,t),me.init(r,t),r._zod.processJSONSchema=(e,n,i)=>nC(r,e)});function $R(r,t={}){return jT(AR,r,t)}function IR(r){return VT(r)}const Vt={custom:"custom"},Mv=["markdown","web-bundle","url"],TR=["committed","pending"];function CR(r){let t;try{t=new URL(r)}catch{return!1}return t.protocol==="http:"||t.protocol==="https:"}Lv({id:d().min(1),kind:_s(Mv),title:d(),status:_s(TR),externalFilePath:d().optional(),externalURL:d().optional()}).superRefine((r,t)=>{switch(r.externalFilePath!==void 0&&r.externalURL!==void 0&&t.addIssue({code:Vt.custom,message:"externalFilePath and externalURL are mutually exclusive",path:["externalURL"]}),r.kind!=="web-bundle"&&r.status!=="committed"&&t.addIssue({code:Vt.custom,message:"only web-bundle artifacts can be pending",path:["status"]}),r.kind){case"markdown":r.externalFilePath===void 0&&t.addIssue({code:Vt.custom,message:"markdown artifacts require externalFilePath",path:["externalFilePath"]}),r.externalURL!==void 0&&t.addIssue({code:Vt.custom,message:"markdown artifacts cannot set externalURL",path:["externalURL"]});break;case"web-bundle":r.externalFilePath!==void 0&&t.addIssue({code:Vt.custom,message:"web-bundle artifacts cannot set externalFilePath",path:["externalFilePath"]}),r.externalURL!==void 0&&t.addIssue({code:Vt.custom,message:"web-bundle artifacts cannot set externalURL",path:["externalURL"]});break;case"url":if(r.externalURL===void 0){t.addIssue({code:Vt.custom,message:"url artifacts require externalURL",path:["externalURL"]});break}r.externalFilePath!==void 0&&t.addIssue({code:Vt.custom,message:"url artifacts cannot set externalFilePath",path:["externalFilePath"]}),CR(r.externalURL)||t.addIssue({code:Vt.custom,message:"externalURL must be an http(s) URL",path:["externalURL"]});break}});Lv({name:d().min(1),description:d(),accepts:L(_s(Mv)).min(1)});function Nv(r){return typeof r=="object"&&r!==null}function RR(r){return!Nv(r)||r.type!=="ready"?!1:!("id"in r)}function PR(r){return!(!Nv(r)||r.type!=="update-content"||typeof r.id!="string"||typeof r.content!="string")}function DR(r,t){return t.find(e=>e.accepts.includes(r))??null}const he={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"},Gt={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"},LR=1,zR=v({_meta:E(d(),k()).nullish(),terminal:Ce().optional().default(!1)}),OR=v({_meta:E(d(),k()).nullish(),label:d().nullish(),name:d(),optional:Ce().optional().default(!1),secret:Ce().optional().default(!0)}),MR=v({_meta:E(d(),k()).nullish(),description:d().nullish(),id:d(),name:d()}),NR=v({_meta:E(d(),k()).nullish(),description:d().nullish(),id:d(),link:d().nullish(),name:d(),vars:L(OR)}),UR=v({_meta:E(d(),k()).nullish(),args:L(d()).optional(),description:d().nullish(),env:E(d(),d()).optional(),id:d(),name:d()}),FR=j([NR.and(v({type:$("env_var")})),UR.and(v({type:$("terminal")})),MR]),WR=v({_meta:E(d(),k()).nullish(),methodId:d()}),HR=v({_meta:E(d(),k()).nullish()}),ZR=v({_meta:E(d(),k()).nullish(),blob:d(),mimeType:d().nullish(),uri:d()}),BR=v({default:Ce().nullish(),description:d().nullish(),title:d().nullish()}),jR=v({_meta:E(d(),k()).nullish()}),VR=v({_meta:E(d(),k()).nullish()}),GR=v({amount:F(),currency:d()}),qR=v({_meta:E(d(),k()).nullish(),terminalId:d()}),YR=v({_meta:E(d(),k()).nullish(),newText:d(),oldText:d().nullish(),path:d()}),XR=j([d(),F(),F(),Ce(),L(d())]),KR=v({content:E(d(),XR).nullish()}),JR=j([KR.and(v({action:$("accept")})),v({action:$("decline")}),v({action:$("cancel")})]),QR=v({_meta:E(d(),k()).nullish()}),Uv=d(),e1=v({_meta:E(d(),k()).nullish(),elicitationId:Uv}),t1=v({_meta:E(d(),k()).nullish(),action:JR}),r1=$("object"),n1=$("string"),i1=v({_meta:E(d(),k()).nullish()}),s1=v({_meta:E(d(),k()).nullish(),form:QR.nullish(),url:i1.nullish()}),o1=v({elicitationId:Uv,url:d().url()}),Fv=v({const:d(),title:d()}),Wv=v({_meta:E(d(),k()).nullish(),name:d(),value:d()}),a1=j([$(-32700),$(-32600),$(-32601),$(-32602),$(-32603),$(-32800),$(-32e3),$(-32002),$(-32042),F().int().min(-2147483648,{message:"Invalid value: Expected int32 to be >= -2147483648"}).max(2147483647,{message:"Invalid value: Expected int32 to be <= 2147483647"})]),Hv=v({code:a1,data:k().optional(),message:d()}),Zv=k(),Bv=k(),jv=k(),l1=v({_meta:E(d(),k()).nullish(),readTextFile:Ce().optional().default(!1),writeTextFile:Ce().optional().default(!1)}),Vv=v({_meta:E(d(),k()).nullish(),name:d(),value:d()}),Gv=v({_meta:E(d(),k()).nullish(),name:d(),title:d().nullish(),version:d()}),c1=v({default:F().nullish(),description:d().nullish(),maximum:F().nullish(),minimum:F().nullish(),title:d().nullish()}),u1=v({_meta:E(d(),k()).nullish()}),h1=v({_meta:E(d(),k()).nullish(),additionalDirectories:L(d()).optional(),cursor:d().nullish(),cwd:d().nullish()}),d1=v({_meta:E(d(),k()).nullish()}),p1=v({_meta:E(d(),k()).nullish(),logout:d1.nullish()}),f1=v({_meta:E(d(),k()).nullish()}),g1=v({_meta:E(d(),k()).nullish()}),m1=v({_meta:E(d(),k()).nullish(),http:Ce().optional().default(!1),sse:Ce().optional().default(!1)}),v1=v({_meta:E(d(),k()).nullish(),headers:L(Vv),name:d(),url:d()}),y1=v({_meta:E(d(),k()).nullish(),headers:L(Vv),name:d(),url:d()}),b1=v({_meta:E(d(),k()).nullish(),args:L(d()),command:d(),env:L(Wv),name:d()}),kl=j([v1.and(v({type:$("http")})),y1.and(v({type:$("sse")})),b1]),Nh=d(),w1=v({_meta:E(d(),k()).nullish(),description:d().nullish(),modelId:Nh,name:d()}),S1=j([$("error"),$("warning"),$("information"),$("hint")]),_1=v({_meta:E(d(),k()).nullish()}),k1=v({_meta:E(d(),k()).nullish()}),E1=v({_meta:E(d(),k()).nullish()}),x1=v({_meta:E(d(),k()).nullish()}),A1=v({_meta:E(d(),k()).nullish()}),$1=v({_meta:E(d(),k()).nullish(),maxCount:F().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),I1=v({diff:d(),uri:d()}),T1=v({endLine:F().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),startLine:F().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),text:d()}),C1=v({_meta:E(d(),k()).nullish()}),R1=v({_meta:E(d(),k()).nullish()}),P1=v({languageId:d(),text:d(),uri:d()}),D1=v({_meta:E(d(),k()).nullish(),maxCount:F().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),L1=j([$("rejected"),$("ignored"),$("replaced"),$("cancelled")]),z1=v({excerpts:L(T1),uri:d()}),O1=v({_meta:E(d(),k()).nullish()}),M1=v({_meta:E(d(),k()).nullish()}),N1=v({name:d(),owner:d(),remoteUrl:d()}),U1=v({_meta:E(d(),k()).nullish()}),F1=v({_meta:E(d(),k()).nullish(),jump:C1.nullish(),rename:M1.nullish(),searchAndReplace:U1.nullish()}),W1=v({id:d(),isRegex:Ce().nullish(),replace:d(),search:d(),uri:d()}),H1=j([$("automatic"),$("diagnostic"),$("manual")]),Z1=v({_meta:E(d(),k()).nullish(),maxCount:F().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),B1=v({_meta:E(d(),k()).nullish(),diagnostics:_1.nullish(),editHistory:$1.nullish(),openFiles:R1.nullish(),recentFiles:D1.nullish(),relatedSnippets:O1.nullish(),userActions:Z1.nullish()}),j1=v({_meta:E(d(),k()).nullish(),additionalDirectories:L(d()).optional(),cwd:d(),mcpServers:L(kl)}),V1=v({default:F().nullish(),description:d().nullish(),maximum:F().nullish(),minimum:F().nullish(),title:d().nullish()}),qv=d(),G1=j([$("allow_once"),$("allow_always"),$("reject_once"),$("reject_always")]),q1=v({_meta:E(d(),k()).nullish(),kind:G1,name:d(),optionId:qv}),Y1=j([$("high"),$("medium"),$("low")]),X1=j([$("pending"),$("in_progress"),$("completed")]),K1=v({_meta:E(d(),k()).nullish(),content:d(),priority:Y1,status:X1}),J1=v({_meta:E(d(),k()).nullish(),entries:L(K1)}),Cr=v({character:F().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),line:F().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"})}),Q1=v({id:d(),position:Cr,uri:d()}),eP=v({id:d(),newName:d(),position:Cr,uri:d()}),tP=v({action:d(),position:Cr,timestampMs:F(),uri:d()}),Yv=j([$("utf-16"),$("utf-32"),$("utf-8")]),rP=v({_meta:E(d(),k()).nullish(),auth:zR.optional().default({terminal:!1}),elicitation:s1.nullish(),fs:l1.optional().default({readTextFile:!1,writeTextFile:!1}),nes:F1.nullish(),positionEncodings:L(Yv).optional(),terminal:Ce().optional().default(!1)}),nP=v({_meta:E(d(),k()).nullish(),audio:Ce().optional().default(!1),embeddedContext:Ce().optional().default(!1),image:Ce().optional().default(!1)}),Xv=F().int().gte(0).lte(65535),iP=v({_meta:E(d(),k()).nullish(),clientCapabilities:rP.optional().default({auth:{terminal:!1},fs:{readTextFile:!1,writeTextFile:!1},terminal:!1}),clientInfo:Gv.nullish(),protocolVersion:Xv}),Ui=v({end:Cr,start:Cr}),sP=v({message:d(),range:Ui,severity:S1,uri:d()}),oP=v({languageId:d(),lastFocusedMs:F().nullish(),uri:d(),visibleRange:Ui.nullish()}),aP=v({_meta:E(d(),k()).nullish(),diagnostics:L(sP).nullish(),editHistory:L(I1).nullish(),openFiles:L(oP).nullish(),recentFiles:L(P1).nullish(),relatedSnippets:L(z1).nullish(),userActions:L(tP).nullish()}),lP=v({newText:d(),range:Ui}),cP=v({cursorPosition:Cr.nullish(),edits:L(lP),id:d(),uri:d()}),uP=j([cP.and(v({kind:$("edit")})),Q1.and(v({kind:$("jump")})),eP.and(v({kind:$("rename")})),W1.and(v({kind:$("searchAndReplace")}))]),hP=v({_meta:E(d(),k()).nullish(),content:d()}),dP=v({_meta:E(d(),k()).nullish()}),kn=j([F(),d()]).nullable();v({_meta:E(d(),k()).nullish(),requestId:kn});const pP=_s(["assistant","user"]),To=v({_meta:E(d(),k()).nullish(),audience:L(pP).nullish(),lastModified:d().nullish(),priority:F().nullish()}),fP=v({_meta:E(d(),k()).nullish(),annotations:To.nullish(),data:d(),mimeType:d()}),gP=v({_meta:E(d(),k()).nullish(),annotations:To.nullish(),data:d(),mimeType:d(),uri:d().nullish()}),mP=v({_meta:E(d(),k()).nullish(),annotations:To.nullish(),description:d().nullish(),mimeType:d().nullish(),name:d(),size:F().nullish(),title:d().nullish(),uri:d()}),vP=v({_meta:E(d(),k()).nullish(),optionId:qv}),yP=j([v({outcome:$("cancelled")}),vP.and(v({outcome:$("selected")}))]),bP=v({_meta:E(d(),k()).nullish(),outcome:yP}),wP=v({_meta:E(d(),k()).nullish()}),SP=v({_meta:E(d(),k()).nullish()}),_P=v({currentValue:Ce()}),kP=d(),Kv=d(),EP=j([$("mode"),$("model"),$("thought_level"),d()]),Uh=d(),Jv=v({_meta:E(d(),k()).nullish(),description:d().nullish(),name:d(),value:Uh}),xP=v({_meta:E(d(),k()).nullish(),group:kP,name:d(),options:L(Jv)}),AP=j([L(Jv),L(xP)]),$P=v({currentValue:Uh,options:AP}),Fi=_l(j([$P.and(v({type:$("select")})),_P.and(v({type:$("boolean")}))]),v({_meta:E(d(),k()).nullish(),category:EP.nullish(),description:d().nullish(),id:Kv,name:d()})),IP=v({_meta:E(d(),k()).nullish(),configOptions:L(Fi)}),TP=v({_meta:E(d(),k()).nullish()}),Q=d(),CP=v({_meta:E(d(),k()).nullish(),id:d(),sessionId:Q}),RP=v({_meta:E(d(),k()).nullish(),sessionId:Q}),PP=v({_meta:E(d(),k()).nullish(),sessionId:Q}),DP=v({_meta:E(d(),k()).nullish(),sessionId:Q}),Qv=v({_meta:E(d(),k()).nullish(),args:L(d()).optional(),command:d(),cwd:d().nullish(),env:L(Wv).optional(),outputByteLimit:F().nullish(),sessionId:Q}),LP=v({_meta:E(d(),k()).nullish(),sessionId:Q,uri:d()}),zP=v({_meta:E(d(),k()).nullish(),position:Cr,sessionId:Q,uri:d(),version:F(),visibleRange:Ui}),OP=v({_meta:E(d(),k()).nullish(),languageId:d(),sessionId:Q,text:d(),uri:d(),version:F()}),MP=v({_meta:E(d(),k()).nullish(),sessionId:Q,uri:d()}),NP=v({_meta:E(d(),k()).nullish(),additionalDirectories:L(d()).optional(),cwd:d(),mcpServers:L(kl).optional(),sessionId:Q}),ey=v({_meta:E(d(),k()).nullish(),sessionId:Q,terminalId:d()}),UP=v({_meta:E(d(),k()).nullish(),additionalDirectories:L(d()).optional(),cwd:d(),mcpServers:L(kl),sessionId:Q}),ty=v({_meta:E(d(),k()).nullish(),limit:F().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),line:F().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:d(),sessionId:Q}),FP=v({_meta:E(d(),k()).nullish(),id:d(),reason:L1.nullish(),sessionId:Q}),ry=v({_meta:E(d(),k()).nullish(),sessionId:Q,terminalId:d()}),WP=v({_meta:E(d(),k()).nullish(),additionalDirectories:L(d()).optional(),cwd:d(),mcpServers:L(kl).optional(),sessionId:Q}),HP=v({_meta:E(d(),k()).nullish(),additionalDirectories:L(d()).optional(),cwd:d(),sessionId:Q,title:d().nullish(),updatedAt:d().nullish()}),ZP=v({_meta:E(d(),k()).nullish(),nextCursor:d().nullish(),sessions:L(HP)}),BP=v({_meta:E(d(),k()).nullish(),title:d().nullish(),updatedAt:d().nullish()}),jP=v({_meta:E(d(),k()).nullish()}),El=d(),VP=v({_meta:E(d(),k()).nullish(),currentModeId:El}),GP=v({_meta:E(d(),k()).nullish(),description:d().nullish(),id:El,name:d()}),xl=v({_meta:E(d(),k()).nullish(),availableModes:L(GP),currentModeId:El}),Al=v({_meta:E(d(),k()).nullish(),availableModels:L(w1),currentModelId:Nh}),qP=v({_meta:E(d(),k()).nullish(),configOptions:L(Fi).nullish(),models:Al.nullish(),modes:xl.nullish(),sessionId:Q}),YP=v({_meta:E(d(),k()).nullish(),configOptions:L(Fi).nullish(),models:Al.nullish(),modes:xl.nullish()}),XP=v({_meta:E(d(),k()).nullish(),configOptions:L(Fi).nullish(),models:Al.nullish(),modes:xl.nullish(),sessionId:Q}),KP=v({_meta:E(d(),k()).nullish(),configOptions:L(Fi).nullish(),models:Al.nullish(),modes:xl.nullish()}),JP=v({_meta:E(d(),k()).nullish()}),QP=v({_meta:E(d(),k()).nullish(),additionalDirectories:wP.nullish(),close:SP.nullish(),fork:TP.nullish(),list:jP.nullish(),resume:JP.nullish()}),eD=_l(j([v({type:$("boolean"),value:Ce()}),v({value:Uh})]),v({_meta:E(d(),k()).nullish(),configId:Kv,sessionId:Q})),tD=v({_meta:E(d(),k()).nullish(),configOptions:L(Fi)}),rD=v({_meta:E(d(),k()).nullish(),modeId:El,sessionId:Q}),nD=v({_meta:E(d(),k()).nullish()}),iD=v({_meta:E(d(),k()).nullish(),modelId:Nh,sessionId:Q}),sD=v({_meta:E(d(),k()).nullish()}),oD=v({_meta:E(d(),k()).nullish(),sessionId:Q}),aD=j([$("end_turn"),$("max_tokens"),$("max_turn_requests"),$("refusal"),$("cancelled")]),lD=j([$("email"),$("uri"),$("date"),$("date-time")]),cD=v({default:d().nullish(),description:d().nullish(),enum:L(d()).nullish(),format:lD.nullish(),maxLength:F().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),minLength:F().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),oneOf:L(Fv).nullish(),pattern:d().nullish(),title:d().nullish()}),uD=v({_meta:E(d(),k()).nullish(),context:aP.nullish(),position:Cr,selection:Ui.nullish(),sessionId:Q,triggerKind:H1,uri:d(),version:F()}),hD=v({_meta:E(d(),k()).nullish(),suggestions:L(uP)}),dD=v({_meta:E(d(),k()).nullish(),terminalId:d()}),pD=v({_meta:E(d(),k()).nullish(),exitCode:F().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:d().nullish()}),ny=v({_meta:E(d(),k()).nullish(),sessionId:Q,terminalId:d()}),fD=v({_meta:E(d(),k()).nullish(),exitStatus:pD.nullish(),output:d(),truncated:Ce()}),gD=v({_meta:E(d(),k()).nullish(),annotations:To.nullish(),text:d()}),mD=v({range:Ui.nullish(),text:d()}),vD=v({_meta:E(d(),k()).nullish(),contentChanges:L(mD),sessionId:Q,uri:d(),version:F()});v({method:d(),params:j([RP,OP,vD,LP,MP,zP,CP,FP,Zv]).nullish()});const yD=j([$("full"),$("incremental")]),bD=v({_meta:E(d(),k()).nullish(),syncKind:yD}),wD=v({_meta:E(d(),k()).nullish(),didChange:bD.nullish(),didClose:k1.nullish(),didFocus:E1.nullish(),didOpen:x1.nullish(),didSave:A1.nullish()}),SD=v({_meta:E(d(),k()).nullish(),document:wD.nullish()}),_D=v({_meta:E(d(),k()).nullish(),context:B1.nullish(),events:SD.nullish()}),kD=v({_meta:E(d(),k()).nullish(),auth:p1.optional().default({}),loadSession:Ce().optional().default(!1),mcpCapabilities:m1.optional().default({http:!1,sse:!1}),nes:_D.nullish(),positionEncoding:Yv.nullish(),promptCapabilities:nP.optional().default({audio:!1,embeddedContext:!1,image:!1}),sessionCapabilities:QP.optional().default({})}),ED=v({_meta:E(d(),k()).nullish(),agentCapabilities:kD.optional().default({auth:{},loadSession:!1,mcpCapabilities:{http:!1,sse:!1},promptCapabilities:{audio:!1,embeddedContext:!1,image:!1},sessionCapabilities:{}}),agentInfo:Gv.nullish(),authMethods:L(FR).optional().default([]),protocolVersion:Xv}),xD=v({_meta:E(d(),k()).nullish(),mimeType:d().nullish(),text:d(),uri:d()}),AD=j([xD,ZR]),$D=v({_meta:E(d(),k()).nullish(),annotations:To.nullish(),resource:AD}),Fh=j([gD.and(v({type:$("text")})),gP.and(v({type:$("image")})),fP.and(v({type:$("audio")})),mP.and(v({type:$("resource_link")})),$D.and(v({type:$("resource")}))]),ID=v({_meta:E(d(),k()).nullish(),content:Fh}),Ec=v({_meta:E(d(),k()).nullish(),content:Fh,messageId:d().nullish()}),TD=v({_meta:E(d(),k()).nullish(),messageId:d().nullish(),prompt:L(Fh),sessionId:Q}),CD=v({anyOf:L(Fv)}),iy=j([ID.and(v({type:$("content")})),YR.and(v({type:$("diff")})),dD.and(v({type:$("terminal")}))]),sy=d(),oy=v({_meta:E(d(),k()).nullish(),line:F().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:d()}),ay=j([$("pending"),$("in_progress"),$("completed"),$("failed")]),ly=j([$("read"),$("edit"),$("delete"),$("move"),$("search"),$("execute"),$("think"),$("fetch"),$("switch_mode"),$("other")]),RD=v({_meta:E(d(),k()).nullish(),content:L(iy).optional(),kind:ly.optional(),locations:L(oy).optional(),rawInput:k().optional(),rawOutput:k().optional(),status:ay.optional(),title:d(),toolCallId:sy}),cy=v({_meta:E(d(),k()).nullish(),content:L(iy).nullish(),kind:ly.nullish(),locations:L(oy).nullish(),rawInput:k().optional(),rawOutput:k().optional(),status:ay.nullish(),title:d().nullish(),toolCallId:sy}),uy=v({_meta:E(d(),k()).nullish(),options:L(q1),sessionId:Q,toolCall:cy}),PD=v({_meta:E(d(),k()).nullish(),hint:d()}),DD=PD,LD=v({_meta:E(d(),k()).nullish(),description:d(),input:DD.nullish(),name:d()}),zD=v({_meta:E(d(),k()).nullish(),availableCommands:L(LD)}),OD=v({enum:L(d()),type:n1}),MD=j([OD,CD]),ND=v({default:L(d()).nullish(),description:d().nullish(),items:MD,maxItems:F().nullish(),minItems:F().nullish(),title:d().nullish()}),UD=j([cD.and(v({type:$("string")})),V1.and(v({type:$("number")})),c1.and(v({type:$("integer")})),BR.and(v({type:$("boolean")})),ND.and(v({type:$("array")}))]),FD=v({description:d().nullish(),properties:E(d(),UD).optional().default({}),required:L(d()).nullish(),title:d().nullish(),type:r1.optional().default("object")}),WD=v({requestedSchema:FD}),HD=_l(j([WD.and(v({mode:$("form")})),o1.and(v({mode:$("url")}))]),v({_meta:E(d(),k()).nullish(),message:d(),sessionId:Q})),ZD=v({cachedReadTokens:F().nullish(),cachedWriteTokens:F().nullish(),inputTokens:F(),outputTokens:F(),thoughtTokens:F().nullish(),totalTokens:F()}),BD=v({_meta:E(d(),k()).nullish(),stopReason:aD,usage:ZD.nullish(),userMessageId:d().nullish()});j([v({id:kn,result:j([ED,HR,g1,XP,YP,ZP,qP,KP,VR,nD,tD,BD,sD,oD,hD,jR,jv])}),v({error:Hv,id:kn})]);const jD=v({_meta:E(d(),k()).nullish(),cost:GR.nullish(),size:F(),used:F()}),VD=j([Ec.and(v({sessionUpdate:$("user_message_chunk")})),Ec.and(v({sessionUpdate:$("agent_message_chunk")})),Ec.and(v({sessionUpdate:$("agent_thought_chunk")})),RD.and(v({sessionUpdate:$("tool_call")})),cy.and(v({sessionUpdate:$("tool_call_update")})),J1.and(v({sessionUpdate:$("plan")})),zD.and(v({sessionUpdate:$("available_commands_update")})),VP.and(v({sessionUpdate:$("current_mode_update")})),IP.and(v({sessionUpdate:$("config_option_update")})),BP.and(v({sessionUpdate:$("session_info_update")})),jD.and(v({sessionUpdate:$("usage_update")}))]),hy=v({_meta:E(d(),k()).nullish(),sessionId:Q,update:VD});v({method:d(),params:j([hy,e1,Zv]).nullish()});const dy=v({_meta:E(d(),k()).nullish(),sessionId:Q,terminalId:d()}),GD=v({_meta:E(d(),k()).nullish(),exitCode:F().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:d().nullish()}),qD=v({name:d(),uri:d()}),YD=v({_meta:E(d(),k()).nullish(),repository:N1.nullish(),workspaceFolders:L(qD).nullish(),workspaceUri:d().nullish()});v({id:kn,method:d(),params:j([iP,WR,f1,j1,UP,h1,NP,WP,DP,rD,eD,TD,iD,YD,uD,PP,Bv]).nullish()});const py=v({_meta:E(d(),k()).nullish(),content:d(),path:d(),sessionId:Q});v({id:kn,method:d(),params:j([py,ty,uy,Qv,ny,ry,dy,ey,HD,Bv]).nullish()});const XD=v({_meta:E(d(),k()).nullish()});j([v({id:kn,result:j([XD,hP,bP,qR,fD,dP,GD,u1,t1,jv])}),v({error:Hv,id:kn})]);var J;class KD{constructor(t,e){w(this,J);const n=t(this),i=async(o,a)=>{var c,u,h,p,m,g,S;switch(o){case Gt.fs_write_text_file:{const _=py.parse(a);return(c=n.writeTextFile)==null?void 0:c.call(n,_)}case Gt.fs_read_text_file:{const _=ty.parse(a);return(u=n.readTextFile)==null?void 0:u.call(n,_)}case Gt.session_request_permission:{const _=uy.parse(a);return n.requestPermission(_)}case Gt.terminal_create:{const _=Qv.parse(a);return(h=n.createTerminal)==null?void 0:h.call(n,_)}case Gt.terminal_output:{const _=ny.parse(a);return(p=n.terminalOutput)==null?void 0:p.call(n,_)}case Gt.terminal_release:{const _=ry.parse(a);return await((m=n.releaseTerminal)==null?void 0:m.call(n,_))??{}}case Gt.terminal_wait_for_exit:{const _=dy.parse(a);return(g=n.waitForTerminalExit)==null?void 0:g.call(n,_)}case Gt.terminal_kill:{const _=ey.parse(a);return await((S=n.killTerminal)==null?void 0:S.call(n,_))??{}}default:if(n.extMethod)return n.extMethod(o,a);throw $e.methodNotFound(o)}},s=async(o,a)=>{switch(o){case Gt.session_update:{const c=hy.parse(a);return n.sessionUpdate(c)}default:if(n.extNotification)return n.extNotification(o,a);throw $e.methodNotFound(o)}};x(this,J,new JD(i,s,e))}async initialize(t){return await l(this,J).sendRequest(he.initialize,t)}async newSession(t){return await l(this,J).sendRequest(he.session_new,t)}async loadSession(t){return await l(this,J).sendRequest(he.session_load,t)??{}}async unstable_forkSession(t){return await l(this,J).sendRequest(he.session_fork,t)}async listSessions(t){return await l(this,J).sendRequest(he.session_list,t)}async unstable_resumeSession(t){return await l(this,J).sendRequest(he.session_resume,t)}async unstable_closeSession(t){return await l(this,J).sendRequest(he.session_close,t)}async setSessionMode(t){return await l(this,J).sendRequest(he.session_set_mode,t)??{}}async unstable_setSessionModel(t){return await l(this,J).sendRequest(he.session_set_model,t)??{}}async setSessionConfigOption(t){return await l(this,J).sendRequest(he.session_set_config_option,t)}async authenticate(t){return await l(this,J).sendRequest(he.authenticate,t)??{}}async unstable_logout(t){return await l(this,J).sendRequest(he.logout,t)??{}}async prompt(t){return await l(this,J).sendRequest(he.session_prompt,t)}async cancel(t){return await l(this,J).sendNotification(he.session_cancel,t)}async unstable_startNes(t){return await l(this,J).sendRequest(he.nes_start,t)}async unstable_suggestNes(t){return await l(this,J).sendRequest(he.nes_suggest,t)}async unstable_closeNes(t){return await l(this,J).sendRequest(he.nes_close,t)??{}}async unstable_didOpenDocument(t){return await l(this,J).sendNotification(he.document_did_open,t)}async unstable_didChangeDocument(t){return await l(this,J).sendNotification(he.document_did_change,t)}async unstable_didCloseDocument(t){return await l(this,J).sendNotification(he.document_did_close,t)}async unstable_didSaveDocument(t){return await l(this,J).sendNotification(he.document_did_save,t)}async unstable_didFocusDocument(t){return await l(this,J).sendNotification(he.document_did_focus,t)}async unstable_acceptNes(t){return await l(this,J).sendNotification(he.nes_accept,t)}async unstable_rejectNes(t){return await l(this,J).sendNotification(he.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 yr,Xa,Ps,Ds,oi,ai,Lt,Ls,fe,fy,lu,gy,my,vy,yy,cu,os;class JD{constructor(t,e,n){w(this,fe);w(this,yr,new Map);w(this,Xa,0);w(this,Ps);w(this,Ds);w(this,oi);w(this,ai,Promise.resolve());w(this,Lt,new AbortController);w(this,Ls);x(this,Ps,t),x(this,Ds,e),x(this,oi,n),x(this,Ls,new Promise(i=>{l(this,Lt).signal.addEventListener("abort",()=>i())})),f(this,fe,fy).call(this)}get signal(){return l(this,Lt).signal}get closed(){return l(this,Ls)}async sendRequest(t,e){f(this,fe,cu).call(this);const n=Cd(this,Xa)._++,i=new Promise((s,o)=>{l(this,yr).set(n,{resolve:s,reject:o})});return await f(this,fe,os).call(this,{jsonrpc:"2.0",id:n,method:t,params:e}),i}async sendNotification(t,e){f(this,fe,cu).call(this),await f(this,fe,os).call(this,{jsonrpc:"2.0",method:t,params:e})}}yr=new WeakMap,Xa=new WeakMap,Ps=new WeakMap,Ds=new WeakMap,oi=new WeakMap,ai=new WeakMap,Lt=new WeakMap,Ls=new WeakMap,fe=new WeakSet,fy=async function(){let t;try{const e=l(this,oi).readable.getReader();try{for(;!l(this,Lt).signal.aborted;){const{value:n,done:i}=await e.read();if(i)break;if(n)try{f(this,fe,gy).call(this,n)}catch(s){console.error("Unexpected error during message processing:",n,s),"id"in n&&n.id!==void 0&&f(this,fe,os).call(this,{jsonrpc:"2.0",id:n.id,error:{code:-32700,message:"Parse error"}})}}}finally{e.releaseLock()}}catch(e){t=e}finally{f(this,fe,lu).call(this,t)}},lu=function(t){if(l(this,Lt).signal.aborted)return;const e=t??new Error("ACP connection closed");for(const n of l(this,yr).values())n.reject(e);l(this,yr).clear(),l(this,Lt).abort(e)},gy=async function(t){if("method"in t&&"id"in t){const e=await f(this,fe,my).call(this,t.method,t.params);"error"in e&&console.error("Error handling request",t,e.error),await f(this,fe,os).call(this,{jsonrpc:"2.0",id:t.id,...e})}else if("method"in t){const e=await f(this,fe,vy).call(this,t.method,t.params);"error"in e&&console.error("Error handling notification",t,e.error)}else"id"in t?f(this,fe,yy).call(this,t):console.error("Invalid message",{message:t})},my=async function(t,e){try{return{result:await l(this,Ps).call(this,t,e)??null}}catch(n){if(n instanceof $e)return n.toResult();if(n instanceof Af)return $e.invalidParams(n.format()).toResult();let i;(n instanceof Error||typeof n=="object"&&n!=null&&"message"in n&&typeof n.message=="string")&&(i=n.message);try{return $e.internalError(i?JSON.parse(i):{}).toResult()}catch{return $e.internalError({details:i}).toResult()}}},vy=async function(t,e){try{return await l(this,Ds).call(this,t,e),{result:null}}catch(n){if(n instanceof $e)return n.toResult();if(n instanceof Af)return $e.invalidParams(n.format()).toResult();let i;(n instanceof Error||typeof n=="object"&&n!=null&&"message"in n&&typeof n.message=="string")&&(i=n.message);try{return $e.internalError(i?JSON.parse(i):{}).toResult()}catch{return $e.internalError({details:i}).toResult()}}},yy=function(t){const e=l(this,yr).get(t.id);if(e){if("result"in t)e.resolve(t.result);else if("error"in t){const{code:n,message:i,data:s}=t.error;e.reject(new $e(n,i,s))}l(this,yr).delete(t.id)}else console.error("Got response to unknown request",t.id)},cu=function(){if(l(this,Lt).signal.aborted)throw l(this,Lt).signal.reason??new Error("ACP connection closed")},os=async function(t){return x(this,ai,l(this,ai).then(async()=>{const e=l(this,oi).writable.getWriter();try{await e.write(t)}finally{e.releaseLock()}}).catch(e=>{f(this,fe,lu).call(this,e)})),l(this,ai)};class $e extends Error{constructor(e,n,i){super(n);y(this,"code");y(this,"data");this.code=e,this.name="RequestError",this.data=i}static parseError(e,n){return new $e(-32700,`Parse error${n?`: ${n}`:""}`,e)}static invalidRequest(e,n){return new $e(-32600,`Invalid request${n?`: ${n}`:""}`,e)}static methodNotFound(e){return new $e(-32601,`"Method not found": ${e}`,{method:e})}static invalidParams(e,n){return new $e(-32602,`Invalid params${n?`: ${n}`:""}`,e)}static internalError(e,n){return new $e(-32603,`Internal error${n?`: ${n}`:""}`,e)}static authRequired(e,n){return new $e(-32e3,`Authentication required${n?`: ${n}`:""}`,e)}static resourceNotFound(e){return new $e(-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 QD=/^Sender \(untrusted metadata\):\n```json\n[\s\S]*?\n```\n\n?/,eL=/^\[[^\n]*Working directory:[^\n]*\]\n\n?/,tL=/\[Television screen context\][\s\S]*?\[\/Television screen context\]\n*/,rL=/\b(tv|television|screen|artifact|artifacts|viewer|filmstrip|layout|focus)\b/i,nL=/\[\[\s*(?:reply_to_current|reply_to\s*:\s*[^\]\n]+|audio_as_voice)\s*\]\]\s*/gi,iL="single_session",sL={name:"television-acp-client",version:"0.0.0"},by="agent:main:television",oL=Io(Wt);var ne,Kt,li,Jt,an,ln,cn,un,br,ci,zt,Be,Qt,ui,hn,er,wr,zs,tr,bt,Ka,rr,T,wy,Sy,_y,uu,ky,Ey,xy,Ay,$y,Iy,Ty,Br,qn,Yn,Xe,Cy,Xn,hu,du,ga,Ry,Py,Os,Ms,pu,Kn,Dy,Ly;class aL extends oL{constructor(e){super();w(this,T);w(this,ne,cL());w(this,Kt,null);w(this,li,null);w(this,Jt,null);w(this,an,null);w(this,ln,null);w(this,cn,null);w(this,un);w(this,br,null);w(this,ci,1);w(this,zt,null);w(this,Be,null);w(this,Qt,!1);w(this,ui,!1);w(this,hn,!1);w(this,er,null);w(this,wr,new Set);w(this,zs);w(this,tr);w(this,bt);w(this,Ka,e=>{f(this,T,Sy).call(this,e)});w(this,rr,null);w(this,Os,()=>{f(this,T,Kn).call(this,"ACP bridge websocket closed")});w(this,Ms,()=>{f(this,T,Kn).call(this,"ACP bridge websocket error")});x(this,tr,e),x(this,bt,e.sessionMode??iL),x(this,un,e.mappedSessionStore??lL()),x(this,zs,e.createSocket??(n=>new WebSocket(n)))}getState(){return l(this,ne)}get messages(){return l(this,ne).messageOrder.map(e=>l(this,ne).messagesById[e]).filter(e=>e!==void 0)}async connect(){if(this.disposed)throw new Error("ACPClient has been disposed");if(l(this,ne).lifecycle.status!=="ready"){f(this,T,Xe).call(this,{lifecycle:{status:"connecting"}}),l(this,li)??x(this,li,f(this,T,wy).call(this));try{await l(this,li),await f(this,T,uu).call(this)}catch(e){throw f(this,T,Kn).call(this,Qo(e)),e}}}dispose(){f(this,T,pu).call(this),f(this,T,Xe).call(this,{lifecycle:{status:"disposed"},run:{status:"idle",stopReason:null,canCancel:!1,error:null},bridge:null})}async sendMessage(e){if(await this.connect(),l(this,ne).lifecycle.status!=="ready"||l(this,ne).run.status==="running"||l(this,ne).run.status==="cancelling")throw new Error("ACPClient is not ready to send a new message");const n=e.text.trim();if(!n)throw new Error("Cannot send an empty message");f(this,T,qn).call(this,{id:f(this,T,Xn).call(this,"user"),kind:"user",text:n,status:"final"}),f(this,T,Xe).call(this,{run:{status:"running",stopReason:null,canCancel:!0,error:null}});try{const i=await f(this,T,ga).call(this).prompt({sessionId:f(this,T,du).call(this),prompt:[{type:"text",text:f(this,T,Cy).call(this,n)}]});f(this,T,Br).call(this,i.stopReason==="cancelled"?"cancelled":"final"),f(this,T,Xe).call(this,{run:{status:i.stopReason==="cancelled"?"cancelled":"completed",stopReason:i.stopReason,canCancel:!1,error:null}})}catch(i){throw f(this,T,Ly).call(this)||(f(this,T,Br).call(this,"error"),f(this,T,Xe).call(this,{run:{status:"error",stopReason:null,canCancel:!1,error:Qo(i)}})),i}}async cancel(){if(await this.connect(),!l(this,ne).run.canCancel||l(this,ne).run.status!=="running")throw new Error("No active cancellable run");f(this,T,Xe).call(this,{run:{...l(this,ne).run,status:"cancelling"}}),await f(this,T,ga).call(this).cancel({sessionId:f(this,T,du).call(this)})}setScreenContext(e){var s,o,a;if(e===null){if(l(this,Be)===null)return;x(this,Be,null),x(this,Qt,!1);return}const n={screenID:e.screenID,screenName:e.screenName};if(((s=l(this,Be))==null?void 0:s.screenID)===n.screenID&&((o=l(this,Be))==null?void 0:o.screenName)===n.screenName)return;const i=((a=l(this,Be))==null?void 0:a.screenID)??null;if(x(this,Be,n),l(this,bt)==="single_session"){(!l(this,br)||i!==n.screenID)&&x(this,Qt,!0);return}l(this,br)!==Pf(l(this,bt),n.screenID,l(this,tr).clientGUID??"default-client")&&(x(this,Jt,null),x(this,an,null),l(this,Kt)&&l(this,ne).run.status==="idle"&&f(this,T,uu).call(this).catch(c=>{f(this,T,Kn).call(this,Qo(c))}))}}ne=new WeakMap,Kt=new WeakMap,li=new WeakMap,Jt=new WeakMap,an=new WeakMap,ln=new WeakMap,cn=new WeakMap,un=new WeakMap,br=new WeakMap,ci=new WeakMap,zt=new WeakMap,Be=new WeakMap,Qt=new WeakMap,ui=new WeakMap,hn=new WeakMap,er=new WeakMap,wr=new WeakMap,zs=new WeakMap,tr=new WeakMap,bt=new WeakMap,Ka=new WeakMap,rr=new WeakMap,T=new WeakSet,wy=async function(){try{f(this,T,Xe).call(this,{lifecycle:{status:"connecting"}});const{stream:e,socket:n,metadata:i}=await dL({serverURL:l(this,tr).serverURL,token:l(this,tr).token,createSocket:l(this,zs),onDisconnect:l(this,Ka)});x(this,cn,i),f(this,T,Xe).call(this,{bridge:i}),x(this,rr,n),n.addEventListener("close",l(this,Os)),n.addEventListener("error",l(this,Ms)),x(this,Kt,new KD(s=>({connection:s,sessionUpdate:async o=>{await f(this,T,Ey).call(this,o)},requestPermission:async o=>f(this,T,xy).call(this,o)}),e)),await l(this,Kt).initialize({protocolVersion:LR,clientCapabilities:{},clientInfo:sL})}catch(e){throw e}},Sy=function(e){f(this,T,Kn).call(this,Qo(e))},_y=function(e){const n=e==null?void 0:e.models;if(!(n!=null&&n.currentModelId))return;const i=n.availableModels.find(s=>s.modelId===n.currentModelId);console.info("[ACPClient] Current model:",(i==null?void 0:i.name)??n.currentModelId,`(${n.currentModelId})`)},uu=async function(){const e=f(this,T,Py).call(this);if(l(this,Jt)&&l(this,an)===e){await l(this,Jt);return}x(this,an,e),x(this,Jt,f(this,T,ky).call(this,e)),await l(this,Jt)},ky=async function(e){var c;const n=f(this,T,ga).call(this);f(this,T,Dy).call(this);let i,s=!1,o=null;const a={cwd:f(this,T,Ry).call(this),mcpServers:[],_meta:{sessionKey:e}};try{if(x(this,hn,!0),x(this,er,null),((c=l(this,cn))==null?void 0:c.sessionIdStrategy)==="mapped"){const u=l(this,un).getActualSessionId(e);if(u)try{const h=await n.loadSession({...a,sessionId:u});if(uL(h))throw new Error("Mapped ACP session was not found");o=h,i=u,s=!0}catch{const h=await n.newSession(a);o=h,i=h.sessionId,l(this,un).setActualSessionId(e,i),s=!1}else{const h=await n.newSession(a);o=h,i=h.sessionId,l(this,un).setActualSessionId(e,i),s=!1}}else try{o=await n.loadSession({...a,sessionId:e}),i=e,s=l(this,ne).messageOrder.length>0}catch{const u=await n.newSession(a);o=u,i=u.sessionId,s=!1}}finally{x(this,hn,!1),x(this,er,null),f(this,T,Br).call(this,"final")}f(this,T,_y).call(this,o),await n.setSessionConfigOption({sessionId:i,configId:"verbose_level",value:"full"}),x(this,ln,i),x(this,br,e),x(this,ui,!0),s?(l(this,wr).add(e),l(this,bt)==="single_session"&&x(this,Qt,!1)):(l(this,wr).delete(e),x(this,Qt,l(this,bt)==="single_session")),f(this,T,Xe).call(this,{lifecycle:{status:"ready"}})},Ey=async function(e){const n=e.update;switch(n.sessionUpdate){case"user_message_chunk":n.content.type==="text"&&f(this,T,Ty).call(this,n.content.text);return;case"agent_message_chunk":n.content.type==="text"&&f(this,T,Ay).call(this,n.content.text);return;case"tool_call":f(this,T,$y).call(this,n);return;case"tool_call_update":f(this,T,Iy).call(this,n);return;case"agent_thought_chunk":return;default:return}},xy=async function(e){return{outcome:{outcome:"cancelled"}}},Ay=function(e){x(this,er,null);const n=hL(e);if(!n)return;if(!l(this,zt)){const s={id:f(this,T,Xn).call(this,"assistant"),kind:"assistant",text:n,status:"streaming"};x(this,zt,s.id),f(this,T,qn).call(this,s);return}const i=l(this,ne).messagesById[l(this,zt)];if(!i||i.kind!=="assistant")throw new Error("Open assistant message invariant violated");f(this,T,Yn).call(this,{...i,text:`${i.text}${n}`,status:"streaming"})},$y=function(e){f(this,T,Br).call(this,"final");const n=f(this,T,hu).call(this,e.toolCallId),i=Lf("content"in e?e.content:void 0),s={id:(n==null?void 0:n.id)??f(this,T,Xn).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:(n==null?void 0:n.text)??i,locations:e.locations??(n==null?void 0:n.locations)};if(n){f(this,T,Yn).call(this,s);return}f(this,T,qn).call(this,s)},Iy=function(e){const n=f(this,T,hu).call(this,e.toolCallId),i=(n==null?void 0:n.text)??"",s=Lf(e.content),o=s?`${i}${s}`:i,a={id:(n==null?void 0:n.id)??f(this,T,Xn).call(this,"tool"),kind:"tool_call",toolCallId:e.toolCallId,title:(n==null?void 0:n.title)??e.toolCallId,toolKind:(n==null?void 0:n.toolKind)??"other",status:e.status==="failed"?"failed":e.status==="completed"?"completed":"in_progress",text:o,locations:e.locations??(n==null?void 0:n.locations)};if(n){f(this,T,Yn).call(this,a);return}f(this,T,qn).call(this,a)},Ty=function(e){if(f(this,T,Br).call(this,"final"),!e)return;const n=l(this,hn)?l(this,er):null;if(!n){const s=Df(e);if(!s)return;const o={id:f(this,T,Xn).call(this,"user"),kind:"user",text:s,status:"final"};f(this,T,qn).call(this,o),l(this,hn)&&x(this,er,o.id);return}const i=l(this,ne).messagesById[n];if(!i||i.kind!=="user")throw new Error("Replay user message invariant violated");f(this,T,Yn).call(this,{...i,text:Df(`${i.text}${e}`)})},Br=function(e){if(!l(this,zt))return;const n=l(this,ne).messagesById[l(this,zt)];(n==null?void 0:n.kind)==="assistant"&&f(this,T,Yn).call(this,{...n,status:e}),x(this,zt,null)},qn=function(e){f(this,T,Xe).call(this,{messagesById:{...l(this,ne).messagesById,[e.id]:e},messageOrder:[...l(this,ne).messageOrder,e.id]})},Yn=function(e){f(this,T,Xe).call(this,{messagesById:{...l(this,ne).messagesById,[e.id]:e}})},Xe=function(e){const n={...l(this,ne),...e};x(this,ne,{...n,sendDisabled:n.lifecycle.status!=="ready"||n.run.status==="running"||n.run.status==="cancelling",cancelDisabled:!(n.run.status==="running"||n.run.status==="cancelling")||!n.run.canCancel}),this.dispatchEvent(new oe("change"))},Cy=function(e){const n=l(this,br);if(!n)return e;const i=l(this,Be)?l(this,bt)==="single_session"?l(this,Qt)||!l(this,wr).has(n):!l(this,wr).has(n):!1,s=l(this,ui)&&(l(this,Be)!==null||rL.test(e));if(!(s||i))return e;s&&x(this,ui,!1),i&&(x(this,Qt,!1),l(this,wr).add(n));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
|
-
`)},Xn=function(e){const n=`${e}-${l(this,ci)}`;return x(this,ci,l(this,ci)+1),n},hu=function(e){for(const n of l(this,ne).messageOrder){const i=l(this,ne).messagesById[n];if((i==null?void 0:i.kind)==="tool_call"&&i.toolCallId===e)return i}return null},du=function(){if(!l(this,ln))throw new Error("ACP session is not ready");return l(this,ln)},ga=function(){if(!l(this,Kt))throw new Error("ACP connection is not ready");return l(this,Kt)},Ry=function(){var n;const e=(n=l(this,cn))==null?void 0:n.sessionCwd;if(!e)throw new Error("ACP bridge session cwd is not ready");return e},Py=function(){var n;if(l(this,bt)==="single_session")return`${by}-${(l(this,tr).clientGUID??"default-client").toLowerCase()}`;const e=(n=l(this,Be))==null?void 0:n.screenID;if(!e)throw new Error("Screen context is required for per-screen session mode");return Pf(l(this,bt),e,l(this,tr).clientGUID??"default-client")},Os=new WeakMap,Ms=new WeakMap,pu=function(){x(this,Kt,null),x(this,li,null),x(this,Jt,null),x(this,an,null),x(this,ln,null),x(this,br,null),x(this,cn,null),l(this,rr)&&(l(this,rr).removeEventListener("close",l(this,Os)),l(this,rr).removeEventListener("error",l(this,Ms)),l(this,rr).close(),x(this,rr,null))},Kn=function(e){this.disposed||l(this,ne).lifecycle.status==="disconnected"||(f(this,T,Br).call(this,"error"),f(this,T,pu).call(this),f(this,T,Xe).call(this,{lifecycle:{status:"disconnected",...e?{error:e}:{}},run:{status:"idle",stopReason:null,canCancel:!1,error:null},bridge:null}))},Dy=function(){x(this,zt,null),x(this,er,null),x(this,ci,1),f(this,T,Xe).call(this,{run:{status:"idle",stopReason:null,canCancel:!1,error:null},messagesById:{},messageOrder:[]})},Ly=function(){return l(this,ne).lifecycle.status==="disconnected"};function lL(){const r=new Map;return{getActualSessionId(t){return r.get(t)??null},setActualSessionId(t,e){r.set(t,e)},clearActualSessionId(t){r.delete(t)}}}function cL(){return{lifecycle:{status:"connecting"},run:{status:"idle",stopReason:null,canCancel:!1,error:null},bridge:null,messagesById:{},messageOrder:[],sendDisabled:!0,cancelDisabled:!0}}function uL(r){return r==null?!0:typeof r=="object"&&Object.keys(r).length===0}function Pf(r,t,e){return r==="single_session"?`${by}-${e.toLowerCase()}`:`agent:main:television-${e.toLowerCase()}-${t.toLowerCase()}`}function zy(r){return r.replace(/^(?:\s*\n)+/,"")}function Df(r){let t=r;return t=t.replace(QD,""),t=t.replace(eL,""),t=t.replace(tL,""),t=zy(t),t}function hL(r){let t=r;return t=t.replace(nL,""),t=zy(t),t}function Lf(r){return!r||r.length===0?"":r.flatMap(t=>t.type==="content"&&t.content.type==="text"?[t.content.text]:[]).join("")}async function dL(r){const t=r.createSocket(gL(r.serverURL,r.token));let e=!1,n,i;const s=new Promise((u,h)=>{n=u,i=h}),o=new ReadableStream({start(u){let h=!1;const p=()=>{t.send(JSON.stringify({type:"acp-bridge-connect"}))},m=_=>{const I=fL(_);if(!I)return;let P;try{P=JSON.parse(I)}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=pL(P)}catch(W){const M=W instanceof Error?W:new Error(String(W));e||i(M),u.error(M);return}e||(e=!0,n(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}},g=()=>{var I;if(h)return;h=!0;const _=new Error("ACP bridge websocket closed");e||i(_),(I=r.onDisconnect)==null||I.call(r,_),u.close()},S=()=>{var I;if(h)return;h=!0;const _=new Error("ACP bridge websocket error");e||i(_),(I=r.onDisconnect)==null||I.call(r,_),u.error(_)};t.addEventListener("open",p),t.addEventListener("message",m),t.addEventListener("close",g),t.addEventListener("error",S)}}),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 pL(r){const{agent:t,sessionIdStrategy:e,sessionCwd:n}=r;if((t==="openclaw"||t==="hermes")&&(e==="deterministic"||e==="mapped")&&typeof n=="string"&&n.length>0)return{agent:t,sessionIdStrategy:e,sessionCwd:n};throw new Error("ACP bridge ready status missing bootstrap metadata")}function fL(r){if(typeof r=="string")return r;if(r instanceof Uint8Array)return new TextDecoder().decode(r);if(typeof Buffer<"u"&&r instanceof Buffer)return r.toString("utf8");if(typeof r=="object"&&r!==null&&"data"in r){const t=r.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 gL(r,t){const e=new URL(r);return e.protocol=e.protocol==="https:"?"wss:":"ws:",e.pathname="/acp",e.search="",e.searchParams.set("token",t),e.hash="",e.toString()}function Qo(r){return r instanceof Error?r.message:String(r)}const zf="television.acpClientGUID",Of="television.acpMappedSessions",Mf=1;var hi;class mL{constructor(){w(this,hi,new Map)}getActualSessionId(t){return l(this,hi).get(t)??null}setActualSessionId(t,e){l(this,hi).set(t,e)}clearActualSessionId(t){l(this,hi).delete(t)}}hi=new WeakMap;var di,Ns,lt,ma,va,fu;class vL{constructor(t,e){w(this,lt);w(this,di);w(this,Ns);x(this,di,t),x(this,Ns,e)}getActualSessionId(t){const e=f(this,lt,va).call(this)[f(this,lt,ma).call(this,t)];return typeof e=="string"&&e.length>0?e:null}setActualSessionId(t,e){const n=f(this,lt,va).call(this);n[f(this,lt,ma).call(this,t)]=e,f(this,lt,fu).call(this,n)}clearActualSessionId(t){const e=f(this,lt,va).call(this);delete e[f(this,lt,ma).call(this,t)],f(this,lt,fu).call(this,e)}}di=new WeakMap,Ns=new WeakMap,lt=new WeakSet,ma=function(t){return JSON.stringify([l(this,Ns),t])},va=function(){const t=l(this,di).getItem(Of);if(!t)return{};let e;try{e=JSON.parse(t)}catch{return{}}if(typeof e!="object"||e===null||Array.isArray(e))return{};const n=e;return n.version!==Mf?{}:typeof n.entries!="object"||n.entries===null||Array.isArray(n.entries)?{}:Object.fromEntries(Object.entries(n.entries).filter(i=>typeof i[1]=="string"))},fu=function(t){const e={version:Mf,entries:t};l(this,di).setItem(Of,JSON.stringify(e))};function yL(){return typeof window>"u"?null:window.localStorage}function bL(r){const t=r.getItem(zf);if(t)return t;const e=yl().toLowerCase();return r.setItem(zf,e),e}const wL=4401;class gu extends Error{constructor(t="Authentication required"){super(t),this.name="AuthError"}}class Oy extends Wt{constructor(e){super();y(this,"url");y(this,"name");y(this,"token");y(this,"status","disconnected");y(this,"screens",new Map);y(this,"views",[]);y(this,"client");y(this,"acpClient");y(this,"createSocket");y(this,"createClient");y(this,"socket",null);y(this,"connectAttempt",0);this.url=we(e.url),this.name=e.name,this.token=e.token??null,this.createSocket=e.createSocket??(i=>new WebSocket(i)),this.createClient=e.createClient??((i,s)=>new OA(i,{token:s??void 0})),this.client=this.createClient(this.url,this.token);const n=e.mappedSessionStore??(e.acpStorage?new vL(e.acpStorage,this.url):new mL);this.acpClient=new aL({serverURL:this.url,token:this.token??"",...e.createACPSocket?{createSocket:e.createACPSocket}:e.createSocket?{createSocket:e.createSocket}:{},...e.clientGUID?{clientGUID:e.clientGUID}:{},mappedSessionStore:n})}async connect(){var i;this.connectAttempt+=1;const e=this.connectAttempt;(i=this.socket)==null||i.close(),this.client=this.createClient(this.url,this.token),this.status="connecting",this.dispatchEvent(new oe("change"));const n=this.createSocket(_L(this.url,this.token));return this.socket=n,await new Promise((s,o)=>{let a=!1;const c=()=>{a||this.connectAttempt!==e||(a=!0,this.status="connected",this.dispatchEvent(new oe("change")),s())},u=p=>{a||this.connectAttempt!==e||(a=!0,this.status="disconnected",this.dispatchEvent(new oe("change")),o(p))},h=async()=>{try{const[{screens:p},m,g]=await Promise.all([this.client.screens.list(),this.client.views.list(),this.client.display.get()]);this.screens=new Map(p.map(S=>[S.id,structuredClone(S)])),this.views=m,this.dispatchEvent(new oe("change")),this.dispatchEvent(new eu("server-event",{serverURL:this.url,event:{type:"screen-changed",screenID:g.activeScreenID}})),c()}catch(p){u(p instanceof Error?p:new Error(String(p)))}};n.addEventListener("open",()=>{h()}),n.addEventListener("message",p=>{const m=EL(p);m&&(this.applyServerEvent(m),this.dispatchEvent(new eu("server-event",{serverURL:this.url,event:m})))}),n.addEventListener("close",p=>{if(this.connectAttempt===e){if(this.socket=null,kL(p)===wL){u(new gu);return}if(!a){u(new Error("Connection closed before initialization"));return}this.status="disconnected",this.dispatchEvent(new oe("change"))}}),n.addEventListener("error",()=>{u(new Error("WebSocket connection failed"))})})}disconnect(){var e;this.connectAttempt+=1,(e=this.socket)==null||e.close(),this.socket=null,this.status="disconnected",this.dispatchEvent(new oe("change"))}dispose(){this.disconnect(),this.acpClient.dispose()}getViewURL(e){const n=DR(e.kind,this.views);if(!n)return null;const i=`${this.url}/views/${encodeURIComponent(n.id)}/`;return this.token===null?i:`${i}?token=${encodeURIComponent(this.token)}`}getContentURL(e){if(e.kind==="url")return null;const n=`${this.url}/artifacts/${encodeURIComponent(e.id)}/content/`;return this.token===null?n:`${n}?token=${encodeURIComponent(this.token)}`}async createScreen(e){const{screen:n}=await this.client.screens.create({name:e});return this.screens.set(n.id,structuredClone(n)),n}applyServerEvent(e){switch(e.type){case"screen-created":this.screens.set(e.screen.id,structuredClone(e.screen)),this.dispatchEvent(new pa("screens-changed"));break;case"screen-updated":this.screens.set(e.screen.id,structuredClone(e.screen)),this.dispatchEvent(new pa("screens-changed"));break;case"screen-removed":this.screens.delete(e.screenID),this.dispatchEvent(new pa("screens-changed"));break;case"artifact-created":break;case"artifact-attached":{const n=this.screens.get(e.screenID);n&&!qm(n.layout,e.artifact.id)&&(n.layout=[...n.layout,Gm(e.artifact.id,{id:e.cardID})]);break}case"artifact-removed":{const n=this.screens.get(e.screenID);n&&(n.layout=Nm(n.layout,e.artifactID));break}case"artifact-updated":case"artifact-content-changed":case"screen-changed":case"theme-changed":case"artifact-focus":break;default:return SL(e,"server event")}}}function SL(r,t){throw new Error(`Unexpected ${t}: ${JSON.stringify(r)}`)}function _L(r,t){const e=new URL(r);return e.protocol=e.protocol==="https:"?"wss:":"ws:",e.pathname="/events",e.search="",t&&e.searchParams.set("token",t),e.hash="",e.toString()}function kL(r){return typeof r=="object"&&r!==null&&"code"in r&&typeof r.code=="number"?r.code:null}function EL(r){const t=typeof r=="string"?r:typeof r=="object"&&r!==null&&"data"in r&&typeof r.data=="string"?r.data:"";if(!t)return null;try{return JSON.parse(t)}catch{return null}}const xL="Local";var Us,mu;class AL extends Wt{constructor(e){super();w(this,Us);y(this,"servers",new Map);y(this,"localServerURL");y(this,"clientGUID");y(this,"acpStorage");y(this,"localStore");y(this,"createSocket");y(this,"lastActiveServerURL");y(this,"serverListeners",new Map);y(this,"handleLocalStoreChange",()=>{const e=this.localStore.get().activeServerURL;e!==this.lastActiveServerURL&&(this.lastActiveServerURL=e,this.dispatchEvent(new oe("change")))});this.localStore=e.localStore,this.localServerURL=e.localServerURL?we(e.localServerURL):null,this.createSocket=e.createSocket??(i=>new WebSocket(i)),this.lastActiveServerURL=this.localStore.get().activeServerURL;const n=e.acpStorage===void 0?yL():e.acpStorage;this.acpStorage=n,this.clientGUID=e.clientGUID??(n?bL(n):yl().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 n=we(e.url);this.servers.get(n)&&this.remove(n),this.servers.set(n,e);const s=()=>{this.dispatchEvent(new oe("change"))},o=c=>{this.dispatchEvent(new eu("server-event",{serverURL:c.serverURL,event:c.event}))},a=()=>{this.dispatchEvent(new pa("screens-changed"))};e.addEventListener("change",s),e.addEventListener("server-event",o),e.addEventListener("screens-changed",a),this.serverListeners.set(n,{onServerChange:s,onServerEvent:o,onScreensChanged:a}),this.dispatchEvent(new oe("change"))}remove(e){const n=we(e);if(this.localServerURL&&n===this.localServerURL)return;const i=this.servers.get(n);if(!i)return;const s=this.serverListeners.get(n);s&&(i.removeEventListener("change",s.onServerChange),i.removeEventListener("server-event",s.onServerEvent),i.removeEventListener("screens-changed",s.onScreensChanged),this.serverListeners.delete(n)),i.dispose(),this.servers.delete(n);const o=this.localStore.get(),a=o.activeServerURL===n;this.localStore.set({...o,servers:o.servers.filter(c=>c.url!==n),activeServerURL:a?null:o.activeServerURL}),this.dispatchEvent(new oe("change"))}setActive(e){const n=this.localStore.get(),i=e?we(e.url):null;n.activeServerURL!==i&&this.localStore.set({...n,activeServerURL:i})}connectConfiguredServers(e,n){const i=e?we(e):null;if(i){const a=this.localStore.get();a.servers.some(u=>we(u.url)===i)||this.localStore.set({...a,servers:[...a.servers,{url:i,name:xL}]})}const s=this.localStore.get().servers;for(const a of s){const c=we(a.url),u=i!==null&&c===i,h=f(this,Us,mu).call(this,{url:a.url,name:a.name,token:u?n??null:null});this.add(h),h.connect().catch(()=>{})}const o=i?this.servers.get(i)??null:null;this.setActive(o??this.servers.values().next().value??null)}addServer(e,n){const i=we(e);this.remove(i);const s=this.localStore.get();this.localStore.set({...s,servers:[...s.servers.filter(a=>we(a.url)!==i),{url:i,name:n}]});const o=f(this,Us,mu).call(this,{url:i,name:n,token:null});this.add(o),this.setActive(o),o.connect().catch(()=>{})}removeServer(e){this.remove(e)}}Us=new WeakSet,mu=function(e){return new Oy({url:e.url,name:e.name,token:e.token,createSocket:this.createSocket,clientGUID:this.clientGUID,acpStorage:this.acpStorage})};var Fs;class $L extends Wt{constructor(){super();w(this,Fs,e=>{const n=IL(e);n!==null&&(e.preventDefault(),this.dispatchEvent(new iA("shortcut-triggered",{shortcut:n})))});document.addEventListener("keydown",l(this,Fs))}dispose(){document.removeEventListener("keydown",l(this,Fs))}}Fs=new WeakMap;function IL(r){for(const[t,e]of Object.entries(MA))if(TL(r,e.trigger))return t;return null}function TL(r,t){return!(r.key.toLowerCase()!==t.key.toLowerCase()||r.metaKey!==!!t.meta||r.ctrlKey!==!!t.ctrl||r.shiftKey!==!!t.shift||r.altKey!==!!t.alt)}const CL="serverURL",RL="token",PL="mode",DL="electron";function My(r=window.location.search,t=window.location.origin){const n=new URLSearchParams(r).get(CL);return n?new URL(n).origin:new URL(t).origin}function Nf(r=window.location.search){return new URLSearchParams(r).get(RL)}function Wh(r=window.location.search){return new URLSearchParams(r).get(PL)===DL}let pr=null;async function Ny(r,t){if(pr==null||pr.abort(),r===null){pr=null,za();return}const e=new AbortController;pr=e;try{const n=t.token?{Authorization:`Bearer ${t.token}`}:void 0,i=new URL(`/themes/${r}/theme.css`,t.url).toString(),s=await fetch(i,{signal:e.signal,...n?{headers:n}:{}});if(!s.ok)throw new Error(`Theme fetch failed: ${s.status}`);const o=await s.text();if(pr!==e)return;Dm(o)}catch(n){if(n.name==="AbortError")return;za();const i=n instanceof Error?n.message:String(n);console.warn(`applyTheme: ${i}`)}finally{pr===e&&(pr=null)}}/**
|
|
44
|
-
* @license
|
|
45
|
-
* Copyright 2017 Google LLC
|
|
46
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
47
|
-
*/const ms=globalThis,Uf=r=>r,Ha=ms.trustedTypes,Ff=Ha?Ha.createPolicy("lit-html",{createHTML:r=>r}):void 0,Uy="$lit$",gr=`lit$${Math.random().toFixed(9).slice(2)}$`,Fy="?"+gr,LL=`<${Fy}>`,En=document,ks=()=>En.createComment(""),Es=r=>r===null||typeof r!="object"&&typeof r!="function",Hh=Array.isArray,zL=r=>Hh(r)||typeof(r==null?void 0:r[Symbol.iterator])=="function",xc=`[
|
|
48
|
-
\f\r]`,Yi=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Wf=/-->/g,Hf=/>/g,Fr=RegExp(`>|${xc}(?:([^\\s"'>=/]+)(${xc}*=${xc}*(?:[^
|
|
49
|
-
\f\r"'\`<>=]|("|')|))|$)`,"g"),Zf=/'/g,Bf=/"/g,Wy=/^(?:script|style|textarea|title)$/i,OL=r=>(t,...e)=>({_$litType$:r,strings:t,values:e}),H=OL(1),xn=Symbol.for("lit-noChange"),ae=Symbol.for("lit-nothing"),jf=new WeakMap,Qr=En.createTreeWalker(En,129);function Hy(r,t){if(!Hh(r)||!r.hasOwnProperty("raw"))throw Error("invalid template strings array");return Ff!==void 0?Ff.createHTML(t):t}const ML=(r,t)=>{const e=r.length-1,n=[];let i,s=t===2?"<svg>":t===3?"<math>":"",o=Yi;for(let a=0;a<e;a++){const c=r[a];let u,h,p=-1,m=0;for(;m<c.length&&(o.lastIndex=m,h=o.exec(c),h!==null);)m=o.lastIndex,o===Yi?h[1]==="!--"?o=Wf:h[1]!==void 0?o=Hf:h[2]!==void 0?(Wy.test(h[2])&&(i=RegExp("</"+h[2],"g")),o=Fr):h[3]!==void 0&&(o=Fr):o===Fr?h[0]===">"?(o=i??Yi,p=-1):h[1]===void 0?p=-2:(p=o.lastIndex-h[2].length,u=h[1],o=h[3]===void 0?Fr:h[3]==='"'?Bf:Zf):o===Bf||o===Zf?o=Fr:o===Wf||o===Hf?o=Yi:(o=Fr,i=void 0);const g=o===Fr&&r[a+1].startsWith("/>")?" ":"";s+=o===Yi?c+LL:p>=0?(n.push(u),c.slice(0,p)+Uy+c.slice(p)+gr+g):c+gr+(p===-2?a:g)}return[Hy(r,s+(r[e]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),n]};class xs{constructor({strings:t,_$litType$:e},n){let i;this.parts=[];let s=0,o=0;const a=t.length-1,c=this.parts,[u,h]=ML(t,e);if(this.el=xs.createElement(u,n),Qr.currentNode=this.el.content,e===2||e===3){const p=this.el.content.firstChild;p.replaceWith(...p.childNodes)}for(;(i=Qr.nextNode())!==null&&c.length<a;){if(i.nodeType===1){if(i.hasAttributes())for(const p of i.getAttributeNames())if(p.endsWith(Uy)){const m=h[o++],g=i.getAttribute(p).split(gr),S=/([.?@])?(.*)/.exec(m);c.push({type:1,index:s,name:S[2],strings:g,ctor:S[1]==="."?UL:S[1]==="?"?FL:S[1]==="@"?WL:Il}),i.removeAttribute(p)}else p.startsWith(gr)&&(c.push({type:6,index:s}),i.removeAttribute(p));if(Wy.test(i.tagName)){const p=i.textContent.split(gr),m=p.length-1;if(m>0){i.textContent=Ha?Ha.emptyScript:"";for(let g=0;g<m;g++)i.append(p[g],ks()),Qr.nextNode(),c.push({type:2,index:++s});i.append(p[m],ks())}}}else if(i.nodeType===8)if(i.data===Fy)c.push({type:2,index:s});else{let p=-1;for(;(p=i.data.indexOf(gr,p+1))!==-1;)c.push({type:7,index:s}),p+=gr.length-1}s++}}static createElement(t,e){const n=En.createElement("template");return n.innerHTML=t,n}}function Ti(r,t,e=r,n){var o,a;if(t===xn)return t;let i=n!==void 0?(o=e._$Co)==null?void 0:o[n]:e._$Cl;const s=Es(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(r),i._$AT(r,e,n)),n!==void 0?(e._$Co??(e._$Co=[]))[n]=i:e._$Cl=i),i!==void 0&&(t=Ti(r,i._$AS(r,t.values),i,n)),t}class NL{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:n}=this._$AD,i=((t==null?void 0:t.creationScope)??En).importNode(e,!0);Qr.currentNode=i;let s=Qr.nextNode(),o=0,a=0,c=n[0];for(;c!==void 0;){if(o===c.index){let u;c.type===2?u=new $l(s,s.nextSibling,this,t):c.type===1?u=new c.ctor(s,c.name,c.strings,this,t):c.type===6&&(u=new HL(s,this,t)),this._$AV.push(u),c=n[++a]}o!==(c==null?void 0:c.index)&&(s=Qr.nextNode(),o++)}return Qr.currentNode=En,i}p(t){let e=0;for(const n of this._$AV)n!==void 0&&(n.strings!==void 0?(n._$AI(t,n,e),e+=n.strings.length-2):n._$AI(t[e])),e++}}let $l=class Zy{get _$AU(){var t;return((t=this._$AM)==null?void 0:t._$AU)??this._$Cv}constructor(t,e,n,i){this.type=2,this._$AH=ae,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=n,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=Ti(this,t,e),Es(t)?t===ae||t==null||t===""?(this._$AH!==ae&&this._$AR(),this._$AH=ae):t!==this._$AH&&t!==xn&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):zL(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!==ae&&Es(this._$AH)?this._$AA.nextSibling.data=t:this.T(En.createTextNode(t)),this._$AH=t}$(t){var s;const{values:e,_$litType$:n}=t,i=typeof n=="number"?this._$AC(t):(n.el===void 0&&(n.el=xs.createElement(Hy(n.h,n.h[0]),this.options)),n);if(((s=this._$AH)==null?void 0:s._$AD)===i)this._$AH.p(e);else{const o=new NL(i,this),a=o.u(this.options);o.p(e),this.T(a),this._$AH=o}}_$AC(t){let e=jf.get(t.strings);return e===void 0&&jf.set(t.strings,e=new xs(t)),e}k(t){Hh(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let n,i=0;for(const s of t)i===e.length?e.push(n=new Zy(this.O(ks()),this.O(ks()),this,this.options)):n=e[i],n._$AI(s),i++;i<e.length&&(this._$AR(n&&n._$AB.nextSibling,i),e.length=i)}_$AR(t=this._$AA.nextSibling,e){var n;for((n=this._$AP)==null?void 0:n.call(this,!1,!0,e);t!==this._$AB;){const i=Uf(t).nextSibling;Uf(t).remove(),t=i}}setConnected(t){var e;this._$AM===void 0&&(this._$Cv=t,(e=this._$AP)==null||e.call(this,t))}},Il=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,n,i,s){this.type=1,this._$AH=ae,this._$AN=void 0,this.element=t,this.name=e,this._$AM=i,this.options=s,n.length>2||n[0]!==""||n[1]!==""?(this._$AH=Array(n.length-1).fill(new String),this.strings=n):this._$AH=ae}_$AI(t,e=this,n,i){const s=this.strings;let o=!1;if(s===void 0)t=Ti(this,t,e,0),o=!Es(t)||t!==this._$AH&&t!==xn,o&&(this._$AH=t);else{const a=t;let c,u;for(t=s[0],c=0;c<s.length-1;c++)u=Ti(this,a[n+c],e,c),u===xn&&(u=this._$AH[c]),o||(o=!Es(u)||u!==this._$AH[c]),u===ae?t=ae:t!==ae&&(t+=(u??"")+s[c+1]),this._$AH[c]=u}o&&!i&&this.j(t)}j(t){t===ae?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}},UL=class extends Il{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===ae?void 0:t}},FL=class extends Il{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==ae)}},WL=class extends Il{constructor(t,e,n,i,s){super(t,e,n,i,s),this.type=5}_$AI(t,e=this){if((t=Ti(this,t,e,0)??ae)===xn)return;const n=this._$AH,i=t===ae&&n!==ae||t.capture!==n.capture||t.once!==n.once||t.passive!==n.passive,s=t!==ae&&(n===ae||i);i&&this.element.removeEventListener(this.name,this,n),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 HL{constructor(t,e,n){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=n}get _$AU(){return this._$AM._$AU}_$AI(t){Ti(this,t)}}const ZL={I:$l},Ac=ms.litHtmlPolyfillSupport;Ac==null||Ac(xs,$l),(ms.litHtmlVersions??(ms.litHtmlVersions=[])).push("3.3.2");const Fe=(r,t,e)=>{const n=t;let i=n._$litPart$;return i===void 0&&(n._$litPart$=i=new $l(t.insertBefore(ks(),null),null,void 0,{})),i._$AI(r),i};/**
|
|
50
|
-
* @license
|
|
51
|
-
* Copyright 2017 Google LLC
|
|
52
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
53
|
-
*/const Zh={CHILD:2},Tl=r=>(...t)=>({_$litDirective$:r,values:t});let Bh=class{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,n){this._$Ct=t,this._$AM=e,this._$Ci=n}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}};/**
|
|
54
|
-
* @license
|
|
55
|
-
* Copyright 2017 Google LLC
|
|
56
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
57
|
-
*/let Za=class extends Bh{constructor(t){if(super(t),this.it=ae,t.type!==Zh.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(t){if(t===ae||t==null)return this._t=void 0,this.it=t;if(t===xn)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:[]}}};Za.directiveName="unsafeHTML",Za.resultType=1;const BL=Tl(Za);/**
|
|
58
|
-
* @license
|
|
59
|
-
* Copyright 2017 Google LLC
|
|
60
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
61
|
-
*/let vu=class extends Za{};vu.directiveName="unsafeSVG",vu.resultType=2;const jL=Tl(vu),VL={size:16,color:"currentColor",weight:"regular"};function GL(r){return typeof r=="string"?{regular:r}:r}function Wi(r,t="0 0 256 256"){const e=GL(r);return n=>{const{size:i,color:s,weight:o}={...VL,...n},a=e[o]??e.regular;return H`<svg
|
|
62
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
63
|
-
data-ui-icon=""
|
|
64
|
-
width="${i}"
|
|
65
|
-
height="${i}"
|
|
66
|
-
viewBox="${t}"
|
|
67
|
-
fill="${s}"
|
|
68
|
-
>${jL(a)}</svg>`}}/**
|
|
69
|
-
* @license
|
|
70
|
-
* Copyright 2020 Google LLC
|
|
71
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
72
|
-
*/const{I:qL}=ZL,Vf=r=>r,YL=r=>r.strings===void 0,Gf=()=>document.createComment(""),Xi=(r,t,e)=>{var s;const n=r._$AA.parentNode,i=t===void 0?r._$AB:t._$AA;if(e===void 0){const o=n.insertBefore(Gf(),i),a=n.insertBefore(Gf(),i);e=new qL(o,a,r,r.options)}else{const o=e._$AB.nextSibling,a=e._$AM,c=a!==r;if(c){let u;(s=e._$AQ)==null||s.call(e,r),e._$AM=r,e._$AP!==void 0&&(u=r._$AU)!==a._$AU&&e._$AP(u)}if(o!==i||c){let u=e._$AA;for(;u!==o;){const h=Vf(u).nextSibling;Vf(n).insertBefore(u,i),u=h}}}return e},Wr=(r,t,e=r)=>(r._$AI(t,e),r),XL={},KL=(r,t=XL)=>r._$AH=t,JL=r=>r._$AH,$c=r=>{r._$AR(),r._$AA.remove()};/**
|
|
73
|
-
* @license
|
|
74
|
-
* Copyright 2017 Google LLC
|
|
75
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
76
|
-
*/const vs=(r,t)=>{var n;const e=r._$AN;if(e===void 0)return!1;for(const i of e)(n=i._$AO)==null||n.call(i,t,!1),vs(i,t);return!0},Ba=r=>{let t,e;do{if((t=r._$AM)===void 0)break;e=t._$AN,e.delete(r),r=t}while((e==null?void 0:e.size)===0)},By=r=>{for(let t;t=r._$AM;r=t){let e=t._$AN;if(e===void 0)t._$AN=e=new Set;else if(e.has(r))break;e.add(r),tz(t)}};function QL(r){this._$AN!==void 0?(Ba(this),this._$AM=r,By(this)):this._$AM=r}function ez(r,t=!1,e=0){const n=this._$AH,i=this._$AN;if(i!==void 0&&i.size!==0)if(t)if(Array.isArray(n))for(let s=e;s<n.length;s++)vs(n[s],!1),Ba(n[s]);else n!=null&&(vs(n,!1),Ba(n));else vs(this,r)}const tz=r=>{r.type==Zh.CHILD&&(r._$AP??(r._$AP=ez),r._$AQ??(r._$AQ=QL))};class rz extends Bh{constructor(){super(...arguments),this._$AN=void 0}_$AT(t,e,n){super._$AT(t,e,n),By(this),this.isConnected=t._$AU}_$AO(t,e=!0){var n,i;t!==this.isConnected&&(this.isConnected=t,t?(n=this.reconnected)==null||n.call(this):(i=this.disconnected)==null||i.call(this)),e&&(vs(this,t),Ba(this))}setValue(t){if(YL(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
|
-
* @license
|
|
78
|
-
* Copyright 2020 Google LLC
|
|
79
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
80
|
-
*/const ya=()=>new nz;class nz{}const Ic=new WeakMap,ba=Tl(class extends rz{render(r){return ae}update(r,[t]){var n;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=(n=r.options)==null?void 0:n.host,this.rt(this.ct=r.element)),ae}rt(r){if(this.isConnected||(r=void 0),typeof this.G=="function"){const t=this.ht??globalThis;let e=Ic.get(t);e===void 0&&(e=new WeakMap,Ic.set(t,e)),e.get(this.G)!==void 0&&this.G.call(this.ht,void 0),e.set(this.G,r),r!==void 0&&this.G.call(this.ht,r)}else this.G.value=r}get lt(){var r,t;return typeof this.G=="function"?(r=Ic.get(this.ht??globalThis))==null?void 0:r.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)}}),iz=Wi('<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"/>'),jh=Wi('<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"/>'),jy=Wi('<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"/>'),sz=Wi({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"/>'}),oz=Wi({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"/>'}),az=Wi('<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"/>');class lz extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}const qf='a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])',Tc=4;var ze,Qe,dn,et,Ws,pi,fi,B,yu,bu,Gy,wa,qy,wu,Su,Hs,Zs,pn,Yy,_u,Xy,Ky,Sa,Jn;class Vy extends HTMLElement{constructor(){super();w(this,B);w(this,ze,!1);w(this,Qe,null);w(this,dn);w(this,et,null);w(this,Ws,"bottom-start");w(this,pi,!1);w(this,fi,!1);w(this,Hs,e=>{l(this,ze)&&(l(this,pi)||e.composedPath().includes(this)||(this.open=!1))});w(this,Zs,e=>{if(l(this,ze)){if(e.key==="Escape"){e.preventDefault(),this.open=!1;return}e.key==="Tab"&&f(this,B,Yy).call(this,e)}});w(this,pn,()=>{l(this,ze)&&f(this,B,Sa).call(this)});x(this,dn,this.attachShadow({mode:"open"})),Lm(l(this,dn)),f(this,B,bu).call(this,"anchor")}connectedCallback(){this.removeAttribute("popover"),this.hasAttribute("tone")||this.setAttribute("tone","light"),f(this,B,bu).call(this,"open"),f(this,B,Jn).call(this),l(this,ze)&&(f(this,B,wu).call(this),f(this,B,wa).call(this))}disconnectedCallback(){var e;f(this,B,Su).call(this),(e=l(this,Qe))==null||e.removeAttribute("aria-expanded")}attributeChangedCallback(e){e==="open"?f(this,B,Gy).call(this,this.hasAttribute("open")):e==="material"&&l(this,ze)&&(f(this,B,Jn).call(this),f(this,B,wa).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"),x(this,Qe,e),f(this,B,yu).call(this),l(this,ze)&&f(this,B,Sa).call(this))}}ze=new WeakMap,Qe=new WeakMap,dn=new WeakMap,et=new WeakMap,Ws=new WeakMap,pi=new WeakMap,fi=new WeakMap,B=new WeakSet,yu=function(){l(this,Qe)&&l(this,Qe).setAttribute("aria-expanded",l(this,ze)?"true":"false")},bu=function(e){if(!Object.prototype.hasOwnProperty.call(this,e))return;const n=this,i=n[e];delete n[e],n[e]=i},Gy=function(e){var n,i,s;if(l(this,ze)!==e){if(x(this,ze,e),f(this,B,yu).call(this),!this.isConnected){f(this,B,Jn).call(this);return}e?(x(this,pi,!0),setTimeout(()=>{x(this,pi,!1)},0),f(this,B,Jn).call(this),f(this,B,wu).call(this),f(this,B,wa).call(this)):(f(this,B,Su).call(this),(i=(n=l(this,et))==null?void 0:n.hidePopover)==null||i.call(n),f(this,B,Jn).call(this),(s=l(this,Qe))==null||s.focus(),this.dispatchEvent(new lz))}},wa=function(){l(this,fi)||(x(this,fi,!0),queueMicrotask(()=>{x(this,fi,!1),!(!l(this,ze)||!this.isConnected)&&(f(this,B,qy).call(this),f(this,B,Ky).call(this))}))},qy=function(){var e,n;if(l(this,et)){try{(n=(e=l(this,et)).showPopover)==null||n.call(e)}catch{}f(this,B,Sa).call(this)}},wu=function(){document.addEventListener("click",l(this,Hs)),document.addEventListener("keydown",l(this,Zs),!0),window.addEventListener("resize",l(this,pn)),window.addEventListener("scroll",l(this,pn),!0)},Su=function(){document.removeEventListener("click",l(this,Hs)),document.removeEventListener("keydown",l(this,Zs),!0),window.removeEventListener("resize",l(this,pn)),window.removeEventListener("scroll",l(this,pn),!0)},Hs=new WeakMap,Zs=new WeakMap,pn=new WeakMap,Yy=function(e){const n=f(this,B,_u).call(this);if(n.length===0){e.preventDefault();return}const i=n[0],s=n[n.length-1],o=f(this,B,Xy).call(this),a=o instanceof HTMLElement&&n.includes(o);e.shiftKey?(!a||o===i)&&(e.preventDefault(),s.focus()):(!a||o===s)&&(e.preventDefault(),i.focus())},_u=function(){if(!l(this,et))return[];const e=l(this,et).querySelector("slot");if(!(e instanceof HTMLSlotElement))return[];const n=[];for(const i of e.assignedElements({flatten:!0}))if(i instanceof HTMLElement){i.matches(qf)&&n.push(i);for(const s of i.querySelectorAll(qf))n.push(s)}return n},Xy=function(){var n;let e=document.activeElement;for(;e&&((n=e.shadowRoot)!=null&&n.activeElement);)e=e.shadowRoot.activeElement;return e},Ky=function(){var n;const e=f(this,B,_u).call(this);e.length>0?e[0].focus():(n=l(this,et))==null||n.focus()},Sa=function(){if(!l(this,ze)||!l(this,Qe)||!l(this,et))return;const e=l(this,Qe).getBoundingClientRect(),n=l(this,et).getBoundingClientRect(),s=window.innerHeight-e.bottom,o=n.height+Tc,a=s<o&&e.top>o?"top-start":"bottom-start";x(this,Ws,a);const c=a==="bottom-start"?e.bottom+Tc:e.top-n.height-Tc,u=e.left;l(this,et).style.transform=`translate(${u}px, ${c}px)`,l(this,et).setAttribute("data-placement",a)},Jn=function(){this.toggleAttribute("open",l(this,ze));const e=this.getAttribute("material")??"paper";Fe(l(this,ze)?H`<div
|
|
81
|
-
class="panel"
|
|
82
|
-
part="panel"
|
|
83
|
-
popover="manual"
|
|
84
|
-
data-placement=${l(this,Ws)}
|
|
85
|
-
tabindex="-1"
|
|
86
|
-
role="dialog"
|
|
87
|
-
material=${e}
|
|
88
|
-
level="1"
|
|
89
|
-
>
|
|
90
|
-
<slot></slot>
|
|
91
|
-
</div>`:ae,l(this,dn)),x(this,et,l(this,dn).querySelector(".panel"))},y(Vy,"observedAttributes",["open","material"]);customElements.get("ui-popover")||customElements.define("ui-popover",Vy);class Jy extends Event{constructor(e){super("dropdown-item-select",{bubbles:!0,composed:!0});y(this,"value");this.value=e}}class cz extends Event{constructor(e){super("select",{bubbles:!0,composed:!0});y(this,"value");this.value=e}}var tt,wt,Sr,_r,ie,Bs,js,z,eb,as,tb,rb,ku,nb,ls,jr,fn,Vs,Ja,Gs,Qa,ib,sb,Eu,cs,xu,Au,qt;class Qy extends HTMLElement{constructor(){super();w(this,z);w(this,tt,!1);w(this,wt,null);w(this,Sr,null);w(this,_r);w(this,ie,null);w(this,Bs,ya());w(this,js,new MutationObserver(e=>f(this,z,ib).call(this,e)));w(this,fn,()=>{f(this,z,ls).call(this,!l(this,tt))});w(this,Vs,e=>{e.key!=="Enter"&&e.key!==" "||(e.preventDefault(),l(this,fn).call(this))});w(this,Ja,()=>{l(this,tt)&&f(this,z,ls).call(this,!1)});w(this,Gs,e=>{e instanceof Jy&&(e.stopPropagation(),x(this,tt,!1),f(this,z,as).call(this,e.value),f(this,z,qt).call(this),this.dispatchEvent(new cz(e.value)))});w(this,Qa,()=>{f(this,z,Eu).call(this)});x(this,_r,this.attachShadow({mode:"open"})),Lm(l(this,_r))}connectedCallback(){this.addEventListener("dropdown-item-select",l(this,Gs)),f(this,z,eb).call(this),l(this,js).observe(this,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["selected","value","slot"]}),f(this,z,qt).call(this)}disconnectedCallback(){this.removeEventListener("dropdown-item-select",l(this,Gs)),l(this,js).disconnect(),f(this,z,Au).call(this)}attributeChangedCallback(e){if(e==="open"){f(this,z,ls).call(this,this.hasAttribute("open"));return}f(this,z,qt).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,wt)}set value(e){e===null?(f(this,z,jr).call(this,null,null),f(this,z,tb).call(this)):f(this,z,as).call(this,e),f(this,z,qt).call(this)}close(){f(this,z,ls).call(this,!1)}}tt=new WeakMap,wt=new WeakMap,Sr=new WeakMap,_r=new WeakMap,ie=new WeakMap,Bs=new WeakMap,js=new WeakMap,z=new WeakSet,eb=function(){var n;const e=this.querySelector("dropdown-item[selected]");e&&f(this,z,jr).call(this,e.value,((n=e.textContent)==null?void 0:n.trim())??null)},as=function(e){var n;for(const i of l(this,z,ku))i.value===e?(f(this,z,jr).call(this,e,((n=i.textContent)==null?void 0:n.trim())??null),i.hasAttribute("selected")||i.setAttribute("selected","")):i.hasAttribute("selected")&&i.removeAttribute("selected")},tb=function(){const e=this.querySelectorAll("dropdown-item[selected]");for(const n of e)n.removeAttribute("selected")},rb=function(e){for(const n of l(this,z,ku))if(n.value===e)return n;return null},ku=function(){return this.querySelectorAll("dropdown-item")},nb=function(){return l(this,Sr)??this.title},ls=function(e){l(this,tt)!==e&&(x(this,tt,e),f(this,z,qt).call(this))},jr=function(e,n){x(this,wt,e),x(this,Sr,n)},fn=new WeakMap,Vs=new WeakMap,Ja=new WeakMap,Gs=new WeakMap,Qa=new WeakMap,ib=function(e){e.every(i=>i.target instanceof Element?i.target.closest('[slot="trigger"]')!==null:!1)||f(this,z,sb).call(this)},sb=function(){var n,i;const e=this.querySelector("dropdown-item[selected]");if(e){const s=e.value,o=((n=e.textContent)==null?void 0:n.trim())??null,a=l(this,wt)!==s||l(this,Sr)!==o;f(this,z,jr).call(this,s,o),f(this,z,as).call(this,s),a?f(this,z,qt).call(this):f(this,z,cs).call(this);return}if(l(this,wt)!==null){const s=f(this,z,rb).call(this,l(this,wt));if(s){const o=((i=s.textContent)==null?void 0:i.trim())??null,a=l(this,Sr)!==o;f(this,z,jr).call(this,l(this,wt),o),f(this,z,as).call(this,l(this,wt)),a?f(this,z,qt).call(this):f(this,z,cs).call(this);return}}if(l(this,wt)!==null||l(this,Sr)!==null){f(this,z,jr).call(this,null,null),f(this,z,qt).call(this);return}f(this,z,cs).call(this)},Eu=function(){const e=l(this,_r).querySelector('slot[name="trigger"]'),n=e instanceof HTMLSlotElement?e.assignedElements()[0]??null:null;l(this,ie)!==n&&(f(this,z,Au).call(this),x(this,ie,n),l(this,ie)&&(l(this,ie).addEventListener("click",l(this,fn)),l(this,ie)instanceof HTMLButtonElement?l(this,ie).hasAttribute("type")||(l(this,ie).type="button"):(l(this,ie).hasAttribute("role")||l(this,ie).setAttribute("role","button"),l(this,ie).hasAttribute("tabindex")||(l(this,ie).tabIndex=0),l(this,ie).addEventListener("keydown",l(this,Vs))))),f(this,z,cs).call(this),f(this,z,xu).call(this)},cs=function(){l(this,ie)&&(l(this,ie).setAttribute("data-dropdown-trigger",""),l(this,ie).setAttribute("aria-haspopup","listbox"),l(this,ie).setAttribute("aria-expanded",l(this,tt)?"true":"false"))},xu=function(){const e=l(this,Bs).value;if(!e)return;const n=l(this,_r).querySelector("button.fallback-trigger");e.anchor=l(this,ie)??n??null},Au=function(){l(this,ie)&&(l(this,ie).removeEventListener("click",l(this,fn)),l(this,ie).removeEventListener("keydown",l(this,Vs)),l(this,ie).removeAttribute("data-dropdown-trigger"),l(this,ie).removeAttribute("aria-haspopup"),l(this,ie).removeAttribute("aria-expanded"),x(this,ie,null))},qt=function(){this.toggleAttribute("open",l(this,tt)),Fe(H`
|
|
92
|
-
<slot name="trigger" @slotchange=${l(this,Qa)}>
|
|
93
|
-
<button
|
|
94
|
-
class="fallback-trigger"
|
|
95
|
-
part="trigger"
|
|
96
|
-
type="button"
|
|
97
|
-
aria-haspopup="listbox"
|
|
98
|
-
aria-expanded=${l(this,tt)?"true":"false"}
|
|
99
|
-
@click=${l(this,fn)}
|
|
100
|
-
>
|
|
101
|
-
<span class="trigger-label" part="trigger-label">${l(this,z,nb)}</span>
|
|
102
|
-
<span class="trigger-icon" part="trigger-icon" aria-hidden="true">
|
|
103
|
-
${jy({size:16})}
|
|
104
|
-
</span>
|
|
105
|
-
</button>
|
|
106
|
-
</slot>
|
|
107
|
-
<ui-popover
|
|
108
|
-
class="dropdown-popover"
|
|
109
|
-
material="glass-frosted"
|
|
110
|
-
?open=${l(this,tt)}
|
|
111
|
-
@close=${l(this,Ja)}
|
|
112
|
-
${ba(l(this,Bs))}
|
|
113
|
-
>
|
|
114
|
-
${l(this,tt)?H`<div class="dropdown-list" part="list" role="listbox">
|
|
115
|
-
<slot></slot>
|
|
116
|
-
</div>`:ae}
|
|
117
|
-
</ui-popover>
|
|
118
|
-
`,l(this,_r)),f(this,z,xu).call(this),queueMicrotask(()=>f(this,z,Eu).call(this))},y(Qy,"observedAttributes",["title","open"]);class uz extends HTMLElement{}class hz extends HTMLElement{}class dz extends HTMLElement{}var In,$u,ab,qs,Ys;class ob extends HTMLElement{constructor(){super(...arguments);w(this,In);w(this,qs,()=>{this.action||f(this,In,ab).call(this)});w(this,Ys,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,qs)),this.addEventListener("keydown",l(this,Ys)),f(this,In,$u).call(this)}disconnectedCallback(){this.removeEventListener("click",l(this,qs)),this.removeEventListener("keydown",l(this,Ys))}attributeChangedCallback(){f(this,In,$u).call(this)}get value(){return this.getAttribute("value")??""}get selected(){return this.hasAttribute("selected")}get action(){return this.hasAttribute("action")}}In=new WeakSet,$u=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")},ab=function(){this.dispatchEvent(new Jy(this.value))},qs=new WeakMap,Ys=new WeakMap,y(ob,"observedAttributes",["action","selected","value"]);customElements.get("dropdown-menu")||customElements.define("dropdown-menu",Qy);customElements.get("dropdown-group")||customElements.define("dropdown-group",uz);customElements.get("dropdown-label")||customElements.define("dropdown-label",hz);customElements.get("dropdown-divider")||customElements.define("dropdown-divider",dz);customElements.get("dropdown-item")||customElements.define("dropdown-item",ob);class pz extends Event{constructor(e){super("rename",{bubbles:!0,composed:!0});y(this,"value");this.value=e}}var Ot,St,se,Oe,us,Xs,Iu,_a,Tu,Ks,Js,Qs;class lb extends HTMLElement{constructor(){super(...arguments);w(this,Oe);w(this,Ot,"");w(this,St,!1);w(this,se,null);w(this,Xs,e=>{l(this,St)||(e.preventDefault(),f(this,Oe,Iu).call(this))});w(this,Ks,e=>{e.stopPropagation()});w(this,Js,e=>{var n,i;e.key==="Enter"?(e.preventDefault(),f(this,Oe,_a).call(this,!0),(n=l(this,se))==null||n.blur()):e.key==="Escape"&&(e.preventDefault(),f(this,Oe,_a).call(this,!1),(i=l(this,se))==null||i.blur())});w(this,Qs,()=>{f(this,Oe,_a).call(this,!0)})}connectedCallback(){l(this,se)||(x(this,se,document.createElement("span")),l(this,se).className="editable-text-span",this.append(l(this,se)));const e=this.getAttribute("value");e!==null&&x(this,Ot,e),f(this,Oe,us).call(this),this.addEventListener("dblclick",l(this,Xs))}disconnectedCallback(){this.removeEventListener("dblclick",l(this,Xs)),l(this,St)&&f(this,Oe,Tu).call(this)}attributeChangedCallback(e){if(e==="value"){const n=this.getAttribute("value")??"";x(this,Ot,n),l(this,St)||f(this,Oe,us).call(this)}}get value(){return l(this,Ot)}set value(e){x(this,Ot,e),l(this,St)||f(this,Oe,us).call(this)}startEditing(){l(this,St)||f(this,Oe,Iu).call(this)}}Ot=new WeakMap,St=new WeakMap,se=new WeakMap,Oe=new WeakSet,us=function(){l(this,se)&&(l(this,se).textContent=l(this,Ot))},Xs=new WeakMap,Iu=function(){l(this,se)&&(x(this,St,!0),l(this,se).setAttribute("contenteditable","plaintext-only"),l(this,se).setAttribute("spellcheck","false"),l(this,se).addEventListener("keydown",l(this,Js)),l(this,se).addEventListener("blur",l(this,Qs)),l(this,se).addEventListener("mousedown",l(this,Ks)),this.toggleAttribute("data-editing",!0),queueMicrotask(()=>{var n;if(!l(this,se))return;l(this,se).focus();const e=(n=this.ownerDocument.defaultView)==null?void 0:n.getSelection();e==null||e.selectAllChildren(l(this,se))}))},_a=function(e){if(!l(this,St)||!l(this,se))return;const n=(l(this,se).textContent??"").trim();x(this,St,!1),l(this,se).removeAttribute("contenteditable"),l(this,se).removeAttribute("spellcheck"),this.toggleAttribute("data-editing",!1),f(this,Oe,Tu).call(this),e&&n.length>0&&n!==l(this,Ot)&&(x(this,Ot,n),this.dispatchEvent(new pz(n))),f(this,Oe,us).call(this)},Tu=function(){var e,n,i;(e=l(this,se))==null||e.removeEventListener("keydown",l(this,Js)),(n=l(this,se))==null||n.removeEventListener("blur",l(this,Qs)),(i=l(this,se))==null||i.removeEventListener("mousedown",l(this,Ks))},Ks=new WeakMap,Js=new WeakMap,Qs=new WeakMap,y(lb,"observedAttributes",["value"]);customElements.get("editable-text")||customElements.define("editable-text",lb);class fz extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}var eo,Rr,Cu,el,to,Ru;class cb extends HTMLElement{constructor(){super();w(this,Rr);w(this,eo);w(this,el,e=>{e.target===e.currentTarget&&f(this,Rr,Cu).call(this)});w(this,to,e=>{this.open&&e.key==="Escape"&&f(this,Rr,Cu).call(this)});x(this,eo,this.attachShadow({mode:"open"}))}connectedCallback(){document.addEventListener("keydown",l(this,to)),f(this,Rr,Ru).call(this)}disconnectedCallback(){document.removeEventListener("keydown",l(this,to))}attributeChangedCallback(){f(this,Rr,Ru).call(this)}get open(){return this.hasAttribute("open")}}eo=new WeakMap,Rr=new WeakSet,Cu=function(){this.dispatchEvent(new fz)},el=new WeakMap,to=new WeakMap,Ru=function(){Fe(H`
|
|
119
|
-
${this.open?H`
|
|
120
|
-
<div class="backdrop" part="backdrop" @click=${l(this,el)}>
|
|
121
|
-
<slot></slot>
|
|
122
|
-
</div>
|
|
123
|
-
`:null}
|
|
124
|
-
`,l(this,eo))},y(cb,"observedAttributes",["open"]);customElements.get("modal-overlay")||customElements.define("modal-overlay",cb);class gz extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}class mz extends HTMLElement{}var ro,no,Pu;class ub extends HTMLElement{constructor(){super();w(this,no);w(this,ro);x(this,ro,this.attachShadow({mode:"open"}))}connectedCallback(){f(this,no,Pu).call(this)}attributeChangedCallback(){f(this,no,Pu).call(this)}get closable(){return this.hasAttribute("closable")}}ro=new WeakMap,no=new WeakSet,Pu=function(){const e=this.querySelector("panel-page");Fe(H`
|
|
125
|
-
<section class="panel" part="panel">
|
|
126
|
-
<header class="title-bar" part="header">
|
|
127
|
-
<h2 class="title" part="title">${(e==null?void 0:e.getAttribute("title"))??""}</h2>
|
|
128
|
-
${this.closable?H`
|
|
129
|
-
<button
|
|
130
|
-
type="button"
|
|
131
|
-
class="title-button"
|
|
132
|
-
part="button close-button"
|
|
133
|
-
aria-label="Close"
|
|
134
|
-
@click=${()=>this.dispatchEvent(new gz)}
|
|
135
|
-
>
|
|
136
|
-
<span class="close-icon" part="icon close-icon">${jh({size:16})}</span>
|
|
137
|
-
</button>
|
|
138
|
-
`:null}
|
|
139
|
-
</header>
|
|
140
|
-
<slot></slot>
|
|
141
|
-
</section>
|
|
142
|
-
`,l(this,ro))},y(ub,"observedAttributes",["closable"]);customElements.get("panel-view")||customElements.define("panel-view",ub);customElements.get("panel-page")||customElements.define("panel-page",mz);function Cl(r){return typeof r=="object"&&r!==null}function vz(r){return!Cl(r)||r.type!=="wheel"||typeof r.deltaX!="number"||typeof r.deltaY!="number"||typeof r.shiftKey!="boolean"?!1:!("id"in r)}function yz(r){return!Cl(r)||r.type!=="swipe-move"||typeof r.deltaX!="number"?!1:!("id"in r)}function bz(r){return!Cl(r)||r.type!=="swipe-end"||typeof r.velocityX!="number"?!1:!("id"in r)}function hb(r){return!Cl(r)||r.type!=="open-artifact"||typeof r.artifactID!="string"?!1:!("id"in r)}function wz(r=window){if(r.parent===r)return;let t=0,e=0;r.document.documentElement&&(r.document.documentElement.style.touchAction="pan-y"),r.addEventListener("wheel",u=>{const h=u;t=h.clientX,e=h.clientY,r.parent.postMessage({type:"wheel",deltaX:h.deltaX,deltaY:h.deltaY,shiftKey:h.shiftKey},"*"),h.preventDefault()},{passive:!1});const n=8,i=100,s=1e3,o=new Map;r.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}),r.addEventListener("pointermove",u=>{const h=u,p=o.get(h.pointerId);if(!p||p.discarded)return;if(!p.active){const _=h.clientX-p.startX,I=h.clientY-p.startY,P=Math.abs(_),R=Math.abs(I);if(P<n&&R<n)return;if(R>=P){p.discarded=!0;return}p.active=!0}const m=h.clientX-p.lastX;p.lastX=h.clientX,p.offset+=m,p.samples.push({time:h.timeStamp,offset:p.offset});const g=h.timeStamp-i;let S=0;for(let _=0;_<p.samples.length;_+=1){if(p.samples[_].time>=g){S=_;break}S=_+1}if(S>0){const _=Math.max(0,S-1);p.samples.splice(0,_)}r.parent.postMessage({type:"swipe-move",deltaX:m},"*"),h.preventDefault()},{passive:!1}),r.addEventListener("pointerup",u=>{const h=u,p=o.get(h.pointerId);if(!p||(o.delete(h.pointerId),!p.active))return;let m=0;if(p.samples.length>=2){const g=p.samples[0],S=p.samples[p.samples.length-1],_=S.time-g.time;_>0&&(m=(S.offset-g.offset)/_*s)}r.parent.postMessage({type:"swipe-end",velocityX:m},"*")}),r.addEventListener("pointercancel",u=>{const h=u,p=o.get(h.pointerId);p&&(o.delete(h.pointerId),p.active&&r.parent.postMessage({type:"swipe-end",velocityX:0},"*"))}),r.addEventListener("message",u=>{var _,I;const h=u.data;if(h===null||typeof h!="object"||h.type!=="scroll")return;const p=h,m=typeof p.deltaX=="number"?p.deltaX:0,g=typeof p.deltaY=="number"?p.deltaY:0;let S=((I=(_=r.document).elementFromPoint)==null?void 0:I.call(_,t,e))??null;for(;S!==null;){const P=r.getComputedStyle(S);if(g!==0){const R=(P.overflowY==="auto"||P.overflowY==="scroll")&&S.scrollHeight>S.clientHeight,W=g>0?S.scrollTop+S.clientHeight<S.scrollHeight:S.scrollTop>0;if(R&&W){S.scrollBy(m,g);return}}if(m!==0){const R=(P.overflowX==="auto"||P.overflowX==="scroll")&&S.scrollWidth>S.clientWidth,W=m>0?S.scrollLeft+S.clientWidth<S.scrollWidth:S.scrollLeft>0;if(R&&W){S.scrollBy(m,g);return}}S=S.parentElement}r.scrollBy(m,g)});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:(r.parent.postMessage({type:"open-artifact",artifactID:p},"*"),!0)}r.document.addEventListener("click",u=>{const h=u,p=typeof h.composedPath=="function"?h.composedPath():[];let m=null;for(const _ of p)if(_ instanceof HTMLAnchorElement||_&&_.tagName==="A"){m=_;break}if(m===null)return;const g=m.getAttribute("href");if(g===null)return;let S;try{S=new URL(g,r.document.baseURI).toString()}catch{return}a(S)&&u.preventDefault()},!0);const c=r.navigation;c&&c.addEventListener("navigate",u=>{var p;a((p=u.destination)==null?void 0:p.url)&&u.preventDefault()})}function Sz(){return`(${wz.toString()})(window);`}const _z=it(),kz=it(),Ez="No handler registered for update-content",xz="handleUpdateContent: handler already registered";function Az(r){return r instanceof Error&&typeof r.message=="string"?r.message:String(r)}const $z=Io(Wt);var gi,mi,vi,gn,mn,io,Me,Du,db,pb,hs,Lu,Tg;let Iz=(Tg=class extends $z{constructor(e){super();w(this,Me);w(this,gi);w(this,mi);w(this,vi);w(this,gn,null);w(this,mn,null);w(this,io,!1);x(this,gi,e);const n=e.ownerDocument.defaultView;if(!n)throw new Error("ArtifactView: iframe has no owner window");x(this,mi,n),x(this,vi,i=>f(this,Me,db).call(this,i)),l(this,mi).addEventListener("message",l(this,vi))}get content(){return l(this,mn)}set content(e){f(this,Me,Lu).call(this),x(this,mn,e),l(this,io)&&f(this,Me,Du).call(this,e)}handleUpdateContent(e){if(f(this,Me,Lu).call(this),l(this,gn)!==null)throw new Error(xz);x(this,gn,e)}dispose(){l(this,mi).removeEventListener("message",l(this,vi)),x(this,gn,null)}},gi=new WeakMap,mi=new WeakMap,vi=new WeakMap,gn=new WeakMap,mn=new WeakMap,io=new WeakMap,Me=new WeakSet,Du=function(e){const n={type:"content-updated",content:e};f(this,Me,hs).call(this,n)},db=function(e){if(this.disposed||e.source!==l(this,gi).contentWindow)return;const n=e.data;if(RR(n)){x(this,io,!0),this.dispatchEvent(new _z("ready")),l(this,mn)!==null&&f(this,Me,Du).call(this,l(this,mn));return}if(PR(n)){f(this,Me,pb).call(this,n);return}if(hb(n)){this.dispatchEvent(new kz("open-artifact",{artifactID:n.artifactID}));return}},pb=async function(e){const n=l(this,gn);if(n===null){f(this,Me,hs).call(this,{type:"response",id:e.id,error:{message:Ez}});return}try{await n(e.content)}catch(i){if(this.disposed)return;f(this,Me,hs).call(this,{type:"response",id:e.id,error:{message:Az(i)}});return}this.disposed||f(this,Me,hs).call(this,{type:"response",id:e.id,result:{}})},hs=function(e){const n=l(this,gi).contentWindow;n&&n.postMessage(e,"*")},Lu=function(){if(this.disposed)throw new Error("ArtifactView is disposed")},Tg);const Tz="text/html";async function Cz(r){const t=await fetch(r);if(!t.ok)throw new Error(`Failed to fetch artifact content: ${t.status}`);const e=await t.text(),n=new DOMParser().parseFromString(e,"text/html"),i=n.createElement("base");i.href=new URL(r,window.location.href).href,n.head.insertBefore(i,n.head.firstChild);const s=n.createElement("script");s.textContent=Sz(),n.head.appendChild(s);const o=new Blob([`<!DOCTYPE html>
|
|
143
|
-
${n.documentElement.outerHTML}`],{type:Tz});return URL.createObjectURL(o)}const Yf="television-artifact-bridge",Rz="_tvThemeBuster",fb=it(),Pz=it();class Dz extends HTMLElement{constructor(){super(...arguments);y(this,"_artifact",null);y(this,"_viewURL",null);y(this,"_contentURL",null);y(this,"_screen",null);y(this,"_subscribedScreen",null);y(this,"_subscribedServer",null);y(this,"_activeView",null);y(this,"_contentState",{kind:"idle"});y(this,"_fetchSequence",0);y(this,"_blobSequence",0);y(this,"_themeReloadSequence",0);y(this,"_mountedViewURL",null);y(this,"_mountedDirectRenderURL",null);y(this,"_mountedDirectRenderStatus",null);y(this,"_directRender",!1);y(this,"_blobURL",null);y(this,"_subscribedWebview",null);y(this,"_directRenderMessageListener",null);y(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)}});y(this,"handleServerEvent",e=>{const n=this._screen;if(!n||e.event.type!=="theme-changed"||e.serverURL!==n.server.url)return;const i=this.themeReloadSourceURL();i!==null&&(this._themeReloadSequence+=1,this.loadBlobFrame(this.withThemeBuster(i,this._themeReloadSequence)))});y(this,"handleOpenArtifact",e=>{this.requestFocus(e.artifactID)});y(this,"handleIframeMessage",e=>{const n=this.querySelector("iframe.artifact-frame");!n||n.contentWindow!==e.source||vz(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=n.contentWindow)==null||o.postMessage(s,this.iframeTargetOrigin(n))})});y(this,"handleWebviewIpcMessage",e=>{var o;const n=e.detail??e;if(!n||n.channel!==Yf)return;const i=(o=n.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,Yf,{type:"scroll",deltaX:0,deltaY:a})})})}set artifact(e){const n=this._artifact;this._artifact=e,this.render(),n!==null&&n!==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}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 fb("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 n=this.querySelector("iframe.artifact-frame");if(!n){this._contentState={kind:"error"},this.render();return}this._activeView=new Iz(n),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 n=this._screen,i=this._artifact;if(!n||!i)throw new Error("artifact-view: cannot save without a screen and artifact");await n.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 n;if(!this.isConnected){this.unsubscribeFromServer();return}const e=((n=this._screen)==null?void 0:n.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,n){const i=new URL(e,window.location.href);return i.searchParams.set(Rz,String(n)),i.toString()}startContentFetch(){this._fetchSequence+=1;const e=this._fetchSequence,n=this._contentURL,i=this._activeView;if(!i||n===null){this._contentState={kind:"error"},this.render();return}this._contentState={kind:"loading"},(async()=>{try{const s=await fetch(n);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,n=this._contentURL,i=this._activeView;!i||n===null||(async()=>{try{const s=await fetch(n);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 n=this._blobSequence;(async()=>{try{const i=await Cz(e);if(n!==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(n!==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=n=>{const i=this.querySelector("iframe.artifact-frame");i&&n.source===i.contentWindow&&hb(n.data)&&this.requestFocus(n.data.artifactID)};this._directRenderMessageListener=e,window.addEventListener("message",e)}removeDirectRenderMessageListener(){this._directRenderMessageListener!==null&&(window.removeEventListener("message",this._directRenderMessageListener),this._directRenderMessageListener=null)}requestFocus(e){const n=this._screen;n&&n.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 n=e.externalURL;if(!n)throw new Error(`URL artifact ${e.id} is missing externalURL`);return Wh()?H`
|
|
144
|
-
<webview
|
|
145
|
-
class="artifact-frame artifact-content"
|
|
146
|
-
src=${n}
|
|
147
|
-
sandbox="allow-scripts allow-same-origin allow-forms"
|
|
148
|
-
></webview>
|
|
149
|
-
`:H`
|
|
150
|
-
<iframe
|
|
151
|
-
class="artifact-frame artifact-content"
|
|
152
|
-
src=${n}
|
|
153
|
-
sandbox="allow-scripts allow-same-origin allow-forms"
|
|
154
|
-
></iframe>
|
|
155
|
-
`}return this._contentState.kind==="error"?H`
|
|
156
|
-
<div class="artifact-content artifact-placeholder">
|
|
157
|
-
<em>Failed to load content</em>
|
|
158
|
-
</div>
|
|
159
|
-
`:this._viewURL!==null||this._directRender?H`
|
|
160
|
-
<iframe
|
|
161
|
-
class="artifact-frame artifact-content"
|
|
162
|
-
src=${this._blobURL??"about:blank"}
|
|
163
|
-
sandbox="allow-scripts"
|
|
164
|
-
></iframe>
|
|
165
|
-
`:H`
|
|
166
|
-
<div class="artifact-content artifact-placeholder">
|
|
167
|
-
<em>Artifact unavailable</em>
|
|
168
|
-
</div>
|
|
169
|
-
`}template(){const e=this._artifact;return H`
|
|
170
|
-
${this.contentTemplate()}
|
|
171
|
-
<footer class="artifact-title-bar" drag-handle material="glass-frosted">
|
|
172
|
-
<div class="artifact-title-group">
|
|
173
|
-
<span class="artifact-title-icon">${iz({size:16})}</span>
|
|
174
|
-
<span class="artifact-title">${e.title}</span>
|
|
175
|
-
</div>
|
|
176
|
-
<button
|
|
177
|
-
icon-only
|
|
178
|
-
variant="ghost"
|
|
179
|
-
class="artifact-close-btn"
|
|
180
|
-
@click=${()=>this.handleClose()}
|
|
181
|
-
aria-label="Close"
|
|
182
|
-
>
|
|
183
|
-
${jh({size:16})}
|
|
184
|
-
</button>
|
|
185
|
-
</footer>
|
|
186
|
-
`}render(){this._artifact&&(this.setAttribute("kind",this._artifact.kind),Fe(this.template(),this),this.syncWebviewSubscription())}dispatchArtifactWheel(e,n){this.dispatchEvent(new Pz("artifact-wheel",{bubbles:!0,composed:!0,deltaX:e.deltaX,deltaY:e.deltaY,shiftKey:e.shiftKey,scrollNative:n}))}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 n=e.getAttribute("sandbox")??"";if(!new Set(n.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",Dz);/**
|
|
187
|
-
* @license
|
|
188
|
-
* Copyright 2017 Google LLC
|
|
189
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
190
|
-
*/const Xf=(r,t,e)=>{const n=new Map;for(let i=t;i<=e;i++)n.set(r[i],i);return n},Kf=Tl(class extends Bh{constructor(r){if(super(r),r.type!==Zh.CHILD)throw Error("repeat() can only be used in text expressions")}dt(r,t,e){let n;e===void 0?e=t:t!==void 0&&(n=t);const i=[],s=[];let o=0;for(const a of r)i[o]=n?n(a,o):o,s[o]=e(a,o),o++;return{values:s,keys:i}}render(r,t,e){return this.dt(r,t,e).values}update(r,[t,e,n]){const i=JL(r),{values:s,keys:o}=this.dt(t,e,n);if(!Array.isArray(i))return this.ut=o,s;const a=this.ut??(this.ut=[]),c=[];let u,h,p=0,m=i.length-1,g=0,S=s.length-1;for(;p<=m&&g<=S;)if(i[p]===null)p++;else if(i[m]===null)m--;else if(a[p]===o[g])c[g]=Wr(i[p],s[g]),p++,g++;else if(a[m]===o[S])c[S]=Wr(i[m],s[S]),m--,S--;else if(a[p]===o[S])c[S]=Wr(i[p],s[S]),Xi(r,c[S+1],i[p]),p++,S--;else if(a[m]===o[g])c[g]=Wr(i[m],s[g]),Xi(r,i[p],i[m]),m--,g++;else if(u===void 0&&(u=Xf(o,g,S),h=Xf(a,p,m)),u.has(a[p]))if(u.has(a[m])){const _=h.get(o[g]),I=_!==void 0?i[_]:null;if(I===null){const P=Xi(r,i[p]);Wr(P,s[g]),c[g]=P}else c[g]=Wr(I,s[g]),Xi(r,i[p],I),i[_]=null;g++}else $c(i[m]),m--;else $c(i[p]),p++;for(;g<=S;){const _=Xi(r,c[S+1]);Wr(_,s[g]),c[g++]=_}for(;p<=m;){const _=i[p++];_!==null&&$c(_)}return this.ut=o,KL(r,c),xn}}),Ae=r=>({type:"px",...r}),xe=r=>({type:"unit",...r}),ea=2;class Lz{constructor(t){y(this,"basis");y(this,"min");y(this,"_gap");y(this,"_viewport");y(this,"_unit");this.basis=t.basis,this.min=t.min,this._viewport=t.viewport,this._gap=t.gap??Ae({x:ce,y:ce});const e=this._viewport.x??_n,n=this._viewport.y??Ma,i=this._gap.x??ce,s=this._gap.y??ce,o=e<=pA,a=o?e-i*ea:Math.min(_n,e-i*ea),c=o?n-s*ea:Math.min(Ma,n-s*ea),u=(a-i*(ft-1))/ft,h=(c-s*(ct-1))/ct,p=this.basis.x??0,m=this.basis.y??0,g=this.min.x??0,S=this.min.y??0;this._unit=Ae(o?{x:Math.max(g,u),y:Math.max(S,h)}:{x:Math.max(g,Math.min(p,u)),y:Math.max(S,Math.min(m,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,n=this._unit.y??0,i=this._gap.x??ce,s=this._gap.y??ce,o=t.x==null?void 0:t.x*e+Math.max(0,t.x-1)*i,a=t.y==null?void 0:t.y*n+Math.max(0,t.y-1)*s;return Ae({x:o,y:a})}}const An=1e-4,_t=1e-6,zz=40,Oz=24;function gb(r,t){return Math.max(0,r-t*2)}function mb(r){const t=[0];for(const e of r)t.push((t[t.length-1]??0)+e);return t}function vb(r){const t=[0];for(let e=0;e<r.length;e+=1){const n=t[e]??0;t.push(n+r[e]+ce)}return t}function yb(r,t,e){if(t<0||t>=r.length)return 0;let n=0,i=0;for(let s=t;s<r.length;s+=1){const o=r[s],a=i===0?o:n+ce+o;if(a>e+An)break;n=a,i+=1}return Math.max(1,i)}function Mz(r,t,e){if(t<0||t>=r.length)return 0;let n=0,i=0;for(let s=t;s>=0;s-=1){const o=r[s],a=i===0?o:n+ce+o;if(a>e+An)break;n=a,i+=1}return Math.max(1,i)}function Nz(r,t){if(r.length===0)return 0;let e=0,n=0;for(let i=r.length-1;i>=0;i-=1){const s=r[i],o=n===0?s:e+ce+s;if(o>t+An)break;e=o,n+=1}return Math.max(1,n)}function Vh(r,t){if(r.length===0)return 0;const e=Nz(r,t);return Math.max(0,r.length-e)}function Jf(r,t,e){if(r.length===0)return 0;const n=yb(r,t,e),i=Math.min(r.length,t+n);if(i<=t)return 0;const s=r.slice(t,i);return s.reduce((o,a)=>o+a,0)+Math.max(0,s.length-1)*ce}function zu(r,t,e){const n=r[t]??0;return e-n}function Qn(r,t,e,n,i){if(r.length===0)return 0;const s=Vh(r,i),o=t[s]??0,a=Math.max(0,Math.min(o,e));let c=0;for(let U=0;U<s;U+=1){const Y=t[U]??0,V=t[U+1]??Y;if(a>=Y&&a<=V+An){c=U;break}c=U+1}const u=Math.min(c+1,s),h=t[c]??0,p=t[u]??h,m=Math.max(p-h,An),g=u===c?0:(a-h)/m,S=vb(r),_=Jf(r,c,i),I=Jf(r,u,i),P=(n-_)/2,R=(n-I)/2,W=zu(S,c,P),M=zu(S,u,R);return W+(M-W)*g}function Uz(r,t,e,n,i){const s=Vh(r,n),o=t[s]??0;let a=0,c=o;for(let u=0;u<zz;u+=1){const h=(a+c)/2;Qn(r,t,h,e,n)>i?a=h:c=h}return(a+c)/2}function Fz(r,t,e){const n=vb(r),[i,s]=t,o=r.slice(i,s+1),a=o.reduce((u,h)=>u+h,0)+Math.max(0,o.length-1)*ce,c=(e-a)/2;return zu(n,i,c)}function Wz(r,t,e){const n=yb(r,t,e);return[t,Math.min(r.length-1,t+n-1)]}function Hz(r,t,e){const n=Mz(r,t,e);return[Math.max(0,t-n+1),t]}function Zz(r,t){return r[0]===t[0]&&r[1]===t[1]}function Bz(r){const{nodeCols:t,nodeWidthsPx:e,viewportWidthPx:n}=r;if(t.length===0||e.length===0)return{viewspans:[],minScroll:0,maxScroll:0};const i=e.length,s=r.gapPx??ce,o=gb(n,s),a=mb(t),c=Vh(e,o),u=a[c]??0;function h(I){const P=Fz(e,I,n),R=Uz(e,a,n,o,P);return{nodeRange:I,anchor:Math.max(0,Math.min(u,R))}}const p=[];for(let I=0;I<i;){const P=Wz(e,I,o);p.push(h(P)),I=P[1]+1}const m=h(Hz(e,i-1,o)),g=p.filter(I=>I.nodeRange[0]<m.nodeRange[0]),S=g[g.length-1];return{viewspans:S&&Zz(S.nodeRange,m.nodeRange)?g:[...g,m],minScroll:0,maxScroll:u}}function Bn(r,t){var i;let e=0,n=Number.POSITIVE_INFINITY;for(let s=0;s<r.length;s+=1){const o=Math.abs((((i=r[s])==null?void 0:i.anchor)??0)-t);if(o+_t<n){n=o,e=s;continue}Math.abs(o-n)<=_t&&s<e&&(e=s)}return e}function jz(r,t,e){return e<=0?0:Math.max(0,Math.min(e-1,r+t))}function Hr(r,t,e){return Math.max(t,Math.min(e,r))}function Vz(r,t){var e;for(let n=0;n<r.length;n+=1)if(Math.abs((((e=r[n])==null?void 0:e.anchor)??0)-t)<=_t)return n;return-1}function Gz(r,t,e){var i,s;if(r.length===0)return t;const n=Vz(r,t);if(n>=0){const o=r[n+e];return(o==null?void 0:o.anchor)??r[e>0?r.length-1:0].anchor}if(e>0){for(const o of r)if(o.anchor>t+_t)return o.anchor;return((i=r[r.length-1])==null?void 0:i.anchor)??t}for(let o=r.length-1;o>=0;o-=1){const a=r[o];if(a&&a.anchor<t-_t)return a.anchor}return((s=r[0])==null?void 0:s.anchor)??t}class qz extends Wt{constructor(e){super();y(this,"_scroll",0);y(this,"_minScroll",0);y(this,"_maxScroll",0);y(this,"_viewspans",[]);y(this,"_activeViewspanIndex",0);y(this,"_nodeWidthsPx",[]);y(this,"_boundaryCols",[0]);y(this,"_viewportWidthPx",0);y(this,"_framedViewportWidthPx",0);this._scroll=(e==null?void 0:e.x)??0}get scroll(){return xe({x:this._scroll})}get translate(){return Ae({x:Qn(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 n=Hr(e.x??this._scroll,this._minScroll,this._maxScroll);Math.abs(n-this._scroll)<=_t||(this._scroll=n,this._activeViewspanIndex=Bn(this._viewspans,this._scroll),this.dispatchEvent(new Zn("layout-scroll",{scroll:this.scroll})))}rebuild(e){var m;const n=e.nodeWidths.map(g=>Math.max(0,g.x??0)),i=n.map(g=>e.grid.toPixels(xe({x:g})).x??0),s=e.grid.viewport.x??0,o=e.grid.gap.x??ce,a=Bz({nodeCols:n,nodeWidthsPx:i,viewportWidthPx:s,gapPx:o});this._nodeWidthsPx=i,this._boundaryCols=mb(n),this._viewportWidthPx=s,this._framedViewportWidthPx=gb(s,o),this._viewspans=a.viewspans,this._minScroll=a.minScroll,this._maxScroll=a.maxScroll;const c=Hr(this._scroll,this._minScroll,this._maxScroll);this._activeViewspanIndex=Bn(this._viewspans,c);const h=e.snap!==!1?((m=this._viewspans[this._activeViewspanIndex])==null?void 0:m.anchor)??c:c,p=Hr(h,this._minScroll,this._maxScroll);Math.abs(p-this._scroll)>_t&&(this._scroll=p,this.dispatchEvent(new Zn("layout-scroll",{scroll:this.scroll})))}step(e){var o;if(this._viewspans.length===0)return;const n=jz(this._activeViewspanIndex,e,this._viewspans.length),i=((o=this._viewspans[n])==null?void 0:o.anchor)??this._scroll,s=Hr(i,this._minScroll,this._maxScroll);this._activeViewspanIndex=n,!(Math.abs(s-this._scroll)<=_t)&&(this._scroll=s,this.dispatchEvent(new Zn("layout-scroll",{scroll:this.scroll})))}snap(e){var s;if(this._viewspans.length===0)return;const n=e===void 0?((s=this._viewspans[Bn(this._viewspans,this._scroll)])==null?void 0:s.anchor)??this._scroll:Gz(this._viewspans,this._scroll,e),i=Hr(n,this._minScroll,this._maxScroll);this._activeViewspanIndex=Bn(this._viewspans,i),!(Math.abs(i-this._scroll)<=_t)&&(this._scroll=i,this.dispatchEvent(new Zn("layout-scroll",{scroll:this.scroll})))}wheel(e){const n=Hr(this._scroll+(e.x??0),this._minScroll,this._maxScroll);Math.abs(n-this._scroll)<=_t||(this._scroll=n,this._activeViewspanIndex=Bn(this._viewspans,this._scroll),this.dispatchEvent(new Zn("layout-scroll",{scroll:this.scroll})))}wheelPixels(e){const n=e.x??0;if(Math.abs(n)<=An)return;const i=Qn(this._nodeWidthsPx,this._boundaryCols,this._scroll,this._viewportWidthPx,this._framedViewportWidthPx),s=i-n,o=Qn(this._nodeWidthsPx,this._boundaryCols,this._maxScroll,this._viewportWidthPx,this._framedViewportWidthPx),a=Qn(this._nodeWidthsPx,this._boundaryCols,this._minScroll,this._viewportWidthPx,this._framedViewportWidthPx),c=Math.max(o,Math.min(a,s));if(Math.abs(c-i)<=An)return;let u=this._minScroll,h=this._maxScroll;for(let m=0;m<Oz;m+=1){const g=(u+h)/2;Qn(this._nodeWidthsPx,this._boundaryCols,g,this._viewportWidthPx,this._framedViewportWidthPx)>c?u=g:h=g}const p=Hr((u+h)/2,this._minScroll,this._maxScroll);Math.abs(p-this._scroll)<=_t||(this._scroll=p,this._activeViewspanIndex=Bn(this._viewspans,this._scroll),this.dispatchEvent(new Zn("layout-scroll",{scroll:this.scroll})))}}const Cc={"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}},Yz=["stack-above","stack-below","reorder-before","reorder-after"];function Rc(r,t){return{left:r.left+r.width*t.left,top:r.top+r.height*t.top,width:r.width*t.width,height:r.height*t.height}}function Zr(r,t,e){return r>=e.left&&r<e.left+e.width&&t>=e.top&&t<e.top+e.height}function Ou(r){return Number.isFinite(r)?Math.max(ws,Math.min(Ih,Math.round(r))):ws}function Xz(r,t,e){const n=r.findIndex(a=>a.type==="card"&&a.id===t);if(n===-1)return r;const i=r[n];if(!i||i.type!=="card")return r;const s=Ou(e);if(i.width===s)return r;const o=[...r];return o[n]={...i,width:s},o}function bb(r,t){for(const e of r){if(e.type==="card"&&e.id===t)return e;if(e.type==="stack")for(const n of e.children){if(n.type==="card"&&n.id===t)return n;if(n.type==="row"){for(const i of n.children)if(i.id===t)return i}}}return null}function Mu(r){return r.height===ct||r.height===$r?{...r,height:$r}:r}function Nu(r){return r.height===$r?{...r,height:ct}:r}function Kz(r,t,e,n){const i=r.findIndex(h=>h.type==="stack"&&h.id===t);if(i===-1)return r;const s=r[i];if(!s||s.type!=="stack")return r;const o=s.children.find(h=>h.type==="card"&&h.id===e);if(!o||o.type!=="card")return r;const a=s.children.filter(h=>h.id!==e);if(a.length===s.children.length||a.length<1)return r;const c=[...r];if(a.length===1){const[h]=a;c[i]=h.type==="card"?Nu(h):h}else c[i]={...s,children:a};const u=Math.max(0,Math.min(n,c.length));return c.splice(u,0,Nu(o)),c}const Jz=it(),Qz=it(),eO=50;function tO(r,t){if(r.type!==t.type)return!1;switch(r.type){case"reorder":return t.index===r.index;case"stack":return t.targetCardId===r.targetCardId&&t.position===r.position;case"stack-child-noop":return!0;case"stack-child-extract":return t.toIndex===r.toIndex;case"stack-child-reorder":return t.position===r.position;default:return!1}}function Co(r){return{id:r.id,type:"drop-target",width:r.width,height:r.height}}function Qf(r){return r.map(nO)}function rO(r){return r.type==="drop-target"?{id:r.id,type:"card",artifactID:r.id,width:r.width,height:r.height}:r}function nO(r){return r.type==="drop-target"?{id:r.id,type:"card",artifactID:r.id,width:r.width,height:r.height}:r.type==="stack"?{...r,children:r.children.map(rO)}:r}function wb(r,t){return r.find(n=>n.type==="card"&&n.id===t)??null}function eg(r,t){return r.find(n=>n.type==="stack"&&n.id===t)??null}function iO(r,t){const e=[...t],n=e.findIndex(a=>a.type==="card"&&a.id===r.nodeId);if(n===-1)return null;const i=e[n];if(!i||i.type!=="card")return null;e.splice(n,1);const s=Math.max(0,Math.min(r.lastReorderIndex,e.length));e.splice(s,0,i);const o=e.findIndex(a=>a.type==="card"&&a.id===r.nodeId);return o===-1?null:{base:e,visualDraggedIndex:o}}function sO(r,t,e,n){const i=[...r.base];i.splice(r.visualDraggedIndex,1);const s=i.findIndex(m=>m.type==="card"&&m.id===e.targetCardId),o=s===-1?null:i[s];if(!o||o.type!=="card")return null;const a=wb(n,t.nodeId);if(!a)return null;const c=Mu(a),u=Mu(o),h=Co(c),p=e.position==="above"?[h,u]:[u,h];return i[s]={id:o.id,type:"stack",children:p},i}function Pc(r,t){return r.parentStackId?aO(r,t):oO(r,t)}function oO(r,t){const e=r.hitTarget;if(e.type==="reorder"){const n=t[r.sourceIndex];if(!n||n.type!=="card")return[...t];const i=[...t];return i.splice(r.sourceIndex,1),i.splice(e.index,0,Co(n)),i}if(e.type==="stack"){const n=iO(r,t);return n?sO(n,r,e,t)??[...t]:[...t]}return[...t]}function aO(r,t){const e=r.hitTarget;switch(e.type){case"stack-child-reorder":return lO(r,t,e.position);case"stack-child-extract":return cO(r,t,e.toIndex);case"stack-child-noop":return uO(r,t);default:return[...t]}}function lO(r,t,e){const n=t.findIndex(m=>m.type==="stack"&&m.id===r.parentStackId);if(n===-1)return[...t];const i=t[n];if(!i||i.type!=="stack")return[...t];if(!i.children.every(m=>m.type==="card"))return[...t];const s=i.children,o=s.findIndex(m=>m.id===r.nodeId);if(o===-1)return[...t];const a=s[o],c=s.filter(m=>m.id!==r.nodeId),u=Co(a),h=e==="above"?[u,...c]:[...c,u],p=[...t];return p[n]={...i,children:h},p}function cO(r,t,e){if(!r.parentStackId)return[...t];const n=Kz(t,r.parentStackId,r.nodeId,e);if(n===t)return[...t];const i=n.findIndex(a=>a.type==="card"&&a.id===r.nodeId);if(i===-1)return[...t];const s=n[i];if(!s||s.type!=="card")return[...t];const o=[...n];return o[i]=Co(s),o}function uO(r,t){const e=t.findIndex(c=>c.type==="stack"&&c.id===r.parentStackId);if(e===-1)return[...t];const n=t[e];if(!n||n.type!=="stack")return[...t];const i=n.children.findIndex(c=>c.type==="card"&&c.id===r.nodeId);if(i===-1)return[...t];const s=n.children[i];if(!s||s.type!=="card")return[...t];const o=[...t],a=[...n.children];return a[i]=Co(s),o[e]={...n,children:a},o}function hO(r,t){return t.find(n=>n.type==="stack"&&n.id===r.id)?r.id:yl()}function dO(r,t,e){if(r.type==="drop-target"){const n=bb(t,e);if(!n)throw new Error(`finalize: missing dragged card ${e}`);return Mu(n)}return r}function pO(r,t,e){const n=r.children.map(s=>dO(s,t,e));return{id:hO(r,t),type:"stack",children:n}}function fO(r,t,e){if(r.type==="drop-target"){const n=bb(t,e);if(!n)throw new Error(`finalize: missing dragged card ${e}`);return wb(t,e)!==null?n:Nu(n)}return r.type==="card"||r.type==="row"?r:pO(r,t,e)}function gO(r,t,e){return r.map(n=>fO(n,t,e))}function mO(r,t){return JSON.stringify(r)===JSON.stringify(t)}const vO=Io(Wt);class yO extends vO{constructor(e={}){super();y(this,"pending",null);y(this,"active",null)}start(e){if(this.pending||this.active)return;const n=e.pointer.x??0,i=e.pointer.y??0;this.pending={startX:n,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 n=e.pointer.x??0,i=e.pointer.y??0,s=this.pending;if(s){const u=n-s.startX,h=i-s.startY;Math.hypot(u,h)>=gA&&(this.pending=null,this.active={...s,pointerX:n,pointerY:i,hitTarget:{type:"reorder",index:s.sourceIndex},lastReorderIndex:s.sourceIndex},this.emitDrag(),this.dispatchEvent(new oe("change")));return}if(!this.active)return;const o=Pc(this.active,this.active.baseLayout),a=this.getHitTargetForPointer(n,i,e,o),c=a.type==="reorder"?a.index:this.active.lastReorderIndex;this.active.pointerX===n&&this.active.pointerY===i&&tO(this.active.hitTarget,a)&&this.active.lastReorderIndex===c||(this.active={...this.active,pointerX:n,pointerY:i,hitTarget:a,lastReorderIndex:c},this.emitDrag(),this.dispatchEvent(new oe("change")))}drop(){if(this.pending){this.cancel();return}if(!this.active)return;const e=this.active.baseLayout;let n=null;try{const i=Pc(this.active,e),s=gO(i,e,this.active.nodeId);mO(s,e)||(n=s)}catch{n=null}this.reset(),n&&this.dispatchEvent(new Qz("drop",{layout:n})),this.dispatchEvent(new oe("change"))}cancel(){!this.pending&&!this.active||(this.reset(),this.dispatchEvent(new oe("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=Pc(this.active,this.active.baseLayout);this.dispatchEvent(new Jz("drag",{nodeId:this.active.nodeId,source:{index:this.active.sourceIndex,parentId:this.active.parentStackId},grabOffset:Ae({x:this.active.grabOffsetX,y:this.active.grabOffsetY}),pointer:Ae({x:this.active.pointerX,y:this.active.pointerY}),size:Ae({x:this.active.width,y:this.active.height}),projectedLayout:e}))}getHitTargetForPointer(e,n,i,s){return this.active?this.isPointerInsideDragBounds(e,n,i.viewport)?this.active.parentStackId?this.getStackChildHitTarget(e,n,i,s):this.getTopLevelCardHitTarget(e,n,i,s):{type:"reorder",index:this.active.sourceIndex}:{type:"reorder",index:0}}getStackChildHitTarget(e,n,i,s){var u;if(!((u=this.active)!=null&&u.parentStackId))return{type:"stack-child-noop"};const o=this.getSourceStackInteractionRect(i.geometry);if(o&&Zr(e,n,o)){const h=o.top+o.height/2;return{type:"stack-child-reorder",position:n<h?"above":"below"}}const a=this.getSourceRemainingSiblingRect(i.geometry);if(a&&Zr(e,n,a)){const h=a.top+a.height/2;return{type:"stack-child-reorder",position:n<h?"above":"below"}}return{type:"stack-child-extract",toIndex:this.getTopLevelReorderIndexForPointer(e,n,i,s)}}getSourceRemainingSiblingRect(e){var s,o;if(!((s=this.active)!=null&&s.parentStackId))return;const n=eg(this.active.baseLayout,this.active.parentStackId);if(!n)return;const i=n.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 n=e.find(a=>{var c;return a.id===((c=this.active)==null?void 0:c.parentStackId)});if(n)return this.active.sourceStackRect=n.rect,n.rect;const i=eg(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,n,i,s){var g,S,_;const o=this.getTopLevelZoneNodes(i.geometry,s);if(o.length===0)return{type:"reorder",index:((g=this.active)==null?void 0:g.sourceIndex)??0};const c=(i.effectiveVelocity??0)<=eO;for(const I of o){const P=I.rect;if(!Zr(e,n,P))continue;const R=this.resolveTopLevelTargetForCard(e,n,I,I.logicalIndex,c);if(R)return R;if(!c&&((S=this.active)!=null&&S.hitTarget))return this.active.hitTarget}const u=this.getNearestTargetableZone(e,o);if(!u)return{type:"reorder",index:((_=this.active)==null?void 0:_.sourceIndex)??0};const h=Math.max(u.rect.left,Math.min(u.rect.left+u.rect.width,e)),p=this.resolveTopLevelTargetForCard(h,n,u,u.logicalIndex,c);if(p)return p;const m=u.rect.left+u.rect.width/2;return{type:"reorder",index:e<m?u.logicalIndex:u.logicalIndex+1}}getTopLevelReorderIndexForPointer(e,n,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(!Zr(e,n,p.rect))continue;const m=Rc(p.rect,Cc["reorder-before"]);if(Zr(e,n,m))return p.logicalIndex;const g=Rc(p.rect,Cc["reorder-after"]);if(Zr(e,n,g))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,n){const i=new Map(n.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,n,i,s,o){const a=i.rect;for(const c of Yz){if(!o&&(c==="stack-above"||c==="stack-below"))continue;const u=Cc[c],h=Rc(a,u);if(Zr(e,n,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,n){let i=null,s=Number.POSITIVE_INFINITY;for(const o of n){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,n,i){return e>=i.left&&e<=i.left+i.width&&n>=i.top&&n<=i.top+i.height}}const tg=60,bO=80,rg=.5,ng=10;class wO{constructor(){y(this,"awaitingFreshWheelGesture",!1);y(this,"lastWheelEventAt",Number.NEGATIVE_INFINITY);y(this,"lastWheelDeltaX",0);y(this,"activeGestureType","none");y(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:n,deltaX:i,deltaY:s,overArtifactContent:o}=t;e-this.lastWheelGestureAt>=tg&&(this.activeGestureType="none");const c=n&&s!==0,u=c?s:i,h=Math.abs(u),p=Math.abs(s);return this.activeGestureType==="vertical-artifact"&&o?h>=rg&&h>=p*ng?this.classifyHorizontal(e,u):(this.lastWheelGestureAt=e,{type:"scroll-native"}):this.activeGestureType==="horizontal-filmstrip"?!c&&o&&p>0&&p>=h*ng?(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 n=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)+bO;return this.awaitingFreshWheelGesture&&n<tg&&!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 SO=100,_O=1e3;class kO{constructor(t,e){y(this,"_status","idle");y(this,"cumulativeOffset",0);y(this,"samples",[]);y(this,"scroll");y(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(Ae({x:-e})))}end(){if(this._status!=="active")return;const t=this.computeVelocityPxPerSec();this.setAnimating(!0),Math.abs(t)<vA?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-SO;let n=0;for(let i=0;i<this.samples.length;i+=1){if(this.samples[i].time>=e){n=i;break}n=i+1}if(n>0){const i=Math.max(0,n-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],n=e.time-t.time;return n<=0?0:(e.offset-t.offset)/n*_O}}function EO({baseLayout:r,visibleLayout:t,resolved:e,cardsByID:n,grid:i,dragState:s,isForeground:o}){var S;const a=new Map(t.map(_=>[_.id,_])),c=e.nodes.map((_,I)=>{const P=a.get(_.id),R=[];for(const M of _.cards){if(s&&M.id===s.nodeId){R.push({key:`placeholder:${M.id}`,kind:"placeholder",card:null,placement:M,isTopLevelCard:!1,isDragged:!1,sourceStackId:s.source.parentId??null});continue}const U=n.get(M.id);U&&R.push({key:U.id,kind:"card",card:U,placement:M,isTopLevelCard:(P==null?void 0:P.type)==="card",isDragged:!1,sourceStackId:null})}if(s!=null&&s.source.parentId&&_.id===s.source.parentId){const M=n.get(s.nodeId);if(M){const U={key:M.id,kind:"card",card:M,placement:null,isTopLevelCard:!1,isDragged:!0,sourceStackId:s.source.parentId},Y=xO(r,s.source.parentId,s.nodeId),V=Y<0?R.length:Math.min(Y,R.length);R.splice(V,0,U)}}const W=!!(s&&(P==null?void 0:P.type)==="card"&&P.id===s.nodeId&&P.artifactID===s.nodeId);return{key:W?`placeholder:${_.id}`:_.id,kind:"visible",nodeId:_.id,widthPx:i.toPixels(xe({x:_.width})).x??0,widthUnits:_.width,layoutIndex:I,isForeground:o(I),isPlaceholder:W,slots:R}});if(!s||s.source.parentId&&a.has(s.source.parentId))return c;const u=n.get(s.nodeId);if(!u)return c;const h=s.source.parentId??s.nodeId,p=((S=Jr(r).nodes[s.source.index])==null?void 0:S.width)??ft,m={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}]},g=Math.max(0,Math.min(s.source.index,c.length));return c.splice(g,0,m),c}function ig(r){if(!r)return null;const t=r.projectedLayout,e=r.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 n=t.findIndex(i=>i.type==="drop-target");return n===-1?"none":e?`stack-child-extract:${n}`:`reorder:${n}`}function xO(r,t,e){const n=r.find(i=>i.type==="stack"&&i.id===t);return!n||n.type!=="stack"?-1:n.children.findIndex(i=>i.type==="card"&&i.id===e)}const AO=2,sg=1e3,ta=1e-4,$O=120,og=!1;function ag(r){return r.replace(/["\\]/g,"\\$&")}function lg(r,t,e){if(r===0)return 0;const n=t.toPixels(xe({y:ct})).y??0;return(e-n)/AO}function Dc(r){const t=r.clientWidth>0?r.clientWidth:_n,e=r.clientHeight>0?r.clientHeight:Ma;let n=0,i=0;if(r.isConnected){const o=getComputedStyle(r);n=parseFloat(o.paddingTop)||0,i=parseFloat(o.paddingBottom)||0}const s=Math.max(1,e-n-i);return{width:t,height:s,offsetY:n}}class IO extends Event{constructor(e){super("scroll",{bubbles:!0,composed:!0});y(this,"scrollPosition");this.scrollPosition=e}}class Sb extends Event{constructor(e){super("layout-change",{bubbles:!0,composed:!0});y(this,"layout");this.layout=e}}class TO extends HTMLElement{constructor(){super();y(this,"_layout",[]);y(this,"_scrollPosition",0);y(this,"layoutGrid",null);y(this,"layoutScroll",new qz(xe({x:0})));y(this,"scrollModelKey","");y(this,"resizeObserver",null);y(this,"renderPending",!1);y(this,"animateNextRender",!0);y(this,"wheelGesture",new wO);y(this,"swipeGesture",new kO(this.layoutScroll,e=>{this.animateNextRender=e}));y(this,"swipePointerId",null);y(this,"swipeStartX",0);y(this,"swipeStartY",0);y(this,"swipeLastX",0);y(this,"swipeActive",!1);y(this,"swipeShouldSuppressClick",!1);y(this,"swipeListenersAttached",!1);y(this,"wheelIdleSnapTimer",null);y(this,"dragController",new yO);y(this,"dragState",null);y(this,"activeDragPointerId",null);y(this,"dragListenersAttached",!1);y(this,"dragFrame",0);y(this,"lastDragFrameTime",0);y(this,"lastPointerX",0);y(this,"lastPointerY",0);y(this,"pointerVelocityPxPerSec",0);y(this,"scrollVelocityPxPerSec",0);y(this,"motionSampleTime",0);y(this,"motionSampleX",0);y(this,"motionSampleY",0);y(this,"lastDragControllerStatus","idle");y(this,"lastProjectedDragLayoutSignature","");y(this,"lastDragDropIntent",null);y(this,"lastActivePlaceholderId",null);y(this,"draggedSlotElement",null);y(this,"draggedSlotContainingBlock",null);y(this,"currentDragPreviewSize",null);y(this,"dragTrackOffsetXPx",0);y(this,"previousProjectedLayoutForOffset",null);y(this,"resizeState",null);y(this,"resizeListenersAttached",!1);y(this,"_cards",new Map);y(this,"onDragControllerChange",()=>{const e=this.dragController.status;e!==this.lastDragControllerStatus&&(this.lastDragControllerStatus=e,e==="idle"&&(this.dragState=null,this.resetDragPreviewState()),this.scheduleRender())});y(this,"onDragControllerDrag",e=>{var c;const n=JSON.stringify(e.projectedLayout),i=ig(e),s=RO(e.projectedLayout);if(n!==this.lastProjectedDragLayoutSignature||i!==this.lastDragDropIntent||s!==this.lastActivePlaceholderId){const u=Qf(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=n,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)});y(this,"onDragControllerDrop",e=>{this.dragState=null,this.resetDragPreviewState(),this.commitLayout(e.layout)});y(this,"onLayoutScrollInternal",e=>{const i=e.scroll.x??0;Math.abs(i-this._scrollPosition)<ta||(this._scrollPosition=i,this.emitScrollPositionChanged(i),this.scheduleRender())});y(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)))});y(this,"handleWheel",e=>{if(this._layout.length===0)return;const n=this.wheelGesture.decide({now:Date.now(),shiftKey:e.shiftKey,deltaX:e.deltaX,deltaY:e.deltaY,overArtifactContent:!1});n.type==="scroll-horizontal"&&(e.preventDefault(),this.applyHorizontalWheel(n.horizontalDelta))});y(this,"handleWindowMessage",e=>{if(this._layout.length===0)return;const n=this.findManagedArtifactFrame(e.source);if(n&&this.isTrustedArtifactFrameMessage(e,n)){if(yz(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(bz(e.data)){this.swipeGesture.status==="active"&&this.swipeGesture.end();return}}});y(this,"handleArtifactWheel",e=>{if(this._layout.length===0)return;const n=this.wheelGesture.decide({now:Date.now(),shiftKey:e.shiftKey,deltaX:e.deltaX,deltaY:e.deltaY,overArtifactContent:!0});if(n.type==="scroll-horizontal"){this.applyHorizontalWheel(n.horizontalDelta);return}n.type==="scroll-native"&&e.scrollNative(e.deltaY)});y(this,"handlePointerDown",e=>{if(e.button!==0||this.dragController.status!=="idle"||this.resizeState)return;const n=e.target;if(!(n instanceof Element))return;const i=n.closest("[data-resize-handle]");if(i){this.beginResize(e,i);return}const s=n.closest("[drag-handle]")!==null,o=n.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=n.closest(".node");if(p&&!p.hasAttribute("data-foreground")){const m=p.getAttribute("layout-node");if(m!==null){const g=parseInt(m,10);if(!isNaN(g)){const S=this.findViewspanContainingNode(g);if(S){this.clearWheelIdleSnap(),this.animateNextRender=!0,this.layoutScroll.scroll=xe({x:S.anchor}),e.preventDefault(),e.stopPropagation();return}}}}}return}if(o)return;const a=n.closest(".card-slot");if(!a)return;const c=a.getAttribute("data-layout-node-id");if(!c)return;const u=PO(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:Ae({x:e.clientX,y:e.clientY}),grabOffset:Ae({x:e.clientX-h.left,y:e.clientY-h.top}),size:Ae({x:h.width,y:h.height}),layout:this._layout}),this.attachDragListeners(),this.activeDragPointerId=e.pointerId;try{this.setPointerCapture(e.pointerId)}catch{}e.preventDefault()});y(this,"handleResizePointerMove",e=>{const n=this.resizeState;if(!n||e.pointerId!==n.pointerId)return;const i=this.layoutGrid,s=((i==null?void 0:i.unit.x)??fr)+ce;if(s<=0)return;const o=e.clientX-n.startClientX,a=Ou(n.startWidth+o/s);a!==n.currentWidth&&(n.currentWidth=a,this.scheduleRender())});y(this,"handleResizePointerUp",e=>{const n=this.resizeState;if(!n||e.pointerId!==n.pointerId)return;const i=n.currentWidth,s=n.startWidth,o=n.cardId;this.endResize(e.pointerId),i!==s?this.commitLayout(Xz(this._layout,o,i)):this.scheduleRender()});y(this,"handleResizePointerCancel",e=>{!this.resizeState||e.pointerId!==this.resizeState.pointerId||(this.endResize(e.pointerId),this.scheduleRender())});y(this,"handleResizeWindowBlur",()=>{this.resizeState&&(this.endResize(this.resizeState.pointerId),this.scheduleRender())});y(this,"handleResizeKeyDown",e=>{this.resizeState&&e.key==="Escape"&&(e.preventDefault(),this.endResize(this.resizeState.pointerId),this.scheduleRender())});y(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<lf&&a<lf)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 n=e.clientX-this.swipeLastX;this.swipeLastX=e.clientX,this.swipeGesture.move(e.timeStamp,n),e.preventDefault()});y(this,"handleSwipePointerUp",e=>{this.swipePointerId===null||e.pointerId!==this.swipePointerId||(this.swipeActive&&this.swipeGesture.end(),this.releaseSwipePointerCapture(e.pointerId),this.endSwipeTracking())});y(this,"handleSwipePointerCancel",e=>{this.swipePointerId===null||e.pointerId!==this.swipePointerId||(this.swipeActive&&this.swipeGesture.cancel(),this.releaseSwipePointerCapture(e.pointerId),this.endSwipeTracking())});y(this,"handleSwipeWindowBlur",()=>{this.swipePointerId!==null&&this.swipeActive&&this.swipeGesture.cancel(),this.swipePointerId!==null&&this.releaseSwipePointerCapture(this.swipePointerId),this.endSwipeTracking()});y(this,"handleSwipeClick",e=>{this.swipeShouldSuppressClick&&(this.swipeShouldSuppressClick=!1,e.preventDefault(),e.stopPropagation(),typeof e.stopImmediatePropagation=="function"&&e.stopImmediatePropagation())});y(this,"handleWindowPointerMove",e=>{this.lastPointerX=e.clientX,this.lastPointerY=e.clientY,this.updatePointerVelocity(e.clientX,e.clientY),this.syncDragTargetForLatestPointer(),this.ensureDragFrameLoop()});y(this,"handleWindowPointerUp",e=>{this.stopDragFrameLoop(),this.releasePointerCaptureForEvent(e.pointerId),this.dragController.drop(),this.clearMotionTracking(),this.detachDragListeners()});y(this,"handleWindowPointerCancel",e=>{this.stopDragFrameLoop(),this.releasePointerCaptureForEvent(e.pointerId),this.dragController.cancel(),this.clearMotionTracking(),this.detachDragListeners()});y(this,"handleWindowBlur",()=>{this.releaseActiveDragPointerCapture(),this.stopDragFrameLoop(),this.dragController.cancel(),this.clearMotionTracking(),this.detachDragListeners()});y(this,"runDragFrame",e=>{if(this.dragController.status==="idle"){this.dragFrame=0;return}const n=Math.max(0,e-this.lastDragFrameTime)/sg;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,n);this.scrollVelocityPxPerSec=n>ta?Math.abs(o)/n:0,Math.abs(o)>ta&&(this.animateNextRender=!1,this.layoutScroll.wheelPixels(Ae({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){this._layout=[...e],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)<ta||(this.animateNextRender=!1,this.syncScrollModel(),this.layoutScroll.scroll=xe({x:e}))}get scrollPosition(){return this._scrollPosition}focusArtifact(e){const n=Jr(this._layout),i=n.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+=n.nodes[o].width;this.scrollPosition=s,queueMicrotask(()=>{const o=this.querySelector(`.card-slot[data-layout-card-id="${ag(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("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("message",this.handleWindowMessage),(e=this.resizeObserver)==null||e.disconnect(),this.resizeObserver=null,this.clearWheelIdleSnap(),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,n){return new Lz({basis:Ae({x:fr,y:fr}),min:Ae({x:of,y:of}),viewport:Ae({x:e,y:n}),gap:Ae({x:ce,y:ce})})}syncScrollModel(){const e=Dc(this),i=Jr(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:og}))}emitScrollPositionChanged(e){this.dispatchEvent(new IO(e))}emitLayoutChanged(){this.dispatchEvent(new Sb([...this._layout]))}shiftWindow(e){this.clearWheelIdleSnap(),this.syncScrollModel(),this.animateNextRender=!0,this.layoutScroll.step(e)}applyHorizontalWheel(e){this.syncScrollModel();const n=this.layoutGrid;if(!n)return;this.animateNextRender=!1;const i=n.toUnits(Ae({x:e}));this.layoutScroll.wheel(xe({x:i.x??0}))}scheduleWheelIdleSnap(){this.clearWheelIdleSnap(),this.wheelIdleSnapTimer=setTimeout(()=>{this.wheelIdleSnapTimer=null,this.animateNextRender=!0,this.layoutScroll.snap()},$O)}clearWheelIdleSnap(){this.wheelIdleSnapTimer!==null&&(clearTimeout(this.wheelIdleSnapTimer),this.wheelIdleSnapTimer=null)}findViewspanContainingNode(e){const n=this.layoutScroll.viewspans,i=this._scrollPosition;let s=null,o=Number.POSITIVE_INFINITY;for(const a of n)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 n=this.querySelectorAll("iframe.artifact-frame");for(const i of n)if(i.contentWindow===e)return i;return null}isTrustedArtifactFrameMessage(e,n){if(e.origin==="null")return!0;const i=this.getArtifactFrameOrigin(n);return i===null||e.origin===i}getArtifactFrameOrigin(e){const n=e.getAttribute("src")??e.src;if(!n)return null;try{return new URL(n,window.location.href).origin}catch{return null}}beginResize(e,n){const i=n.getAttribute("data-resize-handle");if(!i)return;const s=this._layout.find(a=>a.type==="card"&&a.id===i);if(!s)return;const o=Ou(typeof s.width=="number"?s.width:ft);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):Qf(this.dragState.projectedLayout)}applyResizeOverride(e){const n=this.resizeState;if(!n)return e;const i=e.findIndex(a=>a.type==="card"&&a.id===n.cardId);if(i===-1)return e;const s=e[i];if(!s||s.type!=="card"||s.width===n.currentWidth)return e;const o=[...e];return o[i]={...s,width:n.currentWidth},o}getGridSlotStyle(e){return`grid-column: ${e.col} / span ${e.width}; grid-row: ${e.row} / span ${e.height};`}findContainingBlock(e){let n=e.parentElement;for(;n;){const i=getComputedStyle(n);if(i.transform!=="none"||i.perspective!=="none"||i.filter!=="none")return n;const s=i.willChange;if(s.includes("transform")||s.includes("perspective")||s.includes("filter"))return n;const o=i.contain;if(o.includes("layout")||o.includes("paint")||o.includes("strict"))return n;n=n.parentElement}return document.documentElement}getDraggedSlotStyle(e){const n=this.currentDragPreviewSize??{width:e.size.x??0,height:e.size.y??0};return["position: fixed;",`width: ${n.width}px;`,`height: ${n.height}px;`,"pointer-events: none;","z-index: 10;"].join(" ")}writeDraggedSlotPosition(e,n){(!this.draggedSlotContainingBlock||!this.draggedSlotContainingBlock.isConnected||!this.draggedSlotContainingBlock.contains(e))&&(this.draggedSlotContainingBlock=this.findContainingBlock(e));const i=this.draggedSlotContainingBlock.getBoundingClientRect(),s=n.pointer.x??0,o=n.pointer.y??0,a=n.grabOffset.x??0,c=n.grabOffset.y??0,u=this.currentDragPreviewSize??{width:n.size.x??0,height:n.size.y??0},h=n.size.x??0,p=n.size.y??0,m=h>0?a*(u.width/h):a,g=p>0?c*(u.height/p):c;e.style.left=`${s-m-i.left}px`,e.style.top=`${o-g-i.top}px`,e.style.width=`${u.width}px`,e.style.height=`${u.height}px`}renderSlot(e,n){var o,a;if(e.kind==="placeholder")return e.placement?H`
|
|
191
|
-
<div
|
|
192
|
-
class="card-slot card-placeholder"
|
|
193
|
-
data-layout-placeholder-for=${(n==null?void 0:n.nodeId)??""}
|
|
194
|
-
data-layout-placeholder-ghost="false"
|
|
195
|
-
data-layout-source-stack=${e.sourceStackId??""}
|
|
196
|
-
style=${this.getGridSlotStyle(e.placement)}
|
|
197
|
-
></div>
|
|
198
|
-
`:null;const i=e.card;if(!i)return null;const s=e.isDragged&&n?this.getDraggedSlotStyle(n):e.placement?this.getGridSlotStyle(e.placement):"";return H`
|
|
199
|
-
<div
|
|
200
|
-
class="card-slot"
|
|
201
|
-
data-layout-card-id=${i.artifactID}
|
|
202
|
-
data-layout-node-id=${i.id}
|
|
203
|
-
data-layout-drag-source=${String(e.isDragged)}
|
|
204
|
-
layout-cols=${String(((o=e.placement)==null?void 0:o.width)??"")}
|
|
205
|
-
layout-rows=${String(((a=e.placement)==null?void 0:a.height)??"")}
|
|
206
|
-
style=${s}
|
|
207
|
-
>
|
|
208
|
-
<div class="card-content-mount" data-mount-for=${i.id}></div>
|
|
209
|
-
${e.isTopLevelCard&&!e.isDragged?H`<div
|
|
210
|
-
class="resize-handle"
|
|
211
|
-
data-resize-handle=${i.id}
|
|
212
|
-
data-test-resize-handle=${i.id}
|
|
213
|
-
></div>`:null}
|
|
214
|
-
</div>
|
|
215
|
-
`}renderNode(e,n){return H`
|
|
216
|
-
<div
|
|
217
|
-
class=${e.kind==="ghost"?"drag-source-node":"node"}
|
|
218
|
-
layout-node=${String(e.layoutIndex??"")}
|
|
219
|
-
data-layout-node-id=${e.nodeId}
|
|
220
|
-
data-layout-placeholder=${String(e.kind==="visible"&&e.isPlaceholder)}
|
|
221
|
-
layout-node-cols=${String(e.widthUnits)}
|
|
222
|
-
?data-foreground=${e.kind==="visible"&&e.isForeground}
|
|
223
|
-
style=${e.kind==="visible"?`width: ${e.widthPx}px; --card-width-px: ${e.widthPx};`:""}
|
|
224
|
-
>
|
|
225
|
-
<div class="node-inner" style=${`grid-template-columns: repeat(${e.widthUnits}, var(--layout-unit-x));`}>
|
|
226
|
-
${Kf(e.slots,i=>i.key,i=>this.renderSlot(i,n))}
|
|
227
|
-
</div>
|
|
228
|
-
</div>
|
|
229
|
-
`}render(){var Y;const e=Dc(this),n=this.createGrid(e.width,e.height);this.layoutGrid=n;const i=this.getVisibleLayout(),s=this.dragController.status==="active",o=Jr(i),a=o.nodes.map(V=>V.width),c=`${e.width}x${e.height}:${a.join(",")}`;!s&&c!==this.scrollModelKey&&(this.scrollModelKey=c,this.layoutScroll.rebuild({grid:n,nodeWidths:a.map(V=>xe({x:V})),snap:og}),this._scrollPosition=this.layoutScroll.scroll.x??this._scrollPosition);const u=CO(this._layout),h=n.unit.x??fr,p=n.unit.y??fr,m=s?this.dragTrackOffsetXPx:0,g=(this.layoutScroll.translate.x??0)+m,S=lg(o.nodes.length,n,e.height),_=this.animateNextRender&&!s,I=[`transform: translate(${g}px, ${S}px);`,`transition-duration: ${_?fA: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",`${ce}px`);const P=this.dragState,R=new Set;{let V=g;for(let le=0;le<o.nodes.length;le+=1){const yt=n.toPixels(xe({x:o.nodes[le].width})).x??0,Or=V+yt;V>=-1&&Or<=e.width+1&&R.add(le),V=Or+ce}}const W=V=>R.has(V),M=EO({baseLayout:this._layout,visibleLayout:i,resolved:o,cardsByID:u,grid:n,dragState:this.dragState,isForeground:W}),U=ig(this.dragState);if(U?this.setAttribute("data-test-drop-intent",U):this.removeAttribute("data-test-drop-intent"),this.dragState){let V=null;for(const le of o.nodes){for(const yt of le.cards)if(yt.id===this.dragState.nodeId){V={width:n.toPixels(xe({x:yt.width})).x??0,height:n.toPixels(xe({y:yt.height})).y??0};break}if(V)break}this.currentDragPreviewSize=V??{width:this.dragState.size.x??0,height:this.dragState.size.y??0}}else this.currentDragPreviewSize=null;Fe(H`
|
|
230
|
-
<div class="track" style=${I}>
|
|
231
|
-
${Kf(M,V=>V.key,V=>this.renderNode(V,P))}
|
|
232
|
-
</div>
|
|
233
|
-
`,this),this.syncCardElements(u,P?((Y=u.get(P.nodeId))==null?void 0:Y.artifactID)??null:null),this.syncDraggedSlotElement(P)}syncCardElements(e,n){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===n)}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 n=this.clampPointerToViewport(this.lastPointerX,this.lastPointerY,e);(n.x!==this.lastPointerX||n.y!==this.lastPointerY)&&this.syncDragTarget(n.x,n.y,e)}syncDragTarget(e,n,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:Ae({x:e,y:n}),viewport:{left:i.left,top:i.top,width:i.width,height:i.height},geometry:a,effectiveVelocity:Math.max(this.pointerVelocityPxPerSec,this.scrollVelocityPxPerSec)})}resetMotionTracking(e,n){this.pointerVelocityPxPerSec=0,this.scrollVelocityPxPerSec=0,this.motionSampleTime=performance.now(),this.motionSampleX=e,this.motionSampleY=n}clearMotionTracking(){this.pointerVelocityPxPerSec=0,this.scrollVelocityPxPerSec=0,this.motionSampleTime=0}updatePointerVelocity(e,n){this.samplePointerVelocityAt(performance.now(),e,n)}samplePointerVelocityAt(e,n,i){if(this.motionSampleTime===0){this.motionSampleTime=e,this.motionSampleX=n,this.motionSampleY=i,this.pointerVelocityPxPerSec=0;return}const s=e-this.motionSampleTime;if(s<100)return;const o=n-this.motionSampleX;this.pointerVelocityPxPerSec=Math.abs(o)/s*sg,this.motionSampleTime=e,this.motionSampleX=n,this.motionSampleY=i}clampPointerToViewport(e,n,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,n))}}getDragEdgeScrollDeltaPixels(e,n,i){var u;const s=n.left+Yo,o=n.left+n.width-Yo,a=((u=this.layoutGrid)==null?void 0:u.unit.x)??fr,c=mA*a;if(e<s){const h=Math.max(0,Math.min(1,(s-e)/Yo));return-(c*h**af)*i}if(e>o){const h=Math.max(0,Math.min(1,(e-o)/Yo));return c*h**af*i}return 0}measureLayoutGeometry(e,n=0){const i=this.layoutGrid;if(!i)return[];const s=Jr(e),o=new Map(s.nodes.map(S=>[S.id,S.width])),a=i.toPixels(xe({y:ct})).y??Ma,c=Dc(this),u=(this.layoutScroll.translate.x??0)+n,h=lg(s.nodes.length,i,c.height),p=c.offsetY+h,m=[];let g=u;for(const S of e){const _=o.get(S.id)??ft,I=i.toPixels(xe({x:_})).x??_n,P={left:g,top:p,width:I,height:a};m.push({id:S.id,rect:P}),g+=I+ce}return m}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 n;return(n=this.draggedSlotElement)!=null&&n.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="${ag(e)}"][data-layout-drag-source="true"]`),this.draggedSlotElement)}syncDraggedSlotElement(e){if(!e||this.dragController.status!=="active"){this.draggedSlotElement=null;return}const n=this.getCachedDraggedSlotElement(e.nodeId);n&&this.writeDraggedSlotPosition(n,e)}shouldApplyTrackOffset(e,n){if(n)return!0;for(const i of e){if(i.type!=="stack")continue;if(i.children.some(o=>o.type==="drop-target")&&n!==i.id)return!0}return!1}computeDragTrackOffset(e,n,i,s,o,a){if(!e)return a;const c=s?o??this.getStableAnchorCardId(e,n,i):this.getStableAnchorNodeId(e,n,i);if(!c)return a;const u=s?ug(e,c,this.layoutGrid):hg(e,c,this.layoutGrid),h=s?ug(n,c,this.layoutGrid):hg(n,c,this.layoutGrid);return u===null||h===null?a:a+(u-h)}getStableAnchorCardId(e,n,i){const s=cg(e),o=new Set(cg(n));for(const a of s)if(a!==i&&o.has(a))return a;return null}getStableAnchorNodeId(e,n,i){const s=new Set(n.map(o=>o.id));for(const o of e)if(o.id!==i&&s.has(o.id))return o.id;return null}getStackChildAnchorCardId(e,n){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!==n);return(s==null?void 0:s.id)??null}}function CO(r){const t=new Map;for(const e of r){if(e.type==="card"){t.set(e.id,e);continue}for(const n of e.children)if(n.type==="card")t.set(n.id,n);else for(const i of n.children)t.set(i.id,i)}return t}function RO(r){for(const t of r)if(t.type==="drop-target"||t.type==="stack"&&t.children.some(e=>e.type==="drop-target"))return t.id;return null}function PO(r,t){const e=r.findIndex(n=>n.type==="card"&&n.id===t);if(e!==-1)return{topLevelIndex:e};for(let n=0;n<r.length;n+=1){const i=r[n];if(!(!i||i.type!=="stack")&&i.children.some(s=>s.type==="card"&&s.id===t))return{topLevelIndex:n,sourceStackId:i.id}}return null}function cg(r){const t=[];for(const e of r){if(e.type==="card"){t.push(e.id);continue}if(e.type==="stack"){const n=e.children.find(i=>i.type==="card");n&&t.push(n.id)}}return t}function ug(r,t,e){if(!e)return null;const n=Jr(r),i=new Map(n.nodes.map(o=>[o.id,o.width]));let s=0;for(const o of r){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)??ft,c=e.toPixels(xe({x:a})).x??_n;s+=c+ce}return null}function hg(r,t,e){if(!e)return null;const n=Jr(r),i=new Map(n.nodes.map(o=>[o.id,o.width]));let s=0;for(const o of r){if(o.id===t)return s;const a=i.get(o.id)??ft,c=e.toPixels(xe({x:a})).x??_n;s+=c+ce}return null}customElements.get("layout-view")||customElements.define("layout-view",TO);class DO extends HTMLElement{constructor(){super(...arguments);y(this,"screenManager",Ft.resolve("ScreenManager"));y(this,"boundModel",null);y(this,"cardEls",new Map);y(this,"handleActiveScreenChanged",()=>{this.rebindModel(),this.render()});y(this,"handleModelChange",()=>{this.render()});y(this,"handleCloseArtifact",e=>{e instanceof fb&&this.screenManager.activeScreen&&this.screenManager.activeScreen.removeArtifact(e.artifactID)});y(this,"handleScrollPositionChanged",e=>{const n=e;typeof n.scrollPosition=="number"&&Number.isFinite(n.scrollPosition)&&this.screenManager.activeScreen&&this.screenManager.activeScreen.setScrollPosition(n.scrollPosition)});y(this,"handleLayoutChanged",e=>{e instanceof Sb&&this.screenManager.activeScreen&&this.screenManager.activeScreen.setLayout(e.layout)});y(this,"handleServerEvent",e=>{const n=e.event;if(n.type!=="artifact-focus"||!this.boundModel||n.screenID!==this.boundModel.id)return;const i=this.querySelector("layout-view");i&&i.focusArtifact(n.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 n=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),n.set(i.id,s)}for(const[i,s]of this.cardEls)n.has(i)||(s.remove(),this.cardEls.delete(i));return n}disposeCardElements(){for(const e of this.cardEls.values())e.remove();this.cardEls.clear()}render(){const e=this.screenManager.activeScreen,n=(e==null?void 0:e.layout)??[],i=this.buildCards(e);if(n.length===0){Fe(H``,this);return}Fe(H`
|
|
234
|
-
<layout-view
|
|
235
|
-
.layout=${n}
|
|
236
|
-
.cards=${i}
|
|
237
|
-
.scrollPosition=${(e==null?void 0:e.scrollPosition)??0}
|
|
238
|
-
@scroll=${this.handleScrollPositionChanged}
|
|
239
|
-
@layout-change=${this.handleLayoutChanged}
|
|
240
|
-
@close-artifact=${this.handleCloseArtifact}
|
|
241
|
-
></layout-view>
|
|
242
|
-
`,this)}}customElements.define("screen-view",DO);function ja(r){return typeof r=="object"&&r!==null}const Lc=new WeakMap,dg=Object.prototype.hasOwnProperty,LO=(()=>{const r=new Set;let t=HTMLElement.prototype;for(;t;){for(const e of Object.getOwnPropertyNames(t))r.add(e);if(t===Node.prototype)break;t=Object.getPrototypeOf(t)}return r})();function zO(r,t){if(ja(r))return t===null?void 0:r.parse(t);if(r===Boolean)return t!==null;if(t!==null)return r===Number?Number(t):t}function OO(r,t){return ja(r)?t==null?null:r.serialize(t):r===Boolean?t?"":null:t==null?null:String(t)}var so,Uu,vn,ut,Mt,yi,yn,bi,Se,ei,_b,kb,Eb,xb,ka;const Yr=class Yr extends HTMLElement{constructor(){var i;super();w(this,Se);w(this,vn,new Map);w(this,ut,new Map);w(this,Mt,new Map);w(this,yi,!1);w(this,yn,!1);w(this,bi,!1);const e=f(i=Yr,so,Uu).call(i,this.constructor),n=this;for(const s of e.properties)dg.call(n,s)&&(l(this,Mt).set(s,n[s]),delete n[s])}static get observedAttributes(){var e;return f(e=Yr,so,Uu).call(e,this).observedAttributes}connected(){}disconnected(){}changed(e){}connectedCallback(){if(f(this,Se,xb).call(this),!l(this,yn))for(const e of f(this,Se,ei).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,Se,ka).call(this)}disconnectedCallback(){this.dispatchEvent(new Event("reactive:disconnect")),this.disconnected()}attributeChangedCallback(e,n,i){if(n===i)return;const s=f(this,Se,ei).call(this).byAttr.get(e);s&&(l(this,Mt).has(s.property)||(this[s.property]=zO(s.type,i)))}};so=new WeakSet,Uu=function(e){const n=Lc.get(e);if(n)return n;const i=[...e.properties??[]],s=e.attributes??{},o=new Map,a=new Map;for(const u of i)if(LO.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(ja(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 m={attribute:u,property:p,type:h.type};o.set(u,m),a.set(p,m)}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,vn).get(u)},set(p){f(this,Se,_b).call(this,u,p)}})}const c={properties:i,observedAttributes:Object.keys(s),byAttr:o,byProp:a};return Lc.set(e,c),c},vn=new WeakMap,ut=new WeakMap,Mt=new WeakMap,yi=new WeakMap,yn=new WeakMap,bi=new WeakMap,Se=new WeakSet,ei=function(){return Lc.get(this.constructor)},_b=function(e,n){if(!l(this,bi)&&l(this,Mt).has(e))return;const i=l(this,vn).get(e);f(this,Se,kb).call(this,e,i,n)||(l(this,ut).has(e)||l(this,ut).set(e,i),l(this,vn).set(e,n),l(this,Mt).delete(e),f(this,Se,Eb).call(this,e,n),this.isConnected&&f(this,Se,ka).call(this))},kb=function(e,n,i){if(Object.is(n,i))return!0;const s=f(this,Se,ei).call(this).byProp.get(e);if(!s||!ja(s.type))return!1;const o=n==null,a=i==null;if(o||a)return o&&a;try{return s.type.serialize(n)===s.type.serialize(i)}catch{return!1}},Eb=function(e,n){const i=f(this,Se,ei).call(this).byProp.get(e);if(!i)return;const{attribute:s,type:o}=i;if(o===Boolean){const c=this.hasAttribute(s);n&&!c?this.setAttribute(s,""):!n&&c&&this.removeAttribute(s);return}const a=OO(o,n);if(a===null){this.hasAttribute(s)&&this.removeAttribute(s);return}this.getAttribute(s)!==a&&this.setAttribute(s,a)},xb=function(){const e=this,n=f(this,Se,ei).call(this);for(const i of n.properties){if(!dg.call(e,i))continue;const s=e[i];delete e[i],!(l(this,Mt).has(i)||l(this,vn).has(i))&&(e[i]=s)}x(this,bi,!0);try{for(const[i,s]of l(this,Mt))e[i]=s;l(this,Mt).clear()}finally{x(this,bi,!1)}},ka=function(){l(this,yi)||!this.isConnected||l(this,yn)&&l(this,ut).size===0||(x(this,yi,!0),queueMicrotask(()=>{if(x(this,yi,!1),!this.isConnected||l(this,yn)&&l(this,ut).size===0)return;const e=new Map(l(this,ut));l(this,ut).clear(),x(this,yn,!0);try{this.changed(e)}catch(n){console.error(n)}this.isConnected&&l(this,ut).size>0&&f(this,Se,ka).call(this)}))},w(Yr,so),y(Yr,"properties"),y(Yr,"attributes");let As=Yr;var pe,nr,kr,wi,Si,ir,oo,Ee,_i,Nt,Z,Ab,ao,lo,co,uo,Fu,Wu,Hu,$b,Ib,Tb,Cb,tl,rl,nl,il,Zu,Rb,Ea,sl,xa,ol,Pb,Db,Lb,zb,Ob,at;class MO extends As{constructor(){super(...arguments);w(this,Z);w(this,pe,Ft.resolve("ScreenManager"));w(this,nr,Ft.resolve("ServerManager"));w(this,kr,null);w(this,wi,new DisposableStack);w(this,Si,ya());w(this,ir,ya());w(this,oo,ya());w(this,Ee,{kind:"none"});w(this,_i,!1);w(this,Nt,[]);w(this,ao,()=>{f(this,Z,Fu).call(this),x(this,Ee,{kind:"none"}),l(this,at).call(this)});w(this,lo,()=>{l(this,at).call(this)});w(this,co,()=>{l(this,at).call(this)});w(this,uo,()=>{l(this,at).call(this)});w(this,tl,()=>{var i,s;if(l(this,Ee).kind==="picker"){f(this,Z,xa).call(this);return}x(this,Nt,f(this,Z,Rb).call(this));const e=((i=l(this,pe).activeScreen)==null?void 0:i.id)??null,n=e&&l(this,Nt).some(o=>o.screenID===e)?e:((s=l(this,Nt)[0])==null?void 0:s.screenID)??null;x(this,Ee,{kind:"picker",filter:"",highlightedID:n}),l(this,at).call(this),queueMicrotask(()=>{var o;(o=l(this,oo).value)==null||o.focus()})});w(this,rl,e=>{var u;const n=l(this,Ee);if(n.kind!=="picker")return;const i=e.target;if(!(i instanceof HTMLInputElement))return;const s=i.value,o=f(this,Z,Ea).call(this,l(this,Nt),s),c=n.highlightedID!==null&&o.some(h=>h.screenID===n.highlightedID)?n.highlightedID:((u=o[0])==null?void 0:u.screenID)??null;x(this,Ee,{kind:"picker",filter:s,highlightedID:c}),l(this,at).call(this)});w(this,nl,e=>{var s;const n=l(this,Ee);if(n.kind!=="picker")return;if(e.key==="Escape"){e.preventDefault(),f(this,Z,xa).call(this),(s=l(this,Si).value)==null||s.focus();return}const i=f(this,Z,Ea).call(this,l(this,Nt),n.filter);if(e.key==="ArrowDown"||e.key==="ArrowUp"){if(e.preventDefault(),i.length===0)return;const o=i.findIndex(u=>u.screenID===n.highlightedID),a=e.key==="ArrowDown"?1:-1,c=o<0?0:Math.max(0,Math.min(i.length-1,o+a));x(this,Ee,{kind:"picker",filter:n.filter,highlightedID:i[c].screenID}),l(this,at).call(this);return}if(e.key==="Enter"){e.preventDefault();const o=i.find(a=>a.screenID===n.highlightedID);o&&f(this,Z,Zu).call(this,o)}});w(this,il,e=>{f(this,Z,Zu).call(this,e)});w(this,sl,e=>{l(this,Ee).kind==="picker"&&e.target===l(this,ir).value&&(x(this,Ee,{kind:"none"}),l(this,at).call(this))});w(this,ol,async()=>{if(l(this,_i))return;const e=f(this,Z,Pb).call(this);if(e){x(this,_i,!0);try{const n=await e.createScreen(NO(new Date));l(this,pe).addTab(e.url,n.id),l(this,pe).setActive(e.url,n.id)}catch{}finally{x(this,_i,!1)}}});w(this,at,()=>{const e=f(this,Z,Tb).call(this);Fe(H`
|
|
243
|
-
${f(this,Z,Db).call(this)}
|
|
244
|
-
<div class="pills" role="group" aria-label="Open tabs">
|
|
245
|
-
${e.map(n=>f(this,Z,Lb).call(this,n))}
|
|
246
|
-
</div>
|
|
247
|
-
${f(this,Z,zb).call(this)}
|
|
248
|
-
`,this),l(this,ir).value&&(l(this,ir).value.anchor=l(this,Si).value??null)})}connected(){l(this,pe).addEventListener("active-screen-changed",l(this,ao)),l(this,pe).addEventListener("tabs-changed",l(this,lo)),l(this,nr).addEventListener("screens-changed",l(this,co)),f(this,Z,Fu).call(this),l(this,at).call(this),f(this,Z,Ab).call(this),l(this,wi).defer(()=>{l(this,pe).removeEventListener("active-screen-changed",l(this,ao)),l(this,pe).removeEventListener("tabs-changed",l(this,lo)),l(this,nr).removeEventListener("screens-changed",l(this,co)),f(this,Z,Wu).call(this)})}disconnected(){l(this,wi).dispose(),x(this,wi,new DisposableStack)}}pe=new WeakMap,nr=new WeakMap,kr=new WeakMap,wi=new WeakMap,Si=new WeakMap,ir=new WeakMap,oo=new WeakMap,Ee=new WeakMap,_i=new WeakMap,Nt=new WeakMap,Z=new WeakSet,Ab=async function(){const e=await Rm(this);this.setAttribute("tone",e)},ao=new WeakMap,lo=new WeakMap,co=new WeakMap,uo=new WeakMap,Fu=function(){var n;const e=l(this,pe).activeScreen;l(this,kr)!==e&&(f(this,Z,Wu).call(this),x(this,kr,e),(n=l(this,kr))==null||n.addEventListener("change",l(this,uo)))},Wu=function(){var e;(e=l(this,kr))==null||e.removeEventListener("change",l(this,uo)),x(this,kr,null)},Hu=function(e,n){l(this,pe).setActive(e,n)},$b=function(e,n,i){i.stopPropagation();const s=l(this,pe).getTabs(e),o=f(this,Z,Cb).call(this,s,n),a=l(this,pe).activeScreen,c=(a==null?void 0:a.id)===n&&a.server.url===e;l(this,pe).removeTab(e,n),c&&(o?l(this,pe).setActive(e,o):l(this,pe).clearActive())},Ib=function(e,n,i){const s=l(this,pe).activeScreen;if((s==null?void 0:s.id)===n){s.rename(i.value);return}const o=l(this,nr).servers.get(e),a=o==null?void 0:o.screens.get(n);!o||!a||o.client.screens.update({screenID:n,name:i.value}).catch(()=>{})},Tb=function(){const e=l(this,pe).activeScreen,n=[];for(const i of l(this,nr).servers.values())for(const s of l(this,pe).getTabs(i.url)){const o=i.screens.get(s);o&&n.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 n},Cb=function(e,n){const i=e.indexOf(n);if(i<0)return null;const s=e.filter(a=>a!==n);if(s.length===0)return null;const o=Math.max(0,i-1);return s[o]??null},tl=new WeakMap,rl=new WeakMap,nl=new WeakMap,il=new WeakMap,Zu=function(e){l(this,pe).addTab(e.serverURL,e.screenID),l(this,pe).setActive(e.serverURL,e.screenID),f(this,Z,xa).call(this)},Rb=function(){const e=[];for(const n of l(this,nr).servers.values())for(const i of n.screens.values())e.push({serverURL:n.url,screenID:i.id,name:i.name});return e},Ea=function(e,n){const i=n.trim().toLowerCase();return i.length===0?e:e.filter(s=>s.name.toLowerCase().includes(i))},sl=new WeakMap,xa=function(){l(this,Ee).kind==="picker"&&(l(this,ir).value&&(l(this,ir).value.open=!1),x(this,Ee,{kind:"none"}),l(this,at).call(this))},ol=new WeakMap,Pb=function(){for(const e of l(this,nr).servers.values())return e;return null},Db=function(){return H`
|
|
249
|
-
<segmented-control variant="glass" role="group" aria-label="Screens">
|
|
250
|
-
<button
|
|
251
|
-
type="button"
|
|
252
|
-
?icon-only=${!0}
|
|
253
|
-
aria-label="Choose screen"
|
|
254
|
-
@click=${l(this,tl)}
|
|
255
|
-
${ba(l(this,Si))}
|
|
256
|
-
>
|
|
257
|
-
${oz({size:16,weight:"regular"})}
|
|
258
|
-
</button>
|
|
259
|
-
<button
|
|
260
|
-
type="button"
|
|
261
|
-
?icon-only=${!0}
|
|
262
|
-
aria-label="New screen"
|
|
263
|
-
@click=${l(this,ol)}
|
|
264
|
-
>
|
|
265
|
-
${az({size:16,weight:"regular"})}
|
|
266
|
-
</button>
|
|
267
|
-
</segmented-control>
|
|
268
|
-
`},Lb=function(e){return H`
|
|
269
|
-
<span class="tab" ?data-active=${e.isActive}>
|
|
270
|
-
<button
|
|
271
|
-
type="button"
|
|
272
|
-
variant="glass"
|
|
273
|
-
class="screen-name tab-body"
|
|
274
|
-
aria-pressed=${e.isActive?"true":"false"}
|
|
275
|
-
aria-current=${e.isActive?"page":ae}
|
|
276
|
-
aria-label=${e.isActive?`Current tab: ${e.name}`:`Switch to ${e.name}`}
|
|
277
|
-
@mousedown=${n=>{n.button===0&&f(this,Z,Hu).call(this,e.serverURL,e.screenID)}}
|
|
278
|
-
@click=${()=>f(this,Z,Hu).call(this,e.serverURL,e.screenID)}
|
|
279
|
-
>
|
|
280
|
-
<span class="tab-leading">
|
|
281
|
-
${sz({weight:"bold"})}
|
|
282
|
-
</span>
|
|
283
|
-
<editable-text
|
|
284
|
-
class="tab-name"
|
|
285
|
-
.value=${e.name}
|
|
286
|
-
@rename=${n=>f(this,Z,Ib).call(this,e.serverURL,e.screenID,n)}
|
|
287
|
-
></editable-text>
|
|
288
|
-
</button>
|
|
289
|
-
<button
|
|
290
|
-
type="button"
|
|
291
|
-
variant="ghost"
|
|
292
|
-
size="xs"
|
|
293
|
-
icon-only
|
|
294
|
-
class="tab-close"
|
|
295
|
-
aria-label=${`Close ${e.name}`}
|
|
296
|
-
@click=${n=>f(this,Z,$b).call(this,e.serverURL,e.screenID,n)}
|
|
297
|
-
>
|
|
298
|
-
${jh({weight:"bold"})}
|
|
299
|
-
</button>
|
|
300
|
-
</span>
|
|
301
|
-
`},zb=function(){var o;const e=l(this,Ee).kind==="picker"?l(this,Ee).filter:"",n=l(this,Ee).kind==="picker"?l(this,Ee).highlightedID:null,i=((o=l(this,pe).activeScreen)==null?void 0:o.id)??null,s=f(this,Z,Ea).call(this,l(this,Nt),e);return H`
|
|
302
|
-
<ui-popover
|
|
303
|
-
class="picker-popover"
|
|
304
|
-
material="glass-frosted"
|
|
305
|
-
?open=${l(this,Ee).kind==="picker"}
|
|
306
|
-
@close=${l(this,sl)}
|
|
307
|
-
@keydown=${l(this,nl)}
|
|
308
|
-
${ba(l(this,ir))}
|
|
309
|
-
>
|
|
310
|
-
<div class="picker">
|
|
311
|
-
<input
|
|
312
|
-
type="text"
|
|
313
|
-
class="picker-filter"
|
|
314
|
-
placeholder="Filter screens"
|
|
315
|
-
aria-label="Filter screens"
|
|
316
|
-
.value=${e}
|
|
317
|
-
@input=${l(this,rl)}
|
|
318
|
-
${ba(l(this,oo))}
|
|
319
|
-
/>
|
|
320
|
-
${s.length===0?H`<p class="picker-empty">
|
|
321
|
-
${l(this,Nt).length===0?"No screens":"No matches"}
|
|
322
|
-
</p>`:f(this,Z,Ob).call(this,s,n,i)}
|
|
323
|
-
</div>
|
|
324
|
-
</ui-popover>
|
|
325
|
-
`},Ob=function(e,n,i){return H`
|
|
326
|
-
<ul class="picker-list" role="listbox">
|
|
327
|
-
<li class="picker-section-label" role="presentation">Recent</li>
|
|
328
|
-
${e.map(s=>{const o=s.screenID===i;return H`
|
|
329
|
-
<li
|
|
330
|
-
class="picker-row"
|
|
331
|
-
role="option"
|
|
332
|
-
aria-selected=${s.screenID===n}
|
|
333
|
-
aria-current=${o?"true":ae}
|
|
334
|
-
?data-highlighted=${s.screenID===n}
|
|
335
|
-
?data-active=${o}
|
|
336
|
-
@click=${()=>l(this,il).call(this,s)}
|
|
337
|
-
>
|
|
338
|
-
<span class="picker-name">${s.name}</span>
|
|
339
|
-
</li>
|
|
340
|
-
`})}
|
|
341
|
-
</ul>
|
|
342
|
-
`},at=new WeakMap;customElements.define("screen-select",MO);function NO(r){const t=r.toLocaleDateString("en-US",{month:"long",day:"numeric",year:"numeric"}),e=12,n=r.getHours(),i=n%e===0?e:n%e,s=r.getMinutes().toString().padStart(2,"0"),o=n>=e?"pm":"am";return`${t} at ${i}:${s}${o}`}const zc=6e4;var Er,bn,ki,Aa;class UO extends HTMLElement{constructor(){super(...arguments);w(this,ki);w(this,Er,null);w(this,bn,null)}connectedCallback(){this.hasAttribute("material")||this.setAttribute("material","glass"),f(this,ki,Aa).call(this);const e=zc-Date.now()%zc;x(this,Er,window.setTimeout(()=>{x(this,Er,null),f(this,ki,Aa).call(this),x(this,bn,window.setInterval(()=>f(this,ki,Aa).call(this),zc))},e))}disconnectedCallback(){l(this,Er)!==null&&clearTimeout(l(this,Er)),l(this,bn)!==null&&clearInterval(l(this,bn)),x(this,Er,null),x(this,bn,null)}}Er=new WeakMap,bn=new WeakMap,ki=new WeakSet,Aa=function(){const e=new Date,n=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);Fe(H`<span class="date">${n}</span><span class="time">${i}</span>`,this)};customElements.get("menu-bar-clock")||customElements.define("menu-bar-clock",UO);function FO(r,t){let e=null;const n=()=>t((e==null?void 0:e.messages)??[]),i=()=>{var a;const o=((a=r.activeServer)==null?void 0:a.acpClient)??null;o!==e&&(e==null||e.removeEventListener("change",n),e=o,e&&(e.addEventListener("change",n),e.connect().catch(c=>{console.error("ACPClient.connect() failed",c)})),n())};r.addEventListener("change",i),i();const s=()=>{r.removeEventListener("change",i),e==null||e.removeEventListener("change",n),e=null};return{dispose:s,[Symbol.dispose](){s()}}}/*! @license DOMPurify 3.3.3 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.3.3/LICENSE */const{entries:Mb,setPrototypeOf:pg,isFrozen:WO,getPrototypeOf:HO,getOwnPropertyDescriptor:ZO}=Object;let{freeze:Ge,seal:gt,create:$a}=Object,{apply:Bu,construct:ju}=typeof Reflect<"u"&&Reflect;Ge||(Ge=function(t){return t});gt||(gt=function(t){return t});Bu||(Bu=function(t,e){for(var n=arguments.length,i=new Array(n>2?n-2:0),s=2;s<n;s++)i[s-2]=arguments[s];return t.apply(e,i)});ju||(ju=function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),i=1;i<e;i++)n[i-1]=arguments[i];return new t(...n)});const ra=qe(Array.prototype.forEach),BO=qe(Array.prototype.lastIndexOf),fg=qe(Array.prototype.pop),Ki=qe(Array.prototype.push),jO=qe(Array.prototype.splice),Ia=qe(String.prototype.toLowerCase),Oc=qe(String.prototype.toString),Mc=qe(String.prototype.match),Ji=qe(String.prototype.replace),VO=qe(String.prototype.indexOf),GO=qe(String.prototype.trim),ot=qe(Object.prototype.hasOwnProperty),We=qe(RegExp.prototype.test),Qi=qO(TypeError);function qe(r){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var e=arguments.length,n=new Array(e>1?e-1:0),i=1;i<e;i++)n[i-1]=arguments[i];return Bu(r,t,n)}}function qO(r){return function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return ju(r,e)}}function G(r,t){let e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Ia;pg&&pg(r,null);let n=t.length;for(;n--;){let i=t[n];if(typeof i=="string"){const s=e(i);s!==i&&(WO(t)||(t[n]=s),i=s)}r[i]=!0}return r}function YO(r){for(let t=0;t<r.length;t++)ot(r,t)||(r[t]=null);return r}function Ct(r){const t=$a(null);for(const[e,n]of Mb(r))ot(r,e)&&(Array.isArray(n)?t[e]=YO(n):n&&typeof n=="object"&&n.constructor===Object?t[e]=Ct(n):t[e]=n);return t}function es(r,t){for(;r!==null;){const n=ZO(r,t);if(n){if(n.get)return qe(n.get);if(typeof n.value=="function")return qe(n.value)}r=HO(r)}function e(){return null}return e}const gg=Ge(["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"]),Nc=Ge(["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"]),Uc=Ge(["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=Ge(["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"]),Fc=Ge(["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=Ge(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),mg=Ge(["#text"]),vg=Ge(["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"]),Wc=Ge(["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"]),yg=Ge(["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"]),na=Ge(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),JO=gt(/\{\{[\w\W]*|[\w\W]*\}\}/gm),QO=gt(/<%[\w\W]*|[\w\W]*%>/gm),e2=gt(/\$\{[\w\W]*/gm),t2=gt(/^data-[\-\w.\u00B7-\uFFFF]+$/),r2=gt(/^aria-[\-\w]+$/),Nb=gt(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),n2=gt(/^(?:\w+script|data):/i),i2=gt(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Ub=gt(/^html$/i),s2=gt(/^[a-z][.\w]*(-[.\w]+)+$/i);var bg=Object.freeze({__proto__:null,ARIA_ATTR:r2,ATTR_WHITESPACE:i2,CUSTOM_ELEMENT:s2,DATA_ATTR:t2,DOCTYPE_NAME:Ub,ERB_EXPR:QO,IS_ALLOWED_URI:Nb,IS_SCRIPT_OR_DATA:n2,MUSTACHE_EXPR:JO,TMPLIT_EXPR:e2});const ts={element:1,text:3,progressingInstruction:7,comment:8,document:9},o2=function(){return typeof window>"u"?null:window},a2=function(t,e){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let n=null;const i="data-tt-policy-suffix";e&&e.hasAttribute(i)&&(n=e.getAttribute(i));const s="dompurify"+(n?"#"+n:"");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}},wg=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Fb(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:o2();const t=N=>Fb(N);if(t.version="3.3.3",t.removed=[],!r||!r.document||r.document.nodeType!==ts.document||!r.Element)return t.isSupported=!1,t;let{document:e}=r;const n=e,i=n.currentScript,{DocumentFragment:s,HTMLTemplateElement:o,Node:a,Element:c,NodeFilter:u,NamedNodeMap:h=r.NamedNodeMap||r.MozNamedAttrMap,HTMLFormElement:p,DOMParser:m,trustedTypes:g}=r,S=c.prototype,_=es(S,"cloneNode"),I=es(S,"remove"),P=es(S,"nextSibling"),R=es(S,"childNodes"),W=es(S,"parentNode");if(typeof o=="function"){const N=e.createElement("template");N.content&&N.content.ownerDocument&&(e=N.content.ownerDocument)}let M,U="";const{implementation:Y,createNodeIterator:V,createDocumentFragment:le,getElementsByTagName:yt}=e,{importNode:Or}=n;let Re=wg();t.isSupported=typeof Mb=="function"&&typeof W=="function"&&Y&&Y.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:Mr,ERB_EXPR:xt,TMPLIT_EXPR:hr,DATA_ATTR:Dl,ARIA_ATTR:Po,IS_SCRIPT_OR_DATA:nw,ATTR_WHITESPACE:sd,CUSTOM_ELEMENT:iw}=bg;let{IS_ALLOWED_URI:od}=bg,Ie=null;const ad=G({},[...gg,...Nc,...Uc,...Fc,...mg]);let Pe=null;const ld=G({},[...vg,...Wc,...yg,...na]);let ye=Object.seal($a(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}})),Zi=null,Do=null;const dr=Object.seal($a(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let cd=!0,Ll=!0,ud=!1,hd=!0,Dn=!1,Lo=!0,Nr=!1,zl=!1,Ol=!1,Ln=!1,zo=!1,Oo=!1,dd=!0,pd=!1;const sw="user-content-";let Ml=!0,Bi=!1,zn={},At=null;const Nl=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 fd=null;const gd=G({},["audio","video","img","source","image","track"]);let Ul=null;const md=G({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Mo="http://www.w3.org/1998/Math/MathML",No="http://www.w3.org/2000/svg",Ht="http://www.w3.org/1999/xhtml";let On=Ht,Fl=!1,Wl=null;const ow=G({},[Mo,No,Ht],Oc);let Uo=G({},["mi","mo","mn","ms","mtext"]),Fo=G({},["annotation-xml"]);const aw=G({},["title","style","font","a","script"]);let ji=null;const lw=["application/xhtml+xml","text/html"],cw="text/html";let ke=null,Mn=null;const uw=e.createElement("form"),vd=function(b){return b instanceof RegExp||b instanceof Function},Hl=function(){let b=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(Mn&&Mn===b)){if((!b||typeof b!="object")&&(b={}),b=Ct(b),ji=lw.indexOf(b.PARSER_MEDIA_TYPE)===-1?cw:b.PARSER_MEDIA_TYPE,ke=ji==="application/xhtml+xml"?Oc:Ia,Ie=ot(b,"ALLOWED_TAGS")?G({},b.ALLOWED_TAGS,ke):ad,Pe=ot(b,"ALLOWED_ATTR")?G({},b.ALLOWED_ATTR,ke):ld,Wl=ot(b,"ALLOWED_NAMESPACES")?G({},b.ALLOWED_NAMESPACES,Oc):ow,Ul=ot(b,"ADD_URI_SAFE_ATTR")?G(Ct(md),b.ADD_URI_SAFE_ATTR,ke):md,fd=ot(b,"ADD_DATA_URI_TAGS")?G(Ct(gd),b.ADD_DATA_URI_TAGS,ke):gd,At=ot(b,"FORBID_CONTENTS")?G({},b.FORBID_CONTENTS,ke):Nl,Zi=ot(b,"FORBID_TAGS")?G({},b.FORBID_TAGS,ke):Ct({}),Do=ot(b,"FORBID_ATTR")?G({},b.FORBID_ATTR,ke):Ct({}),zn=ot(b,"USE_PROFILES")?b.USE_PROFILES:!1,cd=b.ALLOW_ARIA_ATTR!==!1,Ll=b.ALLOW_DATA_ATTR!==!1,ud=b.ALLOW_UNKNOWN_PROTOCOLS||!1,hd=b.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Dn=b.SAFE_FOR_TEMPLATES||!1,Lo=b.SAFE_FOR_XML!==!1,Nr=b.WHOLE_DOCUMENT||!1,Ln=b.RETURN_DOM||!1,zo=b.RETURN_DOM_FRAGMENT||!1,Oo=b.RETURN_TRUSTED_TYPE||!1,Ol=b.FORCE_BODY||!1,dd=b.SANITIZE_DOM!==!1,pd=b.SANITIZE_NAMED_PROPS||!1,Ml=b.KEEP_CONTENT!==!1,Bi=b.IN_PLACE||!1,od=b.ALLOWED_URI_REGEXP||Nb,On=b.NAMESPACE||Ht,Uo=b.MATHML_TEXT_INTEGRATION_POINTS||Uo,Fo=b.HTML_INTEGRATION_POINTS||Fo,ye=b.CUSTOM_ELEMENT_HANDLING||{},b.CUSTOM_ELEMENT_HANDLING&&vd(b.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(ye.tagNameCheck=b.CUSTOM_ELEMENT_HANDLING.tagNameCheck),b.CUSTOM_ELEMENT_HANDLING&&vd(b.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(ye.attributeNameCheck=b.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),b.CUSTOM_ELEMENT_HANDLING&&typeof b.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(ye.allowCustomizedBuiltInElements=b.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Dn&&(Ll=!1),zo&&(Ln=!0),zn&&(Ie=G({},mg),Pe=$a(null),zn.html===!0&&(G(Ie,gg),G(Pe,vg)),zn.svg===!0&&(G(Ie,Nc),G(Pe,Wc),G(Pe,na)),zn.svgFilters===!0&&(G(Ie,Uc),G(Pe,Wc),G(Pe,na)),zn.mathMl===!0&&(G(Ie,Fc),G(Pe,yg),G(Pe,na))),ot(b,"ADD_TAGS")||(dr.tagCheck=null),ot(b,"ADD_ATTR")||(dr.attributeCheck=null),b.ADD_TAGS&&(typeof b.ADD_TAGS=="function"?dr.tagCheck=b.ADD_TAGS:(Ie===ad&&(Ie=Ct(Ie)),G(Ie,b.ADD_TAGS,ke))),b.ADD_ATTR&&(typeof b.ADD_ATTR=="function"?dr.attributeCheck=b.ADD_ATTR:(Pe===ld&&(Pe=Ct(Pe)),G(Pe,b.ADD_ATTR,ke))),b.ADD_URI_SAFE_ATTR&&G(Ul,b.ADD_URI_SAFE_ATTR,ke),b.FORBID_CONTENTS&&(At===Nl&&(At=Ct(At)),G(At,b.FORBID_CONTENTS,ke)),b.ADD_FORBID_CONTENTS&&(At===Nl&&(At=Ct(At)),G(At,b.ADD_FORBID_CONTENTS,ke)),Ml&&(Ie["#text"]=!0),Nr&&G(Ie,["html","head","body"]),Ie.table&&(G(Ie,["tbody"]),delete Zi.tbody),b.TRUSTED_TYPES_POLICY){if(typeof b.TRUSTED_TYPES_POLICY.createHTML!="function")throw Qi('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof b.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Qi('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');M=b.TRUSTED_TYPES_POLICY,U=M.createHTML("")}else M===void 0&&(M=a2(g,i)),M!==null&&typeof U=="string"&&(U=M.createHTML(""));Ge&&Ge(b),Mn=b}},yd=G({},[...Nc,...Uc,...XO]),bd=G({},[...Fc,...KO]),hw=function(b){let C=W(b);(!C||!C.tagName)&&(C={namespaceURI:On,tagName:"template"});const D=Ia(b.tagName),ue=Ia(C.tagName);return Wl[b.namespaceURI]?b.namespaceURI===No?C.namespaceURI===Ht?D==="svg":C.namespaceURI===Mo?D==="svg"&&(ue==="annotation-xml"||Uo[ue]):!!yd[D]:b.namespaceURI===Mo?C.namespaceURI===Ht?D==="math":C.namespaceURI===No?D==="math"&&Fo[ue]:!!bd[D]:b.namespaceURI===Ht?C.namespaceURI===No&&!Fo[ue]||C.namespaceURI===Mo&&!Uo[ue]?!1:!bd[D]&&(aw[D]||!yd[D]):!!(ji==="application/xhtml+xml"&&Wl[b.namespaceURI]):!1},$t=function(b){Ki(t.removed,{element:b});try{W(b).removeChild(b)}catch{I(b)}},Ur=function(b,C){try{Ki(t.removed,{attribute:C.getAttributeNode(b),from:C})}catch{Ki(t.removed,{attribute:null,from:C})}if(C.removeAttribute(b),b==="is")if(Ln||zo)try{$t(C)}catch{}else try{C.setAttribute(b,"")}catch{}},wd=function(b){let C=null,D=null;if(Ol)b="<remove></remove>"+b;else{const be=Mc(b,/^[\r\n\t ]+/);D=be&&be[0]}ji==="application/xhtml+xml"&&On===Ht&&(b='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+b+"</body></html>");const ue=M?M.createHTML(b):b;if(On===Ht)try{C=new m().parseFromString(ue,ji)}catch{}if(!C||!C.documentElement){C=Y.createDocument(On,"template",null);try{C.documentElement.innerHTML=Fl?U:ue}catch{}}const Ne=C.body||C.documentElement;return b&&D&&Ne.insertBefore(e.createTextNode(D),Ne.childNodes[0]||null),On===Ht?yt.call(C,Nr?"html":"body")[0]:Nr?C.documentElement:Ne},Sd=function(b){return V.call(b.ownerDocument||b,b,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},Zl=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")},_d=function(b){return typeof a=="function"&&b instanceof a};function Zt(N,b,C){ra(N,D=>{D.call(t,b,C,Mn)})}const kd=function(b){let C=null;if(Zt(Re.beforeSanitizeElements,b,null),Zl(b))return $t(b),!0;const D=ke(b.nodeName);if(Zt(Re.uponSanitizeElement,b,{tagName:D,allowedTags:Ie}),Lo&&b.hasChildNodes()&&!_d(b.firstElementChild)&&We(/<[/\w!]/g,b.innerHTML)&&We(/<[/\w!]/g,b.textContent)||b.nodeType===ts.progressingInstruction||Lo&&b.nodeType===ts.comment&&We(/<[/\w]/g,b.data))return $t(b),!0;if(!(dr.tagCheck instanceof Function&&dr.tagCheck(D))&&(!Ie[D]||Zi[D])){if(!Zi[D]&&xd(D)&&(ye.tagNameCheck instanceof RegExp&&We(ye.tagNameCheck,D)||ye.tagNameCheck instanceof Function&&ye.tagNameCheck(D)))return!1;if(Ml&&!At[D]){const ue=W(b)||b.parentNode,Ne=R(b)||b.childNodes;if(Ne&&ue){const be=Ne.length;for(let Ye=be-1;Ye>=0;--Ye){const Bt=_(Ne[Ye],!0);Bt.__removalCount=(b.__removalCount||0)+1,ue.insertBefore(Bt,P(b))}}}return $t(b),!0}return b instanceof c&&!hw(b)||(D==="noscript"||D==="noembed"||D==="noframes")&&We(/<\/no(script|embed|frames)/i,b.innerHTML)?($t(b),!0):(Dn&&b.nodeType===ts.text&&(C=b.textContent,ra([Mr,xt,hr],ue=>{C=Ji(C,ue," ")}),b.textContent!==C&&(Ki(t.removed,{element:b.cloneNode()}),b.textContent=C)),Zt(Re.afterSanitizeElements,b,null),!1)},Ed=function(b,C,D){if(Do[C]||dd&&(C==="id"||C==="name")&&(D in e||D in uw))return!1;if(!(Ll&&!Do[C]&&We(Dl,C))){if(!(cd&&We(Po,C))){if(!(dr.attributeCheck instanceof Function&&dr.attributeCheck(C,b))){if(!Pe[C]||Do[C]){if(!(xd(b)&&(ye.tagNameCheck instanceof RegExp&&We(ye.tagNameCheck,b)||ye.tagNameCheck instanceof Function&&ye.tagNameCheck(b))&&(ye.attributeNameCheck instanceof RegExp&&We(ye.attributeNameCheck,C)||ye.attributeNameCheck instanceof Function&&ye.attributeNameCheck(C,b))||C==="is"&&ye.allowCustomizedBuiltInElements&&(ye.tagNameCheck instanceof RegExp&&We(ye.tagNameCheck,D)||ye.tagNameCheck instanceof Function&&ye.tagNameCheck(D))))return!1}else if(!Ul[C]){if(!We(od,Ji(D,sd,""))){if(!((C==="src"||C==="xlink:href"||C==="href")&&b!=="script"&&VO(D,"data:")===0&&fd[b])){if(!(ud&&!We(nw,Ji(D,sd,"")))){if(D)return!1}}}}}}}return!0},xd=function(b){return b!=="annotation-xml"&&Mc(b,iw)},Ad=function(b){Zt(Re.beforeSanitizeAttributes,b,null);const{attributes:C}=b;if(!C||Zl(b))return;const D={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Pe,forceKeepAttr:void 0};let ue=C.length;for(;ue--;){const Ne=C[ue],{name:be,namespaceURI:Ye,value:Bt}=Ne,Nn=ke(be),Bl=Bt;let De=be==="value"?Bl:GO(Bl);if(D.attrName=Nn,D.attrValue=De,D.keepAttr=!0,D.forceKeepAttr=void 0,Zt(Re.uponSanitizeAttribute,b,D),De=D.attrValue,pd&&(Nn==="id"||Nn==="name")&&(Ur(be,b),De=sw+De),Lo&&We(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,De)){Ur(be,b);continue}if(Nn==="attributename"&&Mc(De,"href")){Ur(be,b);continue}if(D.forceKeepAttr)continue;if(!D.keepAttr){Ur(be,b);continue}if(!hd&&We(/\/>/i,De)){Ur(be,b);continue}Dn&&ra([Mr,xt,hr],Id=>{De=Ji(De,Id," ")});const $d=ke(b.nodeName);if(!Ed($d,Nn,De)){Ur(be,b);continue}if(M&&typeof g=="object"&&typeof g.getAttributeType=="function"&&!Ye)switch(g.getAttributeType($d,Nn)){case"TrustedHTML":{De=M.createHTML(De);break}case"TrustedScriptURL":{De=M.createScriptURL(De);break}}if(De!==Bl)try{Ye?b.setAttributeNS(Ye,be,De):b.setAttribute(be,De),Zl(b)?$t(b):fg(t.removed)}catch{Ur(be,b)}}Zt(Re.afterSanitizeAttributes,b,null)},dw=function N(b){let C=null;const D=Sd(b);for(Zt(Re.beforeSanitizeShadowDOM,b,null);C=D.nextNode();)Zt(Re.uponSanitizeShadowNode,C,null),kd(C),Ad(C),C.content instanceof s&&N(C.content);Zt(Re.afterSanitizeShadowDOM,b,null)};return t.sanitize=function(N){let b=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},C=null,D=null,ue=null,Ne=null;if(Fl=!N,Fl&&(N="<!-->"),typeof N!="string"&&!_d(N))if(typeof N.toString=="function"){if(N=N.toString(),typeof N!="string")throw Qi("dirty is not a string, aborting")}else throw Qi("toString is not a function");if(!t.isSupported)return N;if(zl||Hl(b),t.removed=[],typeof N=="string"&&(Bi=!1),Bi){if(N.nodeName){const Bt=ke(N.nodeName);if(!Ie[Bt]||Zi[Bt])throw Qi("root node is forbidden and cannot be sanitized in-place")}}else if(N instanceof a)C=wd("<!---->"),D=C.ownerDocument.importNode(N,!0),D.nodeType===ts.element&&D.nodeName==="BODY"||D.nodeName==="HTML"?C=D:C.appendChild(D);else{if(!Ln&&!Dn&&!Nr&&N.indexOf("<")===-1)return M&&Oo?M.createHTML(N):N;if(C=wd(N),!C)return Ln?null:Oo?U:""}C&&Ol&&$t(C.firstChild);const be=Sd(Bi?N:C);for(;ue=be.nextNode();)kd(ue),Ad(ue),ue.content instanceof s&&dw(ue.content);if(Bi)return N;if(Ln){if(zo)for(Ne=le.call(C.ownerDocument);C.firstChild;)Ne.appendChild(C.firstChild);else Ne=C;return(Pe.shadowroot||Pe.shadowrootmode)&&(Ne=Or.call(n,Ne,!0)),Ne}let Ye=Nr?C.outerHTML:C.innerHTML;return Nr&&Ie["!doctype"]&&C.ownerDocument&&C.ownerDocument.doctype&&C.ownerDocument.doctype.name&&We(Ub,C.ownerDocument.doctype.name)&&(Ye="<!DOCTYPE "+C.ownerDocument.doctype.name+`>
|
|
343
|
-
`+Ye),Dn&&ra([Mr,xt,hr],Bt=>{Ye=Ji(Ye,Bt," ")}),M&&Oo?M.createHTML(Ye):Ye},t.setConfig=function(){let N=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Hl(N),zl=!0},t.clearConfig=function(){Mn=null,zl=!1},t.isValidAttribute=function(N,b,C){Mn||Hl({});const D=ke(N),ue=ke(b);return Ed(D,ue,C)},t.addHook=function(N,b){typeof b=="function"&&Ki(Re[N],b)},t.removeHook=function(N,b){if(b!==void 0){const C=BO(Re[N],b);return C===-1?void 0:jO(Re[N],C,1)[0]}return fg(Re[N])},t.removeHooks=function(N){Re[N]=[]},t.removeAllHooks=function(){Re=wg()},t}var Wb=Fb();function Gh(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Pn=Gh();function Hb(r){Pn=r}var qr={exec:()=>null};function K(r,t=""){let e=typeof r=="string"?r:r.source,n={replace:(i,s)=>{let o=typeof s=="string"?s:s.source;return o=o.replace(Ve.caret,"$1"),e=e.replace(i,o),n},getRegex:()=>new RegExp(e,t)};return n}var l2=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),Ve={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:r=>new RegExp(`^( {0,3}${r})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:r=>new RegExp(`^ {0,${Math.min(3,r-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:r=>new RegExp(`^ {0,${Math.min(3,r-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:r=>new RegExp(`^ {0,${Math.min(3,r-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:r=>new RegExp(`^ {0,${Math.min(3,r-1)}}#`),htmlBeginRegex:r=>new RegExp(`^ {0,${Math.min(3,r-1)}}<(?:[a-z].*>|!--)`,"i"),blockquoteBeginRegex:r=>new RegExp(`^ {0,${Math.min(3,r-1)}}>`)},c2=/^(?:[ \t]*(?:\n|$))+/,u2=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,h2=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Ro=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,d2=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,qh=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Zb=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Bb=K(Zb).replace(/bull/g,qh).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(),p2=K(Zb).replace(/bull/g,qh).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(),Yh=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,f2=/^[^\n]+/,Xh=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,g2=K(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Xh).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),m2=K(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,qh).getRegex(),Rl="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",Kh=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,v2=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",Kh).replace("tag",Rl).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),jb=K(Yh).replace("hr",Ro).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",Rl).getRegex(),y2=K(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",jb).getRegex(),Jh={blockquote:y2,code:u2,def:g2,fences:h2,heading:d2,hr:Ro,html:v2,lheading:Bb,list:m2,newline:c2,paragraph:jb,table:qr,text:f2},Sg=K("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Ro).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",Rl).getRegex(),b2={...Jh,lheading:p2,table:Sg,paragraph:K(Yh).replace("hr",Ro).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Sg).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",Rl).getRegex()},w2={...Jh,html:K(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Kh).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:qr,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:K(Yh).replace("hr",Ro).replace("heading",` *#{1,6} *[^
|
|
344
|
-
]`).replace("lheading",Bb).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},S2=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,_2=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Vb=/^( {2,}|\\)\n(?!\s*$)/,k2=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Hi=/[\p{P}\p{S}]/u,Pl=/[\s\p{P}\p{S}]/u,Qh=/[^\s\p{P}\p{S}]/u,E2=K(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Pl).getRegex(),Gb=/(?!~)[\p{P}\p{S}]/u,x2=/(?!~)[\s\p{P}\p{S}]/u,A2=/(?:[^\s\p{P}\p{S}]|~)/u,$2=K(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",l2?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),qb=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,I2=K(qb,"u").replace(/punct/g,Hi).getRegex(),T2=K(qb,"u").replace(/punct/g,Gb).getRegex(),Yb="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",C2=K(Yb,"gu").replace(/notPunctSpace/g,Qh).replace(/punctSpace/g,Pl).replace(/punct/g,Hi).getRegex(),R2=K(Yb,"gu").replace(/notPunctSpace/g,A2).replace(/punctSpace/g,x2).replace(/punct/g,Gb).getRegex(),P2=K("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Qh).replace(/punctSpace/g,Pl).replace(/punct/g,Hi).getRegex(),D2=K(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,Hi).getRegex(),L2="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",z2=K(L2,"gu").replace(/notPunctSpace/g,Qh).replace(/punctSpace/g,Pl).replace(/punct/g,Hi).getRegex(),O2=K(/\\(punct)/,"gu").replace(/punct/g,Hi).getRegex(),M2=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(),N2=K(Kh).replace("(?:-->|$)","-->").getRegex(),U2=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",N2).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Va=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,F2=K(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",Va).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Xb=K(/^!?\[(label)\]\[(ref)\]/).replace("label",Va).replace("ref",Xh).getRegex(),Kb=K(/^!?\[(ref)\](?:\[\])?/).replace("ref",Xh).getRegex(),W2=K("reflink|nolink(?!\\()","g").replace("reflink",Xb).replace("nolink",Kb).getRegex(),_g=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,ed={_backpedal:qr,anyPunctuation:O2,autolink:M2,blockSkip:$2,br:Vb,code:_2,del:qr,delLDelim:qr,delRDelim:qr,emStrongLDelim:I2,emStrongRDelimAst:C2,emStrongRDelimUnd:P2,escape:S2,link:F2,nolink:Kb,punctuation:E2,reflink:Xb,reflinkSearch:W2,tag:U2,text:k2,url:qr},H2={...ed,link:K(/^!?\[(label)\]\((.*?)\)/).replace("label",Va).getRegex(),reflink:K(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Va).getRegex()},Vu={...ed,emStrongRDelimAst:R2,emStrongLDelim:T2,delLDelim:D2,delRDelim:z2,url:K(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",_g).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",_g).getRegex()},Z2={...Vu,br:K(Vb).replace("{2,}","*").getRegex(),text:K(Vu.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},ia={normal:Jh,gfm:b2,pedantic:w2},rs={normal:ed,gfm:Vu,breaks:Z2,pedantic:H2},B2={"&":"&","<":"<",">":">",'"':""","'":"'"},kg=r=>B2[r];function Rt(r,t){if(t){if(Ve.escapeTest.test(r))return r.replace(Ve.escapeReplace,kg)}else if(Ve.escapeTestNoEncode.test(r))return r.replace(Ve.escapeReplaceNoEncode,kg);return r}function Eg(r){try{r=encodeURI(r).replace(Ve.percentDecode,"%")}catch{return null}return r}function xg(r,t){var s;let e=r.replace(Ve.findPipe,(o,a,c)=>{let u=!1,h=a;for(;--h>=0&&c[h]==="\\";)u=!u;return u?"|":" |"}),n=e.split(Ve.splitPipe),i=0;if(n[0].trim()||n.shift(),n.length>0&&!((s=n.at(-1))!=null&&s.trim())&&n.pop(),t)if(n.length>t)n.splice(t);else for(;n.length<t;)n.push("");for(;i<n.length;i++)n[i]=n[i].trim().replace(Ve.slashPipe,"|");return n}function ns(r,t,e){let n=r.length;if(n===0)return"";let i=0;for(;i<n&&r.charAt(n-i-1)===t;)i++;return r.slice(0,n-i)}function j2(r,t){if(r.indexOf(t[1])===-1)return-1;let e=0;for(let n=0;n<r.length;n++)if(r[n]==="\\")n++;else if(r[n]===t[0])e++;else if(r[n]===t[1]&&(e--,e<0))return n;return e>0?-2:-1}function V2(r,t=0){let e=t,n="";for(let i of r)if(i===" "){let s=4-e%4;n+=" ".repeat(s),e+=s}else n+=i,e++;return n}function Ag(r,t,e,n,i){let s=t.href,o=t.title||null,a=r[1].replace(i.other.outputLinkReplace,"$1");n.state.inLink=!0;let c={type:r[0].charAt(0)==="!"?"image":"link",raw:e,href:s,title:o,text:a,tokens:n.inlineTokens(a)};return n.state.inLink=!1,c}function G2(r,t,e){let n=r.match(e.other.indentCodeCompensation);if(n===null)return t;let i=n[1];return t.split(`
|
|
345
|
-
`).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 Ga=class{constructor(r){y(this,"options");y(this,"rules");y(this,"lexer");this.options=r||Pn}space(r){let t=this.rules.block.newline.exec(r);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(r){let t=this.rules.block.code.exec(r);if(t){let e=t[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?e:ns(e,`
|
|
347
|
-
`)}}}fences(r){let t=this.rules.block.fences.exec(r);if(t){let e=t[0],n=G2(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:n}}}heading(r){let t=this.rules.block.heading.exec(r);if(t){let e=t[2].trim();if(this.rules.other.endingHash.test(e)){let n=ns(e,"#");(this.options.pedantic||!n||this.rules.other.endingSpaceChar.test(n))&&(e=n.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(r){let t=this.rules.block.hr.exec(r);if(t)return{type:"hr",raw:ns(t[0],`
|
|
348
|
-
`)}}blockquote(r){let t=this.rules.block.blockquote.exec(r);if(t){let e=ns(t[0],`
|
|
349
|
-
`).split(`
|
|
350
|
-
`),n="",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
|
-
`),h=u.replace(this.rules.other.blockquoteSetextReplace,`
|
|
352
|
-
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");n=n?`${n}
|
|
353
|
-
${u}`:u,i=i?`${i}
|
|
354
|
-
${h}`:h;let p=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(h,s,!0),this.lexer.state.top=p,e.length===0)break;let m=s.at(-1);if((m==null?void 0:m.type)==="code")break;if((m==null?void 0:m.type)==="blockquote"){let g=m,S=g.raw+`
|
|
355
|
-
`+e.join(`
|
|
356
|
-
`),_=this.blockquote(S);s[s.length-1]=_,n=n.substring(0,n.length-g.raw.length)+_.raw,i=i.substring(0,i.length-g.text.length)+_.text;break}else if((m==null?void 0:m.type)==="list"){let g=m,S=g.raw+`
|
|
357
|
-
`+e.join(`
|
|
358
|
-
`),_=this.list(S);s[s.length-1]=_,n=n.substring(0,n.length-m.raw.length)+_.raw,i=i.substring(0,i.length-g.raw.length)+_.raw,e=S.substring(s.at(-1).raw.length).split(`
|
|
359
|
-
`);continue}}return{type:"blockquote",raw:n,tokens:s,text:i}}}list(r){var e,n;let t=this.rules.block.list.exec(r);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(;r;){let h=!1,p="",m="";if(!(t=a.exec(r))||this.rules.block.hr.test(r))break;p=t[0],r=r.substring(p.length);let g=V2(t[2].split(`
|
|
360
|
-
`,1)[0],t[1].length),S=r.split(`
|
|
361
|
-
`,1)[0],_=!g.trim(),I=0;if(this.options.pedantic?(I=2,m=g.trimStart()):_?I=t[1].length+1:(I=g.search(this.rules.other.nonSpaceChar),I=I>4?1:I,m=g.slice(I),I+=t[1].length),_&&this.rules.other.blankLine.test(S)&&(p+=S+`
|
|
362
|
-
`,r=r.substring(S.length+1),h=!0),!h){let P=this.rules.other.nextBulletRegex(I),R=this.rules.other.hrRegex(I),W=this.rules.other.fencesBeginRegex(I),M=this.rules.other.headingBeginRegex(I),U=this.rules.other.htmlBeginRegex(I),Y=this.rules.other.blockquoteBeginRegex(I);for(;r;){let V=r.split(`
|
|
363
|
-
`,1)[0],le;if(S=V,this.options.pedantic?(S=S.replace(this.rules.other.listReplaceNesting," "),le=S):le=S.replace(this.rules.other.tabCharGlobal," "),W.test(S)||M.test(S)||U.test(S)||Y.test(S)||P.test(S)||R.test(S))break;if(le.search(this.rules.other.nonSpaceChar)>=I||!S.trim())m+=`
|
|
364
|
-
`+le.slice(I);else{if(_||g.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||W.test(g)||M.test(g)||R.test(g))break;m+=`
|
|
365
|
-
`+S}_=!S.trim(),p+=V+`
|
|
366
|
-
`,r=r.substring(V.length+1),g=le.slice(I)}}o.loose||(c?o.loose=!0:this.rules.other.doubleBlankLine.test(p)&&(c=!0)),o.items.push({type:"list_item",raw:p,task:!!this.options.gfm&&this.rules.other.listIsTask.test(m),loose:!1,text:m,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"||((n=h.tokens[0])==null?void 0:n.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 m=this.lexer.inlineQueue.length-1;m>=0;m--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[m].src)){this.lexer.inlineQueue[m].src=this.lexer.inlineQueue[m].src.replace(this.rules.other.listReplaceTask,"");break}}let p=this.rules.other.listTaskCheckbox.exec(h.raw);if(p){let m={type:"checkbox",raw:p[0]+" ",checked:p[0]!=="[ ]"};h.checked=m.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=m.raw+h.tokens[0].raw,h.tokens[0].text=m.raw+h.tokens[0].text,h.tokens[0].tokens.unshift(m)):h.tokens.unshift({type:"paragraph",raw:m.raw,text:m.raw,tokens:[m]}):h.tokens.unshift(m)}}if(!o.loose){let p=h.tokens.filter(g=>g.type==="space"),m=p.length>0&&p.some(g=>this.rules.other.anyLine.test(g.raw));o.loose=m}}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(r){let t=this.rules.block.html.exec(r);if(t)return{type:"html",block:!0,raw:t[0],pre:t[1]==="pre"||t[1]==="script"||t[1]==="style",text:t[0]}}def(r){let t=this.rules.block.def.exec(r);if(t){let e=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),n=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:n,title:i}}}table(r){var o;let t=this.rules.block.table.exec(r);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let e=xg(t[1]),n=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),i=(o=t[3])!=null&&o.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
367
|
-
`):[],s={type:"table",raw:t[0],header:[],align:[],rows:[]};if(e.length===n.length){for(let a of n)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(xg(a,s.header.length).map((c,u)=>({text:c,tokens:this.lexer.inline(c),header:!1,align:s.align[u]})));return s}}lheading(r){let t=this.rules.block.lheading.exec(r);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(r){let t=this.rules.block.paragraph.exec(r);if(t){let e=t[1].charAt(t[1].length-1)===`
|
|
368
|
-
`?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(r){let t=this.rules.block.text.exec(r);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(r){let t=this.rules.inline.escape.exec(r);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(r){let t=this.rules.inline.tag.exec(r);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(r){let t=this.rules.inline.link.exec(r);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=ns(e.slice(0,-1),"\\");if((e.length-s.length)%2===0)return}else{let s=j2(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 n=t[2],i="";if(this.options.pedantic){let s=this.rules.other.pedanticHrefTitle.exec(n);s&&(n=s[1],i=s[3])}else i=t[3]?t[3].slice(1,-1):"";return n=n.trim(),this.rules.other.startAngleBracket.test(n)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(e)?n=n.slice(1):n=n.slice(1,-1)),Ag(t,{href:n&&n.replace(this.rules.inline.anyPunctuation,"$1"),title:i&&i.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(r,t){let e;if((e=this.rules.inline.reflink.exec(r))||(e=this.rules.inline.nolink.exec(r))){let n=(e[2]||e[1]).replace(this.rules.other.multipleSpaceGlobal," "),i=t[n.toLowerCase()];if(!i){let s=e[0].charAt(0);return{type:"text",raw:s,text:s}}return Ag(e,i,e[0],this.lexer,this.rules)}}emStrong(r,t,e=""){let n=this.rules.inline.emStrongLDelim.exec(r);if(!(!n||!n[1]&&!n[2]&&!n[3]&&!n[4]||n[4]&&e.match(this.rules.other.unicodeAlphaNumeric))&&(!(n[1]||n[3])||!e||this.rules.inline.punctuation.exec(e))){let i=[...n[0]].length-1,s,o,a=i,c=0,u=n[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(u.lastIndex=0,t=t.slice(-1*r.length+i);(n=u.exec(t))!=null;){if(s=n[1]||n[2]||n[3]||n[4]||n[5]||n[6],!s)continue;if(o=[...s].length,n[3]||n[4]){a+=o;continue}else if((n[5]||n[6])&&i%3&&!((i+o)%3)){c+=o;continue}if(a-=o,a>0)continue;o=Math.min(o,o+a+c);let h=[...n[0]][0].length,p=r.slice(0,i+n.index+h+o);if(Math.min(i,o)%2){let g=p.slice(1,-1);return{type:"em",raw:p,text:g,tokens:this.lexer.inlineTokens(g)}}let m=p.slice(2,-2);return{type:"strong",raw:p,text:m,tokens:this.lexer.inlineTokens(m)}}}}codespan(r){let t=this.rules.inline.code.exec(r);if(t){let e=t[2].replace(this.rules.other.newLineCharGlobal," "),n=this.rules.other.nonSpaceChar.test(e),i=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return n&&i&&(e=e.substring(1,e.length-1)),{type:"codespan",raw:t[0],text:e}}}br(r){let t=this.rules.inline.br.exec(r);if(t)return{type:"br",raw:t[0]}}del(r,t,e=""){let n=this.rules.inline.delLDelim.exec(r);if(n&&(!n[1]||!e||this.rules.inline.punctuation.exec(e))){let i=[...n[0]].length-1,s,o,a=i,c=this.rules.inline.delRDelim;for(c.lastIndex=0,t=t.slice(-1*r.length+i);(n=c.exec(t))!=null;){if(s=n[1]||n[2]||n[3]||n[4]||n[5]||n[6],!s||(o=[...s].length,o!==i))continue;if(n[3]||n[4]){a+=o;continue}if(a-=o,a>0)continue;o=Math.min(o,o+a);let u=[...n[0]][0].length,h=r.slice(0,i+n.index+u+o),p=h.slice(i,-i);return{type:"del",raw:h,text:p,tokens:this.lexer.inlineTokens(p)}}}}autolink(r){let t=this.rules.inline.autolink.exec(r);if(t){let e,n;return t[2]==="@"?(e=t[1],n="mailto:"+e):(e=t[1],n=e),{type:"link",raw:t[0],text:e,href:n,tokens:[{type:"text",raw:e,text:e}]}}}url(r){var e;let t;if(t=this.rules.inline.url.exec(r)){let n,i;if(t[2]==="@")n=t[0],i="mailto:"+n;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]);n=t[0],t[1]==="www."?i="http://"+t[0]:i=t[0]}return{type:"link",raw:t[0],text:n,href:i,tokens:[{type:"text",raw:n,text:n}]}}}inlineText(r){let t=this.rules.inline.text.exec(r);if(t){let e=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:e}}}},kt=class Gu{constructor(t){y(this,"tokens");y(this,"options");y(this,"state");y(this,"inlineQueue");y(this,"tokenizer");this.tokens=[],this.tokens.links=Object.create(null),this.options=t||Pn,this.options.tokenizer=this.options.tokenizer||new Ga,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:Ve,block:ia.normal,inline:rs.normal};this.options.pedantic?(e.block=ia.pedantic,e.inline=rs.pedantic):this.options.gfm&&(e.block=ia.gfm,this.options.breaks?e.inline=rs.breaks:e.inline=rs.gfm),this.tokenizer.rules=e}static get rules(){return{block:ia,inline:rs}}static lex(t,e){return new Gu(e).lex(t)}static lexInline(t,e){return new Gu(e).inlineTokens(t)}lex(t){t=t.replace(Ve.carriageReturn,`
|
|
369
|
-
`),this.blockTokens(t,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){let n=this.inlineQueue[e];this.inlineTokens(n.src,n.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(t,e=[],n=!1){var i,s,o;for(this.tokenizer.lexer=this,this.options.pedantic&&(t=t.replace(Ve.tabCharGlobal," ").replace(Ve.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
|
-
`: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
|
-
`)?"":`
|
|
372
|
-
`)+a.raw,u.text+=`
|
|
373
|
-
`+a.text,this.inlineQueue.at(-1).src=u.text):e.push(a);continue}if(a=this.tokenizer.fences(t)){t=t.substring(a.raw.length),e.push(a);continue}if(a=this.tokenizer.heading(t)){t=t.substring(a.raw.length),e.push(a);continue}if(a=this.tokenizer.hr(t)){t=t.substring(a.raw.length),e.push(a);continue}if(a=this.tokenizer.blockquote(t)){t=t.substring(a.raw.length),e.push(a);continue}if(a=this.tokenizer.list(t)){t=t.substring(a.raw.length),e.push(a);continue}if(a=this.tokenizer.html(t)){t=t.substring(a.raw.length),e.push(a);continue}if(a=this.tokenizer.def(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(`
|
|
374
|
-
`)?"":`
|
|
375
|
-
`)+a.raw,u.text+=`
|
|
376
|
-
`+a.raw,this.inlineQueue.at(-1).src=u.text):this.tokens.links[a.tag]||(this.tokens.links[a.tag]={href:a.href,title:a.title},e.push(a));continue}if(a=this.tokenizer.table(t)){t=t.substring(a.raw.length),e.push(a);continue}if(a=this.tokenizer.lheading(t)){t=t.substring(a.raw.length),e.push(a);continue}let c=t;if((o=this.options.extensions)!=null&&o.startBlock){let u=1/0,h=t.slice(1),p;this.options.extensions.startBlock.forEach(m=>{p=m.call({lexer:this},h),typeof p=="number"&&p>=0&&(u=Math.min(u,p))}),u<1/0&&u>=0&&(c=t.substring(0,u+1))}if(this.state.top&&(a=this.tokenizer.paragraph(c))){let u=e.at(-1);n&&(u==null?void 0:u.type)==="paragraph"?(u.raw+=(u.raw.endsWith(`
|
|
377
|
-
`)?"":`
|
|
378
|
-
`)+a.raw,u.text+=`
|
|
379
|
-
`+a.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=u.text):e.push(a),n=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
|
-
`)?"":`
|
|
381
|
-
`)+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,m;this.tokenizer.lexer=this;let n=t,i=null;if(this.tokens.links){let g=Object.keys(this.tokens.links);if(g.length>0)for(;(i=this.tokenizer.rules.inline.reflinkSearch.exec(n))!=null;)g.includes(i[0].slice(i[0].lastIndexOf("[")+1,-1))&&(n=n.slice(0,i.index)+"["+"a".repeat(i[0].length-2)+"]"+n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(i=this.tokenizer.rules.inline.anyPunctuation.exec(n))!=null;)n=n.slice(0,i.index)+"++"+n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let s;for(;(i=this.tokenizer.rules.inline.blockSkip.exec(n))!=null;)s=i[2]?i[2].length:0,n=n.slice(0,i.index+s)+"["+"a".repeat(i[0].length-s-2)+"]"+n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);n=((u=(c=this.options.hooks)==null?void 0:c.emStrongMask)==null?void 0:u.call({lexer:this},n))??n;let o=!1,a="";for(;t;){o||(a=""),o=!1;let g;if((p=(h=this.options.extensions)==null?void 0:h.inline)!=null&&p.some(_=>(g=_.call({lexer:this},t,e))?(t=t.substring(g.raw.length),e.push(g),!0):!1))continue;if(g=this.tokenizer.escape(t)){t=t.substring(g.raw.length),e.push(g);continue}if(g=this.tokenizer.tag(t)){t=t.substring(g.raw.length),e.push(g);continue}if(g=this.tokenizer.link(t)){t=t.substring(g.raw.length),e.push(g);continue}if(g=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(g.raw.length);let _=e.at(-1);g.type==="text"&&(_==null?void 0:_.type)==="text"?(_.raw+=g.raw,_.text+=g.text):e.push(g);continue}if(g=this.tokenizer.emStrong(t,n,a)){t=t.substring(g.raw.length),e.push(g);continue}if(g=this.tokenizer.codespan(t)){t=t.substring(g.raw.length),e.push(g);continue}if(g=this.tokenizer.br(t)){t=t.substring(g.raw.length),e.push(g);continue}if(g=this.tokenizer.del(t,n,a)){t=t.substring(g.raw.length),e.push(g);continue}if(g=this.tokenizer.autolink(t)){t=t.substring(g.raw.length),e.push(g);continue}if(!this.state.inLink&&(g=this.tokenizer.url(t))){t=t.substring(g.raw.length),e.push(g);continue}let S=t;if((m=this.options.extensions)!=null&&m.startInline){let _=1/0,I=t.slice(1),P;this.options.extensions.startInline.forEach(R=>{P=R.call({lexer:this},I),typeof P=="number"&&P>=0&&(_=Math.min(_,P))}),_<1/0&&_>=0&&(S=t.substring(0,_+1))}if(g=this.tokenizer.inlineText(S)){t=t.substring(g.raw.length),g.raw.slice(-1)!=="_"&&(a=g.raw.slice(-1)),o=!0;let _=e.at(-1);(_==null?void 0:_.type)==="text"?(_.raw+=g.raw,_.text+=g.text):e.push(g);continue}if(t){let _="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(_);break}else throw new Error(_)}}return e}},qa=class{constructor(r){y(this,"options");y(this,"parser");this.options=r||Pn}space(r){return""}code({text:r,lang:t,escaped:e}){var s;let n=(s=(t||"").match(Ve.notSpaceStart))==null?void 0:s[0],i=r.replace(Ve.endingNewline,"")+`
|
|
383
|
-
`;return n?'<pre><code class="language-'+Rt(n)+'">'+(e?i:Rt(i,!0))+`</code></pre>
|
|
384
|
-
`:"<pre><code>"+(e?i:Rt(i,!0))+`</code></pre>
|
|
385
|
-
`}blockquote({tokens:r}){return`<blockquote>
|
|
386
|
-
${this.parser.parse(r)}</blockquote>
|
|
387
|
-
`}html({text:r}){return r}def(r){return""}heading({tokens:r,depth:t}){return`<h${t}>${this.parser.parseInline(r)}</h${t}>
|
|
388
|
-
`}hr(r){return`<hr>
|
|
389
|
-
`}list(r){let t=r.ordered,e=r.start,n="";for(let o=0;o<r.items.length;o++){let a=r.items[o];n+=this.listitem(a)}let i=t?"ol":"ul",s=t&&e!==1?' start="'+e+'"':"";return"<"+i+s+`>
|
|
390
|
-
`+n+"</"+i+`>
|
|
391
|
-
`}listitem(r){return`<li>${this.parser.parse(r.tokens)}</li>
|
|
392
|
-
`}checkbox({checked:r}){return"<input "+(r?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:r}){return`<p>${this.parser.parseInline(r)}</p>
|
|
393
|
-
`}table(r){let t="",e="";for(let i=0;i<r.header.length;i++)e+=this.tablecell(r.header[i]);t+=this.tablerow({text:e});let n="";for(let i=0;i<r.rows.length;i++){let s=r.rows[i];e="";for(let o=0;o<s.length;o++)e+=this.tablecell(s[o]);n+=this.tablerow({text:e})}return n&&(n=`<tbody>${n}</tbody>`),`<table>
|
|
394
|
-
<thead>
|
|
395
|
-
`+t+`</thead>
|
|
396
|
-
`+n+`</table>
|
|
397
|
-
`}tablerow({text:r}){return`<tr>
|
|
398
|
-
${r}</tr>
|
|
399
|
-
`}tablecell(r){let t=this.parser.parseInline(r.tokens),e=r.header?"th":"td";return(r.align?`<${e} align="${r.align}">`:`<${e}>`)+t+`</${e}>
|
|
400
|
-
`}strong({tokens:r}){return`<strong>${this.parser.parseInline(r)}</strong>`}em({tokens:r}){return`<em>${this.parser.parseInline(r)}</em>`}codespan({text:r}){return`<code>${Rt(r,!0)}</code>`}br(r){return"<br>"}del({tokens:r}){return`<del>${this.parser.parseInline(r)}</del>`}link({href:r,title:t,tokens:e}){let n=this.parser.parseInline(e),i=Eg(r);if(i===null)return n;r=i;let s='<a href="'+r+'"';return t&&(s+=' title="'+Rt(t)+'"'),s+=">"+n+"</a>",s}image({href:r,title:t,text:e,tokens:n}){n&&(e=this.parser.parseInline(n,this.parser.textRenderer));let i=Eg(r);if(i===null)return Rt(e);r=i;let s=`<img src="${r}" alt="${Rt(e)}"`;return t&&(s+=` title="${Rt(t)}"`),s+=">",s}text(r){return"tokens"in r&&r.tokens?this.parser.parseInline(r.tokens):"escaped"in r&&r.escaped?r.text:Rt(r.text)}},td=class{strong({text:r}){return r}em({text:r}){return r}codespan({text:r}){return r}del({text:r}){return r}html({text:r}){return r}text({text:r}){return r}link({text:r}){return""+r}image({text:r}){return""+r}br(){return""}checkbox({raw:r}){return r}},Et=class qu{constructor(t){y(this,"options");y(this,"renderer");y(this,"textRenderer");this.options=t||Pn,this.options.renderer=this.options.renderer||new qa,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new td}static parse(t,e){return new qu(e).parse(t)}static parseInline(t,e){return new qu(e).parseInline(t)}parse(t){var n,i;this.renderer.parser=this;let e="";for(let s=0;s<t.length;s++){let o=t[s];if((i=(n=this.options.extensions)==null?void 0:n.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 n="";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)){n+=u||"";continue}}let c=a;switch(c.type){case"escape":{n+=e.text(c);break}case"html":{n+=e.html(c);break}case"link":{n+=e.link(c);break}case"image":{n+=e.image(c);break}case"checkbox":{n+=e.checkbox(c);break}case"strong":{n+=e.strong(c);break}case"em":{n+=e.em(c);break}case"codespan":{n+=e.codespan(c);break}case"br":{n+=e.br(c);break}case"del":{n+=e.del(c);break}case"text":{n+=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 n}},sa,ds=(sa=class{constructor(r){y(this,"options");y(this,"block");this.options=r||Pn}preprocess(r){return r}postprocess(r){return r}processAllTokens(r){return r}emStrongMask(r){return r}provideLexer(){return this.block?kt.lex:kt.lexInline}provideParser(){return this.block?Et.parse:Et.parseInline}},y(sa,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),y(sa,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),sa),q2=class{constructor(...r){y(this,"defaults",Gh());y(this,"options",this.setOptions);y(this,"parse",this.parseMarkdown(!0));y(this,"parseInline",this.parseMarkdown(!1));y(this,"Parser",Et);y(this,"Renderer",qa);y(this,"TextRenderer",td);y(this,"Lexer",kt);y(this,"Tokenizer",Ga);y(this,"Hooks",ds);this.use(...r)}walkTokens(r,t){var n,i;let e=[];for(let s of r)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=(n=this.defaults.extensions)==null?void 0:n.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(...r){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return r.forEach(e=>{let n={...e};if(n.async=this.defaults.async||n.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)}),n.extensions=t),e.renderer){let i=this.defaults.renderer||new qa(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||""}}n.renderer=i}if(e.tokenizer){let i=this.defaults.tokenizer||new Ga(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}}n.tokenizer=i}if(e.hooks){let i=this.defaults.hooks||new ds;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];ds.passThroughHooks.has(s)?i[o]=u=>{if(this.defaults.async&&ds.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}}n.hooks=i}if(e.walkTokens){let i=this.defaults.walkTokens,s=e.walkTokens;n.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,...n}}),this}setOptions(r){return this.defaults={...this.defaults,...r},this}lexer(r,t){return kt.lex(r,t??this.defaults)}parser(r,t){return Et.parse(r,t??this.defaults)}parseMarkdown(r){return(t,e)=>{let n={...e},i={...this.defaults,...n},s=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&n.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=r),i.async)return(async()=>{let o=i.hooks?await i.hooks.preprocess(t):t,a=await(i.hooks?await i.hooks.provideLexer():r?kt.lex:kt.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():r?Et.parse:Et.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():r?kt.lex:kt.lexInline)(t,i);i.hooks&&(o=i.hooks.processAllTokens(o)),i.walkTokens&&this.walkTokens(o,i.walkTokens);let a=(i.hooks?i.hooks.provideParser():r?Et.parse:Et.parseInline)(o,i);return i.hooks&&(a=i.hooks.postprocess(a)),a}catch(o){return s(o)}}}onError(r,t){return e=>{if(e.message+=`
|
|
401
|
-
Please report this to https://github.com/markedjs/marked.`,r){let n="<p>An error occurred:</p><pre>"+Rt(e.message+"",!0)+"</pre>";return t?Promise.resolve(n):n}if(t)return Promise.reject(e);throw e}}},$n=new q2;function ee(r,t){return $n.parse(r,t)}ee.options=ee.setOptions=function(r){return $n.setOptions(r),ee.defaults=$n.defaults,Hb(ee.defaults),ee};ee.getDefaults=Gh;ee.defaults=Pn;ee.use=function(...r){return $n.use(...r),ee.defaults=$n.defaults,Hb(ee.defaults),ee};ee.walkTokens=function(r,t){return $n.walkTokens(r,t)};ee.parseInline=$n.parseInline;ee.Parser=Et;ee.parser=Et.parse;ee.Renderer=qa;ee.TextRenderer=td;ee.Lexer=kt;ee.lexer=kt.lex;ee.Tokenizer=Ga;ee.Hooks=ds;ee.parse=ee;ee.options;ee.setOptions;ee.use;ee.walkTokens;ee.parseInline;Et.parse;kt.lex;Wb.addHook("afterSanitizeAttributes",r=>{r.tagName==="A"&&(r.setAttribute("target","_blank"),r.setAttribute("rel","noopener noreferrer"))});function Y2(r){const t=ee.parse(r,{async:!1});return Wb.sanitize(t,{USE_PROFILES:{html:!0}})}const X2=8,$g=new WeakMap;function K2(r){const t=$g.get(r);if(t&&t.text===r.text)return t.html;const e=Y2(r.text);return $g.set(r,{text:r.text,html:e}),e}function J2(r){return r.replace(/_/g," ")}function Q2(r){return H`
|
|
402
|
-
<div class="tool-call-header">
|
|
403
|
-
<span class="tool-call-title">${r.title}</span>
|
|
404
|
-
<span class="tool-call-meta">${r.toolKind} · ${J2(r.status)}</span>
|
|
405
|
-
</div>
|
|
406
|
-
${r.text?H`<pre class="tool-call-text">${r.text}</pre>`:null}
|
|
407
|
-
`}function Ig(r){for(let t=r.length-1;t>=0;t-=1){const e=r[t];if(e&&e.kind==="user")return e.id}return null}var sr,wn,al,ll,ho,Yu;class Jb extends As{constructor(){super(...arguments);w(this,ho);y(this,"messages",[]);w(this,sr,!0);w(this,wn,null);w(this,al,()=>{const e=l(this,wn);if(!e)return;const i=e.scrollHeight-e.clientHeight-e.scrollTop<=X2;i!==l(this,sr)&&(x(this,sr,i),this.toggleAttribute("data-pinned",i))});w(this,ll,()=>{x(this,sr,!0),this.toggleAttribute("data-pinned",!0),f(this,ho,Yu).call(this,!0)})}changed(e){let n=!1;if(e.has("messages")){const i=e.get("messages")??[],s=Ig(this.messages);n=s!==null&&s!==Ig(i),n&&x(this,sr,!0)}Fe(this.template(),this),l(this,wn)||x(this,wn,this.querySelector(".history-scroll")),this.toggleAttribute("data-pinned",l(this,sr)),f(this,ho,Yu).call(this,n)}template(){return H`
|
|
408
|
-
<div class="history-scroll" @scroll=${l(this,al)}>
|
|
409
|
-
${this.messages.map(e=>{const n=e.kind==="assistant"?BL(K2(e)):e.kind==="tool_call"?Q2(e):e.text;return H`<div
|
|
410
|
-
class="message message-${e.kind}"
|
|
411
|
-
data-message-id=${e.id}
|
|
412
|
-
>${n}</div>`})}
|
|
413
|
-
</div>
|
|
414
|
-
<button
|
|
415
|
-
type="button"
|
|
416
|
-
class="history-jump"
|
|
417
|
-
aria-label="Jump to latest message"
|
|
418
|
-
@click=${l(this,ll)}
|
|
419
|
-
>
|
|
420
|
-
${jy({size:16})}
|
|
421
|
-
</button>
|
|
422
|
-
`}}sr=new WeakMap,wn=new WeakMap,al=new WeakMap,ll=new WeakMap,ho=new WeakSet,Yu=function(e){requestAnimationFrame(()=>{const n=l(this,wn);n&&(!l(this,sr)&&!e||(n.scrollTop=n.scrollHeight-n.clientHeight))})},y(Jb,"properties",["messages"]);customElements.define("message-history",Jb);var po,fo,Ei,cl,ul,ht,Ta,go,Ku,Ju,mo,vo;class Xu extends As{constructor(){super(...arguments);w(this,ht);y(this,"placeholder","What do you want to do?");y(this,"open",!1);y(this,"messages",[]);w(this,po,Ft.resolve("ServerManager"));w(this,fo,Ft.resolve("ShortcutService"));w(this,Ei,null);y(this,"handleTriggerActivate",()=>{this.open=!0});y(this,"handleKeydown",e=>{var o;if(e.key!=="Enter"||e.shiftKey)return;const n=e.currentTarget,i=n.value.trim();if(e.preventDefault(),!i)return;n.value="",f(this,ht,Ta).call(this,n);const s=(o=l(this,po).activeServer)==null?void 0:o.acpClient;s&&s.sendMessage({text:i}).catch(a=>{console.error("ACPClient.sendMessage() failed",a)})});w(this,cl,e=>{f(this,ht,Ta).call(this,e.currentTarget)});w(this,ul,e=>{if(e.target instanceof HTMLTextAreaElement)return;const n=e.currentTarget.querySelector("textarea");n==null||n.focus()});w(this,go,e=>{if(e.shortcut!=="focusCommandInput")return;if(!this.open){this.open=!0;return}const n=this.querySelector("textarea");if(n){if(document.activeElement===n){this.open=!1;return}n.focus()}});w(this,mo,e=>{e.target instanceof Node&&(this.contains(e.target)||(this.open=!1))});w(this,vo,e=>{e.key==="Escape"&&(this.open=!1)})}connected(){const e=new DisposableStack;x(this,Ei,e);const n=FO(l(this,po),i=>{this.messages=i});e.defer(()=>n.dispose()),l(this,fo).addEventListener("shortcut-triggered",l(this,go)),e.defer(()=>l(this,fo).removeEventListener("shortcut-triggered",l(this,go))),this.open&&f(this,ht,Ku).call(this)}disconnected(){var e;(e=l(this,Ei))==null||e.dispose(),x(this,Ei,null),f(this,ht,Ju).call(this)}changed(e){if(this.open?(this.removeAttribute("material"),this.removeAttribute("tone"),this.removeAttribute("level")):(this.setAttribute("material","paper"),this.setAttribute("tone","dark"),this.setAttribute("level","overlay")),Fe(this.template(),this),e.has("open"))if(this.open){f(this,ht,Ku).call(this);const n=this.querySelector("textarea");n&&(f(this,ht,Ta).call(this,n),n.focus())}else f(this,ht,Ju).call(this)}template(){return this.open?H`
|
|
423
|
-
${this.messages.length>0?H`
|
|
424
|
-
<div
|
|
425
|
-
class="chat"
|
|
426
|
-
material="paper"
|
|
427
|
-
tone="dark"
|
|
428
|
-
level="overlay"
|
|
429
|
-
>
|
|
430
|
-
<message-history selectable .messages=${this.messages}></message-history>
|
|
431
|
-
</div>
|
|
432
|
-
`:null}
|
|
433
|
-
<div
|
|
434
|
-
class="input"
|
|
435
|
-
material="paper"
|
|
436
|
-
tone="dark"
|
|
437
|
-
level="overlay"
|
|
438
|
-
@click=${l(this,ul)}
|
|
439
|
-
>
|
|
440
|
-
<textarea
|
|
441
|
-
class="textarea"
|
|
442
|
-
rows="1"
|
|
443
|
-
@keydown=${this.handleKeydown}
|
|
444
|
-
@input=${l(this,cl)}
|
|
445
|
-
></textarea>
|
|
446
|
-
</div>
|
|
447
|
-
`:H`
|
|
448
|
-
<div
|
|
449
|
-
class="trigger"
|
|
450
|
-
tabindex="0"
|
|
451
|
-
role="button"
|
|
452
|
-
@click=${this.handleTriggerActivate}
|
|
453
|
-
@focus=${this.handleTriggerActivate}
|
|
454
|
-
>
|
|
455
|
-
<span class="label">${this.placeholder}</span>
|
|
456
|
-
<span class="kbd" aria-hidden="true">⌘K</span>
|
|
457
|
-
</div>
|
|
458
|
-
`}}po=new WeakMap,fo=new WeakMap,Ei=new WeakMap,cl=new WeakMap,ul=new WeakMap,ht=new WeakSet,Ta=function(e){e.style.height="auto",e.style.height=`${e.scrollHeight}px`},go=new WeakMap,Ku=function(){document.addEventListener("mousedown",l(this,mo)),document.addEventListener("keydown",l(this,vo))},Ju=function(){document.removeEventListener("mousedown",l(this,mo)),document.removeEventListener("keydown",l(this,vo))},mo=new WeakMap,vo=new WeakMap,y(Xu,"properties",["placeholder","open","messages"]),y(Xu,"attributes",{placeholder:{type:String},open:{type:Boolean}});customElements.define("command-panel",Xu);class Qb extends Event{constructor(e){super("auth-submit",{bubbles:!0,composed:!0});y(this,"token");this.token=e}}class eM extends HTMLElement{constructor(){super(...arguments);y(this,"_invalid",!1);y(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 n=e.currentTarget;this._tokenValue=n.value}handleSubmit(e){e.preventDefault();const n=this._tokenValue.trim();n&&this.dispatchEvent(new Qb(n))}render(){Fe(H`
|
|
459
|
-
<modal-overlay open>
|
|
460
|
-
<section class="auth-modal">
|
|
461
|
-
<form class="auth-form" @submit=${e=>this.handleSubmit(e)}>
|
|
462
|
-
<h2 class="auth-modal-title">Enter access token</h2>
|
|
463
|
-
<p class="auth-modal-copy">This Television server requires a token.</p>
|
|
464
|
-
<label class="settings-field">
|
|
465
|
-
<span>Token</span>
|
|
466
|
-
<input
|
|
467
|
-
class=${this.invalid?"auth-token-input-invalid":""}
|
|
468
|
-
type="password"
|
|
469
|
-
name="token"
|
|
470
|
-
.value=${this.tokenValue}
|
|
471
|
-
@input=${e=>this.handleInput(e)}
|
|
472
|
-
required
|
|
473
|
-
/>
|
|
474
|
-
</label>
|
|
475
|
-
<button type="submit" class="settings-submit-button">Connect</button>
|
|
476
|
-
</form>
|
|
477
|
-
</section>
|
|
478
|
-
</modal-overlay>
|
|
479
|
-
`,this)}}customElements.get("auth-modal")||customElements.define("auth-modal",eM);class tM extends HTMLElement{constructor(){super(...arguments);y(this,"runtimeServerURL",My());y(this,"electronMode",Wh());y(this,"serverManager",Ft.resolve("ServerManager"));y(this,"screenManager",Ft.resolve("ScreenManager"));y(this,"connectError",null);y(this,"handleServerManagerChange",()=>{this.render()});y(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 n=e instanceof Qb?e.token:e instanceof CustomEvent&&typeof((i=e.detail)==null?void 0:i.token)=="string"?e.detail.token:null;n&&this.handleAuthSubmit(n)}),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,Nf());return}if(this.serverManager.activeServer)return;const e=new Oy({url:this.runtimeServerURL,name:"Server",token:Nf()});this.serverManager.add(e),this.serverManager.setActive(e);try{await e.connect(),this.connectError=null}catch(n){this.connectError=n instanceof Error&&!(n instanceof gu)?n.message:null}this.render()}async handleAuthSubmit(e){const n=this.serverManager.activeServer;if(n){this.connectError=null,n.token=e,this.updateTokenQueryParam(e);try{await n.connect()}catch(i){i instanceof gu||(this.connectError=i instanceof Error?i.message:String(i))}this.render()}}updateTokenQueryParam(e){const n=new URL(window.location.href);n.searchParams.set("token",e),window.history.replaceState({},"",`${n.pathname}${n.search}${n.hash}`)}render(){const e=this.serverManager.activeServer,n=(e==null?void 0:e.status)??null,i=this.screenManager.activeScreen,s=!!(e&&i&&this.screenManager.hasTab(e.url,i.id));if(n==="connecting"){Fe(H`
|
|
480
|
-
<main class="auth-gate"><p>Connecting...</p></main>
|
|
481
|
-
`,this);return}if(n==="disconnected"){const o=e;if(!o)return;Fe(H`
|
|
482
|
-
<main class="auth-gate">
|
|
483
|
-
<auth-modal
|
|
484
|
-
.invalid=${!!o.token}
|
|
485
|
-
.tokenValue=${o.token??""}
|
|
486
|
-
></auth-modal>
|
|
487
|
-
</main>
|
|
488
|
-
`,this);return}Fe(H`
|
|
489
|
-
<main>
|
|
490
|
-
${this.connectError?H`<p data-testid="auth-error">${this.connectError}</p>`:H`
|
|
491
|
-
${s?H`<screen-view></screen-view>`:null}
|
|
492
|
-
${n==="connected"?H`
|
|
493
|
-
<div class="chrome">
|
|
494
|
-
<div class="top-row" electron-draggable>
|
|
495
|
-
<screen-select></screen-select>
|
|
496
|
-
<menu-bar-clock></menu-bar-clock>
|
|
497
|
-
</div>
|
|
498
|
-
<command-panel></command-panel>
|
|
499
|
-
</div>
|
|
500
|
-
`:null}
|
|
501
|
-
`}
|
|
502
|
-
</main>
|
|
503
|
-
`,this)}}customElements.get("television-app")||customElements.define("television-app",tM);const rd=Wh(),nd=My(),ew=new BA(rd?"television-electron":"television-browser",FA(nd)),ar=new AL({localStore:ew,localServerURL:nd}),tw=new XA({localStore:ew,serverManager:ar}),rM=new $L,rw=()=>{const r=ar.activeServer;if(!r||r.status!=="connected"){za();return}r.client.display.get().then(t=>{if(!(ar.activeServer!==r||r.status!=="connected"))return Ny(t.activeThemeName,r)}).catch(()=>{ar.activeServer===r&&za()})};rw();ar.addEventListener("change",rw);ar.addEventListener("server-event",r=>{if(r.event.type!=="theme-changed")return;const t=ar.activeServer;!t||t.url!==r.serverURL||Ny(r.event.themeName,t)});Ft.register("ServerManager",()=>ar);Ft.register("ScreenManager",()=>tw);Ft.register("ShortcutService",()=>rM);globalThis.__telepath={screenManager:tw,serverManager:ar};const id=document.createElement("television-app");id.runtimeServerURL=nd;id.electronMode=rd;rd&&document.body.classList.add("electron");document.body.appendChild(id);
|