@telepath-computer/television 0.1.98 → 0.1.100
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.cjs +444 -434
- package/dist/skills/television/SKILL.md +215 -198
- package/dist/skills/television-calendar/SKILL.md +99 -0
- package/dist/skills/television-table/SKILL.md +89 -0
- package/dist/views/markdown/manifest.json +1 -1
- package/dist/web/assets/index-BteBsj8I.js +513 -0
- package/dist/web/index.html +1 -1
- package/package.json +1 -1
- package/dist/skills/artifact-calendar/SKILL.md +0 -151
- package/dist/skills/artifact-calendar/house-style.md +0 -67
- package/dist/skills/artifact-table/SKILL.md +0 -217
- package/dist/skills/artifact-table/house-style.md +0 -67
- package/dist/views/text/index.html +0 -38
- package/dist/views/text/manifest.json +0 -5
- package/dist/web/assets/index-Cf-KqGge.js +0 -513
- /package/dist/skills/{artifact-calendar → television-calendar}/calendar.css +0 -0
- /package/dist/skills/{artifact-calendar → television-calendar}/calendar.js +0 -0
|
@@ -0,0 +1,513 @@
|
|
|
1
|
+
var iw=Object.defineProperty;var _d=r=>{throw TypeError(r)};var sw=(r,t,e)=>t in r?iw(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var y=(r,t,e)=>sw(r,typeof t!="symbol"?t+"":t,e),Wl=(r,t,e)=>t.has(r)||_d("Cannot "+e);var l=(r,t,e)=>(Wl(r,t,"read from private field"),e?e.call(r):t.get(r)),w=(r,t,e)=>t.has(r)?_d("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(r):t.set(r,e),k=(r,t,e,n)=>(Wl(r,t,"write to private field"),n?n.call(r,e):t.set(r,e),e),f=(r,t,e)=>(Wl(r,t,"access private method"),e);var kd=(r,t,e,n)=>({set _(i){k(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 ow(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 xd=Object.prototype.toString,yg=function(t){var e=xd.call(t),n=e==="[object Arguments]";return n||(n=e!=="[object Array]"&&t!==null&&typeof t=="object"&&typeof t.length=="number"&&t.length>=0&&xd.call(t.callee)==="[object Function]"),n},Hl,Ed;function aw(){if(Ed)return Hl;Ed=1;var r;if(!Object.keys){var t=Object.prototype.hasOwnProperty,e=Object.prototype.toString,n=yg,i=Object.prototype.propertyIsEnumerable,s=!i.call({toString:null},"toString"),o=i.call(function(){},"prototype"),a=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],c=function(v){var m=v.constructor;return m&&m.prototype===v},u={$applicationCache:!0,$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$onmozfullscreenchange:!0,$onmozfullscreenerror:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},h=function(){if(typeof window>"u")return!1;for(var v in window)try{if(!u["$"+v]&&t.call(window,v)&&window[v]!==null&&typeof window[v]=="object")try{c(window[v])}catch{return!0}}catch{return!0}return!1}(),p=function(v){if(typeof window>"u"||!h)return c(v);try{return c(v)}catch{return!1}};r=function(m){var x=m!==null&&typeof m=="object",E=e.call(m)==="[object Function]",T=n(m),O=x&&e.call(m)==="[object String]",R=[];if(!x&&!E&&!T)throw new TypeError("Object.keys called on a non-object");var Z=o&&E;if(O&&m.length>0&&!t.call(m,0))for(var F=0;F<m.length;++F)R.push(String(F));if(T&&m.length>0)for(var V=0;V<m.length;++V)R.push(String(V));else for(var N in m)!(Z&&N==="prototype")&&t.call(m,N)&&R.push(String(N));if(s)for(var J=p(m),j=0;j<a.length;++j)!(J&&a[j]==="constructor")&&t.call(m,a[j])&&R.push(a[j]);return R}}return Hl=r,Hl}var lw=Array.prototype.slice,cw=yg,Ad=Object.keys,ia=Ad?function(t){return Ad(t)}:aw(),$d=Object.keys;ia.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 cw(n)?$d(lw.call(n)):$d(n)})}else Object.keys=ia;return Object.keys||ia};var uw=ia,sa=Object.defineProperty||!1;if(sa)try{sa({},"a",{value:1})}catch{sa=!1}var mo=sa,hr=SyntaxError,X=TypeError,hw=Object.getOwnPropertyDescriptor,oa=hw;if(oa)try{oa([],"length")}catch{oa=null}var Ti=oa,Id=mo,dw=hr,On=X,Td=Ti,bg=function(t,e,n){if(!t||typeof t!="object"&&typeof t!="function")throw new On("`obj` must be an object or a function`");if(typeof e!="string"&&typeof e!="symbol")throw new On("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new On("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new On("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new On("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new On("`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=!!Td&&Td(t,e);if(Id)Id(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 dw("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},Lc=mo,wg=function(){return!!Lc};wg.hasArrayLengthDefineBug=function(){if(!Lc)return null;try{return Lc([],"length",{value:1}).length!==1}catch{return!0}};var cl=wg,pw=uw,fw=typeof Symbol=="function"&&typeof Symbol("foo")=="symbol",gw=Object.prototype.toString,mw=Array.prototype.concat,Cd=bg,vw=function(r){return typeof r=="function"&&gw.call(r)==="[object Function]"},Sg=cl(),yw=function(r,t,e,n){if(t in r){if(n===!0){if(r[t]===e)return}else if(!vw(n)||!n())return}Sg?Cd(r,t,e,!0):Cd(r,t,e)},_g=function(r,t){var e=arguments.length>2?arguments[2]:{},n=pw(t);fw&&(n=mw.call(n,Object.getOwnPropertySymbols(t)));for(var i=0;i<n.length;i+=1)yw(r,n[i],t[n[i]],e[n[i]])};_g.supportsDescriptors=!!Sg;var An=_g,aa={exports:{}};typeof self<"u"?aa.exports=self:typeof window<"u"?aa.exports=window:aa.exports=Function("return this")();var kg=aa.exports,bw=kg,xg=function(){return typeof Vr!="object"||!Vr||Vr.Math!==Math||Vr.Array!==Array?bw:Vr},ww=An,Sw=Ti,_w=xg,kw=function(){var t=_w();if(ww.supportsDescriptors){var e=Sw(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},xw=An,Ew=kg,Eg=xg,Aw=kw,$w=Eg(),Ag=function(){return $w};xw(Ag,{getPolyfill:Eg,implementation:Ew,shim:Aw});var Vu=Ag,dr=function(t){return!!t&&(typeof t=="function"||typeof t=="object")},Gu=Object,$g=Error,Iw=EvalError,Tw=RangeError,ju=ReferenceError,Cw=URIError,Rw=Math.abs,Pw=Math.floor,Dw=Math.max,Lw=Math.min,zw=Math.pow,Ow=Math.round,qu=Number.isNaN||function(t){return t!==t},Mw=qu,Nw=function(t){return Mw(t)||t===0?t:t<0?-1:1},Ci=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},Rd=typeof Symbol<"u"&&Symbol,Uw=Ci,Yu=function(){return typeof Rd!="function"||typeof Symbol!="function"||typeof Rd("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:Uw()},Ig=typeof Reflect<"u"&&Reflect.getPrototypeOf||null,Fw=Gu,Tg=Fw.getPrototypeOf||null,Ww="Function.prototype.bind called on incompatible ",Hw=Object.prototype.toString,Zw=Math.max,Bw="[object Function]",Pd=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},Vw=function(t,e){for(var n=[],i=e,s=0;i<t.length;i+=1,s+=1)n[s]=t[i];return n},Gw=function(r,t){for(var e="",n=0;n<r.length;n+=1)e+=r[n],n+1<r.length&&(e+=t);return e},jw=function(t){var e=this;if(typeof e!="function"||Hw.apply(e)!==Bw)throw new TypeError(Ww+e);for(var n=Vw(arguments,1),i,s=function(){if(this instanceof i){var h=e.apply(this,Pd(n,arguments));return Object(h)===h?h:this}return e.apply(t,Pd(n,arguments))},o=Zw(0,e.length-n.length),a=[],c=0;c<o;c++)a[c]="$"+c;if(i=Function("binder","return function ("+Gw(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},qw=jw,vo=Function.prototype.bind||qw,Xu=Function.prototype.call,Ku=Function.prototype.apply,Yw=typeof Reflect<"u"&&Reflect&&Reflect.apply,Xw=vo,Kw=Ku,Jw=Xu,Qw=Yw,Cg=Qw||Xw.call(Jw,Kw),eS=vo,tS=X,rS=Xu,nS=Cg,ul=function(t){if(t.length<1||typeof t[0]!="function")throw new tS("a function is required");return nS(eS,rS,t)},iS=ul,Dd=Ti,Rg;try{Rg=[].__proto__===Array.prototype}catch(r){if(!r||typeof r!="object"||!("code"in r)||r.code!=="ERR_PROTO_ACCESS")throw r}var Zl=!!Rg&&Dd&&Dd(Object.prototype,"__proto__"),Pg=Object,Ld=Pg.getPrototypeOf,sS=Zl&&typeof Zl.get=="function"?iS([Zl.get]):typeof Ld=="function"?function(t){return Ld(t==null?t:Pg(t))}:!1,zd=Ig,Od=Tg,Md=sS,Dg=zd?function(t){return zd(t)}:Od?function(t){if(!t||typeof t!="object"&&typeof t!="function")throw new TypeError("getProto: not an object");return Od(t)}:Md?function(t){return Md(t)}:null,oS=Function.prototype.call,aS=Object.prototype.hasOwnProperty,lS=vo,pr=lS.call(oS,aS),Y,cS=Gu,uS=$g,hS=Iw,dS=Tw,pS=ju,ki=hr,ri=X,fS=Cw,gS=Rw,mS=Pw,vS=Dw,yS=Lw,bS=zw,wS=Ow,SS=Nw,Lg=Function,Bl=function(r){try{return Lg('"use strict"; return ('+r+").constructor;")()}catch{}},ms=Ti,_S=mo,Vl=function(){throw new ri},kS=ms?function(){try{return arguments.callee,Vl}catch{try{return ms(arguments,"callee").get}catch{return Vl}}}():Vl,Mn=Yu(),Ce=Dg,xS=Tg,ES=Ig,zg=Ku,yo=Xu,Hn={},AS=typeof Uint8Array>"u"||!Ce?Y:Ce(Uint8Array),bn={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?Y:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?Y:ArrayBuffer,"%ArrayIteratorPrototype%":Mn&&Ce?Ce([][Symbol.iterator]()):Y,"%AsyncFromSyncIteratorPrototype%":Y,"%AsyncFunction%":Hn,"%AsyncGenerator%":Hn,"%AsyncGeneratorFunction%":Hn,"%AsyncIteratorPrototype%":Hn,"%Atomics%":typeof Atomics>"u"?Y:Atomics,"%BigInt%":typeof BigInt>"u"?Y:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?Y:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?Y:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?Y:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":uS,"%eval%":eval,"%EvalError%":hS,"%Float16Array%":typeof Float16Array>"u"?Y:Float16Array,"%Float32Array%":typeof Float32Array>"u"?Y:Float32Array,"%Float64Array%":typeof Float64Array>"u"?Y:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?Y:FinalizationRegistry,"%Function%":Lg,"%GeneratorFunction%":Hn,"%Int8Array%":typeof Int8Array>"u"?Y:Int8Array,"%Int16Array%":typeof Int16Array>"u"?Y:Int16Array,"%Int32Array%":typeof Int32Array>"u"?Y:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":Mn&&Ce?Ce(Ce([][Symbol.iterator]())):Y,"%JSON%":typeof JSON=="object"?JSON:Y,"%Map%":typeof Map>"u"?Y:Map,"%MapIteratorPrototype%":typeof Map>"u"||!Mn||!Ce?Y:Ce(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":cS,"%Object.getOwnPropertyDescriptor%":ms,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?Y:Promise,"%Proxy%":typeof Proxy>"u"?Y:Proxy,"%RangeError%":dS,"%ReferenceError%":pS,"%Reflect%":typeof Reflect>"u"?Y:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?Y:Set,"%SetIteratorPrototype%":typeof Set>"u"||!Mn||!Ce?Y:Ce(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?Y:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":Mn&&Ce?Ce(""[Symbol.iterator]()):Y,"%Symbol%":Mn?Symbol:Y,"%SyntaxError%":ki,"%ThrowTypeError%":kS,"%TypedArray%":AS,"%TypeError%":ri,"%Uint8Array%":typeof Uint8Array>"u"?Y:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?Y:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?Y:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?Y:Uint32Array,"%URIError%":fS,"%WeakMap%":typeof WeakMap>"u"?Y:WeakMap,"%WeakRef%":typeof WeakRef>"u"?Y:WeakRef,"%WeakSet%":typeof WeakSet>"u"?Y:WeakSet,"%Function.prototype.call%":yo,"%Function.prototype.apply%":zg,"%Object.defineProperty%":_S,"%Object.getPrototypeOf%":xS,"%Math.abs%":gS,"%Math.floor%":mS,"%Math.max%":vS,"%Math.min%":yS,"%Math.pow%":bS,"%Math.round%":wS,"%Math.sign%":SS,"%Reflect.getPrototypeOf%":ES};if(Ce)try{null.error}catch(r){var $S=Ce(Ce(r));bn["%Error.prototype%"]=$S}var IS=function r(t){var e;if(t==="%AsyncFunction%")e=Bl("async function () {}");else if(t==="%GeneratorFunction%")e=Bl("function* () {}");else if(t==="%AsyncGeneratorFunction%")e=Bl("async function* () {}");else if(t==="%AsyncGenerator%"){var n=r("%AsyncGeneratorFunction%");n&&(e=n.prototype)}else if(t==="%AsyncIteratorPrototype%"){var i=r("%AsyncGenerator%");i&&Ce&&(e=Ce(i.prototype))}return bn[t]=e,e},Nd={__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"]},bo=vo,Ia=pr,TS=bo.call(yo,Array.prototype.concat),CS=bo.call(zg,Array.prototype.splice),Ud=bo.call(yo,String.prototype.replace),Ta=bo.call(yo,String.prototype.slice),RS=bo.call(yo,RegExp.prototype.exec),PS=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,DS=/\\(\\)?/g,LS=function(t){var e=Ta(t,0,1),n=Ta(t,-1);if(e==="%"&&n!=="%")throw new ki("invalid intrinsic syntax, expected closing `%`");if(n==="%"&&e!=="%")throw new ki("invalid intrinsic syntax, expected opening `%`");var i=[];return Ud(t,PS,function(s,o,a,c){i[i.length]=a?Ud(c,DS,"$1"):o||s}),i},zS=function(t,e){var n=t,i;if(Ia(Nd,n)&&(i=Nd[n],n="%"+i[0]+"%"),Ia(bn,n)){var s=bn[n];if(s===Hn&&(s=IS(n)),typeof s>"u"&&!e)throw new ri("intrinsic "+t+" exists, but is not available. Please file an issue!");return{alias:i,name:n,value:s}}throw new ki("intrinsic "+t+" does not exist!")},vt=function(t,e){if(typeof t!="string"||t.length===0)throw new ri("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof e!="boolean")throw new ri('"allowMissing" argument must be a boolean');if(RS(/^%?[^%]*%?$/,t)===null)throw new ki("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var n=LS(t),i=n.length>0?n[0]:"",s=zS("%"+i+"%",e),o=s.name,a=s.value,c=!1,u=s.alias;u&&(i=u[0],CS(n,TS([0,1],u)));for(var h=1,p=!0;h<n.length;h+=1){var v=n[h],m=Ta(v,0,1),x=Ta(v,-1);if((m==='"'||m==="'"||m==="`"||x==='"'||x==="'"||x==="`")&&m!==x)throw new ki("property names with quotes must have matching quotes");if((v==="constructor"||!p)&&(c=!0),i+="."+v,o="%"+i+"%",Ia(bn,o))a=bn[o];else if(a!=null){if(!(v in a)){if(!e)throw new ri("base intrinsic for "+t+" exists, but the property is not available.");return}if(ms&&h+1>=n.length){var E=ms(a,v);p=!!E,p&&"get"in E&&!("originalValue"in E.get)?a=E.get:a=a[v]}else p=Ia(a,v),a=a[v];p&&!c&&(bn[o]=a)}}return a},Gl,Fd;function Lr(){if(Fd)return Gl;Fd=1;var r=vt,t=ul,e=t([r("%String.prototype.indexOf%")]);return Gl=function(i,s){var o=r(i,!!s);return typeof o=="function"&&e(i,".prototype.")>-1?t([o]):o},Gl}var jl,Wd;function Ju(){if(Wd)return jl;Wd=1;var r=vt,t=r("%Array%"),e=!t.isArray&&Lr()("Object.prototype.toString");return jl=t.isArray||function(i){return e(i)==="[object Array]"},jl}var OS=cl,Hd=mo,Og=OS.hasArrayLengthDefineBug(),MS=Og&&Ju(),NS=Lr(),US=NS("Object.prototype.propertyIsEnumerable"),Qu=function(t,e,n,i,s,o){if(!Hd){if(!t(o)||!o["[[Configurable]]"]||!o["[[Writable]]"]||s in i&&US(i,s)!==!!o["[[Enumerable]]"])return!1;var a=o["[[Value]]"];return i[s]=a,e(i[s],a)}return Og&&s==="length"&&"[[Value]]"in o&&MS(i)&&i.length!==o["[[Value]]"]?(i.length=o["[[Value]]"],i.length===o["[[Value]]"]):(Hd(i,s,n(o)),!0)},FS=X,Vi=pr,WS={__proto__:null,"[[Configurable]]":!0,"[[Enumerable]]":!0,"[[Get]]":!0,"[[Set]]":!0,"[[Value]]":!0,"[[Writable]]":!0},Ri=function(t){if(!t||typeof t!="object")return!1;for(var e in t)if(Vi(t,e)&&!WS[e])return!1;var n=Vi(t,"[[Value]]")||Vi(t,"[[Writable]]"),i=Vi(t,"[[Get]]")||Vi(t,"[[Set]]");if(n&&i)throw new FS("Property Descriptors may not be both accessor and data descriptors");return!0},Mg=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},HS=X,ZS=Ri,BS=Mg,Ng=function(t){if(typeof t<"u"&&!ZS(t))throw new HS("Assertion failed: `Desc` must be a Property Descriptor");return BS(t)},VS=X,Zd=pr,GS=Ri,Ug=function(t){if(typeof t>"u")return!1;if(!GS(t))throw new VS("Assertion failed: `Desc` must be a Property Descriptor");return!(!Zd(t,"[[Value]]")&&!Zd(t,"[[Writable]]"))},Pi=function(t){return typeof t=="string"||typeof t=="symbol"},Bd=qu,Fg=function(t,e){return t===e?t===0?1/t===1/e:!0:Bd(t)&&Bd(e)},Vd=X,jS=dr,qS=Qu,YS=Ng,XS=Ug,KS=Pi,JS=Fg,eh=function(t,e,n){if(!jS(t))throw new Vd("Assertion failed: Type(O) is not Object");if(!KS(e))throw new Vd("Assertion failed: P is not a Property Key");var i={"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Value]]":n,"[[Writable]]":!0};return qS(XS,JS,YS,t,e,i)},Wg=Function.prototype.toString,Jn=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,zc,la;if(typeof Jn=="function"&&typeof Object.defineProperty=="function")try{zc=Object.defineProperty({},"length",{get:function(){throw la}}),la={},Jn(function(){throw 42},null,zc)}catch(r){r!==la&&(Jn=null)}else Jn=null;var QS=/^\s*class\b/,Oc=function(t){try{var e=Wg.call(t);return QS.test(e)}catch{return!1}},ql=function(t){try{return Oc(t)?!1:(Wg.call(t),!0)}catch{return!1}},ca=Object.prototype.toString,e0="[object Object]",t0="[object Function]",r0="[object GeneratorFunction]",n0="[object HTMLAllCollection]",i0="[object HTML document.all class]",s0="[object HTMLCollection]",o0=typeof Symbol=="function"&&!!Symbol.toStringTag,a0=!(0 in[,]),Mc=function(){return!1};if(typeof document=="object"){var l0=document.all;ca.call(l0)===ca.call(document.all)&&(Mc=function(t){if((a0||!t)&&(typeof t>"u"||typeof t=="object"))try{var e=ca.call(t);return(e===n0||e===i0||e===s0||e===e0)&&t("")==null}catch{}return!1})}var Hg=Jn?function(t){if(Mc(t))return!0;if(!t||typeof t!="function"&&typeof t!="object")return!1;try{Jn(t,null,zc)}catch(e){if(e!==la)return!1}return!Oc(t)&&ql(t)}:function(t){if(Mc(t))return!0;if(!t||typeof t!="function"&&typeof t!="object")return!1;if(o0)return ql(t);if(Oc(t))return!1;var e=ca.call(t);return e!==t0&&e!==r0&&!/^\[object HTML/.test(e)?!1:ql(t)},c0=Hg,u0=function(t){return!!t},Rt=pr,Uo=X,h0=dr,Gd=c0,Yl=u0,d0=function(t){if(!h0(t))throw new Uo("ToPropertyDescriptor requires an object");var e={};if(Rt(t,"enumerable")&&(e["[[Enumerable]]"]=Yl(t.enumerable)),Rt(t,"configurable")&&(e["[[Configurable]]"]=Yl(t.configurable)),Rt(t,"value")&&(e["[[Value]]"]=t.value),Rt(t,"writable")&&(e["[[Writable]]"]=Yl(t.writable)),Rt(t,"get")){var n=t.get;if(typeof n<"u"&&!Gd(n))throw new Uo("getter must be a function");e["[[Get]]"]=n}if(Rt(t,"set")){var i=t.set;if(typeof i<"u"&&!Gd(i))throw new Uo("setter must be a function");e["[[Set]]"]=i}if((Rt(e,"[[Get]]")||Rt(e,"[[Set]]"))&&(Rt(e,"[[Value]]")||Rt(e,"[[Writable]]")))throw new Uo("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute");return e},Xl=X,p0=dr,jd=Ri,f0=Qu,g0=Ng,m0=Ug,v0=Pi,y0=Fg,b0=d0,w0=function(t,e,n){if(!p0(t))throw new Xl("Assertion failed: Type(O) is not Object");if(!v0(e))throw new Xl("Assertion failed: P is not a Property Key");var i=jd(n)?n:b0(n);if(!jd(i))throw new Xl("Assertion failed: Desc is not a valid Property Descriptor");return f0(m0,y0,g0,t,e,i)},qd=X,S0=dr,_0=w0,k0=Pi,x0=function(t,e,n){if(!S0(t))throw new qd("Assertion failed: Type(O) is not Object");if(!k0(e))throw new qd("Assertion failed: P is not a Property Key");var i={"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Value]]":n,"[[Writable]]":!0};return _0(t,e,i)},E0=typeof Reflect<"u"&&Reflect.setPrototypeOf||null,A0=Gu,$0=A0.setPrototypeOf||null,I0=ul,Yd=Ti,T0=X,Zg={};try{Zg.__proto__=null}catch(r){if(!r||typeof r!="object"||!("code"in r)||r.code!=="ERR_PROTO_ACCESS")throw r}var C0=!("toString"in Zg),Kl=Yd&&Yd(Object.prototype,"__proto__"),R0=C0&&(!!Kl&&typeof Kl.set=="function"&&I0([Kl.set])||function(t,e){if(t==null)throw new T0("set Object.prototype.__proto__ called on null or undefined");return t.__proto__=e,e}),Xd=E0,P0=$0,Kd=R0,D0=X,L0=Xd?function(t,e){if(Xd(t,e))return t;throw new D0("Reflect.setPrototypeOf: failed to set [[Prototype]]")}:P0||(Kd?function(t,e){return Kd(t,e),t}:null),Jd=X,z0=dr,Qd=Dg,O0=function(t){if(!z0(t))throw new Jd("Assertion failed: O must be an Object");if(!Qd)throw new Jd("This environment does not support fetching prototypes.");return Qd(t)},M0=X,N0=L0,U0=dr,F0=O0,W0=function(t,e){if(e!==null&&!U0(e))throw new M0("Assertion failed: V must be Object or Null");try{N0(t,e)}catch{return!1}return F0(t)===e},Jl=eh,ep=x0,Bg=W0,H0=cl(),th=$g;function wo(r,t,e){var n=new th(e);return Bg(n,ua),delete n.constructor,ep(n,"error",r),ep(n,"suppressed",t),n}H0&&Object.defineProperty(wo,"prototype",{writable:!1});var ua=wo.prototype;if(!Jl(ua,"constructor",wo)||!Jl(ua,"message","")||!Jl(ua,"name","SuppressedError"))throw new th("unable to install SuppressedError.prototype properties; please report this!");Bg(wo.prototype,th.prototype);var Z0=wo,B0=Z0,Vg=function(){return typeof SuppressedError=="function"?SuppressedError:B0},V0=An,tp=Vu(),G0=Vg,j0=function(){var t=G0();return V0(tp,{SuppressedError:t},{SuppressedError:function(){return tp.SuppressedError!==t}}),t};j0();var q0=X,Y0=Ri,X0=Mg,K0=function(t){if(typeof t<"u"&&!Y0(t))throw new q0("Assertion failed: `Desc` must be a Property Descriptor");return X0(t)},J0=X,rp=pr,Q0=Ri,e_=function(t){if(typeof t>"u")return!1;if(!Q0(t))throw new J0("Assertion failed: `Desc` must be a Property Descriptor");return!(!rp(t,"[[Value]]")&&!rp(t,"[[Writable]]"))},np=qu,t_=function(t,e){return t===e?t===0?1/t===1/e:!0:np(t)&&np(e)},Di=Hg,r_=function(t){return!!t},Pt=pr,Fo=X,n_=dr,ip=Di,Ql=r_,i_=function(t){if(!n_(t))throw new Fo("ToPropertyDescriptor requires an object");var e={};if(Pt(t,"enumerable")&&(e["[[Enumerable]]"]=Ql(t.enumerable)),Pt(t,"configurable")&&(e["[[Configurable]]"]=Ql(t.configurable)),Pt(t,"value")&&(e["[[Value]]"]=t.value),Pt(t,"writable")&&(e["[[Writable]]"]=Ql(t.writable)),Pt(t,"get")){var n=t.get;if(typeof n<"u"&&!ip(n))throw new Fo("getter must be a function");e["[[Get]]"]=n}if(Pt(t,"set")){var i=t.set;if(typeof i<"u"&&!ip(i))throw new Fo("setter must be a function");e["[[Set]]"]=i}if((Pt(e,"[[Get]]")||Pt(e,"[[Set]]"))&&(Pt(e,"[[Value]]")||Pt(e,"[[Writable]]")))throw new Fo("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute");return e},ec=X,s_=dr,sp=Ri,o_=Qu,a_=K0,l_=e_,c_=Pi,u_=t_,h_=i_,So=function(t,e,n){if(!s_(t))throw new ec("Assertion failed: Type(O) is not Object");if(!c_(e))throw new ec("Assertion failed: P is not a Property Key");var i=sp(n)?n:h_(n);if(!sp(i))throw new ec("Assertion failed: Desc is not a valid Property Descriptor");return o_(l_,u_,a_,t,e,i)},d_=Ci(),p_=d_?Symbol.dispose||Symbol("Symbol.dispose"):null,f_=Ci,g_=p_,rh=function(){return f_()&&Symbol.dispose||g_},m_=Yu,v_=So,y_=rh,b_=function(){var t=y_();return m_()&&v_(Symbol,"dispose",{"[[Configurable]]":!1,"[[Enumerable]]":!1,"[[Writable]]":!1,"[[Value]]":t}),t},w_=Ci(),S_=w_?Symbol.asyncDispose||Symbol("Symbol.asyncDispose"):null,__=Ci,k_=S_,nh=function(){return __()&&Symbol.asyncDispose||k_},x_=Yu,E_=So,A_=nh,$_=function(){var t=A_();return x_()&&E_(Symbol,"asyncDispose",{"[[Configurable]]":!1,"[[Enumerable]]":!1,"[[Writable]]":!1,"[[Value]]":t}),t},I_=Ju(),T_=vt,C_=Lr(),R_=X,P_=I_,D_=T_("%Reflect.apply%",!0)||C_("Function.prototype.apply"),hl=function(t,e){var n=arguments.length>2?arguments[2]:[];if(!P_(n))throw new R_("Assertion failed: optional `argumentsList`, if provided, must be a List");return D_(t,e,n)};const L_={},z_=Object.freeze(Object.defineProperty({__proto__:null,default:L_},Symbol.toStringTag,{value:"Module"})),O_=ow(z_);var ih=typeof Map=="function"&&Map.prototype,tc=Object.getOwnPropertyDescriptor&&ih?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,Ca=ih&&tc&&typeof tc.get=="function"?tc.get:null,op=ih&&Map.prototype.forEach,sh=typeof Set=="function"&&Set.prototype,rc=Object.getOwnPropertyDescriptor&&sh?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,Ra=sh&&rc&&typeof rc.get=="function"?rc.get:null,ap=sh&&Set.prototype.forEach,M_=typeof WeakMap=="function"&&WeakMap.prototype,hs=M_?WeakMap.prototype.has:null,N_=typeof WeakSet=="function"&&WeakSet.prototype,ds=N_?WeakSet.prototype.has:null,U_=typeof WeakRef=="function"&&WeakRef.prototype,lp=U_?WeakRef.prototype.deref:null,F_=Boolean.prototype.valueOf,W_=Object.prototype.toString,H_=Function.prototype.toString,Z_=String.prototype.match,oh=String.prototype.slice,$r=String.prototype.replace,B_=String.prototype.toUpperCase,cp=String.prototype.toLowerCase,Gg=RegExp.prototype.test,up=Array.prototype.concat,Ht=Array.prototype.join,V_=Array.prototype.slice,hp=Math.floor,Nc=typeof BigInt=="function"?BigInt.prototype.valueOf:null,nc=Object.getOwnPropertySymbols,Uc=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,xi=typeof Symbol=="function"&&typeof Symbol.iterator=="object",ps=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===xi||!0)?Symbol.toStringTag:null,jg=Object.prototype.propertyIsEnumerable,dp=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(r){return r.__proto__}:null);function pp(r,t){if(r===1/0||r===-1/0||r!==r||r&&r>-1e3&&r<1e3||Gg.call(/e/,t))return t;var e=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof r=="number"){var n=r<0?-hp(-r):hp(r);if(n!==r){var i=String(n),s=oh.call(t,i.length+1);return $r.call(i,e,"$&_")+"."+$r.call($r.call(s,/([0-9]{3})/g,"$&_"),/_$/,"")}}return $r.call(t,e,"$&_")}var Fc=O_,fp=Fc.custom,gp=Xg(fp)?fp:null,qg={__proto__:null,double:'"',single:"'"},G_={__proto__:null,double:/(["\\])/g,single:/(['\\])/g},Li=function r(t,e,n,i){var s=e||{};if(Jt(s,"quoteStyle")&&!Jt(qg,s.quoteStyle))throw new TypeError('option "quoteStyle" must be "single" or "double"');if(Jt(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=Jt(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(Jt(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(Jt(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 Jg(t,s);if(typeof t=="number"){if(t===0)return 1/0/t>0?"0":"-0";var c=String(t);return a?pp(t,c):c}if(typeof t=="bigint"){var u=String(t)+"n";return a?pp(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 Wc(t)?"[Array]":"[Object]";var p=uk(s,n);if(typeof i>"u")i=[];else if(Kg(i,t)>=0)return"[Circular]";function v(ht,It,Tl){if(It&&(i=V_.call(i),i.push(It)),Tl){var Co={depth:s.depth};return Jt(s,"quoteStyle")&&(Co.quoteStyle=s.quoteStyle),r(ht,Co,n+1,i)}return r(ht,s,n+1,i)}if(typeof t=="function"&&!mp(t)){var m=tk(t),x=Wo(t,v);return"[Function"+(m?": "+m:" (anonymous)")+"]"+(x.length>0?" { "+Ht.call(x,", ")+" }":"")}if(Xg(t)){var E=xi?$r.call(String(t),/^(Symbol\(.*\))_[^)]*$/,"$1"):Uc.call(t);return typeof t=="object"&&!xi?Gi(E):E}if(ak(t)){for(var T="<"+cp.call(String(t.nodeName)),O=t.attributes||[],R=0;R<O.length;R++)T+=" "+O[R].name+"="+Yg(j_(O[R].value),"double",s);return T+=">",t.childNodes&&t.childNodes.length&&(T+="..."),T+="</"+cp.call(String(t.nodeName))+">",T}if(Wc(t)){if(t.length===0)return"[]";var Z=Wo(t,v);return p&&!ck(Z)?"["+Hc(Z,p)+"]":"[ "+Ht.call(Z,", ")+" ]"}if(Y_(t)){var F=Wo(t,v);return!("cause"in Error.prototype)&&"cause"in t&&!jg.call(t,"cause")?"{ ["+String(t)+"] "+Ht.call(up.call("[cause]: "+v(t.cause),F),", ")+" }":F.length===0?"["+String(t)+"]":"{ ["+String(t)+"] "+Ht.call(F,", ")+" }"}if(typeof t=="object"&&o){if(gp&&typeof t[gp]=="function"&&Fc)return Fc(t,{depth:h-n});if(o!=="symbol"&&typeof t.inspect=="function")return t.inspect()}if(rk(t)){var V=[];return op&&op.call(t,function(ht,It){V.push(v(It,t,!0)+" => "+v(ht,t))}),vp("Map",Ca.call(t),V,p)}if(sk(t)){var N=[];return ap&&ap.call(t,function(ht){N.push(v(ht,t))}),vp("Set",Ra.call(t),N,p)}if(nk(t))return ic("WeakMap");if(ok(t))return ic("WeakSet");if(ik(t))return ic("WeakRef");if(K_(t))return Gi(v(Number(t)));if(Q_(t))return Gi(v(Nc.call(t)));if(J_(t))return Gi(F_.call(t));if(X_(t))return Gi(v(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(!q_(t)&&!mp(t)){var J=Wo(t,v),j=dp?dp(t)===Object.prototype:t instanceof Object||t.constructor===Object,ot=t instanceof Object?"":"null prototype",At=!j&&ps&&Object(t)===t&&ps in t?oh.call(zr(t),8,-1):ot?"Object":"",ye=j||typeof t.constructor!="function"?"":t.constructor.name?t.constructor.name+" ":"",$t=ye+(At||ot?"["+Ht.call(up.call([],At||[],ot||[]),": ")+"] ":"");return J.length===0?$t+"{}":p?$t+"{"+Hc(J,p)+"}":$t+"{ "+Ht.call(J,", ")+" }"}return String(t)};function Yg(r,t,e){var n=e.quoteStyle||t,i=qg[n];return i+r+i}function j_(r){return $r.call(String(r),/"/g,""")}function $n(r){return!ps||!(typeof r=="object"&&(ps in r||typeof r[ps]<"u"))}function Wc(r){return zr(r)==="[object Array]"&&$n(r)}function q_(r){return zr(r)==="[object Date]"&&$n(r)}function mp(r){return zr(r)==="[object RegExp]"&&$n(r)}function Y_(r){return zr(r)==="[object Error]"&&$n(r)}function X_(r){return zr(r)==="[object String]"&&$n(r)}function K_(r){return zr(r)==="[object Number]"&&$n(r)}function J_(r){return zr(r)==="[object Boolean]"&&$n(r)}function Xg(r){if(xi)return r&&typeof r=="object"&&r instanceof Symbol;if(typeof r=="symbol")return!0;if(!r||typeof r!="object"||!Uc)return!1;try{return Uc.call(r),!0}catch{}return!1}function Q_(r){if(!r||typeof r!="object"||!Nc)return!1;try{return Nc.call(r),!0}catch{}return!1}var ek=Object.prototype.hasOwnProperty||function(r){return r in this};function Jt(r,t){return ek.call(r,t)}function zr(r){return W_.call(r)}function tk(r){if(r.name)return r.name;var t=Z_.call(H_.call(r),/^function\s*([\w$]+)/);return t?t[1]:null}function Kg(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 rk(r){if(!Ca||!r||typeof r!="object")return!1;try{Ca.call(r);try{Ra.call(r)}catch{return!0}return r instanceof Map}catch{}return!1}function nk(r){if(!hs||!r||typeof r!="object")return!1;try{hs.call(r,hs);try{ds.call(r,ds)}catch{return!0}return r instanceof WeakMap}catch{}return!1}function ik(r){if(!lp||!r||typeof r!="object")return!1;try{return lp.call(r),!0}catch{}return!1}function sk(r){if(!Ra||!r||typeof r!="object")return!1;try{Ra.call(r);try{Ca.call(r)}catch{return!0}return r instanceof Set}catch{}return!1}function ok(r){if(!ds||!r||typeof r!="object")return!1;try{ds.call(r,ds);try{hs.call(r,hs)}catch{return!0}return r instanceof WeakSet}catch{}return!1}function ak(r){return!r||typeof r!="object"?!1:typeof HTMLElement<"u"&&r instanceof HTMLElement?!0:typeof r.nodeName=="string"&&typeof r.getAttribute=="function"}function Jg(r,t){if(r.length>t.maxStringLength){var e=r.length-t.maxStringLength,n="... "+e+" more character"+(e>1?"s":"");return Jg(oh.call(r,0,t.maxStringLength),t)+n}var i=G_[t.quoteStyle||"single"];i.lastIndex=0;var s=$r.call($r.call(r,i,"\\$1"),/[\x00-\x1f]/g,lk);return Yg(s,"single",t)}function lk(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":"")+B_.call(t.toString(16))}function Gi(r){return"Object("+r+")"}function ic(r){return r+" { ? }"}function vp(r,t,e,n){var i=n?Hc(e,n):Ht.call(e,", ");return r+" ("+t+") {"+i+"}"}function ck(r){for(var t=0;t<r.length;t++)if(Kg(r[t],`
|
|
2
|
+
`)>=0)return!1;return!0}function uk(r,t){var e;if(r.indent===" ")e=" ";else if(typeof r.indent=="number"&&r.indent>0)e=Ht.call(Array(r.indent+1)," ");else return null;return{base:e,prev:Ht.call(Array(t+1),e)}}function Hc(r,t){if(r.length===0)return"";var e=`
|
|
3
|
+
`+t.prev+t.base;return e+Ht.call(r,","+e)+`
|
|
4
|
+
`+t.prev}function Wo(r,t){var e=Wc(r),n=[];if(e){n.length=r.length;for(var i=0;i<r.length;i++)n[i]=Jt(r,i)?t(r[i],r):""}var s=typeof nc=="function"?nc(r):[],o;if(xi){o={};for(var a=0;a<s.length;a++)o["$"+s[a]]=s[a]}for(var c in r)Jt(r,c)&&(e&&String(Number(c))===c&&c<r.length||xi&&o["$"+c]instanceof Symbol||(Gg.call(/[^\w$]/,c)?n.push(t(c,r)+": "+t(r[c],r)):n.push(c+": "+t(r[c],r))));if(typeof nc=="function")for(var u=0;u<s.length;u++)jg.call(r,s[u])&&n.push("["+t(s[u])+"]: "+t(r[s[u]],r));return n}var hk=Li,dk=X,dl=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},pk=function(r,t){if(r){var e=dl(r,t);return e&&e.value}},fk=function(r,t,e){var n=dl(r,t);n?n.value=e:r.next={key:t,next:r.next,value:e}},gk=function(r,t){return r?!!dl(r,t):!1},mk=function(r,t){if(r)return dl(r,t,!0)},vk=function(){var t,e={assert:function(n){if(!e.has(n))throw new dk("Side channel does not contain "+hk(n))},delete:function(n){var i=t&&t.next,s=mk(t,n);return s&&i&&i===s&&(t=void 0),!!s},get:function(n){return pk(t,n)},has:function(n){return gk(t,n)},set:function(n,i){t||(t={next:void 0}),fk(t,n,i)}};return e},yk=vt,_o=Lr(),bk=Li,wk=X,yp=yk("%Map%",!0),Sk=_o("Map.prototype.get",!0),_k=_o("Map.prototype.set",!0),kk=_o("Map.prototype.has",!0),xk=_o("Map.prototype.delete",!0),Ek=_o("Map.prototype.size",!0),Qg=!!yp&&function(){var t,e={assert:function(n){if(!e.has(n))throw new wk("Side channel does not contain "+bk(n))},delete:function(n){if(t){var i=xk(t,n);return Ek(t)===0&&(t=void 0),i}return!1},get:function(n){if(t)return Sk(t,n)},has:function(n){return t?kk(t,n):!1},set:function(n,i){t||(t=new yp),_k(t,n,i)}};return e},Ak=vt,pl=Lr(),$k=Li,Ho=Qg,Ik=X,Nn=Ak("%WeakMap%",!0),Tk=pl("WeakMap.prototype.get",!0),Ck=pl("WeakMap.prototype.set",!0),Rk=pl("WeakMap.prototype.has",!0),Pk=pl("WeakMap.prototype.delete",!0),Dk=Nn?function(){var t,e,n={assert:function(i){if(!n.has(i))throw new Ik("Side channel does not contain "+$k(i))},delete:function(i){if(Nn&&i&&(typeof i=="object"||typeof i=="function")){if(t)return Pk(t,i)}else if(Ho&&e)return e.delete(i);return!1},get:function(i){return Nn&&i&&(typeof i=="object"||typeof i=="function")&&t?Tk(t,i):e&&e.get(i)},has:function(i){return Nn&&i&&(typeof i=="object"||typeof i=="function")&&t?Rk(t,i):!!e&&e.has(i)},set:function(i,s){Nn&&i&&(typeof i=="object"||typeof i=="function")?(t||(t=new Nn),Ck(t,i,s)):Ho&&(e||(e=Ho()),e.set(i,s))}};return n}:Ho,Lk=X,zk=Li,Ok=vk,Mk=Qg,Nk=Dk,Uk=Nk||Mk||Ok,Fk=function(){var t,e={assert:function(n){if(!e.has(n))throw new Lk("Side channel does not contain "+zk(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=Uk()),t.set(n,i)}};return e},Wk=pr,ji=Fk(),qt=X,ah={assert:function(r,t){if(!r||typeof r!="object"&&typeof r!="function")throw new qt("`O` is not an object");if(typeof t!="string")throw new qt("`slot` must be a string");if(ji.assert(r),!ah.has(r,t))throw new qt("`"+t+"` is not present on `O`")},get:function(r,t){if(!r||typeof r!="object"&&typeof r!="function")throw new qt("`O` is not an object");if(typeof t!="string")throw new qt("`slot` must be a string");var e=ji.get(r);return e&&e["$"+t]},has:function(r,t){if(!r||typeof r!="object"&&typeof r!="function")throw new qt("`O` is not an object");if(typeof t!="string")throw new qt("`slot` must be a string");var e=ji.get(r);return!!e&&Wk(e,"$"+t)},set:function(r,t,e){if(!r||typeof r!="object"&&typeof r!="function")throw new qt("`O` is not an object");if(typeof t!="string")throw new qt("`slot` must be a string");var n=ji.get(r);n||(n={},ji.set(r,n)),n["$"+t]=e}};Object.freeze&&Object.freeze(ah);var lh=ah,em=hr,Ir=lh,ko=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 em('Assertion failed: `type` must be one of "normal", "break", "continue", "return", or "throw"');Ir.set(this,"[[Type]]",t),Ir.set(this,"[[Value]]",e)};ko.prototype.type=function(){return Ir.get(this,"[[Type]]")};ko.prototype.value=function(){return Ir.get(this,"[[Value]]")};ko.prototype["?"]=function(){var t=Ir.get(this,"[[Type]]"),e=Ir.get(this,"[[Value]]");if(t==="throw")throw e;return e};ko.prototype["!"]=function(){var t=Ir.get(this,"[[Type]]");if(t!=="normal")throw new em('Assertion failed: Completion Record is not of type "normal"');return Ir.get(this,"[[Value]]")};var ch=ko,Hk=ch,uh=function(t){return new Hk("normal",t)},sc,bp;function Zk(){if(bp)return sc;bp=1;var r=Ci;return sc=function(){return r()&&!!Symbol.toStringTag},sc}var Bk=vt,wp=Bk("%Object.defineProperty%",!0),Vk=Zk()(),Gk=pr,jk=X,Zo=Vk?Symbol.toStringTag:null,tm=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 jk("if provided, the `overrideIfSet` and `nonConfigurable` options must be booleans");Zo&&(n||!Gk(t,Zo))&&(wp?wp(t,Zo,{configurable:!i,enumerable:!1,value:e,writable:!1}):t[Zo]=e)},rm={exports:{}},qk=vt,Sp=bg,Yk=cl(),_p=Ti,kp=X,Xk=qk("%Math.floor%"),Kk=function(t,e){if(typeof t!="function")throw new kp("`fn` is not a function");if(typeof e!="number"||e<0||e>4294967295||Xk(e)!==e)throw new kp("`length` must be a positive 32-bit integer");var n=arguments.length>2&&!!arguments[2],i=!0,s=!0;if("length"in t&&_p){var o=_p(t,"length");o&&!o.configurable&&(i=!1),o&&!o.writable&&(s=!1)}return(i||s||!n)&&(Yk?Sp(t,"length",e,!0,!0):Sp(t,"length",e)),t},Jk=vo,Qk=Ku,ex=Cg,tx=function(){return ex(Jk,Qk,arguments)};(function(r){var t=Kk,e=mo,n=ul,i=tx;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})(rm);var hh=rm.exports,rx=function(t,e){for(var n=0;n<t.length;n+=1)if(!e(t[n],n,t))return!1;return!0},nx=Object,ix=function(t){return t&&typeof t=="object"&&(typeof t["[[ResourceValue]]"]>"u"||nx(t["[[ResourceValue]]"])===t["[[ResourceValue]]"])&&(t["[[Hint]]"]==="SYNC-DISPOSE"||t["[[Hint]]"]==="ASYNC-DISPOSE")&&(typeof t["[[DisposeMethod]]"]=="function"||typeof t["[[DisposeMethod]]"]>"u")},sx=pr,ox=Ju(),ax=rx,lx=ix,cx=function(t){return t&&typeof t=="object"&&sx(t,"[[DisposableResourceStack]]")&&ox(t["[[DisposableResourceStack]]"])&&(t["[[DisposableResourceStack]]"].length===0||ax(t["[[DisposableResourceStack]]"],lx))},ux=dr,hx=function(t){if(t===null)return"Null";if(typeof t>"u")return"Undefined";if(ux(t))return"Object";if(typeof t=="number")return"Number";if(typeof t=="boolean")return"Boolean";if(typeof t=="string")return"String"},dx=hx,dh=function(t){return typeof t=="symbol"?"Symbol":typeof t=="bigint"?"BigInt":dx(t)},px=X,fx=Li,gx=Pi,mx=function(t,e){if(!gx(e))throw new px("Assertion failed: P is not a Property Key, got "+fx(e));return t[e]},xp=X,vx=mx,yx=Di,bx=Pi,Ep=Li,wx=function(t,e){if(!bx(e))throw new xp("Assertion failed: P is not a Property Key");var n=vx(t,e);if(n!=null){if(!yx(n))throw new xp(Ep(e)+" is not a function: "+Ep(n));return n}},Zc={exports:{}},Sx=vt,_x=Sx,Ap=_x("%Reflect.construct%",!0),Pa=So;try{Pa({},"",{"[[Get]]":function(){}})}catch{Pa=null}if(Pa&&Ap){var $p={},Ip={};Pa(Ip,"length",{"[[Get]]":function(){throw $p},"[[Enumerable]]":!0}),Zc.exports=function(t){try{Ap(t,Ip)}catch(e){return e===$p}}}else Zc.exports=function(t){return typeof t=="function"&&!!t.prototype};var kx=Zc.exports,oc=X,Tp=Di,xx=kx,Ex=function(t){if(!xx(t))throw new oc("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 oc("executor has already been called");e["[[Resolve]]"]=i,e["[[Reject]]"]=s});if(!Tp(e["[[Resolve]]"])||!Tp(e["[[Reject]]"]))throw new oc("executor must provide valid resolve and reject functions");return{"[[Promise]]":n,"[[Resolve]]":e["[[Resolve]]"],"[[Reject]]":e["[[Reject]]"]}},Cp=hr,Ax=X,ac=hl,Rp=wx,$x=Ex,Ix=dh,Pp=rh(),Dp=nh(),Tx=function(t,e){if(Ix(t)!=="Object")throw new Ax("`V` must be an Object");if(e!=="SYNC-DISPOSE"&&e!=="ASYNC-DISPOSE")throw new Cp("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");var n;if(e==="ASYNC-DISPOSE"&&Dp&&(n=Rp(t,Dp)),!n){if(!Pp)throw new Cp("`Symbol.dispose` is not supported");if(n=Rp(t,Pp),typeof n<"u")return function(){var i=this;if(e==="ASYNC-DISPOSE"){var s=$x(Promise);try{ac(n,i),ac(s["[[Resolve]]"],void 0,[void 0])}catch(o){s["[[Reject]]"](o)}return s["[[Promise]]"]}ac(n,i)}}return n},Cx=hr,lc=X,Rx=Di,Px=dh,Dx=Tx,Lx=function(t,e){if(e!=="SYNC-DISPOSE"&&e!=="ASYNC-DISPOSE")throw new Cx("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"&&Px(t)!=="Object")throw new lc("`V` must be an Object, or `null` or `undefined`");if(n=Dx(t,e),typeof n>"u")throw new lc("dispose method must not be `undefined` on `V` when an object `V` is provided")}else if(n=arguments[2],!Rx(n))throw new lc("`method`, when provided, must be a function");return{"[[ResourceValue]]":t,"[[Hint]]":e,"[[DisposeMethod]]":n}},zx=hr,Bo=X,Ox=cx,Lp=Lx,Mx=Lr(),Nx=Mx("Array.prototype.push"),nm=function(t,e,n){if(!Ox(t))throw new Bo("Assertion failed: `disposeCapability` must be a DisposeCapability Record");if(n!=="SYNC-DISPOSE"&&n!=="ASYNC-DISPOSE")throw new zx("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 Bo("Assertion failed: `method`, when present, must be a function");if(!t["[[DisposableResourceStack]]"])throw new Bo("Assertion failed: `disposeCapability.[[DisposableResourceStack]]` must not be ~EMPTY~");var s;if(arguments.length<4){if(e==null&&n==="SYNC_DISPOSE")return"UNUSED";s=Lp(e,n)}else{if(typeof e<"u")throw new Bo("Assertion failed: `V` must be undefined when `method` is present");s=Lp(void 0,n,i)}return Nx(t["[[DisposableResourceStack]]"],s),"UNUSED"},cc,zp;function ph(){if(zp)return cc;zp=1;var r=vt,t=hh,e=hr,n=r("%Promise.resolve%",!0),i=n&&t(n);return cc=function(o,a){if(!i)throw new e("This environment does not support Promises.");return i(o,a)},cc}var uc,Op;function Ux(){if(Op)return uc;Op=1;var r=vt,t=hr,e=r("%Promise%",!0),n=hl,i=ph(),s=dh;return uc=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)},uc}var hc,Mp;function Fx(){if(Mp)return hc;Mp=1;var r=ch;return hc=function(e){return new r("throw",e)},hc}var Wx=vt,dc=hr,Np=X,Hx=Wx("%Promise%",!0),Zx=Lr(),Up=Zx("Promise.prototype.then",!0),Bx=ch,Fp=Ux(),Vx=uh,Gx=ph(),Wp=Fx(),jx=Vg(),im=function(t,e){if(!(e instanceof Bx))throw new Np("`completion` must be a Completion Record");var n=t["[[DisposableResourceStack]]"];if(!n)throw new Np("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 dc("mixed hint stacks are not supported");for(var o=i==="ASYNC-DISPOSE"&&Gx(Hx,e),a=function(v){if(e.type()==="throw"){var m=e.value(),x=new jx(v,m);e=Wp(x)}else e=Wp(v)},c=i==="ASYNC-DISPOSE"&&function(m){return Up(o,function(){var x=Fp(m["[[ResourceValue]]"],m["[[Hint]]"],m["[[DisposeMethod]]"]);if(!x)throw new dc("Assertion failed: non-`~ASYNC-DISPOSE~` resource returned a promise from Dispose");return Up(x,Vx)},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=Fp(h["[[ResourceValue]]"],h["[[Hint]]"],h["[[DisposeMethod]]"]);if(p)throw new dc("Assertion failed: `~SYNC-DISPOSE~` resource returned something from Dispose")}catch(v){a(v)}}return t["[[DisposableResourceStack]]"]=null,i==="ASYNC-DISPOSE"?o:e},sm=function(){var t=[];return{"[[DisposableResourceStack]]":t}},fl=ju,fh=X,qx=hl,zi=eh,Yx=So,om=Di,Xx=uh,rt=lh,Kx=tm,am=An.supportsDescriptors,Jx=hh,gh=nm,Qx=im,lm=sm,Hp=rh(),ft=function r(){if(!(this instanceof r)||rt.has(this,"[[DisposableState]]")||rt.has(this,"[[DisposeCapability]]"))throw new fh("can only be used with new");rt.set(this,"[[DisposableState]]","PENDING"),rt.set(this,"[[DisposeCapability]]",lm())},cm=function(){var t=this;return rt.assert(t,"[[DisposableState]]"),rt.get(t,"[[DisposableState]]")==="DISPOSED"},xo=Jx(cm);am?Yx(ft.prototype,"disposed",{"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Get]]":cm}):ft.prototype.disposed=!1;var um=function(t){rt.set(t,"[[DisposableState]]","DISPOSED"),am||(t.disposed=!0)};zi(ft.prototype,"dispose",function(){var t=this;if(!xo(t))return um(t),Qx(rt.get(t,"[[DisposeCapability]]"),Xx())["?"]()});zi(ft.prototype,"use",function(t){var e=this;if(xo(e))throw new fl("a disposed stack can not use anything new");return gh(rt.get(e,"[[DisposeCapability]]"),t,"SYNC-DISPOSE"),t});zi(ft.prototype,"adopt",function(t,e){var n=this;if(xo(n))throw new fl("a disposed stack can not use anything new");if(!om(e))throw new fh("`onDispose` must be a function");var i=function(){return qx(e,void 0,[t])};return gh(rt.get(n,"[[DisposeCapability]]"),void 0,"SYNC-DISPOSE",i),t});zi(ft.prototype,"defer",function(t){var e=this;if(xo(e))throw new fl("a disposed stack can not defer anything new");if(!om(t))throw new fh("`onDispose` must be a function");gh(rt.get(e,"[[DisposeCapability]]"),void 0,"SYNC-DISPOSE",t)});zi(ft.prototype,"move",function(){var t=this;if(xo(t))throw new fl("a disposed stack can not use anything new");var e=new ft;return rt.set(e,"[[DisposeCapability]]",rt.get(t,"[[DisposeCapability]]")),rt.set(t,"[[DisposeCapability]]",lm()),um(t),e});Hp&&zi(ft.prototype,Hp,ft.prototype.dispose);Kx(ft.prototype,"DisposableStack");var eE=ft,tE=eE,rE=function(){return typeof DisposableStack=="function"?DisposableStack:tE},nE=An,iE=Vu(),sE=rE,oE=function(){var t=sE();return nE(iE,{DisposableStack:t},{DisposableStack:!0}),t},aE=vt,gl=ju,mh=X,Zp=aE("%Promise%",!0),vh=nm,lE=hl,Oi=eh,cE=So,uE=im,hm=Di,dm=sm,hE=uh,Bp=ph(),nt=lh,dE=tm,pm=An.supportsDescriptors,pE=hh,fE=Lr(),gE=fE("Promise.prototype.then",!0),Vp=nh(),gt=function r(){if(!(this instanceof r)||nt.has(this,"[[AsyncDisposableState]]")||nt.has(this,"[[DisposeCapability]]"))throw new mh("can only be used with new");nt.set(this,"[[AsyncDisposableState]]","pending"),nt.set(this,"[[DisposeCapability]]",dm())},fm=function(){var t=this;return nt.assert(t,"[[AsyncDisposableState]]"),nt.get(t,"[[AsyncDisposableState]]")==="disposed"},Eo=pE(fm);pm?cE(gt.prototype,"disposed",{"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Get]]":fm}):gt.prototype.disposed=!1;var gm=function(t){nt.set(t,"[[AsyncDisposableState]]","disposed"),pm||(t.disposed=!0)};Oi(gt.prototype,"disposeAsync",function(){var t=this;return Eo(t)?Bp(Zp):(gm(t),gE(Bp(Zp,uE(nt.get(t,"[[DisposeCapability]]"),hE())),function(e){return e["?"]()}))});Oi(gt.prototype,"use",function(t){var e=this;if(Eo(e))throw new gl("a disposed stack can not use anything new");return vh(nt.get(e,"[[DisposeCapability]]"),t,"ASYNC-DISPOSE"),t});Oi(gt.prototype,"adopt",function(t,e){var n=this;if(Eo(n))throw new gl("a disposed stack can not use anything new");if(!hm(e))throw new mh("`onDisposeAsync` must be a function");var i=function(){return lE(e,void 0,[t])};return i.value=t,vh(nt.get(n,"[[DisposeCapability]]"),void 0,"ASYNC-DISPOSE",i),t});Oi(gt.prototype,"defer",function(t){var e=this;if(Eo(e))throw new gl("a disposed stack can not defer anything new");if(!hm(t))throw new mh("`onDispose` must be a function");vh(nt.get(e,"[[DisposeCapability]]"),void 0,"ASYNC-DISPOSE",t)});Oi(gt.prototype,"move",function(){var t=this;if(Eo(t))throw new gl("a disposed stack can not use anything new");var e=new gt;return nt.set(e,"[[DisposeCapability]]",nt.get(t,"[[DisposeCapability]]")),nt.set(t,"[[DisposeCapability]]",dm()),gm(t),e});Vp&&Oi(gt.prototype,Vp,gt.prototype.disposeAsync);dE(gt.prototype,"AsyncDisposableStack");var mE=gt,vE=mE,yE=function(){return typeof AsyncDisposableStack=="function"?AsyncDisposableStack:vE},bE=An,wE=Vu(),SE=yE,_E=function(){var t=SE();return bE(wE,{AsyncDisposableStack:t},{AsyncDisposableStack:!0}),t},kE=b_,xE=$_,EE=oE,AE=_E,$E=function(){kE(),xE(),EE(),AE()};$E();const Gp=new WeakMap;function IE(r){return(typeof r=="object"||typeof r=="function")&&r!==null&&"then"in r&&typeof r.then=="function"}function Un(r){return typeof r=="string"?r:typeof r=="symbol"?r.description??r.toString():r.name||"(anonymous class)"}function jp(){return new Error("register(Key, factory) requires a factory function. Wrap existing instances as () => instance.")}function TE(){return new Error("register(Key, factory) does not accept async factories. Await setup before registering.")}class CE{constructor(){y(this,"entries",new Map);y(this,"constructionStack",[])}register(t,e){if(e===void 0){if(typeof t!="function")throw jp();this.validateClassRegistration(t),this.storeFactory(t,()=>this.instantiateClass(t));return}if(typeof e!="function")throw jp();if(e.constructor.name==="AsyncFunction")throw TE();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=Gp.get(t);if(e){if(t.length!==e.length)throw new Error(`${Un(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(`${Un(t)} cannot be registered with register(Class). Undecorated classes must have zero required constructor parameters. Use register(Key, () => value) instead.`)}instantiateClass(t){const e=Gp.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(`${Un(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=>Un(i)).join(" -> ");throw new Error(`Circular dependency detected: ${n}`)}this.constructionStack.push(t.key);try{const n=t.factory();if(IE(n))throw new Error(`Factory for ${Un(t.key)} returned a Promise. Await setup before registering.`);if(typeof n!="object"||n===null)throw new Error(`Factory for ${Un(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 Zt=new CE,RE=.5,qp=.1,Yp=8,PE=4,mm=3,vm=3,DE=4,Yr=255,ym=.2126,bm=.7152,wm=.0722;async function Sm(r){const t=LE(r);if(!t)return"light";try{return await ME(r,t)>=RE?"light":"dark"}catch{return"light"}}function LE(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(zE(o))return s}return null}function zE(r){return r.backgroundImage&&r.backgroundImage!=="none"?!0:OE(r.backgroundColor)>0}function OE(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===DE?parseFloat(e[mm]):e.length===vm?1:0}async function ME(r,t){const e=r.getBoundingClientRect(),n=t.getBoundingClientRect(),i={x:Vo((e.left-n.left)/n.width),y:Vo((e.top-n.top)/n.height),width:Vo(e.width/n.width),height:Vo(e.height/n.height)},s=window.getComputedStyle(t),o=NE(s.backgroundImage);return o?FE({url:o,surfaceWidth:n.width,surfaceHeight:n.height,region:i}):WE(s.backgroundColor)}function NE(r){const t=r.match(/url\(\s*["']?([^"')]+)["']?\s*\)/);return t?t[1]:null}const Xp=new Map;function UE(r){let t=Xp.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}),Xp.set(r,t),t)}async function FE(r){const t=await UE(r.url),e=Math.max(Yp,Math.ceil(r.surfaceWidth*qp)),n=Math.max(Yp,Math.ceil(r.surfaceHeight*qp)),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 v=Math.max(0,Math.floor(r.region.x*e)),m=Math.max(0,Math.floor(r.region.y*n)),x=Math.max(1,Math.min(e-v,Math.floor(r.region.width*e))),E=Math.max(1,Math.min(n-m,Math.floor(r.region.height*n))),T=s.getImageData(v,m,x,E).data;let O=0,R=0;for(let Z=0;Z<T.length;Z+=PE){const F=T[Z]/Yr,V=T[Z+1]/Yr,N=T[Z+2]/Yr,J=T[Z+mm]/Yr;O+=J*(ym*F+bm*V+wm*N),R+=1}return R>0?O/R:1}function WE(r){const t=r.match(/rgba?\(([^)]+)\)/);if(!t)return 1;const e=t[1].split(/[\s,/]+/).filter(Boolean).map(parseFloat);if(e.length<vm)return 1;const n=e[0]/Yr,i=e[1]/Yr,s=e[2]/Yr;return ym*n+bm*i+wm*s}function Vo(r){return r<0?0:r>1?1:r}const HE=["ghost","glass"],vs=[...HE.flatMap(r=>[`button[variant="${r}"]`,`segmented-control[variant="${r}"]`]),'[material="glass"]'].join(", "),Go=new WeakSet,Kp=new WeakSet;function _m(r){if(Kp.has(r))return;Kp.add(r);for(const e of r.querySelectorAll(vs))pc(e);if(typeof MutationObserver!="function")return;new MutationObserver(e=>{for(const n of e)if(n.type==="childList")for(const i of n.addedNodes)ZE(i,pc);else n.type==="attributes"&&n.target instanceof HTMLElement&&n.target.matches(vs)&&pc(n.target)}).observe(r,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["variant","material"]})}function ZE(r,t){if(r instanceof Element){r instanceof HTMLElement&&r.matches(vs)&&t(r);for(const e of r.querySelectorAll(vs))t(e)}}async function pc(r){if(Go.has(r)||r.hasAttribute("tone"))return;Go.add(r);const t=await Sm(r);if(!r.matches(vs)){Go.delete(r);return}if(r.hasAttribute("tone")){Go.delete(r);return}r.setAttribute("tone",t)}const BE="*,*: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)}',yh=new CSSStyleSheet;yh.replaceSync(BE);const bh=new CSSStyleSheet;try{document.adoptedStyleSheets=[...document.adoptedStyleSheets,yh,bh]}catch{}_m(document);function km(r){bh.replaceSync(r)}function Da(){km("")}function xm(r){try{r.adoptedStyleSheets=[...r.adoptedStyleSheets,yh,bh]}catch{}_m(r)}const VE=new Set(["target","currentTarget","eventPhase","defaultPrevented","isTrusted","timeStamp","srcElement","returnValue","cancelBubble","NONE","CAPTURING_PHASE","AT_TARGET","BUBBLING_PHASE","composedPath","stopPropagation","stopImmediatePropagation","preventDefault","initEvent"]);function GE(r){for(const t of Object.keys(r))if(VE.has(t))throw new Error(`Event payload key "${t}" is reserved; choose a different property name`)}function jE(r,t){GE(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}),jE(this,c)}}return r}class Bt extends globalThis.EventTarget{}function qE(r,t,e){const n=r.dispose.bind(r);r.dispose=()=>{if(!t())return e(),n()}}function Ao(r){var e;class t extends r{constructor(...s){super(...s);w(this,e,!1);qE(this,()=>l(this,e),()=>{k(this,e,!0)})}[Symbol.dispose](){this.dispose()}get disposed(){return l(this,e)}}return e=new WeakMap,t}const YE=it(),XE=it(),KE=it(),ha=it(),Em="0123456789ABCDEFGHJKMNPQRSTVWXYZ",La=32,JE=16,Am=10,Jp=0xffffffffffff;var Xr;(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"})(Xr||(Xr={}));class rs extends Error{constructor(t,e){super(`${e} (${t})`),this.name="ULIDError",this.code=t}}function QE(r){const t=Math.floor(r()*La)%La;return Em.charAt(t)}function eA(r){const t=tA(),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 rs(Xr.PRNGDetectFailure,"Failed to find a reliable PRNG")}function tA(){return iA()?self:typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:null}function rA(r,t){let e="";for(;r>0;r--)e=QE(t)+e;return e}function nA(r,t=Am){if(isNaN(r))throw new rs(Xr.EncodeTimeValueMalformed,`Time must be a number: ${r}`);if(r>Jp)throw new rs(Xr.EncodeTimeSizeExceeded,`Cannot encode a time larger than ${Jp}: ${r}`);if(r<0)throw new rs(Xr.EncodeTimeNegative,`Time must be positive: ${r}`);if(Number.isInteger(r)===!1)throw new rs(Xr.EncodeTimeValueMalformed,`Time must be an integer: ${r}`);let e,n="";for(let i=t;i>0;i--)e=r%La,n=Em.charAt(e)+n,r=(r-e)/La;return n}function iA(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}function ml(r,t){const e=eA(),n=Date.now();return nA(n,Am)+rA(JE,e)}const Et=4,ut=6,ys=2,Bc=2,wh=8,sA=ut,Sh="auto",Tr="auto",mr=120,Qp=50,ce=16,wn=mr*Et+ce*(Et-1),za=mr*ut+ce*(ut-1),oA=wn+ce*2,aA=200,lA=4,jo=150,cA=10,ef=2,tf=8,uA=300,hA=4;function $m(r){return Cm(r)}function Im(r,t){return Cm(r.flatMap(e=>Pm(e,t)))}function Tm(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}Dm(n,"strip",t,e)}return{valid:t.length===0,errors:t}}function Qn(r){const t=$m(r),e=Tm(t);if(!e.valid)throw new Error(`Invalid layout: ${e.errors.join("; ")}`);return{totalNodes:t.length,nodes:t.filter(n=>n.type!=="row").map(gA)}}function Cm(r){const t=[];for(const e of r){const n=Rm(e);for(const i of n){if(i.type==="row"){t.push(...i.children.map(cr));continue}t.push(i)}}return t}function Rm(r){switch(r.type){case"card":return[cr(r)];case"row":{const t=r.children.map(cr);return t.length===0?[]:t.length===1?[t[0]]:[{...r,children:t}]}case"stack":{const t=[];for(const e of r.children){const n=Rm(e);for(const i of n){if(i.type==="stack"){t.push(...i.children.map(Vc));continue}if(i.type==="row"){t.push({...i,children:i.children.map(cr)});continue}t.push(cr(i))}}return t.length===0?[]:t.length===1?[Vc(t[0])]:[{...r,children:t}]}}}function Pm(r,t){switch(r.type){case"card":return r.artifactID===t?[]:[cr(r)];case"row":{const e=r.children.filter(n=>n.artifactID!==t).map(cr);return e.length===0?[]:e.length===1?[e[0]]:[{...r,children:e}]}case"stack":{const e=r.children.flatMap(n=>Pm(n,t).filter(s=>s.type!=="stack"));return e.length===0?[]:e.length===1?[Vc(e[0])]:[{...r,children:e}]}}}function Dm(r,t,e,n){switch(r.type){case"card":Lm(r,t,e,n);return;case"row":dA(r,t,e,n);return;case"stack":pA(r,t,e,n);return}}function Lm(r,t,e,n){_h(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),fA(r.width)||e.push(`Card ${r.id} width must be an integer in the range ${ys}-${wh}`),zm(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<ys&&e.push(`Row child ${r.id} must be at least 2 columns wide`)}function dA(r,t,e,n){if(_h(r.id,e),t!=="stack"&&e.push(`Row ${r.id} may only appear inside a stack`),zm(r.height,hA)||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}Lm(s,"row",e,n),i+=Gr(s.width)}i!==Et&&e.push(`Row ${r.id} children must sum to 4 columns`)}function pA(r,t,e,n){if(_h(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(Dm(a,"stack",e,n),a.height===Tr){s+=1;continue}i+=a.height}if(i>ut&&e.push(`Stack ${r.id} exceeds the 6-row budget`),s===0)return;const o=ut-i;if(o<s*Bc||o%s!==0){e.push(`Stack ${r.id} has auto-height children that cannot resolve to whole height >= 2`);return}o/s<Bc&&e.push(`Stack ${r.id} has auto-height children below the minimum row size`)}function _h(r,t){(typeof r!="string"||r.length===0)&&t.push(`Node id must be a non-empty string: ${String(r)}`)}function fA(r){return r===Sh||Number.isInteger(r)&&r>=ys&&r<=wh}function zm(r,t=sA){return r===Tr||Number.isInteger(r)&&r>=Bc&&r<=t}function Gr(r){return r===Sh?Et:r}function gA(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:Om(r.height,ut)}]};const t=mA(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(Et,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 mA(r){let t=0,e=0;for(const i of r)i.height===Tr?e+=1:t+=i.height;const n=e>0?(ut-t)/e:0;return r.map(i=>Om(i.height,n))}function Om(r,t){return r===Tr?t:r}function cr(r){return{...r}}function Vc(r){return r.type==="card"?cr(r):{...r,children:r.children.map(cr)}}function Mm(r,t={}){return{id:t.id??ml(),type:"card",artifactID:r,width:t.width??Sh,height:t.height??Tr}}function Nm(r,t){return r.some(e=>Um(e,t))}function Um(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=>Um(e,t))}}function rf(r){return r.layout.flatMap(Fm)}function Fm(r){switch(r.type){case"card":return[r.artifactID];case"row":return r.children.map(t=>t.artifactID);case"stack":return r.children.flatMap(Fm)}}const ae=it(),Gc=it(),Fn=it(),vA=it();function yA(r){class t extends Error{constructor(n,i){super(n),this.name=r,i&&Object.assign(this,i)}}return t}const bA=yA("RequestError"),wA=200,SA=300;class _A{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 kA(i);if(!i.ok||i.status<wA||i.status>=SA)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 fc(i,i.statusText),i.status)}async requestText(t,e){const n=await this.request(t,e);if(!n.ok)throw this.createError(await fc(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 fc(i,i.statusText),i.status)}createError(t,e){const n={serverURL:this.serverURL};return e!==void 0&&(n.status=e),new bA(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 kA(r){try{return await r.json()}catch{const t=await r.text().catch(()=>"");return t?{message:t}:{}}}async function fc(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 xA(r){return r.map(t=>`${t.name} (${t.id})`).join(", ")}var zt,ja,Wm;class EA{constructor(t){w(this,ja);w(this,zt);k(this,zt,t)}list(){return l(this,zt).requestJSON("GET","/screens")}async get(t={}){const e=await f(this,ja,Wm).call(this,t.screenID);return l(this,zt).requestJSON("GET",`/screens/${encodeURIComponent(e)}`)}create(t){const e={name:t.name};return t.id!==void 0&&(e.id=t.id),l(this,zt).requestJSON("POST","/screens",e)}update(t){const{screenID:e,...n}=t;return l(this,zt).requestJSON("PATCH",`/screens/${encodeURIComponent(e)}`,n)}remove(t){return l(this,zt).requestJSON("DELETE",`/screens/${encodeURIComponent(t.screenID)}`)}}zt=new WeakMap,ja=new WeakSet,Wm=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,zt).createError(`screenID is required when multiple screens exist. Available screens: ${xA(e)}`)};var Ue;class AA{constructor(t){w(this,Ue);k(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 Jr;class $A{constructor(t){w(this,Jr);k(this,Jr,t)}get(){return l(this,Jr).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,Jr).requestVoid("PATCH","/display",e)}focus(t){const e={artifactID:t.artifactID};return t.screenID!==void 0&&(e.screenID=t.screenID),l(this,Jr).requestJSON("POST","/display/focus",e)}}Jr=new WeakMap;var Es;class IA{constructor(t){w(this,Es);k(this,Es,t)}async list(){const{views:t}=await l(this,Es).requestJSON("GET","/views");return t}}Es=new WeakMap;var Qt;class TA{constructor(t,e={}){y(this,"screens");y(this,"artifacts");y(this,"display");y(this,"views");w(this,Qt);k(this,Qt,new _A(t,e)),this.screens=new EA(l(this,Qt)),this.artifacts=new AA(l(this,Qt)),this.display=new $A(l(this,Qt)),this.views=new IA(l(this,Qt))}health(){return l(this,Qt).requestJSON("GET","/health")}}Qt=new WeakMap;const CA={focusCommandInput:{label:"Focus Command Input",trigger:{key:"k",meta:!0}}},RA="Local",PA="store-";function _e(r){return new URL(r).origin}function DA(r){return{servers:[{url:_e(r),name:RA}],activeServerURL:null,activeScreenID:null,tabs:{},screens:{}}}function LA(r,t){return[...r.tabs[_e(t)]??[]]}function zA(r,t,e){const n=_e(t),i=r.tabs[n]??[];return i.includes(e)?r:{...r,tabs:{...r.tabs,[n]:[...i,e]}}}function OA(r,t,e){const n=_e(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 Qr,en,tn;class MA extends Bt{constructor(e,n,i={}){super();w(this,Qr);w(this,en);w(this,tn);k(this,Qr,`${PA}${e}`),k(this,en,i.storage??NA());const s=l(this,en).getItem(l(this,Qr));s===null?(k(this,tn,n),l(this,en).setItem(l(this,Qr),JSON.stringify(n))):k(this,tn,UA(JSON.parse(s),n))}get(){return l(this,tn)}set(e){k(this,tn,e),l(this,en).setItem(l(this,Qr),JSON.stringify(e)),this.dispatchEvent(new ae("change"))}}Qr=new WeakMap,en=new WeakMap,tn=new WeakMap;function NA(){const r=globalThis.localStorage;if(!r)throw new Error("LocalStore: no storage adapter supplied and window.localStorage is unavailable");return r}function UA(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 FA=Ao(Bt);var rn,Ke,nn,Ze,yr,br,re,Zn,Hm,As,Zm,Bm,Vm,Gm,jc,qc,Yc,jm;class WA extends FA{constructor(e){var i;super();w(this,re);y(this,"id");y(this,"server");w(this,rn);w(this,Ke,new Map);w(this,nn);w(this,Ze);w(this,yr);w(this,br,null);w(this,As,e=>{if(this.disposed)return;const n=e.event;switch(n.type){case"screen-updated":n.screen.id===this.id&&f(this,re,Zm).call(this,n.screen);break;case"artifact-created":break;case"artifact-attached":n.screenID===this.id&&f(this,re,Bm).call(this,n.cardID,n.artifact);break;case"artifact-updated":f(this,re,Vm).call(this,n.artifact);break;case"artifact-removed":n.screenID===this.id&&f(this,re,Gm).call(this,n.artifactID);break;case"artifact-content-changed":l(this,Ke).has(n.artifactID)&&this.dispatchEvent(new vA("artifact-content-changed",{artifactID:n.artifactID}));break}});this.id=e.screen.id,this.server=e.server,k(this,rn,e.localStore),k(this,nn,e.screen.name),k(this,Ze,structuredClone(e.screen.layout));const n=((i=l(this,rn).get().screens[this.id])==null?void 0:i.scrollPosition)??0;k(this,yr,Math.max(0,n)),this.server.addEventListener("server-event",l(this,As)),f(this,re,Hm).call(this)}get name(){return l(this,nn)}get layout(){return l(this,Ze)}get scrollPosition(){return l(this,yr)}get artifacts(){return l(this,Ke)}setScrollPosition(e){f(this,re,Zn).call(this);const n=Math.max(0,e);n!==l(this,yr)&&(k(this,yr,n),f(this,re,jm).call(this),this.dispatchEvent(new ae("change")))}setLayout(e){f(this,re,Zn).call(this);const n=$m(e);if(!Tm(n).valid)return;const s=f(this,re,qc).call(this);k(this,Ze,n),k(this,br,{layout:n,snapshot:s}),this.dispatchEvent(new ae("change")),this.server.client.screens.update({screenID:this.id,layout:n.map(o=>structuredClone(o))}).catch(()=>{var o;this.disposed||((o=l(this,br))==null?void 0:o.layout)===n&&(k(this,br,null),f(this,re,Yc).call(this,s),this.dispatchEvent(new ae("change")))})}rename(e){f(this,re,Zn).call(this),k(this,nn,e),this.dispatchEvent(new ae("change")),this.server.client.screens.update({screenID:this.id,name:e}).catch(()=>{})}async remove(){f(this,re,Zn).call(this),await this.server.client.screens.remove({screenID:this.id})}removeArtifact(e){if(f(this,re,Zn).call(this),!l(this,Ke).has(e))return;const n=f(this,re,qc).call(this);f(this,re,jc).call(this,e),this.dispatchEvent(new ae("change")),this.server.client.artifacts.detach({artifactID:e,screenID:this.id}).catch(()=>{this.disposed||(f(this,re,Yc).call(this,n),this.dispatchEvent(new ae("change")))})}dispose(){this.server.removeEventListener("server-event",l(this,As))}}rn=new WeakMap,Ke=new WeakMap,nn=new WeakMap,Ze=new WeakMap,yr=new WeakMap,br=new WeakMap,re=new WeakSet,Zn=function(){if(this.disposed)throw new Error("ScreenModel is disposed")},Hm=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 ae("change"))}catch{}},As=new WeakMap,Zm=function(e){l(this,br)&&k(this,br,null),k(this,nn,e.name),k(this,Ze,structuredClone(e.layout)),this.dispatchEvent(new ae("change"))},Bm=function(e,n){Nm(l(this,Ze),n.id)||k(this,Ze,[...l(this,Ze),Mm(n.id,{id:e})]),l(this,Ke).set(n.id,n),this.dispatchEvent(new ae("change"))},Vm=function(e){const n=l(this,Ke).get(e.id);n&&(l(this,Ke).set(e.id,{...n,...e}),this.dispatchEvent(new ae("change")))},Gm=function(e){f(this,re,jc).call(this,e)&&this.dispatchEvent(new ae("change"))},jc=function(e){const n=l(this,Ke).delete(e),i=rf({layout:l(this,Ze)}).length,s=Im(l(this,Ze),e),o=rf({layout:s}).length;return k(this,Ze,s),n||i!==o},qc=function(){return{layout:structuredClone(l(this,Ze)),artifacts:new Map([...l(this,Ke).entries()].map(([e,n])=>[e,structuredClone(n)]))}},Yc=function(e){k(this,Ze,structuredClone(e.layout)),l(this,Ke).clear();for(const[n,i]of e.artifacts)l(this,Ke).set(n,structuredClone(i))},jm=function(){const e=l(this,rn).get();l(this,rn).set({...e,screens:{...e.screens,[this.id]:{scrollPosition:l(this,yr)}}})};const HA=Ao(Bt);var Le,Je,Ot,$s,Is,Ts,Ve,da,Xc,Bn;class ZA extends HA{constructor(e){super();w(this,Ve);w(this,Le);w(this,Je);w(this,Ot,null);w(this,$s,()=>{this.disposed||f(this,Ve,da).call(this)});w(this,Is,()=>{this.disposed||f(this,Ve,da).call(this)});w(this,Ts,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===_e(e.serverURL)&&i.activeScreenID===n.screenID&&f(this,Ve,Bn).call(this,e.serverURL,null);return}if(n.type==="screen-changed"){if(n.screenID===null){f(this,Ve,Bn).call(this,e.serverURL,null);return}const i=l(this,Je).servers.get(_e(e.serverURL));if(!i||!i.screens.has(n.screenID))return;this.addTab(e.serverURL,n.screenID),f(this,Ve,Bn).call(this,e.serverURL,n.screenID)}});k(this,Le,e.localStore),k(this,Je,e.serverManager),l(this,Le).addEventListener("change",l(this,$s)),l(this,Je).addEventListener("change",l(this,Is)),l(this,Je).addEventListener("server-event",l(this,Ts)),f(this,Ve,da).call(this)}get activeScreen(){return l(this,Ot)}getTabs(e){const n=_e(e),i=LA(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=_e(e),s=l(this,Je).servers.get(i);s&&!s.screens.has(n)||f(this,Ve,Xc).call(this,zA(l(this,Le).get(),i,n))}removeTab(e,n){f(this,Ve,Xc).call(this,OA(l(this,Le).get(),e,n))}setActive(e,n){const i=_e(e),s=l(this,Je).servers.get(i);!s||!s.screens.has(n)||f(this,Ve,Bn).call(this,i,n)&&s.client.display.patch({activeScreenID:n}).catch(()=>{})}clearActive(){const e=l(this,Le).get().activeServerURL;if(!e||!f(this,Ve,Bn).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,$s)),l(this,Je).removeEventListener("change",l(this,Is)),l(this,Je).removeEventListener("server-event",l(this,Ts)),(e=l(this,Ot))==null||e.dispose(),k(this,Ot,null)}}Le=new WeakMap,Je=new WeakMap,Ot=new WeakMap,$s=new WeakMap,Is=new WeakMap,Ts=new WeakMap,Ve=new WeakSet,da=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,Ot))==null?void 0:c.id)??null,a=(s==null?void 0:s.id)??null;o===a&&((u=l(this,Ot))==null?void 0:u.server)===i||((h=l(this,Ot))==null||h.dispose(),k(this,Ot,i&&s?new WA({screen:s,server:i,localStore:l(this,Le)}):null),i&&i.acpClient.setScreenContext(s?{screenID:s.id,screenName:s.name}:null),this.dispatchEvent(new YE("active-screen-changed")))},Xc=function(e){e!==l(this,Le).get()&&(l(this,Le).set(e),this.dispatchEvent(new XE("tabs-changed")))},Bn=function(e,n){const i=_e(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 v=h[p];v in a||(a[v]=u[v].bind(a))}}const i=(e==null?void 0:e.Parent)??Object;class s extends i{}Object.defineProperty(s,"name",{value: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 ni extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class qm extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const Ym={};function Cr(r){return Ym}function Xm(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 Kc(r,t){return typeof t=="bigint"?t.toString():t}function kh(r){return{get value(){{const t=r();return Object.defineProperty(this,"value",{value:t}),t}}}}function xh(r){return r==null}function Eh(r){const t=r.startsWith("^")?1:0,e=r.endsWith("$")?r.length-1:r.length;return r.slice(t,e)}function BA(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 nf=Symbol("evaluating");function ne(r,t,e){let n;Object.defineProperty(r,t,{get(){if(n!==nf)return n===void 0&&(n=nf,n=e()),n},set(i){Object.defineProperty(r,t,{value:i})},configurable:!0})}function In(r,t,e){Object.defineProperty(r,t,{value:e,writable:!0,enumerable:!0,configurable:!0})}function Or(...r){const t={};for(const e of r){const n=Object.getOwnPropertyDescriptors(e);Object.assign(t,n)}return Object.defineProperties({},t)}function sf(r){return JSON.stringify(r)}function VA(r){return r.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Km="captureStackTrace"in Error?Error.captureStackTrace:(...r)=>{};function Oa(r){return typeof r=="object"&&r!==null&&!Array.isArray(r)}const GA=kh(()=>{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 Ei(r){if(Oa(r)===!1)return!1;const t=r.constructor;if(t===void 0||typeof t!="function")return!0;const e=t.prototype;return!(Oa(e)===!1||Object.prototype.hasOwnProperty.call(e,"isPrototypeOf")===!1)}function Jm(r){return Ei(r)?{...r}:Array.isArray(r)?[...r]:r}const jA=new Set(["string","number","symbol"]);function Ai(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Mr(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 z(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 qA(r){return Object.keys(r).filter(t=>r[t]._zod.optin==="optional"&&r[t]._zod.optout==="optional")}const YA={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 XA(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=Or(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 In(this,"shape",o),o},checks:[]});return Mr(r,s)}function KA(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=Or(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 In(this,"shape",o),o},checks:[]});return Mr(r,s)}function JA(r,t){if(!Ei(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=Or(r._zod.def,{get shape(){const s={...r._zod.def.shape,...t};return In(this,"shape",s),s}});return Mr(r,i)}function QA(r,t){if(!Ei(t))throw new Error("Invalid input to safeExtend: expected a plain object");const e=Or(r._zod.def,{get shape(){const n={...r._zod.def.shape,...t};return In(this,"shape",n),n}});return Mr(r,e)}function e$(r,t){const e=Or(r._zod.def,{get shape(){const n={...r._zod.def.shape,...t._zod.def.shape};return In(this,"shape",n),n},get catchall(){return t._zod.def.catchall},checks:[]});return Mr(r,e)}function t$(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=Or(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 In(this,"shape",c),c},checks:[]});return Mr(t,o)}function r$(r,t,e){const n=Or(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 In(this,"shape",s),s}});return Mr(t,n)}function ei(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 ti(r,t){return t.map(e=>{var n;return(n=e).path??(n.path=[]),e.path.unshift(r),e})}function qo(r){return typeof r=="string"?r:r==null?void 0:r.message}function Rr(r,t,e){var i,s,o,a,c,u;const n={...r,path:r.path??[]};if(!r.message){const h=qo((o=(s=(i=r.inst)==null?void 0:i._zod.def)==null?void 0:s.error)==null?void 0:o.call(s,r))??qo((a=t==null?void 0:t.error)==null?void 0:a.call(t,r))??qo((c=e.customError)==null?void 0:c.call(e,r))??qo((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 Ah(r){return Array.isArray(r)?"array":typeof r=="string"?"string":"unknown"}function bs(...r){const[t,e,n]=r;return typeof t=="string"?{message:t,code:"custom",input:e,inst:n}:{...t}}const Qm=(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,Kc,2),Object.defineProperty(r,"toString",{value:()=>r.message,enumerable:!1})},ev=A("$ZodError",Qm),tv=A("$ZodError",Qm,{Parent:Error});function n$(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 i$(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 $h=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 ni;if(o.issues.length){const a=new((i==null?void 0:i.Err)??r)(o.issues.map(c=>Rr(c,s,Cr())));throw Km(a,i==null?void 0:i.callee),a}return o.value},Ih=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=>Rr(c,s,Cr())));throw Km(a,i==null?void 0:i.callee),a}return o.value},vl=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 ni;return s.issues.length?{success:!1,error:new(r??ev)(s.issues.map(o=>Rr(o,i,Cr())))}:{success:!0,data:s.value}},s$=vl(tv),yl=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=>Rr(o,i,Cr())))}:{success:!0,data:s.value}},o$=yl(tv),a$=r=>(t,e,n)=>{const i=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return $h(r)(t,e,i)},l$=r=>(t,e,n)=>$h(r)(t,e,n),c$=r=>async(t,e,n)=>{const i=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return Ih(r)(t,e,i)},u$=r=>async(t,e,n)=>Ih(r)(t,e,n),h$=r=>(t,e,n)=>{const i=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return vl(r)(t,e,i)},d$=r=>(t,e,n)=>vl(r)(t,e,n),p$=r=>async(t,e,n)=>{const i=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return yl(r)(t,e,i)},f$=r=>async(t,e,n)=>yl(r)(t,e,n),g$=/^[cC][^\s-]{8,}$/,m$=/^[0-9a-z]+$/,v$=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,y$=/^[0-9a-vA-V]{20}$/,b$=/^[A-Za-z0-9]{27}$/,w$=/^[a-zA-Z0-9_-]{21}$/,S$=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,_$=/^([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})$/,of=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)$/,k$=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,x$="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function E$(){return new RegExp(x$,"u")}const A$=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,$$=/^(([0-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}|:))$/,I$=/^((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])$/,T$=/^(([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])$/,C$=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,rv=/^[A-Za-z0-9_-]*$/,R$=/^\+[1-9]\d{6,14}$/,nv="(?:(?:\\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])))",P$=new RegExp(`^${nv}$`);function iv(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 D$(r){return new RegExp(`^${iv(r)}$`)}function L$(r){const t=iv({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(`^${nv}T(?:${n})$`)}const z$=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}$`)},O$=/^-?\d+$/,sv=/^-?\d+(?:\.\d+)?$/,M$=/^(?:true|false)$/i,N$=/^[^A-Z]*$/,U$=/^[^a-z]*$/,st=A("$ZodCheck",(r,t)=>{var e;r._zod??(r._zod={}),r._zod.def=t,(e=r._zod).onattach??(e.onattach=[])}),ov={number:"number",bigint:"bigint",object:"date"},av=A("$ZodCheckLessThan",(r,t)=>{st.init(r,t);const e=ov[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})}}),lv=A("$ZodCheckGreaterThan",(r,t)=>{st.init(r,t);const e=ov[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})}}),F$=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):BA(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})}}),W$=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]=YA[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=O$)}),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})}}),H$=A("$ZodCheckMaxLength",(r,t)=>{var e;st.init(r,t),(e=r._zod.def).when??(e.when=n=>{const i=n.value;return!xh(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=Ah(i);n.issues.push({origin:o,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:r,continue:!t.abort})}}),Z$=A("$ZodCheckMinLength",(r,t)=>{var e;st.init(r,t),(e=r._zod.def).when??(e.when=n=>{const i=n.value;return!xh(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=Ah(i);n.issues.push({origin:o,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:r,continue:!t.abort})}}),B$=A("$ZodCheckLengthEquals",(r,t)=>{var e;st.init(r,t),(e=r._zod.def).when??(e.when=n=>{const i=n.value;return!xh(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=Ah(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})}}),bl=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=()=>{})}),V$=A("$ZodCheckRegex",(r,t)=>{bl.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})}}),G$=A("$ZodCheckLowerCase",(r,t)=>{t.pattern??(t.pattern=N$),bl.init(r,t)}),j$=A("$ZodCheckUpperCase",(r,t)=>{t.pattern??(t.pattern=U$),bl.init(r,t)}),q$=A("$ZodCheckIncludes",(r,t)=>{st.init(r,t);const e=Ai(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})}}),Y$=A("$ZodCheckStartsWith",(r,t)=>{st.init(r,t);const e=new RegExp(`^${Ai(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})}}),X$=A("$ZodCheckEndsWith",(r,t)=>{st.init(r,t);const e=new RegExp(`.*${Ai(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})}}),K$=A("$ZodCheckOverwrite",(r,t)=>{st.init(r,t),r._zod.check=e=>{e.value=t.tx(e.value)}});class J${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 Q$={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=Q$;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=ei(a),p;for(const v of c){if(v._zod.def.when){if(!v._zod.def.when(a))continue}else if(h)continue;const m=a.issues.length,x=v._zod.check(a);if(x instanceof Promise&&(u==null?void 0:u.async)===!1)throw new ni;if(p||x instanceof Promise)p=(p??Promise.resolve()).then(async()=>{await x,a.issues.length!==m&&(h||(h=ei(a,m)))});else{if(a.issues.length===m)continue;h||(h=ei(a,m))}}return p?p.then(()=>a):a},o=(a,c,u)=>{if(ei(a))return a.aborted=!0,a;const h=s(c,n,u);if(h instanceof Promise){if(u.async===!1)throw new ni;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 ni;return u.then(h=>s(h,n,c))}return s(u,n,c)}}ne(r,"~standard",()=>({validate:s=>{var o;try{const a=s$(r,s);return a.success?{value:a.data}:{issues:(o=a.error)==null?void 0:o.issues}}catch{return o$(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}))}),Th=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()??z$(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)=>{bl.init(r,t),Th.init(r,t)}),eI=A("$ZodGUID",(r,t)=>{t.pattern??(t.pattern=_$),de.init(r,t)}),tI=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=of(n))}else t.pattern??(t.pattern=of());de.init(r,t)}),rI=A("$ZodEmail",(r,t)=>{t.pattern??(t.pattern=k$),de.init(r,t)}),nI=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})}}}),iI=A("$ZodEmoji",(r,t)=>{t.pattern??(t.pattern=E$()),de.init(r,t)}),sI=A("$ZodNanoID",(r,t)=>{t.pattern??(t.pattern=w$),de.init(r,t)}),oI=A("$ZodCUID",(r,t)=>{t.pattern??(t.pattern=g$),de.init(r,t)}),aI=A("$ZodCUID2",(r,t)=>{t.pattern??(t.pattern=m$),de.init(r,t)}),lI=A("$ZodULID",(r,t)=>{t.pattern??(t.pattern=v$),de.init(r,t)}),cI=A("$ZodXID",(r,t)=>{t.pattern??(t.pattern=y$),de.init(r,t)}),uI=A("$ZodKSUID",(r,t)=>{t.pattern??(t.pattern=b$),de.init(r,t)}),hI=A("$ZodISODateTime",(r,t)=>{t.pattern??(t.pattern=L$(t)),de.init(r,t)}),dI=A("$ZodISODate",(r,t)=>{t.pattern??(t.pattern=P$),de.init(r,t)}),pI=A("$ZodISOTime",(r,t)=>{t.pattern??(t.pattern=D$(t)),de.init(r,t)}),fI=A("$ZodISODuration",(r,t)=>{t.pattern??(t.pattern=S$),de.init(r,t)}),gI=A("$ZodIPv4",(r,t)=>{t.pattern??(t.pattern=A$),de.init(r,t),r._zod.bag.format="ipv4"}),mI=A("$ZodIPv6",(r,t)=>{t.pattern??(t.pattern=$$),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})}}}),vI=A("$ZodCIDRv4",(r,t)=>{t.pattern??(t.pattern=I$),de.init(r,t)}),yI=A("$ZodCIDRv6",(r,t)=>{t.pattern??(t.pattern=T$),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 cv(r){if(r==="")return!0;if(r.length%4!==0)return!1;try{return atob(r),!0}catch{return!1}}const bI=A("$ZodBase64",(r,t)=>{t.pattern??(t.pattern=C$),de.init(r,t),r._zod.bag.contentEncoding="base64",r._zod.check=e=>{cv(e.value)||e.issues.push({code:"invalid_format",format:"base64",input:e.value,inst:r,continue:!t.abort})}});function wI(r){if(!rv.test(r))return!1;const t=r.replace(/[-_]/g,n=>n==="-"?"+":"/"),e=t.padEnd(Math.ceil(t.length/4)*4,"=");return cv(e)}const SI=A("$ZodBase64URL",(r,t)=>{t.pattern??(t.pattern=rv),de.init(r,t),r._zod.bag.contentEncoding="base64url",r._zod.check=e=>{wI(e.value)||e.issues.push({code:"invalid_format",format:"base64url",input:e.value,inst:r,continue:!t.abort})}}),_I=A("$ZodE164",(r,t)=>{t.pattern??(t.pattern=R$),de.init(r,t)});function kI(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 xI=A("$ZodJWT",(r,t)=>{de.init(r,t),r._zod.check=e=>{kI(e.value,t.alg)||e.issues.push({code:"invalid_format",format:"jwt",input:e.value,inst:r,continue:!t.abort})}}),uv=A("$ZodNumber",(r,t)=>{ge.init(r,t),r._zod.pattern=r._zod.bag.pattern??sv,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}}),EI=A("$ZodNumberFormat",(r,t)=>{W$.init(r,t),uv.init(r,t)}),AI=A("$ZodBoolean",(r,t)=>{ge.init(r,t),r._zod.pattern=M$,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}}),$I=A("$ZodUnknown",(r,t)=>{ge.init(r,t),r._zod.parse=e=>e}),II=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 af(r,t,e){r.issues.length&&t.issues.push(...ti(e,r.issues)),t.value[e]=r.value}const TI=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=>af(u,e,o))):af(c,e,o)}return s.length?Promise.all(s).then(()=>e):e}});function Ma(r,t,e,n,i){if(r.issues.length){if(i&&!(e in n))return;t.issues.push(...ti(e,r.issues))}r.value===void 0?e in n&&(t.value[e]=void 0):t.value[e]=r.value}function hv(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=qA(r.shape);return{...r,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(e)}}function dv(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 v=c.run({value:t[p],issues:[]},n);v instanceof Promise?r.push(v.then(m=>Ma(m,e,p,t,h))):Ma(v,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 CI=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=kh(()=>hv(t));ne(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=Oa,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 v of o.keys){const m=p[v],x=m._zod.optout==="optional",E=m._zod.run({value:u[v],issues:[]},c);E instanceof Promise?h.push(E.then(T=>Ma(T,a,v,u,x))):Ma(E,a,v,u,x)}return s?dv(h,u,a,c,n.value,r):h.length?Promise.all(h).then(()=>a):a}}),RI=A("$ZodObjectJIT",(r,t)=>{CI.init(r,t);const e=r._zod.parse,n=kh(()=>hv(t)),i=v=>{var Z;const m=new J$(["shape","payload","ctx"]),x=n.value,E=F=>{const V=sf(F);return`shape[${V}]._zod.run({ value: input[${V}], issues: [] }, ctx)`};m.write("const input = payload.value;");const T=Object.create(null);let O=0;for(const F of x.keys)T[F]=`key_${O++}`;m.write("const newResult = {};");for(const F of x.keys){const V=T[F],N=sf(F),J=v[F],j=((Z=J==null?void 0:J._zod)==null?void 0:Z.optout)==="optional";m.write(`const ${V} = ${E(F)};`),j?m.write(`
|
|
7
|
+
if (${V}.issues.length) {
|
|
8
|
+
if (${N} in input) {
|
|
9
|
+
payload.issues = payload.issues.concat(${V}.issues.map(iss => ({
|
|
10
|
+
...iss,
|
|
11
|
+
path: iss.path ? [${N}, ...iss.path] : [${N}]
|
|
12
|
+
})));
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
if (${V}.value === undefined) {
|
|
17
|
+
if (${N} in input) {
|
|
18
|
+
newResult[${N}] = undefined;
|
|
19
|
+
}
|
|
20
|
+
} else {
|
|
21
|
+
newResult[${N}] = ${V}.value;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
`):m.write(`
|
|
25
|
+
if (${V}.issues.length) {
|
|
26
|
+
payload.issues = payload.issues.concat(${V}.issues.map(iss => ({
|
|
27
|
+
...iss,
|
|
28
|
+
path: iss.path ? [${N}, ...iss.path] : [${N}]
|
|
29
|
+
})));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (${V}.value === undefined) {
|
|
33
|
+
if (${N} in input) {
|
|
34
|
+
newResult[${N}] = undefined;
|
|
35
|
+
}
|
|
36
|
+
} else {
|
|
37
|
+
newResult[${N}] = ${V}.value;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
`)}m.write("payload.value = newResult;"),m.write("return payload;");const R=m.compile();return(F,V)=>R(v,F,V)};let s;const o=Oa,a=!Ym.jitless,u=a&&GA.value,h=t.catchall;let p;r._zod.parse=(v,m)=>{p??(p=n.value);const x=v.value;return o(x)?a&&u&&(m==null?void 0:m.async)===!1&&m.jitless!==!0?(s||(s=i(t.shape)),v=s(v,m),h?dv([],x,v,m,p,r):v):e(v,m):(v.issues.push({expected:"object",code:"invalid_type",input:x,inst:r}),v)}});function lf(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=>!ei(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=>Rr(o,n,Cr())))}),t)}const PI=A("$ZodUnion",(r,t)=>{ge.init(r,t),ne(r._zod,"optin",()=>t.options.some(i=>i._zod.optin==="optional")?"optional":void 0),ne(r._zod,"optout",()=>t.options.some(i=>i._zod.optout==="optional")?"optional":void 0),ne(r._zod,"values",()=>{if(t.options.every(i=>i._zod.values))return new Set(t.options.flatMap(i=>Array.from(i._zod.values)))}),ne(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=>Eh(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=>lf(c,i,r,s)):lf(a,i,r,s)}}),DI=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])=>cf(e,c,u)):cf(e,s,o)}});function Jc(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(Ei(r)&&Ei(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=Jc(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=Jc(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 cf(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}),ei(r))return r;const o=Jc(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 LI=A("$ZodRecord",(r,t)=>{ge.init(r,t),r._zod.parse=(e,n)=>{const i=e.value;if(!Ei(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(...ti(u,p.issues)),e.value[u]=p.value})):(h.issues.length&&e.issues.push(...ti(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"&&sv.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=>Rr(p,n,Cr())),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(...ti(a,p.issues)),e.value[c.value]=p.value})):(h.issues.length&&e.issues.push(...ti(a,h.issues)),e.value[c.value]=h.value)}}return s.length?Promise.all(s).then(()=>e):e}}),zI=A("$ZodEnum",(r,t)=>{ge.init(r,t);const e=Xm(t.entries),n=new Set(e);r._zod.values=n,r._zod.pattern=new RegExp(`^(${e.filter(i=>jA.has(typeof i)).map(i=>typeof i=="string"?Ai(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}}),OI=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"?Ai(n):n?Ai(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}}),MI=A("$ZodTransform",(r,t)=>{ge.init(r,t),r._zod.parse=(e,n)=>{if(n.direction==="backward")throw new qm(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 ni;return e.value=i,e}});function uf(r,t){return r.issues.length&&t===void 0?{issues:[],value:void 0}:r}const pv=A("$ZodOptional",(r,t)=>{ge.init(r,t),r._zod.optin="optional",r._zod.optout="optional",ne(r._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),ne(r._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${Eh(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=>uf(s,e.value)):uf(i,e.value)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),NI=A("$ZodExactOptional",(r,t)=>{pv.init(r,t),ne(r._zod,"values",()=>t.innerType._zod.values),ne(r._zod,"pattern",()=>t.innerType._zod.pattern),r._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),UI=A("$ZodNullable",(r,t)=>{ge.init(r,t),ne(r._zod,"optin",()=>t.innerType._zod.optin),ne(r._zod,"optout",()=>t.innerType._zod.optout),ne(r._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${Eh(e.source)}|null)$`):void 0}),ne(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)}),FI=A("$ZodDefault",(r,t)=>{ge.init(r,t),r._zod.optin="optional",ne(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=>hf(s,t)):hf(i,t)}});function hf(r,t){return r.value===void 0&&(r.value=t.defaultValue),r}const WI=A("$ZodPrefault",(r,t)=>{ge.init(r,t),r._zod.optin="optional",ne(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))}),HI=A("$ZodNonOptional",(r,t)=>{ge.init(r,t),ne(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=>df(s,r)):df(i,r)}});function df(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 ZI=A("$ZodCatch",(r,t)=>{ge.init(r,t),ne(r._zod,"optin",()=>t.innerType._zod.optin),ne(r._zod,"optout",()=>t.innerType._zod.optout),ne(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=>Rr(o,n,Cr()))},input:e.value}),e.issues=[]),e)):(e.value=i.value,i.issues.length&&(e.value=t.catchValue({...e,error:{issues:i.issues.map(s=>Rr(s,n,Cr()))},input:e.value}),e.issues=[]),e)}}),BI=A("$ZodPipe",(r,t)=>{ge.init(r,t),ne(r._zod,"values",()=>t.in._zod.values),ne(r._zod,"optin",()=>t.in._zod.optin),ne(r._zod,"optout",()=>t.out._zod.optout),ne(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=>Yo(o,t.in,n)):Yo(s,t.in,n)}const i=t.in._zod.run(e,n);return i instanceof Promise?i.then(s=>Yo(s,t.out,n)):Yo(i,t.out,n)}});function Yo(r,t,e){return r.issues.length?(r.aborted=!0,r):t._zod.run({value:r.value,issues:r.issues},e)}const VI=A("$ZodReadonly",(r,t)=>{ge.init(r,t),ne(r._zod,"propValues",()=>t.innerType._zod.propValues),ne(r._zod,"values",()=>t.innerType._zod.values),ne(r._zod,"optin",()=>{var e,n;return(n=(e=t.innerType)==null?void 0:e._zod)==null?void 0:n.optin}),ne(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(pf):pf(i)}});function pf(r){return r.value=Object.freeze(r.value),r}const GI=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=>ff(s,e,n,r));ff(i,e,n,r)}});function ff(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(bs(i))}}var gf;class jI{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 qI(){return new jI}(gf=globalThis).__zod_globalRegistry??(gf.__zod_globalRegistry=qI());const ns=globalThis.__zod_globalRegistry;function YI(r,t){return new r({type:"string",...z(t)})}function XI(r,t){return new r({type:"string",format:"email",check:"string_format",abort:!1,...z(t)})}function mf(r,t){return new r({type:"string",format:"guid",check:"string_format",abort:!1,...z(t)})}function KI(r,t){return new r({type:"string",format:"uuid",check:"string_format",abort:!1,...z(t)})}function JI(r,t){return new r({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...z(t)})}function QI(r,t){return new r({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...z(t)})}function eT(r,t){return new r({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...z(t)})}function tT(r,t){return new r({type:"string",format:"url",check:"string_format",abort:!1,...z(t)})}function rT(r,t){return new r({type:"string",format:"emoji",check:"string_format",abort:!1,...z(t)})}function nT(r,t){return new r({type:"string",format:"nanoid",check:"string_format",abort:!1,...z(t)})}function iT(r,t){return new r({type:"string",format:"cuid",check:"string_format",abort:!1,...z(t)})}function sT(r,t){return new r({type:"string",format:"cuid2",check:"string_format",abort:!1,...z(t)})}function oT(r,t){return new r({type:"string",format:"ulid",check:"string_format",abort:!1,...z(t)})}function aT(r,t){return new r({type:"string",format:"xid",check:"string_format",abort:!1,...z(t)})}function lT(r,t){return new r({type:"string",format:"ksuid",check:"string_format",abort:!1,...z(t)})}function cT(r,t){return new r({type:"string",format:"ipv4",check:"string_format",abort:!1,...z(t)})}function uT(r,t){return new r({type:"string",format:"ipv6",check:"string_format",abort:!1,...z(t)})}function hT(r,t){return new r({type:"string",format:"cidrv4",check:"string_format",abort:!1,...z(t)})}function dT(r,t){return new r({type:"string",format:"cidrv6",check:"string_format",abort:!1,...z(t)})}function pT(r,t){return new r({type:"string",format:"base64",check:"string_format",abort:!1,...z(t)})}function fT(r,t){return new r({type:"string",format:"base64url",check:"string_format",abort:!1,...z(t)})}function gT(r,t){return new r({type:"string",format:"e164",check:"string_format",abort:!1,...z(t)})}function mT(r,t){return new r({type:"string",format:"jwt",check:"string_format",abort:!1,...z(t)})}function vT(r,t){return new r({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...z(t)})}function yT(r,t){return new r({type:"string",format:"date",check:"string_format",...z(t)})}function bT(r,t){return new r({type:"string",format:"time",check:"string_format",precision:null,...z(t)})}function wT(r,t){return new r({type:"string",format:"duration",check:"string_format",...z(t)})}function ST(r,t){return new r({type:"number",checks:[],...z(t)})}function _T(r,t){return new r({type:"number",check:"number_format",abort:!1,format:"safeint",...z(t)})}function kT(r,t){return new r({type:"boolean",...z(t)})}function xT(r){return new r({type:"unknown"})}function ET(r,t){return new r({type:"never",...z(t)})}function vf(r,t){return new av({check:"less_than",...z(t),value:r,inclusive:!1})}function gc(r,t){return new av({check:"less_than",...z(t),value:r,inclusive:!0})}function yf(r,t){return new lv({check:"greater_than",...z(t),value:r,inclusive:!1})}function mc(r,t){return new lv({check:"greater_than",...z(t),value:r,inclusive:!0})}function bf(r,t){return new F$({check:"multiple_of",...z(t),value:r})}function fv(r,t){return new H$({check:"max_length",...z(t),maximum:r})}function Na(r,t){return new Z$({check:"min_length",...z(t),minimum:r})}function gv(r,t){return new B$({check:"length_equals",...z(t),length:r})}function AT(r,t){return new V$({check:"string_format",format:"regex",...z(t),pattern:r})}function $T(r){return new G$({check:"string_format",format:"lowercase",...z(r)})}function IT(r){return new j$({check:"string_format",format:"uppercase",...z(r)})}function TT(r,t){return new q$({check:"string_format",format:"includes",...z(t),includes:r})}function CT(r,t){return new Y$({check:"string_format",format:"starts_with",...z(t),prefix:r})}function RT(r,t){return new X$({check:"string_format",format:"ends_with",...z(t),suffix:r})}function Mi(r){return new K$({check:"overwrite",tx:r})}function PT(r){return Mi(t=>t.normalize(r))}function DT(){return Mi(r=>r.trim())}function LT(){return Mi(r=>r.toLowerCase())}function zT(){return Mi(r=>r.toUpperCase())}function OT(){return Mi(r=>VA(r))}function MT(r,t,e){return new r({type:"array",element:t,...z(e)})}function NT(r,t,e){return new r({type:"custom",check:"custom",fn:t,...z(e)})}function UT(r){const t=FT(e=>(e.addIssue=n=>{if(typeof n=="string")e.issues.push(bs(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(bs(i))}},r(e.value,e)));return t}function FT(r,t){const e=new st({check:"custom",...z(t)});return e._zod.check=r,e}function mv(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)??ns,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 xe(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 v={...e,schemaPath:[...e.schemaPath,r],path:e.path};if(r._zod.processJSONSchema)r._zod.processJSONSchema(t,o.schema,v);else{const x=o.schema,E=t.processors[i.type];if(!E)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);E(r,t,x,v)}const m=r._zod.parent;m&&(o.ref||(o.ref=m),xe(m,t,v),t.seen.get(m).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 vv(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 v=n.get(p);if(v&&v!==h[0])throw new Error(`Duplicate schema id "${p}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);n.set(p,h[0])}}const i=h=>{var E;const p=r.target==="draft-2020-12"?"$defs":"definitions";if(r.external){const T=(E=r.external.registry.get(h[0]))==null?void 0:E.id,O=r.external.uri??(Z=>Z);if(T)return{ref:O(T)};const R=h[1].defId??h[1].schema.id??`schema${r.counter++}`;return h[1].defId=R,{defId:R,ref:`${O("__shared")}#/${p}/${R}`}}if(h[1]===e)return{ref:"#"};const m=`#/${p}/`,x=h[1].schema.id??`__schema${r.counter++}`;return{defId:x,ref:m+x}},s=h=>{if(h[1].schema.$ref)return;const p=h[1],{ref:v,defId:m}=i(h);p.def={...p.schema},m&&(p.defId=m);const x=p.schema;for(const E in x)delete x[E];x.$ref=v};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 m=(c=r.external.registry.get(h[0]))==null?void 0:c.id;if(t!==h[0]&&m){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 yv(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,v={...p},m=h.ref;if(h.ref=null,m){n(m);const E=r.seen.get(m),T=E.schema;if(T.$ref&&(r.target==="draft-07"||r.target==="draft-04"||r.target==="openapi-3.0")?(p.allOf=p.allOf??[],p.allOf.push(T)):Object.assign(p,T),Object.assign(p,v),u._zod.parent===m)for(const R in p)R==="$ref"||R==="allOf"||R in v||delete p[R];if(T.$ref&&E.def)for(const R in p)R==="$ref"||R==="allOf"||R in E.def&&JSON.stringify(p[R])===JSON.stringify(E.def[R])&&delete p[R]}const x=u._zod.parent;if(x&&x!==m){n(x);const E=r.seen.get(x);if(E!=null&&E.schema.$ref&&(p.$ref=E.schema.$ref,E.def))for(const T in p)T==="$ref"||T==="allOf"||T in E.def&&JSON.stringify(p[T])===JSON.stringify(E.def[T])&&delete p[T]}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:Ua(t,"input",r.processors),output:Ua(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 WT=(r,t={})=>e=>{const n=mv({...e,processors:t});return xe(r,n),vv(n,r),yv(n,r)},Ua=(r,t,e={})=>n=>{const{libraryOptions:i,target:s}=n??{},o=mv({...i??{},target:s,io:t,processors:e});return xe(r,o),vv(o,r),yv(o,r)},HT={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},ZT=(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=HT[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}))])}},BT=(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)},VT=(r,t,e,n)=>{e.type="boolean"},GT=(r,t,e,n)=>{e.not={}},jT=(r,t,e,n)=>{},qT=(r,t,e,n)=>{const i=r._zod.def,s=Xm(i.entries);s.every(o=>typeof o=="number")&&(e.type="number"),s.every(o=>typeof o=="string")&&(e.type="string"),e.enum=s},YT=(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},XT=(r,t,e,n)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},KT=(r,t,e,n)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},JT=(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=xe(s.element,t,{...n,path:[...n.path,"items"]})},QT=(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]=xe(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=xe(s.catchall,t,{...n,path:[...n.path,"additionalProperties"]})):t.io==="output"&&(i.additionalProperties=!1)},eC=(r,t,e,n)=>{const i=r._zod.def,s=i.inclusive===!1,o=i.options.map((a,c)=>xe(a,t,{...n,path:[...n.path,s?"oneOf":"anyOf",c]}));s?e.oneOf=o:e.anyOf=o},tC=(r,t,e,n)=>{const i=r._zod.def,s=xe(i.left,t,{...n,path:[...n.path,"allOf",0]}),o=xe(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},rC=(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=xe(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=xe(s.keyType,t,{...n,path:[...n.path,"propertyNames"]})),i.additionalProperties=xe(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)}},nC=(r,t,e,n)=>{const i=r._zod.def,s=xe(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"}]},iC=(r,t,e,n)=>{const i=r._zod.def;xe(i.innerType,t,n);const s=t.seen.get(r);s.ref=i.innerType},sC=(r,t,e,n)=>{const i=r._zod.def;xe(i.innerType,t,n);const s=t.seen.get(r);s.ref=i.innerType,e.default=JSON.parse(JSON.stringify(i.defaultValue))},oC=(r,t,e,n)=>{const i=r._zod.def;xe(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)))},aC=(r,t,e,n)=>{const i=r._zod.def;xe(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},lC=(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;xe(s,t,n);const o=t.seen.get(r);o.ref=s},cC=(r,t,e,n)=>{const i=r._zod.def;xe(i.innerType,t,n);const s=t.seen.get(r);s.ref=i.innerType,e.readOnly=!0},bv=(r,t,e,n)=>{const i=r._zod.def;xe(i.innerType,t,n);const s=t.seen.get(r);s.ref=i.innerType},uC=A("ZodISODateTime",(r,t)=>{hI.init(r,t),ve.init(r,t)});function hC(r){return vT(uC,r)}const dC=A("ZodISODate",(r,t)=>{dI.init(r,t),ve.init(r,t)});function pC(r){return yT(dC,r)}const fC=A("ZodISOTime",(r,t)=>{pI.init(r,t),ve.init(r,t)});function gC(r){return bT(fC,r)}const mC=A("ZodISODuration",(r,t)=>{fI.init(r,t),ve.init(r,t)});function vC(r){return wT(mC,r)}const wv=(r,t)=>{ev.init(r,t),r.name="ZodError",Object.defineProperties(r,{format:{value:e=>i$(r,e)},flatten:{value:e=>n$(r,e)},addIssue:{value:e=>{r.issues.push(e),r.message=JSON.stringify(r.issues,Kc,2)}},addIssues:{value:e=>{r.issues.push(...e),r.message=JSON.stringify(r.issues,Kc,2)}},isEmpty:{get(){return r.issues.length===0}}})},wf=A("ZodError",wv),yt=A("ZodError",wv,{Parent:Error}),yC=$h(yt),bC=Ih(yt),wC=vl(yt),SC=yl(yt),_C=a$(yt),kC=l$(yt),xC=c$(yt),EC=u$(yt),AC=h$(yt),$C=d$(yt),IC=p$(yt),TC=f$(yt),me=A("ZodType",(r,t)=>(ge.init(r,t),Object.assign(r["~standard"],{jsonSchema:{input:Ua(r,"input"),output:Ua(r,"output")}}),r.toJSONSchema=WT(r,{}),r.def=t,r.type=t.type,Object.defineProperty(r,"_def",{value:t}),r.check=(...e)=>r.clone(Or(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)=>Mr(r,e,n),r.brand=()=>r,r.register=(e,n)=>(e.add(r,n),r),r.parse=(e,n)=>yC(r,e,n,{callee:r.parse}),r.safeParse=(e,n)=>wC(r,e,n),r.parseAsync=async(e,n)=>bC(r,e,n,{callee:r.parseAsync}),r.safeParseAsync=async(e,n)=>SC(r,e,n),r.spa=r.safeParseAsync,r.encode=(e,n)=>_C(r,e,n),r.decode=(e,n)=>kC(r,e,n),r.encodeAsync=async(e,n)=>xC(r,e,n),r.decodeAsync=async(e,n)=>EC(r,e,n),r.safeEncode=(e,n)=>AC(r,e,n),r.safeDecode=(e,n)=>$C(r,e,n),r.safeEncodeAsync=async(e,n)=>IC(r,e,n),r.safeDecodeAsync=async(e,n)=>TC(r,e,n),r.refine=(e,n)=>r.check(w1(e,n)),r.superRefine=e=>r.check(S1(e)),r.overwrite=e=>r.check(Mi(e)),r.optional=()=>kf(r),r.exactOptional=()=>a1(r),r.nullable=()=>xf(r),r.nullish=()=>kf(xf(r)),r.nonoptional=e=>p1(r,e),r.array=()=>D(r),r.or=e=>G([r,e]),r.and=e=>wl(r,e),r.transform=e=>Ef(r,s1(e)),r.default=e=>u1(r,e),r.prefault=e=>d1(r,e),r.catch=e=>g1(r,e),r.pipe=e=>Ef(r,e),r.readonly=()=>y1(r),r.describe=e=>{const n=r.clone();return ns.add(n,{description:e}),n},Object.defineProperty(r,"description",{get(){var e;return(e=ns.get(r))==null?void 0:e.description},configurable:!0}),r.meta=(...e)=>{if(e.length===0)return ns.get(r);const n=r.clone();return ns.add(n,e[0]),n},r.isOptional=()=>r.safeParse(void 0).success,r.isNullable=()=>r.safeParse(null).success,r.apply=e=>e(r),r)),Sv=A("_ZodString",(r,t)=>{Th.init(r,t),me.init(r,t),r._zod.processJSONSchema=(n,i,s)=>ZT(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(AT(...n)),r.includes=(...n)=>r.check(TT(...n)),r.startsWith=(...n)=>r.check(CT(...n)),r.endsWith=(...n)=>r.check(RT(...n)),r.min=(...n)=>r.check(Na(...n)),r.max=(...n)=>r.check(fv(...n)),r.length=(...n)=>r.check(gv(...n)),r.nonempty=(...n)=>r.check(Na(1,...n)),r.lowercase=n=>r.check($T(n)),r.uppercase=n=>r.check(IT(n)),r.trim=()=>r.check(DT()),r.normalize=(...n)=>r.check(PT(...n)),r.toLowerCase=()=>r.check(LT()),r.toUpperCase=()=>r.check(zT()),r.slugify=()=>r.check(OT())}),CC=A("ZodString",(r,t)=>{Th.init(r,t),Sv.init(r,t),r.email=e=>r.check(XI(RC,e)),r.url=e=>r.check(tT(PC,e)),r.jwt=e=>r.check(mT(jC,e)),r.emoji=e=>r.check(rT(DC,e)),r.guid=e=>r.check(mf(Sf,e)),r.uuid=e=>r.check(KI(Xo,e)),r.uuidv4=e=>r.check(JI(Xo,e)),r.uuidv6=e=>r.check(QI(Xo,e)),r.uuidv7=e=>r.check(eT(Xo,e)),r.nanoid=e=>r.check(nT(LC,e)),r.guid=e=>r.check(mf(Sf,e)),r.cuid=e=>r.check(iT(zC,e)),r.cuid2=e=>r.check(sT(OC,e)),r.ulid=e=>r.check(oT(MC,e)),r.base64=e=>r.check(pT(BC,e)),r.base64url=e=>r.check(fT(VC,e)),r.xid=e=>r.check(aT(NC,e)),r.ksuid=e=>r.check(lT(UC,e)),r.ipv4=e=>r.check(cT(FC,e)),r.ipv6=e=>r.check(uT(WC,e)),r.cidrv4=e=>r.check(hT(HC,e)),r.cidrv6=e=>r.check(dT(ZC,e)),r.e164=e=>r.check(gT(GC,e)),r.datetime=e=>r.check(hC(e)),r.date=e=>r.check(pC(e)),r.time=e=>r.check(gC(e)),r.duration=e=>r.check(vC(e))});function d(r){return YI(CC,r)}const ve=A("ZodStringFormat",(r,t)=>{de.init(r,t),Sv.init(r,t)}),RC=A("ZodEmail",(r,t)=>{rI.init(r,t),ve.init(r,t)}),Sf=A("ZodGUID",(r,t)=>{eI.init(r,t),ve.init(r,t)}),Xo=A("ZodUUID",(r,t)=>{tI.init(r,t),ve.init(r,t)}),PC=A("ZodURL",(r,t)=>{nI.init(r,t),ve.init(r,t)}),DC=A("ZodEmoji",(r,t)=>{iI.init(r,t),ve.init(r,t)}),LC=A("ZodNanoID",(r,t)=>{sI.init(r,t),ve.init(r,t)}),zC=A("ZodCUID",(r,t)=>{oI.init(r,t),ve.init(r,t)}),OC=A("ZodCUID2",(r,t)=>{aI.init(r,t),ve.init(r,t)}),MC=A("ZodULID",(r,t)=>{lI.init(r,t),ve.init(r,t)}),NC=A("ZodXID",(r,t)=>{cI.init(r,t),ve.init(r,t)}),UC=A("ZodKSUID",(r,t)=>{uI.init(r,t),ve.init(r,t)}),FC=A("ZodIPv4",(r,t)=>{gI.init(r,t),ve.init(r,t)}),WC=A("ZodIPv6",(r,t)=>{mI.init(r,t),ve.init(r,t)}),HC=A("ZodCIDRv4",(r,t)=>{vI.init(r,t),ve.init(r,t)}),ZC=A("ZodCIDRv6",(r,t)=>{yI.init(r,t),ve.init(r,t)}),BC=A("ZodBase64",(r,t)=>{bI.init(r,t),ve.init(r,t)}),VC=A("ZodBase64URL",(r,t)=>{SI.init(r,t),ve.init(r,t)}),GC=A("ZodE164",(r,t)=>{_I.init(r,t),ve.init(r,t)}),jC=A("ZodJWT",(r,t)=>{xI.init(r,t),ve.init(r,t)}),_v=A("ZodNumber",(r,t)=>{uv.init(r,t),me.init(r,t),r._zod.processJSONSchema=(n,i,s)=>BT(r,n,i),r.gt=(n,i)=>r.check(yf(n,i)),r.gte=(n,i)=>r.check(mc(n,i)),r.min=(n,i)=>r.check(mc(n,i)),r.lt=(n,i)=>r.check(vf(n,i)),r.lte=(n,i)=>r.check(gc(n,i)),r.max=(n,i)=>r.check(gc(n,i)),r.int=n=>r.check(_f(n)),r.safe=n=>r.check(_f(n)),r.positive=n=>r.check(yf(0,n)),r.nonnegative=n=>r.check(mc(0,n)),r.negative=n=>r.check(vf(0,n)),r.nonpositive=n=>r.check(gc(0,n)),r.multipleOf=(n,i)=>r.check(bf(n,i)),r.step=(n,i)=>r.check(bf(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 W(r){return ST(_v,r)}const qC=A("ZodNumberFormat",(r,t)=>{EI.init(r,t),_v.init(r,t)});function _f(r){return _T(qC,r)}const YC=A("ZodBoolean",(r,t)=>{AI.init(r,t),me.init(r,t),r._zod.processJSONSchema=(e,n,i)=>VT(r,e,n)});function Re(r){return kT(YC,r)}const XC=A("ZodUnknown",(r,t)=>{$I.init(r,t),me.init(r,t),r._zod.processJSONSchema=(e,n,i)=>jT()});function S(){return xT(XC)}const KC=A("ZodNever",(r,t)=>{II.init(r,t),me.init(r,t),r._zod.processJSONSchema=(e,n,i)=>GT(r,e,n)});function JC(r){return ET(KC,r)}const QC=A("ZodArray",(r,t)=>{TI.init(r,t),me.init(r,t),r._zod.processJSONSchema=(e,n,i)=>JT(r,e,n,i),r.element=t.element,r.min=(e,n)=>r.check(Na(e,n)),r.nonempty=e=>r.check(Na(1,e)),r.max=(e,n)=>r.check(fv(e,n)),r.length=(e,n)=>r.check(gv(e,n)),r.unwrap=()=>r.element});function D(r,t){return MT(QC,r,t)}const kv=A("ZodObject",(r,t)=>{RI.init(r,t),me.init(r,t),r._zod.processJSONSchema=(e,n,i)=>QT(r,e,n,i),ne(r,"shape",()=>t.shape),r.keyof=()=>ws(Object.keys(r._zod.def.shape)),r.catchall=e=>r.clone({...r._zod.def,catchall:e}),r.passthrough=()=>r.clone({...r._zod.def,catchall:S()}),r.loose=()=>r.clone({...r._zod.def,catchall:S()}),r.strict=()=>r.clone({...r._zod.def,catchall:JC()}),r.strip=()=>r.clone({...r._zod.def,catchall:void 0}),r.extend=e=>JA(r,e),r.safeExtend=e=>QA(r,e),r.merge=e=>e$(r,e),r.pick=e=>XA(r,e),r.omit=e=>KA(r,e),r.partial=(...e)=>t$(Ev,r,e[0]),r.required=(...e)=>r$(Av,r,e[0])});function xv(r,t){const e={type:"object",shape:r??{},...z(t)};return new kv(e)}function g(r,t){return new kv({type:"object",shape:r,catchall:S(),...z(t)})}const e1=A("ZodUnion",(r,t)=>{PI.init(r,t),me.init(r,t),r._zod.processJSONSchema=(e,n,i)=>eC(r,e,n,i),r.options=t.options});function G(r,t){return new e1({type:"union",options:r,...z(t)})}const t1=A("ZodIntersection",(r,t)=>{DI.init(r,t),me.init(r,t),r._zod.processJSONSchema=(e,n,i)=>tC(r,e,n,i)});function wl(r,t){return new t1({type:"intersection",left:r,right:t})}const r1=A("ZodRecord",(r,t)=>{LI.init(r,t),me.init(r,t),r._zod.processJSONSchema=(e,n,i)=>rC(r,e,n,i),r.keyType=t.keyType,r.valueType=t.valueType});function _(r,t,e){return new r1({type:"record",keyType:r,valueType:t,...z(e)})}const Qc=A("ZodEnum",(r,t)=>{zI.init(r,t),me.init(r,t),r._zod.processJSONSchema=(n,i,s)=>qT(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 Qc({...t,checks:[],...z(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 Qc({...t,checks:[],...z(i),entries:s})}});function ws(r,t){const e=Array.isArray(r)?Object.fromEntries(r.map(n=>[n,n])):r;return new Qc({type:"enum",entries:e,...z(t)})}const n1=A("ZodLiteral",(r,t)=>{OI.init(r,t),me.init(r,t),r._zod.processJSONSchema=(e,n,i)=>YT(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 n1({type:"literal",values:Array.isArray(r)?r:[r],...z(t)})}const i1=A("ZodTransform",(r,t)=>{MI.init(r,t),me.init(r,t),r._zod.processJSONSchema=(e,n,i)=>KT(r,e),r._zod.parse=(e,n)=>{if(n.direction==="backward")throw new qm(r.constructor.name);e.addIssue=s=>{if(typeof s=="string")e.issues.push(bs(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(bs(o))}};const i=t.transform(e.value,e);return i instanceof Promise?i.then(s=>(e.value=s,e)):(e.value=i,e)}});function s1(r){return new i1({type:"transform",transform:r})}const Ev=A("ZodOptional",(r,t)=>{pv.init(r,t),me.init(r,t),r._zod.processJSONSchema=(e,n,i)=>bv(r,e,n,i),r.unwrap=()=>r._zod.def.innerType});function kf(r){return new Ev({type:"optional",innerType:r})}const o1=A("ZodExactOptional",(r,t)=>{NI.init(r,t),me.init(r,t),r._zod.processJSONSchema=(e,n,i)=>bv(r,e,n,i),r.unwrap=()=>r._zod.def.innerType});function a1(r){return new o1({type:"optional",innerType:r})}const l1=A("ZodNullable",(r,t)=>{UI.init(r,t),me.init(r,t),r._zod.processJSONSchema=(e,n,i)=>nC(r,e,n,i),r.unwrap=()=>r._zod.def.innerType});function xf(r){return new l1({type:"nullable",innerType:r})}const c1=A("ZodDefault",(r,t)=>{FI.init(r,t),me.init(r,t),r._zod.processJSONSchema=(e,n,i)=>sC(r,e,n,i),r.unwrap=()=>r._zod.def.innerType,r.removeDefault=r.unwrap});function u1(r,t){return new c1({type:"default",innerType:r,get defaultValue(){return typeof t=="function"?t():Jm(t)}})}const h1=A("ZodPrefault",(r,t)=>{WI.init(r,t),me.init(r,t),r._zod.processJSONSchema=(e,n,i)=>oC(r,e,n,i),r.unwrap=()=>r._zod.def.innerType});function d1(r,t){return new h1({type:"prefault",innerType:r,get defaultValue(){return typeof t=="function"?t():Jm(t)}})}const Av=A("ZodNonOptional",(r,t)=>{HI.init(r,t),me.init(r,t),r._zod.processJSONSchema=(e,n,i)=>iC(r,e,n,i),r.unwrap=()=>r._zod.def.innerType});function p1(r,t){return new Av({type:"nonoptional",innerType:r,...z(t)})}const f1=A("ZodCatch",(r,t)=>{ZI.init(r,t),me.init(r,t),r._zod.processJSONSchema=(e,n,i)=>aC(r,e,n,i),r.unwrap=()=>r._zod.def.innerType,r.removeCatch=r.unwrap});function g1(r,t){return new f1({type:"catch",innerType:r,catchValue:typeof t=="function"?t:()=>t})}const m1=A("ZodPipe",(r,t)=>{BI.init(r,t),me.init(r,t),r._zod.processJSONSchema=(e,n,i)=>lC(r,e,n,i),r.in=t.in,r.out=t.out});function Ef(r,t){return new m1({type:"pipe",in:r,out:t})}const v1=A("ZodReadonly",(r,t)=>{VI.init(r,t),me.init(r,t),r._zod.processJSONSchema=(e,n,i)=>cC(r,e,n,i),r.unwrap=()=>r._zod.def.innerType});function y1(r){return new v1({type:"readonly",innerType:r})}const b1=A("ZodCustom",(r,t)=>{GI.init(r,t),me.init(r,t),r._zod.processJSONSchema=(e,n,i)=>XT(r,e)});function w1(r,t={}){return NT(b1,r,t)}function S1(r){return UT(r)}const Yt={custom:"custom"},$v=["markdown","web-bundle","url"],_1=["committed","pending"];function k1(r){let t;try{t=new URL(r)}catch{return!1}return t.protocol==="http:"||t.protocol==="https:"}xv({id:d().min(1),kind:ws($v),title:d(),status:ws(_1),externalFilePath:d().optional(),externalURL:d().optional()}).superRefine((r,t)=>{switch(r.externalFilePath!==void 0&&r.externalURL!==void 0&&t.addIssue({code:Yt.custom,message:"externalFilePath and externalURL are mutually exclusive",path:["externalURL"]}),r.kind!=="web-bundle"&&r.status!=="committed"&&t.addIssue({code:Yt.custom,message:"only web-bundle artifacts can be pending",path:["status"]}),r.kind){case"markdown":r.externalFilePath===void 0&&t.addIssue({code:Yt.custom,message:"markdown artifacts require externalFilePath",path:["externalFilePath"]}),r.externalURL!==void 0&&t.addIssue({code:Yt.custom,message:"markdown artifacts cannot set externalURL",path:["externalURL"]});break;case"web-bundle":r.externalFilePath!==void 0&&t.addIssue({code:Yt.custom,message:"web-bundle artifacts cannot set externalFilePath",path:["externalFilePath"]}),r.externalURL!==void 0&&t.addIssue({code:Yt.custom,message:"web-bundle artifacts cannot set externalURL",path:["externalURL"]});break;case"url":if(r.externalURL===void 0){t.addIssue({code:Yt.custom,message:"url artifacts require externalURL",path:["externalURL"]});break}r.externalFilePath!==void 0&&t.addIssue({code:Yt.custom,message:"url artifacts cannot set externalFilePath",path:["externalFilePath"]}),k1(r.externalURL)||t.addIssue({code:Yt.custom,message:"externalURL must be an http(s) URL",path:["externalURL"]});break}});xv({name:d().min(1),description:d(),accepts:D(ws($v)).min(1)});function Iv(r){return typeof r=="object"&&r!==null}function x1(r){return!Iv(r)||r.type!=="ready"?!1:!("id"in r)}function E1(r){return!(!Iv(r)||r.type!=="update-content"||typeof r.id!="string"||typeof r.content!="string")}function A1(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"},Xt={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"},$1=1,I1=g({_meta:_(d(),S()).nullish(),terminal:Re().optional().default(!1)}),T1=g({_meta:_(d(),S()).nullish(),label:d().nullish(),name:d(),optional:Re().optional().default(!1),secret:Re().optional().default(!0)}),C1=g({_meta:_(d(),S()).nullish(),description:d().nullish(),id:d(),name:d()}),R1=g({_meta:_(d(),S()).nullish(),description:d().nullish(),id:d(),link:d().nullish(),name:d(),vars:D(T1)}),P1=g({_meta:_(d(),S()).nullish(),args:D(d()).optional(),description:d().nullish(),env:_(d(),d()).optional(),id:d(),name:d()}),D1=G([R1.and(g({type:$("env_var")})),P1.and(g({type:$("terminal")})),C1]),L1=g({_meta:_(d(),S()).nullish(),methodId:d()}),z1=g({_meta:_(d(),S()).nullish()}),O1=g({_meta:_(d(),S()).nullish(),blob:d(),mimeType:d().nullish(),uri:d()}),M1=g({default:Re().nullish(),description:d().nullish(),title:d().nullish()}),N1=g({_meta:_(d(),S()).nullish()}),U1=g({_meta:_(d(),S()).nullish()}),F1=g({amount:W(),currency:d()}),W1=g({_meta:_(d(),S()).nullish(),terminalId:d()}),H1=g({_meta:_(d(),S()).nullish(),newText:d(),oldText:d().nullish(),path:d()}),Z1=G([d(),W(),W(),Re(),D(d())]),B1=g({content:_(d(),Z1).nullish()}),V1=G([B1.and(g({action:$("accept")})),g({action:$("decline")}),g({action:$("cancel")})]),G1=g({_meta:_(d(),S()).nullish()}),Tv=d(),j1=g({_meta:_(d(),S()).nullish(),elicitationId:Tv}),q1=g({_meta:_(d(),S()).nullish(),action:V1}),Y1=$("object"),X1=$("string"),K1=g({_meta:_(d(),S()).nullish()}),J1=g({_meta:_(d(),S()).nullish(),form:G1.nullish(),url:K1.nullish()}),Q1=g({elicitationId:Tv,url:d().url()}),Cv=g({const:d(),title:d()}),Rv=g({_meta:_(d(),S()).nullish(),name:d(),value:d()}),eR=G([$(-32700),$(-32600),$(-32601),$(-32602),$(-32603),$(-32800),$(-32e3),$(-32002),$(-32042),W().int().min(-2147483648,{message:"Invalid value: Expected int32 to be >= -2147483648"}).max(2147483647,{message:"Invalid value: Expected int32 to be <= 2147483647"})]),Pv=g({code:eR,data:S().optional(),message:d()}),Dv=S(),Lv=S(),zv=S(),tR=g({_meta:_(d(),S()).nullish(),readTextFile:Re().optional().default(!1),writeTextFile:Re().optional().default(!1)}),Ov=g({_meta:_(d(),S()).nullish(),name:d(),value:d()}),Mv=g({_meta:_(d(),S()).nullish(),name:d(),title:d().nullish(),version:d()}),rR=g({default:W().nullish(),description:d().nullish(),maximum:W().nullish(),minimum:W().nullish(),title:d().nullish()}),nR=g({_meta:_(d(),S()).nullish()}),iR=g({_meta:_(d(),S()).nullish(),additionalDirectories:D(d()).optional(),cursor:d().nullish(),cwd:d().nullish()}),sR=g({_meta:_(d(),S()).nullish()}),oR=g({_meta:_(d(),S()).nullish(),logout:sR.nullish()}),aR=g({_meta:_(d(),S()).nullish()}),lR=g({_meta:_(d(),S()).nullish()}),cR=g({_meta:_(d(),S()).nullish(),http:Re().optional().default(!1),sse:Re().optional().default(!1)}),uR=g({_meta:_(d(),S()).nullish(),headers:D(Ov),name:d(),url:d()}),hR=g({_meta:_(d(),S()).nullish(),headers:D(Ov),name:d(),url:d()}),dR=g({_meta:_(d(),S()).nullish(),args:D(d()),command:d(),env:D(Rv),name:d()}),Sl=G([uR.and(g({type:$("http")})),hR.and(g({type:$("sse")})),dR]),Ch=d(),pR=g({_meta:_(d(),S()).nullish(),description:d().nullish(),modelId:Ch,name:d()}),fR=G([$("error"),$("warning"),$("information"),$("hint")]),gR=g({_meta:_(d(),S()).nullish()}),mR=g({_meta:_(d(),S()).nullish()}),vR=g({_meta:_(d(),S()).nullish()}),yR=g({_meta:_(d(),S()).nullish()}),bR=g({_meta:_(d(),S()).nullish()}),wR=g({_meta:_(d(),S()).nullish(),maxCount:W().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),SR=g({diff:d(),uri:d()}),_R=g({endLine:W().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),startLine:W().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),text:d()}),kR=g({_meta:_(d(),S()).nullish()}),xR=g({_meta:_(d(),S()).nullish()}),ER=g({languageId:d(),text:d(),uri:d()}),AR=g({_meta:_(d(),S()).nullish(),maxCount:W().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),$R=G([$("rejected"),$("ignored"),$("replaced"),$("cancelled")]),IR=g({excerpts:D(_R),uri:d()}),TR=g({_meta:_(d(),S()).nullish()}),CR=g({_meta:_(d(),S()).nullish()}),RR=g({name:d(),owner:d(),remoteUrl:d()}),PR=g({_meta:_(d(),S()).nullish()}),DR=g({_meta:_(d(),S()).nullish(),jump:kR.nullish(),rename:CR.nullish(),searchAndReplace:PR.nullish()}),LR=g({id:d(),isRegex:Re().nullish(),replace:d(),search:d(),uri:d()}),zR=G([$("automatic"),$("diagnostic"),$("manual")]),OR=g({_meta:_(d(),S()).nullish(),maxCount:W().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),MR=g({_meta:_(d(),S()).nullish(),diagnostics:gR.nullish(),editHistory:wR.nullish(),openFiles:xR.nullish(),recentFiles:AR.nullish(),relatedSnippets:TR.nullish(),userActions:OR.nullish()}),NR=g({_meta:_(d(),S()).nullish(),additionalDirectories:D(d()).optional(),cwd:d(),mcpServers:D(Sl)}),UR=g({default:W().nullish(),description:d().nullish(),maximum:W().nullish(),minimum:W().nullish(),title:d().nullish()}),Nv=d(),FR=G([$("allow_once"),$("allow_always"),$("reject_once"),$("reject_always")]),WR=g({_meta:_(d(),S()).nullish(),kind:FR,name:d(),optionId:Nv}),HR=G([$("high"),$("medium"),$("low")]),ZR=G([$("pending"),$("in_progress"),$("completed")]),BR=g({_meta:_(d(),S()).nullish(),content:d(),priority:HR,status:ZR}),VR=g({_meta:_(d(),S()).nullish(),entries:D(BR)}),Pr=g({character:W().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),line:W().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"})}),GR=g({id:d(),position:Pr,uri:d()}),jR=g({id:d(),newName:d(),position:Pr,uri:d()}),qR=g({action:d(),position:Pr,timestampMs:W(),uri:d()}),Uv=G([$("utf-16"),$("utf-32"),$("utf-8")]),YR=g({_meta:_(d(),S()).nullish(),auth:I1.optional().default({terminal:!1}),elicitation:J1.nullish(),fs:tR.optional().default({readTextFile:!1,writeTextFile:!1}),nes:DR.nullish(),positionEncodings:D(Uv).optional(),terminal:Re().optional().default(!1)}),XR=g({_meta:_(d(),S()).nullish(),audio:Re().optional().default(!1),embeddedContext:Re().optional().default(!1),image:Re().optional().default(!1)}),Fv=W().int().gte(0).lte(65535),KR=g({_meta:_(d(),S()).nullish(),clientCapabilities:YR.optional().default({auth:{terminal:!1},fs:{readTextFile:!1,writeTextFile:!1},terminal:!1}),clientInfo:Mv.nullish(),protocolVersion:Fv}),Ni=g({end:Pr,start:Pr}),JR=g({message:d(),range:Ni,severity:fR,uri:d()}),QR=g({languageId:d(),lastFocusedMs:W().nullish(),uri:d(),visibleRange:Ni.nullish()}),eP=g({_meta:_(d(),S()).nullish(),diagnostics:D(JR).nullish(),editHistory:D(SR).nullish(),openFiles:D(QR).nullish(),recentFiles:D(ER).nullish(),relatedSnippets:D(IR).nullish(),userActions:D(qR).nullish()}),tP=g({newText:d(),range:Ni}),rP=g({cursorPosition:Pr.nullish(),edits:D(tP),id:d(),uri:d()}),nP=G([rP.and(g({kind:$("edit")})),GR.and(g({kind:$("jump")})),jR.and(g({kind:$("rename")})),LR.and(g({kind:$("searchAndReplace")}))]),iP=g({_meta:_(d(),S()).nullish(),content:d()}),sP=g({_meta:_(d(),S()).nullish()}),Sn=G([W(),d()]).nullable();g({_meta:_(d(),S()).nullish(),requestId:Sn});const oP=ws(["assistant","user"]),$o=g({_meta:_(d(),S()).nullish(),audience:D(oP).nullish(),lastModified:d().nullish(),priority:W().nullish()}),aP=g({_meta:_(d(),S()).nullish(),annotations:$o.nullish(),data:d(),mimeType:d()}),lP=g({_meta:_(d(),S()).nullish(),annotations:$o.nullish(),data:d(),mimeType:d(),uri:d().nullish()}),cP=g({_meta:_(d(),S()).nullish(),annotations:$o.nullish(),description:d().nullish(),mimeType:d().nullish(),name:d(),size:W().nullish(),title:d().nullish(),uri:d()}),uP=g({_meta:_(d(),S()).nullish(),optionId:Nv}),hP=G([g({outcome:$("cancelled")}),uP.and(g({outcome:$("selected")}))]),dP=g({_meta:_(d(),S()).nullish(),outcome:hP}),pP=g({_meta:_(d(),S()).nullish()}),fP=g({_meta:_(d(),S()).nullish()}),gP=g({currentValue:Re()}),mP=d(),Wv=d(),vP=G([$("mode"),$("model"),$("thought_level"),d()]),Rh=d(),Hv=g({_meta:_(d(),S()).nullish(),description:d().nullish(),name:d(),value:Rh}),yP=g({_meta:_(d(),S()).nullish(),group:mP,name:d(),options:D(Hv)}),bP=G([D(Hv),D(yP)]),wP=g({currentValue:Rh,options:bP}),Ui=wl(G([wP.and(g({type:$("select")})),gP.and(g({type:$("boolean")}))]),g({_meta:_(d(),S()).nullish(),category:vP.nullish(),description:d().nullish(),id:Wv,name:d()})),SP=g({_meta:_(d(),S()).nullish(),configOptions:D(Ui)}),_P=g({_meta:_(d(),S()).nullish()}),ee=d(),kP=g({_meta:_(d(),S()).nullish(),id:d(),sessionId:ee}),xP=g({_meta:_(d(),S()).nullish(),sessionId:ee}),EP=g({_meta:_(d(),S()).nullish(),sessionId:ee}),AP=g({_meta:_(d(),S()).nullish(),sessionId:ee}),Zv=g({_meta:_(d(),S()).nullish(),args:D(d()).optional(),command:d(),cwd:d().nullish(),env:D(Rv).optional(),outputByteLimit:W().nullish(),sessionId:ee}),$P=g({_meta:_(d(),S()).nullish(),sessionId:ee,uri:d()}),IP=g({_meta:_(d(),S()).nullish(),position:Pr,sessionId:ee,uri:d(),version:W(),visibleRange:Ni}),TP=g({_meta:_(d(),S()).nullish(),languageId:d(),sessionId:ee,text:d(),uri:d(),version:W()}),CP=g({_meta:_(d(),S()).nullish(),sessionId:ee,uri:d()}),RP=g({_meta:_(d(),S()).nullish(),additionalDirectories:D(d()).optional(),cwd:d(),mcpServers:D(Sl).optional(),sessionId:ee}),Bv=g({_meta:_(d(),S()).nullish(),sessionId:ee,terminalId:d()}),PP=g({_meta:_(d(),S()).nullish(),additionalDirectories:D(d()).optional(),cwd:d(),mcpServers:D(Sl),sessionId:ee}),Vv=g({_meta:_(d(),S()).nullish(),limit:W().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),line:W().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:d(),sessionId:ee}),DP=g({_meta:_(d(),S()).nullish(),id:d(),reason:$R.nullish(),sessionId:ee}),Gv=g({_meta:_(d(),S()).nullish(),sessionId:ee,terminalId:d()}),LP=g({_meta:_(d(),S()).nullish(),additionalDirectories:D(d()).optional(),cwd:d(),mcpServers:D(Sl).optional(),sessionId:ee}),zP=g({_meta:_(d(),S()).nullish(),additionalDirectories:D(d()).optional(),cwd:d(),sessionId:ee,title:d().nullish(),updatedAt:d().nullish()}),OP=g({_meta:_(d(),S()).nullish(),nextCursor:d().nullish(),sessions:D(zP)}),MP=g({_meta:_(d(),S()).nullish(),title:d().nullish(),updatedAt:d().nullish()}),NP=g({_meta:_(d(),S()).nullish()}),_l=d(),UP=g({_meta:_(d(),S()).nullish(),currentModeId:_l}),FP=g({_meta:_(d(),S()).nullish(),description:d().nullish(),id:_l,name:d()}),kl=g({_meta:_(d(),S()).nullish(),availableModes:D(FP),currentModeId:_l}),xl=g({_meta:_(d(),S()).nullish(),availableModels:D(pR),currentModelId:Ch}),WP=g({_meta:_(d(),S()).nullish(),configOptions:D(Ui).nullish(),models:xl.nullish(),modes:kl.nullish(),sessionId:ee}),HP=g({_meta:_(d(),S()).nullish(),configOptions:D(Ui).nullish(),models:xl.nullish(),modes:kl.nullish()}),ZP=g({_meta:_(d(),S()).nullish(),configOptions:D(Ui).nullish(),models:xl.nullish(),modes:kl.nullish(),sessionId:ee}),BP=g({_meta:_(d(),S()).nullish(),configOptions:D(Ui).nullish(),models:xl.nullish(),modes:kl.nullish()}),VP=g({_meta:_(d(),S()).nullish()}),GP=g({_meta:_(d(),S()).nullish(),additionalDirectories:pP.nullish(),close:fP.nullish(),fork:_P.nullish(),list:NP.nullish(),resume:VP.nullish()}),jP=wl(G([g({type:$("boolean"),value:Re()}),g({value:Rh})]),g({_meta:_(d(),S()).nullish(),configId:Wv,sessionId:ee})),qP=g({_meta:_(d(),S()).nullish(),configOptions:D(Ui)}),YP=g({_meta:_(d(),S()).nullish(),modeId:_l,sessionId:ee}),XP=g({_meta:_(d(),S()).nullish()}),KP=g({_meta:_(d(),S()).nullish(),modelId:Ch,sessionId:ee}),JP=g({_meta:_(d(),S()).nullish()}),QP=g({_meta:_(d(),S()).nullish(),sessionId:ee}),eD=G([$("end_turn"),$("max_tokens"),$("max_turn_requests"),$("refusal"),$("cancelled")]),tD=G([$("email"),$("uri"),$("date"),$("date-time")]),rD=g({default:d().nullish(),description:d().nullish(),enum:D(d()).nullish(),format:tD.nullish(),maxLength:W().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),minLength:W().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),oneOf:D(Cv).nullish(),pattern:d().nullish(),title:d().nullish()}),nD=g({_meta:_(d(),S()).nullish(),context:eP.nullish(),position:Pr,selection:Ni.nullish(),sessionId:ee,triggerKind:zR,uri:d(),version:W()}),iD=g({_meta:_(d(),S()).nullish(),suggestions:D(nP)}),sD=g({_meta:_(d(),S()).nullish(),terminalId:d()}),oD=g({_meta:_(d(),S()).nullish(),exitCode:W().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:d().nullish()}),jv=g({_meta:_(d(),S()).nullish(),sessionId:ee,terminalId:d()}),aD=g({_meta:_(d(),S()).nullish(),exitStatus:oD.nullish(),output:d(),truncated:Re()}),lD=g({_meta:_(d(),S()).nullish(),annotations:$o.nullish(),text:d()}),cD=g({range:Ni.nullish(),text:d()}),uD=g({_meta:_(d(),S()).nullish(),contentChanges:D(cD),sessionId:ee,uri:d(),version:W()});g({method:d(),params:G([xP,TP,uD,$P,CP,IP,kP,DP,Dv]).nullish()});const hD=G([$("full"),$("incremental")]),dD=g({_meta:_(d(),S()).nullish(),syncKind:hD}),pD=g({_meta:_(d(),S()).nullish(),didChange:dD.nullish(),didClose:mR.nullish(),didFocus:vR.nullish(),didOpen:yR.nullish(),didSave:bR.nullish()}),fD=g({_meta:_(d(),S()).nullish(),document:pD.nullish()}),gD=g({_meta:_(d(),S()).nullish(),context:MR.nullish(),events:fD.nullish()}),mD=g({_meta:_(d(),S()).nullish(),auth:oR.optional().default({}),loadSession:Re().optional().default(!1),mcpCapabilities:cR.optional().default({http:!1,sse:!1}),nes:gD.nullish(),positionEncoding:Uv.nullish(),promptCapabilities:XR.optional().default({audio:!1,embeddedContext:!1,image:!1}),sessionCapabilities:GP.optional().default({})}),vD=g({_meta:_(d(),S()).nullish(),agentCapabilities:mD.optional().default({auth:{},loadSession:!1,mcpCapabilities:{http:!1,sse:!1},promptCapabilities:{audio:!1,embeddedContext:!1,image:!1},sessionCapabilities:{}}),agentInfo:Mv.nullish(),authMethods:D(D1).optional().default([]),protocolVersion:Fv}),yD=g({_meta:_(d(),S()).nullish(),mimeType:d().nullish(),text:d(),uri:d()}),bD=G([yD,O1]),wD=g({_meta:_(d(),S()).nullish(),annotations:$o.nullish(),resource:bD}),Ph=G([lD.and(g({type:$("text")})),lP.and(g({type:$("image")})),aP.and(g({type:$("audio")})),cP.and(g({type:$("resource_link")})),wD.and(g({type:$("resource")}))]),SD=g({_meta:_(d(),S()).nullish(),content:Ph}),vc=g({_meta:_(d(),S()).nullish(),content:Ph,messageId:d().nullish()}),_D=g({_meta:_(d(),S()).nullish(),messageId:d().nullish(),prompt:D(Ph),sessionId:ee}),kD=g({anyOf:D(Cv)}),qv=G([SD.and(g({type:$("content")})),H1.and(g({type:$("diff")})),sD.and(g({type:$("terminal")}))]),Yv=d(),Xv=g({_meta:_(d(),S()).nullish(),line:W().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:d()}),Kv=G([$("pending"),$("in_progress"),$("completed"),$("failed")]),Jv=G([$("read"),$("edit"),$("delete"),$("move"),$("search"),$("execute"),$("think"),$("fetch"),$("switch_mode"),$("other")]),xD=g({_meta:_(d(),S()).nullish(),content:D(qv).optional(),kind:Jv.optional(),locations:D(Xv).optional(),rawInput:S().optional(),rawOutput:S().optional(),status:Kv.optional(),title:d(),toolCallId:Yv}),Qv=g({_meta:_(d(),S()).nullish(),content:D(qv).nullish(),kind:Jv.nullish(),locations:D(Xv).nullish(),rawInput:S().optional(),rawOutput:S().optional(),status:Kv.nullish(),title:d().nullish(),toolCallId:Yv}),ey=g({_meta:_(d(),S()).nullish(),options:D(WR),sessionId:ee,toolCall:Qv}),ED=g({_meta:_(d(),S()).nullish(),hint:d()}),AD=ED,$D=g({_meta:_(d(),S()).nullish(),description:d(),input:AD.nullish(),name:d()}),ID=g({_meta:_(d(),S()).nullish(),availableCommands:D($D)}),TD=g({enum:D(d()),type:X1}),CD=G([TD,kD]),RD=g({default:D(d()).nullish(),description:d().nullish(),items:CD,maxItems:W().nullish(),minItems:W().nullish(),title:d().nullish()}),PD=G([rD.and(g({type:$("string")})),UR.and(g({type:$("number")})),rR.and(g({type:$("integer")})),M1.and(g({type:$("boolean")})),RD.and(g({type:$("array")}))]),DD=g({description:d().nullish(),properties:_(d(),PD).optional().default({}),required:D(d()).nullish(),title:d().nullish(),type:Y1.optional().default("object")}),LD=g({requestedSchema:DD}),zD=wl(G([LD.and(g({mode:$("form")})),Q1.and(g({mode:$("url")}))]),g({_meta:_(d(),S()).nullish(),message:d(),sessionId:ee})),OD=g({cachedReadTokens:W().nullish(),cachedWriteTokens:W().nullish(),inputTokens:W(),outputTokens:W(),thoughtTokens:W().nullish(),totalTokens:W()}),MD=g({_meta:_(d(),S()).nullish(),stopReason:eD,usage:OD.nullish(),userMessageId:d().nullish()});G([g({id:Sn,result:G([vD,z1,lR,ZP,HP,OP,WP,BP,U1,XP,qP,MD,JP,QP,iD,N1,zv])}),g({error:Pv,id:Sn})]);const ND=g({_meta:_(d(),S()).nullish(),cost:F1.nullish(),size:W(),used:W()}),UD=G([vc.and(g({sessionUpdate:$("user_message_chunk")})),vc.and(g({sessionUpdate:$("agent_message_chunk")})),vc.and(g({sessionUpdate:$("agent_thought_chunk")})),xD.and(g({sessionUpdate:$("tool_call")})),Qv.and(g({sessionUpdate:$("tool_call_update")})),VR.and(g({sessionUpdate:$("plan")})),ID.and(g({sessionUpdate:$("available_commands_update")})),UP.and(g({sessionUpdate:$("current_mode_update")})),SP.and(g({sessionUpdate:$("config_option_update")})),MP.and(g({sessionUpdate:$("session_info_update")})),ND.and(g({sessionUpdate:$("usage_update")}))]),ty=g({_meta:_(d(),S()).nullish(),sessionId:ee,update:UD});g({method:d(),params:G([ty,j1,Dv]).nullish()});const ry=g({_meta:_(d(),S()).nullish(),sessionId:ee,terminalId:d()}),FD=g({_meta:_(d(),S()).nullish(),exitCode:W().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:d().nullish()}),WD=g({name:d(),uri:d()}),HD=g({_meta:_(d(),S()).nullish(),repository:RR.nullish(),workspaceFolders:D(WD).nullish(),workspaceUri:d().nullish()});g({id:Sn,method:d(),params:G([KR,L1,aR,NR,PP,iR,RP,LP,AP,YP,jP,_D,KP,HD,nD,EP,Lv]).nullish()});const ny=g({_meta:_(d(),S()).nullish(),content:d(),path:d(),sessionId:ee});g({id:Sn,method:d(),params:G([ny,Vv,ey,Zv,jv,Gv,ry,Bv,zD,Lv]).nullish()});const ZD=g({_meta:_(d(),S()).nullish()});G([g({id:Sn,result:G([ZD,iP,dP,W1,aD,sP,FD,nR,q1,zv])}),g({error:Pv,id:Sn})]);var Q;class BD{constructor(t,e){w(this,Q);const n=t(this),i=async(o,a)=>{var c,u,h,p,v,m,x;switch(o){case Xt.fs_write_text_file:{const E=ny.parse(a);return(c=n.writeTextFile)==null?void 0:c.call(n,E)}case Xt.fs_read_text_file:{const E=Vv.parse(a);return(u=n.readTextFile)==null?void 0:u.call(n,E)}case Xt.session_request_permission:{const E=ey.parse(a);return n.requestPermission(E)}case Xt.terminal_create:{const E=Zv.parse(a);return(h=n.createTerminal)==null?void 0:h.call(n,E)}case Xt.terminal_output:{const E=jv.parse(a);return(p=n.terminalOutput)==null?void 0:p.call(n,E)}case Xt.terminal_release:{const E=Gv.parse(a);return await((v=n.releaseTerminal)==null?void 0:v.call(n,E))??{}}case Xt.terminal_wait_for_exit:{const E=ry.parse(a);return(m=n.waitForTerminalExit)==null?void 0:m.call(n,E)}case Xt.terminal_kill:{const E=Bv.parse(a);return await((x=n.killTerminal)==null?void 0:x.call(n,E))??{}}default:if(n.extMethod)return n.extMethod(o,a);throw Ie.methodNotFound(o)}},s=async(o,a)=>{switch(o){case Xt.session_update:{const c=ty.parse(a);return n.sessionUpdate(c)}default:if(n.extNotification)return n.extNotification(o,a);throw Ie.methodNotFound(o)}};k(this,Q,new VD(i,s,e))}async initialize(t){return await l(this,Q).sendRequest(he.initialize,t)}async newSession(t){return await l(this,Q).sendRequest(he.session_new,t)}async loadSession(t){return await l(this,Q).sendRequest(he.session_load,t)??{}}async unstable_forkSession(t){return await l(this,Q).sendRequest(he.session_fork,t)}async listSessions(t){return await l(this,Q).sendRequest(he.session_list,t)}async unstable_resumeSession(t){return await l(this,Q).sendRequest(he.session_resume,t)}async unstable_closeSession(t){return await l(this,Q).sendRequest(he.session_close,t)}async setSessionMode(t){return await l(this,Q).sendRequest(he.session_set_mode,t)??{}}async unstable_setSessionModel(t){return await l(this,Q).sendRequest(he.session_set_model,t)??{}}async setSessionConfigOption(t){return await l(this,Q).sendRequest(he.session_set_config_option,t)}async authenticate(t){return await l(this,Q).sendRequest(he.authenticate,t)??{}}async unstable_logout(t){return await l(this,Q).sendRequest(he.logout,t)??{}}async prompt(t){return await l(this,Q).sendRequest(he.session_prompt,t)}async cancel(t){return await l(this,Q).sendNotification(he.session_cancel,t)}async unstable_startNes(t){return await l(this,Q).sendRequest(he.nes_start,t)}async unstable_suggestNes(t){return await l(this,Q).sendRequest(he.nes_suggest,t)}async unstable_closeNes(t){return await l(this,Q).sendRequest(he.nes_close,t)??{}}async unstable_didOpenDocument(t){return await l(this,Q).sendNotification(he.document_did_open,t)}async unstable_didChangeDocument(t){return await l(this,Q).sendNotification(he.document_did_change,t)}async unstable_didCloseDocument(t){return await l(this,Q).sendNotification(he.document_did_close,t)}async unstable_didSaveDocument(t){return await l(this,Q).sendNotification(he.document_did_save,t)}async unstable_didFocusDocument(t){return await l(this,Q).sendNotification(he.document_did_focus,t)}async unstable_acceptNes(t){return await l(this,Q).sendNotification(he.nes_accept,t)}async unstable_rejectNes(t){return await l(this,Q).sendNotification(he.nes_reject,t)}async extMethod(t,e){return await l(this,Q).sendRequest(t,e)}async extNotification(t,e){return await l(this,Q).sendNotification(t,e)}get signal(){return l(this,Q).signal}get closed(){return l(this,Q).closed}}Q=new WeakMap;var wr,qa,Cs,Rs,ii,si,Mt,Ps,fe,iy,eu,sy,oy,ay,ly,tu,is;class VD{constructor(t,e,n){w(this,fe);w(this,wr,new Map);w(this,qa,0);w(this,Cs);w(this,Rs);w(this,ii);w(this,si,Promise.resolve());w(this,Mt,new AbortController);w(this,Ps);k(this,Cs,t),k(this,Rs,e),k(this,ii,n),k(this,Ps,new Promise(i=>{l(this,Mt).signal.addEventListener("abort",()=>i())})),f(this,fe,iy).call(this)}get signal(){return l(this,Mt).signal}get closed(){return l(this,Ps)}async sendRequest(t,e){f(this,fe,tu).call(this);const n=kd(this,qa)._++,i=new Promise((s,o)=>{l(this,wr).set(n,{resolve:s,reject:o})});return await f(this,fe,is).call(this,{jsonrpc:"2.0",id:n,method:t,params:e}),i}async sendNotification(t,e){f(this,fe,tu).call(this),await f(this,fe,is).call(this,{jsonrpc:"2.0",method:t,params:e})}}wr=new WeakMap,qa=new WeakMap,Cs=new WeakMap,Rs=new WeakMap,ii=new WeakMap,si=new WeakMap,Mt=new WeakMap,Ps=new WeakMap,fe=new WeakSet,iy=async function(){let t;try{const e=l(this,ii).readable.getReader();try{for(;!l(this,Mt).signal.aborted;){const{value:n,done:i}=await e.read();if(i)break;if(n)try{f(this,fe,sy).call(this,n)}catch(s){console.error("Unexpected error during message processing:",n,s),"id"in n&&n.id!==void 0&&f(this,fe,is).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,eu).call(this,t)}},eu=function(t){if(l(this,Mt).signal.aborted)return;const e=t??new Error("ACP connection closed");for(const n of l(this,wr).values())n.reject(e);l(this,wr).clear(),l(this,Mt).abort(e)},sy=async function(t){if("method"in t&&"id"in t){const e=await f(this,fe,oy).call(this,t.method,t.params);"error"in e&&console.error("Error handling request",t,e.error),await f(this,fe,is).call(this,{jsonrpc:"2.0",id:t.id,...e})}else if("method"in t){const e=await f(this,fe,ay).call(this,t.method,t.params);"error"in e&&console.error("Error handling notification",t,e.error)}else"id"in t?f(this,fe,ly).call(this,t):console.error("Invalid message",{message:t})},oy=async function(t,e){try{return{result:await l(this,Cs).call(this,t,e)??null}}catch(n){if(n instanceof Ie)return n.toResult();if(n instanceof wf)return Ie.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 Ie.internalError(i?JSON.parse(i):{}).toResult()}catch{return Ie.internalError({details:i}).toResult()}}},ay=async function(t,e){try{return await l(this,Rs).call(this,t,e),{result:null}}catch(n){if(n instanceof Ie)return n.toResult();if(n instanceof wf)return Ie.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 Ie.internalError(i?JSON.parse(i):{}).toResult()}catch{return Ie.internalError({details:i}).toResult()}}},ly=function(t){const e=l(this,wr).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 Ie(n,i,s))}l(this,wr).delete(t.id)}else console.error("Got response to unknown request",t.id)},tu=function(){if(l(this,Mt).signal.aborted)throw l(this,Mt).signal.reason??new Error("ACP connection closed")},is=async function(t){return k(this,si,l(this,si).then(async()=>{const e=l(this,ii).writable.getWriter();try{await e.write(t)}finally{e.releaseLock()}}).catch(e=>{f(this,fe,eu).call(this,e)})),l(this,si)};class Ie 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 Ie(-32700,`Parse error${n?`: ${n}`:""}`,e)}static invalidRequest(e,n){return new Ie(-32600,`Invalid request${n?`: ${n}`:""}`,e)}static methodNotFound(e){return new Ie(-32601,`"Method not found": ${e}`,{method:e})}static invalidParams(e,n){return new Ie(-32602,`Invalid params${n?`: ${n}`:""}`,e)}static internalError(e,n){return new Ie(-32603,`Internal error${n?`: ${n}`:""}`,e)}static authRequired(e,n){return new Ie(-32e3,`Authentication required${n?`: ${n}`:""}`,e)}static resourceNotFound(e){return new Ie(-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 GD=/^Sender \(untrusted metadata\):\n```json\n[\s\S]*?\n```\n\n?/,jD=/^\[[^\n]*Working directory:[^\n]*\]\n\n?/,qD=/\[Television screen context\][\s\S]*?\[\/Television screen context\]\n*/,YD=/\b(tv|television|screen|artifact|artifacts|viewer|filmstrip|layout|focus)\b/i,XD=/\[\[\s*(?:reply_to_current|reply_to\s*:\s*[^\]\n]+|audio_as_voice)\s*\]\]\s*/gi,KD="single_session",JD={name:"television-acp-client",version:"0.0.0"},cy="agent:main:television",QD=Ao(Bt);var ie,er,oi,tr,sn,on,an,ln,Sr,ai,Nt,Be,rr,li,cn,nr,_r,Ds,ir,bt,Ya,sr,I,uy,hy,dy,ru,py,fy,gy,my,vy,yy,by,Zr,Vn,Gn,Xe,wy,jn,nu,iu,pa,Sy,_y,Ls,zs,su,qn,ky,xy;class eL extends QD{constructor(e){super();w(this,I);w(this,ie,rL());w(this,er,null);w(this,oi,null);w(this,tr,null);w(this,sn,null);w(this,on,null);w(this,an,null);w(this,ln);w(this,Sr,null);w(this,ai,1);w(this,Nt,null);w(this,Be,null);w(this,rr,!1);w(this,li,!1);w(this,cn,!1);w(this,nr,null);w(this,_r,new Set);w(this,Ds);w(this,ir);w(this,bt);w(this,Ya,e=>{f(this,I,hy).call(this,e)});w(this,sr,null);w(this,Ls,()=>{f(this,I,qn).call(this,"ACP bridge websocket closed")});w(this,zs,()=>{f(this,I,qn).call(this,"ACP bridge websocket error")});k(this,ir,e),k(this,bt,e.sessionMode??KD),k(this,ln,e.mappedSessionStore??tL()),k(this,Ds,e.createSocket??(n=>new WebSocket(n)))}getState(){return l(this,ie)}get messages(){return l(this,ie).messageOrder.map(e=>l(this,ie).messagesById[e]).filter(e=>e!==void 0)}async connect(){if(this.disposed)throw new Error("ACPClient has been disposed");if(l(this,ie).lifecycle.status!=="ready"){f(this,I,Xe).call(this,{lifecycle:{status:"connecting"}}),l(this,oi)??k(this,oi,f(this,I,uy).call(this));try{await l(this,oi),await f(this,I,ru).call(this)}catch(e){throw f(this,I,qn).call(this,Ko(e)),e}}}dispose(){f(this,I,su).call(this),f(this,I,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,ie).lifecycle.status!=="ready"||l(this,ie).run.status==="running"||l(this,ie).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,I,Vn).call(this,{id:f(this,I,jn).call(this,"user"),kind:"user",text:n,status:"final"}),f(this,I,Xe).call(this,{run:{status:"running",stopReason:null,canCancel:!0,error:null}});try{const i=await f(this,I,pa).call(this).prompt({sessionId:f(this,I,iu).call(this),prompt:[{type:"text",text:f(this,I,wy).call(this,n)}]});f(this,I,Zr).call(this,i.stopReason==="cancelled"?"cancelled":"final"),f(this,I,Xe).call(this,{run:{status:i.stopReason==="cancelled"?"cancelled":"completed",stopReason:i.stopReason,canCancel:!1,error:null}})}catch(i){throw f(this,I,xy).call(this)||(f(this,I,Zr).call(this,"error"),f(this,I,Xe).call(this,{run:{status:"error",stopReason:null,canCancel:!1,error:Ko(i)}})),i}}async cancel(){if(await this.connect(),!l(this,ie).run.canCancel||l(this,ie).run.status!=="running")throw new Error("No active cancellable run");f(this,I,Xe).call(this,{run:{...l(this,ie).run,status:"cancelling"}}),await f(this,I,pa).call(this).cancel({sessionId:f(this,I,iu).call(this)})}setScreenContext(e){var s,o,a;if(e===null){if(l(this,Be)===null)return;k(this,Be,null),k(this,rr,!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(k(this,Be,n),l(this,bt)==="single_session"){(!l(this,Sr)||i!==n.screenID)&&k(this,rr,!0);return}l(this,Sr)!==Af(l(this,bt),n.screenID,l(this,ir).clientGUID??"default-client")&&(k(this,tr,null),k(this,sn,null),l(this,er)&&l(this,ie).run.status==="idle"&&f(this,I,ru).call(this).catch(c=>{f(this,I,qn).call(this,Ko(c))}))}}ie=new WeakMap,er=new WeakMap,oi=new WeakMap,tr=new WeakMap,sn=new WeakMap,on=new WeakMap,an=new WeakMap,ln=new WeakMap,Sr=new WeakMap,ai=new WeakMap,Nt=new WeakMap,Be=new WeakMap,rr=new WeakMap,li=new WeakMap,cn=new WeakMap,nr=new WeakMap,_r=new WeakMap,Ds=new WeakMap,ir=new WeakMap,bt=new WeakMap,Ya=new WeakMap,sr=new WeakMap,I=new WeakSet,uy=async function(){try{f(this,I,Xe).call(this,{lifecycle:{status:"connecting"}});const{stream:e,socket:n,metadata:i}=await sL({serverURL:l(this,ir).serverURL,token:l(this,ir).token,createSocket:l(this,Ds),onDisconnect:l(this,Ya)});k(this,an,i),f(this,I,Xe).call(this,{bridge:i}),k(this,sr,n),n.addEventListener("close",l(this,Ls)),n.addEventListener("error",l(this,zs)),k(this,er,new BD(s=>({connection:s,sessionUpdate:async o=>{await f(this,I,fy).call(this,o)},requestPermission:async o=>f(this,I,gy).call(this,o)}),e)),await l(this,er).initialize({protocolVersion:$1,clientCapabilities:{},clientInfo:JD})}catch(e){throw e}},hy=function(e){f(this,I,qn).call(this,Ko(e))},dy=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})`)},ru=async function(){const e=f(this,I,_y).call(this);if(l(this,tr)&&l(this,sn)===e){await l(this,tr);return}k(this,sn,e),k(this,tr,f(this,I,py).call(this,e)),await l(this,tr)},py=async function(e){var c;const n=f(this,I,pa).call(this);f(this,I,ky).call(this);let i,s=!1,o=null;const a={cwd:f(this,I,Sy).call(this),mcpServers:[],_meta:{sessionKey:e}};try{if(k(this,cn,!0),k(this,nr,null),((c=l(this,an))==null?void 0:c.sessionIdStrategy)==="mapped"){const u=l(this,ln).getActualSessionId(e);if(u)try{const h=await n.loadSession({...a,sessionId:u});if(nL(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,ln).setActualSessionId(e,i),s=!1}else{const h=await n.newSession(a);o=h,i=h.sessionId,l(this,ln).setActualSessionId(e,i),s=!1}}else try{o=await n.loadSession({...a,sessionId:e}),i=e,s=l(this,ie).messageOrder.length>0}catch{const u=await n.newSession(a);o=u,i=u.sessionId,s=!1}}finally{k(this,cn,!1),k(this,nr,null),f(this,I,Zr).call(this,"final")}f(this,I,dy).call(this,o),await n.setSessionConfigOption({sessionId:i,configId:"verbose_level",value:"full"}),k(this,on,i),k(this,Sr,e),k(this,li,!0),s?(l(this,_r).add(e),l(this,bt)==="single_session"&&k(this,rr,!1)):(l(this,_r).delete(e),k(this,rr,l(this,bt)==="single_session")),f(this,I,Xe).call(this,{lifecycle:{status:"ready"}})},fy=async function(e){const n=e.update;switch(n.sessionUpdate){case"user_message_chunk":n.content.type==="text"&&f(this,I,by).call(this,n.content.text);return;case"agent_message_chunk":n.content.type==="text"&&f(this,I,my).call(this,n.content.text);return;case"tool_call":f(this,I,vy).call(this,n);return;case"tool_call_update":f(this,I,yy).call(this,n);return;case"agent_thought_chunk":return;default:return}},gy=async function(e){return{outcome:{outcome:"cancelled"}}},my=function(e){k(this,nr,null);const n=iL(e);if(!n)return;if(!l(this,Nt)){const s={id:f(this,I,jn).call(this,"assistant"),kind:"assistant",text:n,status:"streaming"};k(this,Nt,s.id),f(this,I,Vn).call(this,s);return}const i=l(this,ie).messagesById[l(this,Nt)];if(!i||i.kind!=="assistant")throw new Error("Open assistant message invariant violated");f(this,I,Gn).call(this,{...i,text:`${i.text}${n}`,status:"streaming"})},vy=function(e){f(this,I,Zr).call(this,"final");const n=f(this,I,nu).call(this,e.toolCallId),i=If("content"in e?e.content:void 0),s={id:(n==null?void 0:n.id)??f(this,I,jn).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,I,Gn).call(this,s);return}f(this,I,Vn).call(this,s)},yy=function(e){const n=f(this,I,nu).call(this,e.toolCallId),i=(n==null?void 0:n.text)??"",s=If(e.content),o=s?`${i}${s}`:i,a={id:(n==null?void 0:n.id)??f(this,I,jn).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,I,Gn).call(this,a);return}f(this,I,Vn).call(this,a)},by=function(e){if(f(this,I,Zr).call(this,"final"),!e)return;const n=l(this,cn)?l(this,nr):null;if(!n){const s=$f(e);if(!s)return;const o={id:f(this,I,jn).call(this,"user"),kind:"user",text:s,status:"final"};f(this,I,Vn).call(this,o),l(this,cn)&&k(this,nr,o.id);return}const i=l(this,ie).messagesById[n];if(!i||i.kind!=="user")throw new Error("Replay user message invariant violated");f(this,I,Gn).call(this,{...i,text:$f(`${i.text}${e}`)})},Zr=function(e){if(!l(this,Nt))return;const n=l(this,ie).messagesById[l(this,Nt)];(n==null?void 0:n.kind)==="assistant"&&f(this,I,Gn).call(this,{...n,status:e}),k(this,Nt,null)},Vn=function(e){f(this,I,Xe).call(this,{messagesById:{...l(this,ie).messagesById,[e.id]:e},messageOrder:[...l(this,ie).messageOrder,e.id]})},Gn=function(e){f(this,I,Xe).call(this,{messagesById:{...l(this,ie).messagesById,[e.id]:e}})},Xe=function(e){const n={...l(this,ie),...e};k(this,ie,{...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 ae("change"))},wy=function(e){const n=l(this,Sr);if(!n)return e;const i=l(this,Be)?l(this,bt)==="single_session"?l(this,rr)||!l(this,_r).has(n):!l(this,_r).has(n):!1,s=l(this,li)&&(l(this,Be)!==null||YD.test(e));if(!(s||i))return e;s&&k(this,li,!1),i&&(k(this,rr,!1),l(this,_r).add(n));const a=["[Television screen context]","This chat session is coming from a Television client.","Using Television requires the `television` skill. If 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
|
+
`)},jn=function(e){const n=`${e}-${l(this,ai)}`;return k(this,ai,l(this,ai)+1),n},nu=function(e){for(const n of l(this,ie).messageOrder){const i=l(this,ie).messagesById[n];if((i==null?void 0:i.kind)==="tool_call"&&i.toolCallId===e)return i}return null},iu=function(){if(!l(this,on))throw new Error("ACP session is not ready");return l(this,on)},pa=function(){if(!l(this,er))throw new Error("ACP connection is not ready");return l(this,er)},Sy=function(){var n;const e=(n=l(this,an))==null?void 0:n.sessionCwd;if(!e)throw new Error("ACP bridge session cwd is not ready");return e},_y=function(){var n;if(l(this,bt)==="single_session")return`${cy}-${(l(this,ir).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 Af(l(this,bt),e,l(this,ir).clientGUID??"default-client")},Ls=new WeakMap,zs=new WeakMap,su=function(){k(this,er,null),k(this,oi,null),k(this,tr,null),k(this,sn,null),k(this,on,null),k(this,Sr,null),k(this,an,null),l(this,sr)&&(l(this,sr).removeEventListener("close",l(this,Ls)),l(this,sr).removeEventListener("error",l(this,zs)),l(this,sr).close(),k(this,sr,null))},qn=function(e){this.disposed||l(this,ie).lifecycle.status==="disconnected"||(f(this,I,Zr).call(this,"error"),f(this,I,su).call(this),f(this,I,Xe).call(this,{lifecycle:{status:"disconnected",...e?{error:e}:{}},run:{status:"idle",stopReason:null,canCancel:!1,error:null},bridge:null}))},ky=function(){k(this,Nt,null),k(this,nr,null),k(this,ai,1),f(this,I,Xe).call(this,{run:{status:"idle",stopReason:null,canCancel:!1,error:null},messagesById:{},messageOrder:[]})},xy=function(){return l(this,ie).lifecycle.status==="disconnected"};function tL(){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 rL(){return{lifecycle:{status:"connecting"},run:{status:"idle",stopReason:null,canCancel:!1,error:null},bridge:null,messagesById:{},messageOrder:[],sendDisabled:!0,cancelDisabled:!0}}function nL(r){return r==null?!0:typeof r=="object"&&Object.keys(r).length===0}function Af(r,t,e){return r==="single_session"?`${cy}-${e.toLowerCase()}`:`agent:main:television-${e.toLowerCase()}-${t.toLowerCase()}`}function Ey(r){return r.replace(/^(?:\s*\n)+/,"")}function $f(r){let t=r;return t=t.replace(GD,""),t=t.replace(jD,""),t=t.replace(qD,""),t=Ey(t),t}function iL(r){let t=r;return t=t.replace(XD,""),t=Ey(t),t}function If(r){return!r||r.length===0?"":r.flatMap(t=>t.type==="content"&&t.content.type==="text"?[t.content.text]:[]).join("")}async function sL(r){const t=r.createSocket(lL(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"}))},v=E=>{const T=aL(E);if(!T)return;let O;try{O=JSON.parse(T)}catch(R){const Z=R instanceof Error?R:new Error(String(R));i(Z),u.error(Z);return}switch(O.type){case"acp-bridge-status":if(O.status==="ready"){let R;try{R=oL(O)}catch(Z){const F=Z instanceof Error?Z:new Error(String(Z));e||i(F),u.error(F);return}e||(e=!0,n(R));return}if(O.status==="error"||O.status==="exited"){const R=new Error(O.error??`ACP bridge ${O.status}`);e||i(R),u.error(R)}return;case"acp-bridge-message":u.enqueue(O.message);return}},m=()=>{var T;if(h)return;h=!0;const E=new Error("ACP bridge websocket closed");e||i(E),(T=r.onDisconnect)==null||T.call(r,E),u.close()},x=()=>{var T;if(h)return;h=!0;const E=new Error("ACP bridge websocket error");e||i(E),(T=r.onDisconnect)==null||T.call(r,E),u.error(E)};t.addEventListener("open",p),t.addEventListener("message",v),t.addEventListener("close",m),t.addEventListener("error",x)}}),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 oL(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 aL(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 lL(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 Ko(r){return r instanceof Error?r.message:String(r)}const Tf="television.acpClientGUID",Cf="television.acpMappedSessions",Rf=1;var ci;class cL{constructor(){w(this,ci,new Map)}getActualSessionId(t){return l(this,ci).get(t)??null}setActualSessionId(t,e){l(this,ci).set(t,e)}clearActualSessionId(t){l(this,ci).delete(t)}}ci=new WeakMap;var ui,Os,ct,fa,ga,ou;class uL{constructor(t,e){w(this,ct);w(this,ui);w(this,Os);k(this,ui,t),k(this,Os,e)}getActualSessionId(t){const e=f(this,ct,ga).call(this)[f(this,ct,fa).call(this,t)];return typeof e=="string"&&e.length>0?e:null}setActualSessionId(t,e){const n=f(this,ct,ga).call(this);n[f(this,ct,fa).call(this,t)]=e,f(this,ct,ou).call(this,n)}clearActualSessionId(t){const e=f(this,ct,ga).call(this);delete e[f(this,ct,fa).call(this,t)],f(this,ct,ou).call(this,e)}}ui=new WeakMap,Os=new WeakMap,ct=new WeakSet,fa=function(t){return JSON.stringify([l(this,Os),t])},ga=function(){const t=l(this,ui).getItem(Cf);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!==Rf?{}:typeof n.entries!="object"||n.entries===null||Array.isArray(n.entries)?{}:Object.fromEntries(Object.entries(n.entries).filter(i=>typeof i[1]=="string"))},ou=function(t){const e={version:Rf,entries:t};l(this,ui).setItem(Cf,JSON.stringify(e))};function hL(){return typeof window>"u"?null:window.localStorage}function dL(r){const t=r.getItem(Tf);if(t)return t;const e=ml().toLowerCase();return r.setItem(Tf,e),e}const pL=4401;class au extends Error{constructor(t="Authentication required"){super(t),this.name="AuthError"}}class Ay extends Bt{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=_e(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 TA(i,{token:s??void 0})),this.client=this.createClient(this.url,this.token);const n=e.mappedSessionStore??(e.acpStorage?new uL(e.acpStorage,this.url):new cL);this.acpClient=new eL({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 ae("change"));const n=this.createSocket(gL(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 ae("change")),s())},u=p=>{a||this.connectAttempt!==e||(a=!0,this.status="disconnected",this.dispatchEvent(new ae("change")),o(p))},h=async()=>{try{const[{screens:p},v,m]=await Promise.all([this.client.screens.list(),this.client.views.list(),this.client.display.get()]);this.screens=new Map(p.map(x=>[x.id,structuredClone(x)])),this.views=v,this.dispatchEvent(new ae("change")),this.dispatchEvent(new Gc("server-event",{serverURL:this.url,event:{type:"screen-changed",screenID:m.activeScreenID}})),c()}catch(p){u(p instanceof Error?p:new Error(String(p)))}};n.addEventListener("open",()=>{h()}),n.addEventListener("message",p=>{const v=vL(p);v&&(this.applyServerEvent(v),this.dispatchEvent(new Gc("server-event",{serverURL:this.url,event:v})))}),n.addEventListener("close",p=>{if(this.connectAttempt===e){if(this.socket=null,mL(p)===pL){u(new au);return}if(!a){u(new Error("Connection closed before initialization"));return}this.status="disconnected",this.dispatchEvent(new ae("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 ae("change"))}dispose(){this.disconnect(),this.acpClient.dispose()}getViewURL(e){const n=A1(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 ha("screens-changed"));break;case"screen-updated":this.screens.set(e.screen.id,structuredClone(e.screen)),this.dispatchEvent(new ha("screens-changed"));break;case"screen-removed":this.screens.delete(e.screenID),this.dispatchEvent(new ha("screens-changed"));break;case"artifact-created":break;case"artifact-attached":{const n=this.screens.get(e.screenID);n&&!Nm(n.layout,e.artifact.id)&&(n.layout=[...n.layout,Mm(e.artifact.id,{id:e.cardID})]);break}case"artifact-removed":{const n=this.screens.get(e.screenID);n&&(n.layout=Im(n.layout,e.artifactID));break}case"artifact-updated":case"artifact-content-changed":case"screen-changed":case"theme-changed":case"artifact-focus":break;default:return fL(e,"server event")}}}function fL(r,t){throw new Error(`Unexpected ${t}: ${JSON.stringify(r)}`)}function gL(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 mL(r){return typeof r=="object"&&r!==null&&"code"in r&&typeof r.code=="number"?r.code:null}function vL(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 yL="Local";var Ms,lu;class bL extends Bt{constructor(e){super();w(this,Ms);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 ae("change")))});this.localStore=e.localStore,this.localServerURL=e.localServerURL?_e(e.localServerURL):null,this.createSocket=e.createSocket??(i=>new WebSocket(i)),this.lastActiveServerURL=this.localStore.get().activeServerURL;const n=e.acpStorage===void 0?hL():e.acpStorage;this.acpStorage=n,this.clientGUID=e.clientGUID??(n?dL(n):ml().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=_e(e.url);this.servers.get(n)&&this.remove(n),this.servers.set(n,e);const s=()=>{this.dispatchEvent(new ae("change"))},o=c=>{this.dispatchEvent(new Gc("server-event",{serverURL:c.serverURL,event:c.event}))},a=()=>{this.dispatchEvent(new ha("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 ae("change"))}remove(e){const n=_e(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 ae("change"))}setActive(e){const n=this.localStore.get(),i=e?_e(e.url):null;n.activeServerURL!==i&&this.localStore.set({...n,activeServerURL:i})}connectConfiguredServers(e,n){const i=e?_e(e):null;if(i){const a=this.localStore.get();a.servers.some(u=>_e(u.url)===i)||this.localStore.set({...a,servers:[...a.servers,{url:i,name:yL}]})}const s=this.localStore.get().servers;for(const a of s){const c=_e(a.url),u=i!==null&&c===i,h=f(this,Ms,lu).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=_e(e);this.remove(i);const s=this.localStore.get();this.localStore.set({...s,servers:[...s.servers.filter(a=>_e(a.url)!==i),{url:i,name:n}]});const o=f(this,Ms,lu).call(this,{url:i,name:n,token:null});this.add(o),this.setActive(o),o.connect().catch(()=>{})}removeServer(e){this.remove(e)}}Ms=new WeakSet,lu=function(e){return new Ay({url:e.url,name:e.name,token:e.token,createSocket:this.createSocket,clientGUID:this.clientGUID,acpStorage:this.acpStorage})};var Ns;class wL extends Bt{constructor(){super();w(this,Ns,e=>{const n=SL(e);n!==null&&(e.preventDefault(),this.dispatchEvent(new KE("shortcut-triggered",{shortcut:n})))});document.addEventListener("keydown",l(this,Ns))}dispose(){document.removeEventListener("keydown",l(this,Ns))}}Ns=new WeakMap;function SL(r){for(const[t,e]of Object.entries(CA))if(_L(r,e.trigger))return t;return null}function _L(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 kL="serverURL",xL="token",EL="mode",AL="electron";function $y(r=window.location.search,t=window.location.origin){const n=new URLSearchParams(r).get(kL);return n?new URL(n).origin:new URL(t).origin}function Pf(r=window.location.search){return new URLSearchParams(r).get(xL)}function Dh(r=window.location.search){return new URLSearchParams(r).get(EL)===AL}let gr=null;async function Iy(r,t){if(gr==null||gr.abort(),r===null){gr=null,Da();return}const e=new AbortController;gr=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(gr!==e)return;km(o)}catch(n){if(n.name==="AbortError")return;Da();const i=n instanceof Error?n.message:String(n);console.warn(`applyTheme: ${i}`)}finally{gr===e&&(gr=null)}}/**
|
|
44
|
+
* @license
|
|
45
|
+
* Copyright 2017 Google LLC
|
|
46
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
47
|
+
*/const fs=globalThis,Df=r=>r,Fa=fs.trustedTypes,Lf=Fa?Fa.createPolicy("lit-html",{createHTML:r=>r}):void 0,Ty="$lit$",vr=`lit$${Math.random().toFixed(9).slice(2)}$`,Cy="?"+vr,$L=`<${Cy}>`,_n=document,Ss=()=>_n.createComment(""),_s=r=>r===null||typeof r!="object"&&typeof r!="function",Lh=Array.isArray,IL=r=>Lh(r)||typeof(r==null?void 0:r[Symbol.iterator])=="function",yc=`[
|
|
48
|
+
\f\r]`,qi=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,zf=/-->/g,Of=/>/g,Fr=RegExp(`>|${yc}(?:([^\\s"'>=/]+)(${yc}*=${yc}*(?:[^
|
|
49
|
+
\f\r"'\`<>=]|("|')|))|$)`,"g"),Mf=/'/g,Nf=/"/g,Ry=/^(?:script|style|textarea|title)$/i,TL=r=>(t,...e)=>({_$litType$:r,strings:t,values:e}),U=TL(1),$i=Symbol.for("lit-noChange"),le=Symbol.for("lit-nothing"),Uf=new WeakMap,Kr=_n.createTreeWalker(_n,129);function Py(r,t){if(!Lh(r)||!r.hasOwnProperty("raw"))throw Error("invalid template strings array");return Lf!==void 0?Lf.createHTML(t):t}const CL=(r,t)=>{const e=r.length-1,n=[];let i,s=t===2?"<svg>":t===3?"<math>":"",o=qi;for(let a=0;a<e;a++){const c=r[a];let u,h,p=-1,v=0;for(;v<c.length&&(o.lastIndex=v,h=o.exec(c),h!==null);)v=o.lastIndex,o===qi?h[1]==="!--"?o=zf:h[1]!==void 0?o=Of:h[2]!==void 0?(Ry.test(h[2])&&(i=RegExp("</"+h[2],"g")),o=Fr):h[3]!==void 0&&(o=Fr):o===Fr?h[0]===">"?(o=i??qi,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]==='"'?Nf:Mf):o===Nf||o===Mf?o=Fr:o===zf||o===Of?o=qi:(o=Fr,i=void 0);const m=o===Fr&&r[a+1].startsWith("/>")?" ":"";s+=o===qi?c+$L:p>=0?(n.push(u),c.slice(0,p)+Ty+c.slice(p)+vr+m):c+vr+(p===-2?a:m)}return[Py(r,s+(r[e]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),n]};class ks{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]=CL(t,e);if(this.el=ks.createElement(u,n),Kr.currentNode=this.el.content,e===2||e===3){const p=this.el.content.firstChild;p.replaceWith(...p.childNodes)}for(;(i=Kr.nextNode())!==null&&c.length<a;){if(i.nodeType===1){if(i.hasAttributes())for(const p of i.getAttributeNames())if(p.endsWith(Ty)){const v=h[o++],m=i.getAttribute(p).split(vr),x=/([.?@])?(.*)/.exec(v);c.push({type:1,index:s,name:x[2],strings:m,ctor:x[1]==="."?PL:x[1]==="?"?DL:x[1]==="@"?LL:El}),i.removeAttribute(p)}else p.startsWith(vr)&&(c.push({type:6,index:s}),i.removeAttribute(p));if(Ry.test(i.tagName)){const p=i.textContent.split(vr),v=p.length-1;if(v>0){i.textContent=Fa?Fa.emptyScript:"";for(let m=0;m<v;m++)i.append(p[m],Ss()),Kr.nextNode(),c.push({type:2,index:++s});i.append(p[v],Ss())}}}else if(i.nodeType===8)if(i.data===Cy)c.push({type:2,index:s});else{let p=-1;for(;(p=i.data.indexOf(vr,p+1))!==-1;)c.push({type:7,index:s}),p+=vr.length-1}s++}}static createElement(t,e){const n=_n.createElement("template");return n.innerHTML=t,n}}function Ii(r,t,e=r,n){var o,a;if(t===$i)return t;let i=n!==void 0?(o=e._$Co)==null?void 0:o[n]:e._$Cl;const s=_s(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=Ii(r,i._$AS(r,t.values),i,n)),t}class RL{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)??_n).importNode(e,!0);Kr.currentNode=i;let s=Kr.nextNode(),o=0,a=0,c=n[0];for(;c!==void 0;){if(o===c.index){let u;c.type===2?u=new zh(s,s.nextSibling,this,t):c.type===1?u=new c.ctor(s,c.name,c.strings,this,t):c.type===6&&(u=new zL(s,this,t)),this._$AV.push(u),c=n[++a]}o!==(c==null?void 0:c.index)&&(s=Kr.nextNode(),o++)}return Kr.currentNode=_n,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 zh=class Dy{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=le,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=Ii(this,t,e),_s(t)?t===le||t==null||t===""?(this._$AH!==le&&this._$AR(),this._$AH=le):t!==this._$AH&&t!==$i&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):IL(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!==le&&_s(this._$AH)?this._$AA.nextSibling.data=t:this.T(_n.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=ks.createElement(Py(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 RL(i,this),a=o.u(this.options);o.p(e),this.T(a),this._$AH=o}}_$AC(t){let e=Uf.get(t.strings);return e===void 0&&Uf.set(t.strings,e=new ks(t)),e}k(t){Lh(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 Dy(this.O(Ss()),this.O(Ss()),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=Df(t).nextSibling;Df(t).remove(),t=i}}setConnected(t){var e;this._$AM===void 0&&(this._$Cv=t,(e=this._$AP)==null||e.call(this,t))}},El=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,n,i,s){this.type=1,this._$AH=le,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=le}_$AI(t,e=this,n,i){const s=this.strings;let o=!1;if(s===void 0)t=Ii(this,t,e,0),o=!_s(t)||t!==this._$AH&&t!==$i,o&&(this._$AH=t);else{const a=t;let c,u;for(t=s[0],c=0;c<s.length-1;c++)u=Ii(this,a[n+c],e,c),u===$i&&(u=this._$AH[c]),o||(o=!_s(u)||u!==this._$AH[c]),u===le?t=le:t!==le&&(t+=(u??"")+s[c+1]),this._$AH[c]=u}o&&!i&&this.j(t)}j(t){t===le?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}},PL=class extends El{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===le?void 0:t}},DL=class extends El{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==le)}},LL=class extends El{constructor(t,e,n,i,s){super(t,e,n,i,s),this.type=5}_$AI(t,e=this){if((t=Ii(this,t,e,0)??le)===$i)return;const n=this._$AH,i=t===le&&n!==le||t.capture!==n.capture||t.once!==n.once||t.passive!==n.passive,s=t!==le&&(n===le||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 zL{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){Ii(this,t)}}const bc=fs.litHtmlPolyfillSupport;bc==null||bc(ks,zh),(fs.litHtmlVersions??(fs.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 zh(t.insertBefore(Ss(),null),null,void 0,{})),i._$AI(r),i};/**
|
|
50
|
+
* @license
|
|
51
|
+
* Copyright 2017 Google LLC
|
|
52
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
53
|
+
*/const Ly={CHILD:2},Oh=r=>(...t)=>({_$litDirective$:r,values:t});class zy{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 Wa=class extends zy{constructor(t){if(super(t),this.it=le,t.type!==Ly.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(t){if(t===le||t==null)return this._t=void 0,this.it=t;if(t===$i)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:[]}}};Wa.directiveName="unsafeHTML",Wa.resultType=1;const OL=Oh(Wa);/**
|
|
58
|
+
* @license
|
|
59
|
+
* Copyright 2017 Google LLC
|
|
60
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
61
|
+
*/class cu extends Wa{}cu.directiveName="unsafeSVG",cu.resultType=2;const ML=Oh(cu),NL={size:16,color:"currentColor",weight:"regular"};function UL(r){return typeof r=="string"?{regular:r}:r}function Fi(r,t="0 0 256 256"){const e=UL(r);return n=>{const{size:i,color:s,weight:o}={...NL,...n},a=e[o]??e.regular;return U`<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
|
+
>${ML(a)}</svg>`}}/**
|
|
69
|
+
* @license
|
|
70
|
+
* Copyright 2020 Google LLC
|
|
71
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
72
|
+
*/const FL=r=>r.strings===void 0;/**
|
|
73
|
+
* @license
|
|
74
|
+
* Copyright 2017 Google LLC
|
|
75
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
76
|
+
*/const gs=(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),gs(i,t);return!0},Ha=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)},Oy=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),ZL(t)}};function WL(r){this._$AN!==void 0?(Ha(this),this._$AM=r,Oy(this)):this._$AM=r}function HL(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++)gs(n[s],!1),Ha(n[s]);else n!=null&&(gs(n,!1),Ha(n));else gs(this,r)}const ZL=r=>{r.type==Ly.CHILD&&(r._$AP??(r._$AP=HL),r._$AQ??(r._$AQ=WL))};class BL extends zy{constructor(){super(...arguments),this._$AN=void 0}_$AT(t,e,n){super._$AT(t,e,n),Oy(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&&(gs(this,t),Ha(this))}setValue(t){if(FL(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 ma=()=>new VL;class VL{}const wc=new WeakMap,va=Oh(class extends BL{render(r){return le}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)),le}rt(r){if(this.isConnected||(r=void 0),typeof this.G=="function"){const t=this.ht??globalThis;let e=wc.get(t);e===void 0&&(e=new WeakMap,wc.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=wc.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)}}),GL=Fi('<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"/>'),Mh=Fi('<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"/>'),My=Fi('<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"/>'),jL=Fi({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"/>'}),qL=Fi({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"/>'}),YL=Fi('<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 XL extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}const Ff='a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])',Sc=4;var ze,Qe,un,et,Us,hi,di,B,uu,hu,Uy,ya,Fy,du,pu,Fs,Ws,hn,Wy,fu,Hy,Zy,ba,Yn;class Ny extends HTMLElement{constructor(){super();w(this,B);w(this,ze,!1);w(this,Qe,null);w(this,un);w(this,et,null);w(this,Us,"bottom-start");w(this,hi,!1);w(this,di,!1);w(this,Fs,e=>{l(this,ze)&&(l(this,hi)||e.composedPath().includes(this)||(this.open=!1))});w(this,Ws,e=>{if(l(this,ze)){if(e.key==="Escape"){e.preventDefault(),this.open=!1;return}e.key==="Tab"&&f(this,B,Wy).call(this,e)}});w(this,hn,()=>{l(this,ze)&&f(this,B,ba).call(this)});k(this,un,this.attachShadow({mode:"open"})),xm(l(this,un)),f(this,B,hu).call(this,"anchor")}connectedCallback(){this.removeAttribute("popover"),this.hasAttribute("tone")||this.setAttribute("tone","light"),f(this,B,hu).call(this,"open"),f(this,B,Yn).call(this),l(this,ze)&&(f(this,B,du).call(this),f(this,B,ya).call(this))}disconnectedCallback(){var e;f(this,B,pu).call(this),(e=l(this,Qe))==null||e.removeAttribute("aria-expanded")}attributeChangedCallback(e){e==="open"?f(this,B,Uy).call(this,this.hasAttribute("open")):e==="material"&&l(this,ze)&&(f(this,B,Yn).call(this),f(this,B,ya).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"),k(this,Qe,e),f(this,B,uu).call(this),l(this,ze)&&f(this,B,ba).call(this))}}ze=new WeakMap,Qe=new WeakMap,un=new WeakMap,et=new WeakMap,Us=new WeakMap,hi=new WeakMap,di=new WeakMap,B=new WeakSet,uu=function(){l(this,Qe)&&l(this,Qe).setAttribute("aria-expanded",l(this,ze)?"true":"false")},hu=function(e){if(!Object.prototype.hasOwnProperty.call(this,e))return;const n=this,i=n[e];delete n[e],n[e]=i},Uy=function(e){var n,i,s;if(l(this,ze)!==e){if(k(this,ze,e),f(this,B,uu).call(this),!this.isConnected){f(this,B,Yn).call(this);return}e?(k(this,hi,!0),setTimeout(()=>{k(this,hi,!1)},0),f(this,B,Yn).call(this),f(this,B,du).call(this),f(this,B,ya).call(this)):(f(this,B,pu).call(this),(i=(n=l(this,et))==null?void 0:n.hidePopover)==null||i.call(n),f(this,B,Yn).call(this),(s=l(this,Qe))==null||s.focus(),this.dispatchEvent(new XL))}},ya=function(){l(this,di)||(k(this,di,!0),queueMicrotask(()=>{k(this,di,!1),!(!l(this,ze)||!this.isConnected)&&(f(this,B,Fy).call(this),f(this,B,Zy).call(this))}))},Fy=function(){var e,n;if(l(this,et)){try{(n=(e=l(this,et)).showPopover)==null||n.call(e)}catch{}f(this,B,ba).call(this)}},du=function(){document.addEventListener("click",l(this,Fs)),document.addEventListener("keydown",l(this,Ws),!0),window.addEventListener("resize",l(this,hn)),window.addEventListener("scroll",l(this,hn),!0)},pu=function(){document.removeEventListener("click",l(this,Fs)),document.removeEventListener("keydown",l(this,Ws),!0),window.removeEventListener("resize",l(this,hn)),window.removeEventListener("scroll",l(this,hn),!0)},Fs=new WeakMap,Ws=new WeakMap,hn=new WeakMap,Wy=function(e){const n=f(this,B,fu).call(this);if(n.length===0){e.preventDefault();return}const i=n[0],s=n[n.length-1],o=f(this,B,Hy).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())},fu=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(Ff)&&n.push(i);for(const s of i.querySelectorAll(Ff))n.push(s)}return n},Hy=function(){var n;let e=document.activeElement;for(;e&&((n=e.shadowRoot)!=null&&n.activeElement);)e=e.shadowRoot.activeElement;return e},Zy=function(){var n;const e=f(this,B,fu).call(this);e.length>0?e[0].focus():(n=l(this,et))==null||n.focus()},ba=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+Sc,a=s<o&&e.top>o?"top-start":"bottom-start";k(this,Us,a);const c=a==="bottom-start"?e.bottom+Sc:e.top-n.height-Sc,u=e.left;l(this,et).style.transform=`translate(${u}px, ${c}px)`,l(this,et).setAttribute("data-placement",a)},Yn=function(){this.toggleAttribute("open",l(this,ze));const e=this.getAttribute("material")??"paper";Fe(l(this,ze)?U`<div
|
|
81
|
+
class="panel"
|
|
82
|
+
part="panel"
|
|
83
|
+
popover="manual"
|
|
84
|
+
data-placement=${l(this,Us)}
|
|
85
|
+
tabindex="-1"
|
|
86
|
+
role="dialog"
|
|
87
|
+
material=${e}
|
|
88
|
+
level="1"
|
|
89
|
+
>
|
|
90
|
+
<slot></slot>
|
|
91
|
+
</div>`:le,l(this,un)),k(this,et,l(this,un).querySelector(".panel"))},y(Ny,"observedAttributes",["open","material"]);customElements.get("ui-popover")||customElements.define("ui-popover",Ny);class By extends Event{constructor(e){super("dropdown-item-select",{bubbles:!0,composed:!0});y(this,"value");this.value=e}}class KL extends Event{constructor(e){super("select",{bubbles:!0,composed:!0});y(this,"value");this.value=e}}var tt,wt,kr,xr,se,Hs,Zs,L,Gy,ss,jy,qy,gu,Yy,os,Br,dn,Bs,Xa,Vs,Ka,Xy,Ky,mu,as,vu,yu,Kt;class Vy extends HTMLElement{constructor(){super();w(this,L);w(this,tt,!1);w(this,wt,null);w(this,kr,null);w(this,xr);w(this,se,null);w(this,Hs,ma());w(this,Zs,new MutationObserver(e=>f(this,L,Xy).call(this,e)));w(this,dn,()=>{f(this,L,os).call(this,!l(this,tt))});w(this,Bs,e=>{e.key!=="Enter"&&e.key!==" "||(e.preventDefault(),l(this,dn).call(this))});w(this,Xa,()=>{l(this,tt)&&f(this,L,os).call(this,!1)});w(this,Vs,e=>{e instanceof By&&(e.stopPropagation(),k(this,tt,!1),f(this,L,ss).call(this,e.value),f(this,L,Kt).call(this),this.dispatchEvent(new KL(e.value)))});w(this,Ka,()=>{f(this,L,mu).call(this)});k(this,xr,this.attachShadow({mode:"open"})),xm(l(this,xr))}connectedCallback(){this.addEventListener("dropdown-item-select",l(this,Vs)),f(this,L,Gy).call(this),l(this,Zs).observe(this,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["selected","value","slot"]}),f(this,L,Kt).call(this)}disconnectedCallback(){this.removeEventListener("dropdown-item-select",l(this,Vs)),l(this,Zs).disconnect(),f(this,L,yu).call(this)}attributeChangedCallback(e){if(e==="open"){f(this,L,os).call(this,this.hasAttribute("open"));return}f(this,L,Kt).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,L,Br).call(this,null,null),f(this,L,jy).call(this)):f(this,L,ss).call(this,e),f(this,L,Kt).call(this)}close(){f(this,L,os).call(this,!1)}}tt=new WeakMap,wt=new WeakMap,kr=new WeakMap,xr=new WeakMap,se=new WeakMap,Hs=new WeakMap,Zs=new WeakMap,L=new WeakSet,Gy=function(){var n;const e=this.querySelector("dropdown-item[selected]");e&&f(this,L,Br).call(this,e.value,((n=e.textContent)==null?void 0:n.trim())??null)},ss=function(e){var n;for(const i of l(this,L,gu))i.value===e?(f(this,L,Br).call(this,e,((n=i.textContent)==null?void 0:n.trim())??null),i.hasAttribute("selected")||i.setAttribute("selected","")):i.hasAttribute("selected")&&i.removeAttribute("selected")},jy=function(){const e=this.querySelectorAll("dropdown-item[selected]");for(const n of e)n.removeAttribute("selected")},qy=function(e){for(const n of l(this,L,gu))if(n.value===e)return n;return null},gu=function(){return this.querySelectorAll("dropdown-item")},Yy=function(){return l(this,kr)??this.title},os=function(e){l(this,tt)!==e&&(k(this,tt,e),f(this,L,Kt).call(this))},Br=function(e,n){k(this,wt,e),k(this,kr,n)},dn=new WeakMap,Bs=new WeakMap,Xa=new WeakMap,Vs=new WeakMap,Ka=new WeakMap,Xy=function(e){e.every(i=>i.target instanceof Element?i.target.closest('[slot="trigger"]')!==null:!1)||f(this,L,Ky).call(this)},Ky=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,kr)!==o;f(this,L,Br).call(this,s,o),f(this,L,ss).call(this,s),a?f(this,L,Kt).call(this):f(this,L,as).call(this);return}if(l(this,wt)!==null){const s=f(this,L,qy).call(this,l(this,wt));if(s){const o=((i=s.textContent)==null?void 0:i.trim())??null,a=l(this,kr)!==o;f(this,L,Br).call(this,l(this,wt),o),f(this,L,ss).call(this,l(this,wt)),a?f(this,L,Kt).call(this):f(this,L,as).call(this);return}}if(l(this,wt)!==null||l(this,kr)!==null){f(this,L,Br).call(this,null,null),f(this,L,Kt).call(this);return}f(this,L,as).call(this)},mu=function(){const e=l(this,xr).querySelector('slot[name="trigger"]'),n=e instanceof HTMLSlotElement?e.assignedElements()[0]??null:null;l(this,se)!==n&&(f(this,L,yu).call(this),k(this,se,n),l(this,se)&&(l(this,se).addEventListener("click",l(this,dn)),l(this,se)instanceof HTMLButtonElement?l(this,se).hasAttribute("type")||(l(this,se).type="button"):(l(this,se).hasAttribute("role")||l(this,se).setAttribute("role","button"),l(this,se).hasAttribute("tabindex")||(l(this,se).tabIndex=0),l(this,se).addEventListener("keydown",l(this,Bs))))),f(this,L,as).call(this),f(this,L,vu).call(this)},as=function(){l(this,se)&&(l(this,se).setAttribute("data-dropdown-trigger",""),l(this,se).setAttribute("aria-haspopup","listbox"),l(this,se).setAttribute("aria-expanded",l(this,tt)?"true":"false"))},vu=function(){const e=l(this,Hs).value;if(!e)return;const n=l(this,xr).querySelector("button.fallback-trigger");e.anchor=l(this,se)??n??null},yu=function(){l(this,se)&&(l(this,se).removeEventListener("click",l(this,dn)),l(this,se).removeEventListener("keydown",l(this,Bs)),l(this,se).removeAttribute("data-dropdown-trigger"),l(this,se).removeAttribute("aria-haspopup"),l(this,se).removeAttribute("aria-expanded"),k(this,se,null))},Kt=function(){this.toggleAttribute("open",l(this,tt)),Fe(U`
|
|
92
|
+
<slot name="trigger" @slotchange=${l(this,Ka)}>
|
|
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,dn)}
|
|
100
|
+
>
|
|
101
|
+
<span class="trigger-label" part="trigger-label">${l(this,L,Yy)}</span>
|
|
102
|
+
<span class="trigger-icon" part="trigger-icon" aria-hidden="true">
|
|
103
|
+
${My({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,Xa)}
|
|
112
|
+
${va(l(this,Hs))}
|
|
113
|
+
>
|
|
114
|
+
${l(this,tt)?U`<div class="dropdown-list" part="list" role="listbox">
|
|
115
|
+
<slot></slot>
|
|
116
|
+
</div>`:le}
|
|
117
|
+
</ui-popover>
|
|
118
|
+
`,l(this,xr)),f(this,L,vu).call(this),queueMicrotask(()=>f(this,L,mu).call(this))},y(Vy,"observedAttributes",["title","open"]);class JL extends HTMLElement{}class QL extends HTMLElement{}class ez extends HTMLElement{}var En,bu,Qy,Gs,js;class Jy extends HTMLElement{constructor(){super(...arguments);w(this,En);w(this,Gs,()=>{this.action||f(this,En,Qy).call(this)});w(this,js,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,Gs)),this.addEventListener("keydown",l(this,js)),f(this,En,bu).call(this)}disconnectedCallback(){this.removeEventListener("click",l(this,Gs)),this.removeEventListener("keydown",l(this,js))}attributeChangedCallback(){f(this,En,bu).call(this)}get value(){return this.getAttribute("value")??""}get selected(){return this.hasAttribute("selected")}get action(){return this.hasAttribute("action")}}En=new WeakSet,bu=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")},Qy=function(){this.dispatchEvent(new By(this.value))},Gs=new WeakMap,js=new WeakMap,y(Jy,"observedAttributes",["action","selected","value"]);customElements.get("dropdown-menu")||customElements.define("dropdown-menu",Vy);customElements.get("dropdown-group")||customElements.define("dropdown-group",JL);customElements.get("dropdown-label")||customElements.define("dropdown-label",QL);customElements.get("dropdown-divider")||customElements.define("dropdown-divider",ez);customElements.get("dropdown-item")||customElements.define("dropdown-item",Jy);class tz extends Event{constructor(e){super("rename",{bubbles:!0,composed:!0});y(this,"value");this.value=e}}var Ut,St,oe,Oe,ls,qs,wu,wa,Su,Ys,Xs,Ks;class eb extends HTMLElement{constructor(){super(...arguments);w(this,Oe);w(this,Ut,"");w(this,St,!1);w(this,oe,null);w(this,qs,e=>{l(this,St)||(e.preventDefault(),f(this,Oe,wu).call(this))});w(this,Ys,e=>{e.stopPropagation()});w(this,Xs,e=>{var n,i;e.key==="Enter"?(e.preventDefault(),f(this,Oe,wa).call(this,!0),(n=l(this,oe))==null||n.blur()):e.key==="Escape"&&(e.preventDefault(),f(this,Oe,wa).call(this,!1),(i=l(this,oe))==null||i.blur())});w(this,Ks,()=>{f(this,Oe,wa).call(this,!0)})}connectedCallback(){l(this,oe)||(k(this,oe,document.createElement("span")),l(this,oe).className="editable-text-span",this.append(l(this,oe)));const e=this.getAttribute("value");e!==null&&k(this,Ut,e),f(this,Oe,ls).call(this),this.addEventListener("dblclick",l(this,qs))}disconnectedCallback(){this.removeEventListener("dblclick",l(this,qs)),l(this,St)&&f(this,Oe,Su).call(this)}attributeChangedCallback(e){if(e==="value"){const n=this.getAttribute("value")??"";k(this,Ut,n),l(this,St)||f(this,Oe,ls).call(this)}}get value(){return l(this,Ut)}set value(e){k(this,Ut,e),l(this,St)||f(this,Oe,ls).call(this)}startEditing(){l(this,St)||f(this,Oe,wu).call(this)}}Ut=new WeakMap,St=new WeakMap,oe=new WeakMap,Oe=new WeakSet,ls=function(){l(this,oe)&&(l(this,oe).textContent=l(this,Ut))},qs=new WeakMap,wu=function(){l(this,oe)&&(k(this,St,!0),l(this,oe).setAttribute("contenteditable","plaintext-only"),l(this,oe).setAttribute("spellcheck","false"),l(this,oe).addEventListener("keydown",l(this,Xs)),l(this,oe).addEventListener("blur",l(this,Ks)),l(this,oe).addEventListener("mousedown",l(this,Ys)),this.toggleAttribute("data-editing",!0),queueMicrotask(()=>{var n;if(!l(this,oe))return;l(this,oe).focus();const e=(n=this.ownerDocument.defaultView)==null?void 0:n.getSelection();e==null||e.selectAllChildren(l(this,oe))}))},wa=function(e){if(!l(this,St)||!l(this,oe))return;const n=(l(this,oe).textContent??"").trim();k(this,St,!1),l(this,oe).removeAttribute("contenteditable"),l(this,oe).removeAttribute("spellcheck"),this.toggleAttribute("data-editing",!1),f(this,Oe,Su).call(this),e&&n.length>0&&n!==l(this,Ut)&&(k(this,Ut,n),this.dispatchEvent(new tz(n))),f(this,Oe,ls).call(this)},Su=function(){var e,n,i;(e=l(this,oe))==null||e.removeEventListener("keydown",l(this,Xs)),(n=l(this,oe))==null||n.removeEventListener("blur",l(this,Ks)),(i=l(this,oe))==null||i.removeEventListener("mousedown",l(this,Ys))},Ys=new WeakMap,Xs=new WeakMap,Ks=new WeakMap,y(eb,"observedAttributes",["value"]);customElements.get("editable-text")||customElements.define("editable-text",eb);class rz extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}var Js,Dr,_u,Ja,Qs,ku;class tb extends HTMLElement{constructor(){super();w(this,Dr);w(this,Js);w(this,Ja,e=>{e.target===e.currentTarget&&f(this,Dr,_u).call(this)});w(this,Qs,e=>{this.open&&e.key==="Escape"&&f(this,Dr,_u).call(this)});k(this,Js,this.attachShadow({mode:"open"}))}connectedCallback(){document.addEventListener("keydown",l(this,Qs)),f(this,Dr,ku).call(this)}disconnectedCallback(){document.removeEventListener("keydown",l(this,Qs))}attributeChangedCallback(){f(this,Dr,ku).call(this)}get open(){return this.hasAttribute("open")}}Js=new WeakMap,Dr=new WeakSet,_u=function(){this.dispatchEvent(new rz)},Ja=new WeakMap,Qs=new WeakMap,ku=function(){Fe(U`
|
|
119
|
+
${this.open?U`
|
|
120
|
+
<div class="backdrop" part="backdrop" @click=${l(this,Ja)}>
|
|
121
|
+
<slot></slot>
|
|
122
|
+
</div>
|
|
123
|
+
`:null}
|
|
124
|
+
`,l(this,Js))},y(tb,"observedAttributes",["open"]);customElements.get("modal-overlay")||customElements.define("modal-overlay",tb);class nz extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}class iz extends HTMLElement{}var eo,to,xu;class rb extends HTMLElement{constructor(){super();w(this,to);w(this,eo);k(this,eo,this.attachShadow({mode:"open"}))}connectedCallback(){f(this,to,xu).call(this)}attributeChangedCallback(){f(this,to,xu).call(this)}get closable(){return this.hasAttribute("closable")}}eo=new WeakMap,to=new WeakSet,xu=function(){const e=this.querySelector("panel-page");Fe(U`
|
|
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?U`
|
|
129
|
+
<button
|
|
130
|
+
type="button"
|
|
131
|
+
class="title-button"
|
|
132
|
+
part="button close-button"
|
|
133
|
+
aria-label="Close"
|
|
134
|
+
@click=${()=>this.dispatchEvent(new nz)}
|
|
135
|
+
>
|
|
136
|
+
<span class="close-icon" part="icon close-icon">${Mh({size:16})}</span>
|
|
137
|
+
</button>
|
|
138
|
+
`:null}
|
|
139
|
+
</header>
|
|
140
|
+
<slot></slot>
|
|
141
|
+
</section>
|
|
142
|
+
`,l(this,eo))},y(rb,"observedAttributes",["closable"]);customElements.get("panel-view")||customElements.define("panel-view",rb);customElements.get("panel-page")||customElements.define("panel-page",iz);function Al(r){return typeof r=="object"&&r!==null}function sz(r){return!Al(r)||r.type!=="wheel"||typeof r.deltaX!="number"||typeof r.deltaY!="number"||typeof r.shiftKey!="boolean"?!1:!("id"in r)}function oz(r){return!Al(r)||r.type!=="swipe-move"||typeof r.deltaX!="number"?!1:!("id"in r)}function az(r){return!Al(r)||r.type!=="swipe-end"||typeof r.velocityX!="number"?!1:!("id"in r)}function nb(r){return!Al(r)||r.type!=="open-artifact"||typeof r.artifactID!="string"?!1:!("id"in r)}function lz(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 E=h.clientX-p.startX,T=h.clientY-p.startY,O=Math.abs(E),R=Math.abs(T);if(O<n&&R<n)return;if(R>=O){p.discarded=!0;return}p.active=!0}const v=h.clientX-p.lastX;p.lastX=h.clientX,p.offset+=v,p.samples.push({time:h.timeStamp,offset:p.offset});const m=h.timeStamp-i;let x=0;for(let E=0;E<p.samples.length;E+=1){if(p.samples[E].time>=m){x=E;break}x=E+1}if(x>0){const E=Math.max(0,x-1);p.samples.splice(0,E)}r.parent.postMessage({type:"swipe-move",deltaX:v},"*"),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 v=0;if(p.samples.length>=2){const m=p.samples[0],x=p.samples[p.samples.length-1],E=x.time-m.time;E>0&&(v=(x.offset-m.offset)/E*s)}r.parent.postMessage({type:"swipe-end",velocityX:v},"*")}),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 E,T;const h=u.data;if(h===null||typeof h!="object"||h.type!=="scroll")return;const p=h,v=typeof p.deltaX=="number"?p.deltaX:0,m=typeof p.deltaY=="number"?p.deltaY:0;let x=((T=(E=r.document).elementFromPoint)==null?void 0:T.call(E,t,e))??null;for(;x!==null;){const O=r.getComputedStyle(x);if(m!==0){const R=(O.overflowY==="auto"||O.overflowY==="scroll")&&x.scrollHeight>x.clientHeight,Z=m>0?x.scrollTop+x.clientHeight<x.scrollHeight:x.scrollTop>0;if(R&&Z){x.scrollBy(v,m);return}}if(v!==0){const R=(O.overflowX==="auto"||O.overflowX==="scroll")&&x.scrollWidth>x.clientWidth,Z=v>0?x.scrollLeft+x.clientWidth<x.scrollWidth:x.scrollLeft>0;if(R&&Z){x.scrollBy(v,m);return}}x=x.parentElement}r.scrollBy(v,m)});function a(u){if(typeof u!="string")return!1;let h;try{h=new URL(u)}catch{return!1}if(h.protocol!=="artifact:")return!1;const p=h.hostname||h.pathname.replace(/^\/+/,"");return p===""?!1:(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 v=null;for(const E of p)if(E instanceof HTMLAnchorElement||E&&E.tagName==="A"){v=E;break}if(v===null)return;const m=v.getAttribute("href");if(m===null)return;let x;try{x=new URL(m,r.document.baseURI).toString()}catch{return}a(x)&&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 cz(){return`(${lz.toString()})(window);`}const uz=it(),hz=it(),dz="No handler registered for update-content",pz="handleUpdateContent: handler already registered";function fz(r){return r instanceof Error&&typeof r.message=="string"?r.message:String(r)}const gz=Ao(Bt);var pi,fi,gi,pn,fn,ro,Me,Eu,ib,sb,cs,Au,vg;let mz=(vg=class extends gz{constructor(e){super();w(this,Me);w(this,pi);w(this,fi);w(this,gi);w(this,pn,null);w(this,fn,null);w(this,ro,!1);k(this,pi,e);const n=e.ownerDocument.defaultView;if(!n)throw new Error("ArtifactView: iframe has no owner window");k(this,fi,n),k(this,gi,i=>f(this,Me,ib).call(this,i)),l(this,fi).addEventListener("message",l(this,gi))}get content(){return l(this,fn)}set content(e){f(this,Me,Au).call(this),k(this,fn,e),l(this,ro)&&f(this,Me,Eu).call(this,e)}handleUpdateContent(e){if(f(this,Me,Au).call(this),l(this,pn)!==null)throw new Error(pz);k(this,pn,e)}dispose(){l(this,fi).removeEventListener("message",l(this,gi)),k(this,pn,null)}},pi=new WeakMap,fi=new WeakMap,gi=new WeakMap,pn=new WeakMap,fn=new WeakMap,ro=new WeakMap,Me=new WeakSet,Eu=function(e){const n={type:"content-updated",content:e};f(this,Me,cs).call(this,n)},ib=function(e){if(this.disposed||e.source!==l(this,pi).contentWindow)return;const n=e.data;if(x1(n)){k(this,ro,!0),this.dispatchEvent(new uz("ready")),l(this,fn)!==null&&f(this,Me,Eu).call(this,l(this,fn));return}if(E1(n)){f(this,Me,sb).call(this,n);return}if(nb(n)){this.dispatchEvent(new hz("open-artifact",{artifactID:n.artifactID}));return}},sb=async function(e){const n=l(this,pn);if(n===null){f(this,Me,cs).call(this,{type:"response",id:e.id,error:{message:dz}});return}try{await n(e.content)}catch(i){if(this.disposed)return;f(this,Me,cs).call(this,{type:"response",id:e.id,error:{message:fz(i)}});return}this.disposed||f(this,Me,cs).call(this,{type:"response",id:e.id,result:{}})},cs=function(e){const n=l(this,pi).contentWindow;n&&n.postMessage(e,"*")},Au=function(){if(this.disposed)throw new Error("ArtifactView is disposed")},vg);const vz="text/html";async function yz(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=cz(),n.head.appendChild(s);const o=new Blob([`<!DOCTYPE html>
|
|
143
|
+
${n.documentElement.outerHTML}`],{type:vz});return URL.createObjectURL(o)}const Wf="television-artifact-bridge",bz="_tvThemeBuster",ob=it(),wz=it();class Sz 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||sz(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!==Wf)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,Wf,{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}set dragging(e){e?this.setAttribute("dragging","true"):this.removeAttribute("dragging")}get dragging(){return this.getAttribute("dragging")==="true"}get activeView(){return this._activeView}connectedCallback(){this.setAttribute("level","2"),this.render(),this.syncView(),this.syncScreenSubscription(),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 ob("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 mz(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(bz,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 yz(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&&nb(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 Dh()?U`
|
|
144
|
+
<webview
|
|
145
|
+
class="artifact-frame artifact-content"
|
|
146
|
+
src=${n}
|
|
147
|
+
sandbox="allow-scripts allow-same-origin allow-forms"
|
|
148
|
+
></webview>
|
|
149
|
+
`:U`
|
|
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"?U`
|
|
156
|
+
<div class="artifact-content artifact-placeholder">
|
|
157
|
+
<em>Failed to load content</em>
|
|
158
|
+
</div>
|
|
159
|
+
`:this._viewURL!==null||this._directRender?U`
|
|
160
|
+
<iframe
|
|
161
|
+
class="artifact-frame artifact-content"
|
|
162
|
+
src=${this._blobURL??"about:blank"}
|
|
163
|
+
sandbox="allow-scripts"
|
|
164
|
+
></iframe>
|
|
165
|
+
`:U`
|
|
166
|
+
<div class="artifact-content artifact-placeholder">
|
|
167
|
+
<em>Artifact unavailable</em>
|
|
168
|
+
</div>
|
|
169
|
+
`}template(){const e=this._artifact;return U`
|
|
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">${GL({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
|
+
${Mh({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 wz("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",Sz);const $e=r=>({type:"px",...r}),we=r=>({type:"unit",...r}),Jo=2;class _z{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??$e({x:ce,y:ce});const e=this._viewport.x??wn,n=this._viewport.y??za,i=this._gap.x??ce,s=this._gap.y??ce,o=e<=oA,a=o?e-i*Jo:Math.min(wn,e-i*Jo),c=o?n-s*Jo:Math.min(za,n-s*Jo),u=(a-i*(Et-1))/Et,h=(c-s*(ut-1))/ut,p=this.basis.x??0,v=this.basis.y??0,m=this.min.x??0,x=this.min.y??0;this._unit=$e(o?{x:Math.max(m,u),y:Math.max(x,h)}:{x:Math.max(m,Math.min(p,u)),y:Math.max(x,Math.min(v,h))})}get unit(){return this._unit}get viewport(){return this._viewport}get gap(){return this._gap}toUnits(t){return we({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 $e({x:o,y:a})}}const kn=1e-4,_t=1e-6,kz=40,xz=24;function ab(r,t){return Math.max(0,r-t*2)}function lb(r){const t=[0];for(const e of r)t.push((t[t.length-1]??0)+e);return t}function cb(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 ub(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+kn)break;n=a,i+=1}return Math.max(1,i)}function Ez(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+kn)break;n=a,i+=1}return Math.max(1,i)}function Az(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+kn)break;e=o,n+=1}return Math.max(1,n)}function Nh(r,t){if(r.length===0)return 0;const e=Az(r,t);return Math.max(0,r.length-e)}function Hf(r,t,e){if(r.length===0)return 0;const n=ub(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 $u(r,t,e){const n=r[t]??0;return e-n}function Xn(r,t,e,n,i){if(r.length===0)return 0;const s=Nh(r,i),o=t[s]??0,a=Math.max(0,Math.min(o,e));let c=0;for(let V=0;V<s;V+=1){const N=t[V]??0,J=t[V+1]??N;if(a>=N&&a<=J+kn){c=V;break}c=V+1}const u=Math.min(c+1,s),h=t[c]??0,p=t[u]??h,v=Math.max(p-h,kn),m=u===c?0:(a-h)/v,x=cb(r),E=Hf(r,c,i),T=Hf(r,u,i),O=(n-E)/2,R=(n-T)/2,Z=$u(x,c,O),F=$u(x,u,R);return Z+(F-Z)*m}function $z(r,t,e,n,i){const s=Nh(r,n),o=t[s]??0;let a=0,c=o;for(let u=0;u<kz;u+=1){const h=(a+c)/2;Xn(r,t,h,e,n)>i?a=h:c=h}return(a+c)/2}function Iz(r,t,e){const n=cb(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 $u(n,i,c)}function Tz(r,t,e){const n=ub(r,t,e);return[t,Math.min(r.length-1,t+n-1)]}function Cz(r,t,e){const n=Ez(r,t,e);return[Math.max(0,t-n+1),t]}function Rz(r,t){return r[0]===t[0]&&r[1]===t[1]}function Pz(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=ab(n,s),a=lb(t),c=Nh(e,o),u=a[c]??0;function h(T){const O=Iz(e,T,n),R=$z(e,a,n,o,O);return{nodeRange:T,anchor:Math.max(0,Math.min(u,R))}}const p=[];for(let T=0;T<i;){const O=Tz(e,T,o);p.push(h(O)),T=O[1]+1}const v=h(Cz(e,i-1,o)),m=p.filter(T=>T.nodeRange[0]<v.nodeRange[0]),x=m[m.length-1];return{viewspans:x&&Rz(x.nodeRange,v.nodeRange)?m:[...m,v],minScroll:0,maxScroll:u}}function Wn(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 Dz(r,t,e){return e<=0?0:Math.max(0,Math.min(e-1,r+t))}function Wr(r,t,e){return Math.max(t,Math.min(e,r))}function Lz(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 zz(r,t,e){var i,s;if(r.length===0)return t;const n=Lz(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 Oz extends Bt{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 we({x:this._scroll})}get translate(){return $e({x:Xn(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=Wr(e.x??this._scroll,this._minScroll,this._maxScroll);Math.abs(n-this._scroll)<=_t||(this._scroll=n,this._activeViewspanIndex=Wn(this._viewspans,this._scroll),this.dispatchEvent(new Fn("layout-scroll",{scroll:this.scroll})))}rebuild(e){var v;const n=e.nodeWidths.map(m=>Math.max(0,m.x??0)),i=n.map(m=>e.grid.toPixels(we({x:m})).x??0),s=e.grid.viewport.x??0,o=e.grid.gap.x??ce,a=Pz({nodeCols:n,nodeWidthsPx:i,viewportWidthPx:s,gapPx:o});this._nodeWidthsPx=i,this._boundaryCols=lb(n),this._viewportWidthPx=s,this._framedViewportWidthPx=ab(s,o),this._viewspans=a.viewspans,this._minScroll=a.minScroll,this._maxScroll=a.maxScroll;const c=Wr(this._scroll,this._minScroll,this._maxScroll);this._activeViewspanIndex=Wn(this._viewspans,c);const h=e.snap!==!1?((v=this._viewspans[this._activeViewspanIndex])==null?void 0:v.anchor)??c:c,p=Wr(h,this._minScroll,this._maxScroll);Math.abs(p-this._scroll)>_t&&(this._scroll=p,this.dispatchEvent(new Fn("layout-scroll",{scroll:this.scroll})))}step(e){var o;if(this._viewspans.length===0)return;const n=Dz(this._activeViewspanIndex,e,this._viewspans.length),i=((o=this._viewspans[n])==null?void 0:o.anchor)??this._scroll,s=Wr(i,this._minScroll,this._maxScroll);this._activeViewspanIndex=n,!(Math.abs(s-this._scroll)<=_t)&&(this._scroll=s,this.dispatchEvent(new Fn("layout-scroll",{scroll:this.scroll})))}snap(e){var s;if(this._viewspans.length===0)return;const n=e===void 0?((s=this._viewspans[Wn(this._viewspans,this._scroll)])==null?void 0:s.anchor)??this._scroll:zz(this._viewspans,this._scroll,e),i=Wr(n,this._minScroll,this._maxScroll);this._activeViewspanIndex=Wn(this._viewspans,i),!(Math.abs(i-this._scroll)<=_t)&&(this._scroll=i,this.dispatchEvent(new Fn("layout-scroll",{scroll:this.scroll})))}wheel(e){const n=Wr(this._scroll+(e.x??0),this._minScroll,this._maxScroll);Math.abs(n-this._scroll)<=_t||(this._scroll=n,this._activeViewspanIndex=Wn(this._viewspans,this._scroll),this.dispatchEvent(new Fn("layout-scroll",{scroll:this.scroll})))}wheelPixels(e){const n=e.x??0;if(Math.abs(n)<=kn)return;const i=Xn(this._nodeWidthsPx,this._boundaryCols,this._scroll,this._viewportWidthPx,this._framedViewportWidthPx),s=i-n,o=Xn(this._nodeWidthsPx,this._boundaryCols,this._maxScroll,this._viewportWidthPx,this._framedViewportWidthPx),a=Xn(this._nodeWidthsPx,this._boundaryCols,this._minScroll,this._viewportWidthPx,this._framedViewportWidthPx),c=Math.max(o,Math.min(a,s));if(Math.abs(c-i)<=kn)return;let u=this._minScroll,h=this._maxScroll;for(let v=0;v<xz;v+=1){const m=(u+h)/2;Xn(this._nodeWidthsPx,this._boundaryCols,m,this._viewportWidthPx,this._framedViewportWidthPx)>c?u=m:h=m}const p=Wr((u+h)/2,this._minScroll,this._maxScroll);Math.abs(p-this._scroll)<=_t||(this._scroll=p,this._activeViewspanIndex=Wn(this._viewspans,this._scroll),this.dispatchEvent(new Fn("layout-scroll",{scroll:this.scroll})))}}const _c={"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}},Mz=["stack-above","stack-below","reorder-before","reorder-after"];function kc(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 Hr(r,t,e){return r>=e.left&&r<e.left+e.width&&t>=e.top&&t<e.top+e.height}function Iu(r){return Number.isFinite(r)?Math.max(ys,Math.min(wh,Math.round(r))):ys}function Nz(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=Iu(e);if(i.width===s)return r;const o=[...r];return o[n]={...i,width:s},o}function Uh(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 Tu(r){return r.height===ut||r.height===Tr?{...r,height:Tr}:r}function Cu(r){return r.height===Tr?{...r,height:ut}:r}function Uz(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"?Cu(h):h}else c[i]={...s,children:a};const u=Math.max(0,Math.min(n,c.length));return c.splice(u,0,Cu(o)),c}const Fz=it(),Wz=it(),Hz=50;function Zz(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 Io(r){return{id:r.id,type:"drop-target",width:r.width,height:r.height}}function Zf(r){return r.map(Vz)}function Bz(r){return r.type==="drop-target"?{id:r.id,type:"card",artifactID:r.id,width:r.width,height:r.height}:r}function Vz(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(Bz)}:r}function hb(r,t){return r.find(n=>n.type==="card"&&n.id===t)??null}function Bf(r,t){return r.find(n=>n.type==="stack"&&n.id===t)??null}function Gz(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 jz(r,t,e,n){const i=[...r.base];i.splice(r.visualDraggedIndex,1);const s=i.findIndex(v=>v.type==="card"&&v.id===e.targetCardId),o=s===-1?null:i[s];if(!o||o.type!=="card")return null;const a=hb(n,t.nodeId);if(!a)return null;const c=Tu(a),u=Tu(o),h=Io(c),p=e.position==="above"?[h,u]:[u,h];return i[s]={id:o.id,type:"stack",children:p},i}function xc(r,t){return r.parentStackId?Yz(r,t):qz(r,t)}function qz(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,Io(n)),i}if(e.type==="stack"){const n=Gz(r,t);return n?jz(n,r,e,t)??[...t]:[...t]}return[...t]}function Yz(r,t){const e=r.hitTarget;switch(e.type){case"stack-child-reorder":return Xz(r,t,e.position);case"stack-child-extract":return Kz(r,t,e.toIndex);case"stack-child-noop":return Jz(r,t);default:return[...t]}}function Xz(r,t,e){const n=t.findIndex(v=>v.type==="stack"&&v.id===r.parentStackId);if(n===-1)return[...t];const i=t[n];if(!i||i.type!=="stack")return[...t];if(!i.children.every(v=>v.type==="card"))return[...t];const s=i.children,o=s.findIndex(v=>v.id===r.nodeId);if(o===-1)return[...t];const a=s[o],c=s.filter(v=>v.id!==r.nodeId),u=Io(a),h=e==="above"?[u,...c]:[...c,u],p=[...t];return p[n]={...i,children:h},p}function Kz(r,t,e){if(!r.parentStackId)return[...t];const n=Uz(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]=Io(s),o}function Jz(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]=Io(s),o[e]={...n,children:a},o}function Qz(r,t){return t.find(n=>n.type==="stack"&&n.id===r.id)?r.id:ml()}function eO(r,t,e){if(r.type==="drop-target"){const n=Uh(t,e);if(!n)throw new Error(`finalize: missing dragged card ${e}`);return Tu(n)}return r}function tO(r,t,e){const n=r.children.map(s=>eO(s,t,e));return{id:Qz(r,t),type:"stack",children:n}}function rO(r,t,e){if(r.type==="drop-target"){const n=Uh(t,e);if(!n)throw new Error(`finalize: missing dragged card ${e}`);return hb(t,e)!==null?n:Cu(n)}return r.type==="card"||r.type==="row"?r:tO(r,t,e)}function nO(r,t,e){return r.map(n=>rO(n,t,e))}function iO(r,t){return JSON.stringify(r)===JSON.stringify(t)}const sO=Ao(Bt);class oO extends sO{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)>=lA&&(this.pending=null,this.active={...s,pointerX:n,pointerY:i,hitTarget:{type:"reorder",index:s.sourceIndex},lastReorderIndex:s.sourceIndex},this.emitDrag(),this.dispatchEvent(new ae("change")));return}if(!this.active)return;const o=xc(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&&Zz(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 ae("change")))}drop(){if(this.pending){this.cancel();return}if(!this.active)return;const e=this.active.baseLayout;let n=null;try{const i=xc(this.active,e),s=nO(i,e,this.active.nodeId);iO(s,e)||(n=s)}catch{n=null}this.reset(),n&&this.dispatchEvent(new Wz("drop",{layout:n})),this.dispatchEvent(new ae("change"))}cancel(){!this.pending&&!this.active||(this.reset(),this.dispatchEvent(new ae("change")))}dispose(){this.reset()}get status(){return this.active?"active":this.pending?"pending":"idle"}reset(){this.pending=null,this.active=null}emitDrag(){if(!this.active)return;const e=xc(this.active,this.active.baseLayout);this.dispatchEvent(new Fz("drag",{nodeId:this.active.nodeId,source:{index:this.active.sourceIndex,parentId:this.active.parentStackId},grabOffset:$e({x:this.active.grabOffsetX,y:this.active.grabOffsetY}),pointer:$e({x:this.active.pointerX,y:this.active.pointerY}),size:$e({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&&Hr(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&&Hr(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=Bf(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=Bf(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 m,x,E;const o=this.getTopLevelZoneNodes(i.geometry,s);if(o.length===0)return{type:"reorder",index:((m=this.active)==null?void 0:m.sourceIndex)??0};const c=(i.effectiveVelocity??0)<=Hz;for(const T of o){const O=T.rect;if(!Hr(e,n,O))continue;const R=this.resolveTopLevelTargetForCard(e,n,T,T.logicalIndex,c);if(R)return R;if(!c&&((x=this.active)!=null&&x.hitTarget))return this.active.hitTarget}const u=this.getNearestTargetableZone(e,o);if(!u)return{type:"reorder",index:((E=this.active)==null?void 0:E.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 v=u.rect.left+u.rect.width/2;return{type:"reorder",index:e<v?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(!Hr(e,n,p.rect))continue;const v=kc(p.rect,_c["reorder-before"]);if(Hr(e,n,v))return p.logicalIndex;const m=kc(p.rect,_c["reorder-after"]);if(Hr(e,n,m))return p.logicalIndex+1}const a=this.getNearestTargetableZone(e,o);if(!a)return((h=this.active)==null?void 0:h.sourceIndex)??0;const c=a.rect.left+a.rect.width/2;return e<c?a.logicalIndex:a.logicalIndex+1}getTopLevelZoneNodes(e,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 Mz){if(!o&&(c==="stack-above"||c==="stack-below"))continue;const u=_c[c],h=kc(a,u);if(Hr(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 Vf=60,aO=80,Gf=.5,jf=10;class lO{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>=Vf&&(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>=Gf&&h>=p*jf?this.classifyHorizontal(e,u):(this.lastWheelGestureAt=e,{type:"scroll-native"}):this.activeGestureType==="horizontal-filmstrip"?!c&&o&&p>0&&p>=h*jf?(this.activeGestureType="vertical-artifact",this.lastWheelGestureAt=e,{type:"scroll-native"}):this.classifyHorizontal(e,u):h<Gf?(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)+aO;return this.awaitingFreshWheelGesture&&n<Vf&&!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 cO=100,uO=1e3;class hO{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($e({x:-e})))}end(){if(this._status!=="active")return;const t=this.computeVelocityPxPerSec();this.setAnimating(!0),Math.abs(t)<uA?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-cO;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*uO}}const dO=2,qf=1e3,Qo=1e-4,pO=120,Yf=!1;function fO(r){return r.replace(/["\\]/g,"\\$&")}function Xf(r,t,e){if(r===0)return 0;const n=t.toPixels(we({y:ut})).y??0;return(e-n)/dO}function Ec(r){const t=r.clientWidth>0?r.clientWidth:wn,e=r.clientHeight>0?r.clientHeight:za;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 gO extends Event{constructor(e){super("scroll",{bubbles:!0,composed:!0});y(this,"scrollPosition");this.scrollPosition=e}}class db extends Event{constructor(e){super("layout-change",{bubbles:!0,composed:!0});y(this,"layout");this.layout=e}}class mO extends HTMLElement{constructor(){super();y(this,"_layout",[]);y(this,"_scrollPosition",0);y(this,"layoutGrid",null);y(this,"layoutScroll",new Oz(we({x:0})));y(this,"scrollModelKey","");y(this,"resizeObserver",null);y(this,"renderPending",!1);y(this,"animateNextRender",!0);y(this,"wheelGesture",new lO);y(this,"swipeGesture",new hO(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 oO);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,"dragTrackOffsetXPx",0);y(this,"previousProjectedLayoutForOffset",null);y(this,"resizeState",null);y(this,"resizeListenersAttached",!1);y(this,"renderContent",()=>U``);y(this,"onDragControllerChange",()=>{this.dragController.status==="idle"&&(this.dragState=null,this.dragTrackOffsetXPx=0,this.previousProjectedLayoutForOffset=null),this.scheduleRender()});y(this,"onDragControllerDrag",e=>{const n=Zf(e.projectedLayout),i=this.shouldApplyTrackOffset(e.projectedLayout,e.source.parentId),s=e.source.parentId?this.getStackChildAnchorCardId(e.source.parentId,e.nodeId):null;this.dragTrackOffsetXPx=i?this.computeDragTrackOffset(this.previousProjectedLayoutForOffset,n,e.nodeId,e.source.parentId,s,this.dragTrackOffsetXPx):0,this.previousProjectedLayoutForOffset=n,this.dragState={nodeId:e.nodeId,source:e.source,grabOffset:e.grabOffset,pointer:e.pointer,size:e.size,projectedLayout:e.projectedLayout},this.scheduleRender()});y(this,"onDragControllerDrop",e=>{this.dragState=null,this.dragTrackOffsetXPx=0,this.previousProjectedLayoutForOffset=null,this.commitLayout(e.layout)});y(this,"onLayoutScrollInternal",e=>{const i=e.scroll.x??0;Math.abs(i-this._scrollPosition)<Qo||(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(oz(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(az(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 v=p.getAttribute("layout-node");if(v!==null){const m=parseInt(v,10);if(!isNaN(m)){const x=this.findViewspanContainingNode(m);if(x){this.clearWheelIdleSnap(),this.animateNextRender=!0,this.layoutScroll.scroll=we({x:x.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=yO(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:$e({x:e.clientX,y:e.clientY}),grabOffset:$e({x:e.clientX-h.left,y:e.clientY-h.top}),size:$e({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)??mr)+ce;if(s<=0)return;const o=e.clientX-n.startClientX,a=Iu(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(Nz(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<tf&&a<tf)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)/qf;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>Qo?Math.abs(o)/n:0,Math.abs(o)>Qo&&(this.animateNextRender=!1,this.layoutScroll.wheelPixels($e({x:o}))),this.dragController.status==="active"&&this.syncDragTarget(s.x,s.y,i),this.dragFrame=requestAnimationFrame(this.runDragFrame)});this.dragController.addEventListener("change",this.onDragControllerChange),this.dragController.addEventListener("drag",this.onDragControllerDrag),this.dragController.addEventListener("drop",this.onDragControllerDrop),this.layoutScroll.addEventListener("layout-scroll",this.onLayoutScrollInternal)}set layout(e){this._layout=[...e],this.stopDragFrameLoop(),this.dragController.cancel(),this.resizeState&&this.endResize(this.resizeState.pointerId),this.scrollModelKey="",this.syncScrollModel(),this.layoutScroll.scroll=we({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)<Qo||(this.animateNextRender=!1,this.syncScrollModel(),this.layoutScroll.scroll=we({x:e}))}get scrollPosition(){return this._scrollPosition}focusArtifact(e){const n=Qn(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="${fO(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 _z({basis:$e({x:mr,y:mr}),min:$e({x:Qp,y:Qp}),viewport:$e({x:e,y:n}),gap:$e({x:ce,y:ce})})}syncScrollModel(){const e=Ec(this),i=Qn(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=>we({x:o})),snap:Yf}))}emitScrollPositionChanged(e){this.dispatchEvent(new gO(e))}emitLayoutChanged(){this.dispatchEvent(new db([...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($e({x:e}));this.layoutScroll.wheel(we({x:i.x??0}))}scheduleWheelIdleSnap(){this.clearWheelIdleSnap(),this.wheelIdleSnapTimer=setTimeout(()=>{this.wheelIdleSnapTimer=null,this.animateNextRender=!0,this.layoutScroll.snap()},pO)}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=Iu(typeof s.width=="number"?s.width:Et);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)}getDisplayModel(){if(this.dragController.status!=="active"||!this.dragState)return{layout:this.applyResizeOverride(this._layout),activePlaceholderId:null,placeholdersById:new Map};const e=new Map;return e.set(this.dragState.nodeId,{id:this.dragState.nodeId,sourceCardId:this.dragState.nodeId}),{layout:Zf(this.dragState.projectedLayout),activePlaceholderId:this.dragState.nodeId,placeholdersById:e}}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}render(){const e=Ec(this),n=this.createGrid(e.width,e.height);this.layoutGrid=n;const i=this.getDisplayModel(),s=i.layout,o=this.dragController.status==="active",a=Qn(s),c=a.nodes.map(N=>N.width),u=`${e.width}x${e.height}:${c.join(",")}`;!o&&u!==this.scrollModelKey&&(this.scrollModelKey=u,this.layoutScroll.rebuild({grid:n,nodeWidths:c.map(N=>we({x:N})),snap:Yf}),this._scrollPosition=this.layoutScroll.scroll.x??this._scrollPosition);const h=vO(s),p=n.unit.x??mr,v=n.unit.y??mr,m=o?this.dragTrackOffsetXPx:0,x=(this.layoutScroll.translate.x??0)+m,E=Xf(a.nodes.length,n,e.height),T=this.animateNextRender&&!o,O=[`transform: translate(${x}px, ${E}px);`,`transition-duration: ${T?aA:0}ms;`,`pointer-events: ${o?"none":"auto"};`].join(" ");this.animateNextRender=!0,this.style.setProperty("--layout-unit-x",`${p}px`),this.style.setProperty("--layout-unit-y",`${v}px`),this.style.setProperty("--layout-gap",`${ce}px`);const R=this.dragState,Z={width:(R==null?void 0:R.size.x)??0,height:(R==null?void 0:R.size.y)??0},F=new Set;{for(let J=0;J<a.nodes.length;J+=1)n.toPixels(we({x:a.nodes[J].width})).x;let N=x;for(let J=0;J<a.nodes.length;J+=1){const j=n.toPixels(we({x:a.nodes[J].width})).x??0,ot=N+j;N>=-1&&ot<=e.width+1&&F.add(J),N=ot+ce}}const V=N=>F.has(N);Fe(U`
|
|
187
|
+
<div class="track" style=${O}>
|
|
188
|
+
${a.nodes.map((N,J)=>U`
|
|
189
|
+
<div
|
|
190
|
+
class="node"
|
|
191
|
+
layout-node=${String(J)}
|
|
192
|
+
data-layout-node-id=${N.id}
|
|
193
|
+
data-layout-placeholder=${String(i.activePlaceholderId===N.id)}
|
|
194
|
+
layout-node-cols=${String(N.width)}
|
|
195
|
+
?data-foreground=${V(J)}
|
|
196
|
+
style=${`width: ${n.toPixels(we({x:N.width})).x}px; --card-width-px: ${n.toPixels(we({x:N.width})).x};`}
|
|
197
|
+
>
|
|
198
|
+
<div class="node-inner" style=${`grid-template-columns: repeat(${N.width}, var(--layout-unit-x));`}>
|
|
199
|
+
${N.cards.map(j=>{const ot=i.placeholdersById.get(j.id);if(R&&ot)return U`
|
|
200
|
+
<div
|
|
201
|
+
class="card-slot card-placeholder"
|
|
202
|
+
data-layout-placeholder-for=${R.nodeId}
|
|
203
|
+
data-layout-placeholder-ghost="false"
|
|
204
|
+
data-layout-source-stack=${R.source.parentId??""}
|
|
205
|
+
style=${`grid-column: ${j.col} / span ${j.width}; grid-row: ${j.row} / span ${j.height};`}
|
|
206
|
+
></div>
|
|
207
|
+
`;const At=h.get(j.id);if(!At)return null;const ye=N.type==="card";return U`
|
|
208
|
+
<div
|
|
209
|
+
class="card-slot"
|
|
210
|
+
data-layout-card-id=${j.artifactID}
|
|
211
|
+
data-layout-node-id=${j.id}
|
|
212
|
+
layout-cols=${String(j.width)}
|
|
213
|
+
layout-rows=${String(j.height)}
|
|
214
|
+
style=${`grid-column: ${j.col} / span ${j.width}; grid-row: ${j.row} / span ${j.height};`}
|
|
215
|
+
>
|
|
216
|
+
${this.renderContent(At,{isDragging:!1})}
|
|
217
|
+
${ye?U`<div
|
|
218
|
+
class="resize-handle"
|
|
219
|
+
data-resize-handle=${j.id}
|
|
220
|
+
data-test-resize-handle=${j.id}
|
|
221
|
+
></div>`:null}
|
|
222
|
+
</div>
|
|
223
|
+
`})}
|
|
224
|
+
</div>
|
|
225
|
+
</div>
|
|
226
|
+
`)}
|
|
227
|
+
</div>
|
|
228
|
+
${R?(()=>{const N=this.getPlaceholderPixelSize(a,i.activePlaceholderId,n,Z),J=R.pointer.x??0,j=R.pointer.y??0,ot=R.grabOffset.x??0,At=R.grabOffset.y??0,ye=R.size.x??0,$t=R.size.y??0,ht=ye>0?ot*(N.width/ye):ot,It=$t>0?At*(N.height/$t):At;return U`
|
|
229
|
+
<div
|
|
230
|
+
class="drag-preview"
|
|
231
|
+
data-layout-preview-card-id=${R.nodeId}
|
|
232
|
+
style=${[`width: ${N.width}px;`,`height: ${N.height}px;`,`left: ${J-ht}px;`,`top: ${j-It}px;`].join(" ")}
|
|
233
|
+
>
|
|
234
|
+
${this.renderDraggedPreview(R.nodeId)}
|
|
235
|
+
</div>
|
|
236
|
+
`})():null}
|
|
237
|
+
`,this)}ensureDragFrameLoop(){this.dragFrame!==0||this.dragController.status==="idle"||(this.lastDragFrameTime=performance.now(),this.dragFrame=requestAnimationFrame(this.runDragFrame))}stopDragFrameLoop(){this.dragFrame!==0&&(cancelAnimationFrame(this.dragFrame),this.dragFrame=0,this.scrollVelocityPxPerSec=0)}syncDragTargetForLatestPointer(){if(this.dragController.status==="idle")return;const 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.getDisplayModel(),o=new Set(s.placeholdersById.keys()),a=this.dragController.status==="active"?this.dragTrackOffsetXPx:0,c=this.measureLayoutGeometry(s.layout,o,a);this.dragController.update({pointer:$e({x:e,y:n}),viewport:{left:i.left,top:i.top,width:i.width,height:i.height},geometry:c,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*qf,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))}}isPointerOutsideViewport(e,n,i){return e<i.left||e>i.left+i.width||n<i.top||n>i.top+i.height}getDragEdgeScrollDeltaPixels(e,n,i){var u;const s=n.left+jo,o=n.left+n.width-jo,a=((u=this.layoutGrid)==null?void 0:u.unit.x)??mr,c=cA*a;if(e<s){const h=Math.max(0,Math.min(1,(s-e)/jo));return-(c*h**ef)*i}if(e>o){const h=Math.max(0,Math.min(1,(e-o)/jo));return c*h**ef*i}return 0}measureLayoutGeometry(e,n,i=0){const s=this.layoutGrid;if(!s)return[];const o=Qn(e),a=new Map(o.nodes.map(E=>[E.id,E.width])),c=s.toPixels(we({y:ut})).y??za,u=Ec(this),h=(this.layoutScroll.translate.x??0)+i,p=Xf(o.nodes.length,s,u.height),v=u.offsetY+p,m=[];let x=h;for(const E of e){const T=a.get(E.id)??Et,O=s.toPixels(we({x:T})).x??wn,R={left:x,top:v,width:O,height:c};m.push({id:E.id,rect:R}),x+=O+ce}return m}getPlaceholderPixelSize(e,n,i,s){if(!n)return s;for(const o of e.nodes)for(const a of o.cards)if(a.id===n)return{width:i.toPixels(we({x:a.width})).x??s.width,height:i.toPixels(we({y:a.height})).y??s.height};return s}renderDraggedPreview(e){const n=Uh(this._layout,e);return n?this.renderContent(n,{isDragging:!0}):U``}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?Jf(e,c,this.layoutGrid):Qf(e,c,this.layoutGrid),h=s?Jf(n,c,this.layoutGrid):Qf(n,c,this.layoutGrid);return u===null||h===null?a:a+(u-h)}getStableAnchorCardId(e,n,i){const s=Kf(e),o=new Set(Kf(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 vO(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 yO(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 Kf(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 Jf(r,t,e){if(!e)return null;const n=Qn(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)??Et,c=e.toPixels(we({x:a})).x??wn;s+=c+ce}return null}function Qf(r,t,e){if(!e)return null;const n=Qn(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)??Et,c=e.toPixels(we({x:a})).x??wn;s+=c+ce}return null}customElements.get("layout-view")||customElements.define("layout-view",mO);class bO extends HTMLElement{constructor(){super(...arguments);y(this,"screenManager",Zt.resolve("ScreenManager"));y(this,"boundModel",null);y(this,"handleActiveScreenChanged",()=>{this.rebindModel(),this.render()});y(this,"handleModelChange",()=>{this.render()});y(this,"handleCloseArtifact",e=>{e instanceof ob&&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 db&&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()}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)}buildArtifactMap(){const e=this.screenManager.activeScreen;return e?new Map(e.artifacts):new Map}render(){const e=this.screenManager.activeScreen,n=(e==null?void 0:e.layout)??[],i=this.buildArtifactMap();if(n.length===0){Fe(U``,this);return}Fe(U`
|
|
238
|
+
<layout-view
|
|
239
|
+
.layout=${n}
|
|
240
|
+
.renderContent=${(o,a)=>{const c=i.get(o.artifactID);return!c||!e?U``:U`<artifact-view
|
|
241
|
+
.artifact=${c}
|
|
242
|
+
.screen=${e}
|
|
243
|
+
.viewURL=${e.server.getViewURL(c)}
|
|
244
|
+
.contentURL=${e.server.getContentURL(c)}
|
|
245
|
+
.dragging=${a.isDragging}
|
|
246
|
+
></artifact-view>`}}
|
|
247
|
+
.scrollPosition=${(e==null?void 0:e.scrollPosition)??0}
|
|
248
|
+
@scroll=${this.handleScrollPositionChanged}
|
|
249
|
+
@layout-change=${this.handleLayoutChanged}
|
|
250
|
+
@close-artifact=${this.handleCloseArtifact}
|
|
251
|
+
></layout-view>
|
|
252
|
+
`,this)}}customElements.define("screen-view",bO);function Za(r){return typeof r=="object"&&r!==null}const Ac=new WeakMap,eg=Object.prototype.hasOwnProperty,wO=(()=>{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 SO(r,t){if(Za(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 _O(r,t){return Za(r)?t==null?null:r.serialize(t):r===Boolean?t?"":null:t==null?null:String(t)}var no,Ru,gn,dt,Ft,mi,mn,vi,ke,Kn,pb,fb,gb,mb,Sa;const qr=class qr extends HTMLElement{constructor(){var i;super();w(this,ke);w(this,gn,new Map);w(this,dt,new Map);w(this,Ft,new Map);w(this,mi,!1);w(this,mn,!1);w(this,vi,!1);const e=f(i=qr,no,Ru).call(i,this.constructor),n=this;for(const s of e.properties)eg.call(n,s)&&(l(this,Ft).set(s,n[s]),delete n[s])}static get observedAttributes(){var e;return f(e=qr,no,Ru).call(e,this).observedAttributes}connected(){}disconnected(){}changed(e){}connectedCallback(){if(f(this,ke,mb).call(this),!l(this,mn))for(const e of f(this,ke,Kn).call(this).properties)l(this,dt).has(e)||l(this,dt).set(e,void 0);this.dispatchEvent(new Event("reactive:connect")),this.connected(),f(this,ke,Sa).call(this)}disconnectedCallback(){this.dispatchEvent(new Event("reactive:disconnect")),this.disconnected()}attributeChangedCallback(e,n,i){if(n===i)return;const s=f(this,ke,Kn).call(this).byAttr.get(e);s&&(l(this,Ft).has(s.property)||(this[s.property]=SO(s.type,i)))}};no=new WeakSet,Ru=function(e){const n=Ac.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(wO.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(Za(h.type)){if(typeof h.type.parse!="function")throw new Error(`Attribute "${u}" custom coercer is missing a \`parse\` function.`);if(typeof h.type.serialize!="function")throw new Error(`Attribute "${u}" custom coercer is missing a \`serialize\` function.`)}const v={attribute:u,property:p,type:h.type};o.set(u,v),a.set(p,v)}for(const u of i){const h=Object.getOwnPropertyDescriptor(e.prototype,u);if((h==null?void 0:h.get)!==void 0||(h==null?void 0:h.set)!==void 0)throw new Error(`Observed property "${u}" cannot define a custom getter/setter. Use changed() for side effects instead.`);h===void 0&&Object.defineProperty(e.prototype,u,{configurable:!0,enumerable:!0,get(){return l(this,gn).get(u)},set(p){f(this,ke,pb).call(this,u,p)}})}const c={properties:i,observedAttributes:Object.keys(s),byAttr:o,byProp:a};return Ac.set(e,c),c},gn=new WeakMap,dt=new WeakMap,Ft=new WeakMap,mi=new WeakMap,mn=new WeakMap,vi=new WeakMap,ke=new WeakSet,Kn=function(){return Ac.get(this.constructor)},pb=function(e,n){if(!l(this,vi)&&l(this,Ft).has(e))return;const i=l(this,gn).get(e);f(this,ke,fb).call(this,e,i,n)||(l(this,dt).has(e)||l(this,dt).set(e,i),l(this,gn).set(e,n),l(this,Ft).delete(e),f(this,ke,gb).call(this,e,n),this.isConnected&&f(this,ke,Sa).call(this))},fb=function(e,n,i){if(Object.is(n,i))return!0;const s=f(this,ke,Kn).call(this).byProp.get(e);if(!s||!Za(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}},gb=function(e,n){const i=f(this,ke,Kn).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=_O(o,n);if(a===null){this.hasAttribute(s)&&this.removeAttribute(s);return}this.getAttribute(s)!==a&&this.setAttribute(s,a)},mb=function(){const e=this,n=f(this,ke,Kn).call(this);for(const i of n.properties){if(!eg.call(e,i))continue;const s=e[i];delete e[i],!(l(this,Ft).has(i)||l(this,gn).has(i))&&(e[i]=s)}k(this,vi,!0);try{for(const[i,s]of l(this,Ft))e[i]=s;l(this,Ft).clear()}finally{k(this,vi,!1)}},Sa=function(){l(this,mi)||!this.isConnected||l(this,mn)&&l(this,dt).size===0||(k(this,mi,!0),queueMicrotask(()=>{if(k(this,mi,!1),!this.isConnected||l(this,mn)&&l(this,dt).size===0)return;const e=new Map(l(this,dt));l(this,dt).clear(),k(this,mn,!0);try{this.changed(e)}catch(n){console.error(n)}this.isConnected&&l(this,dt).size>0&&f(this,ke,Sa).call(this)}))},w(qr,no),y(qr,"properties"),y(qr,"attributes");let xs=qr;var pe,or,Er,yi,bi,ar,io,Ae,wi,Wt,H,vb,so,oo,ao,lo,Pu,Du,Lu,yb,bb,wb,Sb,Qa,el,tl,rl,zu,_b,_a,nl,ka,il,kb,xb,Eb,Ab,$b,lt;class kO extends xs{constructor(){super(...arguments);w(this,H);w(this,pe,Zt.resolve("ScreenManager"));w(this,or,Zt.resolve("ServerManager"));w(this,Er,null);w(this,yi,new DisposableStack);w(this,bi,ma());w(this,ar,ma());w(this,io,ma());w(this,Ae,{kind:"none"});w(this,wi,!1);w(this,Wt,[]);w(this,so,()=>{f(this,H,Pu).call(this),k(this,Ae,{kind:"none"}),l(this,lt).call(this)});w(this,oo,()=>{l(this,lt).call(this)});w(this,ao,()=>{l(this,lt).call(this)});w(this,lo,()=>{l(this,lt).call(this)});w(this,Qa,()=>{var i,s;if(l(this,Ae).kind==="picker"){f(this,H,ka).call(this);return}k(this,Wt,f(this,H,_b).call(this));const e=((i=l(this,pe).activeScreen)==null?void 0:i.id)??null,n=e&&l(this,Wt).some(o=>o.screenID===e)?e:((s=l(this,Wt)[0])==null?void 0:s.screenID)??null;k(this,Ae,{kind:"picker",filter:"",highlightedID:n}),l(this,lt).call(this),queueMicrotask(()=>{var o;(o=l(this,io).value)==null||o.focus()})});w(this,el,e=>{var u;const n=l(this,Ae);if(n.kind!=="picker")return;const i=e.target;if(!(i instanceof HTMLInputElement))return;const s=i.value,o=f(this,H,_a).call(this,l(this,Wt),s),c=n.highlightedID!==null&&o.some(h=>h.screenID===n.highlightedID)?n.highlightedID:((u=o[0])==null?void 0:u.screenID)??null;k(this,Ae,{kind:"picker",filter:s,highlightedID:c}),l(this,lt).call(this)});w(this,tl,e=>{var s;const n=l(this,Ae);if(n.kind!=="picker")return;if(e.key==="Escape"){e.preventDefault(),f(this,H,ka).call(this),(s=l(this,bi).value)==null||s.focus();return}const i=f(this,H,_a).call(this,l(this,Wt),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));k(this,Ae,{kind:"picker",filter:n.filter,highlightedID:i[c].screenID}),l(this,lt).call(this);return}if(e.key==="Enter"){e.preventDefault();const o=i.find(a=>a.screenID===n.highlightedID);o&&f(this,H,zu).call(this,o)}});w(this,rl,e=>{f(this,H,zu).call(this,e)});w(this,nl,e=>{l(this,Ae).kind==="picker"&&e.target===l(this,ar).value&&(k(this,Ae,{kind:"none"}),l(this,lt).call(this))});w(this,il,async()=>{if(l(this,wi))return;const e=f(this,H,kb).call(this);if(e){k(this,wi,!0);try{const n=await e.createScreen(xO(new Date));l(this,pe).addTab(e.url,n.id),l(this,pe).setActive(e.url,n.id)}catch{}finally{k(this,wi,!1)}}});w(this,lt,()=>{const e=f(this,H,wb).call(this);Fe(U`
|
|
253
|
+
${f(this,H,xb).call(this)}
|
|
254
|
+
<div class="pills" role="group" aria-label="Open tabs">
|
|
255
|
+
${e.map(n=>f(this,H,Eb).call(this,n))}
|
|
256
|
+
</div>
|
|
257
|
+
${f(this,H,Ab).call(this)}
|
|
258
|
+
`,this),l(this,ar).value&&(l(this,ar).value.anchor=l(this,bi).value??null)})}connected(){l(this,pe).addEventListener("active-screen-changed",l(this,so)),l(this,pe).addEventListener("tabs-changed",l(this,oo)),l(this,or).addEventListener("screens-changed",l(this,ao)),f(this,H,Pu).call(this),l(this,lt).call(this),f(this,H,vb).call(this),l(this,yi).defer(()=>{l(this,pe).removeEventListener("active-screen-changed",l(this,so)),l(this,pe).removeEventListener("tabs-changed",l(this,oo)),l(this,or).removeEventListener("screens-changed",l(this,ao)),f(this,H,Du).call(this)})}disconnected(){l(this,yi).dispose(),k(this,yi,new DisposableStack)}}pe=new WeakMap,or=new WeakMap,Er=new WeakMap,yi=new WeakMap,bi=new WeakMap,ar=new WeakMap,io=new WeakMap,Ae=new WeakMap,wi=new WeakMap,Wt=new WeakMap,H=new WeakSet,vb=async function(){const e=await Sm(this);this.setAttribute("tone",e)},so=new WeakMap,oo=new WeakMap,ao=new WeakMap,lo=new WeakMap,Pu=function(){var n;const e=l(this,pe).activeScreen;l(this,Er)!==e&&(f(this,H,Du).call(this),k(this,Er,e),(n=l(this,Er))==null||n.addEventListener("change",l(this,lo)))},Du=function(){var e;(e=l(this,Er))==null||e.removeEventListener("change",l(this,lo)),k(this,Er,null)},Lu=function(e,n){l(this,pe).setActive(e,n)},yb=function(e,n,i){i.stopPropagation();const s=l(this,pe).getTabs(e),o=f(this,H,Sb).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())},bb=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,or).servers.get(e),a=o==null?void 0:o.screens.get(n);!o||!a||o.client.screens.update({screenID:n,name:i.value}).catch(()=>{})},wb=function(){const e=l(this,pe).activeScreen,n=[];for(const i of l(this,or).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},Sb=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},Qa=new WeakMap,el=new WeakMap,tl=new WeakMap,rl=new WeakMap,zu=function(e){l(this,pe).addTab(e.serverURL,e.screenID),l(this,pe).setActive(e.serverURL,e.screenID),f(this,H,ka).call(this)},_b=function(){const e=[];for(const n of l(this,or).servers.values())for(const i of n.screens.values())e.push({serverURL:n.url,screenID:i.id,name:i.name});return e},_a=function(e,n){const i=n.trim().toLowerCase();return i.length===0?e:e.filter(s=>s.name.toLowerCase().includes(i))},nl=new WeakMap,ka=function(){l(this,Ae).kind==="picker"&&(l(this,ar).value&&(l(this,ar).value.open=!1),k(this,Ae,{kind:"none"}),l(this,lt).call(this))},il=new WeakMap,kb=function(){for(const e of l(this,or).servers.values())return e;return null},xb=function(){return U`
|
|
259
|
+
<segmented-control variant="glass" role="group" aria-label="Screens">
|
|
260
|
+
<button
|
|
261
|
+
type="button"
|
|
262
|
+
?icon-only=${!0}
|
|
263
|
+
aria-label="Choose screen"
|
|
264
|
+
@click=${l(this,Qa)}
|
|
265
|
+
${va(l(this,bi))}
|
|
266
|
+
>
|
|
267
|
+
${qL({size:16,weight:"regular"})}
|
|
268
|
+
</button>
|
|
269
|
+
<button
|
|
270
|
+
type="button"
|
|
271
|
+
?icon-only=${!0}
|
|
272
|
+
aria-label="New screen"
|
|
273
|
+
@click=${l(this,il)}
|
|
274
|
+
>
|
|
275
|
+
${YL({size:16,weight:"regular"})}
|
|
276
|
+
</button>
|
|
277
|
+
</segmented-control>
|
|
278
|
+
`},Eb=function(e){return U`
|
|
279
|
+
<span class="tab" ?data-active=${e.isActive}>
|
|
280
|
+
<button
|
|
281
|
+
type="button"
|
|
282
|
+
variant="glass"
|
|
283
|
+
class="screen-name tab-body"
|
|
284
|
+
aria-pressed=${e.isActive?"true":"false"}
|
|
285
|
+
aria-current=${e.isActive?"page":le}
|
|
286
|
+
aria-label=${e.isActive?`Current tab: ${e.name}`:`Switch to ${e.name}`}
|
|
287
|
+
@mousedown=${n=>{n.button===0&&f(this,H,Lu).call(this,e.serverURL,e.screenID)}}
|
|
288
|
+
@click=${()=>f(this,H,Lu).call(this,e.serverURL,e.screenID)}
|
|
289
|
+
>
|
|
290
|
+
<span class="tab-leading">
|
|
291
|
+
${jL({weight:"bold"})}
|
|
292
|
+
</span>
|
|
293
|
+
<editable-text
|
|
294
|
+
class="tab-name"
|
|
295
|
+
.value=${e.name}
|
|
296
|
+
@rename=${n=>f(this,H,bb).call(this,e.serverURL,e.screenID,n)}
|
|
297
|
+
></editable-text>
|
|
298
|
+
</button>
|
|
299
|
+
<button
|
|
300
|
+
type="button"
|
|
301
|
+
variant="ghost"
|
|
302
|
+
size="xs"
|
|
303
|
+
icon-only
|
|
304
|
+
class="tab-close"
|
|
305
|
+
aria-label=${`Close ${e.name}`}
|
|
306
|
+
@click=${n=>f(this,H,yb).call(this,e.serverURL,e.screenID,n)}
|
|
307
|
+
>
|
|
308
|
+
${Mh({weight:"bold"})}
|
|
309
|
+
</button>
|
|
310
|
+
</span>
|
|
311
|
+
`},Ab=function(){var o;const e=l(this,Ae).kind==="picker"?l(this,Ae).filter:"",n=l(this,Ae).kind==="picker"?l(this,Ae).highlightedID:null,i=((o=l(this,pe).activeScreen)==null?void 0:o.id)??null,s=f(this,H,_a).call(this,l(this,Wt),e);return U`
|
|
312
|
+
<ui-popover
|
|
313
|
+
class="picker-popover"
|
|
314
|
+
material="glass-frosted"
|
|
315
|
+
?open=${l(this,Ae).kind==="picker"}
|
|
316
|
+
@close=${l(this,nl)}
|
|
317
|
+
@keydown=${l(this,tl)}
|
|
318
|
+
${va(l(this,ar))}
|
|
319
|
+
>
|
|
320
|
+
<div class="picker">
|
|
321
|
+
<input
|
|
322
|
+
type="text"
|
|
323
|
+
class="picker-filter"
|
|
324
|
+
placeholder="Filter screens"
|
|
325
|
+
aria-label="Filter screens"
|
|
326
|
+
.value=${e}
|
|
327
|
+
@input=${l(this,el)}
|
|
328
|
+
${va(l(this,io))}
|
|
329
|
+
/>
|
|
330
|
+
${s.length===0?U`<p class="picker-empty">
|
|
331
|
+
${l(this,Wt).length===0?"No screens":"No matches"}
|
|
332
|
+
</p>`:f(this,H,$b).call(this,s,n,i)}
|
|
333
|
+
</div>
|
|
334
|
+
</ui-popover>
|
|
335
|
+
`},$b=function(e,n,i){return U`
|
|
336
|
+
<ul class="picker-list" role="listbox">
|
|
337
|
+
<li class="picker-section-label" role="presentation">Recent</li>
|
|
338
|
+
${e.map(s=>{const o=s.screenID===i;return U`
|
|
339
|
+
<li
|
|
340
|
+
class="picker-row"
|
|
341
|
+
role="option"
|
|
342
|
+
aria-selected=${s.screenID===n}
|
|
343
|
+
aria-current=${o?"true":le}
|
|
344
|
+
?data-highlighted=${s.screenID===n}
|
|
345
|
+
?data-active=${o}
|
|
346
|
+
@click=${()=>l(this,rl).call(this,s)}
|
|
347
|
+
>
|
|
348
|
+
<span class="picker-name">${s.name}</span>
|
|
349
|
+
</li>
|
|
350
|
+
`})}
|
|
351
|
+
</ul>
|
|
352
|
+
`},lt=new WeakMap;customElements.define("screen-select",kO);function xO(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 $c=6e4;var Ar,vn,Si,xa;class EO extends HTMLElement{constructor(){super(...arguments);w(this,Si);w(this,Ar,null);w(this,vn,null)}connectedCallback(){this.hasAttribute("material")||this.setAttribute("material","glass"),f(this,Si,xa).call(this);const e=$c-Date.now()%$c;k(this,Ar,window.setTimeout(()=>{k(this,Ar,null),f(this,Si,xa).call(this),k(this,vn,window.setInterval(()=>f(this,Si,xa).call(this),$c))},e))}disconnectedCallback(){l(this,Ar)!==null&&clearTimeout(l(this,Ar)),l(this,vn)!==null&&clearInterval(l(this,vn)),k(this,Ar,null),k(this,vn,null)}}Ar=new WeakMap,vn=new WeakMap,Si=new WeakSet,xa=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(U`<span class="date">${n}</span><span class="time">${i}</span>`,this)};customElements.get("menu-bar-clock")||customElements.define("menu-bar-clock",EO);function AO(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:Ib,setPrototypeOf:tg,isFrozen:$O,getPrototypeOf:IO,getOwnPropertyDescriptor:TO}=Object;let{freeze:je,seal:mt,create:Ea}=Object,{apply:Ou,construct:Mu}=typeof Reflect<"u"&&Reflect;je||(je=function(t){return t});mt||(mt=function(t){return t});Ou||(Ou=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)});Mu||(Mu=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 ea=qe(Array.prototype.forEach),CO=qe(Array.prototype.lastIndexOf),rg=qe(Array.prototype.pop),Yi=qe(Array.prototype.push),RO=qe(Array.prototype.splice),Aa=qe(String.prototype.toLowerCase),Ic=qe(String.prototype.toString),Tc=qe(String.prototype.match),Xi=qe(String.prototype.replace),PO=qe(String.prototype.indexOf),DO=qe(String.prototype.trim),at=qe(Object.prototype.hasOwnProperty),We=qe(RegExp.prototype.test),Ki=LO(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 Ou(r,t,n)}}function LO(r){return function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return Mu(r,e)}}function q(r,t){let e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Aa;tg&&tg(r,null);let n=t.length;for(;n--;){let i=t[n];if(typeof i=="string"){const s=e(i);s!==i&&($O(t)||(t[n]=s),i=s)}r[i]=!0}return r}function zO(r){for(let t=0;t<r.length;t++)at(r,t)||(r[t]=null);return r}function Dt(r){const t=Ea(null);for(const[e,n]of Ib(r))at(r,e)&&(Array.isArray(n)?t[e]=zO(n):n&&typeof n=="object"&&n.constructor===Object?t[e]=Dt(n):t[e]=n);return t}function Ji(r,t){for(;r!==null;){const n=TO(r,t);if(n){if(n.get)return qe(n.get);if(typeof n.value=="function")return qe(n.value)}r=IO(r)}function e(){return null}return e}const ng=je(["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"]),Cc=je(["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"]),Rc=je(["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"]),OO=je(["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"]),Pc=je(["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"]),MO=je(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),ig=je(["#text"]),sg=je(["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"]),Dc=je(["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"]),og=je(["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"]),ta=je(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),NO=mt(/\{\{[\w\W]*|[\w\W]*\}\}/gm),UO=mt(/<%[\w\W]*|[\w\W]*%>/gm),FO=mt(/\$\{[\w\W]*/gm),WO=mt(/^data-[\-\w.\u00B7-\uFFFF]+$/),HO=mt(/^aria-[\-\w]+$/),Tb=mt(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),ZO=mt(/^(?:\w+script|data):/i),BO=mt(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Cb=mt(/^html$/i),VO=mt(/^[a-z][.\w]*(-[.\w]+)+$/i);var ag=Object.freeze({__proto__:null,ARIA_ATTR:HO,ATTR_WHITESPACE:BO,CUSTOM_ELEMENT:VO,DATA_ATTR:WO,DOCTYPE_NAME:Cb,ERB_EXPR:UO,IS_ALLOWED_URI:Tb,IS_SCRIPT_OR_DATA:ZO,MUSTACHE_EXPR:NO,TMPLIT_EXPR:FO});const Qi={element:1,text:3,progressingInstruction:7,comment:8,document:9},GO=function(){return typeof window>"u"?null:window},jO=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}},lg=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Rb(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:GO();const t=M=>Rb(M);if(t.version="3.3.3",t.removed=[],!r||!r.document||r.document.nodeType!==Qi.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:v,trustedTypes:m}=r,x=c.prototype,E=Ji(x,"cloneNode"),T=Ji(x,"remove"),O=Ji(x,"nextSibling"),R=Ji(x,"childNodes"),Z=Ji(x,"parentNode");if(typeof o=="function"){const M=e.createElement("template");M.content&&M.content.ownerDocument&&(e=M.content.ownerDocument)}let F,V="";const{implementation:N,createNodeIterator:J,createDocumentFragment:j,getElementsByTagName:ot}=e,{importNode:At}=n;let ye=lg();t.isSupported=typeof Ib=="function"&&typeof Z=="function"&&N&&N.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:$t,ERB_EXPR:ht,TMPLIT_EXPR:It,DATA_ATTR:Tl,ARIA_ATTR:Co,IS_SCRIPT_OR_DATA:qb,ATTR_WHITESPACE:Jh,CUSTOM_ELEMENT:Yb}=ag;let{IS_ALLOWED_URI:Qh}=ag,Te=null;const ed=q({},[...ng,...Cc,...Rc,...Pc,...ig]);let Pe=null;const td=q({},[...sg,...Dc,...og,...ta]);let be=Object.seal(Ea(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}})),Hi=null,Ro=null;const fr=Object.seal(Ea(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let rd=!0,Cl=!0,nd=!1,id=!0,Cn=!1,Po=!0,Nr=!1,Rl=!1,Pl=!1,Rn=!1,Do=!1,Lo=!1,sd=!0,od=!1;const Xb="user-content-";let Dl=!0,Zi=!1,Pn={},Tt=null;const Ll=q({},["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 ad=null;const ld=q({},["audio","video","img","source","image","track"]);let zl=null;const cd=q({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),zo="http://www.w3.org/1998/Math/MathML",Oo="http://www.w3.org/2000/svg",Vt="http://www.w3.org/1999/xhtml";let Dn=Vt,Ol=!1,Ml=null;const Kb=q({},[zo,Oo,Vt],Ic);let Mo=q({},["mi","mo","mn","ms","mtext"]),No=q({},["annotation-xml"]);const Jb=q({},["title","style","font","a","script"]);let Bi=null;const Qb=["application/xhtml+xml","text/html"],ew="text/html";let Ee=null,Ln=null;const tw=e.createElement("form"),ud=function(b){return b instanceof RegExp||b instanceof Function},Nl=function(){let b=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(Ln&&Ln===b)){if((!b||typeof b!="object")&&(b={}),b=Dt(b),Bi=Qb.indexOf(b.PARSER_MEDIA_TYPE)===-1?ew:b.PARSER_MEDIA_TYPE,Ee=Bi==="application/xhtml+xml"?Ic:Aa,Te=at(b,"ALLOWED_TAGS")?q({},b.ALLOWED_TAGS,Ee):ed,Pe=at(b,"ALLOWED_ATTR")?q({},b.ALLOWED_ATTR,Ee):td,Ml=at(b,"ALLOWED_NAMESPACES")?q({},b.ALLOWED_NAMESPACES,Ic):Kb,zl=at(b,"ADD_URI_SAFE_ATTR")?q(Dt(cd),b.ADD_URI_SAFE_ATTR,Ee):cd,ad=at(b,"ADD_DATA_URI_TAGS")?q(Dt(ld),b.ADD_DATA_URI_TAGS,Ee):ld,Tt=at(b,"FORBID_CONTENTS")?q({},b.FORBID_CONTENTS,Ee):Ll,Hi=at(b,"FORBID_TAGS")?q({},b.FORBID_TAGS,Ee):Dt({}),Ro=at(b,"FORBID_ATTR")?q({},b.FORBID_ATTR,Ee):Dt({}),Pn=at(b,"USE_PROFILES")?b.USE_PROFILES:!1,rd=b.ALLOW_ARIA_ATTR!==!1,Cl=b.ALLOW_DATA_ATTR!==!1,nd=b.ALLOW_UNKNOWN_PROTOCOLS||!1,id=b.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Cn=b.SAFE_FOR_TEMPLATES||!1,Po=b.SAFE_FOR_XML!==!1,Nr=b.WHOLE_DOCUMENT||!1,Rn=b.RETURN_DOM||!1,Do=b.RETURN_DOM_FRAGMENT||!1,Lo=b.RETURN_TRUSTED_TYPE||!1,Pl=b.FORCE_BODY||!1,sd=b.SANITIZE_DOM!==!1,od=b.SANITIZE_NAMED_PROPS||!1,Dl=b.KEEP_CONTENT!==!1,Zi=b.IN_PLACE||!1,Qh=b.ALLOWED_URI_REGEXP||Tb,Dn=b.NAMESPACE||Vt,Mo=b.MATHML_TEXT_INTEGRATION_POINTS||Mo,No=b.HTML_INTEGRATION_POINTS||No,be=b.CUSTOM_ELEMENT_HANDLING||{},b.CUSTOM_ELEMENT_HANDLING&&ud(b.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(be.tagNameCheck=b.CUSTOM_ELEMENT_HANDLING.tagNameCheck),b.CUSTOM_ELEMENT_HANDLING&&ud(b.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(be.attributeNameCheck=b.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),b.CUSTOM_ELEMENT_HANDLING&&typeof b.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(be.allowCustomizedBuiltInElements=b.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Cn&&(Cl=!1),Do&&(Rn=!0),Pn&&(Te=q({},ig),Pe=Ea(null),Pn.html===!0&&(q(Te,ng),q(Pe,sg)),Pn.svg===!0&&(q(Te,Cc),q(Pe,Dc),q(Pe,ta)),Pn.svgFilters===!0&&(q(Te,Rc),q(Pe,Dc),q(Pe,ta)),Pn.mathMl===!0&&(q(Te,Pc),q(Pe,og),q(Pe,ta))),at(b,"ADD_TAGS")||(fr.tagCheck=null),at(b,"ADD_ATTR")||(fr.attributeCheck=null),b.ADD_TAGS&&(typeof b.ADD_TAGS=="function"?fr.tagCheck=b.ADD_TAGS:(Te===ed&&(Te=Dt(Te)),q(Te,b.ADD_TAGS,Ee))),b.ADD_ATTR&&(typeof b.ADD_ATTR=="function"?fr.attributeCheck=b.ADD_ATTR:(Pe===td&&(Pe=Dt(Pe)),q(Pe,b.ADD_ATTR,Ee))),b.ADD_URI_SAFE_ATTR&&q(zl,b.ADD_URI_SAFE_ATTR,Ee),b.FORBID_CONTENTS&&(Tt===Ll&&(Tt=Dt(Tt)),q(Tt,b.FORBID_CONTENTS,Ee)),b.ADD_FORBID_CONTENTS&&(Tt===Ll&&(Tt=Dt(Tt)),q(Tt,b.ADD_FORBID_CONTENTS,Ee)),Dl&&(Te["#text"]=!0),Nr&&q(Te,["html","head","body"]),Te.table&&(q(Te,["tbody"]),delete Hi.tbody),b.TRUSTED_TYPES_POLICY){if(typeof b.TRUSTED_TYPES_POLICY.createHTML!="function")throw Ki('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof b.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Ki('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');F=b.TRUSTED_TYPES_POLICY,V=F.createHTML("")}else F===void 0&&(F=jO(m,i)),F!==null&&typeof V=="string"&&(V=F.createHTML(""));je&&je(b),Ln=b}},hd=q({},[...Cc,...Rc,...OO]),dd=q({},[...Pc,...MO]),rw=function(b){let C=Z(b);(!C||!C.tagName)&&(C={namespaceURI:Dn,tagName:"template"});const P=Aa(b.tagName),ue=Aa(C.tagName);return Ml[b.namespaceURI]?b.namespaceURI===Oo?C.namespaceURI===Vt?P==="svg":C.namespaceURI===zo?P==="svg"&&(ue==="annotation-xml"||Mo[ue]):!!hd[P]:b.namespaceURI===zo?C.namespaceURI===Vt?P==="math":C.namespaceURI===Oo?P==="math"&&No[ue]:!!dd[P]:b.namespaceURI===Vt?C.namespaceURI===Oo&&!No[ue]||C.namespaceURI===zo&&!Mo[ue]?!1:!dd[P]&&(Jb[P]||!hd[P]):!!(Bi==="application/xhtml+xml"&&Ml[b.namespaceURI]):!1},Ct=function(b){Yi(t.removed,{element:b});try{Z(b).removeChild(b)}catch{T(b)}},Ur=function(b,C){try{Yi(t.removed,{attribute:C.getAttributeNode(b),from:C})}catch{Yi(t.removed,{attribute:null,from:C})}if(C.removeAttribute(b),b==="is")if(Rn||Do)try{Ct(C)}catch{}else try{C.setAttribute(b,"")}catch{}},pd=function(b){let C=null,P=null;if(Pl)b="<remove></remove>"+b;else{const Se=Tc(b,/^[\r\n\t ]+/);P=Se&&Se[0]}Bi==="application/xhtml+xml"&&Dn===Vt&&(b='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+b+"</body></html>");const ue=F?F.createHTML(b):b;if(Dn===Vt)try{C=new v().parseFromString(ue,Bi)}catch{}if(!C||!C.documentElement){C=N.createDocument(Dn,"template",null);try{C.documentElement.innerHTML=Ol?V:ue}catch{}}const Ne=C.body||C.documentElement;return b&&P&&Ne.insertBefore(e.createTextNode(P),Ne.childNodes[0]||null),Dn===Vt?ot.call(C,Nr?"html":"body")[0]:Nr?C.documentElement:Ne},fd=function(b){return J.call(b.ownerDocument||b,b,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},Ul=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")},gd=function(b){return typeof a=="function"&&b instanceof a};function Gt(M,b,C){ea(M,P=>{P.call(t,b,C,Ln)})}const md=function(b){let C=null;if(Gt(ye.beforeSanitizeElements,b,null),Ul(b))return Ct(b),!0;const P=Ee(b.nodeName);if(Gt(ye.uponSanitizeElement,b,{tagName:P,allowedTags:Te}),Po&&b.hasChildNodes()&&!gd(b.firstElementChild)&&We(/<[/\w!]/g,b.innerHTML)&&We(/<[/\w!]/g,b.textContent)||b.nodeType===Qi.progressingInstruction||Po&&b.nodeType===Qi.comment&&We(/<[/\w]/g,b.data))return Ct(b),!0;if(!(fr.tagCheck instanceof Function&&fr.tagCheck(P))&&(!Te[P]||Hi[P])){if(!Hi[P]&&yd(P)&&(be.tagNameCheck instanceof RegExp&&We(be.tagNameCheck,P)||be.tagNameCheck instanceof Function&&be.tagNameCheck(P)))return!1;if(Dl&&!Tt[P]){const ue=Z(b)||b.parentNode,Ne=R(b)||b.childNodes;if(Ne&&ue){const Se=Ne.length;for(let Ye=Se-1;Ye>=0;--Ye){const jt=E(Ne[Ye],!0);jt.__removalCount=(b.__removalCount||0)+1,ue.insertBefore(jt,O(b))}}}return Ct(b),!0}return b instanceof c&&!rw(b)||(P==="noscript"||P==="noembed"||P==="noframes")&&We(/<\/no(script|embed|frames)/i,b.innerHTML)?(Ct(b),!0):(Cn&&b.nodeType===Qi.text&&(C=b.textContent,ea([$t,ht,It],ue=>{C=Xi(C,ue," ")}),b.textContent!==C&&(Yi(t.removed,{element:b.cloneNode()}),b.textContent=C)),Gt(ye.afterSanitizeElements,b,null),!1)},vd=function(b,C,P){if(Ro[C]||sd&&(C==="id"||C==="name")&&(P in e||P in tw))return!1;if(!(Cl&&!Ro[C]&&We(Tl,C))){if(!(rd&&We(Co,C))){if(!(fr.attributeCheck instanceof Function&&fr.attributeCheck(C,b))){if(!Pe[C]||Ro[C]){if(!(yd(b)&&(be.tagNameCheck instanceof RegExp&&We(be.tagNameCheck,b)||be.tagNameCheck instanceof Function&&be.tagNameCheck(b))&&(be.attributeNameCheck instanceof RegExp&&We(be.attributeNameCheck,C)||be.attributeNameCheck instanceof Function&&be.attributeNameCheck(C,b))||C==="is"&&be.allowCustomizedBuiltInElements&&(be.tagNameCheck instanceof RegExp&&We(be.tagNameCheck,P)||be.tagNameCheck instanceof Function&&be.tagNameCheck(P))))return!1}else if(!zl[C]){if(!We(Qh,Xi(P,Jh,""))){if(!((C==="src"||C==="xlink:href"||C==="href")&&b!=="script"&&PO(P,"data:")===0&&ad[b])){if(!(nd&&!We(qb,Xi(P,Jh,"")))){if(P)return!1}}}}}}}return!0},yd=function(b){return b!=="annotation-xml"&&Tc(b,Yb)},bd=function(b){Gt(ye.beforeSanitizeAttributes,b,null);const{attributes:C}=b;if(!C||Ul(b))return;const P={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Pe,forceKeepAttr:void 0};let ue=C.length;for(;ue--;){const Ne=C[ue],{name:Se,namespaceURI:Ye,value:jt}=Ne,zn=Ee(Se),Fl=jt;let De=Se==="value"?Fl:DO(Fl);if(P.attrName=zn,P.attrValue=De,P.keepAttr=!0,P.forceKeepAttr=void 0,Gt(ye.uponSanitizeAttribute,b,P),De=P.attrValue,od&&(zn==="id"||zn==="name")&&(Ur(Se,b),De=Xb+De),Po&&We(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,De)){Ur(Se,b);continue}if(zn==="attributename"&&Tc(De,"href")){Ur(Se,b);continue}if(P.forceKeepAttr)continue;if(!P.keepAttr){Ur(Se,b);continue}if(!id&&We(/\/>/i,De)){Ur(Se,b);continue}Cn&&ea([$t,ht,It],Sd=>{De=Xi(De,Sd," ")});const wd=Ee(b.nodeName);if(!vd(wd,zn,De)){Ur(Se,b);continue}if(F&&typeof m=="object"&&typeof m.getAttributeType=="function"&&!Ye)switch(m.getAttributeType(wd,zn)){case"TrustedHTML":{De=F.createHTML(De);break}case"TrustedScriptURL":{De=F.createScriptURL(De);break}}if(De!==Fl)try{Ye?b.setAttributeNS(Ye,Se,De):b.setAttribute(Se,De),Ul(b)?Ct(b):rg(t.removed)}catch{Ur(Se,b)}}Gt(ye.afterSanitizeAttributes,b,null)},nw=function M(b){let C=null;const P=fd(b);for(Gt(ye.beforeSanitizeShadowDOM,b,null);C=P.nextNode();)Gt(ye.uponSanitizeShadowNode,C,null),md(C),bd(C),C.content instanceof s&&M(C.content);Gt(ye.afterSanitizeShadowDOM,b,null)};return t.sanitize=function(M){let b=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},C=null,P=null,ue=null,Ne=null;if(Ol=!M,Ol&&(M="<!-->"),typeof M!="string"&&!gd(M))if(typeof M.toString=="function"){if(M=M.toString(),typeof M!="string")throw Ki("dirty is not a string, aborting")}else throw Ki("toString is not a function");if(!t.isSupported)return M;if(Rl||Nl(b),t.removed=[],typeof M=="string"&&(Zi=!1),Zi){if(M.nodeName){const jt=Ee(M.nodeName);if(!Te[jt]||Hi[jt])throw Ki("root node is forbidden and cannot be sanitized in-place")}}else if(M instanceof a)C=pd("<!---->"),P=C.ownerDocument.importNode(M,!0),P.nodeType===Qi.element&&P.nodeName==="BODY"||P.nodeName==="HTML"?C=P:C.appendChild(P);else{if(!Rn&&!Cn&&!Nr&&M.indexOf("<")===-1)return F&&Lo?F.createHTML(M):M;if(C=pd(M),!C)return Rn?null:Lo?V:""}C&&Pl&&Ct(C.firstChild);const Se=fd(Zi?M:C);for(;ue=Se.nextNode();)md(ue),bd(ue),ue.content instanceof s&&nw(ue.content);if(Zi)return M;if(Rn){if(Do)for(Ne=j.call(C.ownerDocument);C.firstChild;)Ne.appendChild(C.firstChild);else Ne=C;return(Pe.shadowroot||Pe.shadowrootmode)&&(Ne=At.call(n,Ne,!0)),Ne}let Ye=Nr?C.outerHTML:C.innerHTML;return Nr&&Te["!doctype"]&&C.ownerDocument&&C.ownerDocument.doctype&&C.ownerDocument.doctype.name&&We(Cb,C.ownerDocument.doctype.name)&&(Ye="<!DOCTYPE "+C.ownerDocument.doctype.name+`>
|
|
353
|
+
`+Ye),Cn&&ea([$t,ht,It],jt=>{Ye=Xi(Ye,jt," ")}),F&&Lo?F.createHTML(Ye):Ye},t.setConfig=function(){let M=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Nl(M),Rl=!0},t.clearConfig=function(){Ln=null,Rl=!1},t.isValidAttribute=function(M,b,C){Ln||Nl({});const P=Ee(M),ue=Ee(b);return vd(P,ue,C)},t.addHook=function(M,b){typeof b=="function"&&Yi(ye[M],b)},t.removeHook=function(M,b){if(b!==void 0){const C=CO(ye[M],b);return C===-1?void 0:RO(ye[M],C,1)[0]}return rg(ye[M])},t.removeHooks=function(M){ye[M]=[]},t.removeAllHooks=function(){ye=lg()},t}var Pb=Rb();function Fh(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Tn=Fh();function Db(r){Tn=r}var jr={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(Ge.caret,"$1"),e=e.replace(i,o),n},getRegex:()=>new RegExp(e,t)};return n}var qO=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),Ge={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex: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)}}>`)},YO=/^(?:[ \t]*(?:\n|$))+/,XO=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,KO=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,To=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,JO=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Wh=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Lb=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,zb=K(Lb).replace(/bull/g,Wh).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(),QO=K(Lb).replace(/bull/g,Wh).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(),Hh=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,e2=/^[^\n]+/,Zh=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,t2=K(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Zh).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),r2=K(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Wh).getRegex(),$l="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",Bh=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,n2=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",Bh).replace("tag",$l).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Ob=K(Hh).replace("hr",To).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",$l).getRegex(),i2=K(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Ob).getRegex(),Vh={blockquote:i2,code:XO,def:t2,fences:KO,heading:JO,hr:To,html:n2,lheading:zb,list:r2,newline:YO,paragraph:Ob,table:jr,text:e2},cg=K("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",To).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",$l).getRegex(),s2={...Vh,lheading:QO,table:cg,paragraph:K(Hh).replace("hr",To).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",cg).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",$l).getRegex()},o2={...Vh,html:K(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Bh).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:jr,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:K(Hh).replace("hr",To).replace("heading",` *#{1,6} *[^
|
|
354
|
+
]`).replace("lheading",zb).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},a2=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,l2=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Mb=/^( {2,}|\\)\n(?!\s*$)/,c2=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Wi=/[\p{P}\p{S}]/u,Il=/[\s\p{P}\p{S}]/u,Gh=/[^\s\p{P}\p{S}]/u,u2=K(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Il).getRegex(),Nb=/(?!~)[\p{P}\p{S}]/u,h2=/(?!~)[\s\p{P}\p{S}]/u,d2=/(?:[^\s\p{P}\p{S}]|~)/u,p2=K(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",qO?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Ub=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,f2=K(Ub,"u").replace(/punct/g,Wi).getRegex(),g2=K(Ub,"u").replace(/punct/g,Nb).getRegex(),Fb="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",m2=K(Fb,"gu").replace(/notPunctSpace/g,Gh).replace(/punctSpace/g,Il).replace(/punct/g,Wi).getRegex(),v2=K(Fb,"gu").replace(/notPunctSpace/g,d2).replace(/punctSpace/g,h2).replace(/punct/g,Nb).getRegex(),y2=K("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Gh).replace(/punctSpace/g,Il).replace(/punct/g,Wi).getRegex(),b2=K(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,Wi).getRegex(),w2="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",S2=K(w2,"gu").replace(/notPunctSpace/g,Gh).replace(/punctSpace/g,Il).replace(/punct/g,Wi).getRegex(),_2=K(/\\(punct)/,"gu").replace(/punct/g,Wi).getRegex(),k2=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(),x2=K(Bh).replace("(?:-->|$)","-->").getRegex(),E2=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",x2).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Ba=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,A2=K(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",Ba).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Wb=K(/^!?\[(label)\]\[(ref)\]/).replace("label",Ba).replace("ref",Zh).getRegex(),Hb=K(/^!?\[(ref)\](?:\[\])?/).replace("ref",Zh).getRegex(),$2=K("reflink|nolink(?!\\()","g").replace("reflink",Wb).replace("nolink",Hb).getRegex(),ug=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,jh={_backpedal:jr,anyPunctuation:_2,autolink:k2,blockSkip:p2,br:Mb,code:l2,del:jr,delLDelim:jr,delRDelim:jr,emStrongLDelim:f2,emStrongRDelimAst:m2,emStrongRDelimUnd:y2,escape:a2,link:A2,nolink:Hb,punctuation:u2,reflink:Wb,reflinkSearch:$2,tag:E2,text:c2,url:jr},I2={...jh,link:K(/^!?\[(label)\]\((.*?)\)/).replace("label",Ba).getRegex(),reflink:K(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Ba).getRegex()},Nu={...jh,emStrongRDelimAst:v2,emStrongLDelim:g2,delLDelim:b2,delRDelim:S2,url:K(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",ug).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",ug).getRegex()},T2={...Nu,br:K(Mb).replace("{2,}","*").getRegex(),text:K(Nu.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},ra={normal:Vh,gfm:s2,pedantic:o2},es={normal:jh,gfm:Nu,breaks:T2,pedantic:I2},C2={"&":"&","<":"<",">":">",'"':""","'":"'"},hg=r=>C2[r];function Lt(r,t){if(t){if(Ge.escapeTest.test(r))return r.replace(Ge.escapeReplace,hg)}else if(Ge.escapeTestNoEncode.test(r))return r.replace(Ge.escapeReplaceNoEncode,hg);return r}function dg(r){try{r=encodeURI(r).replace(Ge.percentDecode,"%")}catch{return null}return r}function pg(r,t){var s;let e=r.replace(Ge.findPipe,(o,a,c)=>{let u=!1,h=a;for(;--h>=0&&c[h]==="\\";)u=!u;return u?"|":" |"}),n=e.split(Ge.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(Ge.slashPipe,"|");return n}function ts(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 R2(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 P2(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 fg(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 D2(r,t,e){let n=r.match(e.other.indentCodeCompensation);if(n===null)return t;let i=n[1];return t.split(`
|
|
355
|
+
`).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(`
|
|
356
|
+
`)}var Va=class{constructor(r){y(this,"options");y(this,"rules");y(this,"lexer");this.options=r||Tn}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:ts(e,`
|
|
357
|
+
`)}}}fences(r){let t=this.rules.block.fences.exec(r);if(t){let e=t[0],n=D2(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=ts(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:ts(t[0],`
|
|
358
|
+
`)}}blockquote(r){let t=this.rules.block.blockquote.exec(r);if(t){let e=ts(t[0],`
|
|
359
|
+
`).split(`
|
|
360
|
+
`),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(`
|
|
361
|
+
`),h=u.replace(this.rules.other.blockquoteSetextReplace,`
|
|
362
|
+
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");n=n?`${n}
|
|
363
|
+
${u}`:u,i=i?`${i}
|
|
364
|
+
${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 v=s.at(-1);if((v==null?void 0:v.type)==="code")break;if((v==null?void 0:v.type)==="blockquote"){let m=v,x=m.raw+`
|
|
365
|
+
`+e.join(`
|
|
366
|
+
`),E=this.blockquote(x);s[s.length-1]=E,n=n.substring(0,n.length-m.raw.length)+E.raw,i=i.substring(0,i.length-m.text.length)+E.text;break}else if((v==null?void 0:v.type)==="list"){let m=v,x=m.raw+`
|
|
367
|
+
`+e.join(`
|
|
368
|
+
`),E=this.list(x);s[s.length-1]=E,n=n.substring(0,n.length-v.raw.length)+E.raw,i=i.substring(0,i.length-m.raw.length)+E.raw,e=x.substring(s.at(-1).raw.length).split(`
|
|
369
|
+
`);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="",v="";if(!(t=a.exec(r))||this.rules.block.hr.test(r))break;p=t[0],r=r.substring(p.length);let m=P2(t[2].split(`
|
|
370
|
+
`,1)[0],t[1].length),x=r.split(`
|
|
371
|
+
`,1)[0],E=!m.trim(),T=0;if(this.options.pedantic?(T=2,v=m.trimStart()):E?T=t[1].length+1:(T=m.search(this.rules.other.nonSpaceChar),T=T>4?1:T,v=m.slice(T),T+=t[1].length),E&&this.rules.other.blankLine.test(x)&&(p+=x+`
|
|
372
|
+
`,r=r.substring(x.length+1),h=!0),!h){let O=this.rules.other.nextBulletRegex(T),R=this.rules.other.hrRegex(T),Z=this.rules.other.fencesBeginRegex(T),F=this.rules.other.headingBeginRegex(T),V=this.rules.other.htmlBeginRegex(T),N=this.rules.other.blockquoteBeginRegex(T);for(;r;){let J=r.split(`
|
|
373
|
+
`,1)[0],j;if(x=J,this.options.pedantic?(x=x.replace(this.rules.other.listReplaceNesting," "),j=x):j=x.replace(this.rules.other.tabCharGlobal," "),Z.test(x)||F.test(x)||V.test(x)||N.test(x)||O.test(x)||R.test(x))break;if(j.search(this.rules.other.nonSpaceChar)>=T||!x.trim())v+=`
|
|
374
|
+
`+j.slice(T);else{if(E||m.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||Z.test(m)||F.test(m)||R.test(m))break;v+=`
|
|
375
|
+
`+x}E=!x.trim(),p+=J+`
|
|
376
|
+
`,r=r.substring(J.length+1),m=j.slice(T)}}o.loose||(c?o.loose=!0:this.rules.other.doubleBlankLine.test(p)&&(c=!0)),o.items.push({type:"list_item",raw:p,task:!!this.options.gfm&&this.rules.other.listIsTask.test(v),loose:!1,text:v,tokens:[]}),o.raw+=p}let u=o.items.at(-1);if(u)u.raw=u.raw.trimEnd(),u.text=u.text.trimEnd();else return;o.raw=o.raw.trimEnd();for(let h of o.items){if(this.lexer.state.top=!1,h.tokens=this.lexer.blockTokens(h.text,[]),h.task){if(h.text=h.text.replace(this.rules.other.listReplaceTask,""),((e=h.tokens[0])==null?void 0:e.type)==="text"||((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 v=this.lexer.inlineQueue.length-1;v>=0;v--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[v].src)){this.lexer.inlineQueue[v].src=this.lexer.inlineQueue[v].src.replace(this.rules.other.listReplaceTask,"");break}}let p=this.rules.other.listTaskCheckbox.exec(h.raw);if(p){let v={type:"checkbox",raw:p[0]+" ",checked:p[0]!=="[ ]"};h.checked=v.checked,o.loose?h.tokens[0]&&["paragraph","text"].includes(h.tokens[0].type)&&"tokens"in h.tokens[0]&&h.tokens[0].tokens?(h.tokens[0].raw=v.raw+h.tokens[0].raw,h.tokens[0].text=v.raw+h.tokens[0].text,h.tokens[0].tokens.unshift(v)):h.tokens.unshift({type:"paragraph",raw:v.raw,text:v.raw,tokens:[v]}):h.tokens.unshift(v)}}if(!o.loose){let p=h.tokens.filter(m=>m.type==="space"),v=p.length>0&&p.some(m=>this.rules.other.anyLine.test(m.raw));o.loose=v}}if(o.loose)for(let h of o.items){h.loose=!0;for(let p of h.tokens)p.type==="text"&&(p.type="paragraph")}return o}}html(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=pg(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(`
|
|
377
|
+
`):[],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(pg(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)===`
|
|
378
|
+
`?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=ts(e.slice(0,-1),"\\");if((e.length-s.length)%2===0)return}else{let s=R2(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)),fg(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 fg(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 m=p.slice(1,-1);return{type:"em",raw:p,text:m,tokens:this.lexer.inlineTokens(m)}}let v=p.slice(2,-2);return{type:"strong",raw:p,text:v,tokens:this.lexer.inlineTokens(v)}}}}codespan(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 Uu{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||Tn,this.options.tokenizer=this.options.tokenizer||new Va,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let e={other:Ge,block:ra.normal,inline:es.normal};this.options.pedantic?(e.block=ra.pedantic,e.inline=es.pedantic):this.options.gfm&&(e.block=ra.gfm,this.options.breaks?e.inline=es.breaks:e.inline=es.gfm),this.tokenizer.rules=e}static get rules(){return{block:ra,inline:es}}static lex(t,e){return new Uu(e).lex(t)}static lexInline(t,e){return new Uu(e).inlineTokens(t)}lex(t){t=t.replace(Ge.carriageReturn,`
|
|
379
|
+
`),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(Ge.tabCharGlobal," ").replace(Ge.spaceLine,""));t;){let a;if((s=(i=this.options.extensions)==null?void 0:i.block)!=null&&s.some(u=>(a=u.call({lexer:this},t,e))?(t=t.substring(a.raw.length),e.push(a),!0):!1))continue;if(a=this.tokenizer.space(t)){t=t.substring(a.raw.length);let u=e.at(-1);a.raw.length===1&&u!==void 0?u.raw+=`
|
|
380
|
+
`: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(`
|
|
381
|
+
`)?"":`
|
|
382
|
+
`)+a.raw,u.text+=`
|
|
383
|
+
`+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(`
|
|
384
|
+
`)?"":`
|
|
385
|
+
`)+a.raw,u.text+=`
|
|
386
|
+
`+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(v=>{p=v.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(`
|
|
387
|
+
`)?"":`
|
|
388
|
+
`)+a.raw,u.text+=`
|
|
389
|
+
`+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(`
|
|
390
|
+
`)?"":`
|
|
391
|
+
`)+a.raw,u.text+=`
|
|
392
|
+
`+a.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=u.text):e.push(a);continue}if(t){let u="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(u);break}else throw new Error(u)}}return this.state.top=!0,e}inline(t,e=[]){return this.inlineQueue.push({src:t,tokens:e}),e}inlineTokens(t,e=[]){var c,u,h,p,v;this.tokenizer.lexer=this;let n=t,i=null;if(this.tokens.links){let m=Object.keys(this.tokens.links);if(m.length>0)for(;(i=this.tokenizer.rules.inline.reflinkSearch.exec(n))!=null;)m.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 m;if((p=(h=this.options.extensions)==null?void 0:h.inline)!=null&&p.some(E=>(m=E.call({lexer:this},t,e))?(t=t.substring(m.raw.length),e.push(m),!0):!1))continue;if(m=this.tokenizer.escape(t)){t=t.substring(m.raw.length),e.push(m);continue}if(m=this.tokenizer.tag(t)){t=t.substring(m.raw.length),e.push(m);continue}if(m=this.tokenizer.link(t)){t=t.substring(m.raw.length),e.push(m);continue}if(m=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(m.raw.length);let E=e.at(-1);m.type==="text"&&(E==null?void 0:E.type)==="text"?(E.raw+=m.raw,E.text+=m.text):e.push(m);continue}if(m=this.tokenizer.emStrong(t,n,a)){t=t.substring(m.raw.length),e.push(m);continue}if(m=this.tokenizer.codespan(t)){t=t.substring(m.raw.length),e.push(m);continue}if(m=this.tokenizer.br(t)){t=t.substring(m.raw.length),e.push(m);continue}if(m=this.tokenizer.del(t,n,a)){t=t.substring(m.raw.length),e.push(m);continue}if(m=this.tokenizer.autolink(t)){t=t.substring(m.raw.length),e.push(m);continue}if(!this.state.inLink&&(m=this.tokenizer.url(t))){t=t.substring(m.raw.length),e.push(m);continue}let x=t;if((v=this.options.extensions)!=null&&v.startInline){let E=1/0,T=t.slice(1),O;this.options.extensions.startInline.forEach(R=>{O=R.call({lexer:this},T),typeof O=="number"&&O>=0&&(E=Math.min(E,O))}),E<1/0&&E>=0&&(x=t.substring(0,E+1))}if(m=this.tokenizer.inlineText(x)){t=t.substring(m.raw.length),m.raw.slice(-1)!=="_"&&(a=m.raw.slice(-1)),o=!0;let E=e.at(-1);(E==null?void 0:E.type)==="text"?(E.raw+=m.raw,E.text+=m.text):e.push(m);continue}if(t){let E="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(E);break}else throw new Error(E)}}return e}},Ga=class{constructor(r){y(this,"options");y(this,"parser");this.options=r||Tn}space(r){return""}code({text:r,lang:t,escaped:e}){var s;let n=(s=(t||"").match(Ge.notSpaceStart))==null?void 0:s[0],i=r.replace(Ge.endingNewline,"")+`
|
|
393
|
+
`;return n?'<pre><code class="language-'+Lt(n)+'">'+(e?i:Lt(i,!0))+`</code></pre>
|
|
394
|
+
`:"<pre><code>"+(e?i:Lt(i,!0))+`</code></pre>
|
|
395
|
+
`}blockquote({tokens:r}){return`<blockquote>
|
|
396
|
+
${this.parser.parse(r)}</blockquote>
|
|
397
|
+
`}html({text:r}){return r}def(r){return""}heading({tokens:r,depth:t}){return`<h${t}>${this.parser.parseInline(r)}</h${t}>
|
|
398
|
+
`}hr(r){return`<hr>
|
|
399
|
+
`}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+`>
|
|
400
|
+
`+n+"</"+i+`>
|
|
401
|
+
`}listitem(r){return`<li>${this.parser.parse(r.tokens)}</li>
|
|
402
|
+
`}checkbox({checked:r}){return"<input "+(r?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:r}){return`<p>${this.parser.parseInline(r)}</p>
|
|
403
|
+
`}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>
|
|
404
|
+
<thead>
|
|
405
|
+
`+t+`</thead>
|
|
406
|
+
`+n+`</table>
|
|
407
|
+
`}tablerow({text:r}){return`<tr>
|
|
408
|
+
${r}</tr>
|
|
409
|
+
`}tablecell(r){let t=this.parser.parseInline(r.tokens),e=r.header?"th":"td";return(r.align?`<${e} align="${r.align}">`:`<${e}>`)+t+`</${e}>
|
|
410
|
+
`}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>${Lt(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=dg(r);if(i===null)return n;r=i;let s='<a href="'+r+'"';return t&&(s+=' title="'+Lt(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=dg(r);if(i===null)return Lt(e);r=i;let s=`<img src="${r}" alt="${Lt(e)}"`;return t&&(s+=` title="${Lt(t)}"`),s+=">",s}text(r){return"tokens"in r&&r.tokens?this.parser.parseInline(r.tokens):"escaped"in r&&r.escaped?r.text:Lt(r.text)}},qh=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}},xt=class Fu{constructor(t){y(this,"options");y(this,"renderer");y(this,"textRenderer");this.options=t||Tn,this.options.renderer=this.options.renderer||new Ga,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new qh}static parse(t,e){return new Fu(e).parse(t)}static parseInline(t,e){return new Fu(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}},na,us=(na=class{constructor(r){y(this,"options");y(this,"block");this.options=r||Tn}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?xt.parse:xt.parseInline}},y(na,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),y(na,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),na),L2=class{constructor(...r){y(this,"defaults",Fh());y(this,"options",this.setOptions);y(this,"parse",this.parseMarkdown(!0));y(this,"parseInline",this.parseMarkdown(!1));y(this,"Parser",xt);y(this,"Renderer",Ga);y(this,"TextRenderer",qh);y(this,"Lexer",kt);y(this,"Tokenizer",Va);y(this,"Hooks",us);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 Ga(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 Va(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 us;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];us.passThroughHooks.has(s)?i[o]=u=>{if(this.defaults.async&&us.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 xt.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?xt.parse:xt.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?xt.parse:xt.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+=`
|
|
411
|
+
Please report this to https://github.com/markedjs/marked.`,r){let n="<p>An error occurred:</p><pre>"+Lt(e.message+"",!0)+"</pre>";return t?Promise.resolve(n):n}if(t)return Promise.reject(e);throw e}}},xn=new L2;function te(r,t){return xn.parse(r,t)}te.options=te.setOptions=function(r){return xn.setOptions(r),te.defaults=xn.defaults,Db(te.defaults),te};te.getDefaults=Fh;te.defaults=Tn;te.use=function(...r){return xn.use(...r),te.defaults=xn.defaults,Db(te.defaults),te};te.walkTokens=function(r,t){return xn.walkTokens(r,t)};te.parseInline=xn.parseInline;te.Parser=xt;te.parser=xt.parse;te.Renderer=Ga;te.TextRenderer=qh;te.Lexer=kt;te.lexer=kt.lex;te.Tokenizer=Va;te.Hooks=us;te.parse=te;te.options;te.setOptions;te.use;te.walkTokens;te.parseInline;xt.parse;kt.lex;Pb.addHook("afterSanitizeAttributes",r=>{r.tagName==="A"&&(r.setAttribute("target","_blank"),r.setAttribute("rel","noopener noreferrer"))});function z2(r){const t=te.parse(r,{async:!1});return Pb.sanitize(t,{USE_PROFILES:{html:!0}})}const O2=8,gg=new WeakMap;function M2(r){const t=gg.get(r);if(t&&t.text===r.text)return t.html;const e=z2(r.text);return gg.set(r,{text:r.text,html:e}),e}function N2(r){return r.replace(/_/g," ")}function U2(r){return U`
|
|
412
|
+
<div class="tool-call-header">
|
|
413
|
+
<span class="tool-call-title">${r.title}</span>
|
|
414
|
+
<span class="tool-call-meta">${r.toolKind} · ${N2(r.status)}</span>
|
|
415
|
+
</div>
|
|
416
|
+
${r.text?U`<pre class="tool-call-text">${r.text}</pre>`:null}
|
|
417
|
+
`}function mg(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 lr,yn,sl,ol,co,Wu;class Zb extends xs{constructor(){super(...arguments);w(this,co);y(this,"messages",[]);w(this,lr,!0);w(this,yn,null);w(this,sl,()=>{const e=l(this,yn);if(!e)return;const i=e.scrollHeight-e.clientHeight-e.scrollTop<=O2;i!==l(this,lr)&&(k(this,lr,i),this.toggleAttribute("data-pinned",i))});w(this,ol,()=>{k(this,lr,!0),this.toggleAttribute("data-pinned",!0),f(this,co,Wu).call(this,!0)})}changed(e){let n=!1;if(e.has("messages")){const i=e.get("messages")??[],s=mg(this.messages);n=s!==null&&s!==mg(i),n&&k(this,lr,!0)}Fe(this.template(),this),l(this,yn)||k(this,yn,this.querySelector(".history-scroll")),this.toggleAttribute("data-pinned",l(this,lr)),f(this,co,Wu).call(this,n)}template(){return U`
|
|
418
|
+
<div class="history-scroll" @scroll=${l(this,sl)}>
|
|
419
|
+
${this.messages.map(e=>{const n=e.kind==="assistant"?OL(M2(e)):e.kind==="tool_call"?U2(e):e.text;return U`<div
|
|
420
|
+
class="message message-${e.kind}"
|
|
421
|
+
data-message-id=${e.id}
|
|
422
|
+
>${n}</div>`})}
|
|
423
|
+
</div>
|
|
424
|
+
<button
|
|
425
|
+
type="button"
|
|
426
|
+
class="history-jump"
|
|
427
|
+
aria-label="Jump to latest message"
|
|
428
|
+
@click=${l(this,ol)}
|
|
429
|
+
>
|
|
430
|
+
${My({size:16})}
|
|
431
|
+
</button>
|
|
432
|
+
`}}lr=new WeakMap,yn=new WeakMap,sl=new WeakMap,ol=new WeakMap,co=new WeakSet,Wu=function(e){requestAnimationFrame(()=>{const n=l(this,yn);n&&(!l(this,lr)&&!e||(n.scrollTop=n.scrollHeight-n.clientHeight))})},y(Zb,"properties",["messages"]);customElements.define("message-history",Zb);var uo,ho,_i,al,ll,pt,$a,po,Zu,Bu,fo,go;class Hu extends xs{constructor(){super(...arguments);w(this,pt);y(this,"placeholder","What do you want to do?");y(this,"open",!1);y(this,"messages",[]);w(this,uo,Zt.resolve("ServerManager"));w(this,ho,Zt.resolve("ShortcutService"));w(this,_i,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,pt,$a).call(this,n);const s=(o=l(this,uo).activeServer)==null?void 0:o.acpClient;s&&s.sendMessage({text:i}).catch(a=>{console.error("ACPClient.sendMessage() failed",a)})});w(this,al,e=>{f(this,pt,$a).call(this,e.currentTarget)});w(this,ll,e=>{if(e.target instanceof HTMLTextAreaElement)return;const n=e.currentTarget.querySelector("textarea");n==null||n.focus()});w(this,po,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,fo,e=>{e.target instanceof Node&&(this.contains(e.target)||(this.open=!1))});w(this,go,e=>{e.key==="Escape"&&(this.open=!1)})}connected(){const e=new DisposableStack;k(this,_i,e);const n=AO(l(this,uo),i=>{this.messages=i});e.defer(()=>n.dispose()),l(this,ho).addEventListener("shortcut-triggered",l(this,po)),e.defer(()=>l(this,ho).removeEventListener("shortcut-triggered",l(this,po))),this.open&&f(this,pt,Zu).call(this)}disconnected(){var e;(e=l(this,_i))==null||e.dispose(),k(this,_i,null),f(this,pt,Bu).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,pt,Zu).call(this);const n=this.querySelector("textarea");n&&(f(this,pt,$a).call(this,n),n.focus())}else f(this,pt,Bu).call(this)}template(){return this.open?U`
|
|
433
|
+
${this.messages.length>0?U`
|
|
434
|
+
<div
|
|
435
|
+
class="chat"
|
|
436
|
+
material="paper"
|
|
437
|
+
tone="dark"
|
|
438
|
+
level="overlay"
|
|
439
|
+
>
|
|
440
|
+
<message-history selectable .messages=${this.messages}></message-history>
|
|
441
|
+
</div>
|
|
442
|
+
`:null}
|
|
443
|
+
<div
|
|
444
|
+
class="input"
|
|
445
|
+
material="paper"
|
|
446
|
+
tone="dark"
|
|
447
|
+
level="overlay"
|
|
448
|
+
@click=${l(this,ll)}
|
|
449
|
+
>
|
|
450
|
+
<textarea
|
|
451
|
+
class="textarea"
|
|
452
|
+
rows="1"
|
|
453
|
+
@keydown=${this.handleKeydown}
|
|
454
|
+
@input=${l(this,al)}
|
|
455
|
+
></textarea>
|
|
456
|
+
</div>
|
|
457
|
+
`:U`
|
|
458
|
+
<div
|
|
459
|
+
class="trigger"
|
|
460
|
+
tabindex="0"
|
|
461
|
+
role="button"
|
|
462
|
+
@click=${this.handleTriggerActivate}
|
|
463
|
+
@focus=${this.handleTriggerActivate}
|
|
464
|
+
>
|
|
465
|
+
<span class="label">${this.placeholder}</span>
|
|
466
|
+
<span class="kbd" aria-hidden="true">⌘K</span>
|
|
467
|
+
</div>
|
|
468
|
+
`}}uo=new WeakMap,ho=new WeakMap,_i=new WeakMap,al=new WeakMap,ll=new WeakMap,pt=new WeakSet,$a=function(e){e.style.height="auto",e.style.height=`${e.scrollHeight}px`},po=new WeakMap,Zu=function(){document.addEventListener("mousedown",l(this,fo)),document.addEventListener("keydown",l(this,go))},Bu=function(){document.removeEventListener("mousedown",l(this,fo)),document.removeEventListener("keydown",l(this,go))},fo=new WeakMap,go=new WeakMap,y(Hu,"properties",["placeholder","open","messages"]),y(Hu,"attributes",{placeholder:{type:String},open:{type:Boolean}});customElements.define("command-panel",Hu);class Bb extends Event{constructor(e){super("auth-submit",{bubbles:!0,composed:!0});y(this,"token");this.token=e}}class F2 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 Bb(n))}render(){Fe(U`
|
|
469
|
+
<modal-overlay open>
|
|
470
|
+
<section class="auth-modal">
|
|
471
|
+
<form class="auth-form" @submit=${e=>this.handleSubmit(e)}>
|
|
472
|
+
<h2 class="auth-modal-title">Enter access token</h2>
|
|
473
|
+
<p class="auth-modal-copy">This Television server requires a token.</p>
|
|
474
|
+
<label class="settings-field">
|
|
475
|
+
<span>Token</span>
|
|
476
|
+
<input
|
|
477
|
+
class=${this.invalid?"auth-token-input-invalid":""}
|
|
478
|
+
type="password"
|
|
479
|
+
name="token"
|
|
480
|
+
.value=${this.tokenValue}
|
|
481
|
+
@input=${e=>this.handleInput(e)}
|
|
482
|
+
required
|
|
483
|
+
/>
|
|
484
|
+
</label>
|
|
485
|
+
<button type="submit" class="settings-submit-button">Connect</button>
|
|
486
|
+
</form>
|
|
487
|
+
</section>
|
|
488
|
+
</modal-overlay>
|
|
489
|
+
`,this)}}customElements.get("auth-modal")||customElements.define("auth-modal",F2);class W2 extends HTMLElement{constructor(){super(...arguments);y(this,"runtimeServerURL",$y());y(this,"electronMode",Dh());y(this,"serverManager",Zt.resolve("ServerManager"));y(this,"screenManager",Zt.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 Bb?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,Pf());return}if(this.serverManager.activeServer)return;const e=new Ay({url:this.runtimeServerURL,name:"Server",token:Pf()});this.serverManager.add(e),this.serverManager.setActive(e);try{await e.connect(),this.connectError=null}catch(n){this.connectError=n instanceof Error&&!(n instanceof au)?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 au||(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(U`
|
|
490
|
+
<main class="auth-gate"><p>Connecting...</p></main>
|
|
491
|
+
`,this);return}if(n==="disconnected"){const o=e;if(!o)return;Fe(U`
|
|
492
|
+
<main class="auth-gate">
|
|
493
|
+
<auth-modal
|
|
494
|
+
.invalid=${!!o.token}
|
|
495
|
+
.tokenValue=${o.token??""}
|
|
496
|
+
></auth-modal>
|
|
497
|
+
</main>
|
|
498
|
+
`,this);return}Fe(U`
|
|
499
|
+
<main>
|
|
500
|
+
${this.connectError?U`<p data-testid="auth-error">${this.connectError}</p>`:U`
|
|
501
|
+
${s?U`<screen-view></screen-view>`:null}
|
|
502
|
+
${n==="connected"?U`
|
|
503
|
+
<div class="chrome">
|
|
504
|
+
<div class="top-row" electron-draggable>
|
|
505
|
+
<screen-select></screen-select>
|
|
506
|
+
<menu-bar-clock></menu-bar-clock>
|
|
507
|
+
</div>
|
|
508
|
+
<command-panel></command-panel>
|
|
509
|
+
</div>
|
|
510
|
+
`:null}
|
|
511
|
+
`}
|
|
512
|
+
</main>
|
|
513
|
+
`,this)}}customElements.get("television-app")||customElements.define("television-app",W2);const Yh=Dh(),Xh=$y(),Vb=new MA(Yh?"television-electron":"television-browser",DA(Xh)),ur=new bL({localStore:Vb,localServerURL:Xh}),Gb=new ZA({localStore:Vb,serverManager:ur}),H2=new wL,jb=()=>{const r=ur.activeServer;if(!r||r.status!=="connected"){Da();return}r.client.display.get().then(t=>{if(!(ur.activeServer!==r||r.status!=="connected"))return Iy(t.activeThemeName,r)}).catch(()=>{ur.activeServer===r&&Da()})};jb();ur.addEventListener("change",jb);ur.addEventListener("server-event",r=>{if(r.event.type!=="theme-changed")return;const t=ur.activeServer;!t||t.url!==r.serverURL||Iy(r.event.themeName,t)});Zt.register("ServerManager",()=>ur);Zt.register("ScreenManager",()=>Gb);Zt.register("ShortcutService",()=>H2);globalThis.__telepath={screenManager:Gb,serverManager:ur};const Kh=document.createElement("television-app");Kh.runtimeServerURL=Xh;Kh.electronMode=Yh;Yh&&document.body.classList.add("electron");document.body.appendChild(Kh);
|