@telepath-computer/television 0.1.40 → 0.1.41
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.
|
@@ -0,0 +1,468 @@
|
|
|
1
|
+
var zv=Object.defineProperty;var $h=n=>{throw TypeError(n)};var Lv=(n,e,t)=>e in n?zv(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var b=(n,e,t)=>Lv(n,typeof e!="symbol"?e+"":e,t),ol=(n,e,t)=>e.has(n)||$h("Cannot "+t);var l=(n,e,t)=>(ol(n,e,"read from private field"),t?t.call(n):e.get(n)),_=(n,e,t)=>e.has(n)?$h("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(n):e.set(n,t),E=(n,e,t,r)=>(ol(n,e,"write to private field"),r?r.call(n,t):e.set(n,t),t),m=(n,e,t)=>(ol(n,e,"access private method"),t);var Ah=(n,e,t,r)=>({set _(i){E(n,e,i,t)},get _(){return l(n,e,r)}});(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const s of i)if(s.type==="childList")for(const o of s.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function t(i){const s={};return i.integrity&&(s.integrity=i.integrity),i.referrerPolicy&&(s.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?s.credentials="include":i.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function r(i){if(i.ep)return;i.ep=!0;const s=t(i);fetch(i.href,s)}})();var In=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Mv(n){if(n.__esModule)return n;var e=n.default;if(typeof e=="function"){var t=function r(){return this instanceof r?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(n).forEach(function(r){var i=Object.getOwnPropertyDescriptor(n,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:function(){return n[r]}})}),t}var xh=Object.prototype.toString,dp=function(e){var t=xh.call(e),r=t==="[object Arguments]";return r||(r=t!=="[object Array]"&&e!==null&&typeof e=="object"&&typeof e.length=="number"&&e.length>=0&&xh.call(e.callee)==="[object Function]"),r},al,Th;function Nv(){if(Th)return al;Th=1;var n;if(!Object.keys){var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,r=dp,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 y=v.constructor;return y&&y.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},d=function(){if(typeof window>"u")return!1;for(var v in window)try{if(!u["$"+v]&&e.call(window,v)&&window[v]!==null&&typeof window[v]=="object")try{c(window[v])}catch{return!0}}catch{return!0}return!1}(),f=function(v){if(typeof window>"u"||!d)return c(v);try{return c(v)}catch{return!1}};n=function(y){var A=y!==null&&typeof y=="object",k=t.call(y)==="[object Function]",I=r(y),B=A&&t.call(y)==="[object String]",P=[];if(!A&&!k&&!I)throw new TypeError("Object.keys called on a non-object");var le=o&&k;if(B&&y.length>0&&!e.call(y,0))for(var M=0;M<y.length;++M)P.push(String(M));if(I&&y.length>0)for(var Z=0;Z<y.length;++Z)P.push(String(Z));else for(var U in y)!(le&&U==="prototype")&&e.call(y,U)&&P.push(String(U));if(s)for(var ge=f(y),ce=0;ce<a.length;++ce)!(ge&&a[ce]==="constructor")&&e.call(y,a[ce])&&P.push(a[ce]);return P}}return al=n,al}var Uv=Array.prototype.slice,Fv=dp,Ch=Object.keys,Po=Ch?function(e){return Ch(e)}:Nv(),Ih=Object.keys;Po.shim=function(){if(Object.keys){var e=function(){var t=Object.keys(arguments);return t&&t.length===arguments.length}(1,2);e||(Object.keys=function(r){return Fv(r)?Ih(Uv.call(r)):Ih(r)})}else Object.keys=Po;return Object.keys||Po};var Zv=Po,Ro=Object.defineProperty||!1;if(Ro)try{Ro({},"a",{value:1})}catch{Ro=!1}var Hs=Ro,qt=SyntaxError,G=TypeError,Hv=Object.getOwnPropertyDescriptor,Do=Hv;if(Do)try{Do([],"length")}catch{Do=null}var ii=Do,Ph=Hs,Vv=qt,yr=G,Rh=ii,fp=function(e,t,r){if(!e||typeof e!="object"&&typeof e!="function")throw new yr("`obj` must be an object or a function`");if(typeof t!="string"&&typeof t!="symbol")throw new yr("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new yr("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new yr("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new yr("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new yr("`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=!!Rh&&Rh(e,t);if(Ph)Ph(e,t,{configurable:o===null&&c?c.configurable:!o,enumerable:i===null&&c?c.enumerable:!i,value:r,writable:s===null&&c?c.writable:!s});else if(a||!i&&!s&&!o)e[t]=r;else throw new Vv("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},Jl=Hs,pp=function(){return!!Jl};pp.hasArrayLengthDefineBug=function(){if(!Jl)return null;try{return Jl([],"length",{value:1}).length!==1}catch{return!0}};var Ca=pp,jv=Zv,Bv=typeof Symbol=="function"&&typeof Symbol("foo")=="symbol",Gv=Object.prototype.toString,Wv=Array.prototype.concat,Dh=fp,qv=function(n){return typeof n=="function"&&Gv.call(n)==="[object Function]"},gp=Ca(),Yv=function(n,e,t,r){if(e in n){if(r===!0){if(n[e]===t)return}else if(!qv(r)||!r())return}gp?Dh(n,e,t,!0):Dh(n,e,t)},mp=function(n,e){var t=arguments.length>2?arguments[2]:{},r=jv(e);Bv&&(r=Wv.call(r,Object.getOwnPropertySymbols(e)));for(var i=0;i<r.length;i+=1)Yv(n,r[i],e[r[i]],t[r[i]])};mp.supportsDescriptors=!!gp;var ar=mp,Oo={exports:{}};typeof self<"u"?Oo.exports=self:typeof window<"u"?Oo.exports=window:Oo.exports=Function("return this")();var yp=Oo.exports,Kv=yp,vp=function(){return typeof In!="object"||!In||In.Math!==Math||In.Array!==Array?Kv:In},Jv=ar,Xv=ii,Qv=vp,eb=function(){var e=Qv();if(Jv.supportsDescriptors){var t=Xv(e,"globalThis");(!t||t.configurable&&(t.enumerable||!t.writable||globalThis!==e))&&Object.defineProperty(e,"globalThis",{configurable:!0,enumerable:!1,value:e,writable:!0})}else(typeof globalThis!="object"||globalThis!==e)&&(e.globalThis=e);return e},tb=ar,nb=yp,bp=vp,rb=eb,ib=bp(),wp=function(){return ib};tb(wp,{getPolyfill:bp,implementation:nb,shim:rb});var Xc=wp,Yt=function(e){return!!e&&(typeof e=="function"||typeof e=="object")},Qc=Object,_p=Error,sb=EvalError,ob=RangeError,eu=ReferenceError,ab=URIError,lb=Math.abs,cb=Math.floor,ub=Math.max,hb=Math.min,db=Math.pow,fb=Math.round,tu=Number.isNaN||function(e){return e!==e},pb=tu,gb=function(e){return pb(e)||e===0?e:e<0?-1:1},si=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var e={},t=Symbol("test"),r=Object(t);if(typeof t=="string"||Object.prototype.toString.call(t)!=="[object Symbol]"||Object.prototype.toString.call(r)!=="[object Symbol]")return!1;var i=42;e[t]=i;for(var s in e)return!1;if(typeof Object.keys=="function"&&Object.keys(e).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(e).length!==0)return!1;var o=Object.getOwnPropertySymbols(e);if(o.length!==1||o[0]!==t||!Object.prototype.propertyIsEnumerable.call(e,t))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var a=Object.getOwnPropertyDescriptor(e,t);if(a.value!==i||a.enumerable!==!0)return!1}return!0},Oh=typeof Symbol<"u"&&Symbol,mb=si,nu=function(){return typeof Oh!="function"||typeof Symbol!="function"||typeof Oh("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:mb()},Sp=typeof Reflect<"u"&&Reflect.getPrototypeOf||null,yb=Qc,kp=yb.getPrototypeOf||null,vb="Function.prototype.bind called on incompatible ",bb=Object.prototype.toString,wb=Math.max,_b="[object Function]",zh=function(e,t){for(var r=[],i=0;i<e.length;i+=1)r[i]=e[i];for(var s=0;s<t.length;s+=1)r[s+e.length]=t[s];return r},Sb=function(e,t){for(var r=[],i=t,s=0;i<e.length;i+=1,s+=1)r[s]=e[i];return r},kb=function(n,e){for(var t="",r=0;r<n.length;r+=1)t+=n[r],r+1<n.length&&(t+=e);return t},Eb=function(e){var t=this;if(typeof t!="function"||bb.apply(t)!==_b)throw new TypeError(vb+t);for(var r=Sb(arguments,1),i,s=function(){if(this instanceof i){var d=t.apply(this,zh(r,arguments));return Object(d)===d?d:this}return t.apply(e,zh(r,arguments))},o=wb(0,t.length-r.length),a=[],c=0;c<o;c++)a[c]="$"+c;if(i=Function("binder","return function ("+kb(a,",")+"){ return binder.apply(this,arguments); }")(s),t.prototype){var u=function(){};u.prototype=t.prototype,i.prototype=new u,u.prototype=null}return i},$b=Eb,Vs=Function.prototype.bind||$b,ru=Function.prototype.call,iu=Function.prototype.apply,Ab=typeof Reflect<"u"&&Reflect&&Reflect.apply,xb=Vs,Tb=iu,Cb=ru,Ib=Ab,Ep=Ib||xb.call(Cb,Tb),Pb=Vs,Rb=G,Db=ru,Ob=Ep,Ia=function(e){if(e.length<1||typeof e[0]!="function")throw new Rb("a function is required");return Ob(Pb,Db,e)},zb=Ia,Lh=ii,$p;try{$p=[].__proto__===Array.prototype}catch(n){if(!n||typeof n!="object"||!("code"in n)||n.code!=="ERR_PROTO_ACCESS")throw n}var ll=!!$p&&Lh&&Lh(Object.prototype,"__proto__"),Ap=Object,Mh=Ap.getPrototypeOf,Lb=ll&&typeof ll.get=="function"?zb([ll.get]):typeof Mh=="function"?function(e){return Mh(e==null?e:Ap(e))}:!1,Nh=Sp,Uh=kp,Fh=Lb,xp=Nh?function(e){return Nh(e)}:Uh?function(e){if(!e||typeof e!="object"&&typeof e!="function")throw new TypeError("getProto: not an object");return Uh(e)}:Fh?function(e){return Fh(e)}:null,Mb=Function.prototype.call,Nb=Object.prototype.hasOwnProperty,Ub=Vs,Kt=Ub.call(Mb,Nb),j,Fb=Qc,Zb=_p,Hb=sb,Vb=ob,jb=eu,Jr=qt,Pr=G,Bb=ab,Gb=lb,Wb=cb,qb=ub,Yb=hb,Kb=db,Jb=fb,Xb=gb,Tp=Function,cl=function(n){try{return Tp('"use strict"; return ('+n+").constructor;")()}catch{}},Ki=ii,Qb=Hs,ul=function(){throw new Pr},ew=Ki?function(){try{return arguments.callee,ul}catch{try{return Ki(arguments,"callee").get}catch{return ul}}}():ul,vr=nu(),Se=xp,tw=kp,nw=Sp,Cp=iu,js=ru,_r={},rw=typeof Uint8Array>"u"||!Se?j:Se(Uint8Array),er={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?j:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?j:ArrayBuffer,"%ArrayIteratorPrototype%":vr&&Se?Se([][Symbol.iterator]()):j,"%AsyncFromSyncIteratorPrototype%":j,"%AsyncFunction%":_r,"%AsyncGenerator%":_r,"%AsyncGeneratorFunction%":_r,"%AsyncIteratorPrototype%":_r,"%Atomics%":typeof Atomics>"u"?j:Atomics,"%BigInt%":typeof BigInt>"u"?j:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?j:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?j:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?j:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Zb,"%eval%":eval,"%EvalError%":Hb,"%Float16Array%":typeof Float16Array>"u"?j:Float16Array,"%Float32Array%":typeof Float32Array>"u"?j:Float32Array,"%Float64Array%":typeof Float64Array>"u"?j:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?j:FinalizationRegistry,"%Function%":Tp,"%GeneratorFunction%":_r,"%Int8Array%":typeof Int8Array>"u"?j:Int8Array,"%Int16Array%":typeof Int16Array>"u"?j:Int16Array,"%Int32Array%":typeof Int32Array>"u"?j:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":vr&&Se?Se(Se([][Symbol.iterator]())):j,"%JSON%":typeof JSON=="object"?JSON:j,"%Map%":typeof Map>"u"?j:Map,"%MapIteratorPrototype%":typeof Map>"u"||!vr||!Se?j:Se(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Fb,"%Object.getOwnPropertyDescriptor%":Ki,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?j:Promise,"%Proxy%":typeof Proxy>"u"?j:Proxy,"%RangeError%":Vb,"%ReferenceError%":jb,"%Reflect%":typeof Reflect>"u"?j:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?j:Set,"%SetIteratorPrototype%":typeof Set>"u"||!vr||!Se?j:Se(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?j:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":vr&&Se?Se(""[Symbol.iterator]()):j,"%Symbol%":vr?Symbol:j,"%SyntaxError%":Jr,"%ThrowTypeError%":ew,"%TypedArray%":rw,"%TypeError%":Pr,"%Uint8Array%":typeof Uint8Array>"u"?j:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?j:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?j:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?j:Uint32Array,"%URIError%":Bb,"%WeakMap%":typeof WeakMap>"u"?j:WeakMap,"%WeakRef%":typeof WeakRef>"u"?j:WeakRef,"%WeakSet%":typeof WeakSet>"u"?j:WeakSet,"%Function.prototype.call%":js,"%Function.prototype.apply%":Cp,"%Object.defineProperty%":Qb,"%Object.getPrototypeOf%":tw,"%Math.abs%":Gb,"%Math.floor%":Wb,"%Math.max%":qb,"%Math.min%":Yb,"%Math.pow%":Kb,"%Math.round%":Jb,"%Math.sign%":Xb,"%Reflect.getPrototypeOf%":nw};if(Se)try{null.error}catch(n){var iw=Se(Se(n));er["%Error.prototype%"]=iw}var sw=function n(e){var t;if(e==="%AsyncFunction%")t=cl("async function () {}");else if(e==="%GeneratorFunction%")t=cl("function* () {}");else if(e==="%AsyncGeneratorFunction%")t=cl("async function* () {}");else if(e==="%AsyncGenerator%"){var r=n("%AsyncGeneratorFunction%");r&&(t=r.prototype)}else if(e==="%AsyncIteratorPrototype%"){var i=n("%AsyncGenerator%");i&&Se&&(t=Se(i.prototype))}return er[e]=t,t},Zh={__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"]},Bs=Vs,Go=Kt,ow=Bs.call(js,Array.prototype.concat),aw=Bs.call(Cp,Array.prototype.splice),Hh=Bs.call(js,String.prototype.replace),Wo=Bs.call(js,String.prototype.slice),lw=Bs.call(js,RegExp.prototype.exec),cw=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,uw=/\\(\\)?/g,hw=function(e){var t=Wo(e,0,1),r=Wo(e,-1);if(t==="%"&&r!=="%")throw new Jr("invalid intrinsic syntax, expected closing `%`");if(r==="%"&&t!=="%")throw new Jr("invalid intrinsic syntax, expected opening `%`");var i=[];return Hh(e,cw,function(s,o,a,c){i[i.length]=a?Hh(c,uw,"$1"):o||s}),i},dw=function(e,t){var r=e,i;if(Go(Zh,r)&&(i=Zh[r],r="%"+i[0]+"%"),Go(er,r)){var s=er[r];if(s===_r&&(s=sw(r)),typeof s>"u"&&!t)throw new Pr("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:i,name:r,value:s}}throw new Jr("intrinsic "+e+" does not exist!")},st=function(e,t){if(typeof e!="string"||e.length===0)throw new Pr("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof t!="boolean")throw new Pr('"allowMissing" argument must be a boolean');if(lw(/^%?[^%]*%?$/,e)===null)throw new Jr("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var r=hw(e),i=r.length>0?r[0]:"",s=dw("%"+i+"%",t),o=s.name,a=s.value,c=!1,u=s.alias;u&&(i=u[0],aw(r,ow([0,1],u)));for(var d=1,f=!0;d<r.length;d+=1){var v=r[d],y=Wo(v,0,1),A=Wo(v,-1);if((y==='"'||y==="'"||y==="`"||A==='"'||A==="'"||A==="`")&&y!==A)throw new Jr("property names with quotes must have matching quotes");if((v==="constructor"||!f)&&(c=!0),i+="."+v,o="%"+i+"%",Go(er,o))a=er[o];else if(a!=null){if(!(v in a)){if(!t)throw new Pr("base intrinsic for "+e+" exists, but the property is not available.");return}if(Ki&&d+1>=r.length){var k=Ki(a,v);f=!!k,f&&"get"in k&&!("originalValue"in k.get)?a=k.get:a=a[v]}else f=Go(a,v),a=a[v];f&&!c&&(er[o]=a)}}return a},hl,Vh;function bn(){if(Vh)return hl;Vh=1;var n=st,e=Ia,t=e([n("%String.prototype.indexOf%")]);return hl=function(i,s){var o=n(i,!!s);return typeof o=="function"&&t(i,".prototype.")>-1?e([o]):o},hl}var dl,jh;function su(){if(jh)return dl;jh=1;var n=st,e=n("%Array%"),t=!e.isArray&&bn()("Object.prototype.toString");return dl=e.isArray||function(i){return t(i)==="[object Array]"},dl}var fw=Ca,Bh=Hs,Ip=fw.hasArrayLengthDefineBug(),pw=Ip&&su(),gw=bn(),mw=gw("Object.prototype.propertyIsEnumerable"),ou=function(e,t,r,i,s,o){if(!Bh){if(!e(o)||!o["[[Configurable]]"]||!o["[[Writable]]"]||s in i&&mw(i,s)!==!!o["[[Enumerable]]"])return!1;var a=o["[[Value]]"];return i[s]=a,t(i[s],a)}return Ip&&s==="length"&&"[[Value]]"in o&&pw(i)&&i.length!==o["[[Value]]"]?(i.length=o["[[Value]]"],i.length===o["[[Value]]"]):(Bh(i,s,r(o)),!0)},yw=G,_i=Kt,vw={__proto__:null,"[[Configurable]]":!0,"[[Enumerable]]":!0,"[[Get]]":!0,"[[Set]]":!0,"[[Value]]":!0,"[[Writable]]":!0},oi=function(e){if(!e||typeof e!="object")return!1;for(var t in e)if(_i(e,t)&&!vw[t])return!1;var r=_i(e,"[[Value]]")||_i(e,"[[Writable]]"),i=_i(e,"[[Get]]")||_i(e,"[[Set]]");if(r&&i)throw new yw("Property Descriptors may not be both accessor and data descriptors");return!0},Pp=function(e){if(typeof e>"u")return e;var t={};return"[[Value]]"in e&&(t.value=e["[[Value]]"]),"[[Writable]]"in e&&(t.writable=!!e["[[Writable]]"]),"[[Get]]"in e&&(t.get=e["[[Get]]"]),"[[Set]]"in e&&(t.set=e["[[Set]]"]),"[[Enumerable]]"in e&&(t.enumerable=!!e["[[Enumerable]]"]),"[[Configurable]]"in e&&(t.configurable=!!e["[[Configurable]]"]),t},bw=G,ww=oi,_w=Pp,Rp=function(e){if(typeof e<"u"&&!ww(e))throw new bw("Assertion failed: `Desc` must be a Property Descriptor");return _w(e)},Sw=G,Gh=Kt,kw=oi,Dp=function(e){if(typeof e>"u")return!1;if(!kw(e))throw new Sw("Assertion failed: `Desc` must be a Property Descriptor");return!(!Gh(e,"[[Value]]")&&!Gh(e,"[[Writable]]"))},ai=function(e){return typeof e=="string"||typeof e=="symbol"},Wh=tu,Op=function(e,t){return e===t?e===0?1/e===1/t:!0:Wh(e)&&Wh(t)},qh=G,Ew=Yt,$w=ou,Aw=Rp,xw=Dp,Tw=ai,Cw=Op,au=function(e,t,r){if(!Ew(e))throw new qh("Assertion failed: Type(O) is not Object");if(!Tw(t))throw new qh("Assertion failed: P is not a Property Key");var i={"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Value]]":r,"[[Writable]]":!0};return $w(xw,Cw,Aw,e,t,i)},zp=Function.prototype.toString,Tr=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,Xl,zo;if(typeof Tr=="function"&&typeof Object.defineProperty=="function")try{Xl=Object.defineProperty({},"length",{get:function(){throw zo}}),zo={},Tr(function(){throw 42},null,Xl)}catch(n){n!==zo&&(Tr=null)}else Tr=null;var Iw=/^\s*class\b/,Ql=function(e){try{var t=zp.call(e);return Iw.test(t)}catch{return!1}},fl=function(e){try{return Ql(e)?!1:(zp.call(e),!0)}catch{return!1}},Lo=Object.prototype.toString,Pw="[object Object]",Rw="[object Function]",Dw="[object GeneratorFunction]",Ow="[object HTMLAllCollection]",zw="[object HTML document.all class]",Lw="[object HTMLCollection]",Mw=typeof Symbol=="function"&&!!Symbol.toStringTag,Nw=!(0 in[,]),ec=function(){return!1};if(typeof document=="object"){var Uw=document.all;Lo.call(Uw)===Lo.call(document.all)&&(ec=function(e){if((Nw||!e)&&(typeof e>"u"||typeof e=="object"))try{var t=Lo.call(e);return(t===Ow||t===zw||t===Lw||t===Pw)&&e("")==null}catch{}return!1})}var Lp=Tr?function(e){if(ec(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;try{Tr(e,null,Xl)}catch(t){if(t!==zo)return!1}return!Ql(e)&&fl(e)}:function(e){if(ec(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;if(Mw)return fl(e);if(Ql(e))return!1;var t=Lo.call(e);return t!==Rw&&t!==Dw&&!/^\[object HTML/.test(t)?!1:fl(e)},Fw=Lp,Zw=function(e){return!!e},bt=Kt,ho=G,Hw=Yt,Yh=Fw,pl=Zw,Vw=function(e){if(!Hw(e))throw new ho("ToPropertyDescriptor requires an object");var t={};if(bt(e,"enumerable")&&(t["[[Enumerable]]"]=pl(e.enumerable)),bt(e,"configurable")&&(t["[[Configurable]]"]=pl(e.configurable)),bt(e,"value")&&(t["[[Value]]"]=e.value),bt(e,"writable")&&(t["[[Writable]]"]=pl(e.writable)),bt(e,"get")){var r=e.get;if(typeof r<"u"&&!Yh(r))throw new ho("getter must be a function");t["[[Get]]"]=r}if(bt(e,"set")){var i=e.set;if(typeof i<"u"&&!Yh(i))throw new ho("setter must be a function");t["[[Set]]"]=i}if((bt(t,"[[Get]]")||bt(t,"[[Set]]"))&&(bt(t,"[[Value]]")||bt(t,"[[Writable]]")))throw new ho("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute");return t},gl=G,jw=Yt,Kh=oi,Bw=ou,Gw=Rp,Ww=Dp,qw=ai,Yw=Op,Kw=Vw,Jw=function(e,t,r){if(!jw(e))throw new gl("Assertion failed: Type(O) is not Object");if(!qw(t))throw new gl("Assertion failed: P is not a Property Key");var i=Kh(r)?r:Kw(r);if(!Kh(i))throw new gl("Assertion failed: Desc is not a valid Property Descriptor");return Bw(Ww,Yw,Gw,e,t,i)},Jh=G,Xw=Yt,Qw=Jw,e_=ai,t_=function(e,t,r){if(!Xw(e))throw new Jh("Assertion failed: Type(O) is not Object");if(!e_(t))throw new Jh("Assertion failed: P is not a Property Key");var i={"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Value]]":r,"[[Writable]]":!0};return Qw(e,t,i)},n_=typeof Reflect<"u"&&Reflect.setPrototypeOf||null,r_=Qc,i_=r_.setPrototypeOf||null,s_=Ia,Xh=ii,o_=G,Mp={};try{Mp.__proto__=null}catch(n){if(!n||typeof n!="object"||!("code"in n)||n.code!=="ERR_PROTO_ACCESS")throw n}var a_=!("toString"in Mp),ml=Xh&&Xh(Object.prototype,"__proto__"),l_=a_&&(!!ml&&typeof ml.set=="function"&&s_([ml.set])||function(e,t){if(e==null)throw new o_("set Object.prototype.__proto__ called on null or undefined");return e.__proto__=t,t}),Qh=n_,c_=i_,ed=l_,u_=G,h_=Qh?function(e,t){if(Qh(e,t))return e;throw new u_("Reflect.setPrototypeOf: failed to set [[Prototype]]")}:c_||(ed?function(e,t){return ed(e,t),e}:null),td=G,d_=Yt,nd=xp,f_=function(e){if(!d_(e))throw new td("Assertion failed: O must be an Object");if(!nd)throw new td("This environment does not support fetching prototypes.");return nd(e)},p_=G,g_=h_,m_=Yt,y_=f_,v_=function(e,t){if(t!==null&&!m_(t))throw new p_("Assertion failed: V must be Object or Null");try{g_(e,t)}catch{return!1}return y_(e)===t},yl=au,rd=t_,Np=v_,b_=Ca(),lu=_p;function Gs(n,e,t){var r=new lu(t);return Np(r,Mo),delete r.constructor,rd(r,"error",n),rd(r,"suppressed",e),r}b_&&Object.defineProperty(Gs,"prototype",{writable:!1});var Mo=Gs.prototype;if(!yl(Mo,"constructor",Gs)||!yl(Mo,"message","")||!yl(Mo,"name","SuppressedError"))throw new lu("unable to install SuppressedError.prototype properties; please report this!");Np(Gs.prototype,lu.prototype);var w_=Gs,__=w_,Up=function(){return typeof SuppressedError=="function"?SuppressedError:__},S_=ar,id=Xc(),k_=Up,E_=function(){var e=k_();return S_(id,{SuppressedError:e},{SuppressedError:function(){return id.SuppressedError!==e}}),e};E_();var $_=G,A_=oi,x_=Pp,T_=function(e){if(typeof e<"u"&&!A_(e))throw new $_("Assertion failed: `Desc` must be a Property Descriptor");return x_(e)},C_=G,sd=Kt,I_=oi,P_=function(e){if(typeof e>"u")return!1;if(!I_(e))throw new C_("Assertion failed: `Desc` must be a Property Descriptor");return!(!sd(e,"[[Value]]")&&!sd(e,"[[Writable]]"))},od=tu,R_=function(e,t){return e===t?e===0?1/e===1/t:!0:od(e)&&od(t)},li=Lp,D_=function(e){return!!e},wt=Kt,fo=G,O_=Yt,ad=li,vl=D_,z_=function(e){if(!O_(e))throw new fo("ToPropertyDescriptor requires an object");var t={};if(wt(e,"enumerable")&&(t["[[Enumerable]]"]=vl(e.enumerable)),wt(e,"configurable")&&(t["[[Configurable]]"]=vl(e.configurable)),wt(e,"value")&&(t["[[Value]]"]=e.value),wt(e,"writable")&&(t["[[Writable]]"]=vl(e.writable)),wt(e,"get")){var r=e.get;if(typeof r<"u"&&!ad(r))throw new fo("getter must be a function");t["[[Get]]"]=r}if(wt(e,"set")){var i=e.set;if(typeof i<"u"&&!ad(i))throw new fo("setter must be a function");t["[[Set]]"]=i}if((wt(t,"[[Get]]")||wt(t,"[[Set]]"))&&(wt(t,"[[Value]]")||wt(t,"[[Writable]]")))throw new fo("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute");return t},bl=G,L_=Yt,ld=oi,M_=ou,N_=T_,U_=P_,F_=ai,Z_=R_,H_=z_,Ws=function(e,t,r){if(!L_(e))throw new bl("Assertion failed: Type(O) is not Object");if(!F_(t))throw new bl("Assertion failed: P is not a Property Key");var i=ld(r)?r:H_(r);if(!ld(i))throw new bl("Assertion failed: Desc is not a valid Property Descriptor");return M_(U_,Z_,N_,e,t,i)},V_=si(),j_=V_?Symbol.dispose||Symbol("Symbol.dispose"):null,B_=si,G_=j_,cu=function(){return B_()&&Symbol.dispose||G_},W_=nu,q_=Ws,Y_=cu,K_=function(){var e=Y_();return W_()&&q_(Symbol,"dispose",{"[[Configurable]]":!1,"[[Enumerable]]":!1,"[[Writable]]":!1,"[[Value]]":e}),e},J_=si(),X_=J_?Symbol.asyncDispose||Symbol("Symbol.asyncDispose"):null,Q_=si,eS=X_,uu=function(){return Q_()&&Symbol.asyncDispose||eS},tS=nu,nS=Ws,rS=uu,iS=function(){var e=rS();return tS()&&nS(Symbol,"asyncDispose",{"[[Configurable]]":!1,"[[Enumerable]]":!1,"[[Writable]]":!1,"[[Value]]":e}),e},sS=su(),oS=st,aS=bn(),lS=G,cS=sS,uS=oS("%Reflect.apply%",!0)||aS("Function.prototype.apply"),Pa=function(e,t){var r=arguments.length>2?arguments[2]:[];if(!cS(r))throw new lS("Assertion failed: optional `argumentsList`, if provided, must be a List");return uS(e,t,r)};const hS={},dS=Object.freeze(Object.defineProperty({__proto__:null,default:hS},Symbol.toStringTag,{value:"Module"})),fS=Mv(dS);var hu=typeof Map=="function"&&Map.prototype,wl=Object.getOwnPropertyDescriptor&&hu?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,qo=hu&&wl&&typeof wl.get=="function"?wl.get:null,cd=hu&&Map.prototype.forEach,du=typeof Set=="function"&&Set.prototype,_l=Object.getOwnPropertyDescriptor&&du?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,Yo=du&&_l&&typeof _l.get=="function"?_l.get:null,ud=du&&Set.prototype.forEach,pS=typeof WeakMap=="function"&&WeakMap.prototype,ji=pS?WeakMap.prototype.has:null,gS=typeof WeakSet=="function"&&WeakSet.prototype,Bi=gS?WeakSet.prototype.has:null,mS=typeof WeakRef=="function"&&WeakRef.prototype,hd=mS?WeakRef.prototype.deref:null,yS=Boolean.prototype.valueOf,vS=Object.prototype.toString,bS=Function.prototype.toString,wS=String.prototype.match,fu=String.prototype.slice,hn=String.prototype.replace,_S=String.prototype.toUpperCase,dd=String.prototype.toLowerCase,Fp=RegExp.prototype.test,fd=Array.prototype.concat,Tt=Array.prototype.join,SS=Array.prototype.slice,pd=Math.floor,tc=typeof BigInt=="function"?BigInt.prototype.valueOf:null,Sl=Object.getOwnPropertySymbols,nc=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,Xr=typeof Symbol=="function"&&typeof Symbol.iterator=="object",Gi=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===Xr||!0)?Symbol.toStringTag:null,Zp=Object.prototype.propertyIsEnumerable,gd=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(n){return n.__proto__}:null);function md(n,e){if(n===1/0||n===-1/0||n!==n||n&&n>-1e3&&n<1e3||Fp.call(/e/,e))return e;var t=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof n=="number"){var r=n<0?-pd(-n):pd(n);if(r!==n){var i=String(r),s=fu.call(e,i.length+1);return hn.call(i,t,"$&_")+"."+hn.call(hn.call(s,/([0-9]{3})/g,"$&_"),/_$/,"")}}return hn.call(e,t,"$&_")}var rc=fS,yd=rc.custom,vd=jp(yd)?yd:null,Hp={__proto__:null,double:'"',single:"'"},kS={__proto__:null,double:/(["\\])/g,single:/(['\\])/g},ci=function n(e,t,r,i){var s=t||{};if(Lt(s,"quoteStyle")&&!Lt(Hp,s.quoteStyle))throw new TypeError('option "quoteStyle" must be "single" or "double"');if(Lt(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=Lt(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(Lt(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(Lt(s,"numericSeparator")&&typeof s.numericSeparator!="boolean")throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var a=s.numericSeparator;if(typeof e>"u")return"undefined";if(e===null)return"null";if(typeof e=="boolean")return e?"true":"false";if(typeof e=="string")return Gp(e,s);if(typeof e=="number"){if(e===0)return 1/0/e>0?"0":"-0";var c=String(e);return a?md(e,c):c}if(typeof e=="bigint"){var u=String(e)+"n";return a?md(e,u):u}var d=typeof s.depth>"u"?5:s.depth;if(typeof r>"u"&&(r=0),r>=d&&d>0&&typeof e=="object")return ic(e)?"[Array]":"[Object]";var f=ZS(s,r);if(typeof i>"u")i=[];else if(Bp(i,e)>=0)return"[Circular]";function v(mt,Xt,qa){if(Xt&&(i=SS.call(i),i.push(Xt)),qa){var no={depth:s.depth};return Lt(s,"quoteStyle")&&(no.quoteStyle=s.quoteStyle),n(mt,no,r+1,i)}return n(mt,s,r+1,i)}if(typeof e=="function"&&!bd(e)){var y=RS(e),A=po(e,v);return"[Function"+(y?": "+y:" (anonymous)")+"]"+(A.length>0?" { "+Tt.call(A,", ")+" }":"")}if(jp(e)){var k=Xr?hn.call(String(e),/^(Symbol\(.*\))_[^)]*$/,"$1"):nc.call(e);return typeof e=="object"&&!Xr?Si(k):k}if(NS(e)){for(var I="<"+dd.call(String(e.nodeName)),B=e.attributes||[],P=0;P<B.length;P++)I+=" "+B[P].name+"="+Vp(ES(B[P].value),"double",s);return I+=">",e.childNodes&&e.childNodes.length&&(I+="..."),I+="</"+dd.call(String(e.nodeName))+">",I}if(ic(e)){if(e.length===0)return"[]";var le=po(e,v);return f&&!FS(le)?"["+sc(le,f)+"]":"[ "+Tt.call(le,", ")+" ]"}if(AS(e)){var M=po(e,v);return!("cause"in Error.prototype)&&"cause"in e&&!Zp.call(e,"cause")?"{ ["+String(e)+"] "+Tt.call(fd.call("[cause]: "+v(e.cause),M),", ")+" }":M.length===0?"["+String(e)+"]":"{ ["+String(e)+"] "+Tt.call(M,", ")+" }"}if(typeof e=="object"&&o){if(vd&&typeof e[vd]=="function"&&rc)return rc(e,{depth:d-r});if(o!=="symbol"&&typeof e.inspect=="function")return e.inspect()}if(DS(e)){var Z=[];return cd&&cd.call(e,function(mt,Xt){Z.push(v(Xt,e,!0)+" => "+v(mt,e))}),wd("Map",qo.call(e),Z,f)}if(LS(e)){var U=[];return ud&&ud.call(e,function(mt){U.push(v(mt,e))}),wd("Set",Yo.call(e),U,f)}if(OS(e))return kl("WeakMap");if(MS(e))return kl("WeakSet");if(zS(e))return kl("WeakRef");if(TS(e))return Si(v(Number(e)));if(IS(e))return Si(v(tc.call(e)));if(CS(e))return Si(yS.call(e));if(xS(e))return Si(v(String(e)));if(typeof window<"u"&&e===window)return"{ [object Window] }";if(typeof globalThis<"u"&&e===globalThis||typeof In<"u"&&e===In)return"{ [object globalThis] }";if(!$S(e)&&!bd(e)){var ge=po(e,v),ce=gd?gd(e)===Object.prototype:e instanceof Object||e.constructor===Object,yi=e instanceof Object?"":"null prototype",to=!ce&&Gi&&Object(e)===e&&Gi in e?fu.call(wn(e),8,-1):yi?"Object":"",$e=ce||typeof e.constructor!="function"?"":e.constructor.name?e.constructor.name+" ":"",kn=$e+(to||yi?"["+Tt.call(fd.call([],to||[],yi||[]),": ")+"] ":"");return ge.length===0?kn+"{}":f?kn+"{"+sc(ge,f)+"}":kn+"{ "+Tt.call(ge,", ")+" }"}return String(e)};function Vp(n,e,t){var r=t.quoteStyle||e,i=Hp[r];return i+n+i}function ES(n){return hn.call(String(n),/"/g,""")}function lr(n){return!Gi||!(typeof n=="object"&&(Gi in n||typeof n[Gi]<"u"))}function ic(n){return wn(n)==="[object Array]"&&lr(n)}function $S(n){return wn(n)==="[object Date]"&&lr(n)}function bd(n){return wn(n)==="[object RegExp]"&&lr(n)}function AS(n){return wn(n)==="[object Error]"&&lr(n)}function xS(n){return wn(n)==="[object String]"&&lr(n)}function TS(n){return wn(n)==="[object Number]"&&lr(n)}function CS(n){return wn(n)==="[object Boolean]"&&lr(n)}function jp(n){if(Xr)return n&&typeof n=="object"&&n instanceof Symbol;if(typeof n=="symbol")return!0;if(!n||typeof n!="object"||!nc)return!1;try{return nc.call(n),!0}catch{}return!1}function IS(n){if(!n||typeof n!="object"||!tc)return!1;try{return tc.call(n),!0}catch{}return!1}var PS=Object.prototype.hasOwnProperty||function(n){return n in this};function Lt(n,e){return PS.call(n,e)}function wn(n){return vS.call(n)}function RS(n){if(n.name)return n.name;var e=wS.call(bS.call(n),/^function\s*([\w$]+)/);return e?e[1]:null}function Bp(n,e){if(n.indexOf)return n.indexOf(e);for(var t=0,r=n.length;t<r;t++)if(n[t]===e)return t;return-1}function DS(n){if(!qo||!n||typeof n!="object")return!1;try{qo.call(n);try{Yo.call(n)}catch{return!0}return n instanceof Map}catch{}return!1}function OS(n){if(!ji||!n||typeof n!="object")return!1;try{ji.call(n,ji);try{Bi.call(n,Bi)}catch{return!0}return n instanceof WeakMap}catch{}return!1}function zS(n){if(!hd||!n||typeof n!="object")return!1;try{return hd.call(n),!0}catch{}return!1}function LS(n){if(!Yo||!n||typeof n!="object")return!1;try{Yo.call(n);try{qo.call(n)}catch{return!0}return n instanceof Set}catch{}return!1}function MS(n){if(!Bi||!n||typeof n!="object")return!1;try{Bi.call(n,Bi);try{ji.call(n,ji)}catch{return!0}return n instanceof WeakSet}catch{}return!1}function NS(n){return!n||typeof n!="object"?!1:typeof HTMLElement<"u"&&n instanceof HTMLElement?!0:typeof n.nodeName=="string"&&typeof n.getAttribute=="function"}function Gp(n,e){if(n.length>e.maxStringLength){var t=n.length-e.maxStringLength,r="... "+t+" more character"+(t>1?"s":"");return Gp(fu.call(n,0,e.maxStringLength),e)+r}var i=kS[e.quoteStyle||"single"];i.lastIndex=0;var s=hn.call(hn.call(n,i,"\\$1"),/[\x00-\x1f]/g,US);return Vp(s,"single",e)}function US(n){var e=n.charCodeAt(0),t={8:"b",9:"t",10:"n",12:"f",13:"r"}[e];return t?"\\"+t:"\\x"+(e<16?"0":"")+_S.call(e.toString(16))}function Si(n){return"Object("+n+")"}function kl(n){return n+" { ? }"}function wd(n,e,t,r){var i=r?sc(t,r):Tt.call(t,", ");return n+" ("+e+") {"+i+"}"}function FS(n){for(var e=0;e<n.length;e++)if(Bp(n[e],`
|
|
2
|
+
`)>=0)return!1;return!0}function ZS(n,e){var t;if(n.indent===" ")t=" ";else if(typeof n.indent=="number"&&n.indent>0)t=Tt.call(Array(n.indent+1)," ");else return null;return{base:t,prev:Tt.call(Array(e+1),t)}}function sc(n,e){if(n.length===0)return"";var t=`
|
|
3
|
+
`+e.prev+e.base;return t+Tt.call(n,","+t)+`
|
|
4
|
+
`+e.prev}function po(n,e){var t=ic(n),r=[];if(t){r.length=n.length;for(var i=0;i<n.length;i++)r[i]=Lt(n,i)?e(n[i],n):""}var s=typeof Sl=="function"?Sl(n):[],o;if(Xr){o={};for(var a=0;a<s.length;a++)o["$"+s[a]]=s[a]}for(var c in n)Lt(n,c)&&(t&&String(Number(c))===c&&c<n.length||Xr&&o["$"+c]instanceof Symbol||(Fp.call(/[^\w$]/,c)?r.push(e(c,n)+": "+e(n[c],n)):r.push(c+": "+e(n[c],n))));if(typeof Sl=="function")for(var u=0;u<s.length;u++)Zp.call(n,s[u])&&r.push("["+e(s[u])+"]: "+e(n[s[u]],n));return r}var HS=ci,VS=G,Ra=function(n,e,t){for(var r=n,i;(i=r.next)!=null;r=i)if(i.key===e)return r.next=i.next,t||(i.next=n.next,n.next=i),i},jS=function(n,e){if(n){var t=Ra(n,e);return t&&t.value}},BS=function(n,e,t){var r=Ra(n,e);r?r.value=t:n.next={key:e,next:n.next,value:t}},GS=function(n,e){return n?!!Ra(n,e):!1},WS=function(n,e){if(n)return Ra(n,e,!0)},qS=function(){var e,t={assert:function(r){if(!t.has(r))throw new VS("Side channel does not contain "+HS(r))},delete:function(r){var i=e&&e.next,s=WS(e,r);return s&&i&&i===s&&(e=void 0),!!s},get:function(r){return jS(e,r)},has:function(r){return GS(e,r)},set:function(r,i){e||(e={next:void 0}),BS(e,r,i)}};return t},YS=st,qs=bn(),KS=ci,JS=G,_d=YS("%Map%",!0),XS=qs("Map.prototype.get",!0),QS=qs("Map.prototype.set",!0),ek=qs("Map.prototype.has",!0),tk=qs("Map.prototype.delete",!0),nk=qs("Map.prototype.size",!0),Wp=!!_d&&function(){var e,t={assert:function(r){if(!t.has(r))throw new JS("Side channel does not contain "+KS(r))},delete:function(r){if(e){var i=tk(e,r);return nk(e)===0&&(e=void 0),i}return!1},get:function(r){if(e)return XS(e,r)},has:function(r){return e?ek(e,r):!1},set:function(r,i){e||(e=new _d),QS(e,r,i)}};return t},rk=st,Da=bn(),ik=ci,go=Wp,sk=G,br=rk("%WeakMap%",!0),ok=Da("WeakMap.prototype.get",!0),ak=Da("WeakMap.prototype.set",!0),lk=Da("WeakMap.prototype.has",!0),ck=Da("WeakMap.prototype.delete",!0),uk=br?function(){var e,t,r={assert:function(i){if(!r.has(i))throw new sk("Side channel does not contain "+ik(i))},delete:function(i){if(br&&i&&(typeof i=="object"||typeof i=="function")){if(e)return ck(e,i)}else if(go&&t)return t.delete(i);return!1},get:function(i){return br&&i&&(typeof i=="object"||typeof i=="function")&&e?ok(e,i):t&&t.get(i)},has:function(i){return br&&i&&(typeof i=="object"||typeof i=="function")&&e?lk(e,i):!!t&&t.has(i)},set:function(i,s){br&&i&&(typeof i=="object"||typeof i=="function")?(e||(e=new br),ak(e,i,s)):go&&(t||(t=go()),t.set(i,s))}};return r}:go,hk=G,dk=ci,fk=qS,pk=Wp,gk=uk,mk=gk||pk||fk,yk=function(){var e,t={assert:function(r){if(!t.has(r))throw new hk("Side channel does not contain "+dk(r))},delete:function(r){return!!e&&e.delete(r)},get:function(r){return e&&e.get(r)},has:function(r){return!!e&&e.has(r)},set:function(r,i){e||(e=mk()),e.set(r,i)}};return t},vk=Kt,ki=yk(),Dt=G,pu={assert:function(n,e){if(!n||typeof n!="object"&&typeof n!="function")throw new Dt("`O` is not an object");if(typeof e!="string")throw new Dt("`slot` must be a string");if(ki.assert(n),!pu.has(n,e))throw new Dt("`"+e+"` is not present on `O`")},get:function(n,e){if(!n||typeof n!="object"&&typeof n!="function")throw new Dt("`O` is not an object");if(typeof e!="string")throw new Dt("`slot` must be a string");var t=ki.get(n);return t&&t["$"+e]},has:function(n,e){if(!n||typeof n!="object"&&typeof n!="function")throw new Dt("`O` is not an object");if(typeof e!="string")throw new Dt("`slot` must be a string");var t=ki.get(n);return!!t&&vk(t,"$"+e)},set:function(n,e,t){if(!n||typeof n!="object"&&typeof n!="function")throw new Dt("`O` is not an object");if(typeof e!="string")throw new Dt("`slot` must be a string");var r=ki.get(n);r||(r={},ki.set(n,r)),r["$"+e]=t}};Object.freeze&&Object.freeze(pu);var gu=pu,qp=qt,dn=gu,Ys=function n(e,t){if(!(this instanceof n))return new n(e,t);if(e!=="normal"&&e!=="break"&&e!=="continue"&&e!=="return"&&e!=="throw")throw new qp('Assertion failed: `type` must be one of "normal", "break", "continue", "return", or "throw"');dn.set(this,"[[Type]]",e),dn.set(this,"[[Value]]",t)};Ys.prototype.type=function(){return dn.get(this,"[[Type]]")};Ys.prototype.value=function(){return dn.get(this,"[[Value]]")};Ys.prototype["?"]=function(){var e=dn.get(this,"[[Type]]"),t=dn.get(this,"[[Value]]");if(e==="throw")throw t;return t};Ys.prototype["!"]=function(){var e=dn.get(this,"[[Type]]");if(e!=="normal")throw new qp('Assertion failed: Completion Record is not of type "normal"');return dn.get(this,"[[Value]]")};var mu=Ys,bk=mu,yu=function(e){return new bk("normal",e)},El,Sd;function wk(){if(Sd)return El;Sd=1;var n=si;return El=function(){return n()&&!!Symbol.toStringTag},El}var _k=st,kd=_k("%Object.defineProperty%",!0),Sk=wk()(),kk=Kt,Ek=G,mo=Sk?Symbol.toStringTag:null,Yp=function(e,t){var r=arguments.length>2&&!!arguments[2]&&arguments[2].force,i=arguments.length>2&&!!arguments[2]&&arguments[2].nonConfigurable;if(typeof r<"u"&&typeof r!="boolean"||typeof i<"u"&&typeof i!="boolean")throw new Ek("if provided, the `overrideIfSet` and `nonConfigurable` options must be booleans");mo&&(r||!kk(e,mo))&&(kd?kd(e,mo,{configurable:!i,enumerable:!1,value:t,writable:!1}):e[mo]=t)},Kp={exports:{}},$k=st,Ed=fp,Ak=Ca(),$d=ii,Ad=G,xk=$k("%Math.floor%"),Tk=function(e,t){if(typeof e!="function")throw new Ad("`fn` is not a function");if(typeof t!="number"||t<0||t>4294967295||xk(t)!==t)throw new Ad("`length` must be a positive 32-bit integer");var r=arguments.length>2&&!!arguments[2],i=!0,s=!0;if("length"in e&&$d){var o=$d(e,"length");o&&!o.configurable&&(i=!1),o&&!o.writable&&(s=!1)}return(i||s||!r)&&(Ak?Ed(e,"length",t,!0,!0):Ed(e,"length",t)),e},Ck=Vs,Ik=iu,Pk=Ep,Rk=function(){return Pk(Ck,Ik,arguments)};(function(n){var e=Tk,t=Hs,r=Ia,i=Rk;n.exports=function(o){var a=r(arguments),c=1+o.length-(arguments.length-1);return e(a,c>0?c:0,!0)},t?t(n.exports,"apply",{value:i}):n.exports.apply=i})(Kp);var vu=Kp.exports,Dk=function(e,t){for(var r=0;r<e.length;r+=1)if(!t(e[r],r,e))return!1;return!0},Ok=Object,zk=function(e){return e&&typeof e=="object"&&(typeof e["[[ResourceValue]]"]>"u"||Ok(e["[[ResourceValue]]"])===e["[[ResourceValue]]"])&&(e["[[Hint]]"]==="SYNC-DISPOSE"||e["[[Hint]]"]==="ASYNC-DISPOSE")&&(typeof e["[[DisposeMethod]]"]=="function"||typeof e["[[DisposeMethod]]"]>"u")},Lk=Kt,Mk=su(),Nk=Dk,Uk=zk,Fk=function(e){return e&&typeof e=="object"&&Lk(e,"[[DisposableResourceStack]]")&&Mk(e["[[DisposableResourceStack]]"])&&(e["[[DisposableResourceStack]]"].length===0||Nk(e["[[DisposableResourceStack]]"],Uk))},Zk=Yt,Hk=function(e){if(e===null)return"Null";if(typeof e>"u")return"Undefined";if(Zk(e))return"Object";if(typeof e=="number")return"Number";if(typeof e=="boolean")return"Boolean";if(typeof e=="string")return"String"},Vk=Hk,bu=function(e){return typeof e=="symbol"?"Symbol":typeof e=="bigint"?"BigInt":Vk(e)},jk=G,Bk=ci,Gk=ai,Wk=function(e,t){if(!Gk(t))throw new jk("Assertion failed: P is not a Property Key, got "+Bk(t));return e[t]},xd=G,qk=Wk,Yk=li,Kk=ai,Td=ci,Jk=function(e,t){if(!Kk(t))throw new xd("Assertion failed: P is not a Property Key");var r=qk(e,t);if(r!=null){if(!Yk(r))throw new xd(Td(t)+" is not a function: "+Td(r));return r}},oc={exports:{}},Xk=st,Qk=Xk,Cd=Qk("%Reflect.construct%",!0),Ko=Ws;try{Ko({},"",{"[[Get]]":function(){}})}catch{Ko=null}if(Ko&&Cd){var Id={},Pd={};Ko(Pd,"length",{"[[Get]]":function(){throw Id},"[[Enumerable]]":!0}),oc.exports=function(e){try{Cd(e,Pd)}catch(t){return t===Id}}}else oc.exports=function(e){return typeof e=="function"&&!!e.prototype};var eE=oc.exports,$l=G,Rd=li,tE=eE,nE=function(e){if(!tE(e))throw new $l("C must be a constructor");var t={"[[Resolve]]":void 0,"[[Reject]]":void 0},r=new e(function(i,s){if(typeof t["[[Resolve]]"]<"u"||typeof t["[[Reject]]"]<"u")throw new $l("executor has already been called");t["[[Resolve]]"]=i,t["[[Reject]]"]=s});if(!Rd(t["[[Resolve]]"])||!Rd(t["[[Reject]]"]))throw new $l("executor must provide valid resolve and reject functions");return{"[[Promise]]":r,"[[Resolve]]":t["[[Resolve]]"],"[[Reject]]":t["[[Reject]]"]}},Dd=qt,rE=G,Al=Pa,Od=Jk,iE=nE,sE=bu,zd=cu(),Ld=uu(),oE=function(e,t){if(sE(e)!=="Object")throw new rE("`V` must be an Object");if(t!=="SYNC-DISPOSE"&&t!=="ASYNC-DISPOSE")throw new Dd("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");var r;if(t==="ASYNC-DISPOSE"&&Ld&&(r=Od(e,Ld)),!r){if(!zd)throw new Dd("`Symbol.dispose` is not supported");if(r=Od(e,zd),typeof r<"u")return function(){var i=this;if(t==="ASYNC-DISPOSE"){var s=iE(Promise);try{Al(r,i),Al(s["[[Resolve]]"],void 0,[void 0])}catch(o){s["[[Reject]]"](o)}return s["[[Promise]]"]}Al(r,i)}}return r},aE=qt,xl=G,lE=li,cE=bu,uE=oE,hE=function(e,t){if(t!=="SYNC-DISPOSE"&&t!=="ASYNC-DISPOSE")throw new aE("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");var r;if(arguments.length<3)if(e==null)e=void 0,r=void 0;else{if(typeof e<"u"&&cE(e)!=="Object")throw new xl("`V` must be an Object, or `null` or `undefined`");if(r=uE(e,t),typeof r>"u")throw new xl("dispose method must not be `undefined` on `V` when an object `V` is provided")}else if(r=arguments[2],!lE(r))throw new xl("`method`, when provided, must be a function");return{"[[ResourceValue]]":e,"[[Hint]]":t,"[[DisposeMethod]]":r}},dE=qt,yo=G,fE=Fk,Md=hE,pE=bn(),gE=pE("Array.prototype.push"),Jp=function(e,t,r){if(!fE(e))throw new yo("Assertion failed: `disposeCapability` must be a DisposeCapability Record");if(r!=="SYNC-DISPOSE"&&r!=="ASYNC-DISPOSE")throw new dE("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");var i=arguments.length>3?arguments[3]:void 0;if(arguments.length>3&&typeof i!="function")throw new yo("Assertion failed: `method`, when present, must be a function");if(!e["[[DisposableResourceStack]]"])throw new yo("Assertion failed: `disposeCapability.[[DisposableResourceStack]]` must not be ~EMPTY~");var s;if(arguments.length<4){if(t==null&&r==="SYNC_DISPOSE")return"UNUSED";s=Md(t,r)}else{if(typeof t<"u")throw new yo("Assertion failed: `V` must be undefined when `method` is present");s=Md(void 0,r,i)}return gE(e["[[DisposableResourceStack]]"],s),"UNUSED"},Tl,Nd;function wu(){if(Nd)return Tl;Nd=1;var n=st,e=vu,t=qt,r=n("%Promise.resolve%",!0),i=r&&e(r);return Tl=function(o,a){if(!i)throw new t("This environment does not support Promises.");return i(o,a)},Tl}var Cl,Ud;function mE(){if(Ud)return Cl;Ud=1;var n=st,e=qt,t=n("%Promise%",!0),r=Pa,i=wu(),s=bu;return Cl=function(a,c,u){if(typeof a<"u"&&s(a)!=="Object")throw new e("Assertion failed: `V` must be `undefined` or an Object");if(c!=="SYNC-DISPOSE"&&c!=="ASYNC-DISPOSE")throw new e("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");if(typeof u<"u"&&typeof u!="function")throw new e("Assertion failed: `method` must be `undefined` or a function");var d=typeof u>"u"?u:r(u,a);if(c==="ASYNC-DISPOSE")return i(t,d)},Cl}var Il,Fd;function yE(){if(Fd)return Il;Fd=1;var n=mu;return Il=function(t){return new n("throw",t)},Il}var vE=st,Pl=qt,Zd=G,bE=vE("%Promise%",!0),wE=bn(),Hd=wE("Promise.prototype.then",!0),_E=mu,Vd=mE(),SE=yu,kE=wu(),jd=yE(),EE=Up(),Xp=function(e,t){if(!(t instanceof _E))throw new Zd("`completion` must be a Completion Record");var r=e["[[DisposableResourceStack]]"];if(!r)throw new Zd("Assertion failed: `disposeCapability.[[DisposableResourceStack]]` must not be ~EMPTY~");for(var i,s=r.length-1;s>=0;s-=1)if(!i)i=r[s]["[[Hint]]"];else if(i!==r[s]["[[Hint]]"])throw new Pl("mixed hint stacks are not supported");for(var o=i==="ASYNC-DISPOSE"&&kE(bE,t),a=function(v){if(t.type()==="throw"){var y=t.value(),A=new EE(v,y);t=jd(A)}else t=jd(v)},c=i==="ASYNC-DISPOSE"&&function(y){return Hd(o,function(){var A=Vd(y["[[ResourceValue]]"],y["[[Hint]]"],y["[[DisposeMethod]]"]);if(!A)throw new Pl("Assertion failed: non-`~ASYNC-DISPOSE~` resource returned a promise from Dispose");return Hd(A,SE)},a)},u=r.length-1;u>=0;u-=1)if(i==="ASYNC-DISPOSE")o=c(r[u]);else{var d=r[u];try{var f=Vd(d["[[ResourceValue]]"],d["[[Hint]]"],d["[[DisposeMethod]]"]);if(f)throw new Pl("Assertion failed: `~SYNC-DISPOSE~` resource returned something from Dispose")}catch(v){a(v)}}return e["[[DisposableResourceStack]]"]=null,i==="ASYNC-DISPOSE"?o:t},Qp=function(){var e=[];return{"[[DisposableResourceStack]]":e}},Oa=eu,_u=G,$E=Pa,ui=au,AE=Ws,eg=li,xE=yu,je=gu,TE=Yp,tg=ar.supportsDescriptors,CE=vu,Su=Jp,IE=Xp,ng=Qp,Bd=cu(),nt=function n(){if(!(this instanceof n)||je.has(this,"[[DisposableState]]")||je.has(this,"[[DisposeCapability]]"))throw new _u("can only be used with new");je.set(this,"[[DisposableState]]","PENDING"),je.set(this,"[[DisposeCapability]]",ng())},rg=function(){var e=this;return je.assert(e,"[[DisposableState]]"),je.get(e,"[[DisposableState]]")==="DISPOSED"},Ks=CE(rg);tg?AE(nt.prototype,"disposed",{"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Get]]":rg}):nt.prototype.disposed=!1;var ig=function(e){je.set(e,"[[DisposableState]]","DISPOSED"),tg||(e.disposed=!0)};ui(nt.prototype,"dispose",function(){var e=this;if(!Ks(e))return ig(e),IE(je.get(e,"[[DisposeCapability]]"),xE())["?"]()});ui(nt.prototype,"use",function(e){var t=this;if(Ks(t))throw new Oa("a disposed stack can not use anything new");return Su(je.get(t,"[[DisposeCapability]]"),e,"SYNC-DISPOSE"),e});ui(nt.prototype,"adopt",function(e,t){var r=this;if(Ks(r))throw new Oa("a disposed stack can not use anything new");if(!eg(t))throw new _u("`onDispose` must be a function");var i=function(){return $E(t,void 0,[e])};return Su(je.get(r,"[[DisposeCapability]]"),void 0,"SYNC-DISPOSE",i),e});ui(nt.prototype,"defer",function(e){var t=this;if(Ks(t))throw new Oa("a disposed stack can not defer anything new");if(!eg(e))throw new _u("`onDispose` must be a function");Su(je.get(t,"[[DisposeCapability]]"),void 0,"SYNC-DISPOSE",e)});ui(nt.prototype,"move",function(){var e=this;if(Ks(e))throw new Oa("a disposed stack can not use anything new");var t=new nt;return je.set(t,"[[DisposeCapability]]",je.get(e,"[[DisposeCapability]]")),je.set(e,"[[DisposeCapability]]",ng()),ig(e),t});Bd&&ui(nt.prototype,Bd,nt.prototype.dispose);TE(nt.prototype,"DisposableStack");var PE=nt,RE=PE,DE=function(){return typeof DisposableStack=="function"?DisposableStack:RE},OE=ar,zE=Xc(),LE=DE,ME=function(){var e=LE();return OE(zE,{DisposableStack:e},{DisposableStack:!0}),e},NE=st,za=eu,ku=G,Gd=NE("%Promise%",!0),Eu=Jp,UE=Pa,hi=au,FE=Ws,ZE=Xp,sg=li,og=Qp,HE=yu,Wd=wu(),Be=gu,VE=Yp,ag=ar.supportsDescriptors,jE=vu,BE=bn(),GE=BE("Promise.prototype.then",!0),qd=uu(),rt=function n(){if(!(this instanceof n)||Be.has(this,"[[AsyncDisposableState]]")||Be.has(this,"[[DisposeCapability]]"))throw new ku("can only be used with new");Be.set(this,"[[AsyncDisposableState]]","pending"),Be.set(this,"[[DisposeCapability]]",og())},lg=function(){var e=this;return Be.assert(e,"[[AsyncDisposableState]]"),Be.get(e,"[[AsyncDisposableState]]")==="disposed"},Js=jE(lg);ag?FE(rt.prototype,"disposed",{"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Get]]":lg}):rt.prototype.disposed=!1;var cg=function(e){Be.set(e,"[[AsyncDisposableState]]","disposed"),ag||(e.disposed=!0)};hi(rt.prototype,"disposeAsync",function(){var e=this;return Js(e)?Wd(Gd):(cg(e),GE(Wd(Gd,ZE(Be.get(e,"[[DisposeCapability]]"),HE())),function(t){return t["?"]()}))});hi(rt.prototype,"use",function(e){var t=this;if(Js(t))throw new za("a disposed stack can not use anything new");return Eu(Be.get(t,"[[DisposeCapability]]"),e,"ASYNC-DISPOSE"),e});hi(rt.prototype,"adopt",function(e,t){var r=this;if(Js(r))throw new za("a disposed stack can not use anything new");if(!sg(t))throw new ku("`onDisposeAsync` must be a function");var i=function(){return UE(t,void 0,[e])};return i.value=e,Eu(Be.get(r,"[[DisposeCapability]]"),void 0,"ASYNC-DISPOSE",i),e});hi(rt.prototype,"defer",function(e){var t=this;if(Js(t))throw new za("a disposed stack can not defer anything new");if(!sg(e))throw new ku("`onDispose` must be a function");Eu(Be.get(t,"[[DisposeCapability]]"),void 0,"ASYNC-DISPOSE",e)});hi(rt.prototype,"move",function(){var e=this;if(Js(e))throw new za("a disposed stack can not use anything new");var t=new rt;return Be.set(t,"[[DisposeCapability]]",Be.get(e,"[[DisposeCapability]]")),Be.set(e,"[[DisposeCapability]]",og()),cg(e),t});qd&&hi(rt.prototype,qd,rt.prototype.disposeAsync);VE(rt.prototype,"AsyncDisposableStack");var WE=rt,qE=WE,YE=function(){return typeof AsyncDisposableStack=="function"?AsyncDisposableStack:qE},KE=ar,JE=Xc(),XE=YE,QE=function(){var e=XE();return KE(JE,{AsyncDisposableStack:e},{AsyncDisposableStack:!0}),e},e0=K_,t0=iS,n0=ME,r0=QE,i0=function(){e0(),t0(),n0(),r0()};i0();const Yd=new WeakMap;function s0(n){return(typeof n=="object"||typeof n=="function")&&n!==null&&"then"in n&&typeof n.then=="function"}function wr(n){return typeof n=="string"?n:typeof n=="symbol"?n.description??n.toString():n.name||"(anonymous class)"}function Kd(){return new Error("register(Key, factory) requires a factory function. Wrap existing instances as () => instance.")}function o0(){return new Error("register(Key, factory) does not accept async factories. Await setup before registering.")}class a0{constructor(){b(this,"entries",new Map);b(this,"constructionStack",[])}register(e,t){if(t===void 0){if(typeof e!="function")throw Kd();this.validateClassRegistration(e),this.storeFactory(e,()=>this.instantiateClass(e));return}if(typeof t!="function")throw Kd();if(t.constructor.name==="AsyncFunction")throw o0();this.storeFactory(e,t)}has(e){var t;return((t=this.entries.get(e))==null?void 0:t.factory)!==void 0}resolve(e){return this.resolveAny(e)}storeFactory(e,t){const r=this.getOrCreateEntry(e);r.factory=t,r.instance=void 0,r.error=void 0}validateClassRegistration(e){const t=Yd.get(e);if(t){if(e.length!==t.length)throw new Error(`${wr(e)} cannot be registered with register(Class). @injectable(...) declared ${t.length} dependencies but constructor arity is ${e.length}. Use register(Key, () => value) instead.`);return}if(e.length!==0)throw new Error(`${wr(e)} cannot be registered with register(Class). Undecorated classes must have zero required constructor parameters. Use register(Key, () => value) instead.`)}instantiateClass(e){const t=Yd.get(e);if(!t)return new e;const r=t.map(i=>this.resolveAny(i));return new e(...r)}resolveAny(e){return this.getOrCreateEntry(e).proxy}getOrCreateEntry(e){let t=this.entries.get(e);return t||(t={key:e},t.proxy=this.createProxy(t),this.entries.set(e,t),t)}createProxy(e){return new Proxy({},{get:(t,r)=>{if(r==="then")return;const i=this.getInstance(e),s=Reflect.get(i,r,i);return typeof s=="function"?s.bind(i):s},set:(t,r,i)=>{const s=this.getInstance(e);return Reflect.set(s,r,i,s)},has:(t,r)=>{const i=this.getInstance(e);return r in i}})}getInstance(e){if(e.instance)return e.instance;if(e.error)throw e.error;if(!e.factory)throw new Error(`${wr(e.key)} was resolved but never registered`);const t=this.constructionStack.indexOf(e.key);if(t!==-1){const r=[...this.constructionStack.slice(t),e.key].map(i=>wr(i)).join(" -> ");throw new Error(`Circular dependency detected: ${r}`)}this.constructionStack.push(e.key);try{const r=e.factory();if(s0(r))throw new Error(`Factory for ${wr(e.key)} returned a Promise. Await setup before registering.`);if(typeof r!="object"||r===null)throw new Error(`Factory for ${wr(e.key)} returned a non-object value. Wrap primitives in an object.`);return e.instance=r,r}catch(r){throw e.error=r,r}finally{this.constructionStack.pop()}}}const Ge=new a0,l0=new Set(["target","currentTarget","eventPhase","defaultPrevented","isTrusted","timeStamp","srcElement","returnValue","cancelBubble","NONE","CAPTURING_PHASE","AT_TARGET","BUBBLING_PHASE","composedPath","stopPropagation","stopImmediatePropagation","preventDefault","initEvent"]);function c0(n){for(const e of Object.keys(n))if(l0.has(e))throw new Error(`Event payload key "${e}" is reserved; choose a different property name`)}function u0(n,e){c0(e);for(const t of Object.keys(e))Object.defineProperty(n,t,{value:e[t],writable:!0,enumerable:!0,configurable:!0})}function pt(){class n extends Event{constructor(t,r){const{type:i,bubbles:s,cancelable:o,composed:a,...c}=r??{};if(i!==void 0)throw new Error('Do not pass "type" in init; use the constructor argument instead');super(t,{bubbles:s,cancelable:o,composed:a}),u0(this,c)}}return n}class gt extends globalThis.EventTarget{}function h0(n,e,t){const r=n.dispose.bind(n);n.dispose=()=>{if(!e())return t(),r()}}function di(n){var t;class e extends n{constructor(...s){super(...s);_(this,t,!1);h0(this,()=>l(this,t),()=>{E(this,t,!0)})}[Symbol.dispose](){this.dispose()}get disposed(){return l(this,t)}}return t=new WeakMap,e}const d0=pt(),f0=pt(),No=pt(),ug="0123456789ABCDEFGHJKMNPQRSTVWXYZ",Jo=32,p0=16,hg=10,Jd=0xffffffffffff;var zn;(function(n){n.Base32IncorrectEncoding="B32_ENC_INVALID",n.DecodeTimeInvalidCharacter="DEC_TIME_CHAR",n.DecodeTimeValueMalformed="DEC_TIME_MALFORMED",n.EncodeTimeNegative="ENC_TIME_NEG",n.EncodeTimeSizeExceeded="ENC_TIME_SIZE_EXCEED",n.EncodeTimeValueMalformed="ENC_TIME_MALFORMED",n.PRNGDetectFailure="PRNG_DETECT",n.ULIDInvalid="ULID_INVALID",n.Unexpected="UNEXPECTED",n.UUIDInvalid="UUID_INVALID"})(zn||(zn={}));class Oi extends Error{constructor(e,t){super(`${t} (${e})`),this.name="ULIDError",this.code=e}}function g0(n){const e=Math.floor(n()*Jo)%Jo;return ug.charAt(e)}function m0(n){const e=y0(),t=e&&(e.crypto||e.msCrypto)||null;if(typeof(t==null?void 0:t.getRandomValues)=="function")return()=>{const r=new Uint8Array(1);return t.getRandomValues(r),r[0]/256};if(typeof(t==null?void 0:t.randomBytes)=="function")return()=>t.randomBytes(1).readUInt8()/256;throw new Oi(zn.PRNGDetectFailure,"Failed to find a reliable PRNG")}function y0(){return w0()?self:typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:null}function v0(n,e){let t="";for(;n>0;n--)t=g0(e)+t;return t}function b0(n,e=hg){if(isNaN(n))throw new Oi(zn.EncodeTimeValueMalformed,`Time must be a number: ${n}`);if(n>Jd)throw new Oi(zn.EncodeTimeSizeExceeded,`Cannot encode a time larger than ${Jd}: ${n}`);if(n<0)throw new Oi(zn.EncodeTimeNegative,`Time must be positive: ${n}`);if(Number.isInteger(n)===!1)throw new Oi(zn.EncodeTimeValueMalformed,`Time must be an integer: ${n}`);let t,r="";for(let i=e;i>0;i--)t=n%Jo,r=ug.charAt(t)+r,n=(n-t)/Jo;return r}function w0(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}function $u(n,e){const t=m0(),r=Date.now();return b0(r,hg)+v0(p0,t)}const Ct=4,Xe=6,dg=2,ac=2,_0=Ct,S0=Xe,Au="auto",fn="auto",Pn=120,Xd=75,pe=16,tr=Pn*Ct+pe*(Ct-1),Xo=Pn*Xe+pe*(Xe-1),k0=200,E0=4,vo=150,$0=10,Qd=2,A0=4;function fg(n){return mg(n)}function pg(n,e){return mg(n.flatMap(t=>vg(t,e)))}function gg(n){const e=[],t=new Set;for(const r of n){if(r.type==="row"){e.push(`Top-level rows are invalid: ${r.id}`);continue}bg(r,"strip",e,t)}return{valid:e.length===0,errors:e}}function Wi(n){const e=fg(n),t=gg(e);if(!t.valid)throw new Error(`Invalid layout: ${t.errors.join("; ")}`);return{totalNodes:e.length,nodes:e.filter(r=>r.type!=="row").map(I0)}}function mg(n){const e=[];for(const t of n){const r=yg(t);for(const i of r){if(i.type==="row"){e.push(...i.children.map(Gt));continue}e.push(i)}}return e}function yg(n){switch(n.type){case"card":return[Gt(n)];case"row":{const e=n.children.map(Gt);return e.length===0?[]:e.length===1?[e[0]]:[{...n,children:e}]}case"stack":{const e=[];for(const t of n.children){const r=yg(t);for(const i of r){if(i.type==="stack"){e.push(...i.children.map(lc));continue}if(i.type==="row"){e.push({...i,children:i.children.map(Gt)});continue}e.push(Gt(i))}}return e.length===0?[]:e.length===1?[lc(e[0])]:[{...n,children:e}]}}}function vg(n,e){switch(n.type){case"card":return n.artifactID===e?[]:[Gt(n)];case"row":{const t=n.children.filter(r=>r.artifactID!==e).map(Gt);return t.length===0?[]:t.length===1?[t[0]]:[{...n,children:t}]}case"stack":{const t=n.children.flatMap(r=>vg(r,e).filter(s=>s.type!=="stack"));return t.length===0?[]:t.length===1?[lc(t[0])]:[{...n,children:t}]}}}function bg(n,e,t,r){switch(n.type){case"card":wg(n,e,t,r);return;case"row":x0(n,e,t,r);return;case"stack":T0(n,e,t,r);return}}function wg(n,e,t,r){xu(n.id,t),typeof n.artifactID!="string"||n.artifactID.length===0?t.push(`Card ${n.id} is missing artifactID`):r.has(n.artifactID)?t.push(`Duplicate artifactID in layout: ${n.artifactID}`):r.add(n.artifactID),C0(n.width)||t.push(`Card ${n.id} width must be an integer in the range 2-4`),_g(n.height)||t.push(`Card ${n.id} height must be an integer in the range 2-6 or "auto"`);const i=Rn(n.width);e==="row"&&i<dg&&t.push(`Row child ${n.id} must be at least 2 columns wide`)}function x0(n,e,t,r){if(xu(n.id,t),e!=="stack"&&t.push(`Row ${n.id} may only appear inside a stack`),_g(n.height,A0)||t.push(`Row ${n.id} height must be an integer in the range 2-4 or "auto"`),!Array.isArray(n.children)||n.children.length===0){t.push(`Row ${n.id} must contain card nodes`);return}let i=0;for(const s of n.children){if(s.type!=="card"){t.push(`Row ${n.id} must contain only card nodes`);continue}wg(s,"row",t,r),i+=Rn(s.width)}i!==Ct&&t.push(`Row ${n.id} children must sum to 4 columns`)}function T0(n,e,t,r){if(xu(n.id,t),e!=="strip"&&t.push(`Invalid nested stack at ${n.id}; stack children cannot contain another nested stack`),!Array.isArray(n.children)||n.children.length===0){t.push(`Stack ${n.id} must contain at least one child`);return}let i=0,s=0;for(const a of n.children){if(a.type==="stack"){t.push(`Stack ${n.id} cannot contain another nested stack`);continue}if(bg(a,"stack",t,r),a.height===fn){s+=1;continue}i+=a.height}if(i>Xe&&t.push(`Stack ${n.id} exceeds the 6-row budget`),s===0)return;const o=Xe-i;if(o<s*ac||o%s!==0){t.push(`Stack ${n.id} has auto-height children that cannot resolve to whole height >= 2`);return}o/s<ac&&t.push(`Stack ${n.id} has auto-height children below the minimum row size`)}function xu(n,e){(typeof n!="string"||n.length===0)&&e.push(`Node id must be a non-empty string: ${String(n)}`)}function C0(n){return n===Au||Number.isInteger(n)&&n>=dg&&n<=_0}function _g(n,e=S0){return n===fn||Number.isInteger(n)&&n>=ac&&n<=e}function Rn(n){return n===Au?Ct:n}function I0(n){if(n.type==="card")return{id:n.id,type:"card",width:Rn(n.width),cards:[{id:n.id,artifactID:n.artifactID,col:1,row:1,width:Rn(n.width),height:Sg(n.height,Xe)}]};const e=P0(n.children),t=[];let r=1;for(let i=0;i<n.children.length;i+=1){const s=n.children[i],o=e[i];if(s.type==="card")t.push({id:s.id,artifactID:s.artifactID,col:1,row:r,width:Rn(s.width),height:o});else{let a=1;for(const c of s.children)t.push({id:c.id,artifactID:c.artifactID,col:a,row:r,width:Rn(c.width),height:o}),a+=Rn(c.width)}r+=o}return{id:n.id,type:"stack",width:t.reduce((i,s)=>Math.max(i,s.col+s.width-1),1),cards:t}}function P0(n){let e=0,t=0;for(const i of n)i.height===fn?t+=1:e+=i.height;const r=t>0?(Xe-e)/t:0;return n.map(i=>Sg(i.height,r))}function Sg(n,e){return n===fn?e:n}function Gt(n){return{...n}}function lc(n){return n.type==="card"?Gt(n):{...n,children:n.children.map(Gt)}}function kg(n,e={}){return{id:e.id??$u(),type:"card",artifactID:n,width:e.width??Au,height:e.height??fn}}function Eg(n,e){return n.some(t=>$g(t,e))}function $g(n,e){switch(n.type){case"card":return n.artifactID===e;case"row":return n.children.some(t=>t.artifactID===e);case"stack":return n.children.some(t=>$g(t,e))}}function ef(n){return n.layout.flatMap(Ag)}function Ag(n){switch(n.type){case"card":return[n.artifactID];case"row":return n.children.map(e=>e.artifactID);case"stack":return n.children.flatMap(Ag)}}const Q=pt(),xg=pt(),Ei=pt(),R0=pt();function D0(n){class e extends Error{constructor(r,i){super(r),this.name=n,i&&Object.assign(this,i)}}return e}const O0=D0("RequestError"),z0=200,L0=300;class M0{constructor(e,t){b(this,"serverURL");b(this,"token");this.serverURL=e.replace(/\/$/,""),this.token=t.token}async requestJSON(e,t,r){const i=await this.request(e,t,r!==void 0?JSON.stringify(r):void 0,r!==void 0?{"content-type":"application/json"}:void 0),s=await N0(i);if(!i.ok||i.status<z0||i.status>=L0)throw this.createError(typeof s.error=="string"?s.error:i.statusText,i.status);return s}async requestVoid(e,t){const r=await this.request(e,t);if(!r.ok)throw this.createError(await Rl(r,r.statusText),r.status)}async requestText(e,t){const r=await this.request(e,t);if(!r.ok)throw this.createError(await Rl(r,r.statusText),r.status);return r.text()}async requestRawVoid(e,t,r){const i=await this.request(e,t,r,{"content-type":"text/plain"});if(!i.ok)throw this.createError(await Rl(i,i.statusText),i.status)}createError(e,t){const r={serverURL:this.serverURL};return t!==void 0&&(r.status=t),new O0(e,r)}async request(e,t,r,i){const s=`${this.serverURL}${t}`;try{return await fetch(s,{method:e,headers:this.buildHeaders(i),body:r})}catch(o){throw this.createError(o instanceof Error?o.message:"Failed to reach server")}}buildHeaders(e){const t={...e??{}};return this.token&&(t.Authorization=`Bearer ${this.token}`),Object.keys(t).length>0?t:void 0}}async function N0(n){try{return await n.json()}catch{const e=await n.text().catch(()=>"");return e?{message:e}:{}}}async function Rl(n,e){try{const t=await n.json();if(typeof t.error=="string")return t.error;if(typeof t.message=="string")return t.message}catch{}return e}function Tg(n){return n.map(e=>`${e.name} (${e.id})`).join(", ")}var Et,ua,Cg;class U0{constructor(e){_(this,ua);_(this,Et);E(this,Et,e)}list(){return l(this,Et).requestJSON("GET","/screens")}async get(e={}){const t=await m(this,ua,Cg).call(this,e.screenID);return l(this,Et).requestJSON("GET",`/screens/${encodeURIComponent(t)}`)}create(e){const t={name:e.name};return e.id!==void 0&&(t.id=e.id),l(this,Et).requestJSON("POST","/screens",t)}update(e){const t={};return e.name!==void 0&&(t.name=e.name),e.layout!==void 0&&(t.layout=e.layout),l(this,Et).requestJSON("PATCH",`/screens/${encodeURIComponent(e.screenID)}`,t)}remove(e){return l(this,Et).requestJSON("DELETE",`/screens/${encodeURIComponent(e.screenID)}`)}}Et=new WeakMap,ua=new WeakSet,Cg=async function(e){if(e!==void 0)return e;const{screens:t}=await this.list();if(t.length===1)return t[0].id;throw l(this,Et).createError(`screenID is required when multiple screens exist. Available screens: ${Tg(t)}`)};var Ze,ns,ha,Ig;class F0{constructor(e,t){_(this,ha);_(this,Ze);_(this,ns);E(this,Ze,e),E(this,ns,t)}async create(e){const t=await m(this,ha,Ig).call(this,e.screenID);return l(this,Ze).requestJSON("POST",`/screens/${encodeURIComponent(t)}/artifact`,{type:e.type,title:e.title,externalFilePath:e.externalFilePath})}get(e){return l(this,Ze).requestJSON("GET",`/artifacts/${encodeURIComponent(e.artifactID)}`)}update(e){const t={};return e.title!==void 0&&(t.title=e.title),l(this,Ze).requestJSON("PATCH",`/artifacts/${encodeURIComponent(e.artifactID)}`,t)}edit(e){return l(this,Ze).requestJSON("POST",`/artifacts/${encodeURIComponent(e.artifactID)}/edit`)}commitPending(e){return l(this,Ze).requestJSON("POST",`/artifacts/${encodeURIComponent(e.artifactID)}/commit`)}abandonPending(e){return l(this,Ze).requestVoid("POST",`/artifacts/${encodeURIComponent(e.artifactID)}/abandon`)}remove(e){return l(this,Ze).requestJSON("DELETE",`/screens/${encodeURIComponent(e.screenID)}/artifacts/${encodeURIComponent(e.artifactID)}`)}getContent(e){return l(this,Ze).requestText("GET",`/artifacts/${encodeURIComponent(e.artifactID)}/content`)}putContent(e){return l(this,Ze).requestRawVoid("PUT",`/artifacts/${encodeURIComponent(e.artifactID)}/content`,e.content)}}Ze=new WeakMap,ns=new WeakMap,ha=new WeakSet,Ig=async function(e){if(e!==void 0)return e;const{screens:t}=await l(this,ns).list();if(t.length===1)return t[0].id;throw l(this,Ze).createError(`screenID is required when multiple screens exist. Available screens: ${Tg(t)}`)};var rs;class Z0{constructor(e){_(this,rs);E(this,rs,e)}async list(){const{views:e}=await l(this,rs).requestJSON("GET","/views");return e}}rs=new WeakMap;var tn;class H0{constructor(e,t={}){b(this,"screens");b(this,"artifacts");b(this,"views");_(this,tn);E(this,tn,new M0(e,t)),this.screens=new U0(l(this,tn)),this.artifacts=new F0(l(this,tn),this.screens),this.views=new Z0(l(this,tn))}health(){return l(this,tn).requestJSON("GET","/health")}}tn=new WeakMap;const V0={focusCommandInput:{label:"Focus Command Input",trigger:{key:"k",meta:!0}}},j0=di(gt);var Mn,He,Nn,ze,nn,rn,J,Sr,Pg,is,Rg,Dg,Og,zg,cc,uc,hc,Lg;class B0 extends j0{constructor(t){var i;super();_(this,J);b(this,"id");b(this,"server");_(this,Mn);_(this,He,new Map);_(this,Nn);_(this,ze);_(this,nn);_(this,rn,null);_(this,is,t=>{if(this.disposed)return;const r=t.event;switch(r.type){case"screen-updated":r.screen.id===this.id&&m(this,J,Rg).call(this,r.screen);break;case"artifact-created":r.screenID===this.id&&m(this,J,Dg).call(this,r.artifact);break;case"artifact-updated":m(this,J,Og).call(this,r.artifact);break;case"artifact-removed":r.screenID===this.id&&m(this,J,zg).call(this,r.artifactID);break;case"artifact-content-changed":l(this,He).has(r.artifactID)&&this.dispatchEvent(new R0("artifact-content-changed",{artifactID:r.artifactID}));break}});this.id=t.screen.id,this.server=t.server,E(this,Mn,t.localStore),E(this,Nn,t.screen.name),E(this,ze,structuredClone(t.screen.layout));const r=((i=l(this,Mn).get().screens[this.id])==null?void 0:i.scrollPosition)??0;E(this,nn,Math.max(0,r)),this.server.addEventListener("server-event",l(this,is)),m(this,J,Pg).call(this)}get name(){return l(this,Nn)}get layout(){return l(this,ze)}get scrollPosition(){return l(this,nn)}get artifacts(){return l(this,He)}setScrollPosition(t){m(this,J,Sr).call(this);const r=Math.max(0,t);r!==l(this,nn)&&(E(this,nn,r),m(this,J,Lg).call(this),this.dispatchEvent(new Q("change")))}setLayout(t){m(this,J,Sr).call(this);const r=fg(t);if(!gg(r).valid)return;const s=m(this,J,uc).call(this);E(this,ze,r),E(this,rn,{layout:r,snapshot:s}),this.dispatchEvent(new Q("change")),this.server.client.screens.update({screenID:this.id,layout:r.map(o=>structuredClone(o))}).catch(()=>{var o;this.disposed||((o=l(this,rn))==null?void 0:o.layout)===r&&(E(this,rn,null),m(this,J,hc).call(this,s),this.dispatchEvent(new Q("change")))})}rename(t){m(this,J,Sr).call(this),E(this,Nn,t),this.dispatchEvent(new Q("change")),this.server.client.screens.update({screenID:this.id,name:t}).catch(()=>{})}async remove(){m(this,J,Sr).call(this),await this.server.client.screens.remove({screenID:this.id})}removeArtifact(t){if(m(this,J,Sr).call(this),!l(this,He).has(t))return;const r=m(this,J,uc).call(this);m(this,J,cc).call(this,t),this.dispatchEvent(new Q("change")),this.server.client.artifacts.remove({artifactID:t,screenID:this.id}).catch(()=>{this.disposed||(m(this,J,hc).call(this,r),this.dispatchEvent(new Q("change")))})}dispose(){this.server.removeEventListener("server-event",l(this,is))}}Mn=new WeakMap,He=new WeakMap,Nn=new WeakMap,ze=new WeakMap,nn=new WeakMap,rn=new WeakMap,J=new WeakSet,Sr=function(){if(this.disposed)throw new Error("ScreenModel is disposed")},Pg=async function(){try{const t=await this.server.client.screens.get({screenID:this.id});if(this.disposed)return;for(const r of t.artifacts)l(this,He).set(r.id,r);this.dispatchEvent(new Q("change"))}catch{}},is=new WeakMap,Rg=function(t){l(this,rn)&&E(this,rn,null),E(this,Nn,t.name),E(this,ze,structuredClone(t.layout)),this.dispatchEvent(new Q("change"))},Dg=function(t){Eg(l(this,ze),t.id)||E(this,ze,[...l(this,ze),kg(t.id)]),l(this,He).set(t.id,t),this.dispatchEvent(new Q("change"))},Og=function(t){const r=l(this,He).get(t.id);r&&(l(this,He).set(t.id,{...r,...t}),this.dispatchEvent(new Q("change")))},zg=function(t){m(this,J,cc).call(this,t)&&this.dispatchEvent(new Q("change"))},cc=function(t){const r=l(this,He).delete(t),i=ef({layout:l(this,ze)}).length,s=pg(l(this,ze),t),o=ef({layout:s}).length;return E(this,ze,s),r||i!==o},uc=function(){return{layout:structuredClone(l(this,ze)),artifacts:new Map([...l(this,He).entries()].map(([t,r])=>[t,structuredClone(r)]))}},hc=function(t){E(this,ze,structuredClone(t.layout)),l(this,He).clear();for(const[r,i]of t.artifacts)l(this,He).set(r,structuredClone(i))},Lg=function(){const t=l(this,Mn).get();l(this,Mn).set({...t,screens:{...t.screens,[this.id]:{scrollPosition:l(this,nn)}}})};const G0=di(gt);var Qe,Mt,at,ss,os,as,Dr,Uo;class W0 extends G0{constructor(t){super();_(this,Dr);_(this,Qe);_(this,Mt);_(this,at,null);_(this,ss,()=>{this.disposed||m(this,Dr,Uo).call(this)});_(this,os,()=>{this.disposed||m(this,Dr,Uo).call(this)});_(this,as,t=>{var i;if(this.disposed)return;const r=t.event;r.type==="screen-removed"&&((i=l(this,at))==null?void 0:i.id)===r.screenID&&this.clearActive()});E(this,Qe,t.localStore),E(this,Mt,t.serverManager),l(this,Qe).addEventListener("change",l(this,ss)),l(this,Mt).addEventListener("change",l(this,os)),l(this,Mt).addEventListener("server-event",l(this,as)),m(this,Dr,Uo).call(this)}get activeScreen(){return l(this,at)}setActive(t,r){const i=l(this,Qe).get();i.activeServerURL===t&&i.activeScreenID===r||l(this,Qe).set({...i,activeServerURL:t,activeScreenID:r})}clearActive(){const t=l(this,Qe).get();t.activeScreenID!==null&&l(this,Qe).set({...t,activeScreenID:null})}dispose(){var t;l(this,Qe).removeEventListener("change",l(this,ss)),l(this,Mt).removeEventListener("change",l(this,os)),l(this,Mt).removeEventListener("server-event",l(this,as)),(t=l(this,at))==null||t.dispose(),E(this,at,null)}}Qe=new WeakMap,Mt=new WeakMap,at=new WeakMap,ss=new WeakMap,os=new WeakMap,as=new WeakMap,Dr=new WeakSet,Uo=function(){var c,u,d;const{activeServerURL:t,activeScreenID:r}=l(this,Qe).get(),i=t?l(this,Mt).servers.get(t)??null:null,s=i&&r?i.screens.get(r)??null:null,o=((c=l(this,at))==null?void 0:c.id)??null,a=(s==null?void 0:s.id)??null;o===a&&((u=l(this,at))==null?void 0:u.server)===i||((d=l(this,at))==null||d.dispose(),E(this,at,i&&s?new B0({screen:s,server:i,localStore:l(this,Qe)}):null),this.dispatchEvent(new d0("active-screen-changed")))};const q0="Local",Y0="store-";function kt(n){return new URL(n).origin}function K0(n){return{servers:[{url:kt(n),name:q0}],activeServerURL:null,activeScreenID:null,screens:{}}}var Un,Fn,Zn;class J0 extends gt{constructor(t,r,i={}){super();_(this,Un);_(this,Fn);_(this,Zn);E(this,Un,`${Y0}${t}`),E(this,Fn,i.storage??X0());const s=l(this,Fn).getItem(l(this,Un));s===null?(E(this,Zn,r),l(this,Fn).setItem(l(this,Un),JSON.stringify(r))):E(this,Zn,JSON.parse(s))}get(){return l(this,Zn)}set(t){E(this,Zn,t),l(this,Fn).setItem(l(this,Un),JSON.stringify(t)),this.dispatchEvent(new Q("change"))}}Un=new WeakMap,Fn=new WeakMap,Zn=new WeakMap;function X0(){const n=globalThis.localStorage;if(!n)throw new Error("LocalStore: no storage adapter supplied and window.localStorage is unavailable");return n}function $(n,e,t){function r(a,c){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:c,constr:o,traits:new Set},enumerable:!1}),a._zod.traits.has(n))return;a._zod.traits.add(n),e(a,c);const u=o.prototype,d=Object.keys(u);for(let f=0;f<d.length;f++){const v=d[f];v in a||(a[v]=u[v].bind(a))}}const i=(t==null?void 0:t.Parent)??Object;class s extends i{}Object.defineProperty(s,"name",{value:n});function o(a){var c;const u=t!=null&&t.Parent?new s:this;r(u,a),(c=u._zod).deferred??(c.deferred=[]);for(const d of u._zod.deferred)d();return u}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:a=>{var c,u;return t!=null&&t.Parent&&a instanceof t.Parent?!0:(u=(c=a==null?void 0:a._zod)==null?void 0:c.traits)==null?void 0:u.has(n)}}),Object.defineProperty(o,"name",{value:n}),o}class Rr extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Mg extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}}const Ng={};function pn(n){return Ng}function Ug(n){const e=Object.values(n).filter(r=>typeof r=="number");return Object.entries(n).filter(([r,i])=>e.indexOf(+r)===-1).map(([r,i])=>i)}function dc(n,e){return typeof e=="bigint"?e.toString():e}function Tu(n){return{get value(){{const e=n();return Object.defineProperty(this,"value",{value:e}),e}}}}function Cu(n){return n==null}function Iu(n){const e=n.startsWith("^")?1:0,t=n.endsWith("$")?n.length-1:n.length;return n.slice(e,t)}function Q0(n,e){const t=(n.toString().split(".")[1]||"").length,r=e.toString();let i=(r.split(".")[1]||"").length;if(i===0&&/\d?e-\d?/.test(r)){const c=r.match(/\d?e-(\d?)/);c!=null&&c[1]&&(i=Number.parseInt(c[1]))}const s=t>i?t:i,o=Number.parseInt(n.toFixed(s).replace(".","")),a=Number.parseInt(e.toFixed(s).replace(".",""));return o%a/10**s}const tf=Symbol("evaluating");function X(n,e,t){let r;Object.defineProperty(n,e,{get(){if(r!==tf)return r===void 0&&(r=tf,r=t()),r},set(i){Object.defineProperty(n,e,{value:i})},configurable:!0})}function cr(n,e,t){Object.defineProperty(n,e,{value:t,writable:!0,enumerable:!0,configurable:!0})}function _n(...n){const e={};for(const t of n){const r=Object.getOwnPropertyDescriptors(t);Object.assign(e,r)}return Object.defineProperties({},e)}function nf(n){return JSON.stringify(n)}function e$(n){return n.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Fg="captureStackTrace"in Error?Error.captureStackTrace:(...n)=>{};function Qo(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}const t$=Tu(()=>{var n;if(typeof navigator<"u"&&((n=navigator==null?void 0:navigator.userAgent)!=null&&n.includes("Cloudflare")))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function Qr(n){if(Qo(n)===!1)return!1;const e=n.constructor;if(e===void 0||typeof e!="function")return!0;const t=e.prototype;return!(Qo(t)===!1||Object.prototype.hasOwnProperty.call(t,"isPrototypeOf")===!1)}function Zg(n){return Qr(n)?{...n}:Array.isArray(n)?[...n]:n}const n$=new Set(["string","number","symbol"]);function ei(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Sn(n,e,t){const r=new n._zod.constr(e??n._zod.def);return(!e||t!=null&&t.parent)&&(r._zod.parent=n),r}function O(n){const e=n;if(!e)return{};if(typeof e=="string")return{error:()=>e};if((e==null?void 0:e.message)!==void 0){if((e==null?void 0:e.error)!==void 0)throw new Error("Cannot specify both `message` and `error` params");e.error=e.message}return delete e.message,typeof e.error=="string"?{...e,error:()=>e.error}:e}function r$(n){return Object.keys(n).filter(e=>n[e]._zod.optin==="optional"&&n[e]._zod.optout==="optional")}const i$={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 s$(n,e){const t=n._zod.def,r=t.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const s=_n(n._zod.def,{get shape(){const o={};for(const a in e){if(!(a in t.shape))throw new Error(`Unrecognized key: "${a}"`);e[a]&&(o[a]=t.shape[a])}return cr(this,"shape",o),o},checks:[]});return Sn(n,s)}function o$(n,e){const t=n._zod.def,r=t.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const s=_n(n._zod.def,{get shape(){const o={...n._zod.def.shape};for(const a in e){if(!(a in t.shape))throw new Error(`Unrecognized key: "${a}"`);e[a]&&delete o[a]}return cr(this,"shape",o),o},checks:[]});return Sn(n,s)}function a$(n,e){if(!Qr(e))throw new Error("Invalid input to extend: expected a plain object");const t=n._zod.def.checks;if(t&&t.length>0){const s=n._zod.def.shape;for(const o in e)if(Object.getOwnPropertyDescriptor(s,o)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const i=_n(n._zod.def,{get shape(){const s={...n._zod.def.shape,...e};return cr(this,"shape",s),s}});return Sn(n,i)}function l$(n,e){if(!Qr(e))throw new Error("Invalid input to safeExtend: expected a plain object");const t=_n(n._zod.def,{get shape(){const r={...n._zod.def.shape,...e};return cr(this,"shape",r),r}});return Sn(n,t)}function c$(n,e){const t=_n(n._zod.def,{get shape(){const r={...n._zod.def.shape,...e._zod.def.shape};return cr(this,"shape",r),r},get catchall(){return e._zod.def.catchall},checks:[]});return Sn(n,t)}function u$(n,e,t){const i=e._zod.def.checks;if(i&&i.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const o=_n(e._zod.def,{get shape(){const a=e._zod.def.shape,c={...a};if(t)for(const u in t){if(!(u in a))throw new Error(`Unrecognized key: "${u}"`);t[u]&&(c[u]=n?new n({type:"optional",innerType:a[u]}):a[u])}else for(const u in a)c[u]=n?new n({type:"optional",innerType:a[u]}):a[u];return cr(this,"shape",c),c},checks:[]});return Sn(e,o)}function h$(n,e,t){const r=_n(e._zod.def,{get shape(){const i=e._zod.def.shape,s={...i};if(t)for(const o in t){if(!(o in s))throw new Error(`Unrecognized key: "${o}"`);t[o]&&(s[o]=new n({type:"nonoptional",innerType:i[o]}))}else for(const o in i)s[o]=new n({type:"nonoptional",innerType:i[o]});return cr(this,"shape",s),s}});return Sn(e,r)}function Cr(n,e=0){var t;if(n.aborted===!0)return!0;for(let r=e;r<n.issues.length;r++)if(((t=n.issues[r])==null?void 0:t.continue)!==!0)return!0;return!1}function Ir(n,e){return e.map(t=>{var r;return(r=t).path??(r.path=[]),t.path.unshift(n),t})}function bo(n){return typeof n=="string"?n:n==null?void 0:n.message}function gn(n,e,t){var i,s,o,a,c,u;const r={...n,path:n.path??[]};if(!n.message){const d=bo((o=(s=(i=n.inst)==null?void 0:i._zod.def)==null?void 0:s.error)==null?void 0:o.call(s,n))??bo((a=e==null?void 0:e.error)==null?void 0:a.call(e,n))??bo((c=t.customError)==null?void 0:c.call(t,n))??bo((u=t.localeError)==null?void 0:u.call(t,n))??"Invalid input";r.message=d}return delete r.inst,delete r.continue,e!=null&&e.reportInput||delete r.input,r}function Pu(n){return Array.isArray(n)?"array":typeof n=="string"?"string":"unknown"}function Ji(...n){const[e,t,r]=n;return typeof e=="string"?{message:e,code:"custom",input:t,inst:r}:{...e}}const Hg=(n,e)=>{n.name="$ZodError",Object.defineProperty(n,"_zod",{value:n._zod,enumerable:!1}),Object.defineProperty(n,"issues",{value:e,enumerable:!1}),n.message=JSON.stringify(e,dc,2),Object.defineProperty(n,"toString",{value:()=>n.message,enumerable:!1})},Vg=$("$ZodError",Hg),jg=$("$ZodError",Hg,{Parent:Error});function d$(n,e=t=>t.message){const t={},r=[];for(const i of n.issues)i.path.length>0?(t[i.path[0]]=t[i.path[0]]||[],t[i.path[0]].push(e(i))):r.push(e(i));return{formErrors:r,fieldErrors:t}}function f$(n,e=t=>t.message){const t={_errors:[]},r=i=>{for(const s of i.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(o=>r({issues:o}));else if(s.code==="invalid_key")r({issues:s.issues});else if(s.code==="invalid_element")r({issues:s.issues});else if(s.path.length===0)t._errors.push(e(s));else{let o=t,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(e(s))):o[c]=o[c]||{_errors:[]},o=o[c],a++}}};return r(n),t}const Ru=n=>(e,t,r,i)=>{const s=r?Object.assign(r,{async:!1}):{async:!1},o=e._zod.run({value:t,issues:[]},s);if(o instanceof Promise)throw new Rr;if(o.issues.length){const a=new((i==null?void 0:i.Err)??n)(o.issues.map(c=>gn(c,s,pn())));throw Fg(a,i==null?void 0:i.callee),a}return o.value},Du=n=>async(e,t,r,i)=>{const s=r?Object.assign(r,{async:!0}):{async:!0};let o=e._zod.run({value:t,issues:[]},s);if(o instanceof Promise&&(o=await o),o.issues.length){const a=new((i==null?void 0:i.Err)??n)(o.issues.map(c=>gn(c,s,pn())));throw Fg(a,i==null?void 0:i.callee),a}return o.value},La=n=>(e,t,r)=>{const i=r?{...r,async:!1}:{async:!1},s=e._zod.run({value:t,issues:[]},i);if(s instanceof Promise)throw new Rr;return s.issues.length?{success:!1,error:new(n??Vg)(s.issues.map(o=>gn(o,i,pn())))}:{success:!0,data:s.value}},p$=La(jg),Ma=n=>async(e,t,r)=>{const i=r?Object.assign(r,{async:!0}):{async:!0};let s=e._zod.run({value:t,issues:[]},i);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new n(s.issues.map(o=>gn(o,i,pn())))}:{success:!0,data:s.value}},g$=Ma(jg),m$=n=>(e,t,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Ru(n)(e,t,i)},y$=n=>(e,t,r)=>Ru(n)(e,t,r),v$=n=>async(e,t,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Du(n)(e,t,i)},b$=n=>async(e,t,r)=>Du(n)(e,t,r),w$=n=>(e,t,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return La(n)(e,t,i)},_$=n=>(e,t,r)=>La(n)(e,t,r),S$=n=>async(e,t,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Ma(n)(e,t,i)},k$=n=>async(e,t,r)=>Ma(n)(e,t,r),E$=/^[cC][^\s-]{8,}$/,$$=/^[0-9a-z]+$/,A$=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,x$=/^[0-9a-vA-V]{20}$/,T$=/^[A-Za-z0-9]{27}$/,C$=/^[a-zA-Z0-9_-]{21}$/,I$=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,P$=/^([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})$/,rf=n=>n?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${n}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,R$=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,D$="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function O$(){return new RegExp(D$,"u")}const z$=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,L$=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,M$=/^((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])$/,N$=/^(([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])$/,U$=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Bg=/^[A-Za-z0-9_-]*$/,F$=/^\+[1-9]\d{6,14}$/,Gg="(?:(?:\\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])))",Z$=new RegExp(`^${Gg}$`);function Wg(n){const e="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof n.precision=="number"?n.precision===-1?`${e}`:n.precision===0?`${e}:[0-5]\\d`:`${e}:[0-5]\\d\\.\\d{${n.precision}}`:`${e}(?::[0-5]\\d(?:\\.\\d+)?)?`}function H$(n){return new RegExp(`^${Wg(n)}$`)}function V$(n){const e=Wg({precision:n.precision}),t=["Z"];n.local&&t.push(""),n.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${e}(?:${t.join("|")})`;return new RegExp(`^${Gg}T(?:${r})$`)}const j$=n=>{const e=n?`[\\s\\S]{${(n==null?void 0:n.minimum)??0},${(n==null?void 0:n.maximum)??""}}`:"[\\s\\S]*";return new RegExp(`^${e}$`)},B$=/^-?\d+$/,qg=/^-?\d+(?:\.\d+)?$/,G$=/^(?:true|false)$/i,W$=/^[^A-Z]*$/,q$=/^[^a-z]*$/,We=$("$ZodCheck",(n,e)=>{var t;n._zod??(n._zod={}),n._zod.def=e,(t=n._zod).onattach??(t.onattach=[])}),Yg={number:"number",bigint:"bigint",object:"date"},Kg=$("$ZodCheckLessThan",(n,e)=>{We.init(n,e);const t=Yg[typeof e.value];n._zod.onattach.push(r=>{const i=r._zod.bag,s=(e.inclusive?i.maximum:i.exclusiveMaximum)??Number.POSITIVE_INFINITY;e.value<s&&(e.inclusive?i.maximum=e.value:i.exclusiveMaximum=e.value)}),n._zod.check=r=>{(e.inclusive?r.value<=e.value:r.value<e.value)||r.issues.push({origin:t,code:"too_big",maximum:typeof e.value=="object"?e.value.getTime():e.value,input:r.value,inclusive:e.inclusive,inst:n,continue:!e.abort})}}),Jg=$("$ZodCheckGreaterThan",(n,e)=>{We.init(n,e);const t=Yg[typeof e.value];n._zod.onattach.push(r=>{const i=r._zod.bag,s=(e.inclusive?i.minimum:i.exclusiveMinimum)??Number.NEGATIVE_INFINITY;e.value>s&&(e.inclusive?i.minimum=e.value:i.exclusiveMinimum=e.value)}),n._zod.check=r=>{(e.inclusive?r.value>=e.value:r.value>e.value)||r.issues.push({origin:t,code:"too_small",minimum:typeof e.value=="object"?e.value.getTime():e.value,input:r.value,inclusive:e.inclusive,inst:n,continue:!e.abort})}}),Y$=$("$ZodCheckMultipleOf",(n,e)=>{We.init(n,e),n._zod.onattach.push(t=>{var r;(r=t._zod.bag).multipleOf??(r.multipleOf=e.value)}),n._zod.check=t=>{if(typeof t.value!=typeof e.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof t.value=="bigint"?t.value%e.value===BigInt(0):Q0(t.value,e.value)===0)||t.issues.push({origin:typeof t.value,code:"not_multiple_of",divisor:e.value,input:t.value,inst:n,continue:!e.abort})}}),K$=$("$ZodCheckNumberFormat",(n,e)=>{var o;We.init(n,e),e.format=e.format||"float64";const t=(o=e.format)==null?void 0:o.includes("int"),r=t?"int":"number",[i,s]=i$[e.format];n._zod.onattach.push(a=>{const c=a._zod.bag;c.format=e.format,c.minimum=i,c.maximum=s,t&&(c.pattern=B$)}),n._zod.check=a=>{const c=a.value;if(t){if(!Number.isInteger(c)){a.issues.push({expected:r,format:e.format,code:"invalid_type",continue:!1,input:c,inst:n});return}if(!Number.isSafeInteger(c)){c>0?a.issues.push({input:c,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:n,origin:r,inclusive:!0,continue:!e.abort}):a.issues.push({input:c,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:n,origin:r,inclusive:!0,continue:!e.abort});return}}c<i&&a.issues.push({origin:"number",input:c,code:"too_small",minimum:i,inclusive:!0,inst:n,continue:!e.abort}),c>s&&a.issues.push({origin:"number",input:c,code:"too_big",maximum:s,inclusive:!0,inst:n,continue:!e.abort})}}),J$=$("$ZodCheckMaxLength",(n,e)=>{var t;We.init(n,e),(t=n._zod.def).when??(t.when=r=>{const i=r.value;return!Cu(i)&&i.length!==void 0}),n._zod.onattach.push(r=>{const i=r._zod.bag.maximum??Number.POSITIVE_INFINITY;e.maximum<i&&(r._zod.bag.maximum=e.maximum)}),n._zod.check=r=>{const i=r.value;if(i.length<=e.maximum)return;const o=Pu(i);r.issues.push({origin:o,code:"too_big",maximum:e.maximum,inclusive:!0,input:i,inst:n,continue:!e.abort})}}),X$=$("$ZodCheckMinLength",(n,e)=>{var t;We.init(n,e),(t=n._zod.def).when??(t.when=r=>{const i=r.value;return!Cu(i)&&i.length!==void 0}),n._zod.onattach.push(r=>{const i=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;e.minimum>i&&(r._zod.bag.minimum=e.minimum)}),n._zod.check=r=>{const i=r.value;if(i.length>=e.minimum)return;const o=Pu(i);r.issues.push({origin:o,code:"too_small",minimum:e.minimum,inclusive:!0,input:i,inst:n,continue:!e.abort})}}),Q$=$("$ZodCheckLengthEquals",(n,e)=>{var t;We.init(n,e),(t=n._zod.def).when??(t.when=r=>{const i=r.value;return!Cu(i)&&i.length!==void 0}),n._zod.onattach.push(r=>{const i=r._zod.bag;i.minimum=e.length,i.maximum=e.length,i.length=e.length}),n._zod.check=r=>{const i=r.value,s=i.length;if(s===e.length)return;const o=Pu(i),a=s>e.length;r.issues.push({origin:o,...a?{code:"too_big",maximum:e.length}:{code:"too_small",minimum:e.length},inclusive:!0,exact:!0,input:r.value,inst:n,continue:!e.abort})}}),Na=$("$ZodCheckStringFormat",(n,e)=>{var t,r;We.init(n,e),n._zod.onattach.push(i=>{const s=i._zod.bag;s.format=e.format,e.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(e.pattern))}),e.pattern?(t=n._zod).check??(t.check=i=>{e.pattern.lastIndex=0,!e.pattern.test(i.value)&&i.issues.push({origin:"string",code:"invalid_format",format:e.format,input:i.value,...e.pattern?{pattern:e.pattern.toString()}:{},inst:n,continue:!e.abort})}):(r=n._zod).check??(r.check=()=>{})}),eA=$("$ZodCheckRegex",(n,e)=>{Na.init(n,e),n._zod.check=t=>{e.pattern.lastIndex=0,!e.pattern.test(t.value)&&t.issues.push({origin:"string",code:"invalid_format",format:"regex",input:t.value,pattern:e.pattern.toString(),inst:n,continue:!e.abort})}}),tA=$("$ZodCheckLowerCase",(n,e)=>{e.pattern??(e.pattern=W$),Na.init(n,e)}),nA=$("$ZodCheckUpperCase",(n,e)=>{e.pattern??(e.pattern=q$),Na.init(n,e)}),rA=$("$ZodCheckIncludes",(n,e)=>{We.init(n,e);const t=ei(e.includes),r=new RegExp(typeof e.position=="number"?`^.{${e.position}}${t}`:t);e.pattern=r,n._zod.onattach.push(i=>{const s=i._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(r)}),n._zod.check=i=>{i.value.includes(e.includes,e.position)||i.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:e.includes,input:i.value,inst:n,continue:!e.abort})}}),iA=$("$ZodCheckStartsWith",(n,e)=>{We.init(n,e);const t=new RegExp(`^${ei(e.prefix)}.*`);e.pattern??(e.pattern=t),n._zod.onattach.push(r=>{const i=r._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(t)}),n._zod.check=r=>{r.value.startsWith(e.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:e.prefix,input:r.value,inst:n,continue:!e.abort})}}),sA=$("$ZodCheckEndsWith",(n,e)=>{We.init(n,e);const t=new RegExp(`.*${ei(e.suffix)}$`);e.pattern??(e.pattern=t),n._zod.onattach.push(r=>{const i=r._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(t)}),n._zod.check=r=>{r.value.endsWith(e.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:e.suffix,input:r.value,inst:n,continue:!e.abort})}}),oA=$("$ZodCheckOverwrite",(n,e)=>{We.init(n,e),n._zod.check=t=>{t.value=e.tx(t.value)}});class aA{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if(typeof e=="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}const r=e.split(`
|
|
5
|
+
`).filter(o=>o),i=Math.min(...r.map(o=>o.length-o.trimStart().length)),s=r.map(o=>o.slice(i)).map(o=>" ".repeat(this.indent*2)+o);for(const o of s)this.content.push(o)}compile(){const e=Function,t=this==null?void 0:this.args,i=[...((this==null?void 0:this.content)??[""]).map(s=>` ${s}`)];return new e(...t,i.join(`
|
|
6
|
+
`))}}const lA={major:4,minor:3,patch:6},he=$("$ZodType",(n,e)=>{var i;var t;n??(n={}),n._zod.def=e,n._zod.bag=n._zod.bag||{},n._zod.version=lA;const r=[...n._zod.def.checks??[]];n._zod.traits.has("$ZodCheck")&&r.unshift(n);for(const s of r)for(const o of s._zod.onattach)o(n);if(r.length===0)(t=n._zod).deferred??(t.deferred=[]),(i=n._zod.deferred)==null||i.push(()=>{n._zod.run=n._zod.parse});else{const s=(a,c,u)=>{let d=Cr(a),f;for(const v of c){if(v._zod.def.when){if(!v._zod.def.when(a))continue}else if(d)continue;const y=a.issues.length,A=v._zod.check(a);if(A instanceof Promise&&(u==null?void 0:u.async)===!1)throw new Rr;if(f||A instanceof Promise)f=(f??Promise.resolve()).then(async()=>{await A,a.issues.length!==y&&(d||(d=Cr(a,y)))});else{if(a.issues.length===y)continue;d||(d=Cr(a,y))}}return f?f.then(()=>a):a},o=(a,c,u)=>{if(Cr(a))return a.aborted=!0,a;const d=s(c,r,u);if(d instanceof Promise){if(u.async===!1)throw new Rr;return d.then(f=>n._zod.parse(f,u))}return n._zod.parse(d,u)};n._zod.run=(a,c)=>{if(c.skipChecks)return n._zod.parse(a,c);if(c.direction==="backward"){const d=n._zod.parse({value:a.value,issues:[]},{...c,skipChecks:!0});return d instanceof Promise?d.then(f=>o(f,a,c)):o(d,a,c)}const u=n._zod.parse(a,c);if(u instanceof Promise){if(c.async===!1)throw new Rr;return u.then(d=>s(d,r,c))}return s(u,r,c)}}X(n,"~standard",()=>({validate:s=>{var o;try{const a=p$(n,s);return a.success?{value:a.data}:{issues:(o=a.error)==null?void 0:o.issues}}catch{return g$(n,s).then(c=>{var u;return c.success?{value:c.data}:{issues:(u=c.error)==null?void 0:u.issues}})}},vendor:"zod",version:1}))}),Ou=$("$ZodString",(n,e)=>{var t;he.init(n,e),n._zod.pattern=[...((t=n==null?void 0:n._zod.bag)==null?void 0:t.patterns)??[]].pop()??j$(n._zod.bag),n._zod.parse=(r,i)=>{if(e.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:n}),r}}),ae=$("$ZodStringFormat",(n,e)=>{Na.init(n,e),Ou.init(n,e)}),cA=$("$ZodGUID",(n,e)=>{e.pattern??(e.pattern=P$),ae.init(n,e)}),uA=$("$ZodUUID",(n,e)=>{if(e.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[e.version];if(r===void 0)throw new Error(`Invalid UUID version: "${e.version}"`);e.pattern??(e.pattern=rf(r))}else e.pattern??(e.pattern=rf());ae.init(n,e)}),hA=$("$ZodEmail",(n,e)=>{e.pattern??(e.pattern=R$),ae.init(n,e)}),dA=$("$ZodURL",(n,e)=>{ae.init(n,e),n._zod.check=t=>{try{const r=t.value.trim(),i=new URL(r);e.hostname&&(e.hostname.lastIndex=0,e.hostname.test(i.hostname)||t.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:e.hostname.source,input:t.value,inst:n,continue:!e.abort})),e.protocol&&(e.protocol.lastIndex=0,e.protocol.test(i.protocol.endsWith(":")?i.protocol.slice(0,-1):i.protocol)||t.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:e.protocol.source,input:t.value,inst:n,continue:!e.abort})),e.normalize?t.value=i.href:t.value=r;return}catch{t.issues.push({code:"invalid_format",format:"url",input:t.value,inst:n,continue:!e.abort})}}}),fA=$("$ZodEmoji",(n,e)=>{e.pattern??(e.pattern=O$()),ae.init(n,e)}),pA=$("$ZodNanoID",(n,e)=>{e.pattern??(e.pattern=C$),ae.init(n,e)}),gA=$("$ZodCUID",(n,e)=>{e.pattern??(e.pattern=E$),ae.init(n,e)}),mA=$("$ZodCUID2",(n,e)=>{e.pattern??(e.pattern=$$),ae.init(n,e)}),yA=$("$ZodULID",(n,e)=>{e.pattern??(e.pattern=A$),ae.init(n,e)}),vA=$("$ZodXID",(n,e)=>{e.pattern??(e.pattern=x$),ae.init(n,e)}),bA=$("$ZodKSUID",(n,e)=>{e.pattern??(e.pattern=T$),ae.init(n,e)}),wA=$("$ZodISODateTime",(n,e)=>{e.pattern??(e.pattern=V$(e)),ae.init(n,e)}),_A=$("$ZodISODate",(n,e)=>{e.pattern??(e.pattern=Z$),ae.init(n,e)}),SA=$("$ZodISOTime",(n,e)=>{e.pattern??(e.pattern=H$(e)),ae.init(n,e)}),kA=$("$ZodISODuration",(n,e)=>{e.pattern??(e.pattern=I$),ae.init(n,e)}),EA=$("$ZodIPv4",(n,e)=>{e.pattern??(e.pattern=z$),ae.init(n,e),n._zod.bag.format="ipv4"}),$A=$("$ZodIPv6",(n,e)=>{e.pattern??(e.pattern=L$),ae.init(n,e),n._zod.bag.format="ipv6",n._zod.check=t=>{try{new URL(`http://[${t.value}]`)}catch{t.issues.push({code:"invalid_format",format:"ipv6",input:t.value,inst:n,continue:!e.abort})}}}),AA=$("$ZodCIDRv4",(n,e)=>{e.pattern??(e.pattern=M$),ae.init(n,e)}),xA=$("$ZodCIDRv6",(n,e)=>{e.pattern??(e.pattern=N$),ae.init(n,e),n._zod.check=t=>{const r=t.value.split("/");try{if(r.length!==2)throw new Error;const[i,s]=r;if(!s)throw new Error;const o=Number(s);if(`${o}`!==s)throw new Error;if(o<0||o>128)throw new Error;new URL(`http://[${i}]`)}catch{t.issues.push({code:"invalid_format",format:"cidrv6",input:t.value,inst:n,continue:!e.abort})}}});function Xg(n){if(n==="")return!0;if(n.length%4!==0)return!1;try{return atob(n),!0}catch{return!1}}const TA=$("$ZodBase64",(n,e)=>{e.pattern??(e.pattern=U$),ae.init(n,e),n._zod.bag.contentEncoding="base64",n._zod.check=t=>{Xg(t.value)||t.issues.push({code:"invalid_format",format:"base64",input:t.value,inst:n,continue:!e.abort})}});function CA(n){if(!Bg.test(n))return!1;const e=n.replace(/[-_]/g,r=>r==="-"?"+":"/"),t=e.padEnd(Math.ceil(e.length/4)*4,"=");return Xg(t)}const IA=$("$ZodBase64URL",(n,e)=>{e.pattern??(e.pattern=Bg),ae.init(n,e),n._zod.bag.contentEncoding="base64url",n._zod.check=t=>{CA(t.value)||t.issues.push({code:"invalid_format",format:"base64url",input:t.value,inst:n,continue:!e.abort})}}),PA=$("$ZodE164",(n,e)=>{e.pattern??(e.pattern=F$),ae.init(n,e)});function RA(n,e=null){try{const t=n.split(".");if(t.length!==3)return!1;const[r]=t;if(!r)return!1;const i=JSON.parse(atob(r));return!("typ"in i&&(i==null?void 0:i.typ)!=="JWT"||!i.alg||e&&(!("alg"in i)||i.alg!==e))}catch{return!1}}const DA=$("$ZodJWT",(n,e)=>{ae.init(n,e),n._zod.check=t=>{RA(t.value,e.alg)||t.issues.push({code:"invalid_format",format:"jwt",input:t.value,inst:n,continue:!e.abort})}}),Qg=$("$ZodNumber",(n,e)=>{he.init(n,e),n._zod.pattern=n._zod.bag.pattern??qg,n._zod.parse=(t,r)=>{if(e.coerce)try{t.value=Number(t.value)}catch{}const i=t.value;if(typeof i=="number"&&!Number.isNaN(i)&&Number.isFinite(i))return t;const s=typeof i=="number"?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:"Infinity":void 0;return t.issues.push({expected:"number",code:"invalid_type",input:i,inst:n,...s?{received:s}:{}}),t}}),OA=$("$ZodNumberFormat",(n,e)=>{K$.init(n,e),Qg.init(n,e)}),zA=$("$ZodBoolean",(n,e)=>{he.init(n,e),n._zod.pattern=G$,n._zod.parse=(t,r)=>{if(e.coerce)try{t.value=!!t.value}catch{}const i=t.value;return typeof i=="boolean"||t.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:n}),t}}),LA=$("$ZodUnknown",(n,e)=>{he.init(n,e),n._zod.parse=t=>t}),MA=$("$ZodNever",(n,e)=>{he.init(n,e),n._zod.parse=(t,r)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:n}),t)});function sf(n,e,t){n.issues.length&&e.issues.push(...Ir(t,n.issues)),e.value[t]=n.value}const NA=$("$ZodArray",(n,e)=>{he.init(n,e),n._zod.parse=(t,r)=>{const i=t.value;if(!Array.isArray(i))return t.issues.push({expected:"array",code:"invalid_type",input:i,inst:n}),t;t.value=Array(i.length);const s=[];for(let o=0;o<i.length;o++){const a=i[o],c=e.element._zod.run({value:a,issues:[]},r);c instanceof Promise?s.push(c.then(u=>sf(u,t,o))):sf(c,t,o)}return s.length?Promise.all(s).then(()=>t):t}});function ea(n,e,t,r,i){if(n.issues.length){if(i&&!(t in r))return;e.issues.push(...Ir(t,n.issues))}n.value===void 0?t in r&&(e.value[t]=void 0):e.value[t]=n.value}function em(n){var r,i,s,o;const e=Object.keys(n.shape);for(const a of e)if(!((o=(s=(i=(r=n.shape)==null?void 0:r[a])==null?void 0:i._zod)==null?void 0:s.traits)!=null&&o.has("$ZodType")))throw new Error(`Invalid element at key "${a}": expected a Zod schema`);const t=r$(n.shape);return{...n,keys:e,keySet:new Set(e),numKeys:e.length,optionalKeys:new Set(t)}}function tm(n,e,t,r,i,s){const o=[],a=i.keySet,c=i.catchall._zod,u=c.def.type,d=c.optout==="optional";for(const f in e){if(a.has(f))continue;if(u==="never"){o.push(f);continue}const v=c.run({value:e[f],issues:[]},r);v instanceof Promise?n.push(v.then(y=>ea(y,t,f,e,d))):ea(v,t,f,e,d)}return o.length&&t.issues.push({code:"unrecognized_keys",keys:o,input:e,inst:s}),n.length?Promise.all(n).then(()=>t):t}const UA=$("$ZodObject",(n,e)=>{he.init(n,e);const t=Object.getOwnPropertyDescriptor(e,"shape");if(!(t!=null&&t.get)){const a=e.shape;Object.defineProperty(e,"shape",{get:()=>{const c={...a};return Object.defineProperty(e,"shape",{value:c}),c}})}const r=Tu(()=>em(e));X(n._zod,"propValues",()=>{const a=e.shape,c={};for(const u in a){const d=a[u]._zod;if(d.values){c[u]??(c[u]=new Set);for(const f of d.values)c[u].add(f)}}return c});const i=Qo,s=e.catchall;let o;n._zod.parse=(a,c)=>{o??(o=r.value);const u=a.value;if(!i(u))return a.issues.push({expected:"object",code:"invalid_type",input:u,inst:n}),a;a.value={};const d=[],f=o.shape;for(const v of o.keys){const y=f[v],A=y._zod.optout==="optional",k=y._zod.run({value:u[v],issues:[]},c);k instanceof Promise?d.push(k.then(I=>ea(I,a,v,u,A))):ea(k,a,v,u,A)}return s?tm(d,u,a,c,r.value,n):d.length?Promise.all(d).then(()=>a):a}}),FA=$("$ZodObjectJIT",(n,e)=>{UA.init(n,e);const t=n._zod.parse,r=Tu(()=>em(e)),i=v=>{var le;const y=new aA(["shape","payload","ctx"]),A=r.value,k=M=>{const Z=nf(M);return`shape[${Z}]._zod.run({ value: input[${Z}], issues: [] }, ctx)`};y.write("const input = payload.value;");const I=Object.create(null);let B=0;for(const M of A.keys)I[M]=`key_${B++}`;y.write("const newResult = {};");for(const M of A.keys){const Z=I[M],U=nf(M),ge=v[M],ce=((le=ge==null?void 0:ge._zod)==null?void 0:le.optout)==="optional";y.write(`const ${Z} = ${k(M)};`),ce?y.write(`
|
|
7
|
+
if (${Z}.issues.length) {
|
|
8
|
+
if (${U} in input) {
|
|
9
|
+
payload.issues = payload.issues.concat(${Z}.issues.map(iss => ({
|
|
10
|
+
...iss,
|
|
11
|
+
path: iss.path ? [${U}, ...iss.path] : [${U}]
|
|
12
|
+
})));
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
if (${Z}.value === undefined) {
|
|
17
|
+
if (${U} in input) {
|
|
18
|
+
newResult[${U}] = undefined;
|
|
19
|
+
}
|
|
20
|
+
} else {
|
|
21
|
+
newResult[${U}] = ${Z}.value;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
`):y.write(`
|
|
25
|
+
if (${Z}.issues.length) {
|
|
26
|
+
payload.issues = payload.issues.concat(${Z}.issues.map(iss => ({
|
|
27
|
+
...iss,
|
|
28
|
+
path: iss.path ? [${U}, ...iss.path] : [${U}]
|
|
29
|
+
})));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (${Z}.value === undefined) {
|
|
33
|
+
if (${U} in input) {
|
|
34
|
+
newResult[${U}] = undefined;
|
|
35
|
+
}
|
|
36
|
+
} else {
|
|
37
|
+
newResult[${U}] = ${Z}.value;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
`)}y.write("payload.value = newResult;"),y.write("return payload;");const P=y.compile();return(M,Z)=>P(v,M,Z)};let s;const o=Qo,a=!Ng.jitless,u=a&&t$.value,d=e.catchall;let f;n._zod.parse=(v,y)=>{f??(f=r.value);const A=v.value;return o(A)?a&&u&&(y==null?void 0:y.async)===!1&&y.jitless!==!0?(s||(s=i(e.shape)),v=s(v,y),d?tm([],A,v,y,f,n):v):t(v,y):(v.issues.push({expected:"object",code:"invalid_type",input:A,inst:n}),v)}});function of(n,e,t,r){for(const s of n)if(s.issues.length===0)return e.value=s.value,e;const i=n.filter(s=>!Cr(s));return i.length===1?(e.value=i[0].value,i[0]):(e.issues.push({code:"invalid_union",input:e.value,inst:t,errors:n.map(s=>s.issues.map(o=>gn(o,r,pn())))}),e)}const ZA=$("$ZodUnion",(n,e)=>{he.init(n,e),X(n._zod,"optin",()=>e.options.some(i=>i._zod.optin==="optional")?"optional":void 0),X(n._zod,"optout",()=>e.options.some(i=>i._zod.optout==="optional")?"optional":void 0),X(n._zod,"values",()=>{if(e.options.every(i=>i._zod.values))return new Set(e.options.flatMap(i=>Array.from(i._zod.values)))}),X(n._zod,"pattern",()=>{if(e.options.every(i=>i._zod.pattern)){const i=e.options.map(s=>s._zod.pattern);return new RegExp(`^(${i.map(s=>Iu(s.source)).join("|")})$`)}});const t=e.options.length===1,r=e.options[0]._zod.run;n._zod.parse=(i,s)=>{if(t)return r(i,s);let o=!1;const a=[];for(const c of e.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=>of(c,i,n,s)):of(a,i,n,s)}}),HA=$("$ZodIntersection",(n,e)=>{he.init(n,e),n._zod.parse=(t,r)=>{const i=t.value,s=e.left._zod.run({value:i,issues:[]},r),o=e.right._zod.run({value:i,issues:[]},r);return s instanceof Promise||o instanceof Promise?Promise.all([s,o]).then(([c,u])=>af(t,c,u)):af(t,s,o)}});function fc(n,e){if(n===e)return{valid:!0,data:n};if(n instanceof Date&&e instanceof Date&&+n==+e)return{valid:!0,data:n};if(Qr(n)&&Qr(e)){const t=Object.keys(e),r=Object.keys(n).filter(s=>t.indexOf(s)!==-1),i={...n,...e};for(const s of r){const o=fc(n[s],e[s]);if(!o.valid)return{valid:!1,mergeErrorPath:[s,...o.mergeErrorPath]};i[s]=o.data}return{valid:!0,data:i}}if(Array.isArray(n)&&Array.isArray(e)){if(n.length!==e.length)return{valid:!1,mergeErrorPath:[]};const t=[];for(let r=0;r<n.length;r++){const i=n[r],s=e[r],o=fc(i,s);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};t.push(o.data)}return{valid:!0,data:t}}return{valid:!1,mergeErrorPath:[]}}function af(n,e,t){const r=new Map;let i;for(const a of e.issues)if(a.code==="unrecognized_keys"){i??(i=a);for(const c of a.keys)r.has(c)||r.set(c,{}),r.get(c).l=!0}else n.issues.push(a);for(const a of t.issues)if(a.code==="unrecognized_keys")for(const c of a.keys)r.has(c)||r.set(c,{}),r.get(c).r=!0;else n.issues.push(a);const s=[...r].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(s.length&&i&&n.issues.push({...i,keys:s}),Cr(n))return n;const o=fc(e.value,t.value);if(!o.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return n.value=o.data,n}const VA=$("$ZodRecord",(n,e)=>{he.init(n,e),n._zod.parse=(t,r)=>{const i=t.value;if(!Qr(i))return t.issues.push({expected:"record",code:"invalid_type",input:i,inst:n}),t;const s=[],o=e.keyType._zod.values;if(o){t.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 d=e.valueType._zod.run({value:i[u],issues:[]},r);d instanceof Promise?s.push(d.then(f=>{f.issues.length&&t.issues.push(...Ir(u,f.issues)),t.value[u]=f.value})):(d.issues.length&&t.issues.push(...Ir(u,d.issues)),t.value[u]=d.value)}let c;for(const u in i)a.has(u)||(c=c??[],c.push(u));c&&c.length>0&&t.issues.push({code:"unrecognized_keys",input:i,inst:n,keys:c})}else{t.value={};for(const a of Reflect.ownKeys(i)){if(a==="__proto__")continue;let c=e.keyType._zod.run({value:a,issues:[]},r);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof a=="string"&&qg.test(a)&&c.issues.length){const f=e.keyType._zod.run({value:Number(a),issues:[]},r);if(f instanceof Promise)throw new Error("Async schemas not supported in object keys currently");f.issues.length===0&&(c=f)}if(c.issues.length){e.mode==="loose"?t.value[a]=i[a]:t.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(f=>gn(f,r,pn())),input:a,path:[a],inst:n});continue}const d=e.valueType._zod.run({value:i[a],issues:[]},r);d instanceof Promise?s.push(d.then(f=>{f.issues.length&&t.issues.push(...Ir(a,f.issues)),t.value[c.value]=f.value})):(d.issues.length&&t.issues.push(...Ir(a,d.issues)),t.value[c.value]=d.value)}}return s.length?Promise.all(s).then(()=>t):t}}),jA=$("$ZodEnum",(n,e)=>{he.init(n,e);const t=Ug(e.entries),r=new Set(t);n._zod.values=r,n._zod.pattern=new RegExp(`^(${t.filter(i=>n$.has(typeof i)).map(i=>typeof i=="string"?ei(i):i.toString()).join("|")})$`),n._zod.parse=(i,s)=>{const o=i.value;return r.has(o)||i.issues.push({code:"invalid_value",values:t,input:o,inst:n}),i}}),BA=$("$ZodLiteral",(n,e)=>{if(he.init(n,e),e.values.length===0)throw new Error("Cannot create literal schema with no valid values");const t=new Set(e.values);n._zod.values=t,n._zod.pattern=new RegExp(`^(${e.values.map(r=>typeof r=="string"?ei(r):r?ei(r.toString()):String(r)).join("|")})$`),n._zod.parse=(r,i)=>{const s=r.value;return t.has(s)||r.issues.push({code:"invalid_value",values:e.values,input:s,inst:n}),r}}),GA=$("$ZodTransform",(n,e)=>{he.init(n,e),n._zod.parse=(t,r)=>{if(r.direction==="backward")throw new Mg(n.constructor.name);const i=e.transform(t.value,t);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(o=>(t.value=o,t));if(i instanceof Promise)throw new Rr;return t.value=i,t}});function lf(n,e){return n.issues.length&&e===void 0?{issues:[],value:void 0}:n}const nm=$("$ZodOptional",(n,e)=>{he.init(n,e),n._zod.optin="optional",n._zod.optout="optional",X(n._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,void 0]):void 0),X(n._zod,"pattern",()=>{const t=e.innerType._zod.pattern;return t?new RegExp(`^(${Iu(t.source)})?$`):void 0}),n._zod.parse=(t,r)=>{if(e.innerType._zod.optin==="optional"){const i=e.innerType._zod.run(t,r);return i instanceof Promise?i.then(s=>lf(s,t.value)):lf(i,t.value)}return t.value===void 0?t:e.innerType._zod.run(t,r)}}),WA=$("$ZodExactOptional",(n,e)=>{nm.init(n,e),X(n._zod,"values",()=>e.innerType._zod.values),X(n._zod,"pattern",()=>e.innerType._zod.pattern),n._zod.parse=(t,r)=>e.innerType._zod.run(t,r)}),qA=$("$ZodNullable",(n,e)=>{he.init(n,e),X(n._zod,"optin",()=>e.innerType._zod.optin),X(n._zod,"optout",()=>e.innerType._zod.optout),X(n._zod,"pattern",()=>{const t=e.innerType._zod.pattern;return t?new RegExp(`^(${Iu(t.source)}|null)$`):void 0}),X(n._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,null]):void 0),n._zod.parse=(t,r)=>t.value===null?t:e.innerType._zod.run(t,r)}),YA=$("$ZodDefault",(n,e)=>{he.init(n,e),n._zod.optin="optional",X(n._zod,"values",()=>e.innerType._zod.values),n._zod.parse=(t,r)=>{if(r.direction==="backward")return e.innerType._zod.run(t,r);if(t.value===void 0)return t.value=e.defaultValue,t;const i=e.innerType._zod.run(t,r);return i instanceof Promise?i.then(s=>cf(s,e)):cf(i,e)}});function cf(n,e){return n.value===void 0&&(n.value=e.defaultValue),n}const KA=$("$ZodPrefault",(n,e)=>{he.init(n,e),n._zod.optin="optional",X(n._zod,"values",()=>e.innerType._zod.values),n._zod.parse=(t,r)=>(r.direction==="backward"||t.value===void 0&&(t.value=e.defaultValue),e.innerType._zod.run(t,r))}),JA=$("$ZodNonOptional",(n,e)=>{he.init(n,e),X(n._zod,"values",()=>{const t=e.innerType._zod.values;return t?new Set([...t].filter(r=>r!==void 0)):void 0}),n._zod.parse=(t,r)=>{const i=e.innerType._zod.run(t,r);return i instanceof Promise?i.then(s=>uf(s,n)):uf(i,n)}});function uf(n,e){return!n.issues.length&&n.value===void 0&&n.issues.push({code:"invalid_type",expected:"nonoptional",input:n.value,inst:e}),n}const XA=$("$ZodCatch",(n,e)=>{he.init(n,e),X(n._zod,"optin",()=>e.innerType._zod.optin),X(n._zod,"optout",()=>e.innerType._zod.optout),X(n._zod,"values",()=>e.innerType._zod.values),n._zod.parse=(t,r)=>{if(r.direction==="backward")return e.innerType._zod.run(t,r);const i=e.innerType._zod.run(t,r);return i instanceof Promise?i.then(s=>(t.value=s.value,s.issues.length&&(t.value=e.catchValue({...t,error:{issues:s.issues.map(o=>gn(o,r,pn()))},input:t.value}),t.issues=[]),t)):(t.value=i.value,i.issues.length&&(t.value=e.catchValue({...t,error:{issues:i.issues.map(s=>gn(s,r,pn()))},input:t.value}),t.issues=[]),t)}}),QA=$("$ZodPipe",(n,e)=>{he.init(n,e),X(n._zod,"values",()=>e.in._zod.values),X(n._zod,"optin",()=>e.in._zod.optin),X(n._zod,"optout",()=>e.out._zod.optout),X(n._zod,"propValues",()=>e.in._zod.propValues),n._zod.parse=(t,r)=>{if(r.direction==="backward"){const s=e.out._zod.run(t,r);return s instanceof Promise?s.then(o=>wo(o,e.in,r)):wo(s,e.in,r)}const i=e.in._zod.run(t,r);return i instanceof Promise?i.then(s=>wo(s,e.out,r)):wo(i,e.out,r)}});function wo(n,e,t){return n.issues.length?(n.aborted=!0,n):e._zod.run({value:n.value,issues:n.issues},t)}const ex=$("$ZodReadonly",(n,e)=>{he.init(n,e),X(n._zod,"propValues",()=>e.innerType._zod.propValues),X(n._zod,"values",()=>e.innerType._zod.values),X(n._zod,"optin",()=>{var t,r;return(r=(t=e.innerType)==null?void 0:t._zod)==null?void 0:r.optin}),X(n._zod,"optout",()=>{var t,r;return(r=(t=e.innerType)==null?void 0:t._zod)==null?void 0:r.optout}),n._zod.parse=(t,r)=>{if(r.direction==="backward")return e.innerType._zod.run(t,r);const i=e.innerType._zod.run(t,r);return i instanceof Promise?i.then(hf):hf(i)}});function hf(n){return n.value=Object.freeze(n.value),n}const tx=$("$ZodCustom",(n,e)=>{We.init(n,e),he.init(n,e),n._zod.parse=(t,r)=>t,n._zod.check=t=>{const r=t.value,i=e.fn(r);if(i instanceof Promise)return i.then(s=>df(s,t,r,n));df(i,t,r,n)}});function df(n,e,t,r){if(!n){const i={code:"custom",input:t,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(i.params=r._zod.def.params),e.issues.push(Ji(i))}}var ff;class nx{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){const r=t[0];return this._map.set(e,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){const t=this._map.get(e);return t&&typeof t=="object"&&"id"in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){const t=e._zod.parent;if(t){const r={...this.get(t)??{}};delete r.id;const i={...r,...this._map.get(e)};return Object.keys(i).length?i:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function rx(){return new nx}(ff=globalThis).__zod_globalRegistry??(ff.__zod_globalRegistry=rx());const zi=globalThis.__zod_globalRegistry;function ix(n,e){return new n({type:"string",...O(e)})}function sx(n,e){return new n({type:"string",format:"email",check:"string_format",abort:!1,...O(e)})}function pf(n,e){return new n({type:"string",format:"guid",check:"string_format",abort:!1,...O(e)})}function ox(n,e){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,...O(e)})}function ax(n,e){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...O(e)})}function lx(n,e){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...O(e)})}function cx(n,e){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...O(e)})}function ux(n,e){return new n({type:"string",format:"url",check:"string_format",abort:!1,...O(e)})}function hx(n,e){return new n({type:"string",format:"emoji",check:"string_format",abort:!1,...O(e)})}function dx(n,e){return new n({type:"string",format:"nanoid",check:"string_format",abort:!1,...O(e)})}function fx(n,e){return new n({type:"string",format:"cuid",check:"string_format",abort:!1,...O(e)})}function px(n,e){return new n({type:"string",format:"cuid2",check:"string_format",abort:!1,...O(e)})}function gx(n,e){return new n({type:"string",format:"ulid",check:"string_format",abort:!1,...O(e)})}function mx(n,e){return new n({type:"string",format:"xid",check:"string_format",abort:!1,...O(e)})}function yx(n,e){return new n({type:"string",format:"ksuid",check:"string_format",abort:!1,...O(e)})}function vx(n,e){return new n({type:"string",format:"ipv4",check:"string_format",abort:!1,...O(e)})}function bx(n,e){return new n({type:"string",format:"ipv6",check:"string_format",abort:!1,...O(e)})}function wx(n,e){return new n({type:"string",format:"cidrv4",check:"string_format",abort:!1,...O(e)})}function _x(n,e){return new n({type:"string",format:"cidrv6",check:"string_format",abort:!1,...O(e)})}function Sx(n,e){return new n({type:"string",format:"base64",check:"string_format",abort:!1,...O(e)})}function kx(n,e){return new n({type:"string",format:"base64url",check:"string_format",abort:!1,...O(e)})}function Ex(n,e){return new n({type:"string",format:"e164",check:"string_format",abort:!1,...O(e)})}function $x(n,e){return new n({type:"string",format:"jwt",check:"string_format",abort:!1,...O(e)})}function Ax(n,e){return new n({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...O(e)})}function xx(n,e){return new n({type:"string",format:"date",check:"string_format",...O(e)})}function Tx(n,e){return new n({type:"string",format:"time",check:"string_format",precision:null,...O(e)})}function Cx(n,e){return new n({type:"string",format:"duration",check:"string_format",...O(e)})}function Ix(n,e){return new n({type:"number",checks:[],...O(e)})}function Px(n,e){return new n({type:"number",check:"number_format",abort:!1,format:"safeint",...O(e)})}function Rx(n,e){return new n({type:"boolean",...O(e)})}function Dx(n){return new n({type:"unknown"})}function Ox(n,e){return new n({type:"never",...O(e)})}function gf(n,e){return new Kg({check:"less_than",...O(e),value:n,inclusive:!1})}function Dl(n,e){return new Kg({check:"less_than",...O(e),value:n,inclusive:!0})}function mf(n,e){return new Jg({check:"greater_than",...O(e),value:n,inclusive:!1})}function Ol(n,e){return new Jg({check:"greater_than",...O(e),value:n,inclusive:!0})}function yf(n,e){return new Y$({check:"multiple_of",...O(e),value:n})}function rm(n,e){return new J$({check:"max_length",...O(e),maximum:n})}function ta(n,e){return new X$({check:"min_length",...O(e),minimum:n})}function im(n,e){return new Q$({check:"length_equals",...O(e),length:n})}function zx(n,e){return new eA({check:"string_format",format:"regex",...O(e),pattern:n})}function Lx(n){return new tA({check:"string_format",format:"lowercase",...O(n)})}function Mx(n){return new nA({check:"string_format",format:"uppercase",...O(n)})}function Nx(n,e){return new rA({check:"string_format",format:"includes",...O(e),includes:n})}function Ux(n,e){return new iA({check:"string_format",format:"starts_with",...O(e),prefix:n})}function Fx(n,e){return new sA({check:"string_format",format:"ends_with",...O(e),suffix:n})}function fi(n){return new oA({check:"overwrite",tx:n})}function Zx(n){return fi(e=>e.normalize(n))}function Hx(){return fi(n=>n.trim())}function Vx(){return fi(n=>n.toLowerCase())}function jx(){return fi(n=>n.toUpperCase())}function Bx(){return fi(n=>e$(n))}function Gx(n,e,t){return new n({type:"array",element:e,...O(t)})}function Wx(n,e,t){return new n({type:"custom",check:"custom",fn:e,...O(t)})}function qx(n){const e=Yx(t=>(t.addIssue=r=>{if(typeof r=="string")t.issues.push(Ji(r,t.value,e._zod.def));else{const i=r;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=t.value),i.inst??(i.inst=e),i.continue??(i.continue=!e._zod.def.abort),t.issues.push(Ji(i))}},n(t.value,t)));return e}function Yx(n,e){const t=new We({check:"custom",...O(e)});return t._zod.check=n,t}function sm(n){let e=(n==null?void 0:n.target)??"draft-2020-12";return e==="draft-4"&&(e="draft-04"),e==="draft-7"&&(e="draft-07"),{processors:n.processors??{},metadataRegistry:(n==null?void 0:n.metadata)??zi,target:e,unrepresentable:(n==null?void 0:n.unrepresentable)??"throw",override:(n==null?void 0:n.override)??(()=>{}),io:(n==null?void 0:n.io)??"output",counter:0,seen:new Map,cycles:(n==null?void 0:n.cycles)??"ref",reused:(n==null?void 0:n.reused)??"inline",external:(n==null?void 0:n.external)??void 0}}function ve(n,e,t={path:[],schemaPath:[]}){var d,f;var r;const i=n._zod.def,s=e.seen.get(n);if(s)return s.count++,t.schemaPath.includes(n)&&(s.cycle=t.path),s.schema;const o={schema:{},count:1,cycle:void 0,path:t.path};e.seen.set(n,o);const a=(f=(d=n._zod).toJSONSchema)==null?void 0:f.call(d);if(a)o.schema=a;else{const v={...t,schemaPath:[...t.schemaPath,n],path:t.path};if(n._zod.processJSONSchema)n._zod.processJSONSchema(e,o.schema,v);else{const A=o.schema,k=e.processors[i.type];if(!k)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);k(n,e,A,v)}const y=n._zod.parent;y&&(o.ref||(o.ref=y),ve(y,e,v),e.seen.get(y).isParent=!0)}const c=e.metadataRegistry.get(n);return c&&Object.assign(o.schema,c),e.io==="input"&&Oe(n)&&(delete o.schema.examples,delete o.schema.default),e.io==="input"&&o.schema._prefault&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,e.seen.get(n).schema}function om(n,e){var o,a,c,u;const t=n.seen.get(e);if(!t)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=new Map;for(const d of n.seen.entries()){const f=(o=n.metadataRegistry.get(d[0]))==null?void 0:o.id;if(f){const v=r.get(f);if(v&&v!==d[0])throw new Error(`Duplicate schema id "${f}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(f,d[0])}}const i=d=>{var k;const f=n.target==="draft-2020-12"?"$defs":"definitions";if(n.external){const I=(k=n.external.registry.get(d[0]))==null?void 0:k.id,B=n.external.uri??(le=>le);if(I)return{ref:B(I)};const P=d[1].defId??d[1].schema.id??`schema${n.counter++}`;return d[1].defId=P,{defId:P,ref:`${B("__shared")}#/${f}/${P}`}}if(d[1]===t)return{ref:"#"};const y=`#/${f}/`,A=d[1].schema.id??`__schema${n.counter++}`;return{defId:A,ref:y+A}},s=d=>{if(d[1].schema.$ref)return;const f=d[1],{ref:v,defId:y}=i(d);f.def={...f.schema},y&&(f.defId=y);const A=f.schema;for(const k in A)delete A[k];A.$ref=v};if(n.cycles==="throw")for(const d of n.seen.entries()){const f=d[1];if(f.cycle)throw new Error(`Cycle detected: #/${(a=f.cycle)==null?void 0:a.join("/")}/<root>
|
|
41
|
+
|
|
42
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const d of n.seen.entries()){const f=d[1];if(e===d[0]){s(d);continue}if(n.external){const y=(c=n.external.registry.get(d[0]))==null?void 0:c.id;if(e!==d[0]&&y){s(d);continue}}if((u=n.metadataRegistry.get(d[0]))==null?void 0:u.id){s(d);continue}if(f.cycle){s(d);continue}if(f.count>1&&n.reused==="ref"){s(d);continue}}}function am(n,e){var o,a,c;const t=n.seen.get(e);if(!t)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=u=>{const d=n.seen.get(u);if(d.ref===null)return;const f=d.def??d.schema,v={...f},y=d.ref;if(d.ref=null,y){r(y);const k=n.seen.get(y),I=k.schema;if(I.$ref&&(n.target==="draft-07"||n.target==="draft-04"||n.target==="openapi-3.0")?(f.allOf=f.allOf??[],f.allOf.push(I)):Object.assign(f,I),Object.assign(f,v),u._zod.parent===y)for(const P in f)P==="$ref"||P==="allOf"||P in v||delete f[P];if(I.$ref&&k.def)for(const P in f)P==="$ref"||P==="allOf"||P in k.def&&JSON.stringify(f[P])===JSON.stringify(k.def[P])&&delete f[P]}const A=u._zod.parent;if(A&&A!==y){r(A);const k=n.seen.get(A);if(k!=null&&k.schema.$ref&&(f.$ref=k.schema.$ref,k.def))for(const I in f)I==="$ref"||I==="allOf"||I in k.def&&JSON.stringify(f[I])===JSON.stringify(k.def[I])&&delete f[I]}n.override({zodSchema:u,jsonSchema:f,path:d.path??[]})};for(const u of[...n.seen.entries()].reverse())r(u[0]);const i={};if(n.target==="draft-2020-12"?i.$schema="https://json-schema.org/draft/2020-12/schema":n.target==="draft-07"?i.$schema="http://json-schema.org/draft-07/schema#":n.target==="draft-04"?i.$schema="http://json-schema.org/draft-04/schema#":n.target,(o=n.external)!=null&&o.uri){const u=(a=n.external.registry.get(e))==null?void 0:a.id;if(!u)throw new Error("Schema is missing an `id` property");i.$id=n.external.uri(u)}Object.assign(i,t.def??t.schema);const s=((c=n.external)==null?void 0:c.defs)??{};for(const u of n.seen.entries()){const d=u[1];d.def&&d.defId&&(s[d.defId]=d.def)}n.external||Object.keys(s).length>0&&(n.target==="draft-2020-12"?i.$defs=s:i.definitions=s);try{const u=JSON.parse(JSON.stringify(i));return Object.defineProperty(u,"~standard",{value:{...e["~standard"],jsonSchema:{input:na(e,"input",n.processors),output:na(e,"output",n.processors)}},enumerable:!1,writable:!1}),u}catch{throw new Error("Error converting schema to JSON.")}}function Oe(n,e){const t=e??{seen:new Set};if(t.seen.has(n))return!1;t.seen.add(n);const r=n._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return Oe(r.element,t);if(r.type==="set")return Oe(r.valueType,t);if(r.type==="lazy")return Oe(r.getter(),t);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault")return Oe(r.innerType,t);if(r.type==="intersection")return Oe(r.left,t)||Oe(r.right,t);if(r.type==="record"||r.type==="map")return Oe(r.keyType,t)||Oe(r.valueType,t);if(r.type==="pipe")return Oe(r.in,t)||Oe(r.out,t);if(r.type==="object"){for(const i in r.shape)if(Oe(r.shape[i],t))return!0;return!1}if(r.type==="union"){for(const i of r.options)if(Oe(i,t))return!0;return!1}if(r.type==="tuple"){for(const i of r.items)if(Oe(i,t))return!0;return!!(r.rest&&Oe(r.rest,t))}return!1}const Kx=(n,e={})=>t=>{const r=sm({...t,processors:e});return ve(n,r),om(r,n),am(r,n)},na=(n,e,t={})=>r=>{const{libraryOptions:i,target:s}=r??{},o=sm({...i??{},target:s,io:e,processors:t});return ve(n,o),om(o,n),am(o,n)},Jx={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Xx=(n,e,t,r)=>{const i=t;i.type="string";const{minimum:s,maximum:o,format:a,patterns:c,contentEncoding:u}=n._zod.bag;if(typeof s=="number"&&(i.minLength=s),typeof o=="number"&&(i.maxLength=o),a&&(i.format=Jx[a]??a,i.format===""&&delete i.format,a==="time"&&delete i.format),u&&(i.contentEncoding=u),c&&c.size>0){const d=[...c];d.length===1?i.pattern=d[0].source:d.length>1&&(i.allOf=[...d.map(f=>({...e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"?{type:"string"}:{},pattern:f.source}))])}},Qx=(n,e,t,r)=>{const i=t,{minimum:s,maximum:o,format:a,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:d}=n._zod.bag;typeof a=="string"&&a.includes("int")?i.type="integer":i.type="number",typeof d=="number"&&(e.target==="draft-04"||e.target==="openapi-3.0"?(i.minimum=d,i.exclusiveMinimum=!0):i.exclusiveMinimum=d),typeof s=="number"&&(i.minimum=s,typeof d=="number"&&e.target!=="draft-04"&&(d>=s?delete i.minimum:delete i.exclusiveMinimum)),typeof u=="number"&&(e.target==="draft-04"||e.target==="openapi-3.0"?(i.maximum=u,i.exclusiveMaximum=!0):i.exclusiveMaximum=u),typeof o=="number"&&(i.maximum=o,typeof u=="number"&&e.target!=="draft-04"&&(u<=o?delete i.maximum:delete i.exclusiveMaximum)),typeof c=="number"&&(i.multipleOf=c)},eT=(n,e,t,r)=>{t.type="boolean"},tT=(n,e,t,r)=>{t.not={}},nT=(n,e,t,r)=>{},rT=(n,e,t,r)=>{const i=n._zod.def,s=Ug(i.entries);s.every(o=>typeof o=="number")&&(t.type="number"),s.every(o=>typeof o=="string")&&(t.type="string"),t.enum=s},iT=(n,e,t,r)=>{const i=n._zod.def,s=[];for(const o of i.values)if(o===void 0){if(e.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof o=="bigint"){if(e.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");s.push(Number(o))}else s.push(o);if(s.length!==0)if(s.length===1){const o=s[0];t.type=o===null?"null":typeof o,e.target==="draft-04"||e.target==="openapi-3.0"?t.enum=[o]:t.const=o}else s.every(o=>typeof o=="number")&&(t.type="number"),s.every(o=>typeof o=="string")&&(t.type="string"),s.every(o=>typeof o=="boolean")&&(t.type="boolean"),s.every(o=>o===null)&&(t.type="null"),t.enum=s},sT=(n,e,t,r)=>{if(e.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},oT=(n,e,t,r)=>{if(e.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},aT=(n,e,t,r)=>{const i=t,s=n._zod.def,{minimum:o,maximum:a}=n._zod.bag;typeof o=="number"&&(i.minItems=o),typeof a=="number"&&(i.maxItems=a),i.type="array",i.items=ve(s.element,e,{...r,path:[...r.path,"items"]})},lT=(n,e,t,r)=>{var u;const i=t,s=n._zod.def;i.type="object",i.properties={};const o=s.shape;for(const d in o)i.properties[d]=ve(o[d],e,{...r,path:[...r.path,"properties",d]});const a=new Set(Object.keys(o)),c=new Set([...a].filter(d=>{const f=s.shape[d]._zod;return e.io==="input"?f.optin===void 0:f.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=ve(s.catchall,e,{...r,path:[...r.path,"additionalProperties"]})):e.io==="output"&&(i.additionalProperties=!1)},cT=(n,e,t,r)=>{const i=n._zod.def,s=i.inclusive===!1,o=i.options.map((a,c)=>ve(a,e,{...r,path:[...r.path,s?"oneOf":"anyOf",c]}));s?t.oneOf=o:t.anyOf=o},uT=(n,e,t,r)=>{const i=n._zod.def,s=ve(i.left,e,{...r,path:[...r.path,"allOf",0]}),o=ve(i.right,e,{...r,path:[...r.path,"allOf",1]}),a=u=>"allOf"in u&&Object.keys(u).length===1,c=[...a(s)?s.allOf:[s],...a(o)?o.allOf:[o]];t.allOf=c},hT=(n,e,t,r)=>{const i=t,s=n._zod.def;i.type="object";const o=s.keyType,a=o._zod.bag,c=a==null?void 0:a.patterns;if(s.mode==="loose"&&c&&c.size>0){const d=ve(s.valueType,e,{...r,path:[...r.path,"patternProperties","*"]});i.patternProperties={};for(const f of c)i.patternProperties[f.source]=d}else(e.target==="draft-07"||e.target==="draft-2020-12")&&(i.propertyNames=ve(s.keyType,e,{...r,path:[...r.path,"propertyNames"]})),i.additionalProperties=ve(s.valueType,e,{...r,path:[...r.path,"additionalProperties"]});const u=o._zod.values;if(u){const d=[...u].filter(f=>typeof f=="string"||typeof f=="number");d.length>0&&(i.required=d)}},dT=(n,e,t,r)=>{const i=n._zod.def,s=ve(i.innerType,e,r),o=e.seen.get(n);e.target==="openapi-3.0"?(o.ref=i.innerType,t.nullable=!0):t.anyOf=[s,{type:"null"}]},fT=(n,e,t,r)=>{const i=n._zod.def;ve(i.innerType,e,r);const s=e.seen.get(n);s.ref=i.innerType},pT=(n,e,t,r)=>{const i=n._zod.def;ve(i.innerType,e,r);const s=e.seen.get(n);s.ref=i.innerType,t.default=JSON.parse(JSON.stringify(i.defaultValue))},gT=(n,e,t,r)=>{const i=n._zod.def;ve(i.innerType,e,r);const s=e.seen.get(n);s.ref=i.innerType,e.io==="input"&&(t._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},mT=(n,e,t,r)=>{const i=n._zod.def;ve(i.innerType,e,r);const s=e.seen.get(n);s.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}t.default=o},yT=(n,e,t,r)=>{const i=n._zod.def,s=e.io==="input"?i.in._zod.def.type==="transform"?i.out:i.in:i.out;ve(s,e,r);const o=e.seen.get(n);o.ref=s},vT=(n,e,t,r)=>{const i=n._zod.def;ve(i.innerType,e,r);const s=e.seen.get(n);s.ref=i.innerType,t.readOnly=!0},lm=(n,e,t,r)=>{const i=n._zod.def;ve(i.innerType,e,r);const s=e.seen.get(n);s.ref=i.innerType},bT=$("ZodISODateTime",(n,e)=>{wA.init(n,e),fe.init(n,e)});function wT(n){return Ax(bT,n)}const _T=$("ZodISODate",(n,e)=>{_A.init(n,e),fe.init(n,e)});function ST(n){return xx(_T,n)}const kT=$("ZodISOTime",(n,e)=>{SA.init(n,e),fe.init(n,e)});function ET(n){return Tx(kT,n)}const $T=$("ZodISODuration",(n,e)=>{kA.init(n,e),fe.init(n,e)});function AT(n){return Cx($T,n)}const cm=(n,e)=>{Vg.init(n,e),n.name="ZodError",Object.defineProperties(n,{format:{value:t=>f$(n,t)},flatten:{value:t=>d$(n,t)},addIssue:{value:t=>{n.issues.push(t),n.message=JSON.stringify(n.issues,dc,2)}},addIssues:{value:t=>{n.issues.push(...t),n.message=JSON.stringify(n.issues,dc,2)}},isEmpty:{get(){return n.issues.length===0}}})},vf=$("ZodError",cm),ot=$("ZodError",cm,{Parent:Error}),xT=Ru(ot),TT=Du(ot),CT=La(ot),IT=Ma(ot),PT=m$(ot),RT=y$(ot),DT=v$(ot),OT=b$(ot),zT=w$(ot),LT=_$(ot),MT=S$(ot),NT=k$(ot),de=$("ZodType",(n,e)=>(he.init(n,e),Object.assign(n["~standard"],{jsonSchema:{input:na(n,"input"),output:na(n,"output")}}),n.toJSONSchema=Kx(n,{}),n.def=e,n.type=e.type,Object.defineProperty(n,"_def",{value:e}),n.check=(...t)=>n.clone(_n(e,{checks:[...e.checks??[],...t.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0}),n.with=n.check,n.clone=(t,r)=>Sn(n,t,r),n.brand=()=>n,n.register=(t,r)=>(t.add(n,r),n),n.parse=(t,r)=>xT(n,t,r,{callee:n.parse}),n.safeParse=(t,r)=>CT(n,t,r),n.parseAsync=async(t,r)=>TT(n,t,r,{callee:n.parseAsync}),n.safeParseAsync=async(t,r)=>IT(n,t,r),n.spa=n.safeParseAsync,n.encode=(t,r)=>PT(n,t,r),n.decode=(t,r)=>RT(n,t,r),n.encodeAsync=async(t,r)=>DT(n,t,r),n.decodeAsync=async(t,r)=>OT(n,t,r),n.safeEncode=(t,r)=>zT(n,t,r),n.safeDecode=(t,r)=>LT(n,t,r),n.safeEncodeAsync=async(t,r)=>MT(n,t,r),n.safeDecodeAsync=async(t,r)=>NT(n,t,r),n.refine=(t,r)=>n.check(CC(t,r)),n.superRefine=t=>n.check(IC(t)),n.overwrite=t=>n.check(fi(t)),n.optional=()=>_f(n),n.exactOptional=()=>mC(n),n.nullable=()=>Sf(n),n.nullish=()=>_f(Sf(n)),n.nonoptional=t=>SC(n,t),n.array=()=>D(n),n.or=t=>H([n,t]),n.and=t=>Ua(n,t),n.transform=t=>kf(n,pC(t)),n.default=t=>bC(n,t),n.prefault=t=>_C(n,t),n.catch=t=>EC(n,t),n.pipe=t=>kf(n,t),n.readonly=()=>xC(n),n.describe=t=>{const r=n.clone();return zi.add(r,{description:t}),r},Object.defineProperty(n,"description",{get(){var t;return(t=zi.get(n))==null?void 0:t.description},configurable:!0}),n.meta=(...t)=>{if(t.length===0)return zi.get(n);const r=n.clone();return zi.add(r,t[0]),r},n.isOptional=()=>n.safeParse(void 0).success,n.isNullable=()=>n.safeParse(null).success,n.apply=t=>t(n),n)),um=$("_ZodString",(n,e)=>{Ou.init(n,e),de.init(n,e),n._zod.processJSONSchema=(r,i,s)=>Xx(n,r,i);const t=n._zod.bag;n.format=t.format??null,n.minLength=t.minimum??null,n.maxLength=t.maximum??null,n.regex=(...r)=>n.check(zx(...r)),n.includes=(...r)=>n.check(Nx(...r)),n.startsWith=(...r)=>n.check(Ux(...r)),n.endsWith=(...r)=>n.check(Fx(...r)),n.min=(...r)=>n.check(ta(...r)),n.max=(...r)=>n.check(rm(...r)),n.length=(...r)=>n.check(im(...r)),n.nonempty=(...r)=>n.check(ta(1,...r)),n.lowercase=r=>n.check(Lx(r)),n.uppercase=r=>n.check(Mx(r)),n.trim=()=>n.check(Hx()),n.normalize=(...r)=>n.check(Zx(...r)),n.toLowerCase=()=>n.check(Vx()),n.toUpperCase=()=>n.check(jx()),n.slugify=()=>n.check(Bx())}),UT=$("ZodString",(n,e)=>{Ou.init(n,e),um.init(n,e),n.email=t=>n.check(sx(FT,t)),n.url=t=>n.check(ux(ZT,t)),n.jwt=t=>n.check($x(nC,t)),n.emoji=t=>n.check(hx(HT,t)),n.guid=t=>n.check(pf(bf,t)),n.uuid=t=>n.check(ox(_o,t)),n.uuidv4=t=>n.check(ax(_o,t)),n.uuidv6=t=>n.check(lx(_o,t)),n.uuidv7=t=>n.check(cx(_o,t)),n.nanoid=t=>n.check(dx(VT,t)),n.guid=t=>n.check(pf(bf,t)),n.cuid=t=>n.check(fx(jT,t)),n.cuid2=t=>n.check(px(BT,t)),n.ulid=t=>n.check(gx(GT,t)),n.base64=t=>n.check(Sx(QT,t)),n.base64url=t=>n.check(kx(eC,t)),n.xid=t=>n.check(mx(WT,t)),n.ksuid=t=>n.check(yx(qT,t)),n.ipv4=t=>n.check(vx(YT,t)),n.ipv6=t=>n.check(bx(KT,t)),n.cidrv4=t=>n.check(wx(JT,t)),n.cidrv6=t=>n.check(_x(XT,t)),n.e164=t=>n.check(Ex(tC,t)),n.datetime=t=>n.check(wT(t)),n.date=t=>n.check(ST(t)),n.time=t=>n.check(ET(t)),n.duration=t=>n.check(AT(t))});function h(n){return ix(UT,n)}const fe=$("ZodStringFormat",(n,e)=>{ae.init(n,e),um.init(n,e)}),FT=$("ZodEmail",(n,e)=>{hA.init(n,e),fe.init(n,e)}),bf=$("ZodGUID",(n,e)=>{cA.init(n,e),fe.init(n,e)}),_o=$("ZodUUID",(n,e)=>{uA.init(n,e),fe.init(n,e)}),ZT=$("ZodURL",(n,e)=>{dA.init(n,e),fe.init(n,e)}),HT=$("ZodEmoji",(n,e)=>{fA.init(n,e),fe.init(n,e)}),VT=$("ZodNanoID",(n,e)=>{pA.init(n,e),fe.init(n,e)}),jT=$("ZodCUID",(n,e)=>{gA.init(n,e),fe.init(n,e)}),BT=$("ZodCUID2",(n,e)=>{mA.init(n,e),fe.init(n,e)}),GT=$("ZodULID",(n,e)=>{yA.init(n,e),fe.init(n,e)}),WT=$("ZodXID",(n,e)=>{vA.init(n,e),fe.init(n,e)}),qT=$("ZodKSUID",(n,e)=>{bA.init(n,e),fe.init(n,e)}),YT=$("ZodIPv4",(n,e)=>{EA.init(n,e),fe.init(n,e)}),KT=$("ZodIPv6",(n,e)=>{$A.init(n,e),fe.init(n,e)}),JT=$("ZodCIDRv4",(n,e)=>{AA.init(n,e),fe.init(n,e)}),XT=$("ZodCIDRv6",(n,e)=>{xA.init(n,e),fe.init(n,e)}),QT=$("ZodBase64",(n,e)=>{TA.init(n,e),fe.init(n,e)}),eC=$("ZodBase64URL",(n,e)=>{IA.init(n,e),fe.init(n,e)}),tC=$("ZodE164",(n,e)=>{PA.init(n,e),fe.init(n,e)}),nC=$("ZodJWT",(n,e)=>{DA.init(n,e),fe.init(n,e)}),hm=$("ZodNumber",(n,e)=>{Qg.init(n,e),de.init(n,e),n._zod.processJSONSchema=(r,i,s)=>Qx(n,r,i),n.gt=(r,i)=>n.check(mf(r,i)),n.gte=(r,i)=>n.check(Ol(r,i)),n.min=(r,i)=>n.check(Ol(r,i)),n.lt=(r,i)=>n.check(gf(r,i)),n.lte=(r,i)=>n.check(Dl(r,i)),n.max=(r,i)=>n.check(Dl(r,i)),n.int=r=>n.check(wf(r)),n.safe=r=>n.check(wf(r)),n.positive=r=>n.check(mf(0,r)),n.nonnegative=r=>n.check(Ol(0,r)),n.negative=r=>n.check(gf(0,r)),n.nonpositive=r=>n.check(Dl(0,r)),n.multipleOf=(r,i)=>n.check(yf(r,i)),n.step=(r,i)=>n.check(yf(r,i)),n.finite=()=>n;const t=n._zod.bag;n.minValue=Math.max(t.minimum??Number.NEGATIVE_INFINITY,t.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,n.maxValue=Math.min(t.maximum??Number.POSITIVE_INFINITY,t.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,n.isInt=(t.format??"").includes("int")||Number.isSafeInteger(t.multipleOf??.5),n.isFinite=!0,n.format=t.format??null});function N(n){return Ix(hm,n)}const rC=$("ZodNumberFormat",(n,e)=>{OA.init(n,e),hm.init(n,e)});function wf(n){return Px(rC,n)}const iC=$("ZodBoolean",(n,e)=>{zA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>eT(n,t,r)});function Ee(n){return Rx(iC,n)}const sC=$("ZodUnknown",(n,e)=>{LA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>nT()});function w(){return Dx(sC)}const oC=$("ZodNever",(n,e)=>{MA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>tT(n,t,r)});function aC(n){return Ox(oC,n)}const lC=$("ZodArray",(n,e)=>{NA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>aT(n,t,r,i),n.element=e.element,n.min=(t,r)=>n.check(ta(t,r)),n.nonempty=t=>n.check(ta(1,t)),n.max=(t,r)=>n.check(rm(t,r)),n.length=(t,r)=>n.check(im(t,r)),n.unwrap=()=>n.element});function D(n,e){return Gx(lC,n,e)}const dm=$("ZodObject",(n,e)=>{FA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>lT(n,t,r,i),X(n,"shape",()=>e.shape),n.keyof=()=>ra(Object.keys(n._zod.def.shape)),n.catchall=t=>n.clone({...n._zod.def,catchall:t}),n.passthrough=()=>n.clone({...n._zod.def,catchall:w()}),n.loose=()=>n.clone({...n._zod.def,catchall:w()}),n.strict=()=>n.clone({...n._zod.def,catchall:aC()}),n.strip=()=>n.clone({...n._zod.def,catchall:void 0}),n.extend=t=>a$(n,t),n.safeExtend=t=>l$(n,t),n.merge=t=>c$(n,t),n.pick=t=>s$(n,t),n.omit=t=>o$(n,t),n.partial=(...t)=>u$(pm,n,t[0]),n.required=(...t)=>h$(gm,n,t[0])});function fm(n,e){const t={type:"object",shape:n??{},...O(e)};return new dm(t)}function p(n,e){return new dm({type:"object",shape:n,catchall:w(),...O(e)})}const cC=$("ZodUnion",(n,e)=>{ZA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>cT(n,t,r,i),n.options=e.options});function H(n,e){return new cC({type:"union",options:n,...O(e)})}const uC=$("ZodIntersection",(n,e)=>{HA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>uT(n,t,r,i)});function Ua(n,e){return new uC({type:"intersection",left:n,right:e})}const hC=$("ZodRecord",(n,e)=>{VA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>hT(n,t,r,i),n.keyType=e.keyType,n.valueType=e.valueType});function S(n,e,t){return new hC({type:"record",keyType:n,valueType:e,...O(t)})}const pc=$("ZodEnum",(n,e)=>{jA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(r,i,s)=>rT(n,r,i),n.enum=e.entries,n.options=Object.values(e.entries);const t=new Set(Object.keys(e.entries));n.extract=(r,i)=>{const s={};for(const o of r)if(t.has(o))s[o]=e.entries[o];else throw new Error(`Key ${o} not found in enum`);return new pc({...e,checks:[],...O(i),entries:s})},n.exclude=(r,i)=>{const s={...e.entries};for(const o of r)if(t.has(o))delete s[o];else throw new Error(`Key ${o} not found in enum`);return new pc({...e,checks:[],...O(i),entries:s})}});function ra(n,e){const t=Array.isArray(n)?Object.fromEntries(n.map(r=>[r,r])):n;return new pc({type:"enum",entries:t,...O(e)})}const dC=$("ZodLiteral",(n,e)=>{BA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>iT(n,t,r),n.values=new Set(e.values),Object.defineProperty(n,"value",{get(){if(e.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return e.values[0]}})});function x(n,e){return new dC({type:"literal",values:Array.isArray(n)?n:[n],...O(e)})}const fC=$("ZodTransform",(n,e)=>{GA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>oT(n,t),n._zod.parse=(t,r)=>{if(r.direction==="backward")throw new Mg(n.constructor.name);t.addIssue=s=>{if(typeof s=="string")t.issues.push(Ji(s,t.value,e));else{const o=s;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=t.value),o.inst??(o.inst=n),t.issues.push(Ji(o))}};const i=e.transform(t.value,t);return i instanceof Promise?i.then(s=>(t.value=s,t)):(t.value=i,t)}});function pC(n){return new fC({type:"transform",transform:n})}const pm=$("ZodOptional",(n,e)=>{nm.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>lm(n,t,r,i),n.unwrap=()=>n._zod.def.innerType});function _f(n){return new pm({type:"optional",innerType:n})}const gC=$("ZodExactOptional",(n,e)=>{WA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>lm(n,t,r,i),n.unwrap=()=>n._zod.def.innerType});function mC(n){return new gC({type:"optional",innerType:n})}const yC=$("ZodNullable",(n,e)=>{qA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>dT(n,t,r,i),n.unwrap=()=>n._zod.def.innerType});function Sf(n){return new yC({type:"nullable",innerType:n})}const vC=$("ZodDefault",(n,e)=>{YA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>pT(n,t,r,i),n.unwrap=()=>n._zod.def.innerType,n.removeDefault=n.unwrap});function bC(n,e){return new vC({type:"default",innerType:n,get defaultValue(){return typeof e=="function"?e():Zg(e)}})}const wC=$("ZodPrefault",(n,e)=>{KA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>gT(n,t,r,i),n.unwrap=()=>n._zod.def.innerType});function _C(n,e){return new wC({type:"prefault",innerType:n,get defaultValue(){return typeof e=="function"?e():Zg(e)}})}const gm=$("ZodNonOptional",(n,e)=>{JA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>fT(n,t,r,i),n.unwrap=()=>n._zod.def.innerType});function SC(n,e){return new gm({type:"nonoptional",innerType:n,...O(e)})}const kC=$("ZodCatch",(n,e)=>{XA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>mT(n,t,r,i),n.unwrap=()=>n._zod.def.innerType,n.removeCatch=n.unwrap});function EC(n,e){return new kC({type:"catch",innerType:n,catchValue:typeof e=="function"?e:()=>e})}const $C=$("ZodPipe",(n,e)=>{QA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>yT(n,t,r,i),n.in=e.in,n.out=e.out});function kf(n,e){return new $C({type:"pipe",in:n,out:e})}const AC=$("ZodReadonly",(n,e)=>{ex.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>vT(n,t,r,i),n.unwrap=()=>n._zod.def.innerType});function xC(n){return new AC({type:"readonly",innerType:n})}const TC=$("ZodCustom",(n,e)=>{tx.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>sT(n,t)});function CC(n,e={}){return Wx(TC,n,e)}function IC(n){return qx(n)}const PC=["text/markdown","text/html"],RC=["committed","pending"];fm({id:h().min(1),type:ra(PC),title:h(),status:ra(RC),externalFilePath:h().optional()});fm({name:h().min(1),description:h(),accepts:D(h().min(1)).min(1)});function zu(n){return typeof n=="object"&&n!==null}function DC(n){return!zu(n)||n.type!=="ready"?!1:!("id"in n)}function OC(n){return!(!zu(n)||n.type!=="update-content"||typeof n.id!="string"||typeof n.content!="string")}function zC(n){return!zu(n)||n.type!=="wheel"||typeof n.deltaX!="number"||typeof n.deltaY!="number"||typeof n.shiftKey!="boolean"?!1:!("id"in n)}function LC(n,e){if(n===e)return 2;if(n==="*/*")return 0;const t=n.indexOf("/");if(t>0&&n.slice(t+1)==="*"){const r=n.slice(0,t),i=e.indexOf("/");if(i>0&&e.slice(0,i)===r)return 1}return null}function MC(n,e){let t=null;for(const r of n.accepts){const i=LC(r,e);i!==null&&(t===null||i>t)&&(t=i)}return t}function NC(n,e){let t=-1,r=null;for(const i of e){const s=MC(i,n);s!==null&&(s>t||s===t&&r!==null&&i.id<r.id)&&(t=s,r=i)}return r}const UC=4401;class gc extends Error{constructor(e="Authentication required"){super(e),this.name="AuthError"}}class mc extends gt{constructor(t){super();b(this,"url");b(this,"name");b(this,"token");b(this,"status","disconnected");b(this,"screens",new Map);b(this,"views",[]);b(this,"client");b(this,"createSocket");b(this,"createClient");b(this,"socket",null);b(this,"connectAttempt",0);this.url=kt(t.url),this.name=t.name,this.token=t.token??null,this.createSocket=t.createSocket??(r=>new WebSocket(r)),this.createClient=t.createClient??((r,i)=>new H0(r,{token:i??void 0})),this.client=this.createClient(this.url,this.token)}async connect(){var i;this.connectAttempt+=1;const t=this.connectAttempt;(i=this.socket)==null||i.close(),this.client=this.createClient(this.url,this.token),this.status="connecting",this.dispatchEvent(new Q("change"));const r=this.createSocket(FC(this.url,this.token));return this.socket=r,await new Promise((s,o)=>{let a=!1;const c=()=>{a||this.connectAttempt!==t||(a=!0,this.status="connected",this.dispatchEvent(new Q("change")),s())},u=f=>{a||this.connectAttempt!==t||(a=!0,this.status="disconnected",this.dispatchEvent(new Q("change")),o(f))},d=async()=>{try{const[{screens:f},v]=await Promise.all([this.client.screens.list(),this.client.views.list()]);this.screens=new Map(f.map(y=>[y.id,structuredClone(y)])),this.views=v,this.dispatchEvent(new Q("change")),c()}catch(f){u(f instanceof Error?f:new Error(String(f)))}};r.addEventListener("open",()=>{d()}),r.addEventListener("message",f=>{const v=HC(f);v&&(this.applyServerEvent(v),this.dispatchEvent(new xg("server-event",{serverURL:this.url,event:v})))}),r.addEventListener("close",f=>{if(this.connectAttempt===t){if(this.socket=null,ZC(f)===UC){u(new gc);return}if(!a){u(new Error("Connection closed before initialization"));return}this.status="disconnected",this.dispatchEvent(new Q("change"))}}),r.addEventListener("error",()=>{u(new Error("WebSocket connection failed"))})})}disconnect(){var t;this.connectAttempt+=1,(t=this.socket)==null||t.close(),this.socket=null,this.status="disconnected",this.dispatchEvent(new Q("change"))}getViewURL(t){const r=NC(t.type,this.views);if(!r)return null;const i=`${this.url}/views/${encodeURIComponent(r.id)}/`;return this.token===null?i:`${i}?token=${encodeURIComponent(this.token)}`}getContentURL(t){const r=`${this.url}/artifacts/${encodeURIComponent(t)}/content`;return this.token===null?r:`${r}?token=${encodeURIComponent(this.token)}`}async createScreen(t){const{screen:r}=await this.client.screens.create({name:t});return this.screens.set(r.id,structuredClone(r)),r}applyServerEvent(t){switch(t.type){case"screen-created":this.screens.set(t.screen.id,structuredClone(t.screen)),this.dispatchEvent(new No("screens-changed"));break;case"screen-updated":this.screens.set(t.screen.id,structuredClone(t.screen)),this.dispatchEvent(new No("screens-changed"));break;case"screen-removed":this.screens.delete(t.screenID),this.dispatchEvent(new No("screens-changed"));break;case"artifact-created":{const r=this.screens.get(t.screenID);r&&!Eg(r.layout,t.artifact.id)&&(r.layout=[...r.layout,kg(t.artifact.id)]);break}case"artifact-removed":{const r=this.screens.get(t.screenID);r&&(r.layout=pg(r.layout,t.artifactID));break}}}}function FC(n,e){const t=new URL(n);return t.protocol=t.protocol==="https:"?"wss:":"ws:",t.pathname="/events",t.search="",e&&t.searchParams.set("token",e),t.hash="",t.toString()}function ZC(n){return typeof n=="object"&&n!==null&&"code"in n&&typeof n.code=="number"?n.code:null}function HC(n){const e=typeof n=="string"?n:typeof n=="object"&&n!==null&&"data"in n&&typeof n.data=="string"?n.data:"";if(!e)return null;try{return JSON.parse(e)}catch{return null}}class VC extends gt{constructor(t){super();b(this,"servers",new Map);b(this,"localServerURL");b(this,"localStore");b(this,"createSocket");b(this,"lastActiveServerURL");b(this,"serverListeners",new Map);b(this,"handleLocalStoreChange",()=>{const t=this.localStore.get().activeServerURL;t!==this.lastActiveServerURL&&(this.lastActiveServerURL=t,this.dispatchEvent(new Q("change")))});this.localStore=t.localStore,this.localServerURL=t.localServerURL?kt(t.localServerURL):null,this.createSocket=t.createSocket??(r=>new WebSocket(r)),this.lastActiveServerURL=this.localStore.get().activeServerURL,this.localStore.addEventListener("change",this.handleLocalStoreChange)}get activeServer(){const t=this.localStore.get().activeServerURL;return t===null?null:this.servers.get(t)??null}add(t){const r=kt(t.url);this.servers.get(r)&&this.remove(r),this.servers.set(r,t);const s=()=>{this.dispatchEvent(new Q("change"))},o=c=>{this.dispatchEvent(new xg("server-event",{serverURL:c.serverURL,event:c.event}))},a=()=>{this.dispatchEvent(new No("screens-changed"))};t.addEventListener("change",s),t.addEventListener("server-event",o),t.addEventListener("screens-changed",a),this.serverListeners.set(r,{onServerChange:s,onServerEvent:o,onScreensChanged:a}),this.dispatchEvent(new Q("change"))}remove(t){const r=kt(t);if(this.localServerURL&&r===this.localServerURL)return;const i=this.servers.get(r);if(!i)return;const s=this.serverListeners.get(r);s&&(i.removeEventListener("change",s.onServerChange),i.removeEventListener("server-event",s.onServerEvent),i.removeEventListener("screens-changed",s.onScreensChanged),this.serverListeners.delete(r)),i.disconnect(),this.servers.delete(r);const o=this.localStore.get(),a=o.activeServerURL===r;this.localStore.set({...o,servers:o.servers.filter(c=>c.url!==r),activeServerURL:a?null:o.activeServerURL}),this.dispatchEvent(new Q("change"))}setActive(t){const r=this.localStore.get(),i=t?kt(t.url):null;r.activeServerURL!==i&&this.localStore.set({...r,activeServerURL:i})}connectConfiguredServers(t,r){const i=this.localStore.get().servers,s=t?kt(t):null;for(const a of i){const c=kt(a.url),u=s!==null&&c===s,d=new mc({url:a.url,name:a.name,token:u?r??null:null,createSocket:this.createSocket});this.add(d),d.connect().catch(()=>{})}const o=s?this.servers.get(s)??null:null;this.setActive(o??this.servers.values().next().value??null)}addServer(t,r){const i=kt(t);this.remove(i);const s=this.localStore.get();this.localStore.set({...s,servers:[...s.servers.filter(a=>kt(a.url)!==i),{url:i,name:r}]});const o=new mc({url:i,name:r,createSocket:this.createSocket});this.add(o),this.setActive(o),o.connect().catch(()=>{})}removeServer(t){this.remove(t)}}const se={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"},Ot={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"},jC=1,BC=p({_meta:S(h(),w()).nullish(),terminal:Ee().optional().default(!1)}),GC=p({_meta:S(h(),w()).nullish(),label:h().nullish(),name:h(),optional:Ee().optional().default(!1),secret:Ee().optional().default(!0)}),WC=p({_meta:S(h(),w()).nullish(),description:h().nullish(),id:h(),name:h()}),qC=p({_meta:S(h(),w()).nullish(),description:h().nullish(),id:h(),link:h().nullish(),name:h(),vars:D(GC)}),YC=p({_meta:S(h(),w()).nullish(),args:D(h()).optional(),description:h().nullish(),env:S(h(),h()).optional(),id:h(),name:h()}),KC=H([qC.and(p({type:x("env_var")})),YC.and(p({type:x("terminal")})),WC]),JC=p({_meta:S(h(),w()).nullish(),methodId:h()}),XC=p({_meta:S(h(),w()).nullish()}),QC=p({_meta:S(h(),w()).nullish(),blob:h(),mimeType:h().nullish(),uri:h()}),eI=p({default:Ee().nullish(),description:h().nullish(),title:h().nullish()}),tI=p({_meta:S(h(),w()).nullish()}),nI=p({_meta:S(h(),w()).nullish()}),rI=p({amount:N(),currency:h()}),iI=p({_meta:S(h(),w()).nullish(),terminalId:h()}),sI=p({_meta:S(h(),w()).nullish(),newText:h(),oldText:h().nullish(),path:h()}),oI=H([h(),N(),N(),Ee(),D(h())]),aI=p({content:S(h(),oI).nullish()}),lI=H([aI.and(p({action:x("accept")})),p({action:x("decline")}),p({action:x("cancel")})]),cI=p({_meta:S(h(),w()).nullish()}),mm=h(),uI=p({_meta:S(h(),w()).nullish(),elicitationId:mm}),hI=p({_meta:S(h(),w()).nullish(),action:lI}),dI=x("object"),fI=x("string"),pI=p({_meta:S(h(),w()).nullish()}),gI=p({_meta:S(h(),w()).nullish(),form:cI.nullish(),url:pI.nullish()}),mI=p({elicitationId:mm,url:h().url()}),ym=p({const:h(),title:h()}),vm=p({_meta:S(h(),w()).nullish(),name:h(),value:h()}),yI=H([x(-32700),x(-32600),x(-32601),x(-32602),x(-32603),x(-32800),x(-32e3),x(-32002),x(-32042),N().int().min(-2147483648,{message:"Invalid value: Expected int32 to be >= -2147483648"}).max(2147483647,{message:"Invalid value: Expected int32 to be <= 2147483647"})]),bm=p({code:yI,data:w().optional(),message:h()}),wm=w(),_m=w(),Sm=w(),vI=p({_meta:S(h(),w()).nullish(),readTextFile:Ee().optional().default(!1),writeTextFile:Ee().optional().default(!1)}),km=p({_meta:S(h(),w()).nullish(),name:h(),value:h()}),Em=p({_meta:S(h(),w()).nullish(),name:h(),title:h().nullish(),version:h()}),bI=p({default:N().nullish(),description:h().nullish(),maximum:N().nullish(),minimum:N().nullish(),title:h().nullish()}),wI=p({_meta:S(h(),w()).nullish()}),_I=p({_meta:S(h(),w()).nullish(),additionalDirectories:D(h()).optional(),cursor:h().nullish(),cwd:h().nullish()}),SI=p({_meta:S(h(),w()).nullish()}),kI=p({_meta:S(h(),w()).nullish(),logout:SI.nullish()}),EI=p({_meta:S(h(),w()).nullish()}),$I=p({_meta:S(h(),w()).nullish()}),AI=p({_meta:S(h(),w()).nullish(),http:Ee().optional().default(!1),sse:Ee().optional().default(!1)}),xI=p({_meta:S(h(),w()).nullish(),headers:D(km),name:h(),url:h()}),TI=p({_meta:S(h(),w()).nullish(),headers:D(km),name:h(),url:h()}),CI=p({_meta:S(h(),w()).nullish(),args:D(h()),command:h(),env:D(vm),name:h()}),Fa=H([xI.and(p({type:x("http")})),TI.and(p({type:x("sse")})),CI]),Lu=h(),II=p({_meta:S(h(),w()).nullish(),description:h().nullish(),modelId:Lu,name:h()}),PI=H([x("error"),x("warning"),x("information"),x("hint")]),RI=p({_meta:S(h(),w()).nullish()}),DI=p({_meta:S(h(),w()).nullish()}),OI=p({_meta:S(h(),w()).nullish()}),zI=p({_meta:S(h(),w()).nullish()}),LI=p({_meta:S(h(),w()).nullish()}),MI=p({_meta:S(h(),w()).nullish(),maxCount:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),NI=p({diff:h(),uri:h()}),UI=p({endLine:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),startLine:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),text:h()}),FI=p({_meta:S(h(),w()).nullish()}),ZI=p({_meta:S(h(),w()).nullish()}),HI=p({languageId:h(),text:h(),uri:h()}),VI=p({_meta:S(h(),w()).nullish(),maxCount:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),jI=H([x("rejected"),x("ignored"),x("replaced"),x("cancelled")]),BI=p({excerpts:D(UI),uri:h()}),GI=p({_meta:S(h(),w()).nullish()}),WI=p({_meta:S(h(),w()).nullish()}),qI=p({name:h(),owner:h(),remoteUrl:h()}),YI=p({_meta:S(h(),w()).nullish()}),KI=p({_meta:S(h(),w()).nullish(),jump:FI.nullish(),rename:WI.nullish(),searchAndReplace:YI.nullish()}),JI=p({id:h(),isRegex:Ee().nullish(),replace:h(),search:h(),uri:h()}),XI=H([x("automatic"),x("diagnostic"),x("manual")]),QI=p({_meta:S(h(),w()).nullish(),maxCount:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),eP=p({_meta:S(h(),w()).nullish(),diagnostics:RI.nullish(),editHistory:MI.nullish(),openFiles:ZI.nullish(),recentFiles:VI.nullish(),relatedSnippets:GI.nullish(),userActions:QI.nullish()}),tP=p({_meta:S(h(),w()).nullish(),additionalDirectories:D(h()).optional(),cwd:h(),mcpServers:D(Fa)}),nP=p({default:N().nullish(),description:h().nullish(),maximum:N().nullish(),minimum:N().nullish(),title:h().nullish()}),$m=h(),rP=H([x("allow_once"),x("allow_always"),x("reject_once"),x("reject_always")]),iP=p({_meta:S(h(),w()).nullish(),kind:rP,name:h(),optionId:$m}),sP=H([x("high"),x("medium"),x("low")]),oP=H([x("pending"),x("in_progress"),x("completed")]),aP=p({_meta:S(h(),w()).nullish(),content:h(),priority:sP,status:oP}),lP=p({_meta:S(h(),w()).nullish(),entries:D(aP)}),mn=p({character:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),line:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"})}),cP=p({id:h(),position:mn,uri:h()}),uP=p({id:h(),newName:h(),position:mn,uri:h()}),hP=p({action:h(),position:mn,timestampMs:N(),uri:h()}),Am=H([x("utf-16"),x("utf-32"),x("utf-8")]),dP=p({_meta:S(h(),w()).nullish(),auth:BC.optional().default({terminal:!1}),elicitation:gI.nullish(),fs:vI.optional().default({readTextFile:!1,writeTextFile:!1}),nes:KI.nullish(),positionEncodings:D(Am).optional(),terminal:Ee().optional().default(!1)}),fP=p({_meta:S(h(),w()).nullish(),audio:Ee().optional().default(!1),embeddedContext:Ee().optional().default(!1),image:Ee().optional().default(!1)}),xm=N().int().gte(0).lte(65535),pP=p({_meta:S(h(),w()).nullish(),clientCapabilities:dP.optional().default({auth:{terminal:!1},fs:{readTextFile:!1,writeTextFile:!1},terminal:!1}),clientInfo:Em.nullish(),protocolVersion:xm}),pi=p({end:mn,start:mn}),gP=p({message:h(),range:pi,severity:PI,uri:h()}),mP=p({languageId:h(),lastFocusedMs:N().nullish(),uri:h(),visibleRange:pi.nullish()}),yP=p({_meta:S(h(),w()).nullish(),diagnostics:D(gP).nullish(),editHistory:D(NI).nullish(),openFiles:D(mP).nullish(),recentFiles:D(HI).nullish(),relatedSnippets:D(BI).nullish(),userActions:D(hP).nullish()}),vP=p({newText:h(),range:pi}),bP=p({cursorPosition:mn.nullish(),edits:D(vP),id:h(),uri:h()}),wP=H([bP.and(p({kind:x("edit")})),cP.and(p({kind:x("jump")})),uP.and(p({kind:x("rename")})),JI.and(p({kind:x("searchAndReplace")}))]),_P=p({_meta:S(h(),w()).nullish(),content:h()}),SP=p({_meta:S(h(),w()).nullish()}),nr=H([N(),h()]).nullable();p({_meta:S(h(),w()).nullish(),requestId:nr});const kP=ra(["assistant","user"]),Xs=p({_meta:S(h(),w()).nullish(),audience:D(kP).nullish(),lastModified:h().nullish(),priority:N().nullish()}),EP=p({_meta:S(h(),w()).nullish(),annotations:Xs.nullish(),data:h(),mimeType:h()}),$P=p({_meta:S(h(),w()).nullish(),annotations:Xs.nullish(),data:h(),mimeType:h(),uri:h().nullish()}),AP=p({_meta:S(h(),w()).nullish(),annotations:Xs.nullish(),description:h().nullish(),mimeType:h().nullish(),name:h(),size:N().nullish(),title:h().nullish(),uri:h()}),xP=p({_meta:S(h(),w()).nullish(),optionId:$m}),TP=H([p({outcome:x("cancelled")}),xP.and(p({outcome:x("selected")}))]),CP=p({_meta:S(h(),w()).nullish(),outcome:TP}),IP=p({_meta:S(h(),w()).nullish()}),PP=p({_meta:S(h(),w()).nullish()}),RP=p({currentValue:Ee()}),DP=h(),Tm=h(),OP=H([x("mode"),x("model"),x("thought_level"),h()]),Mu=h(),Cm=p({_meta:S(h(),w()).nullish(),description:h().nullish(),name:h(),value:Mu}),zP=p({_meta:S(h(),w()).nullish(),group:DP,name:h(),options:D(Cm)}),LP=H([D(Cm),D(zP)]),MP=p({currentValue:Mu,options:LP}),gi=Ua(H([MP.and(p({type:x("select")})),RP.and(p({type:x("boolean")}))]),p({_meta:S(h(),w()).nullish(),category:OP.nullish(),description:h().nullish(),id:Tm,name:h()})),NP=p({_meta:S(h(),w()).nullish(),configOptions:D(gi)}),UP=p({_meta:S(h(),w()).nullish()}),Y=h(),FP=p({_meta:S(h(),w()).nullish(),id:h(),sessionId:Y}),ZP=p({_meta:S(h(),w()).nullish(),sessionId:Y}),HP=p({_meta:S(h(),w()).nullish(),sessionId:Y}),VP=p({_meta:S(h(),w()).nullish(),sessionId:Y}),Im=p({_meta:S(h(),w()).nullish(),args:D(h()).optional(),command:h(),cwd:h().nullish(),env:D(vm).optional(),outputByteLimit:N().nullish(),sessionId:Y}),jP=p({_meta:S(h(),w()).nullish(),sessionId:Y,uri:h()}),BP=p({_meta:S(h(),w()).nullish(),position:mn,sessionId:Y,uri:h(),version:N(),visibleRange:pi}),GP=p({_meta:S(h(),w()).nullish(),languageId:h(),sessionId:Y,text:h(),uri:h(),version:N()}),WP=p({_meta:S(h(),w()).nullish(),sessionId:Y,uri:h()}),qP=p({_meta:S(h(),w()).nullish(),additionalDirectories:D(h()).optional(),cwd:h(),mcpServers:D(Fa).optional(),sessionId:Y}),Pm=p({_meta:S(h(),w()).nullish(),sessionId:Y,terminalId:h()}),YP=p({_meta:S(h(),w()).nullish(),additionalDirectories:D(h()).optional(),cwd:h(),mcpServers:D(Fa),sessionId:Y}),Rm=p({_meta:S(h(),w()).nullish(),limit:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),line:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:h(),sessionId:Y}),KP=p({_meta:S(h(),w()).nullish(),id:h(),reason:jI.nullish(),sessionId:Y}),Dm=p({_meta:S(h(),w()).nullish(),sessionId:Y,terminalId:h()}),JP=p({_meta:S(h(),w()).nullish(),additionalDirectories:D(h()).optional(),cwd:h(),mcpServers:D(Fa).optional(),sessionId:Y}),XP=p({_meta:S(h(),w()).nullish(),additionalDirectories:D(h()).optional(),cwd:h(),sessionId:Y,title:h().nullish(),updatedAt:h().nullish()}),QP=p({_meta:S(h(),w()).nullish(),nextCursor:h().nullish(),sessions:D(XP)}),e1=p({_meta:S(h(),w()).nullish(),title:h().nullish(),updatedAt:h().nullish()}),t1=p({_meta:S(h(),w()).nullish()}),Za=h(),n1=p({_meta:S(h(),w()).nullish(),currentModeId:Za}),r1=p({_meta:S(h(),w()).nullish(),description:h().nullish(),id:Za,name:h()}),Ha=p({_meta:S(h(),w()).nullish(),availableModes:D(r1),currentModeId:Za}),Va=p({_meta:S(h(),w()).nullish(),availableModels:D(II),currentModelId:Lu}),i1=p({_meta:S(h(),w()).nullish(),configOptions:D(gi).nullish(),models:Va.nullish(),modes:Ha.nullish(),sessionId:Y}),s1=p({_meta:S(h(),w()).nullish(),configOptions:D(gi).nullish(),models:Va.nullish(),modes:Ha.nullish()}),o1=p({_meta:S(h(),w()).nullish(),configOptions:D(gi).nullish(),models:Va.nullish(),modes:Ha.nullish(),sessionId:Y}),a1=p({_meta:S(h(),w()).nullish(),configOptions:D(gi).nullish(),models:Va.nullish(),modes:Ha.nullish()}),l1=p({_meta:S(h(),w()).nullish()}),c1=p({_meta:S(h(),w()).nullish(),additionalDirectories:IP.nullish(),close:PP.nullish(),fork:UP.nullish(),list:t1.nullish(),resume:l1.nullish()}),u1=Ua(H([p({type:x("boolean"),value:Ee()}),p({value:Mu})]),p({_meta:S(h(),w()).nullish(),configId:Tm,sessionId:Y})),h1=p({_meta:S(h(),w()).nullish(),configOptions:D(gi)}),d1=p({_meta:S(h(),w()).nullish(),modeId:Za,sessionId:Y}),f1=p({_meta:S(h(),w()).nullish()}),p1=p({_meta:S(h(),w()).nullish(),modelId:Lu,sessionId:Y}),g1=p({_meta:S(h(),w()).nullish()}),m1=p({_meta:S(h(),w()).nullish(),sessionId:Y}),y1=H([x("end_turn"),x("max_tokens"),x("max_turn_requests"),x("refusal"),x("cancelled")]),v1=H([x("email"),x("uri"),x("date"),x("date-time")]),b1=p({default:h().nullish(),description:h().nullish(),enum:D(h()).nullish(),format:v1.nullish(),maxLength:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),minLength:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),oneOf:D(ym).nullish(),pattern:h().nullish(),title:h().nullish()}),w1=p({_meta:S(h(),w()).nullish(),context:yP.nullish(),position:mn,selection:pi.nullish(),sessionId:Y,triggerKind:XI,uri:h(),version:N()}),_1=p({_meta:S(h(),w()).nullish(),suggestions:D(wP)}),S1=p({_meta:S(h(),w()).nullish(),terminalId:h()}),k1=p({_meta:S(h(),w()).nullish(),exitCode:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:h().nullish()}),Om=p({_meta:S(h(),w()).nullish(),sessionId:Y,terminalId:h()}),E1=p({_meta:S(h(),w()).nullish(),exitStatus:k1.nullish(),output:h(),truncated:Ee()}),$1=p({_meta:S(h(),w()).nullish(),annotations:Xs.nullish(),text:h()}),A1=p({range:pi.nullish(),text:h()}),x1=p({_meta:S(h(),w()).nullish(),contentChanges:D(A1),sessionId:Y,uri:h(),version:N()});p({method:h(),params:H([ZP,GP,x1,jP,WP,BP,FP,KP,wm]).nullish()});const T1=H([x("full"),x("incremental")]),C1=p({_meta:S(h(),w()).nullish(),syncKind:T1}),I1=p({_meta:S(h(),w()).nullish(),didChange:C1.nullish(),didClose:DI.nullish(),didFocus:OI.nullish(),didOpen:zI.nullish(),didSave:LI.nullish()}),P1=p({_meta:S(h(),w()).nullish(),document:I1.nullish()}),R1=p({_meta:S(h(),w()).nullish(),context:eP.nullish(),events:P1.nullish()}),D1=p({_meta:S(h(),w()).nullish(),auth:kI.optional().default({}),loadSession:Ee().optional().default(!1),mcpCapabilities:AI.optional().default({http:!1,sse:!1}),nes:R1.nullish(),positionEncoding:Am.nullish(),promptCapabilities:fP.optional().default({audio:!1,embeddedContext:!1,image:!1}),sessionCapabilities:c1.optional().default({})}),O1=p({_meta:S(h(),w()).nullish(),agentCapabilities:D1.optional().default({auth:{},loadSession:!1,mcpCapabilities:{http:!1,sse:!1},promptCapabilities:{audio:!1,embeddedContext:!1,image:!1},sessionCapabilities:{}}),agentInfo:Em.nullish(),authMethods:D(KC).optional().default([]),protocolVersion:xm}),z1=p({_meta:S(h(),w()).nullish(),mimeType:h().nullish(),text:h(),uri:h()}),L1=H([z1,QC]),M1=p({_meta:S(h(),w()).nullish(),annotations:Xs.nullish(),resource:L1}),Nu=H([$1.and(p({type:x("text")})),$P.and(p({type:x("image")})),EP.and(p({type:x("audio")})),AP.and(p({type:x("resource_link")})),M1.and(p({type:x("resource")}))]),N1=p({_meta:S(h(),w()).nullish(),content:Nu}),zl=p({_meta:S(h(),w()).nullish(),content:Nu,messageId:h().nullish()}),U1=p({_meta:S(h(),w()).nullish(),messageId:h().nullish(),prompt:D(Nu),sessionId:Y}),F1=p({anyOf:D(ym)}),zm=H([N1.and(p({type:x("content")})),sI.and(p({type:x("diff")})),S1.and(p({type:x("terminal")}))]),Lm=h(),Mm=p({_meta:S(h(),w()).nullish(),line:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:h()}),Nm=H([x("pending"),x("in_progress"),x("completed"),x("failed")]),Um=H([x("read"),x("edit"),x("delete"),x("move"),x("search"),x("execute"),x("think"),x("fetch"),x("switch_mode"),x("other")]),Z1=p({_meta:S(h(),w()).nullish(),content:D(zm).optional(),kind:Um.optional(),locations:D(Mm).optional(),rawInput:w().optional(),rawOutput:w().optional(),status:Nm.optional(),title:h(),toolCallId:Lm}),Fm=p({_meta:S(h(),w()).nullish(),content:D(zm).nullish(),kind:Um.nullish(),locations:D(Mm).nullish(),rawInput:w().optional(),rawOutput:w().optional(),status:Nm.nullish(),title:h().nullish(),toolCallId:Lm}),Zm=p({_meta:S(h(),w()).nullish(),options:D(iP),sessionId:Y,toolCall:Fm}),H1=p({_meta:S(h(),w()).nullish(),hint:h()}),V1=H1,j1=p({_meta:S(h(),w()).nullish(),description:h(),input:V1.nullish(),name:h()}),B1=p({_meta:S(h(),w()).nullish(),availableCommands:D(j1)}),G1=p({enum:D(h()),type:fI}),W1=H([G1,F1]),q1=p({default:D(h()).nullish(),description:h().nullish(),items:W1,maxItems:N().nullish(),minItems:N().nullish(),title:h().nullish()}),Y1=H([b1.and(p({type:x("string")})),nP.and(p({type:x("number")})),bI.and(p({type:x("integer")})),eI.and(p({type:x("boolean")})),q1.and(p({type:x("array")}))]),K1=p({description:h().nullish(),properties:S(h(),Y1).optional().default({}),required:D(h()).nullish(),title:h().nullish(),type:dI.optional().default("object")}),J1=p({requestedSchema:K1}),X1=Ua(H([J1.and(p({mode:x("form")})),mI.and(p({mode:x("url")}))]),p({_meta:S(h(),w()).nullish(),message:h(),sessionId:Y})),Q1=p({cachedReadTokens:N().nullish(),cachedWriteTokens:N().nullish(),inputTokens:N(),outputTokens:N(),thoughtTokens:N().nullish(),totalTokens:N()}),eR=p({_meta:S(h(),w()).nullish(),stopReason:y1,usage:Q1.nullish(),userMessageId:h().nullish()});H([p({id:nr,result:H([O1,XC,$I,o1,s1,QP,i1,a1,nI,f1,h1,eR,g1,m1,_1,tI,Sm])}),p({error:bm,id:nr})]);const tR=p({_meta:S(h(),w()).nullish(),cost:rI.nullish(),size:N(),used:N()}),nR=H([zl.and(p({sessionUpdate:x("user_message_chunk")})),zl.and(p({sessionUpdate:x("agent_message_chunk")})),zl.and(p({sessionUpdate:x("agent_thought_chunk")})),Z1.and(p({sessionUpdate:x("tool_call")})),Fm.and(p({sessionUpdate:x("tool_call_update")})),lP.and(p({sessionUpdate:x("plan")})),B1.and(p({sessionUpdate:x("available_commands_update")})),n1.and(p({sessionUpdate:x("current_mode_update")})),NP.and(p({sessionUpdate:x("config_option_update")})),e1.and(p({sessionUpdate:x("session_info_update")})),tR.and(p({sessionUpdate:x("usage_update")}))]),Hm=p({_meta:S(h(),w()).nullish(),sessionId:Y,update:nR});p({method:h(),params:H([Hm,uI,wm]).nullish()});const Vm=p({_meta:S(h(),w()).nullish(),sessionId:Y,terminalId:h()}),rR=p({_meta:S(h(),w()).nullish(),exitCode:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:h().nullish()}),iR=p({name:h(),uri:h()}),sR=p({_meta:S(h(),w()).nullish(),repository:qI.nullish(),workspaceFolders:D(iR).nullish(),workspaceUri:h().nullish()});p({id:nr,method:h(),params:H([pP,JC,EI,tP,YP,_I,qP,JP,VP,d1,u1,U1,p1,sR,w1,HP,_m]).nullish()});const jm=p({_meta:S(h(),w()).nullish(),content:h(),path:h(),sessionId:Y});p({id:nr,method:h(),params:H([jm,Rm,Zm,Im,Om,Dm,Vm,Pm,X1,_m]).nullish()});const oR=p({_meta:S(h(),w()).nullish()});H([p({id:nr,result:H([oR,_P,CP,iI,E1,SP,rR,wI,hI,Sm])}),p({error:bm,id:nr})]);var q;class aR{constructor(e,t){_(this,q);const r=e(this),i=async(o,a)=>{var c,u,d,f,v,y,A;switch(o){case Ot.fs_write_text_file:{const k=jm.parse(a);return(c=r.writeTextFile)==null?void 0:c.call(r,k)}case Ot.fs_read_text_file:{const k=Rm.parse(a);return(u=r.readTextFile)==null?void 0:u.call(r,k)}case Ot.session_request_permission:{const k=Zm.parse(a);return r.requestPermission(k)}case Ot.terminal_create:{const k=Im.parse(a);return(d=r.createTerminal)==null?void 0:d.call(r,k)}case Ot.terminal_output:{const k=Om.parse(a);return(f=r.terminalOutput)==null?void 0:f.call(r,k)}case Ot.terminal_release:{const k=Dm.parse(a);return await((v=r.releaseTerminal)==null?void 0:v.call(r,k))??{}}case Ot.terminal_wait_for_exit:{const k=Vm.parse(a);return(y=r.waitForTerminalExit)==null?void 0:y.call(r,k)}case Ot.terminal_kill:{const k=Pm.parse(a);return await((A=r.killTerminal)==null?void 0:A.call(r,k))??{}}default:if(r.extMethod)return r.extMethod(o,a);throw we.methodNotFound(o)}},s=async(o,a)=>{switch(o){case Ot.session_update:{const c=Hm.parse(a);return r.sessionUpdate(c)}default:if(r.extNotification)return r.extNotification(o,a);throw we.methodNotFound(o)}};E(this,q,new lR(i,s,t))}async initialize(e){return await l(this,q).sendRequest(se.initialize,e)}async newSession(e){return await l(this,q).sendRequest(se.session_new,e)}async loadSession(e){return await l(this,q).sendRequest(se.session_load,e)??{}}async unstable_forkSession(e){return await l(this,q).sendRequest(se.session_fork,e)}async listSessions(e){return await l(this,q).sendRequest(se.session_list,e)}async unstable_resumeSession(e){return await l(this,q).sendRequest(se.session_resume,e)}async unstable_closeSession(e){return await l(this,q).sendRequest(se.session_close,e)}async setSessionMode(e){return await l(this,q).sendRequest(se.session_set_mode,e)??{}}async unstable_setSessionModel(e){return await l(this,q).sendRequest(se.session_set_model,e)??{}}async setSessionConfigOption(e){return await l(this,q).sendRequest(se.session_set_config_option,e)}async authenticate(e){return await l(this,q).sendRequest(se.authenticate,e)??{}}async unstable_logout(e){return await l(this,q).sendRequest(se.logout,e)??{}}async prompt(e){return await l(this,q).sendRequest(se.session_prompt,e)}async cancel(e){return await l(this,q).sendNotification(se.session_cancel,e)}async unstable_startNes(e){return await l(this,q).sendRequest(se.nes_start,e)}async unstable_suggestNes(e){return await l(this,q).sendRequest(se.nes_suggest,e)}async unstable_closeNes(e){return await l(this,q).sendRequest(se.nes_close,e)??{}}async unstable_didOpenDocument(e){return await l(this,q).sendNotification(se.document_did_open,e)}async unstable_didChangeDocument(e){return await l(this,q).sendNotification(se.document_did_change,e)}async unstable_didCloseDocument(e){return await l(this,q).sendNotification(se.document_did_close,e)}async unstable_didSaveDocument(e){return await l(this,q).sendNotification(se.document_did_save,e)}async unstable_didFocusDocument(e){return await l(this,q).sendNotification(se.document_did_focus,e)}async unstable_acceptNes(e){return await l(this,q).sendNotification(se.nes_accept,e)}async unstable_rejectNes(e){return await l(this,q).sendNotification(se.nes_reject,e)}async extMethod(e,t){return await l(this,q).sendRequest(e,t)}async extNotification(e,t){return await l(this,q).sendNotification(e,t)}get signal(){return l(this,q).signal}get closed(){return l(this,q).closed}}q=new WeakMap;var sn,da,ls,cs,Or,zr,$t,us,ue,Bm,yc,Gm,Wm,qm,Ym,vc,Li;class lR{constructor(e,t,r){_(this,ue);_(this,sn,new Map);_(this,da,0);_(this,ls);_(this,cs);_(this,Or);_(this,zr,Promise.resolve());_(this,$t,new AbortController);_(this,us);E(this,ls,e),E(this,cs,t),E(this,Or,r),E(this,us,new Promise(i=>{l(this,$t).signal.addEventListener("abort",()=>i())})),m(this,ue,Bm).call(this)}get signal(){return l(this,$t).signal}get closed(){return l(this,us)}async sendRequest(e,t){m(this,ue,vc).call(this);const r=Ah(this,da)._++,i=new Promise((s,o)=>{l(this,sn).set(r,{resolve:s,reject:o})});return await m(this,ue,Li).call(this,{jsonrpc:"2.0",id:r,method:e,params:t}),i}async sendNotification(e,t){m(this,ue,vc).call(this),await m(this,ue,Li).call(this,{jsonrpc:"2.0",method:e,params:t})}}sn=new WeakMap,da=new WeakMap,ls=new WeakMap,cs=new WeakMap,Or=new WeakMap,zr=new WeakMap,$t=new WeakMap,us=new WeakMap,ue=new WeakSet,Bm=async function(){let e;try{const t=l(this,Or).readable.getReader();try{for(;!l(this,$t).signal.aborted;){const{value:r,done:i}=await t.read();if(i)break;if(r)try{m(this,ue,Gm).call(this,r)}catch(s){console.error("Unexpected error during message processing:",r,s),"id"in r&&r.id!==void 0&&m(this,ue,Li).call(this,{jsonrpc:"2.0",id:r.id,error:{code:-32700,message:"Parse error"}})}}}finally{t.releaseLock()}}catch(t){e=t}finally{m(this,ue,yc).call(this,e)}},yc=function(e){if(l(this,$t).signal.aborted)return;const t=e??new Error("ACP connection closed");for(const r of l(this,sn).values())r.reject(t);l(this,sn).clear(),l(this,$t).abort(t)},Gm=async function(e){if("method"in e&&"id"in e){const t=await m(this,ue,Wm).call(this,e.method,e.params);"error"in t&&console.error("Error handling request",e,t.error),await m(this,ue,Li).call(this,{jsonrpc:"2.0",id:e.id,...t})}else if("method"in e){const t=await m(this,ue,qm).call(this,e.method,e.params);"error"in t&&console.error("Error handling notification",e,t.error)}else"id"in e?m(this,ue,Ym).call(this,e):console.error("Invalid message",{message:e})},Wm=async function(e,t){try{return{result:await l(this,ls).call(this,e,t)??null}}catch(r){if(r instanceof we)return r.toResult();if(r instanceof vf)return we.invalidParams(r.format()).toResult();let i;(r instanceof Error||typeof r=="object"&&r!=null&&"message"in r&&typeof r.message=="string")&&(i=r.message);try{return we.internalError(i?JSON.parse(i):{}).toResult()}catch{return we.internalError({details:i}).toResult()}}},qm=async function(e,t){try{return await l(this,cs).call(this,e,t),{result:null}}catch(r){if(r instanceof we)return r.toResult();if(r instanceof vf)return we.invalidParams(r.format()).toResult();let i;(r instanceof Error||typeof r=="object"&&r!=null&&"message"in r&&typeof r.message=="string")&&(i=r.message);try{return we.internalError(i?JSON.parse(i):{}).toResult()}catch{return we.internalError({details:i}).toResult()}}},Ym=function(e){const t=l(this,sn).get(e.id);if(t){if("result"in e)t.resolve(e.result);else if("error"in e){const{code:r,message:i,data:s}=e.error;t.reject(new we(r,i,s))}l(this,sn).delete(e.id)}else console.error("Got response to unknown request",e.id)},vc=function(){if(l(this,$t).signal.aborted)throw l(this,$t).signal.reason??new Error("ACP connection closed")},Li=async function(e){return E(this,zr,l(this,zr).then(async()=>{const t=l(this,Or).writable.getWriter();try{await t.write(e)}finally{t.releaseLock()}}).catch(t=>{m(this,ue,yc).call(this,t)})),l(this,zr)};class we extends Error{constructor(t,r,i){super(r);b(this,"code");b(this,"data");this.code=t,this.name="RequestError",this.data=i}static parseError(t,r){return new we(-32700,`Parse error${r?`: ${r}`:""}`,t)}static invalidRequest(t,r){return new we(-32600,`Invalid request${r?`: ${r}`:""}`,t)}static methodNotFound(t){return new we(-32601,`"Method not found": ${t}`,{method:t})}static invalidParams(t,r){return new we(-32602,`Invalid params${r?`: ${r}`:""}`,t)}static internalError(t,r){return new we(-32603,`Internal error${r?`: ${r}`:""}`,t)}static authRequired(t,r){return new we(-32e3,`Authentication required${r?`: ${r}`:""}`,t)}static resourceNotFound(t){return new we(-32002,`Resource not found${t?`: ${t}`:""}`,t&&{uri:t})}toResult(){return{error:{code:this.code,message:this.message,data:this.data}}}toErrorResponse(){return{code:this.code,message:this.message,data:this.data}}}const cR=/^Sender \(untrusted metadata\):\n```json\n[\s\S]*?\n```\n\n?/,uR=/^\[[^\n]*Working directory:[^\n]*\]\n\n?/,hR=/\[Television screen context\][\s\S]*?\[\/Television screen context\]\n*/,dR=/\[\[\s*(?:reply_to_current|reply_to\s*:\s*[^\]\n]+|audio_as_voice)\s*\]\]\s*/gi,fR="single_session",pR={name:"television-acp-client",version:"0.0.0"},Km="agent:main:television",gR=di(gt);var ee,Nt,Lr,Ut,Hn,Vn,on,Mr,At,lt,an,jn,Ft,ln,hs,Zt,ct,fa,Ht,C,Jm,Xm,bc,Qm,ey,ty,ny,ry,iy,sy,Tn,kr,Er,qe,oy,$r,wc,_c,Fo,ay,ds,fs,Sc,Ar,ly,cy;class mR extends gR{constructor(t){super();_(this,C);_(this,ee,yR());_(this,Nt,null);_(this,Lr,null);_(this,Ut,null);_(this,Hn,null);_(this,Vn,null);_(this,on,null);_(this,Mr,1);_(this,At,null);_(this,lt,null);_(this,an,!1);_(this,jn,!1);_(this,Ft,null);_(this,ln,new Set);_(this,hs);_(this,Zt);_(this,ct);_(this,fa,t=>{m(this,C,Xm).call(this,t)});_(this,Ht,null);_(this,ds,()=>{m(this,C,Ar).call(this,"ACP bridge websocket closed")});_(this,fs,()=>{m(this,C,Ar).call(this,"ACP bridge websocket error")});E(this,Zt,t),E(this,ct,t.sessionMode??fR),E(this,hs,t.createSocket??(r=>new WebSocket(r)))}getState(){return l(this,ee)}get messages(){return l(this,ee).messageOrder.map(t=>l(this,ee).messagesById[t]).filter(t=>t!==void 0)}async connect(){if(this.disposed)throw new Error("ACPClient has been disposed");if(l(this,ee).lifecycle.status!=="ready"){m(this,C,qe).call(this,{lifecycle:{status:"connecting"}}),l(this,Lr)??E(this,Lr,m(this,C,Jm).call(this));try{await l(this,Lr),await m(this,C,bc).call(this)}catch(t){throw m(this,C,Ar).call(this,So(t)),t}}}dispose(){m(this,C,Sc).call(this),m(this,C,qe).call(this,{lifecycle:{status:"disposed"},run:{status:"idle",stopReason:null,canCancel:!1,error:null}})}async sendMessage(t){if(await this.connect(),l(this,ee).lifecycle.status!=="ready"||l(this,ee).run.status==="running"||l(this,ee).run.status==="cancelling")throw new Error("ACPClient is not ready to send a new message");const r=t.text.trim();if(!r)throw new Error("Cannot send an empty message");m(this,C,kr).call(this,{id:m(this,C,$r).call(this,"user"),kind:"user",text:r,status:"final"}),m(this,C,qe).call(this,{run:{status:"running",stopReason:null,canCancel:!0,error:null}});try{const i=await m(this,C,Fo).call(this).prompt({sessionId:m(this,C,_c).call(this),prompt:[{type:"text",text:m(this,C,oy).call(this,r)}]});m(this,C,Tn).call(this,i.stopReason==="cancelled"?"cancelled":"final"),m(this,C,qe).call(this,{run:{status:i.stopReason==="cancelled"?"cancelled":"completed",stopReason:i.stopReason,canCancel:!1,error:null}})}catch(i){throw m(this,C,cy).call(this)||(m(this,C,Tn).call(this,"error"),m(this,C,qe).call(this,{run:{status:"error",stopReason:null,canCancel:!1,error:So(i)}})),i}}async cancel(){if(await this.connect(),!l(this,ee).run.canCancel||l(this,ee).run.status!=="running")throw new Error("No active cancellable run");m(this,C,qe).call(this,{run:{...l(this,ee).run,status:"cancelling"}}),await m(this,C,Fo).call(this).cancel({sessionId:m(this,C,_c).call(this)})}setScreenContext(t){var s,o,a;const r={screenID:t.screenID,screenName:t.screenName};if(((s=l(this,lt))==null?void 0:s.screenID)===r.screenID&&((o=l(this,lt))==null?void 0:o.screenName)===r.screenName)return;const i=((a=l(this,lt))==null?void 0:a.screenID)??null;if(E(this,lt,r),l(this,ct)==="single_session"){(!l(this,on)||i!==r.screenID)&&E(this,an,!0);return}l(this,on)!==Ef(l(this,ct),r.screenID,l(this,Zt).clientGUID??"default-client")&&(E(this,Ut,null),E(this,Hn,null),l(this,Nt)&&l(this,ee).run.status==="idle"&&m(this,C,bc).call(this).catch(c=>{m(this,C,Ar).call(this,So(c))}))}}ee=new WeakMap,Nt=new WeakMap,Lr=new WeakMap,Ut=new WeakMap,Hn=new WeakMap,Vn=new WeakMap,on=new WeakMap,Mr=new WeakMap,At=new WeakMap,lt=new WeakMap,an=new WeakMap,jn=new WeakMap,Ft=new WeakMap,ln=new WeakMap,hs=new WeakMap,Zt=new WeakMap,ct=new WeakMap,fa=new WeakMap,Ht=new WeakMap,C=new WeakSet,Jm=async function(){try{m(this,C,qe).call(this,{lifecycle:{status:"connecting"}});const{stream:t,socket:r}=await wR({serverURL:l(this,Zt).serverURL,token:l(this,Zt).token,createSocket:l(this,hs),onDisconnect:l(this,fa)});E(this,Ht,r),r.addEventListener("close",l(this,ds)),r.addEventListener("error",l(this,fs)),E(this,Nt,new aR(i=>({connection:i,sessionUpdate:async s=>{await m(this,C,ey).call(this,s)},requestPermission:async s=>m(this,C,ty).call(this,s)}),t)),await l(this,Nt).initialize({protocolVersion:jC,clientCapabilities:{},clientInfo:pR})}catch(t){throw t}},Xm=function(t){m(this,C,Ar).call(this,So(t))},bc=async function(){const t=m(this,C,ay).call(this);if(l(this,Ut)&&l(this,Hn)===t){await l(this,Ut);return}E(this,Hn,t),E(this,Ut,m(this,C,Qm).call(this,t)),await l(this,Ut)},Qm=async function(t){const r=m(this,C,Fo).call(this);m(this,C,ly).call(this);let i,s=!1;try{E(this,jn,!0),E(this,Ft,null),await r.loadSession({sessionId:t,cwd:"/",mcpServers:[],_meta:{sessionKey:t}}),i=t,s=l(this,ee).messageOrder.length>0}catch{i=(await r.newSession({cwd:"/",mcpServers:[],_meta:{sessionKey:t}})).sessionId,s=!1}finally{E(this,jn,!1),E(this,Ft,null),m(this,C,Tn).call(this,"final")}await r.setSessionConfigOption({sessionId:i,configId:"verbose_level",value:"full"}),E(this,Vn,i),E(this,on,t),s?(l(this,ln).add(t),l(this,ct)==="single_session"&&E(this,an,!1)):(l(this,ln).delete(t),E(this,an,l(this,ct)==="single_session")),m(this,C,qe).call(this,{lifecycle:{status:"ready"}})},ey=async function(t){const r=t.update;switch(r.sessionUpdate){case"user_message_chunk":r.content.type==="text"&&m(this,C,sy).call(this,r.content.text);return;case"agent_message_chunk":r.content.type==="text"&&m(this,C,ny).call(this,r.content.text);return;case"tool_call":m(this,C,ry).call(this,r);return;case"tool_call_update":m(this,C,iy).call(this,r);return;case"agent_thought_chunk":return;default:return}},ty=async function(t){return{outcome:{outcome:"cancelled"}}},ny=function(t){E(this,Ft,null);const r=vR(t);if(!r)return;if(!l(this,At)){const s={id:m(this,C,$r).call(this,"assistant"),kind:"assistant",text:r,status:"streaming"};E(this,At,s.id),m(this,C,kr).call(this,s);return}const i=l(this,ee).messagesById[l(this,At)];if(!i||i.kind!=="assistant")throw new Error("Open assistant message invariant violated");m(this,C,Er).call(this,{...i,text:`${i.text}${r}`,status:"streaming"})},ry=function(t){m(this,C,Tn).call(this,"final");const r=m(this,C,wc).call(this,t.toolCallId),i={id:(r==null?void 0:r.id)??m(this,C,$r).call(this,"tool"),kind:"tool_call",toolCallId:t.toolCallId,title:t.title,toolKind:t.kind??"other",status:t.status==="failed"?"failed":t.status==="completed"?"completed":"in_progress",text:(r==null?void 0:r.text)??"",locations:t.locations??(r==null?void 0:r.locations)};if(r){m(this,C,Er).call(this,i);return}m(this,C,kr).call(this,i)},iy=function(t){const r=m(this,C,wc).call(this,t.toolCallId),i=(r==null?void 0:r.text)??"",s=bR(t.content),o=s?`${i}${s}`:i,a={id:(r==null?void 0:r.id)??m(this,C,$r).call(this,"tool"),kind:"tool_call",toolCallId:t.toolCallId,title:(r==null?void 0:r.title)??t.toolCallId,toolKind:(r==null?void 0:r.toolKind)??"other",status:t.status==="failed"?"failed":t.status==="completed"?"completed":"in_progress",text:o,locations:t.locations??(r==null?void 0:r.locations)};if(r){m(this,C,Er).call(this,a);return}m(this,C,kr).call(this,a)},sy=function(t){if(m(this,C,Tn).call(this,"final"),!t)return;const r=l(this,jn)?l(this,Ft):null;if(!r){const s=$f(t);if(!s)return;const o={id:m(this,C,$r).call(this,"user"),kind:"user",text:s,status:"final"};m(this,C,kr).call(this,o),l(this,jn)&&E(this,Ft,o.id);return}const i=l(this,ee).messagesById[r];if(!i||i.kind!=="user")throw new Error("Replay user message invariant violated");m(this,C,Er).call(this,{...i,text:$f(`${i.text}${t}`)})},Tn=function(t){if(!l(this,At))return;const r=l(this,ee).messagesById[l(this,At)];(r==null?void 0:r.kind)==="assistant"&&m(this,C,Er).call(this,{...r,status:t}),E(this,At,null)},kr=function(t){m(this,C,qe).call(this,{messagesById:{...l(this,ee).messagesById,[t.id]:t},messageOrder:[...l(this,ee).messageOrder,t.id]})},Er=function(t){m(this,C,qe).call(this,{messagesById:{...l(this,ee).messagesById,[t.id]:t}})},qe=function(t){const r={...l(this,ee),...t};E(this,ee,{...r,sendDisabled:r.lifecycle.status!=="ready"||r.run.status==="running"||r.run.status==="cancelling",cancelDisabled:!(r.run.status==="running"||r.run.status==="cancelling")||!r.run.canCancel}),this.dispatchEvent(new Q("change"))},oy=function(t){const r=l(this,on);return!l(this,lt)||!r||!(l(this,ct)==="single_session"?l(this,an)||!l(this,ln).has(r):!l(this,ln).has(r))?t:(E(this,an,!1),l(this,ln).add(r),["[Television screen context]","This chat session is coming from a Television client in the screen below.",`screen_id: ${l(this,lt).screenID}`,`screen_name: ${l(this,lt).screenName??""}`,"When the user asks to inspect or change Television state with the tv CLI, use this screen ID with the --screen argument.","[/Television screen context]","",t].join(`
|
|
43
|
+
`))},$r=function(t){const r=`${t}-${l(this,Mr)}`;return E(this,Mr,l(this,Mr)+1),r},wc=function(t){for(const r of l(this,ee).messageOrder){const i=l(this,ee).messagesById[r];if((i==null?void 0:i.kind)==="tool_call"&&i.toolCallId===t)return i}return null},_c=function(){if(!l(this,Vn))throw new Error("ACP session is not ready");return l(this,Vn)},Fo=function(){if(!l(this,Nt))throw new Error("ACP connection is not ready");return l(this,Nt)},ay=function(){var r;if(l(this,ct)==="single_session")return`${Km}-${(l(this,Zt).clientGUID??"default-client").toLowerCase()}`;const t=(r=l(this,lt))==null?void 0:r.screenID;if(!t)throw new Error("Screen context is required for per-screen session mode");return Ef(l(this,ct),t,l(this,Zt).clientGUID??"default-client")},ds=new WeakMap,fs=new WeakMap,Sc=function(){E(this,Nt,null),E(this,Lr,null),E(this,Ut,null),E(this,Hn,null),E(this,Vn,null),E(this,on,null),l(this,Ht)&&(l(this,Ht).removeEventListener("close",l(this,ds)),l(this,Ht).removeEventListener("error",l(this,fs)),l(this,Ht).close(),E(this,Ht,null))},Ar=function(t){this.disposed||l(this,ee).lifecycle.status==="disconnected"||(m(this,C,Tn).call(this,"error"),m(this,C,Sc).call(this),m(this,C,qe).call(this,{lifecycle:{status:"disconnected",...t?{error:t}:{}},run:{status:"idle",stopReason:null,canCancel:!1,error:null}}))},ly=function(){E(this,At,null),E(this,Ft,null),E(this,Mr,1),m(this,C,qe).call(this,{run:{status:"idle",stopReason:null,canCancel:!1,error:null},messagesById:{},messageOrder:[]})},cy=function(){return l(this,ee).lifecycle.status==="disconnected"};function yR(){return{lifecycle:{status:"connecting"},run:{status:"idle",stopReason:null,canCancel:!1,error:null},messagesById:{},messageOrder:[],sendDisabled:!0,cancelDisabled:!0}}function Ef(n,e,t){return n==="single_session"?`${Km}-${t.toLowerCase()}`:`agent:main:television-${t.toLowerCase()}-${e.toLowerCase()}`}function uy(n){return n.replace(/^(?:\s*\n)+/,"")}function $f(n){let e=n;return e=e.replace(cR,""),e=e.replace(uR,""),e=e.replace(hR,""),e=uy(e),e}function vR(n){let e=n;return e=e.replace(dR,""),e=uy(e),e}function bR(n){return!n||n.length===0?"":n.flatMap(e=>e.type==="content"&&e.content.type==="text"?[e.content.text]:[]).join("")}async function wR(n){const e=n.createSocket(SR(n.serverURL,n.token));let t=!1,r,i;const s=new Promise((c,u)=>{r=c,i=u}),o=new ReadableStream({start(c){let u=!1;const d=()=>{e.send(JSON.stringify({type:"acp-bridge-connect"}))},f=A=>{const k=_R(A);if(!k)return;let I;try{I=JSON.parse(k)}catch(B){const P=B instanceof Error?B:new Error(String(B));i(P),c.error(P);return}switch(I.type){case"acp-bridge-status":if(I.status==="ready"){t||(t=!0,r());return}if(I.status==="error"||I.status==="exited"){const B=new Error(I.error??`ACP bridge ${I.status}`);t||i(B),c.error(B)}return;case"acp-bridge-message":c.enqueue(I.message);return}},v=()=>{var k;if(u)return;u=!0;const A=new Error("ACP bridge websocket closed");t||i(A),(k=n.onDisconnect)==null||k.call(n,A),c.close()},y=()=>{var k;if(u)return;u=!0;const A=new Error("ACP bridge websocket error");t||i(A),(k=n.onDisconnect)==null||k.call(n,A),c.error(A)};e.addEventListener("open",d),e.addEventListener("message",f),e.addEventListener("close",v),e.addEventListener("error",y)}}),a=new WritableStream({async write(c){await s,e.send(JSON.stringify({type:"acp-bridge-message",message:c}))},close(){e.close()},abort(){e.close()}});return await s,{stream:{readable:o,writable:a},socket:e}}function _R(n){if(typeof n=="string")return n;if(n instanceof Uint8Array)return new TextDecoder().decode(n);if(typeof Buffer<"u"&&n instanceof Buffer)return n.toString("utf8");if(typeof n=="object"&&n!==null&&"data"in n){const e=n.data;if(typeof e=="string")return e;if(e instanceof Uint8Array)return new TextDecoder().decode(e);if(Array.isArray(e))return Buffer.concat(e).toString("utf8")}return null}function SR(n,e){const t=new URL(n);return t.protocol=t.protocol==="https:"?"wss:":"ws:",t.pathname="/acp",t.search="",t.searchParams.set("token",e),t.hash="",t.toString()}function So(n){return n instanceof Error?n.message:String(n)}const Af="television.acpClientGUID",kR=di(gt);class ER extends kR{constructor(t){super();b(this,"screenManager");b(this,"clients",new Map);b(this,"options");b(this,"sessionMode");b(this,"clientGUID");b(this,"activeClient",null);b(this,"handleActiveScreenChanged",()=>{this.syncActiveClient()});this.screenManager=t.screenManager,this.sessionMode=t.sessionMode??"single_session",this.options={serverURL:t.serverURL,token:t.token,...t.createSocket?{createSocket:t.createSocket}:{},...t.sessionMode?{sessionMode:t.sessionMode}:{}},this.clientGUID=t.clientGUID??$R(t.storage??window.localStorage),this.screenManager.addEventListener("active-screen-changed",this.handleActiveScreenChanged),this.syncActiveClient()}getActiveClient(){return this.activeClient}dispose(){this.screenManager.removeEventListener("active-screen-changed",this.handleActiveScreenChanged);for(const t of this.clients.values())t.dispose();this.clients.clear(),this.activeClient=null}syncActiveClient(){const t=this.screenManager.activeScreen,r=t?this.getClientForScreen(t):null;this.activeClient!==r&&(this.activeClient=r,this.dispatchEvent(new Q("change")))}getClientForScreen(t){const r=this.sessionMode==="single_session"?"single_session":t.id;let i=this.clients.get(r);return i||(i=new mR({...this.options,sessionMode:this.sessionMode,clientGUID:this.clientGUID}),this.clients.set(r,i)),i.setScreenContext({screenID:t.id,screenName:t.name}),i}}function $R(n){const e=n.getItem(Af);if(e)return e;const t=$u().toLowerCase();return n.setItem(Af,t),t}var ps;class AR extends gt{constructor(){super();_(this,ps,t=>{const r=xR(t);r!==null&&(t.preventDefault(),this.dispatchEvent(new f0("shortcut-triggered",{shortcut:r})))});document.addEventListener("keydown",l(this,ps))}dispose(){document.removeEventListener("keydown",l(this,ps))}}ps=new WeakMap;function xR(n){for(const[e,t]of Object.entries(V0))if(TR(n,t.trigger))return e;return null}function TR(n,e){return!(n.key.toLowerCase()!==e.key.toLowerCase()||n.metaKey!==!!e.meta||n.ctrlKey!==!!e.ctrl||n.shiftKey!==!!e.shift||n.altKey!==!!e.alt)}const CR="serverURL",IR="token",PR="mode",RR="electron";function hy(n=window.location.search,e=window.location.origin){const r=new URLSearchParams(n).get(CR);return r?new URL(r).origin:new URL(e).origin}function kc(n=window.location.search){return new URLSearchParams(n).get(IR)}function dy(n=window.location.search){return new URLSearchParams(n).get(PR)===RR}/**
|
|
44
|
+
* @license
|
|
45
|
+
* Copyright 2017 Google LLC
|
|
46
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
47
|
+
*/const qi=globalThis,xf=n=>n,ia=qi.trustedTypes,Tf=ia?ia.createPolicy("lit-html",{createHTML:n=>n}):void 0,fy="$lit$",en=`lit$${Math.random().toFixed(9).slice(2)}$`,py="?"+en,DR=`<${py}>`,rr=document,Xi=()=>rr.createComment(""),Qi=n=>n===null||typeof n!="object"&&typeof n!="function",Uu=Array.isArray,OR=n=>Uu(n)||typeof(n==null?void 0:n[Symbol.iterator])=="function",Ll=`[
|
|
48
|
+
\f\r]`,$i=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Cf=/-->/g,If=/>/g,An=RegExp(`>|${Ll}(?:([^\\s"'>=/]+)(${Ll}*=${Ll}*(?:[^
|
|
49
|
+
\f\r"'\`<>=]|("|')|))|$)`,"g"),Pf=/'/g,Rf=/"/g,gy=/^(?:script|style|textarea|title)$/i,zR=n=>(e,...t)=>({_$litType$:n,strings:e,values:t}),F=zR(1),ti=Symbol.for("lit-noChange"),oe=Symbol.for("lit-nothing"),Df=new WeakMap,Ln=rr.createTreeWalker(rr,129);function my(n,e){if(!Uu(n)||!n.hasOwnProperty("raw"))throw Error("invalid template strings array");return Tf!==void 0?Tf.createHTML(e):e}const LR=(n,e)=>{const t=n.length-1,r=[];let i,s=e===2?"<svg>":e===3?"<math>":"",o=$i;for(let a=0;a<t;a++){const c=n[a];let u,d,f=-1,v=0;for(;v<c.length&&(o.lastIndex=v,d=o.exec(c),d!==null);)v=o.lastIndex,o===$i?d[1]==="!--"?o=Cf:d[1]!==void 0?o=If:d[2]!==void 0?(gy.test(d[2])&&(i=RegExp("</"+d[2],"g")),o=An):d[3]!==void 0&&(o=An):o===An?d[0]===">"?(o=i??$i,f=-1):d[1]===void 0?f=-2:(f=o.lastIndex-d[2].length,u=d[1],o=d[3]===void 0?An:d[3]==='"'?Rf:Pf):o===Rf||o===Pf?o=An:o===Cf||o===If?o=$i:(o=An,i=void 0);const y=o===An&&n[a+1].startsWith("/>")?" ":"";s+=o===$i?c+DR:f>=0?(r.push(u),c.slice(0,f)+fy+c.slice(f)+en+y):c+en+(f===-2?a:y)}return[my(n,s+(n[t]||"<?>")+(e===2?"</svg>":e===3?"</math>":"")),r]};class es{constructor({strings:e,_$litType$:t},r){let i;this.parts=[];let s=0,o=0;const a=e.length-1,c=this.parts,[u,d]=LR(e,t);if(this.el=es.createElement(u,r),Ln.currentNode=this.el.content,t===2||t===3){const f=this.el.content.firstChild;f.replaceWith(...f.childNodes)}for(;(i=Ln.nextNode())!==null&&c.length<a;){if(i.nodeType===1){if(i.hasAttributes())for(const f of i.getAttributeNames())if(f.endsWith(fy)){const v=d[o++],y=i.getAttribute(f).split(en),A=/([.?@])?(.*)/.exec(v);c.push({type:1,index:s,name:A[2],strings:y,ctor:A[1]==="."?NR:A[1]==="?"?UR:A[1]==="@"?FR:ja}),i.removeAttribute(f)}else f.startsWith(en)&&(c.push({type:6,index:s}),i.removeAttribute(f));if(gy.test(i.tagName)){const f=i.textContent.split(en),v=f.length-1;if(v>0){i.textContent=ia?ia.emptyScript:"";for(let y=0;y<v;y++)i.append(f[y],Xi()),Ln.nextNode(),c.push({type:2,index:++s});i.append(f[v],Xi())}}}else if(i.nodeType===8)if(i.data===py)c.push({type:2,index:s});else{let f=-1;for(;(f=i.data.indexOf(en,f+1))!==-1;)c.push({type:7,index:s}),f+=en.length-1}s++}}static createElement(e,t){const r=rr.createElement("template");return r.innerHTML=e,r}}function ni(n,e,t=n,r){var o,a;if(e===ti)return e;let i=r!==void 0?(o=t._$Co)==null?void 0:o[r]:t._$Cl;const s=Qi(e)?void 0:e._$litDirective$;return(i==null?void 0:i.constructor)!==s&&((a=i==null?void 0:i._$AO)==null||a.call(i,!1),s===void 0?i=void 0:(i=new s(n),i._$AT(n,t,r)),r!==void 0?(t._$Co??(t._$Co=[]))[r]=i:t._$Cl=i),i!==void 0&&(e=ni(n,i._$AS(n,e.values),i,r)),e}class MR{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){const{el:{content:t},parts:r}=this._$AD,i=((e==null?void 0:e.creationScope)??rr).importNode(t,!0);Ln.currentNode=i;let s=Ln.nextNode(),o=0,a=0,c=r[0];for(;c!==void 0;){if(o===c.index){let u;c.type===2?u=new Fu(s,s.nextSibling,this,e):c.type===1?u=new c.ctor(s,c.name,c.strings,this,e):c.type===6&&(u=new ZR(s,this,e)),this._$AV.push(u),c=r[++a]}o!==(c==null?void 0:c.index)&&(s=Ln.nextNode(),o++)}return Ln.currentNode=rr,i}p(e){let t=0;for(const r of this._$AV)r!==void 0&&(r.strings!==void 0?(r._$AI(e,r,t),t+=r.strings.length-2):r._$AI(e[t])),t++}}let Fu=class yy{get _$AU(){var e;return((e=this._$AM)==null?void 0:e._$AU)??this._$Cv}constructor(e,t,r,i){this.type=2,this._$AH=oe,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=r,this.options=i,this._$Cv=(i==null?void 0:i.isConnected)??!0}get parentNode(){let e=this._$AA.parentNode;const t=this._$AM;return t!==void 0&&(e==null?void 0:e.nodeType)===11&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=ni(this,e,t),Qi(e)?e===oe||e==null||e===""?(this._$AH!==oe&&this._$AR(),this._$AH=oe):e!==this._$AH&&e!==ti&&this._(e):e._$litType$!==void 0?this.$(e):e.nodeType!==void 0?this.T(e):OR(e)?this.k(e):this._(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==oe&&Qi(this._$AH)?this._$AA.nextSibling.data=e:this.T(rr.createTextNode(e)),this._$AH=e}$(e){var s;const{values:t,_$litType$:r}=e,i=typeof r=="number"?this._$AC(e):(r.el===void 0&&(r.el=es.createElement(my(r.h,r.h[0]),this.options)),r);if(((s=this._$AH)==null?void 0:s._$AD)===i)this._$AH.p(t);else{const o=new MR(i,this),a=o.u(this.options);o.p(t),this.T(a),this._$AH=o}}_$AC(e){let t=Df.get(e.strings);return t===void 0&&Df.set(e.strings,t=new es(e)),t}k(e){Uu(this._$AH)||(this._$AH=[],this._$AR());const t=this._$AH;let r,i=0;for(const s of e)i===t.length?t.push(r=new yy(this.O(Xi()),this.O(Xi()),this,this.options)):r=t[i],r._$AI(s),i++;i<t.length&&(this._$AR(r&&r._$AB.nextSibling,i),t.length=i)}_$AR(e=this._$AA.nextSibling,t){var r;for((r=this._$AP)==null?void 0:r.call(this,!1,!0,t);e!==this._$AB;){const i=xf(e).nextSibling;xf(e).remove(),e=i}}setConnected(e){var t;this._$AM===void 0&&(this._$Cv=e,(t=this._$AP)==null||t.call(this,e))}},ja=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,r,i,s){this.type=1,this._$AH=oe,this._$AN=void 0,this.element=e,this.name=t,this._$AM=i,this.options=s,r.length>2||r[0]!==""||r[1]!==""?(this._$AH=Array(r.length-1).fill(new String),this.strings=r):this._$AH=oe}_$AI(e,t=this,r,i){const s=this.strings;let o=!1;if(s===void 0)e=ni(this,e,t,0),o=!Qi(e)||e!==this._$AH&&e!==ti,o&&(this._$AH=e);else{const a=e;let c,u;for(e=s[0],c=0;c<s.length-1;c++)u=ni(this,a[r+c],t,c),u===ti&&(u=this._$AH[c]),o||(o=!Qi(u)||u!==this._$AH[c]),u===oe?e=oe:e!==oe&&(e+=(u??"")+s[c+1]),this._$AH[c]=u}o&&!i&&this.j(e)}j(e){e===oe?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}},NR=class extends ja{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===oe?void 0:e}},UR=class extends ja{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==oe)}},FR=class extends ja{constructor(e,t,r,i,s){super(e,t,r,i,s),this.type=5}_$AI(e,t=this){if((e=ni(this,e,t,0)??oe)===ti)return;const r=this._$AH,i=e===oe&&r!==oe||e.capture!==r.capture||e.once!==r.once||e.passive!==r.passive,s=e!==oe&&(r===oe||i);i&&this.element.removeEventListener(this.name,this,r),s&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){var t;typeof this._$AH=="function"?this._$AH.call(((t=this.options)==null?void 0:t.host)??this.element,e):this._$AH.handleEvent(e)}};class ZR{constructor(e,t,r){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=r}get _$AU(){return this._$AM._$AU}_$AI(e){ni(this,e)}}const Ml=qi.litHtmlPolyfillSupport;Ml==null||Ml(es,Fu),(qi.litHtmlVersions??(qi.litHtmlVersions=[])).push("3.3.2");const Pe=(n,e,t)=>{const r=e;let i=r._$litPart$;return i===void 0&&(r._$litPart$=i=new Fu(e.insertBefore(Xi(),null),null,void 0,{})),i._$AI(n),i};/**
|
|
50
|
+
* @license
|
|
51
|
+
* Copyright 2017 Google LLC
|
|
52
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
53
|
+
*/const vy={CHILD:2},Zu=n=>(...e)=>({_$litDirective$:n,values:e});class by{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,t,r){this._$Ct=e,this._$AM=t,this._$Ci=r}_$AS(e,t){return this.update(e,t)}update(e,t){return this.render(...t)}}/**
|
|
54
|
+
* @license
|
|
55
|
+
* Copyright 2017 Google LLC
|
|
56
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
57
|
+
*/let sa=class extends by{constructor(e){if(super(e),this.it=oe,e.type!==vy.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(e){if(e===oe||e==null)return this._t=void 0,this.it=e;if(e===ti)return e;if(typeof e!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(e===this.it)return this._t;this.it=e;const t=[e];return t.raw=t,this._t={_$litType$:this.constructor.resultType,strings:t,values:[]}}};sa.directiveName="unsafeHTML",sa.resultType=1;const HR=Zu(sa);/**
|
|
58
|
+
* @license
|
|
59
|
+
* Copyright 2017 Google LLC
|
|
60
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
61
|
+
*/class Ec extends sa{}Ec.directiveName="unsafeSVG",Ec.resultType=2;const VR=Zu(Ec),jR={size:16,color:"currentColor",weight:"regular"};function BR(n){return typeof n=="string"?{regular:n}:n}function Jt(n,e="0 0 256 256"){const t=BR(n);return r=>{const{size:i,color:s,weight:o}={...jR,...r},a=t[o]??t.regular;return F`<svg
|
|
62
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
63
|
+
data-ui-icon=""
|
|
64
|
+
width="${i}"
|
|
65
|
+
height="${i}"
|
|
66
|
+
viewBox="${e}"
|
|
67
|
+
fill="${s}"
|
|
68
|
+
>${VR(a)}</svg>`}}const GR=Jt('<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"/>'),wy=Jt('<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"/>'),WR=Jt('<path d="M181.66,133.66l-80,80a8,8,0,0,1-11.32-11.32L164.69,128,90.34,53.66a8,8,0,0,1,11.32-11.32l80,80A8,8,0,0,1,181.66,133.66Z"/>'),_y=Jt('<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"/>'),qR=Jt('<path d="M213.66,162.34l-80-80a8,8,0,0,0-11.32,0l-80,80A8,8,0,0,0,53.66,173.66L128,99.31l74.34,74.35a8,8,0,0,0,11.32-11.32Z"/>'),YR=Jt('<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"/>'),KR=Jt({regular:'<path d="M219.31,108.68l-80-80a16,16,0,0,0-22.62,0l-80,80A15.87,15.87,0,0,0,32,120v96a8,8,0,0,0,8,8h64a8,8,0,0,0,8-8V160h32v56a8,8,0,0,0,8,8h64a8,8,0,0,0,8-8V120A15.87,15.87,0,0,0,219.31,108.68ZM208,208H160V152a8,8,0,0,0-8-8H104a8,8,0,0,0-8,8v56H48V120l80-80,80,80Z"/>',bold:'<path d="M222.14,105.85l-80-80a20,20,0,0,0-28.28,0l-80,80A19.86,19.86,0,0,0,28,120v96a12,12,0,0,0,12,12h64a12,12,0,0,0,12-12V164h24v52a12,12,0,0,0,12,12h64a12,12,0,0,0,12-12V120A19.86,19.86,0,0,0,222.14,105.85ZM204,204H164V152a12,12,0,0,0-12-12H104a12,12,0,0,0-12,12v52H52V121.65l76-76,76,76Z"/>',fill:'<path d="M224,120v96a8,8,0,0,1-8,8H160a8,8,0,0,1-8-8V164a4,4,0,0,0-4-4H108a4,4,0,0,0-4,4v52a8,8,0,0,1-8,8H40a8,8,0,0,1-8-8V120a16,16,0,0,1,4.69-11.31l80-80a16,16,0,0,1,22.62,0l80,80A16,16,0,0,1,224,120Z"/>'}),JR=Jt({regular:'<path d="M227.31,73.37,182.63,28.68a16,16,0,0,0-22.63,0L36.69,152A15.86,15.86,0,0,0,32,163.31V208a16,16,0,0,0,16,16H92.69A15.86,15.86,0,0,0,104,219.31L227.31,96a16,16,0,0,0,0-22.63ZM51.31,160,136,75.31,152.69,92,68,176.68ZM48,179.31,76.69,208H48Zm48,25.38L79.31,188,164,103.31,180.69,120Zm96-96L147.31,64l24-24L216,84.68Z"/>',bold:'<path d="M230.14,70.54,185.46,25.85a20,20,0,0,0-28.29,0L33.86,149.17A19.85,19.85,0,0,0,28,163.31V208a20,20,0,0,0,20,20H92.69a19.86,19.86,0,0,0,14.14-5.86L230.14,98.82a20,20,0,0,0,0-28.28ZM93,180l71-71,11,11-71,71ZM76,163,65,152l71-71,11,11ZM52,173l15.51,15.51h0L83,204H52ZM192,103,153,64l18.34-18.34,39,39Z"/>'}),XR=Jt({regular:'<path d="M216,48H176V40a24,24,0,0,0-24-24H104A24,24,0,0,0,80,40v8H40a8,8,0,0,0,0,16h8V208a16,16,0,0,0,16,16H192a16,16,0,0,0,16-16V64h8a8,8,0,0,0,0-16ZM96,40a8,8,0,0,1,8-8h48a8,8,0,0,1,8,8v8H96Zm96,168H64V64H192ZM112,104v64a8,8,0,0,1-16,0V104a8,8,0,0,1,16,0Zm48,0v64a8,8,0,0,1-16,0V104a8,8,0,0,1,16,0Z"/>',bold:'<path d="M216,44H176V40a24,24,0,0,0-24-24H104A24,24,0,0,0,80,40v4H40a12,12,0,0,0,0,24h4V208a20,20,0,0,0,20,20H192a20,20,0,0,0,20-20V68h4a12,12,0,0,0,0-24ZM104,40h48v4H104Zm84,164H68V68H188Zm-84-48V120a12,12,0,0,1,24,0v36a12,12,0,0,1-24,0Zm40,0V120a12,12,0,0,1,24,0v36a12,12,0,0,1-24,0Z"/>'});class Sy extends Event{constructor(t){super("dropdown-item-select",{bubbles:!0,composed:!0});b(this,"value");this.value=t}}class QR extends Event{constructor(t){super("select",{bubbles:!0,composed:!0});b(this,"value");this.value=t}}var Ke,ut,cn,Nr,te,gs,z,Ey,Mi,$y,Ay,$c,xy,Ni,Cn,Bn,ms,ys,vs,pa,Ty,Cy,Ac,Ui,Iy,xc,zt;class ky extends HTMLElement{constructor(){super();_(this,z);_(this,Ke,!1);_(this,ut,null);_(this,cn,null);_(this,Nr);_(this,te,null);_(this,gs,new MutationObserver(t=>m(this,z,Ty).call(this,t)));_(this,Bn,()=>{m(this,z,Ni).call(this,!l(this,Ke))});_(this,ms,t=>{t.key!=="Enter"&&t.key!==" "||(t.preventDefault(),l(this,Bn).call(this))});_(this,ys,t=>{l(this,Ke)&&(t.composedPath().includes(this)||m(this,z,Ni).call(this,!1))});_(this,vs,t=>{t instanceof Sy&&(t.stopPropagation(),E(this,Ke,!1),m(this,z,Mi).call(this,t.value),m(this,z,zt).call(this),this.dispatchEvent(new QR(t.value)))});_(this,pa,()=>{m(this,z,Ac).call(this)});E(this,Nr,this.attachShadow({mode:"open"}))}connectedCallback(){this.addEventListener("dropdown-item-select",l(this,vs)),document.addEventListener("click",l(this,ys),!0),m(this,z,Ey).call(this),l(this,gs).observe(this,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["selected","value","slot"]}),m(this,z,zt).call(this)}disconnectedCallback(){this.removeEventListener("dropdown-item-select",l(this,vs)),document.removeEventListener("click",l(this,ys),!0),l(this,gs).disconnect(),m(this,z,xc).call(this)}attributeChangedCallback(t){if(t==="open"){m(this,z,Ni).call(this,this.hasAttribute("open"));return}m(this,z,zt).call(this)}get open(){return l(this,Ke)}set open(t){this.toggleAttribute("open",t)}get title(){return this.getAttribute("title")??""}get placement(){return this.getAttribute("placement")==="top"?"top":"bottom"}get value(){return l(this,ut)}set value(t){t===null?(m(this,z,Cn).call(this,null,null),m(this,z,$y).call(this)):m(this,z,Mi).call(this,t),m(this,z,zt).call(this)}close(){m(this,z,Ni).call(this,!1)}}Ke=new WeakMap,ut=new WeakMap,cn=new WeakMap,Nr=new WeakMap,te=new WeakMap,gs=new WeakMap,z=new WeakSet,Ey=function(){var r;const t=this.querySelector("dropdown-item[selected]");t&&m(this,z,Cn).call(this,t.value,((r=t.textContent)==null?void 0:r.trim())??null)},Mi=function(t){var r;for(const i of l(this,z,$c))i.value===t?(m(this,z,Cn).call(this,t,((r=i.textContent)==null?void 0:r.trim())??null),i.hasAttribute("selected")||i.setAttribute("selected","")):i.hasAttribute("selected")&&i.removeAttribute("selected")},$y=function(){const t=this.querySelectorAll("dropdown-item[selected]");for(const r of t)r.removeAttribute("selected")},Ay=function(t){for(const r of l(this,z,$c))if(r.value===t)return r;return null},$c=function(){return this.querySelectorAll("dropdown-item")},xy=function(){return l(this,cn)??this.title},Ni=function(t){l(this,Ke)!==t&&(E(this,Ke,t),m(this,z,zt).call(this))},Cn=function(t,r){E(this,ut,t),E(this,cn,r)},Bn=new WeakMap,ms=new WeakMap,ys=new WeakMap,vs=new WeakMap,pa=new WeakMap,Ty=function(t){t.every(i=>i.target instanceof Element?i.target.closest('[slot="trigger"]')!==null:!1)||m(this,z,Cy).call(this)},Cy=function(){var r,i;const t=this.querySelector("dropdown-item[selected]");if(t){const s=t.value,o=((r=t.textContent)==null?void 0:r.trim())??null,a=l(this,ut)!==s||l(this,cn)!==o;m(this,z,Cn).call(this,s,o),m(this,z,Mi).call(this,s),a?m(this,z,zt).call(this):m(this,z,Ui).call(this);return}if(l(this,ut)!==null){const s=m(this,z,Ay).call(this,l(this,ut));if(s){const o=((i=s.textContent)==null?void 0:i.trim())??null,a=l(this,cn)!==o;m(this,z,Cn).call(this,l(this,ut),o),m(this,z,Mi).call(this,l(this,ut)),a?m(this,z,zt).call(this):m(this,z,Ui).call(this);return}}if(l(this,ut)!==null||l(this,cn)!==null){m(this,z,Cn).call(this,null,null),m(this,z,zt).call(this);return}m(this,z,Ui).call(this)},Ac=function(){const t=l(this,Nr).querySelector('slot[name="trigger"]'),r=t instanceof HTMLSlotElement?t.assignedElements()[0]??null:null;l(this,te)!==r&&(m(this,z,xc).call(this),E(this,te,r),l(this,te)&&(l(this,te).addEventListener("click",l(this,Bn)),l(this,te)instanceof HTMLButtonElement?l(this,te).hasAttribute("type")||(l(this,te).type="button"):(l(this,te).hasAttribute("role")||l(this,te).setAttribute("role","button"),l(this,te).hasAttribute("tabindex")||(l(this,te).tabIndex=0),l(this,te).addEventListener("keydown",l(this,ms))))),m(this,z,Ui).call(this)},Ui=function(){l(this,te)&&(l(this,te).setAttribute("data-dropdown-trigger",""),l(this,te).setAttribute("aria-haspopup","listbox"),l(this,te).setAttribute("aria-expanded",l(this,Ke)?"true":"false"))},Iy=function(){return this.placement==="top"?qR:_y},xc=function(){l(this,te)&&(l(this,te).removeEventListener("click",l(this,Bn)),l(this,te).removeEventListener("keydown",l(this,ms)),l(this,te).removeAttribute("data-dropdown-trigger"),l(this,te).removeAttribute("aria-haspopup"),l(this,te).removeAttribute("aria-expanded"),E(this,te,null))},zt=function(){this.toggleAttribute("open",l(this,Ke)),Pe(F`
|
|
69
|
+
<slot name="trigger" @slotchange=${l(this,pa)}>
|
|
70
|
+
<button
|
|
71
|
+
class="fallback-trigger"
|
|
72
|
+
part="trigger"
|
|
73
|
+
type="button"
|
|
74
|
+
aria-haspopup="listbox"
|
|
75
|
+
aria-expanded=${l(this,Ke)?"true":"false"}
|
|
76
|
+
@click=${l(this,Bn)}
|
|
77
|
+
>
|
|
78
|
+
<span class="trigger-label" part="trigger-label">${l(this,z,xy)}</span>
|
|
79
|
+
<span class="trigger-icon" part="trigger-icon" aria-hidden="true">
|
|
80
|
+
${l(this,z,Iy).call(this,{size:16})}
|
|
81
|
+
</span>
|
|
82
|
+
</button>
|
|
83
|
+
</slot>
|
|
84
|
+
${l(this,Ke)?F`
|
|
85
|
+
<div
|
|
86
|
+
class="panel"
|
|
87
|
+
part="panel panel-${this.placement}"
|
|
88
|
+
role="listbox"
|
|
89
|
+
>
|
|
90
|
+
<slot></slot>
|
|
91
|
+
</div>
|
|
92
|
+
`:null}
|
|
93
|
+
`,l(this,Nr)),queueMicrotask(()=>m(this,z,Ac).call(this))},b(ky,"observedAttributes",["title","placement","open"]);class eD extends HTMLElement{}class tD extends HTMLElement{}class nD extends HTMLElement{}var or,Tc,Ry,bs,ws;class Py extends HTMLElement{constructor(){super(...arguments);_(this,or);_(this,bs,()=>{this.action||m(this,or,Ry).call(this)});_(this,ws,t=>{t.key!=="Enter"&&t.key!==" "||(t.preventDefault(),this.click())})}connectedCallback(){this.hasAttribute("role")||this.setAttribute("role","option"),this.hasAttribute("tabindex")||(this.tabIndex=0),this.addEventListener("click",l(this,bs)),this.addEventListener("keydown",l(this,ws)),m(this,or,Tc).call(this)}disconnectedCallback(){this.removeEventListener("click",l(this,bs)),this.removeEventListener("keydown",l(this,ws))}attributeChangedCallback(){m(this,or,Tc).call(this)}get value(){return this.getAttribute("value")??""}get selected(){return this.hasAttribute("selected")}get action(){return this.hasAttribute("action")}}or=new WeakSet,Tc=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")},Ry=function(){this.dispatchEvent(new Sy(this.value))},bs=new WeakMap,ws=new WeakMap,b(Py,"observedAttributes",["action","selected","value"]);customElements.get("dropdown-menu")||customElements.define("dropdown-menu",ky);customElements.get("dropdown-group")||customElements.define("dropdown-group",eD);customElements.get("dropdown-label")||customElements.define("dropdown-label",tD);customElements.get("dropdown-divider")||customElements.define("dropdown-divider",nD);customElements.get("dropdown-item")||customElements.define("dropdown-item",Py);class rD extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}var _s,yn,Cc,ga,Ss,Ic;class Dy extends HTMLElement{constructor(){super();_(this,yn);_(this,_s);_(this,ga,t=>{t.target===t.currentTarget&&m(this,yn,Cc).call(this)});_(this,Ss,t=>{this.open&&t.key==="Escape"&&m(this,yn,Cc).call(this)});E(this,_s,this.attachShadow({mode:"open"}))}connectedCallback(){document.addEventListener("keydown",l(this,Ss)),m(this,yn,Ic).call(this)}disconnectedCallback(){document.removeEventListener("keydown",l(this,Ss))}attributeChangedCallback(){m(this,yn,Ic).call(this)}get open(){return this.hasAttribute("open")}}_s=new WeakMap,yn=new WeakSet,Cc=function(){this.dispatchEvent(new rD)},ga=new WeakMap,Ss=new WeakMap,Ic=function(){Pe(F`
|
|
94
|
+
${this.open?F`
|
|
95
|
+
<div class="backdrop" part="backdrop" @click=${l(this,ga)}>
|
|
96
|
+
<slot></slot>
|
|
97
|
+
</div>
|
|
98
|
+
`:null}
|
|
99
|
+
`,l(this,_s))},b(Dy,"observedAttributes",["open"]);customElements.get("modal-overlay")||customElements.define("modal-overlay",Dy);class iD extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}class sD extends HTMLElement{}var ks,Es,Pc;class Oy extends HTMLElement{constructor(){super();_(this,Es);_(this,ks);E(this,ks,this.attachShadow({mode:"open"}))}connectedCallback(){m(this,Es,Pc).call(this)}attributeChangedCallback(){m(this,Es,Pc).call(this)}get closable(){return this.hasAttribute("closable")}}ks=new WeakMap,Es=new WeakSet,Pc=function(){const t=this.querySelector("panel-page");Pe(F`
|
|
100
|
+
<section class="panel" part="panel">
|
|
101
|
+
<header class="title-bar" part="header">
|
|
102
|
+
<h2 class="title" part="title">${(t==null?void 0:t.getAttribute("title"))??""}</h2>
|
|
103
|
+
${this.closable?F`
|
|
104
|
+
<button
|
|
105
|
+
type="button"
|
|
106
|
+
class="title-button"
|
|
107
|
+
part="button close-button"
|
|
108
|
+
aria-label="Close"
|
|
109
|
+
@click=${()=>this.dispatchEvent(new iD)}
|
|
110
|
+
>
|
|
111
|
+
<span class="close-icon" part="icon close-icon">${wy({size:16})}</span>
|
|
112
|
+
</button>
|
|
113
|
+
`:null}
|
|
114
|
+
</header>
|
|
115
|
+
<slot></slot>
|
|
116
|
+
</section>
|
|
117
|
+
`,l(this,ks))},b(Oy,"observedAttributes",["closable"]);customElements.get("panel-view")||customElements.define("panel-view",Oy);customElements.get("panel-page")||customElements.define("panel-page",sD);class oD extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}const Of='a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])',Nl=4;var Ve,Vt,Ur,et,$s,Fr,ne,Ly,My,Rc,As,xs,Gn,Ny,Dc,Uy,Fy,Zo,Ho;class zy extends HTMLElement{constructor(){super();_(this,ne);_(this,Ve,!1);_(this,Vt,null);_(this,Ur);_(this,et,null);_(this,$s,"bottom-start");_(this,Fr,!1);_(this,As,t=>{l(this,Ve)&&(l(this,Fr)||t.composedPath().includes(this)||(this.open=!1))});_(this,xs,t=>{if(l(this,Ve)){if(t.key==="Escape"){t.preventDefault(),this.open=!1;return}t.key==="Tab"&&m(this,ne,Ny).call(this,t)}});_(this,Gn,()=>{l(this,Ve)&&m(this,ne,Zo).call(this)});E(this,Ur,this.attachShadow({mode:"open"}))}connectedCallback(){m(this,ne,Ho).call(this)}disconnectedCallback(){m(this,ne,Rc).call(this)}attributeChangedCallback(t){t==="open"&&m(this,ne,Ly).call(this,this.hasAttribute("open"))}get open(){return l(this,Ve)}set open(t){this.toggleAttribute("open",t)}get anchor(){return l(this,Vt)}set anchor(t){l(this,Vt)!==t&&(E(this,Vt,t),l(this,Ve)&&m(this,ne,Zo).call(this))}}Ve=new WeakMap,Vt=new WeakMap,Ur=new WeakMap,et=new WeakMap,$s=new WeakMap,Fr=new WeakMap,ne=new WeakSet,Ly=function(t){var r;l(this,Ve)!==t&&(E(this,Ve,t),t?(E(this,Fr,!0),setTimeout(()=>{E(this,Fr,!1)},0),m(this,ne,Ho).call(this),m(this,ne,My).call(this),queueMicrotask(()=>{l(this,Ve)&&(m(this,ne,Zo).call(this),m(this,ne,Fy).call(this))})):(m(this,ne,Rc).call(this),m(this,ne,Ho).call(this),(r=l(this,Vt))==null||r.focus(),this.dispatchEvent(new oD)))},My=function(){document.addEventListener("click",l(this,As)),document.addEventListener("keydown",l(this,xs),!0),window.addEventListener("resize",l(this,Gn)),window.addEventListener("scroll",l(this,Gn),!0)},Rc=function(){document.removeEventListener("click",l(this,As)),document.removeEventListener("keydown",l(this,xs),!0),window.removeEventListener("resize",l(this,Gn)),window.removeEventListener("scroll",l(this,Gn),!0)},As=new WeakMap,xs=new WeakMap,Gn=new WeakMap,Ny=function(t){const r=m(this,ne,Dc).call(this);if(r.length===0){t.preventDefault();return}const i=r[0],s=r[r.length-1],o=m(this,ne,Uy).call(this),a=o instanceof HTMLElement&&r.includes(o);t.shiftKey?(!a||o===i)&&(t.preventDefault(),s.focus()):(!a||o===s)&&(t.preventDefault(),i.focus())},Dc=function(){if(!l(this,et))return[];const t=l(this,et).querySelector("slot");if(!(t instanceof HTMLSlotElement))return[];const r=[];for(const i of t.assignedElements({flatten:!0}))if(i instanceof HTMLElement){i.matches(Of)&&r.push(i);for(const s of i.querySelectorAll(Of))r.push(s)}return r},Uy=function(){var r;let t=document.activeElement;for(;t&&((r=t.shadowRoot)!=null&&r.activeElement);)t=t.shadowRoot.activeElement;return t},Fy=function(){var r;const t=m(this,ne,Dc).call(this);t.length>0?t[0].focus():(r=l(this,et))==null||r.focus()},Zo=function(){if(!l(this,Ve)||!l(this,Vt)||!l(this,et))return;const t=l(this,Vt).getBoundingClientRect(),r=l(this,et).getBoundingClientRect(),s=window.innerHeight-t.bottom,o=r.height+Nl,a=s<o&&t.top>o?"top-start":"bottom-start";E(this,$s,a);const c=a==="bottom-start"?t.bottom+Nl:t.top-r.height-Nl,u=t.left;l(this,et).style.top=`${c}px`,l(this,et).style.left=`${u}px`,l(this,et).setAttribute("data-placement",a)},Ho=function(){this.toggleAttribute("open",l(this,Ve)),Pe(l(this,Ve)?F`<div
|
|
118
|
+
class="panel"
|
|
119
|
+
part="panel"
|
|
120
|
+
data-placement=${l(this,$s)}
|
|
121
|
+
tabindex="-1"
|
|
122
|
+
role="dialog"
|
|
123
|
+
>
|
|
124
|
+
<slot></slot>
|
|
125
|
+
</div>`:oe,l(this,Ur)),E(this,et,l(this,Ur).querySelector(".panel"))},b(zy,"observedAttributes",["open"]);customElements.get("ui-popover")||customElements.define("ui-popover",zy);const aD=pt(),lD="No handler registered for update-content",cD="handleUpdateContent: handler already registered";function uD(n){return n instanceof Error&&typeof n.message=="string"?n.message:String(n)}const hD=di(gt);var Zr,Hr,Vr,Wn,qn,Ts,Ce,Oc,Zy,Hy,Fi,zc,hp;let dD=(hp=class extends hD{constructor(t){super();_(this,Ce);_(this,Zr);_(this,Hr);_(this,Vr);_(this,Wn,null);_(this,qn,null);_(this,Ts,!1);E(this,Zr,t);const r=t.ownerDocument.defaultView;if(!r)throw new Error("ArtifactView: iframe has no owner window");E(this,Hr,r),E(this,Vr,i=>m(this,Ce,Zy).call(this,i)),l(this,Hr).addEventListener("message",l(this,Vr))}get content(){return l(this,qn)}set content(t){m(this,Ce,zc).call(this),E(this,qn,t),l(this,Ts)&&m(this,Ce,Oc).call(this,t)}handleUpdateContent(t){if(m(this,Ce,zc).call(this),l(this,Wn)!==null)throw new Error(cD);E(this,Wn,t)}dispose(){l(this,Hr).removeEventListener("message",l(this,Vr)),E(this,Wn,null)}},Zr=new WeakMap,Hr=new WeakMap,Vr=new WeakMap,Wn=new WeakMap,qn=new WeakMap,Ts=new WeakMap,Ce=new WeakSet,Oc=function(t){const r={type:"content-updated",content:t};m(this,Ce,Fi).call(this,r)},Zy=function(t){if(this.disposed||t.source!==l(this,Zr).contentWindow)return;const r=t.data;if(DC(r)){E(this,Ts,!0),this.dispatchEvent(new aD("ready")),l(this,qn)!==null&&m(this,Ce,Oc).call(this,l(this,qn));return}if(OC(r)){m(this,Ce,Hy).call(this,r);return}},Hy=async function(t){const r=l(this,Wn);if(r===null){m(this,Ce,Fi).call(this,{type:"response",id:t.id,error:{message:lD}});return}try{await r(t.content)}catch(i){if(this.disposed)return;m(this,Ce,Fi).call(this,{type:"response",id:t.id,error:{message:uD(i)}});return}this.disposed||m(this,Ce,Fi).call(this,{type:"response",id:t.id,result:{}})},Fi=function(t){const r=l(this,Zr).contentWindow;r&&r.postMessage(t,"*")},zc=function(){if(this.disposed)throw new Error("ArtifactView is disposed")},hp);function fD(n=window){n.parent!==n&&(n.addEventListener("wheel",e=>{const t=e;n.parent.postMessage({type:"wheel",deltaX:t.deltaX,deltaY:t.deltaY,shiftKey:t.shiftKey},"*"),t.preventDefault()},{passive:!1}),n.addEventListener("message",e=>{const t=e.data;if(t!==null&&typeof t=="object"&&t.type==="scroll"){const r=t,i=typeof r.deltaX=="number"?r.deltaX:0,s=typeof r.deltaY=="number"?r.deltaY:0;n.scrollBy(i,s)}}))}function pD(){return`(${fD.toString()})(window);`}async function gD(n){const e=await fetch(n);if(!e.ok)throw new Error(`Failed to fetch artifact content: ${e.status}`);const t=await e.text(),r=new DOMParser().parseFromString(t,"text/html"),i=r.createElement("base");i.href=n,r.head.insertBefore(i,r.head.firstChild);const s=r.createElement("script");s.textContent=pD(),r.head.appendChild(s);const o=new Blob([`<!DOCTYPE html>
|
|
126
|
+
${r.documentElement.outerHTML}`],{type:"text/html"});return URL.createObjectURL(o)}const Vy=pt();class mD extends HTMLElement{constructor(){super(...arguments);b(this,"_artifact",null);b(this,"_viewURL",null);b(this,"_contentURL",null);b(this,"_screen",null);b(this,"_subscribedScreen",null);b(this,"_activeView",null);b(this,"_contentState",{kind:"idle"});b(this,"_fetchSequence",0);b(this,"_blobSequence",0);b(this,"_mountedViewURL",null);b(this,"_directRender",!1);b(this,"_blobURL",null);b(this,"handleScreenContentChanged",t=>{!this._artifact||t.artifactID!==this._artifact.id||this._activeView!==null&&this.refetchContent()})}set artifact(t){const r=this._artifact;this._artifact=t,this.render(),r!==null&&r!==t&&this.syncView()}get artifact(){return this._artifact}set viewURL(t){this._viewURL!==t&&(this._viewURL=t,this.syncView())}get viewURL(){return this._viewURL}set contentURL(t){this._contentURL!==t&&(this._contentURL=t,this.syncView())}get contentURL(){return this._contentURL}set screen(t){this._screen!==t&&(this._screen=t,this.syncScreenSubscription())}get screen(){return this._screen}set dragging(t){t?this.setAttribute("dragging","true"):this.removeAttribute("dragging")}get dragging(){return this.getAttribute("dragging")==="true"}get activeView(){return this._activeView}connectedCallback(){this.render(),this.syncView(),this.syncScreenSubscription()}disconnectedCallback(){this.teardownView(),this.unsubscribeFromScreen()}handleClose(){this._artifact&&this.dispatchEvent(new Vy("close-artifact",{artifactID:this._artifact.id,bubbles:!0,composed:!0}))}syncView(){var t;if(this.isConnected){if(this._viewURL!==null){if(this._directRender&&this.teardownView(),this._mountedViewURL!==this._viewURL){this.teardownView(),this._contentState={kind:"loading"},this._mountedViewURL=this._viewURL,this.render();const r=this.querySelector("iframe.artifact-frame");if(!r){this._contentState={kind:"error"},this.render();return}this._activeView=new dD(r),this._activeView.handleUpdateContent(async i=>{await this.saveContent(i)}),this.loadBlobFrame(this._viewURL),this.startContentFetch();return}this._activeView!==null&&this.startContentFetch();return}if(this._contentURL!==null){this.teardownView(),this._directRender=!0,this._contentState={kind:"idle"},this.render(),((t=this._artifact)==null?void 0:t.status)==="committed"&&this.loadBlobFrame(this._contentURL);return}this.teardownView(),this._contentState={kind:"idle"},this.render()}}async saveContent(t){const r=this._screen,i=this._artifact;if(!r||!i)throw new Error("artifact-view: cannot save without a screen and artifact");await r.server.client.artifacts.putContent({artifactID:i.id,content:t})}syncScreenSubscription(){if(!this.isConnected){this.unsubscribeFromScreen();return}this._subscribedScreen!==this._screen&&(this.unsubscribeFromScreen(),this._screen!==null&&(this._screen.addEventListener("artifact-content-changed",this.handleScreenContentChanged),this._subscribedScreen=this._screen))}unsubscribeFromScreen(){this._subscribedScreen!==null&&(this._subscribedScreen.removeEventListener("artifact-content-changed",this.handleScreenContentChanged),this._subscribedScreen=null)}startContentFetch(){this._fetchSequence+=1;const t=this._fetchSequence,r=this._contentURL,i=this._activeView;if(!i||r===null){this._contentState={kind:"error"},this.render();return}this._contentState={kind:"loading"},(async()=>{try{const s=await fetch(r);if(t!==this._fetchSequence)return;if(!s.ok){this._contentState={kind:"error"},this.teardownView(),this.render();return}const o=await s.text();if(t!==this._fetchSequence||this._activeView!==i)return;this._activeView.content=o,this._contentState={kind:"ready"}}catch{if(t!==this._fetchSequence)return;this._contentState={kind:"error"},this.teardownView(),this.render()}})()}refetchContent(){this._fetchSequence+=1;const t=this._fetchSequence,r=this._contentURL,i=this._activeView;!i||r===null||(async()=>{try{const s=await fetch(r);if(t!==this._fetchSequence||!s.ok)return;const o=await s.text();if(t!==this._fetchSequence||this._activeView!==i)return;this._activeView.content=o}catch{}})()}loadBlobFrame(t){this._blobSequence+=1;const r=this._blobSequence;(async()=>{try{const i=await gD(t);if(r!==this._blobSequence){URL.revokeObjectURL(i);return}this._blobURL=i,this.render();const s=this.querySelector("iframe.artifact-frame");s&&(s.src=i)}catch{if(r!==this._blobSequence)return;this._contentState={kind:"error"},this.teardownView(),this.render()}})()}teardownView(){this._activeView!==null&&(this._activeView.dispose(),this._activeView=null),this._blobURL!==null&&(URL.revokeObjectURL(this._blobURL),this._blobURL=null),this._mountedViewURL=null,this._directRender=!1,this._fetchSequence+=1,this._blobSequence+=1}contentTemplate(){return this._contentState.kind==="error"?F`
|
|
127
|
+
<div class="artifact-content artifact-placeholder">
|
|
128
|
+
<em>Failed to load content</em>
|
|
129
|
+
</div>
|
|
130
|
+
`:this._viewURL!==null||this._directRender?F`
|
|
131
|
+
<iframe
|
|
132
|
+
class="artifact-frame artifact-content"
|
|
133
|
+
src=${this._blobURL??"about:blank"}
|
|
134
|
+
sandbox="allow-scripts"
|
|
135
|
+
></iframe>
|
|
136
|
+
`:F`
|
|
137
|
+
<div class="artifact-content artifact-placeholder">
|
|
138
|
+
<em>Artifact unavailable</em>
|
|
139
|
+
</div>
|
|
140
|
+
`}template(){const t=this._artifact;return F`
|
|
141
|
+
${this.contentTemplate()}
|
|
142
|
+
<footer class="artifact-title-bar" drag-handle>
|
|
143
|
+
<div class="artifact-title-group">
|
|
144
|
+
<span class="artifact-title-icon">${GR({size:16})}</span>
|
|
145
|
+
<span class="artifact-title">${t.title}</span>
|
|
146
|
+
</div>
|
|
147
|
+
<button
|
|
148
|
+
icon-only
|
|
149
|
+
class="artifact-close-btn"
|
|
150
|
+
@click=${()=>this.handleClose()}
|
|
151
|
+
aria-label="Close"
|
|
152
|
+
>
|
|
153
|
+
${wy({size:16})}
|
|
154
|
+
</button>
|
|
155
|
+
</footer>
|
|
156
|
+
`}render(){this._artifact&&(this.setAttribute("type",this._artifact.type),Pe(this.template(),this))}}customElements.define("artifact-view",mD);const ke=n=>({type:"px",...n}),Te=n=>({type:"unit",...n}),ko=2,yD=2;class vD{constructor(e){b(this,"basis");b(this,"min");b(this,"_gap");b(this,"_viewport");b(this,"_unit");this.basis=e.basis,this.min=e.min,this._viewport=e.viewport,this._gap=e.gap??ke({x:pe,y:pe});const t=this._viewport.x??tr,r=this._viewport.y??Xo,i=this._gap.x??pe,s=this._gap.y??pe,o=tr+i*yD,a=t<=o,c=a?t-i*ko:Math.min(tr,t-i*ko),u=a?r-s*ko:Math.min(Xo,r-s*ko),d=(c-i*(Ct-1))/Ct,f=(u-s*(Xe-1))/Xe,v=this.basis.x??0,y=this.basis.y??0,A=this.min.x??0,k=this.min.y??0;this._unit=ke(a?{x:Math.max(A,d),y:Math.max(k,f)}:{x:Math.max(A,Math.min(v,d)),y:Math.max(k,Math.min(y,f))})}get unit(){return this._unit}get viewport(){return this._viewport}get gap(){return this._gap}toUnits(e){return Te({x:e.x==null?void 0:e.x/(this._unit.x??1),y:e.y==null?void 0:e.y/(this._unit.y??1)})}toPixels(e){const t=this._unit.x??0,r=this._unit.y??0,i=this._gap.x??pe,s=this._gap.y??pe,o=e.x==null?void 0:e.x*t+Math.max(0,e.x-1)*i,a=e.y==null?void 0:e.y*r+Math.max(0,e.y-1)*s;return ke({x:o,y:a})}}const ir=1e-4,Bt=1e-6,bD=40,wD=24;function jy(n,e){return Math.max(0,n-e*2)}function By(n){const e=[0];for(const t of n)e.push((e[e.length-1]??0)+t);return e}function Gy(n){const e=[0];for(let t=0;t<n.length;t+=1){const r=e[t]??0;e.push(r+n[t]+pe)}return e}function Wy(n,e,t){if(e<0||e>=n.length)return 0;let r=0,i=0;for(let s=e;s<n.length;s+=1){const o=n[s],a=i===0?o:r+pe+o;if(a>t+ir)break;r=a,i+=1}return Math.max(1,i)}function _D(n,e,t){if(e<0||e>=n.length)return 0;let r=0,i=0;for(let s=e;s>=0;s-=1){const o=n[s],a=i===0?o:r+pe+o;if(a>t+ir)break;r=a,i+=1}return Math.max(1,i)}function SD(n,e){if(n.length===0)return 0;let t=0,r=0;for(let i=n.length-1;i>=0;i-=1){const s=n[i],o=r===0?s:t+pe+s;if(o>e+ir)break;t=o,r+=1}return Math.max(1,r)}function Hu(n,e){if(n.length===0)return 0;const t=SD(n,e);return Math.max(0,n.length-t)}function zf(n,e,t){if(n.length===0)return 0;const r=Wy(n,e,t),i=Math.min(n.length,e+r);if(i<=e)return 0;const s=n.slice(e,i);return s.reduce((o,a)=>o+a,0)+Math.max(0,s.length-1)*pe}function Lc(n,e,t){const r=n[e]??0;return t-r}function xr(n,e,t,r,i){if(n.length===0)return 0;const s=Hu(n,i),o=e[s]??0,a=Math.max(0,Math.min(o,t));let c=0;for(let Z=0;Z<s;Z+=1){const U=e[Z]??0,ge=e[Z+1]??U;if(a>=U&&a<=ge+ir){c=Z;break}c=Z+1}const u=Math.min(c+1,s),d=e[c]??0,f=e[u]??d,v=Math.max(f-d,ir),y=u===c?0:(a-d)/v,A=Gy(n),k=zf(n,c,i),I=zf(n,u,i),B=(r-k)/2,P=(r-I)/2,le=Lc(A,c,B),M=Lc(A,u,P);return le+(M-le)*y}function Lf(n,e,t,r,i){const s=Hu(n,r),o=e[s]??0;let a=0,c=o;for(let u=0;u<bD;u+=1){const d=(a+c)/2;xr(n,e,d,t,r)>i?a=d:c=d}return(a+c)/2}function Mf(n,e,t){const r=Gy(n),[i,s]=e,o=n.slice(i,s+1),a=o.reduce((u,d)=>u+d,0)+Math.max(0,o.length-1)*pe,c=(t-a)/2;return Lc(r,i,c)}function kD(n,e,t){const r=Wy(n,e,t);return[e,Math.min(n.length-1,e+r-1)]}function ED(n,e,t){const r=_D(n,e,t);return[Math.max(0,e-r+1),e]}function $D(n){const e=new Set,t=[];for(const r of n){const i=`${r.nodeRange[0]}:${r.nodeRange[1]}`;if(e.has(i))continue;const s=t[t.length-1];s&&Math.abs(s.anchor-r.anchor)<=Bt||(e.add(i),t.push(r))}return t}function AD(n){const{nodeCols:e,nodeWidthsPx:t,viewportWidthPx:r}=n;if(e.length===0||t.length===0)return{viewspans:[],minScroll:0,maxScroll:0};const i=n.gapPx??pe,s=jy(r,i),o=By(e),a=Hu(t,s),c=o[a]??0,u=[];for(let d=0;d<=a;d+=1){const f=kD(t,d,s),v=Mf(t,f,r),y=Lf(t,o,r,s,v);u.push({nodeRange:f,anchor:Math.max(0,Math.min(c,y))})}for(let d=t.length-1;d>=0;d-=1){const f=ED(t,d,s),v=`${f[0]}:${f[1]}`;if(u.some(k=>`${k.nodeRange[0]}:${k.nodeRange[1]}`===v))continue;const y=Mf(t,f,r),A=Lf(t,o,r,s,y);u.push({nodeRange:f,anchor:Math.max(0,Math.min(c,A))})}return u.sort((d,f)=>Math.abs(d.anchor-f.anchor)>Bt?d.anchor-f.anchor:d.nodeRange[0]!==f.nodeRange[0]?d.nodeRange[0]-f.nodeRange[0]:d.nodeRange[1]-f.nodeRange[1]),{viewspans:$D(u),minScroll:0,maxScroll:c}}function xD(n,e){var i;let t=0,r=Number.POSITIVE_INFINITY;for(let s=0;s<n.length;s+=1){const o=Math.abs((((i=n[s])==null?void 0:i.anchor)??0)-e);if(o+Bt<r){r=o,t=s;continue}Math.abs(o-r)<=Bt&&s<t&&(t=s)}return t}function TD(n,e,t){return t<=0?0:Math.max(0,Math.min(t-1,n+e))}function Ai(n,e,t){return Math.max(e,Math.min(t,n))}class CD extends gt{constructor(t){super();b(this,"_scroll",0);b(this,"minScroll",0);b(this,"maxScroll",0);b(this,"viewspans",[]);b(this,"activeViewspanIndex",null);b(this,"nodeWidthsPx",[]);b(this,"boundaryCols",[0]);b(this,"viewportWidthPx",0);b(this,"framedViewportWidthPx",0);this._scroll=(t==null?void 0:t.x)??0}get scroll(){return Te({x:this._scroll})}get translate(){return ke({x:xr(this.nodeWidthsPx,this.boundaryCols,this._scroll,this.viewportWidthPx,this.framedViewportWidthPx)})}set scroll(t){const r=Ai(t.x??this._scroll,this.minScroll,this.maxScroll);Math.abs(r-this._scroll)<=Bt||(this._scroll=r,this.activeViewspanIndex=null,this.dispatchEvent(new Ei("layout-scroll",{scroll:this.scroll})))}rebuild(t){const r=t.nodeWidths.map(u=>Math.max(0,u.x??0)),i=r.map(u=>t.grid.toPixels(Te({x:u})).x??0),s=t.grid.viewport.x??0,o=t.grid.gap.x??pe,a=AD({nodeCols:r,nodeWidthsPx:i,viewportWidthPx:s,gapPx:o});this.nodeWidthsPx=i,this.boundaryCols=By(r),this.viewportWidthPx=s,this.framedViewportWidthPx=jy(s,o),this.viewspans=a.viewspans,this.minScroll=a.minScroll,this.maxScroll=a.maxScroll,this.activeViewspanIndex=null;const c=Ai(this._scroll,this.minScroll,this.maxScroll);Math.abs(c-this._scroll)>Bt&&(this._scroll=c,this.dispatchEvent(new Ei("layout-scroll",{scroll:this.scroll})))}step(t){var a;if(this.viewspans.length===0)return;const r=this.activeViewspanIndex??xD(this.viewspans,this._scroll),i=TD(r,t,this.viewspans.length),s=((a=this.viewspans[i])==null?void 0:a.anchor)??this._scroll,o=Ai(s,this.minScroll,this.maxScroll);this.activeViewspanIndex=i,!(Math.abs(o-this._scroll)<=Bt)&&(this._scroll=o,this.dispatchEvent(new Ei("layout-scroll",{scroll:this.scroll})))}wheel(t){const r=Ai(this._scroll+(t.x??0),this.minScroll,this.maxScroll);this.activeViewspanIndex=null,!(Math.abs(r-this._scroll)<=Bt)&&(this._scroll=r,this.dispatchEvent(new Ei("layout-scroll",{scroll:this.scroll})))}wheelPixels(t){const r=t.x??0;if(Math.abs(r)<=ir)return;this.activeViewspanIndex=null;const i=xr(this.nodeWidthsPx,this.boundaryCols,this._scroll,this.viewportWidthPx,this.framedViewportWidthPx),s=i-r,o=xr(this.nodeWidthsPx,this.boundaryCols,this.maxScroll,this.viewportWidthPx,this.framedViewportWidthPx),a=xr(this.nodeWidthsPx,this.boundaryCols,this.minScroll,this.viewportWidthPx,this.framedViewportWidthPx),c=Math.max(o,Math.min(a,s));if(Math.abs(c-i)<=ir)return;let u=this.minScroll,d=this.maxScroll;for(let v=0;v<wD;v+=1){const y=(u+d)/2;xr(this.nodeWidthsPx,this.boundaryCols,y,this.viewportWidthPx,this.framedViewportWidthPx)>c?u=y:d=y}const f=Ai((u+d)/2,this.minScroll,this.maxScroll);Math.abs(f-this._scroll)<=Bt||(this._scroll=f,this.dispatchEvent(new Ei("layout-scroll",{scroll:this.scroll})))}}const Ul={"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}},ID=["stack-above","stack-below","reorder-before","reorder-after"];function Fl(n,e){return{left:n.left+n.width*e.left,top:n.top+n.height*e.top,width:n.width*e.width,height:n.height*e.height}}function xn(n,e,t){return n>=t.left&&n<t.left+t.width&&e>=t.top&&e<t.top+t.height}function Vu(n,e){for(const t of n){if(t.type==="card"&&t.id===e)return t;if(t.type==="stack")for(const r of t.children){if(r.type==="card"&&r.id===e)return r;if(r.type==="row"){for(const i of r.children)if(i.id===e)return i}}}return null}function Mc(n){return n.height===Xe||n.height===fn?{...n,height:fn}:n}function Nc(n){return n.height===fn?{...n,height:Xe}:n}function PD(n,e,t,r){const i=n.findIndex(d=>d.type==="stack"&&d.id===e);if(i===-1)return n;const s=n[i];if(!s||s.type!=="stack")return n;const o=s.children.find(d=>d.type==="card"&&d.id===t);if(!o||o.type!=="card")return n;const a=s.children.filter(d=>d.id!==t);if(a.length===s.children.length||a.length<1)return n;const c=[...n];if(a.length===1){const[d]=a;c[i]=d.type==="card"?Nc(d):d}else c[i]={...s,children:a};const u=Math.max(0,Math.min(r,c.length));return c.splice(u,0,Nc(o)),c}const RD=pt(),DD=pt(),OD=50;function zD(n,e){if(n.type!==e.type)return!1;switch(n.type){case"reorder":return e.index===n.index;case"stack":return e.targetCardId===n.targetCardId&&e.position===n.position;case"stack-child-noop":return!0;case"stack-child-extract":return e.toIndex===n.toIndex;case"stack-child-reorder":return e.position===n.position;default:return!1}}function Qs(n){return{id:n.id,type:"drop-target",width:n.width,height:n.height}}function Nf(n){return n.map(MD)}function LD(n){return n.type==="drop-target"?{id:n.id,type:"card",artifactID:n.id,width:n.width,height:n.height}:n}function MD(n){return n.type==="drop-target"?{id:n.id,type:"card",artifactID:n.id,width:n.width,height:n.height}:n.type==="stack"?{...n,children:n.children.map(LD)}:n}function qy(n,e){return n.find(r=>r.type==="card"&&r.id===e)??null}function Uf(n,e){return n.find(r=>r.type==="stack"&&r.id===e)??null}function ND(n,e){const t=[...e],r=t.findIndex(a=>a.type==="card"&&a.id===n.nodeId);if(r===-1)return null;const i=t[r];if(!i||i.type!=="card")return null;t.splice(r,1);const s=Math.max(0,Math.min(n.lastReorderIndex,t.length));t.splice(s,0,i);const o=t.findIndex(a=>a.type==="card"&&a.id===n.nodeId);return o===-1?null:{base:t,visualDraggedIndex:o}}function UD(n,e,t,r){const i=[...n.base];i.splice(n.visualDraggedIndex,1);const s=i.findIndex(v=>v.type==="card"&&v.id===t.targetCardId),o=s===-1?null:i[s];if(!o||o.type!=="card")return null;const a=qy(r,e.nodeId);if(!a)return null;const c=Mc(a),u=Mc(o),d=Qs(c),f=t.position==="above"?[d,u]:[u,d];return i[s]={id:o.id,type:"stack",children:f},i}function Zl(n,e){return n.parentStackId?ZD(n,e):FD(n,e)}function FD(n,e){const t=n.hitTarget;if(t.type==="reorder"){const r=e[n.sourceIndex];if(!r||r.type!=="card")return[...e];const i=[...e];return i.splice(n.sourceIndex,1),i.splice(t.index,0,Qs(r)),i}if(t.type==="stack"){const r=ND(n,e);return r?UD(r,n,t,e)??[...e]:[...e]}return[...e]}function ZD(n,e){const t=n.hitTarget;switch(t.type){case"stack-child-reorder":return HD(n,e,t.position);case"stack-child-extract":return VD(n,e,t.toIndex);case"stack-child-noop":return jD(n,e);default:return[...e]}}function HD(n,e,t){const r=e.findIndex(v=>v.type==="stack"&&v.id===n.parentStackId);if(r===-1)return[...e];const i=e[r];if(!i||i.type!=="stack")return[...e];if(!i.children.every(v=>v.type==="card"))return[...e];const s=i.children,o=s.findIndex(v=>v.id===n.nodeId);if(o===-1)return[...e];const a=s[o],c=s.filter(v=>v.id!==n.nodeId),u=Qs(a),d=t==="above"?[u,...c]:[...c,u],f=[...e];return f[r]={...i,children:d},f}function VD(n,e,t){if(!n.parentStackId)return[...e];const r=PD(e,n.parentStackId,n.nodeId,t);if(r===e)return[...e];const i=r.findIndex(a=>a.type==="card"&&a.id===n.nodeId);if(i===-1)return[...e];const s=r[i];if(!s||s.type!=="card")return[...e];const o=[...r];return o[i]=Qs(s),o}function jD(n,e){const t=e.findIndex(c=>c.type==="stack"&&c.id===n.parentStackId);if(t===-1)return[...e];const r=e[t];if(!r||r.type!=="stack")return[...e];const i=r.children.findIndex(c=>c.type==="card"&&c.id===n.nodeId);if(i===-1)return[...e];const s=r.children[i];if(!s||s.type!=="card")return[...e];const o=[...e],a=[...r.children];return a[i]=Qs(s),o[t]={...r,children:a},o}function BD(n,e){return e.find(r=>r.type==="stack"&&r.id===n.id)?n.id:$u()}function GD(n,e,t){if(n.type==="drop-target"){const r=Vu(e,t);if(!r)throw new Error(`finalize: missing dragged card ${t}`);return Mc(r)}return n}function WD(n,e,t){const r=n.children.map(s=>GD(s,e,t));return{id:BD(n,e),type:"stack",children:r}}function qD(n,e,t){if(n.type==="drop-target"){const r=Vu(e,t);if(!r)throw new Error(`finalize: missing dragged card ${t}`);return qy(e,t)!==null?r:Nc(r)}return n.type==="card"||n.type==="row"?n:WD(n,e,t)}function YD(n,e,t){return n.map(r=>qD(r,e,t))}function KD(n,e){return JSON.stringify(n)===JSON.stringify(e)}const JD=di(gt);class XD extends JD{constructor(t={}){super();b(this,"pending",null);b(this,"active",null)}start(t){if(this.pending||this.active)return;const r=t.pointer.x??0,i=t.pointer.y??0;this.pending={startX:r,startY:i,grabOffsetX:t.grabOffset.x??0,grabOffsetY:t.grabOffset.y??0,nodeId:t.nodeId,sourceIndex:t.source.index,parentStackId:t.source.parentId,width:t.size.x??0,height:t.size.y??0,baseLayout:t.layout}}update(t){const r=t.pointer.x??0,i=t.pointer.y??0,s=this.pending;if(s){const u=r-s.startX,d=i-s.startY;Math.hypot(u,d)>=E0&&(this.pending=null,this.active={...s,pointerX:r,pointerY:i,hitTarget:{type:"reorder",index:s.sourceIndex},lastReorderIndex:s.sourceIndex},this.emitDrag(),this.dispatchEvent(new Q("change")));return}if(!this.active)return;const o=Zl(this.active,this.active.baseLayout),a=this.getHitTargetForPointer(r,i,t,o),c=a.type==="reorder"?a.index:this.active.lastReorderIndex;this.active.pointerX===r&&this.active.pointerY===i&&zD(this.active.hitTarget,a)&&this.active.lastReorderIndex===c||(this.active={...this.active,pointerX:r,pointerY:i,hitTarget:a,lastReorderIndex:c},this.emitDrag(),this.dispatchEvent(new Q("change")))}drop(){if(this.pending){this.cancel();return}if(!this.active)return;const t=this.active.baseLayout;let r=null;try{const i=Zl(this.active,t),s=YD(i,t,this.active.nodeId);KD(s,t)||(r=s)}catch{r=null}this.reset(),r&&this.dispatchEvent(new DD("drop",{layout:r})),this.dispatchEvent(new Q("change"))}cancel(){!this.pending&&!this.active||(this.reset(),this.dispatchEvent(new Q("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 t=Zl(this.active,this.active.baseLayout);this.dispatchEvent(new RD("drag",{nodeId:this.active.nodeId,source:{index:this.active.sourceIndex,parentId:this.active.parentStackId},grabOffset:ke({x:this.active.grabOffsetX,y:this.active.grabOffsetY}),pointer:ke({x:this.active.pointerX,y:this.active.pointerY}),size:ke({x:this.active.width,y:this.active.height}),projectedLayout:t}))}getHitTargetForPointer(t,r,i,s){return this.active?this.isPointerInsideDragBounds(t,r,i.viewport)?this.active.parentStackId?this.getStackChildHitTarget(t,r,i,s):this.getTopLevelCardHitTarget(t,r,i,s):{type:"reorder",index:this.active.sourceIndex}:{type:"reorder",index:0}}getStackChildHitTarget(t,r,i,s){var u;if(!((u=this.active)!=null&&u.parentStackId))return{type:"stack-child-noop"};const o=this.getSourceStackInteractionRect(i.geometry);if(o&&xn(t,r,o)){const d=o.top+o.height/2;return{type:"stack-child-reorder",position:r<d?"above":"below"}}const a=this.getSourceRemainingSiblingRect(i.geometry);if(a&&xn(t,r,a)){const d=a.top+a.height/2;return{type:"stack-child-reorder",position:r<d?"above":"below"}}return{type:"stack-child-extract",toIndex:this.getTopLevelReorderIndexForPointer(t,r,i,s)}}getSourceRemainingSiblingRect(t){var s,o;if(!((s=this.active)!=null&&s.parentStackId))return;const r=Uf(this.active.baseLayout,this.active.parentStackId);if(!r)return;const i=r.children.find(a=>{var c;return a.type==="card"&&a.id!==((c=this.active)==null?void 0:c.nodeId)});if(i)return(o=t.find(a=>a.id===i.id))==null?void 0:o.rect}getSourceStackInteractionRect(t){var o;if(!((o=this.active)!=null&&o.parentStackId))return;const r=t.find(a=>{var c;return a.id===((c=this.active)==null?void 0:c.parentStackId)});if(r)return this.active.sourceStackRect=r.rect,r.rect;const i=Uf(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=t.find(c=>c.id===s.id);if(a)return a.rect}return this.active.sourceStackRect}getTopLevelCardHitTarget(t,r,i,s){var y,A,k;const o=this.getTopLevelZoneNodes(i.geometry,s);if(o.length===0)return{type:"reorder",index:((y=this.active)==null?void 0:y.sourceIndex)??0};const c=(i.effectiveVelocity??0)<=OD;for(const I of o){const B=I.rect;if(!xn(t,r,B))continue;const P=this.resolveTopLevelTargetForCard(t,r,I,I.logicalIndex,c);if(P)return P;if(!c&&((A=this.active)!=null&&A.hitTarget))return this.active.hitTarget}const u=this.getNearestTargetableZone(t,o);if(!u)return{type:"reorder",index:((k=this.active)==null?void 0:k.sourceIndex)??0};const d=Math.max(u.rect.left,Math.min(u.rect.left+u.rect.width,t)),f=this.resolveTopLevelTargetForCard(d,r,u,u.logicalIndex,c);if(f)return f;const v=u.rect.left+u.rect.width/2;return{type:"reorder",index:t<v?u.logicalIndex:u.logicalIndex+1}}getTopLevelReorderIndexForPointer(t,r,i,s){var u,d;const o=this.getTopLevelZoneNodes(i.geometry,s);if(o.length===0)return((u=this.active)==null?void 0:u.sourceIndex)??0;for(const f of o){if(!xn(t,r,f.rect))continue;const v=Fl(f.rect,Ul["reorder-before"]);if(xn(t,r,v))return f.logicalIndex;const y=Fl(f.rect,Ul["reorder-after"]);if(xn(t,r,y))return f.logicalIndex+1}const a=this.getNearestTargetableZone(t,o);if(!a)return((d=this.active)==null?void 0:d.sourceIndex)??0;const c=a.rect.left+a.rect.width/2;return t<c?a.logicalIndex:a.logicalIndex+1}getTopLevelZoneNodes(t,r){const i=new Map(r.map(a=>[a.id,a])),s=[];let o=0;for(const a of t){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(t,r,i,s,o){const a=i.rect;for(const c of ID){if(!o&&(c==="stack-above"||c==="stack-below"))continue;const u=Ul[c],d=Fl(a,u);if(xn(t,r,d))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(t,r){let i=null,s=Number.POSITIVE_INFINITY;for(const o of r){const a=o.rect.left,c=o.rect.left+o.rect.width,u=t<a?a-t:t>c?t-c:0;u<s&&(s=u,i=o)}return i}isPointerInsideDragBounds(t,r,i){return t>=i.left&&t<=i.left+i.width&&r>=i.top&&r<=i.top+i.height}}const Ff=60,QD=80,Zf=.5,Hf=10;class eO{constructor(){b(this,"awaitingFreshWheelGesture",!1);b(this,"lastWheelEventAt",Number.NEGATIVE_INFINITY);b(this,"lastWheelDeltaX",0);b(this,"activeGestureType","none");b(this,"lastWheelGestureAt",Number.NEGATIVE_INFINITY)}markKeyboardNavigation(e){this.awaitingFreshWheelGesture=!0,this.lastWheelEventAt=e,this.activeGestureType="none"}reset(){this.awaitingFreshWheelGesture=!1,this.lastWheelEventAt=Number.NEGATIVE_INFINITY,this.lastWheelDeltaX=0,this.activeGestureType="none",this.lastWheelGestureAt=Number.NEGATIVE_INFINITY}decide(e){const{now:t,shiftKey:r,deltaX:i,deltaY:s,overArtifactContent:o}=e;t-this.lastWheelGestureAt>=Ff&&(this.activeGestureType="none");const c=r&&s!==0,u=c?s:i,d=Math.abs(u),f=Math.abs(s);return this.activeGestureType==="vertical-artifact"&&o?d>=Zf&&d>=f*Hf?this.classifyHorizontal(t,u):(this.lastWheelGestureAt=t,{type:"scroll-native"}):this.activeGestureType==="horizontal-filmstrip"?!c&&o&&f>0&&f>=d*Hf?(this.activeGestureType="vertical-artifact",this.lastWheelGestureAt=t,{type:"scroll-native"}):this.classifyHorizontal(t,u):d<Zf?(o&&(this.activeGestureType="vertical-artifact"),this.lastWheelGestureAt=t,{type:"scroll-native"}):c||d>f?this.classifyHorizontal(t,u):f>d?(o&&(this.activeGestureType="vertical-artifact"),this.lastWheelGestureAt=t,{type:"scroll-native"}):o?(this.activeGestureType="vertical-artifact",this.lastWheelGestureAt=t,{type:"scroll-native"}):this.classifyHorizontal(t,u)}classifyHorizontal(e,t){const r=e-this.lastWheelEventAt,i=Math.sign(this.lastWheelDeltaX),s=Math.sign(t),o=i!==0&&s!==0&&i!==s,a=i!==0&&Math.abs(t)>=Math.abs(this.lastWheelDeltaX)+QD;return this.awaitingFreshWheelGesture&&r<Ff&&!o&&!a?{type:"ignore"}:(this.lastWheelEventAt=e,this.lastWheelDeltaX=t,this.lastWheelGestureAt=e,this.awaitingFreshWheelGesture=!1,this.activeGestureType="horizontal-filmstrip",{type:"scroll-horizontal",horizontalDelta:t})}}const tO=2,Vf=1e3,Eo=1e-4;function jf(n,e,t){if(n===0)return 0;const r=e.toPixels(Te({y:Xe})).y??0;return(t-r)/tO}function Hl(n){const e=n.clientWidth>0?n.clientWidth:tr,t=n.clientHeight>0?n.clientHeight:Xo;let r=0,i=0;if(n.isConnected){const o=getComputedStyle(n);r=parseFloat(o.paddingTop)||0,i=parseFloat(o.paddingBottom)||0}const s=Math.max(1,t-r-i);return{width:e,height:s,offsetY:r}}class nO extends Event{constructor(t){super("scroll",{bubbles:!0,composed:!0});b(this,"scrollPosition");this.scrollPosition=t}}class Yy extends Event{constructor(t){super("layout-change",{bubbles:!0,composed:!0});b(this,"layout");this.layout=t}}class rO extends HTMLElement{constructor(){super();b(this,"_layout",[]);b(this,"_scrollPosition",0);b(this,"layoutGrid",null);b(this,"layoutScroll",new CD(Te({x:0})));b(this,"scrollModelKey","");b(this,"resizeObserver",null);b(this,"renderPending",!1);b(this,"animateNextRender",!0);b(this,"wheelGesture",new eO);b(this,"dragController",new XD);b(this,"dragState",null);b(this,"activeDragPointerId",null);b(this,"dragListenersAttached",!1);b(this,"dragFrame",0);b(this,"lastDragFrameTime",0);b(this,"lastPointerX",0);b(this,"lastPointerY",0);b(this,"pointerVelocityPxPerSec",0);b(this,"scrollVelocityPxPerSec",0);b(this,"motionSampleTime",0);b(this,"motionSampleX",0);b(this,"motionSampleY",0);b(this,"dragTrackOffsetXPx",0);b(this,"previousProjectedLayoutForOffset",null);b(this,"renderContent",()=>F``);b(this,"onDragControllerChange",()=>{this.dragController.status==="idle"&&(this.dragState=null,this.dragTrackOffsetXPx=0,this.previousProjectedLayoutForOffset=null),this.scheduleRender()});b(this,"onDragControllerDrag",t=>{const r=Nf(t.projectedLayout),i=this.shouldApplyTrackOffset(t.projectedLayout,t.source.parentId),s=t.source.parentId?this.getStackChildAnchorCardId(t.source.parentId,t.nodeId):null;this.dragTrackOffsetXPx=i?this.computeDragTrackOffset(this.previousProjectedLayoutForOffset,r,t.nodeId,t.source.parentId,s,this.dragTrackOffsetXPx):0,this.previousProjectedLayoutForOffset=r,this.dragState={nodeId:t.nodeId,source:t.source,grabOffset:t.grabOffset,pointer:t.pointer,size:t.size,projectedLayout:t.projectedLayout},this.scheduleRender()});b(this,"onDragControllerDrop",t=>{this.dragState=null,this.dragTrackOffsetXPx=0,this.previousProjectedLayoutForOffset=null,this.commitLayout(t.layout)});b(this,"onLayoutScrollInternal",t=>{const i=t.scroll.x??0;Math.abs(i-this._scrollPosition)<Eo||(this._scrollPosition=i,this.emitScrollPositionChanged(i),this.scheduleRender())});b(this,"handleKeyDown",t=>{if(t.key==="Escape"&&this.dragController.status!=="idle"){t.preventDefault(),this.stopDragFrameLoop(),this.releaseActiveDragPointerCapture(),this.dragController.cancel(),this.detachDragListeners();return}this.dragController.status==="idle"&&(t.key==="ArrowRight"?(t.preventDefault(),this.wheelGesture.markKeyboardNavigation(Date.now()),this.shiftWindow(1)):t.key==="ArrowLeft"&&(t.preventDefault(),this.wheelGesture.markKeyboardNavigation(Date.now()),this.shiftWindow(-1)))});b(this,"handleWheel",t=>{if(this._layout.length===0)return;const r=this.wheelGesture.decide({now:Date.now(),shiftKey:t.shiftKey,deltaX:t.deltaX,deltaY:t.deltaY,overArtifactContent:!1});r.type==="scroll-horizontal"&&(t.preventDefault(),this.applyHorizontalWheel(r.horizontalDelta))});b(this,"handleWindowMessage",t=>{var o;if(this._layout.length===0)return;const r=this.findManagedArtifactFrame(t.source);if(!r||!this.isTrustedArtifactFrameMessage(t,r)||!zC(t.data))return;const i=this.wheelGesture.decide({now:Date.now(),shiftKey:t.data.shiftKey,deltaX:t.data.deltaX,deltaY:t.data.deltaY,overArtifactContent:!0});if(i.type==="scroll-horizontal"){this.applyHorizontalWheel(i.horizontalDelta);return}if(i.type!=="scroll-native")return;const s={type:"scroll",deltaX:0,deltaY:t.data.deltaY};(o=r.contentWindow)==null||o.postMessage(s,this.getArtifactFrameTargetOrigin(r))});b(this,"handlePointerDown",t=>{if(t.button!==0||this.dragController.status!=="idle")return;const r=t.target;if(!(r instanceof Element)||!r.closest("[drag-handle]")||r.closest("button, input, textarea, select, a, [role='button']"))return;const i=r.closest(".card-slot");if(!i)return;const s=i.getAttribute("data-layout-node-id");if(!s)return;const o=sO(this._layout,s);if(!o)return;const a=i.getBoundingClientRect();this.lastPointerX=t.clientX,this.lastPointerY=t.clientY,this.resetMotionTracking(t.clientX,t.clientY),this.focus(),this.dragController.start({nodeId:s,source:{index:o.topLevelIndex,parentId:o.sourceStackId},pointer:ke({x:t.clientX,y:t.clientY}),grabOffset:ke({x:t.clientX-a.left,y:t.clientY-a.top}),size:ke({x:a.width,y:a.height}),layout:this._layout}),this.attachDragListeners(),this.activeDragPointerId=t.pointerId;try{this.setPointerCapture(t.pointerId)}catch{}t.preventDefault()});b(this,"handleWindowPointerMove",t=>{this.lastPointerX=t.clientX,this.lastPointerY=t.clientY,this.updatePointerVelocity(t.clientX,t.clientY),this.syncDragTargetForLatestPointer(),this.ensureDragFrameLoop()});b(this,"handleWindowPointerUp",t=>{this.stopDragFrameLoop(),this.releasePointerCaptureForEvent(t.pointerId),this.dragController.drop(),this.clearMotionTracking(),this.detachDragListeners()});b(this,"handleWindowPointerCancel",t=>{this.stopDragFrameLoop(),this.releasePointerCaptureForEvent(t.pointerId),this.dragController.cancel(),this.clearMotionTracking(),this.detachDragListeners()});b(this,"handleWindowBlur",()=>{this.releaseActiveDragPointerCapture(),this.stopDragFrameLoop(),this.dragController.cancel(),this.clearMotionTracking(),this.detachDragListeners()});b(this,"runDragFrame",t=>{if(this.dragController.status==="idle"){this.dragFrame=0;return}const r=Math.max(0,t-this.lastDragFrameTime)/Vf;this.lastDragFrameTime=t,this.samplePointerVelocityAt(t,this.lastPointerX,this.lastPointerY);const i=this.getBoundingClientRect(),s=this.clampPointerToViewport(this.lastPointerX,this.lastPointerY,i),o=this.getDragEdgeScrollDeltaPixels(s.x,i,r);this.scrollVelocityPxPerSec=r>Eo?Math.abs(o)/r:0,Math.abs(o)>Eo&&(this.animateNextRender=!1,this.layoutScroll.wheelPixels(ke({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(t){this._layout=[...t],this.stopDragFrameLoop(),this.dragController.cancel(),this.scrollModelKey="",this.syncScrollModel(),this.layoutScroll.scroll=Te({x:this._scrollPosition}),this.scheduleRender()}get layout(){return this._layout}commitLayout(t){this.layout=t,this.emitLayoutChanged()}set scrollPosition(t){Math.abs(t-this._scrollPosition)<Eo||(this.animateNextRender=!1,this.syncScrollModel(),this.layoutScroll.scroll=Te({x:t}))}get scrollPosition(){return this._scrollPosition}connectedCallback(){this.hasAttribute("tabindex")||(this.tabIndex=0),this.focus(),this.addEventListener("keydown",this.handleKeyDown),this.addEventListener("wheel",this.handleWheel,{passive:!1}),this.addEventListener("pointerdown",this.handlePointerDown),window.addEventListener("message",this.handleWindowMessage),typeof ResizeObserver<"u"&&(this.resizeObserver=new ResizeObserver(()=>this.render()),this.resizeObserver.observe(this)),this.render()}disconnectedCallback(){var t;this.removeEventListener("keydown",this.handleKeyDown),this.removeEventListener("wheel",this.handleWheel),this.removeEventListener("pointerdown",this.handlePointerDown),window.removeEventListener("message",this.handleWindowMessage),(t=this.resizeObserver)==null||t.disconnect(),this.resizeObserver=null,this.wheelGesture.reset(),this.detachDragListeners(),this.dragController.removeEventListener("change",this.onDragControllerChange),this.dragController.removeEventListener("drag",this.onDragControllerDrag),this.dragController.removeEventListener("drop",this.onDragControllerDrop),this.layoutScroll.removeEventListener("layout-scroll",this.onLayoutScrollInternal),this.dragController.dispose(),this.stopDragFrameLoop()}scheduleRender(){this.renderPending||(this.renderPending=!0,queueMicrotask(()=>{this.renderPending=!1,this.render()}))}createGrid(t,r){return new vD({basis:ke({x:Pn,y:Pn}),min:ke({x:Xd,y:Xd}),viewport:ke({x:t,y:r}),gap:ke({x:pe,y:pe})})}syncScrollModel(){const t=Hl(this),i=Wi(this._layout).nodes.map(o=>o.width),s=`${t.width}x${t.height}:${i.join(",")}`;s===this.scrollModelKey&&this.layoutGrid||(this.scrollModelKey=s,this.layoutGrid=this.createGrid(t.width,t.height),this.layoutScroll.rebuild({grid:this.layoutGrid,nodeWidths:i.map(o=>Te({x:o}))}))}emitScrollPositionChanged(t){this.dispatchEvent(new nO(t))}emitLayoutChanged(){this.dispatchEvent(new Yy([...this._layout]))}shiftWindow(t){this.syncScrollModel(),this.animateNextRender=!0,this.layoutScroll.step(t)}applyHorizontalWheel(t){this.syncScrollModel();const r=this.layoutGrid;if(!r)return;this.animateNextRender=!1;const i=r.toUnits(ke({x:t}));this.layoutScroll.wheel(Te({x:i.x??0}))}findManagedArtifactFrame(t){if(!t)return null;const r=this.querySelectorAll("iframe.artifact-frame");for(const i of r)if(i.contentWindow===t)return i;return null}isTrustedArtifactFrameMessage(t,r){if(t.origin==="null")return!0;const i=this.getArtifactFrameOrigin(r);return i===null||t.origin===i}getArtifactFrameTargetOrigin(t){const r=t.getAttribute("sandbox")??"";return new Set(r.split(/\s+/).filter(Boolean)).has("allow-same-origin")?this.getArtifactFrameOrigin(t)??"*":"*"}getArtifactFrameOrigin(t){const r=t.getAttribute("src")??t.src;if(!r)return null;try{return new URL(r,window.location.href).origin}catch{return null}}releaseActiveDragPointerCapture(){this.activeDragPointerId!==null&&this.releasePointerCaptureForEvent(this.activeDragPointerId)}releasePointerCaptureForEvent(t){try{this.hasPointerCapture(t)&&this.releasePointerCapture(t)}catch{}}attachDragListeners(){this.dragListenersAttached||(window.addEventListener("pointermove",this.handleWindowPointerMove),window.addEventListener("pointerup",this.handleWindowPointerUp),window.addEventListener("pointercancel",this.handleWindowPointerCancel),this.addEventListener("pointermove",this.handleWindowPointerMove),this.addEventListener("pointerup",this.handleWindowPointerUp),this.addEventListener("pointercancel",this.handleWindowPointerCancel),window.addEventListener("blur",this.handleWindowBlur),this.dragListenersAttached=!0)}detachDragListeners(){this.dragListenersAttached&&(window.removeEventListener("pointermove",this.handleWindowPointerMove),window.removeEventListener("pointerup",this.handleWindowPointerUp),window.removeEventListener("pointercancel",this.handleWindowPointerCancel),this.removeEventListener("pointermove",this.handleWindowPointerMove),this.removeEventListener("pointerup",this.handleWindowPointerUp),this.removeEventListener("pointercancel",this.handleWindowPointerCancel),window.removeEventListener("blur",this.handleWindowBlur),this.dragListenersAttached=!1,this.activeDragPointerId=null)}getDisplayModel(){if(this.dragController.status!=="active"||!this.dragState)return{layout:this._layout,activePlaceholderId:null,placeholdersById:new Map};const t=new Map;return t.set(this.dragState.nodeId,{id:this.dragState.nodeId,sourceCardId:this.dragState.nodeId}),{layout:Nf(this.dragState.projectedLayout),activePlaceholderId:this.dragState.nodeId,placeholdersById:t}}render(){const t=Hl(this),r=this.createGrid(t.width,t.height);this.layoutGrid=r;const i=this.getDisplayModel(),s=i.layout,o=this.dragController.status==="active",a=Wi(s),c=a.nodes.map(M=>M.width),u=`${t.width}x${t.height}:${c.join(",")}`;!o&&u!==this.scrollModelKey&&(this.scrollModelKey=u,this.layoutScroll.rebuild({grid:r,nodeWidths:c.map(M=>Te({x:M}))}),this._scrollPosition=this.layoutScroll.scroll.x??this._scrollPosition);const d=iO(s),f=r.unit.x??Pn,v=r.unit.y??Pn,y=o?this.dragTrackOffsetXPx:0,A=(this.layoutScroll.translate.x??0)+y,k=jf(a.nodes.length,r,t.height),I=this.animateNextRender&&!o,B=[`transform: translate(${A}px, ${k}px);`,`transition-duration: ${I?k0:0}ms;`,`pointer-events: ${o?"none":"auto"};`].join(" ");this.animateNextRender=!0,this.style.setProperty("--layout-unit-x",`${f}px`),this.style.setProperty("--layout-unit-y",`${v}px`),this.style.setProperty("--layout-gap",`${pe}px`);const P=this.dragState,le={width:(P==null?void 0:P.size.x)??0,height:(P==null?void 0:P.size.y)??0};Pe(F`
|
|
157
|
+
<div class="track" style=${B}>
|
|
158
|
+
${a.nodes.map((M,Z)=>F`
|
|
159
|
+
<div
|
|
160
|
+
class="node"
|
|
161
|
+
layout-node=${String(Z)}
|
|
162
|
+
data-layout-node-id=${M.id}
|
|
163
|
+
data-layout-placeholder=${String(i.activePlaceholderId===M.id)}
|
|
164
|
+
layout-node-cols=${String(M.width)}
|
|
165
|
+
style=${`grid-template-columns: repeat(${M.width}, var(--layout-unit-x)); width: ${r.toPixels(Te({x:M.width})).x}px;`}
|
|
166
|
+
>
|
|
167
|
+
${M.cards.map(U=>{const ge=i.placeholdersById.get(U.id);if(P&&ge)return F`
|
|
168
|
+
<div
|
|
169
|
+
class="card-slot card-placeholder"
|
|
170
|
+
data-layout-placeholder-for=${P.nodeId}
|
|
171
|
+
data-layout-placeholder-ghost="false"
|
|
172
|
+
data-layout-source-stack=${P.source.parentId??""}
|
|
173
|
+
style=${`grid-column: ${U.col} / span ${U.width}; grid-row: ${U.row} / span ${U.height};`}
|
|
174
|
+
></div>
|
|
175
|
+
`;const ce=d.get(U.id);return ce?F`
|
|
176
|
+
<div
|
|
177
|
+
class="card-slot"
|
|
178
|
+
data-layout-card-id=${U.artifactID}
|
|
179
|
+
data-layout-node-id=${U.id}
|
|
180
|
+
layout-cols=${String(U.width)}
|
|
181
|
+
layout-rows=${String(U.height)}
|
|
182
|
+
style=${`grid-column: ${U.col} / span ${U.width}; grid-row: ${U.row} / span ${U.height};`}
|
|
183
|
+
>
|
|
184
|
+
${this.renderContent(ce,{isDragging:!1})}
|
|
185
|
+
</div>
|
|
186
|
+
`:null})}
|
|
187
|
+
</div>
|
|
188
|
+
`)}
|
|
189
|
+
</div>
|
|
190
|
+
${P?(()=>{const M=this.getPlaceholderPixelSize(a,i.activePlaceholderId,r,le),Z=P.pointer.x??0,U=P.pointer.y??0,ge=P.grabOffset.x??0,ce=P.grabOffset.y??0;return F`
|
|
191
|
+
<div
|
|
192
|
+
class="drag-preview"
|
|
193
|
+
data-layout-preview-card-id=${P.nodeId}
|
|
194
|
+
style=${[`width: ${M.width}px;`,`height: ${M.height}px;`,`left: ${Z-ge}px;`,`top: ${U-ce}px;`].join(" ")}
|
|
195
|
+
>
|
|
196
|
+
${this.renderDraggedPreview(P.nodeId)}
|
|
197
|
+
</div>
|
|
198
|
+
`})():null}
|
|
199
|
+
`,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 t=this.getBoundingClientRect();if(this.dragController.status==="active"){const i=this.clampPointerToViewport(this.lastPointerX,this.lastPointerY,t);this.syncDragTarget(i.x,i.y,t);return}if(this.syncDragTarget(this.lastPointerX,this.lastPointerY,t),this.dragController.status==="pending")return;const r=this.clampPointerToViewport(this.lastPointerX,this.lastPointerY,t);(r.x!==this.lastPointerX||r.y!==this.lastPointerY)&&this.syncDragTarget(r.x,r.y,t)}syncDragTarget(t,r,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:ke({x:t,y:r}),viewport:{left:i.left,top:i.top,width:i.width,height:i.height},geometry:c,effectiveVelocity:Math.max(this.pointerVelocityPxPerSec,this.scrollVelocityPxPerSec)})}resetMotionTracking(t,r){this.pointerVelocityPxPerSec=0,this.scrollVelocityPxPerSec=0,this.motionSampleTime=performance.now(),this.motionSampleX=t,this.motionSampleY=r}clearMotionTracking(){this.pointerVelocityPxPerSec=0,this.scrollVelocityPxPerSec=0,this.motionSampleTime=0}updatePointerVelocity(t,r){this.samplePointerVelocityAt(performance.now(),t,r)}samplePointerVelocityAt(t,r,i){if(this.motionSampleTime===0){this.motionSampleTime=t,this.motionSampleX=r,this.motionSampleY=i,this.pointerVelocityPxPerSec=0;return}const s=t-this.motionSampleTime;if(s<100)return;const o=r-this.motionSampleX;this.pointerVelocityPxPerSec=Math.abs(o)/s*Vf,this.motionSampleTime=t,this.motionSampleX=r,this.motionSampleY=i}clampPointerToViewport(t,r,i){return{x:Math.max(i.left,Math.min(i.left+i.width,t)),y:Math.max(i.top,Math.min(i.top+i.height,r))}}isPointerOutsideViewport(t,r,i){return t<i.left||t>i.left+i.width||r<i.top||r>i.top+i.height}getDragEdgeScrollDeltaPixels(t,r,i){var u;const s=r.left+vo,o=r.left+r.width-vo,a=((u=this.layoutGrid)==null?void 0:u.unit.x)??Pn,c=$0*a;if(t<s){const d=Math.max(0,Math.min(1,(s-t)/vo));return-(c*d**Qd)*i}if(t>o){const d=Math.max(0,Math.min(1,(t-o)/vo));return c*d**Qd*i}return 0}measureLayoutGeometry(t,r,i=0){const s=this.layoutGrid;if(!s)return[];const o=Wi(t),a=new Map(o.nodes.map(k=>[k.id,k.width])),c=s.toPixels(Te({y:Xe})).y??Xo,u=Hl(this),d=(this.layoutScroll.translate.x??0)+i,f=jf(o.nodes.length,s,u.height),v=u.offsetY+f,y=[];let A=d;for(const k of t){const I=a.get(k.id)??Ct,B=s.toPixels(Te({x:I})).x??tr,P={left:A,top:v,width:B,height:c};y.push({id:k.id,rect:P}),A+=B+pe}return y}getPlaceholderPixelSize(t,r,i,s){if(!r)return s;for(const o of t.nodes)for(const a of o.cards)if(a.id===r)return{width:i.toPixels(Te({x:a.width})).x??s.width,height:i.toPixels(Te({y:a.height})).y??s.height};return s}renderDraggedPreview(t){const r=Vu(this._layout,t);return r?this.renderContent(r,{isDragging:!0}):F``}shouldApplyTrackOffset(t,r){if(r)return!0;for(const i of t){if(i.type!=="stack")continue;if(i.children.some(o=>o.type==="drop-target")&&r!==i.id)return!0}return!1}computeDragTrackOffset(t,r,i,s,o,a){if(!t)return a;const c=s?o??this.getStableAnchorCardId(t,r,i):this.getStableAnchorNodeId(t,r,i);if(!c)return a;const u=s?Gf(t,c,this.layoutGrid):Wf(t,c,this.layoutGrid),d=s?Gf(r,c,this.layoutGrid):Wf(r,c,this.layoutGrid);return u===null||d===null?a:a+(u-d)}getStableAnchorCardId(t,r,i){const s=Bf(t),o=new Set(Bf(r));for(const a of s)if(a!==i&&o.has(a))return a;return null}getStableAnchorNodeId(t,r,i){const s=new Set(r.map(o=>o.id));for(const o of t)if(o.id!==i&&s.has(o.id))return o.id;return null}getStackChildAnchorCardId(t,r){const i=this._layout.find(o=>o.type==="stack"&&o.id===t);if(!i||i.type!=="stack")return null;const s=i.children.find(o=>o.type==="card"&&o.id!==r);return(s==null?void 0:s.id)??null}}function iO(n){const e=new Map;for(const t of n){if(t.type==="card"){e.set(t.id,t);continue}for(const r of t.children)if(r.type==="card")e.set(r.id,r);else for(const i of r.children)e.set(i.id,i)}return e}function sO(n,e){const t=n.findIndex(r=>r.type==="card"&&r.id===e);if(t!==-1)return{topLevelIndex:t};for(let r=0;r<n.length;r+=1){const i=n[r];if(!(!i||i.type!=="stack")&&i.children.some(s=>s.type==="card"&&s.id===e))return{topLevelIndex:r,sourceStackId:i.id}}return null}function Bf(n){const e=[];for(const t of n){if(t.type==="card"){e.push(t.id);continue}if(t.type==="stack"){const r=t.children.find(i=>i.type==="card");r&&e.push(r.id)}}return e}function Gf(n,e,t){if(!t)return null;const r=Wi(n),i=new Map(r.nodes.map(o=>[o.id,o.width]));let s=0;for(const o of n){if(o.type==="card"&&o.id===e||o.type==="stack"&&o.children.some(u=>u.type==="card"&&u.id===e))return s;const a=i.get(o.id)??Ct,c=t.toPixels(Te({x:a})).x??tr;s+=c+pe}return null}function Wf(n,e,t){if(!t)return null;const r=Wi(n),i=new Map(r.nodes.map(o=>[o.id,o.width]));let s=0;for(const o of n){if(o.id===e)return s;const a=i.get(o.id)??Ct,c=t.toPixels(Te({x:a})).x??tr;s+=c+pe}return null}customElements.get("layout-view")||customElements.define("layout-view",rO);class oO extends HTMLElement{constructor(){super(...arguments);b(this,"screenManager",Ge.resolve("ScreenManager"));b(this,"boundModel",null);b(this,"handleActiveScreenChanged",()=>{this.rebindModel(),this.render()});b(this,"handleModelChange",()=>{this.render()});b(this,"handleCloseArtifact",t=>{t instanceof Vy&&this.screenManager.activeScreen&&this.screenManager.activeScreen.removeArtifact(t.artifactID)});b(this,"handleScrollPositionChanged",t=>{const r=t;typeof r.scrollPosition=="number"&&Number.isFinite(r.scrollPosition)&&this.screenManager.activeScreen&&this.screenManager.activeScreen.setScrollPosition(r.scrollPosition)});b(this,"handleLayoutChanged",t=>{t instanceof Yy&&this.screenManager.activeScreen&&this.screenManager.activeScreen.setLayout(t.layout)})}connectedCallback(){this.screenManager.addEventListener("active-screen-changed",this.handleActiveScreenChanged),this.rebindModel(),this.render()}disconnectedCallback(){this.screenManager.removeEventListener("active-screen-changed",this.handleActiveScreenChanged),this.unbindModel()}rebindModel(){const t=this.screenManager.activeScreen;this.boundModel!==t&&(this.unbindModel(),this.boundModel=t,t&&t.addEventListener("change",this.handleModelChange))}unbindModel(){this.boundModel&&(this.boundModel.removeEventListener("change",this.handleModelChange),this.boundModel=null)}buildArtifactMap(){const t=this.screenManager.activeScreen;return t?new Map(t.artifacts):new Map}render(){const t=this.screenManager.activeScreen,r=(t==null?void 0:t.layout)??[],i=this.buildArtifactMap();if(r.length===0){Pe(F`<p data-testid="empty-screen" class="empty">
|
|
200
|
+
No artifacts yet. Create one by asking for something.
|
|
201
|
+
</p>`,this);return}Pe(F`
|
|
202
|
+
<layout-view
|
|
203
|
+
.layout=${r}
|
|
204
|
+
.renderContent=${(o,a)=>{const c=i.get(o.artifactID);return!c||!t?F``:F`<artifact-view
|
|
205
|
+
.artifact=${c}
|
|
206
|
+
.screen=${t}
|
|
207
|
+
.viewURL=${t.server.getViewURL(c)}
|
|
208
|
+
.contentURL=${t.server.getContentURL(c.id)}
|
|
209
|
+
.dragging=${a.isDragging}
|
|
210
|
+
></artifact-view>`}}
|
|
211
|
+
.scrollPosition=${(t==null?void 0:t.scrollPosition)??0}
|
|
212
|
+
@scroll=${this.handleScrollPositionChanged}
|
|
213
|
+
@layout-change=${this.handleLayoutChanged}
|
|
214
|
+
@close-artifact=${this.handleCloseArtifact}
|
|
215
|
+
></layout-view>
|
|
216
|
+
`,this)}}customElements.define("screen-view",oO);var ma,jr,Cs,Wt,Ky,Jy,Uc;class aO extends HTMLElement{constructor(){super(...arguments);_(this,Wt);_(this,ma,Ge.resolve("ScreenManager"));_(this,jr,Ge.resolve("ServerManager"));_(this,Cs,()=>{m(this,Wt,Uc).call(this)})}connectedCallback(){l(this,jr).addEventListener("change",l(this,Cs)),m(this,Wt,Uc).call(this)}disconnectedCallback(){l(this,jr).removeEventListener("change",l(this,Cs))}}ma=new WeakMap,jr=new WeakMap,Cs=new WeakMap,Wt=new WeakSet,Ky=function(t,r){l(this,ma).setActive(t,r)},Jy=function(){for(const t of l(this,jr).servers.values())return t;return null},Uc=function(){const t=m(this,Wt,Jy).call(this),i=(t?[...t.screens.values()]:[]).slice().sort((o,a)=>o.name.localeCompare(a.name,void 0,{sensitivity:"base"})),s=i.length===0?F`<p class="empty">No screens yet. Hit + to create one.</p>`:F`
|
|
217
|
+
<div class="content">
|
|
218
|
+
<h2 class="heading">Screens</h2>
|
|
219
|
+
<ul class="tiles">
|
|
220
|
+
${i.map(o=>F`
|
|
221
|
+
<li>
|
|
222
|
+
<button
|
|
223
|
+
class="tile"
|
|
224
|
+
type="button"
|
|
225
|
+
@click=${()=>t&&m(this,Wt,Ky).call(this,t.url,o.id)}
|
|
226
|
+
>
|
|
227
|
+
${o.name}
|
|
228
|
+
</button>
|
|
229
|
+
</li>
|
|
230
|
+
`)}
|
|
231
|
+
</ul>
|
|
232
|
+
</div>
|
|
233
|
+
`;Pe(s,this)};customElements.get("home-screen")||customElements.define("home-screen",aO);const Vl=new WeakMap,qf=Object.prototype.hasOwnProperty,lO=(()=>{const n=new Set;let e=HTMLElement.prototype;for(;e;){for(const t of Object.getOwnPropertyNames(e))n.add(t);if(e===Node.prototype)break;e=Object.getPrototypeOf(e)}return n})();function cO(n,e){if(n===Boolean)return e!==null;if(e!==null)return n===Number?Number(e):e}var Is,Fc,Yn,tt,xt,Br,Kn,Gr,Ie,Zi,Xy,Qy,ev,Vo;const On=class On extends HTMLElement{constructor(){var i;super();_(this,Ie);_(this,Yn,new Map);_(this,tt,new Map);_(this,xt,new Map);_(this,Br,!1);_(this,Kn,!1);_(this,Gr,!1);const t=m(i=On,Is,Fc).call(i,this.constructor),r=this;for(const s of t.properties)qf.call(r,s)&&(l(this,xt).set(s,r[s]),delete r[s])}static get observedAttributes(){var t;return m(t=On,Is,Fc).call(t,this).observedAttributes}connected(){}disconnected(){}changed(t){}connectedCallback(){if(m(this,Ie,ev).call(this),!l(this,Kn))for(const t of m(this,Ie,Zi).call(this).properties)l(this,tt).has(t)||l(this,tt).set(t,void 0);this.dispatchEvent(new Event("reactive:connect")),this.connected(),m(this,Ie,Vo).call(this)}disconnectedCallback(){this.dispatchEvent(new Event("reactive:disconnect")),this.disconnected()}attributeChangedCallback(t,r,i){if(r===i)return;const s=m(this,Ie,Zi).call(this).byAttr.get(t);s&&(l(this,xt).has(s.property)||(this[s.property]=cO(s.type,i)))}};Is=new WeakSet,Fc=function(t){const r=Vl.get(t);if(r)return r;const i=[...t.properties??[]],s=t.attributes??{},o=new Map,a=new Map;for(const u of i)if(lO.has(u))throw new Error(`Reactive property "${u}" collides with a built-in DOM property. Rename it to avoid shadowing the platform API.`);for(const[u,d]of Object.entries(s)){if(u.includes("-")&&d.property===void 0)throw new Error(`Attribute "${u}" must declare a "property" name because kebab-case cannot be a property.`);const f=d.property??u;if(!i.includes(f))throw new Error(`Attribute '${u}' references property '${f}', which isn't declared in \`static properties\`. Add it to \`properties\` to make it reactive.`);const v={attribute:u,property:f,type:d.type};o.set(u,v),a.set(f,v)}for(const u of i){const d=Object.getOwnPropertyDescriptor(t.prototype,u);if((d==null?void 0:d.get)!==void 0||(d==null?void 0:d.set)!==void 0)throw new Error(`Observed property "${u}" cannot define a custom getter/setter. Use changed() for side effects instead.`);d===void 0&&Object.defineProperty(t.prototype,u,{configurable:!0,enumerable:!0,get(){return l(this,Yn).get(u)},set(f){m(this,Ie,Xy).call(this,u,f)}})}const c={properties:i,observedAttributes:Object.keys(s),byAttr:o,byProp:a};return Vl.set(t,c),c},Yn=new WeakMap,tt=new WeakMap,xt=new WeakMap,Br=new WeakMap,Kn=new WeakMap,Gr=new WeakMap,Ie=new WeakSet,Zi=function(){return Vl.get(this.constructor)},Xy=function(t,r){if(!l(this,Gr)&&l(this,xt).has(t))return;const i=l(this,Yn).get(t);Object.is(i,r)||(l(this,tt).has(t)||l(this,tt).set(t,i),l(this,Yn).set(t,r),l(this,xt).delete(t),m(this,Ie,Qy).call(this,t,r),this.isConnected&&m(this,Ie,Vo).call(this))},Qy=function(t,r){const i=m(this,Ie,Zi).call(this).byProp.get(t);if(!i)return;const{attribute:s,type:o}=i;if(o===Boolean){const c=this.hasAttribute(s);r&&!c?this.setAttribute(s,""):!r&&c&&this.removeAttribute(s);return}if(r==null){this.hasAttribute(s)&&this.removeAttribute(s);return}const a=String(r);this.getAttribute(s)!==a&&this.setAttribute(s,a)},ev=function(){const t=this,r=m(this,Ie,Zi).call(this);for(const i of r.properties){if(!qf.call(t,i))continue;const s=t[i];delete t[i],!(l(this,xt).has(i)||l(this,Yn).has(i))&&(t[i]=s)}E(this,Gr,!0);try{for(const[i,s]of l(this,xt))t[i]=s;l(this,xt).clear()}finally{E(this,Gr,!1)}},Vo=function(){l(this,Br)||!this.isConnected||l(this,Kn)&&l(this,tt).size===0||(E(this,Br,!0),queueMicrotask(()=>{if(E(this,Br,!1),!this.isConnected||l(this,Kn)&&l(this,tt).size===0)return;const t=new Map(l(this,tt));l(this,tt).clear(),E(this,Kn,!0);try{this.changed(t)}catch(r){console.error(r)}this.isConnected&&l(this,tt).size>0&&m(this,Ie,Vo).call(this)}))},_(On,Is),b(On,"properties"),b(On,"attributes");let ts=On;/**
|
|
234
|
+
* @license
|
|
235
|
+
* Copyright 2020 Google LLC
|
|
236
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
237
|
+
*/const uO=n=>n.strings===void 0;/**
|
|
238
|
+
* @license
|
|
239
|
+
* Copyright 2017 Google LLC
|
|
240
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
241
|
+
*/const Yi=(n,e)=>{var r;const t=n._$AN;if(t===void 0)return!1;for(const i of t)(r=i._$AO)==null||r.call(i,e,!1),Yi(i,e);return!0},oa=n=>{let e,t;do{if((e=n._$AM)===void 0)break;t=e._$AN,t.delete(n),n=e}while((t==null?void 0:t.size)===0)},tv=n=>{for(let e;e=n._$AM;n=e){let t=e._$AN;if(t===void 0)e._$AN=t=new Set;else if(t.has(n))break;t.add(n),fO(e)}};function hO(n){this._$AN!==void 0?(oa(this),this._$AM=n,tv(this)):this._$AM=n}function dO(n,e=!1,t=0){const r=this._$AH,i=this._$AN;if(i!==void 0&&i.size!==0)if(e)if(Array.isArray(r))for(let s=t;s<r.length;s++)Yi(r[s],!1),oa(r[s]);else r!=null&&(Yi(r,!1),oa(r));else Yi(this,n)}const fO=n=>{n.type==vy.CHILD&&(n._$AP??(n._$AP=dO),n._$AQ??(n._$AQ=hO))};class pO extends by{constructor(){super(...arguments),this._$AN=void 0}_$AT(e,t,r){super._$AT(e,t,r),tv(this),this.isConnected=e._$AU}_$AO(e,t=!0){var r,i;e!==this.isConnected&&(this.isConnected=e,e?(r=this.reconnected)==null||r.call(this):(i=this.disconnected)==null||i.call(this)),t&&(Yi(this,e),oa(this))}setValue(e){if(uO(this._$Ct))this._$Ct._$AI(e,this);else{const t=[...this._$Ct._$AH];t[this._$Ci]=e,this._$Ct._$AI(t,this,0)}}disconnected(){}reconnected(){}}/**
|
|
242
|
+
* @license
|
|
243
|
+
* Copyright 2020 Google LLC
|
|
244
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
245
|
+
*/const $o=()=>new gO;class gO{}const jl=new WeakMap,Ao=Zu(class extends pO{render(n){return oe}update(n,[e]){var r;const t=e!==this.G;return t&&this.G!==void 0&&this.rt(void 0),(t||this.lt!==this.ct)&&(this.G=e,this.ht=(r=n.options)==null?void 0:r.host,this.rt(this.ct=n.element)),oe}rt(n){if(this.isConnected||(n=void 0),typeof this.G=="function"){const e=this.ht??globalThis;let t=jl.get(e);t===void 0&&(t=new WeakMap,jl.set(e,t)),t.get(this.G)!==void 0&&this.G.call(this.ht,void 0),t.set(this.G,n),n!==void 0&&this.G.call(this.ht,n)}else this.G.value=n}get lt(){var n,e;return typeof this.G=="function"?(n=jl.get(this.ht??globalThis))==null?void 0:n.get(this.G):(e=this.G)==null?void 0:e.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}});var Je,un,Wr,qr,Ps,Jn,Xn,re,Rs,Ds,Me,Zc,Hc,ya,va,ba,wa,_a,Sa,ka,Os,zs,Hi,nv,ht;class mO extends ts{constructor(){super(...arguments);_(this,Me);_(this,Je,Ge.resolve("ScreenManager"));_(this,un,null);_(this,Wr,new DisposableStack);_(this,qr,$o());_(this,Ps,$o());_(this,Jn,$o());_(this,Xn,$o());_(this,re,{kind:"none"});_(this,Rs,()=>{m(this,Me,Zc).call(this),l(this,ht).call(this)});_(this,Ds,()=>{l(this,ht).call(this)});_(this,ya,()=>{l(this,Je).clearActive()});_(this,va,t=>{l(this,re).kind!=="none"&&(t.stopImmediatePropagation(),m(this,Me,Hi).call(this))});_(this,ba,()=>{var r;const t=l(this,Je).activeScreen;t&&((r=l(this,qr).value)==null||r.close(),E(this,re,{kind:"rename",draft:t.name}),l(this,ht).call(this))});_(this,wa,()=>{var t;l(this,Je).activeScreen&&((t=l(this,qr).value)==null||t.close(),E(this,re,{kind:"delete",error:null}),l(this,ht).call(this))});_(this,_a,t=>{if(l(this,re).kind!=="rename")return;const r=t.target;r instanceof HTMLInputElement&&E(this,re,{kind:"rename",draft:r.value})});_(this,Sa,t=>{if(t.preventDefault(),l(this,re).kind!=="rename")return;const r=l(this,Je).activeScreen;if(!r)return;const i=l(this,re).draft.trim();i.length>0&&i!==r.name&&r.rename(i),m(this,Me,Hi).call(this)});_(this,ka,async()=>{if(l(this,re).kind!=="delete")return;const t=l(this,Je).activeScreen;if(t){E(this,re,{kind:"delete",error:null});try{await t.remove(),l(this,Je).clearActive(),m(this,Me,Hi).call(this)}catch(r){E(this,re,{kind:"delete",error:r instanceof Error?r.message:"Failed to delete screen."}),l(this,ht).call(this)}}});_(this,Os,()=>{m(this,Me,Hi).call(this)});_(this,zs,()=>{l(this,re).kind!=="none"&&(E(this,re,{kind:"none"}),l(this,ht).call(this))});_(this,ht,()=>{const t=F`
|
|
246
|
+
<button
|
|
247
|
+
icon-only
|
|
248
|
+
class="home"
|
|
249
|
+
type="button"
|
|
250
|
+
aria-label="Home"
|
|
251
|
+
@click=${l(this,ya)}
|
|
252
|
+
>
|
|
253
|
+
${KR({weight:"fill"})}
|
|
254
|
+
</button>
|
|
255
|
+
`;Pe(F`${t}${m(this,Me,nv).call(this)}`,this);const r=l(this,Ps).value??null;l(this,Jn).value&&(l(this,Jn).value.anchor=r),l(this,Xn).value&&(l(this,Xn).value.anchor=r)})}connected(){l(this,Je).addEventListener("active-screen-changed",l(this,Rs)),m(this,Me,Zc).call(this),l(this,ht).call(this),l(this,Wr).defer(()=>{l(this,Je).removeEventListener("active-screen-changed",l(this,Rs)),m(this,Me,Hc).call(this)})}disconnected(){l(this,Wr).dispose(),E(this,Wr,new DisposableStack)}}Je=new WeakMap,un=new WeakMap,Wr=new WeakMap,qr=new WeakMap,Ps=new WeakMap,Jn=new WeakMap,Xn=new WeakMap,re=new WeakMap,Rs=new WeakMap,Ds=new WeakMap,Me=new WeakSet,Zc=function(){var r;const t=l(this,Je).activeScreen;l(this,un)!==t&&(m(this,Me,Hc).call(this),E(this,un,t),(r=l(this,un))==null||r.addEventListener("change",l(this,Ds)))},Hc=function(){var t;(t=l(this,un))==null||t.removeEventListener("change",l(this,Ds)),E(this,un,null)},ya=new WeakMap,va=new WeakMap,ba=new WeakMap,wa=new WeakMap,_a=new WeakMap,Sa=new WeakMap,ka=new WeakMap,Os=new WeakMap,zs=new WeakMap,Hi=function(){const t=l(this,re).kind==="rename"?l(this,Jn).value:l(this,re).kind==="delete"?l(this,Xn).value:null;t&&(t.open=!1),E(this,re,{kind:"none"}),l(this,ht).call(this)},nv=function(){const t=l(this,Je).activeScreen;if(!t)return null;const r=l(this,re).kind==="rename"?l(this,re).draft:"",i=l(this,re).kind==="delete"?l(this,re).error:null;return F`
|
|
256
|
+
<span class="separator" aria-hidden="true">
|
|
257
|
+
${WR()}
|
|
258
|
+
</span>
|
|
259
|
+
<dropdown-menu ${Ao(l(this,qr))}>
|
|
260
|
+
<button
|
|
261
|
+
slot="trigger"
|
|
262
|
+
type="button"
|
|
263
|
+
variant="ghost"
|
|
264
|
+
aria-label=${`Screen actions for ${t.name}`}
|
|
265
|
+
?data-active=${l(this,re).kind!=="none"}
|
|
266
|
+
@click=${l(this,va)}
|
|
267
|
+
${Ao(l(this,Ps))}
|
|
268
|
+
>
|
|
269
|
+
${t.name}
|
|
270
|
+
</button>
|
|
271
|
+
<dropdown-group>
|
|
272
|
+
<dropdown-item action @click=${l(this,ba)}>
|
|
273
|
+
${JR()} Rename
|
|
274
|
+
</dropdown-item>
|
|
275
|
+
<dropdown-item action danger @click=${l(this,wa)}>
|
|
276
|
+
${XR()} Delete
|
|
277
|
+
</dropdown-item>
|
|
278
|
+
</dropdown-group>
|
|
279
|
+
</dropdown-menu>
|
|
280
|
+
<ui-popover
|
|
281
|
+
class="rename-popover"
|
|
282
|
+
?open=${l(this,re).kind==="rename"}
|
|
283
|
+
@close=${l(this,zs)}
|
|
284
|
+
${Ao(l(this,Jn))}
|
|
285
|
+
>
|
|
286
|
+
<form class="screen-form" @submit=${l(this,Sa)}>
|
|
287
|
+
<label class="field">
|
|
288
|
+
<span>Screen name</span>
|
|
289
|
+
<input
|
|
290
|
+
type="text"
|
|
291
|
+
.value=${r}
|
|
292
|
+
@input=${l(this,_a)}
|
|
293
|
+
/>
|
|
294
|
+
</label>
|
|
295
|
+
<div class="actions">
|
|
296
|
+
<button type="button" @click=${l(this,Os)}>Cancel</button>
|
|
297
|
+
<button type="submit" variant="primary">Save</button>
|
|
298
|
+
</div>
|
|
299
|
+
</form>
|
|
300
|
+
</ui-popover>
|
|
301
|
+
<ui-popover
|
|
302
|
+
class="delete-popover"
|
|
303
|
+
?open=${l(this,re).kind==="delete"}
|
|
304
|
+
@close=${l(this,zs)}
|
|
305
|
+
${Ao(l(this,Xn))}
|
|
306
|
+
>
|
|
307
|
+
<div class="screen-form">
|
|
308
|
+
<p class="confirm-text">Delete "${t.name}"?</p>
|
|
309
|
+
${i?F`<p class="error">${i}</p>`:oe}
|
|
310
|
+
<div class="actions">
|
|
311
|
+
<button type="button" @click=${l(this,Os)}>Cancel</button>
|
|
312
|
+
<button
|
|
313
|
+
type="button"
|
|
314
|
+
variant="danger"
|
|
315
|
+
@click=${l(this,ka)}
|
|
316
|
+
>
|
|
317
|
+
Delete
|
|
318
|
+
</button>
|
|
319
|
+
</div>
|
|
320
|
+
</div>
|
|
321
|
+
</ui-popover>
|
|
322
|
+
`},ht=new WeakMap;customElements.define("screen-breadcrumb",mO);var Ea,$a,Yr,ri,rv,Aa,iv;class yO extends HTMLElement{constructor(){super(...arguments);_(this,ri);_(this,Ea,Ge.resolve("ServerManager"));_(this,$a,Ge.resolve("ScreenManager"));_(this,Yr,!1);_(this,Aa,async()=>{if(l(this,Yr))return;const t=m(this,ri,rv).call(this);if(t){E(this,Yr,!0);try{const r=await t.createScreen(vO(new Date));l(this,$a).setActive(t.url,r.id)}catch{}finally{E(this,Yr,!1)}}})}connectedCallback(){m(this,ri,iv).call(this)}}Ea=new WeakMap,$a=new WeakMap,Yr=new WeakMap,ri=new WeakSet,rv=function(){for(const t of l(this,Ea).servers.values())return t;return null},Aa=new WeakMap,iv=function(){Pe(F`
|
|
323
|
+
<button
|
|
324
|
+
icon-only
|
|
325
|
+
class="new-screen"
|
|
326
|
+
type="button"
|
|
327
|
+
aria-label="New screen"
|
|
328
|
+
@click=${l(this,Aa)}
|
|
329
|
+
>
|
|
330
|
+
${YR({size:16,weight:"bold"})}
|
|
331
|
+
</button>
|
|
332
|
+
`,this)};function vO(n){const e=n.toLocaleDateString("en-US",{month:"long",day:"numeric",year:"numeric"}),t=12,r=n.getHours(),i=r%t===0?t:r%t,s=n.getMinutes().toString().padStart(2,"0"),o=r>=t?"pm":"am";return`${e} at ${i}:${s}${o}`}customElements.define("screen-create-button",yO);function bO(n,e){let t=null;const r=()=>e((t==null?void 0:t.messages)??[]),i=()=>{const o=n.getActiveClient();o!==t&&(t==null||t.removeEventListener("change",r),t=o,t&&(t.addEventListener("change",r),t.connect().catch(a=>{console.error("ACPClient.connect() failed",a)})),r())};n.addEventListener("change",i),i();const s=()=>{n.removeEventListener("change",i),t==null||t.removeEventListener("change",r),t=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:sv,setPrototypeOf:Yf,isFrozen:wO,getPrototypeOf:_O,getOwnPropertyDescriptor:SO}=Object;let{freeze:Ne,seal:it,create:jo}=Object,{apply:Vc,construct:jc}=typeof Reflect<"u"&&Reflect;Ne||(Ne=function(e){return e});it||(it=function(e){return e});Vc||(Vc=function(e,t){for(var r=arguments.length,i=new Array(r>2?r-2:0),s=2;s<r;s++)i[s-2]=arguments[s];return e.apply(t,i)});jc||(jc=function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];return new e(...r)});const xo=Ue(Array.prototype.forEach),kO=Ue(Array.prototype.lastIndexOf),Kf=Ue(Array.prototype.pop),xi=Ue(Array.prototype.push),EO=Ue(Array.prototype.splice),Bo=Ue(String.prototype.toLowerCase),Bl=Ue(String.prototype.toString),Gl=Ue(String.prototype.match),Ti=Ue(String.prototype.replace),$O=Ue(String.prototype.indexOf),AO=Ue(String.prototype.trim),Ye=Ue(Object.prototype.hasOwnProperty),De=Ue(RegExp.prototype.test),Ci=xO(TypeError);function Ue(n){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];return Vc(n,e,r)}}function xO(n){return function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return jc(n,t)}}function V(n,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Bo;Yf&&Yf(n,null);let r=e.length;for(;r--;){let i=e[r];if(typeof i=="string"){const s=t(i);s!==i&&(wO(e)||(e[r]=s),i=s)}n[i]=!0}return n}function TO(n){for(let e=0;e<n.length;e++)Ye(n,e)||(n[e]=null);return n}function _t(n){const e=jo(null);for(const[t,r]of sv(n))Ye(n,t)&&(Array.isArray(r)?e[t]=TO(r):r&&typeof r=="object"&&r.constructor===Object?e[t]=_t(r):e[t]=r);return e}function Ii(n,e){for(;n!==null;){const r=SO(n,e);if(r){if(r.get)return Ue(r.get);if(typeof r.value=="function")return Ue(r.value)}n=_O(n)}function t(){return null}return t}const Jf=Ne(["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"]),Wl=Ne(["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"]),ql=Ne(["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"]),CO=Ne(["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"]),Yl=Ne(["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"]),IO=Ne(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Xf=Ne(["#text"]),Qf=Ne(["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"]),Kl=Ne(["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"]),ep=Ne(["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"]),To=Ne(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),PO=it(/\{\{[\w\W]*|[\w\W]*\}\}/gm),RO=it(/<%[\w\W]*|[\w\W]*%>/gm),DO=it(/\$\{[\w\W]*/gm),OO=it(/^data-[\-\w.\u00B7-\uFFFF]+$/),zO=it(/^aria-[\-\w]+$/),ov=it(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),LO=it(/^(?:\w+script|data):/i),MO=it(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),av=it(/^html$/i),NO=it(/^[a-z][.\w]*(-[.\w]+)+$/i);var tp=Object.freeze({__proto__:null,ARIA_ATTR:zO,ATTR_WHITESPACE:MO,CUSTOM_ELEMENT:NO,DATA_ATTR:OO,DOCTYPE_NAME:av,ERB_EXPR:RO,IS_ALLOWED_URI:ov,IS_SCRIPT_OR_DATA:LO,MUSTACHE_EXPR:PO,TMPLIT_EXPR:DO});const Pi={element:1,text:3,progressingInstruction:7,comment:8,document:9},UO=function(){return typeof window>"u"?null:window},FO=function(e,t){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let r=null;const i="data-tt-policy-suffix";t&&t.hasAttribute(i)&&(r=t.getAttribute(i));const s="dompurify"+(r?"#"+r:"");try{return e.createPolicy(s,{createHTML(o){return o},createScriptURL(o){return o}})}catch{return console.warn("TrustedTypes policy "+s+" could not be created."),null}},np=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function lv(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:UO();const e=L=>lv(L);if(e.version="3.3.3",e.removed=[],!n||!n.document||n.document.nodeType!==Pi.document||!n.Element)return e.isSupported=!1,e;let{document:t}=n;const r=t,i=r.currentScript,{DocumentFragment:s,HTMLTemplateElement:o,Node:a,Element:c,NodeFilter:u,NamedNodeMap:d=n.NamedNodeMap||n.MozNamedAttrMap,HTMLFormElement:f,DOMParser:v,trustedTypes:y}=n,A=c.prototype,k=Ii(A,"cloneNode"),I=Ii(A,"remove"),B=Ii(A,"nextSibling"),P=Ii(A,"childNodes"),le=Ii(A,"parentNode");if(typeof o=="function"){const L=t.createElement("template");L.content&&L.content.ownerDocument&&(t=L.content.ownerDocument)}let M,Z="";const{implementation:U,createNodeIterator:ge,createDocumentFragment:ce,getElementsByTagName:yi}=t,{importNode:to}=r;let $e=np();e.isSupported=typeof sv=="function"&&typeof le=="function"&&U&&U.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:kn,ERB_EXPR:mt,TMPLIT_EXPR:Xt,DATA_ATTR:qa,ARIA_ATTR:no,IS_SCRIPT_OR_DATA:$v,ATTR_WHITESPACE:th,CUSTOM_ELEMENT:Av}=tp;let{IS_ALLOWED_URI:nh}=tp,_e=null;const rh=V({},[...Jf,...Wl,...ql,...Yl,...Xf]);let Ae=null;const ih=V({},[...Qf,...Kl,...ep,...To]);let me=Object.seal(jo(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}})),vi=null,ro=null;const Qt=Object.seal(jo(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let sh=!0,Ya=!0,oh=!1,ah=!0,hr=!1,io=!0,En=!1,Ka=!1,Ja=!1,dr=!1,so=!1,oo=!1,lh=!0,ch=!1;const xv="user-content-";let Xa=!0,bi=!1,fr={},yt=null;const Qa=V({},["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 uh=null;const hh=V({},["audio","video","img","source","image","track"]);let el=null;const dh=V({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),ao="http://www.w3.org/1998/Math/MathML",lo="http://www.w3.org/2000/svg",It="http://www.w3.org/1999/xhtml";let pr=It,tl=!1,nl=null;const Tv=V({},[ao,lo,It],Bl);let co=V({},["mi","mo","mn","ms","mtext"]),uo=V({},["annotation-xml"]);const Cv=V({},["title","style","font","a","script"]);let wi=null;const Iv=["application/xhtml+xml","text/html"],Pv="text/html";let be=null,gr=null;const Rv=t.createElement("form"),fh=function(g){return g instanceof RegExp||g instanceof Function},rl=function(){let g=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(gr&&gr===g)){if((!g||typeof g!="object")&&(g={}),g=_t(g),wi=Iv.indexOf(g.PARSER_MEDIA_TYPE)===-1?Pv:g.PARSER_MEDIA_TYPE,be=wi==="application/xhtml+xml"?Bl:Bo,_e=Ye(g,"ALLOWED_TAGS")?V({},g.ALLOWED_TAGS,be):rh,Ae=Ye(g,"ALLOWED_ATTR")?V({},g.ALLOWED_ATTR,be):ih,nl=Ye(g,"ALLOWED_NAMESPACES")?V({},g.ALLOWED_NAMESPACES,Bl):Tv,el=Ye(g,"ADD_URI_SAFE_ATTR")?V(_t(dh),g.ADD_URI_SAFE_ATTR,be):dh,uh=Ye(g,"ADD_DATA_URI_TAGS")?V(_t(hh),g.ADD_DATA_URI_TAGS,be):hh,yt=Ye(g,"FORBID_CONTENTS")?V({},g.FORBID_CONTENTS,be):Qa,vi=Ye(g,"FORBID_TAGS")?V({},g.FORBID_TAGS,be):_t({}),ro=Ye(g,"FORBID_ATTR")?V({},g.FORBID_ATTR,be):_t({}),fr=Ye(g,"USE_PROFILES")?g.USE_PROFILES:!1,sh=g.ALLOW_ARIA_ATTR!==!1,Ya=g.ALLOW_DATA_ATTR!==!1,oh=g.ALLOW_UNKNOWN_PROTOCOLS||!1,ah=g.ALLOW_SELF_CLOSE_IN_ATTR!==!1,hr=g.SAFE_FOR_TEMPLATES||!1,io=g.SAFE_FOR_XML!==!1,En=g.WHOLE_DOCUMENT||!1,dr=g.RETURN_DOM||!1,so=g.RETURN_DOM_FRAGMENT||!1,oo=g.RETURN_TRUSTED_TYPE||!1,Ja=g.FORCE_BODY||!1,lh=g.SANITIZE_DOM!==!1,ch=g.SANITIZE_NAMED_PROPS||!1,Xa=g.KEEP_CONTENT!==!1,bi=g.IN_PLACE||!1,nh=g.ALLOWED_URI_REGEXP||ov,pr=g.NAMESPACE||It,co=g.MATHML_TEXT_INTEGRATION_POINTS||co,uo=g.HTML_INTEGRATION_POINTS||uo,me=g.CUSTOM_ELEMENT_HANDLING||{},g.CUSTOM_ELEMENT_HANDLING&&fh(g.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(me.tagNameCheck=g.CUSTOM_ELEMENT_HANDLING.tagNameCheck),g.CUSTOM_ELEMENT_HANDLING&&fh(g.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(me.attributeNameCheck=g.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),g.CUSTOM_ELEMENT_HANDLING&&typeof g.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(me.allowCustomizedBuiltInElements=g.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),hr&&(Ya=!1),so&&(dr=!0),fr&&(_e=V({},Xf),Ae=jo(null),fr.html===!0&&(V(_e,Jf),V(Ae,Qf)),fr.svg===!0&&(V(_e,Wl),V(Ae,Kl),V(Ae,To)),fr.svgFilters===!0&&(V(_e,ql),V(Ae,Kl),V(Ae,To)),fr.mathMl===!0&&(V(_e,Yl),V(Ae,ep),V(Ae,To))),Ye(g,"ADD_TAGS")||(Qt.tagCheck=null),Ye(g,"ADD_ATTR")||(Qt.attributeCheck=null),g.ADD_TAGS&&(typeof g.ADD_TAGS=="function"?Qt.tagCheck=g.ADD_TAGS:(_e===rh&&(_e=_t(_e)),V(_e,g.ADD_TAGS,be))),g.ADD_ATTR&&(typeof g.ADD_ATTR=="function"?Qt.attributeCheck=g.ADD_ATTR:(Ae===ih&&(Ae=_t(Ae)),V(Ae,g.ADD_ATTR,be))),g.ADD_URI_SAFE_ATTR&&V(el,g.ADD_URI_SAFE_ATTR,be),g.FORBID_CONTENTS&&(yt===Qa&&(yt=_t(yt)),V(yt,g.FORBID_CONTENTS,be)),g.ADD_FORBID_CONTENTS&&(yt===Qa&&(yt=_t(yt)),V(yt,g.ADD_FORBID_CONTENTS,be)),Xa&&(_e["#text"]=!0),En&&V(_e,["html","head","body"]),_e.table&&(V(_e,["tbody"]),delete vi.tbody),g.TRUSTED_TYPES_POLICY){if(typeof g.TRUSTED_TYPES_POLICY.createHTML!="function")throw Ci('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof g.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Ci('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');M=g.TRUSTED_TYPES_POLICY,Z=M.createHTML("")}else M===void 0&&(M=FO(y,i)),M!==null&&typeof Z=="string"&&(Z=M.createHTML(""));Ne&&Ne(g),gr=g}},ph=V({},[...Wl,...ql,...CO]),gh=V({},[...Yl,...IO]),Dv=function(g){let T=le(g);(!T||!T.tagName)&&(T={namespaceURI:pr,tagName:"template"});const R=Bo(g.tagName),ie=Bo(T.tagName);return nl[g.namespaceURI]?g.namespaceURI===lo?T.namespaceURI===It?R==="svg":T.namespaceURI===ao?R==="svg"&&(ie==="annotation-xml"||co[ie]):!!ph[R]:g.namespaceURI===ao?T.namespaceURI===It?R==="math":T.namespaceURI===lo?R==="math"&&uo[ie]:!!gh[R]:g.namespaceURI===It?T.namespaceURI===lo&&!uo[ie]||T.namespaceURI===ao&&!co[ie]?!1:!gh[R]&&(Cv[R]||!ph[R]):!!(wi==="application/xhtml+xml"&&nl[g.namespaceURI]):!1},vt=function(g){xi(e.removed,{element:g});try{le(g).removeChild(g)}catch{I(g)}},$n=function(g,T){try{xi(e.removed,{attribute:T.getAttributeNode(g),from:T})}catch{xi(e.removed,{attribute:null,from:T})}if(T.removeAttribute(g),g==="is")if(dr||so)try{vt(T)}catch{}else try{T.setAttribute(g,"")}catch{}},mh=function(g){let T=null,R=null;if(Ja)g="<remove></remove>"+g;else{const ye=Gl(g,/^[\r\n\t ]+/);R=ye&&ye[0]}wi==="application/xhtml+xml"&&pr===It&&(g='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+g+"</body></html>");const ie=M?M.createHTML(g):g;if(pr===It)try{T=new v().parseFromString(ie,wi)}catch{}if(!T||!T.documentElement){T=U.createDocument(pr,"template",null);try{T.documentElement.innerHTML=tl?Z:ie}catch{}}const Re=T.body||T.documentElement;return g&&R&&Re.insertBefore(t.createTextNode(R),Re.childNodes[0]||null),pr===It?yi.call(T,En?"html":"body")[0]:En?T.documentElement:Re},yh=function(g){return ge.call(g.ownerDocument||g,g,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},il=function(g){return g instanceof f&&(typeof g.nodeName!="string"||typeof g.textContent!="string"||typeof g.removeChild!="function"||!(g.attributes instanceof d)||typeof g.removeAttribute!="function"||typeof g.setAttribute!="function"||typeof g.namespaceURI!="string"||typeof g.insertBefore!="function"||typeof g.hasChildNodes!="function")},vh=function(g){return typeof a=="function"&&g instanceof a};function Pt(L,g,T){xo(L,R=>{R.call(e,g,T,gr)})}const bh=function(g){let T=null;if(Pt($e.beforeSanitizeElements,g,null),il(g))return vt(g),!0;const R=be(g.nodeName);if(Pt($e.uponSanitizeElement,g,{tagName:R,allowedTags:_e}),io&&g.hasChildNodes()&&!vh(g.firstElementChild)&&De(/<[/\w!]/g,g.innerHTML)&&De(/<[/\w!]/g,g.textContent)||g.nodeType===Pi.progressingInstruction||io&&g.nodeType===Pi.comment&&De(/<[/\w]/g,g.data))return vt(g),!0;if(!(Qt.tagCheck instanceof Function&&Qt.tagCheck(R))&&(!_e[R]||vi[R])){if(!vi[R]&&_h(R)&&(me.tagNameCheck instanceof RegExp&&De(me.tagNameCheck,R)||me.tagNameCheck instanceof Function&&me.tagNameCheck(R)))return!1;if(Xa&&!yt[R]){const ie=le(g)||g.parentNode,Re=P(g)||g.childNodes;if(Re&&ie){const ye=Re.length;for(let Fe=ye-1;Fe>=0;--Fe){const Rt=k(Re[Fe],!0);Rt.__removalCount=(g.__removalCount||0)+1,ie.insertBefore(Rt,B(g))}}}return vt(g),!0}return g instanceof c&&!Dv(g)||(R==="noscript"||R==="noembed"||R==="noframes")&&De(/<\/no(script|embed|frames)/i,g.innerHTML)?(vt(g),!0):(hr&&g.nodeType===Pi.text&&(T=g.textContent,xo([kn,mt,Xt],ie=>{T=Ti(T,ie," ")}),g.textContent!==T&&(xi(e.removed,{element:g.cloneNode()}),g.textContent=T)),Pt($e.afterSanitizeElements,g,null),!1)},wh=function(g,T,R){if(ro[T]||lh&&(T==="id"||T==="name")&&(R in t||R in Rv))return!1;if(!(Ya&&!ro[T]&&De(qa,T))){if(!(sh&&De(no,T))){if(!(Qt.attributeCheck instanceof Function&&Qt.attributeCheck(T,g))){if(!Ae[T]||ro[T]){if(!(_h(g)&&(me.tagNameCheck instanceof RegExp&&De(me.tagNameCheck,g)||me.tagNameCheck instanceof Function&&me.tagNameCheck(g))&&(me.attributeNameCheck instanceof RegExp&&De(me.attributeNameCheck,T)||me.attributeNameCheck instanceof Function&&me.attributeNameCheck(T,g))||T==="is"&&me.allowCustomizedBuiltInElements&&(me.tagNameCheck instanceof RegExp&&De(me.tagNameCheck,R)||me.tagNameCheck instanceof Function&&me.tagNameCheck(R))))return!1}else if(!el[T]){if(!De(nh,Ti(R,th,""))){if(!((T==="src"||T==="xlink:href"||T==="href")&&g!=="script"&&$O(R,"data:")===0&&uh[g])){if(!(oh&&!De($v,Ti(R,th,"")))){if(R)return!1}}}}}}}return!0},_h=function(g){return g!=="annotation-xml"&&Gl(g,Av)},Sh=function(g){Pt($e.beforeSanitizeAttributes,g,null);const{attributes:T}=g;if(!T||il(g))return;const R={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Ae,forceKeepAttr:void 0};let ie=T.length;for(;ie--;){const Re=T[ie],{name:ye,namespaceURI:Fe,value:Rt}=Re,mr=be(ye),sl=Rt;let xe=ye==="value"?sl:AO(sl);if(R.attrName=mr,R.attrValue=xe,R.keepAttr=!0,R.forceKeepAttr=void 0,Pt($e.uponSanitizeAttribute,g,R),xe=R.attrValue,ch&&(mr==="id"||mr==="name")&&($n(ye,g),xe=xv+xe),io&&De(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,xe)){$n(ye,g);continue}if(mr==="attributename"&&Gl(xe,"href")){$n(ye,g);continue}if(R.forceKeepAttr)continue;if(!R.keepAttr){$n(ye,g);continue}if(!ah&&De(/\/>/i,xe)){$n(ye,g);continue}hr&&xo([kn,mt,Xt],Eh=>{xe=Ti(xe,Eh," ")});const kh=be(g.nodeName);if(!wh(kh,mr,xe)){$n(ye,g);continue}if(M&&typeof y=="object"&&typeof y.getAttributeType=="function"&&!Fe)switch(y.getAttributeType(kh,mr)){case"TrustedHTML":{xe=M.createHTML(xe);break}case"TrustedScriptURL":{xe=M.createScriptURL(xe);break}}if(xe!==sl)try{Fe?g.setAttributeNS(Fe,ye,xe):g.setAttribute(ye,xe),il(g)?vt(g):Kf(e.removed)}catch{$n(ye,g)}}Pt($e.afterSanitizeAttributes,g,null)},Ov=function L(g){let T=null;const R=yh(g);for(Pt($e.beforeSanitizeShadowDOM,g,null);T=R.nextNode();)Pt($e.uponSanitizeShadowNode,T,null),bh(T),Sh(T),T.content instanceof s&&L(T.content);Pt($e.afterSanitizeShadowDOM,g,null)};return e.sanitize=function(L){let g=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},T=null,R=null,ie=null,Re=null;if(tl=!L,tl&&(L="<!-->"),typeof L!="string"&&!vh(L))if(typeof L.toString=="function"){if(L=L.toString(),typeof L!="string")throw Ci("dirty is not a string, aborting")}else throw Ci("toString is not a function");if(!e.isSupported)return L;if(Ka||rl(g),e.removed=[],typeof L=="string"&&(bi=!1),bi){if(L.nodeName){const Rt=be(L.nodeName);if(!_e[Rt]||vi[Rt])throw Ci("root node is forbidden and cannot be sanitized in-place")}}else if(L instanceof a)T=mh("<!---->"),R=T.ownerDocument.importNode(L,!0),R.nodeType===Pi.element&&R.nodeName==="BODY"||R.nodeName==="HTML"?T=R:T.appendChild(R);else{if(!dr&&!hr&&!En&&L.indexOf("<")===-1)return M&&oo?M.createHTML(L):L;if(T=mh(L),!T)return dr?null:oo?Z:""}T&&Ja&&vt(T.firstChild);const ye=yh(bi?L:T);for(;ie=ye.nextNode();)bh(ie),Sh(ie),ie.content instanceof s&&Ov(ie.content);if(bi)return L;if(dr){if(so)for(Re=ce.call(T.ownerDocument);T.firstChild;)Re.appendChild(T.firstChild);else Re=T;return(Ae.shadowroot||Ae.shadowrootmode)&&(Re=to.call(r,Re,!0)),Re}let Fe=En?T.outerHTML:T.innerHTML;return En&&_e["!doctype"]&&T.ownerDocument&&T.ownerDocument.doctype&&T.ownerDocument.doctype.name&&De(av,T.ownerDocument.doctype.name)&&(Fe="<!DOCTYPE "+T.ownerDocument.doctype.name+`>
|
|
333
|
+
`+Fe),hr&&xo([kn,mt,Xt],Rt=>{Fe=Ti(Fe,Rt," ")}),M&&oo?M.createHTML(Fe):Fe},e.setConfig=function(){let L=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};rl(L),Ka=!0},e.clearConfig=function(){gr=null,Ka=!1},e.isValidAttribute=function(L,g,T){gr||rl({});const R=be(L),ie=be(g);return wh(R,ie,T)},e.addHook=function(L,g){typeof g=="function"&&xi($e[L],g)},e.removeHook=function(L,g){if(g!==void 0){const T=kO($e[L],g);return T===-1?void 0:EO($e[L],T,1)[0]}return Kf($e[L])},e.removeHooks=function(L){$e[L]=[]},e.removeAllHooks=function(){$e=np()},e}var cv=lv();function ju(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var ur=ju();function uv(n){ur=n}var Dn={exec:()=>null};function W(n,e=""){let t=typeof n=="string"?n:n.source,r={replace:(i,s)=>{let o=typeof s=="string"?s:s.source;return o=o.replace(Le.caret,"$1"),t=t.replace(i,o),r},getRegex:()=>new RegExp(t,e)};return r}var ZO=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),Le={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:n=>new RegExp(`^( {0,3}${n})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}#`),htmlBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}<(?:[a-z].*>|!--)`,"i"),blockquoteBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}>`)},HO=/^(?:[ \t]*(?:\n|$))+/,VO=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,jO=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,eo=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,BO=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Bu=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,hv=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,dv=W(hv).replace(/bull/g,Bu).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(),GO=W(hv).replace(/bull/g,Bu).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(),Gu=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,WO=/^[^\n]+/,Wu=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,qO=W(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Wu).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),YO=W(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Bu).getRegex(),Ba="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",qu=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,KO=W("^ {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",qu).replace("tag",Ba).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),fv=W(Gu).replace("hr",eo).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",Ba).getRegex(),JO=W(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",fv).getRegex(),Yu={blockquote:JO,code:VO,def:qO,fences:jO,heading:BO,hr:eo,html:KO,lheading:dv,list:YO,newline:HO,paragraph:fv,table:Dn,text:WO},rp=W("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",eo).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",Ba).getRegex(),XO={...Yu,lheading:GO,table:rp,paragraph:W(Gu).replace("hr",eo).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",rp).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",Ba).getRegex()},QO={...Yu,html:W(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",qu).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:Dn,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:W(Gu).replace("hr",eo).replace("heading",` *#{1,6} *[^
|
|
334
|
+
]`).replace("lheading",dv).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},ez=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,tz=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,pv=/^( {2,}|\\)\n(?!\s*$)/,nz=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,mi=/[\p{P}\p{S}]/u,Ga=/[\s\p{P}\p{S}]/u,Ku=/[^\s\p{P}\p{S}]/u,rz=W(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Ga).getRegex(),gv=/(?!~)[\p{P}\p{S}]/u,iz=/(?!~)[\s\p{P}\p{S}]/u,sz=/(?:[^\s\p{P}\p{S}]|~)/u,oz=W(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",ZO?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),mv=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,az=W(mv,"u").replace(/punct/g,mi).getRegex(),lz=W(mv,"u").replace(/punct/g,gv).getRegex(),yv="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",cz=W(yv,"gu").replace(/notPunctSpace/g,Ku).replace(/punctSpace/g,Ga).replace(/punct/g,mi).getRegex(),uz=W(yv,"gu").replace(/notPunctSpace/g,sz).replace(/punctSpace/g,iz).replace(/punct/g,gv).getRegex(),hz=W("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Ku).replace(/punctSpace/g,Ga).replace(/punct/g,mi).getRegex(),dz=W(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,mi).getRegex(),fz="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",pz=W(fz,"gu").replace(/notPunctSpace/g,Ku).replace(/punctSpace/g,Ga).replace(/punct/g,mi).getRegex(),gz=W(/\\(punct)/,"gu").replace(/punct/g,mi).getRegex(),mz=W(/^<(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(),yz=W(qu).replace("(?:-->|$)","-->").getRegex(),vz=W("^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",yz).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),aa=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,bz=W(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",aa).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),vv=W(/^!?\[(label)\]\[(ref)\]/).replace("label",aa).replace("ref",Wu).getRegex(),bv=W(/^!?\[(ref)\](?:\[\])?/).replace("ref",Wu).getRegex(),wz=W("reflink|nolink(?!\\()","g").replace("reflink",vv).replace("nolink",bv).getRegex(),ip=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Ju={_backpedal:Dn,anyPunctuation:gz,autolink:mz,blockSkip:oz,br:pv,code:tz,del:Dn,delLDelim:Dn,delRDelim:Dn,emStrongLDelim:az,emStrongRDelimAst:cz,emStrongRDelimUnd:hz,escape:ez,link:bz,nolink:bv,punctuation:rz,reflink:vv,reflinkSearch:wz,tag:vz,text:nz,url:Dn},_z={...Ju,link:W(/^!?\[(label)\]\((.*?)\)/).replace("label",aa).getRegex(),reflink:W(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",aa).getRegex()},Bc={...Ju,emStrongRDelimAst:uz,emStrongLDelim:lz,delLDelim:dz,delRDelim:pz,url:W(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",ip).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:W(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",ip).getRegex()},Sz={...Bc,br:W(pv).replace("{2,}","*").getRegex(),text:W(Bc.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Co={normal:Yu,gfm:XO,pedantic:QO},Ri={normal:Ju,gfm:Bc,breaks:Sz,pedantic:_z},kz={"&":"&","<":"<",">":">",'"':""","'":"'"},sp=n=>kz[n];function St(n,e){if(e){if(Le.escapeTest.test(n))return n.replace(Le.escapeReplace,sp)}else if(Le.escapeTestNoEncode.test(n))return n.replace(Le.escapeReplaceNoEncode,sp);return n}function op(n){try{n=encodeURI(n).replace(Le.percentDecode,"%")}catch{return null}return n}function ap(n,e){var s;let t=n.replace(Le.findPipe,(o,a,c)=>{let u=!1,d=a;for(;--d>=0&&c[d]==="\\";)u=!u;return u?"|":" |"}),r=t.split(Le.splitPipe),i=0;if(r[0].trim()||r.shift(),r.length>0&&!((s=r.at(-1))!=null&&s.trim())&&r.pop(),e)if(r.length>e)r.splice(e);else for(;r.length<e;)r.push("");for(;i<r.length;i++)r[i]=r[i].trim().replace(Le.slashPipe,"|");return r}function Di(n,e,t){let r=n.length;if(r===0)return"";let i=0;for(;i<r&&n.charAt(r-i-1)===e;)i++;return n.slice(0,r-i)}function Ez(n,e){if(n.indexOf(e[1])===-1)return-1;let t=0;for(let r=0;r<n.length;r++)if(n[r]==="\\")r++;else if(n[r]===e[0])t++;else if(n[r]===e[1]&&(t--,t<0))return r;return t>0?-2:-1}function $z(n,e=0){let t=e,r="";for(let i of n)if(i===" "){let s=4-t%4;r+=" ".repeat(s),t+=s}else r+=i,t++;return r}function lp(n,e,t,r,i){let s=e.href,o=e.title||null,a=n[1].replace(i.other.outputLinkReplace,"$1");r.state.inLink=!0;let c={type:n[0].charAt(0)==="!"?"image":"link",raw:t,href:s,title:o,text:a,tokens:r.inlineTokens(a)};return r.state.inLink=!1,c}function Az(n,e,t){let r=n.match(t.other.indentCodeCompensation);if(r===null)return e;let i=r[1];return e.split(`
|
|
335
|
+
`).map(s=>{let o=s.match(t.other.beginningSpace);if(o===null)return s;let[a]=o;return a.length>=i.length?s.slice(i.length):s}).join(`
|
|
336
|
+
`)}var la=class{constructor(n){b(this,"options");b(this,"rules");b(this,"lexer");this.options=n||ur}space(n){let e=this.rules.block.newline.exec(n);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(n){let e=this.rules.block.code.exec(n);if(e){let t=e[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:e[0],codeBlockStyle:"indented",text:this.options.pedantic?t:Di(t,`
|
|
337
|
+
`)}}}fences(n){let e=this.rules.block.fences.exec(n);if(e){let t=e[0],r=Az(t,e[3]||"",this.rules);return{type:"code",raw:t,lang:e[2]?e[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):e[2],text:r}}}heading(n){let e=this.rules.block.heading.exec(n);if(e){let t=e[2].trim();if(this.rules.other.endingHash.test(t)){let r=Di(t,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(t=r.trim())}return{type:"heading",raw:e[0],depth:e[1].length,text:t,tokens:this.lexer.inline(t)}}}hr(n){let e=this.rules.block.hr.exec(n);if(e)return{type:"hr",raw:Di(e[0],`
|
|
338
|
+
`)}}blockquote(n){let e=this.rules.block.blockquote.exec(n);if(e){let t=Di(e[0],`
|
|
339
|
+
`).split(`
|
|
340
|
+
`),r="",i="",s=[];for(;t.length>0;){let o=!1,a=[],c;for(c=0;c<t.length;c++)if(this.rules.other.blockquoteStart.test(t[c]))a.push(t[c]),o=!0;else if(!o)a.push(t[c]);else break;t=t.slice(c);let u=a.join(`
|
|
341
|
+
`),d=u.replace(this.rules.other.blockquoteSetextReplace,`
|
|
342
|
+
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");r=r?`${r}
|
|
343
|
+
${u}`:u,i=i?`${i}
|
|
344
|
+
${d}`:d;let f=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(d,s,!0),this.lexer.state.top=f,t.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 y=v,A=y.raw+`
|
|
345
|
+
`+t.join(`
|
|
346
|
+
`),k=this.blockquote(A);s[s.length-1]=k,r=r.substring(0,r.length-y.raw.length)+k.raw,i=i.substring(0,i.length-y.text.length)+k.text;break}else if((v==null?void 0:v.type)==="list"){let y=v,A=y.raw+`
|
|
347
|
+
`+t.join(`
|
|
348
|
+
`),k=this.list(A);s[s.length-1]=k,r=r.substring(0,r.length-v.raw.length)+k.raw,i=i.substring(0,i.length-y.raw.length)+k.raw,t=A.substring(s.at(-1).raw.length).split(`
|
|
349
|
+
`);continue}}return{type:"blockquote",raw:r,tokens:s,text:i}}}list(n){var t,r;let e=this.rules.block.list.exec(n);if(e){let i=e[1].trim(),s=i.length>1,o={type:"list",raw:"",ordered:s,start:s?+i.slice(0,-1):"",loose:!1,items:[]};i=s?`\\d{1,9}\\${i.slice(-1)}`:`\\${i}`,this.options.pedantic&&(i=s?i:"[*+-]");let a=this.rules.other.listItemRegex(i),c=!1;for(;n;){let d=!1,f="",v="";if(!(e=a.exec(n))||this.rules.block.hr.test(n))break;f=e[0],n=n.substring(f.length);let y=$z(e[2].split(`
|
|
350
|
+
`,1)[0],e[1].length),A=n.split(`
|
|
351
|
+
`,1)[0],k=!y.trim(),I=0;if(this.options.pedantic?(I=2,v=y.trimStart()):k?I=e[1].length+1:(I=y.search(this.rules.other.nonSpaceChar),I=I>4?1:I,v=y.slice(I),I+=e[1].length),k&&this.rules.other.blankLine.test(A)&&(f+=A+`
|
|
352
|
+
`,n=n.substring(A.length+1),d=!0),!d){let B=this.rules.other.nextBulletRegex(I),P=this.rules.other.hrRegex(I),le=this.rules.other.fencesBeginRegex(I),M=this.rules.other.headingBeginRegex(I),Z=this.rules.other.htmlBeginRegex(I),U=this.rules.other.blockquoteBeginRegex(I);for(;n;){let ge=n.split(`
|
|
353
|
+
`,1)[0],ce;if(A=ge,this.options.pedantic?(A=A.replace(this.rules.other.listReplaceNesting," "),ce=A):ce=A.replace(this.rules.other.tabCharGlobal," "),le.test(A)||M.test(A)||Z.test(A)||U.test(A)||B.test(A)||P.test(A))break;if(ce.search(this.rules.other.nonSpaceChar)>=I||!A.trim())v+=`
|
|
354
|
+
`+ce.slice(I);else{if(k||y.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||le.test(y)||M.test(y)||P.test(y))break;v+=`
|
|
355
|
+
`+A}k=!A.trim(),f+=ge+`
|
|
356
|
+
`,n=n.substring(ge.length+1),y=ce.slice(I)}}o.loose||(c?o.loose=!0:this.rules.other.doubleBlankLine.test(f)&&(c=!0)),o.items.push({type:"list_item",raw:f,task:!!this.options.gfm&&this.rules.other.listIsTask.test(v),loose:!1,text:v,tokens:[]}),o.raw+=f}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 d of o.items){if(this.lexer.state.top=!1,d.tokens=this.lexer.blockTokens(d.text,[]),d.task){if(d.text=d.text.replace(this.rules.other.listReplaceTask,""),((t=d.tokens[0])==null?void 0:t.type)==="text"||((r=d.tokens[0])==null?void 0:r.type)==="paragraph"){d.tokens[0].raw=d.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),d.tokens[0].text=d.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let 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 f=this.rules.other.listTaskCheckbox.exec(d.raw);if(f){let v={type:"checkbox",raw:f[0]+" ",checked:f[0]!=="[ ]"};d.checked=v.checked,o.loose?d.tokens[0]&&["paragraph","text"].includes(d.tokens[0].type)&&"tokens"in d.tokens[0]&&d.tokens[0].tokens?(d.tokens[0].raw=v.raw+d.tokens[0].raw,d.tokens[0].text=v.raw+d.tokens[0].text,d.tokens[0].tokens.unshift(v)):d.tokens.unshift({type:"paragraph",raw:v.raw,text:v.raw,tokens:[v]}):d.tokens.unshift(v)}}if(!o.loose){let f=d.tokens.filter(y=>y.type==="space"),v=f.length>0&&f.some(y=>this.rules.other.anyLine.test(y.raw));o.loose=v}}if(o.loose)for(let d of o.items){d.loose=!0;for(let f of d.tokens)f.type==="text"&&(f.type="paragraph")}return o}}html(n){let e=this.rules.block.html.exec(n);if(e)return{type:"html",block:!0,raw:e[0],pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:e[0]}}def(n){let e=this.rules.block.def.exec(n);if(e){let t=e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),r=e[2]?e[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",i=e[3]?e[3].substring(1,e[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):e[3];return{type:"def",tag:t,raw:e[0],href:r,title:i}}}table(n){var o;let e=this.rules.block.table.exec(n);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;let t=ap(e[1]),r=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),i=(o=e[3])!=null&&o.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
357
|
+
`):[],s={type:"table",raw:e[0],header:[],align:[],rows:[]};if(t.length===r.length){for(let a of r)this.rules.other.tableAlignRight.test(a)?s.align.push("right"):this.rules.other.tableAlignCenter.test(a)?s.align.push("center"):this.rules.other.tableAlignLeft.test(a)?s.align.push("left"):s.align.push(null);for(let a=0;a<t.length;a++)s.header.push({text:t[a],tokens:this.lexer.inline(t[a]),header:!0,align:s.align[a]});for(let a of i)s.rows.push(ap(a,s.header.length).map((c,u)=>({text:c,tokens:this.lexer.inline(c),header:!1,align:s.align[u]})));return s}}lheading(n){let e=this.rules.block.lheading.exec(n);if(e){let t=e[1].trim();return{type:"heading",raw:e[0],depth:e[2].charAt(0)==="="?1:2,text:t,tokens:this.lexer.inline(t)}}}paragraph(n){let e=this.rules.block.paragraph.exec(n);if(e){let t=e[1].charAt(e[1].length-1)===`
|
|
358
|
+
`?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:t,tokens:this.lexer.inline(t)}}}text(n){let e=this.rules.block.text.exec(n);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(n){let e=this.rules.inline.escape.exec(n);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(n){let e=this.rules.inline.tag.exec(n);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(n){let e=this.rules.inline.link.exec(n);if(e){let t=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(t)){if(!this.rules.other.endAngleBracket.test(t))return;let s=Di(t.slice(0,-1),"\\");if((t.length-s.length)%2===0)return}else{let s=Ez(e[2],"()");if(s===-2)return;if(s>-1){let o=(e[0].indexOf("!")===0?5:4)+e[1].length+s;e[2]=e[2].substring(0,s),e[0]=e[0].substring(0,o).trim(),e[3]=""}}let r=e[2],i="";if(this.options.pedantic){let s=this.rules.other.pedanticHrefTitle.exec(r);s&&(r=s[1],i=s[3])}else i=e[3]?e[3].slice(1,-1):"";return r=r.trim(),this.rules.other.startAngleBracket.test(r)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(t)?r=r.slice(1):r=r.slice(1,-1)),lp(e,{href:r&&r.replace(this.rules.inline.anyPunctuation,"$1"),title:i&&i.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer,this.rules)}}reflink(n,e){let t;if((t=this.rules.inline.reflink.exec(n))||(t=this.rules.inline.nolink.exec(n))){let r=(t[2]||t[1]).replace(this.rules.other.multipleSpaceGlobal," "),i=e[r.toLowerCase()];if(!i){let s=t[0].charAt(0);return{type:"text",raw:s,text:s}}return lp(t,i,t[0],this.lexer,this.rules)}}emStrong(n,e,t=""){let r=this.rules.inline.emStrongLDelim.exec(n);if(!(!r||!r[1]&&!r[2]&&!r[3]&&!r[4]||r[4]&&t.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[3])||!t||this.rules.inline.punctuation.exec(t))){let i=[...r[0]].length-1,s,o,a=i,c=0,u=r[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(u.lastIndex=0,e=e.slice(-1*n.length+i);(r=u.exec(e))!=null;){if(s=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!s)continue;if(o=[...s].length,r[3]||r[4]){a+=o;continue}else if((r[5]||r[6])&&i%3&&!((i+o)%3)){c+=o;continue}if(a-=o,a>0)continue;o=Math.min(o,o+a+c);let d=[...r[0]][0].length,f=n.slice(0,i+r.index+d+o);if(Math.min(i,o)%2){let y=f.slice(1,-1);return{type:"em",raw:f,text:y,tokens:this.lexer.inlineTokens(y)}}let v=f.slice(2,-2);return{type:"strong",raw:f,text:v,tokens:this.lexer.inlineTokens(v)}}}}codespan(n){let e=this.rules.inline.code.exec(n);if(e){let t=e[2].replace(this.rules.other.newLineCharGlobal," "),r=this.rules.other.nonSpaceChar.test(t),i=this.rules.other.startingSpaceChar.test(t)&&this.rules.other.endingSpaceChar.test(t);return r&&i&&(t=t.substring(1,t.length-1)),{type:"codespan",raw:e[0],text:t}}}br(n){let e=this.rules.inline.br.exec(n);if(e)return{type:"br",raw:e[0]}}del(n,e,t=""){let r=this.rules.inline.delLDelim.exec(n);if(r&&(!r[1]||!t||this.rules.inline.punctuation.exec(t))){let i=[...r[0]].length-1,s,o,a=i,c=this.rules.inline.delRDelim;for(c.lastIndex=0,e=e.slice(-1*n.length+i);(r=c.exec(e))!=null;){if(s=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!s||(o=[...s].length,o!==i))continue;if(r[3]||r[4]){a+=o;continue}if(a-=o,a>0)continue;o=Math.min(o,o+a);let u=[...r[0]][0].length,d=n.slice(0,i+r.index+u+o),f=d.slice(i,-i);return{type:"del",raw:d,text:f,tokens:this.lexer.inlineTokens(f)}}}}autolink(n){let e=this.rules.inline.autolink.exec(n);if(e){let t,r;return e[2]==="@"?(t=e[1],r="mailto:"+t):(t=e[1],r=t),{type:"link",raw:e[0],text:t,href:r,tokens:[{type:"text",raw:t,text:t}]}}}url(n){var t;let e;if(e=this.rules.inline.url.exec(n)){let r,i;if(e[2]==="@")r=e[0],i="mailto:"+r;else{let s;do s=e[0],e[0]=((t=this.rules.inline._backpedal.exec(e[0]))==null?void 0:t[0])??"";while(s!==e[0]);r=e[0],e[1]==="www."?i="http://"+e[0]:i=e[0]}return{type:"link",raw:e[0],text:r,href:i,tokens:[{type:"text",raw:r,text:r}]}}}inlineText(n){let e=this.rules.inline.text.exec(n);if(e){let t=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:e[0],escaped:t}}}},dt=class Gc{constructor(e){b(this,"tokens");b(this,"options");b(this,"state");b(this,"inlineQueue");b(this,"tokenizer");this.tokens=[],this.tokens.links=Object.create(null),this.options=e||ur,this.options.tokenizer=this.options.tokenizer||new la,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 t={other:Le,block:Co.normal,inline:Ri.normal};this.options.pedantic?(t.block=Co.pedantic,t.inline=Ri.pedantic):this.options.gfm&&(t.block=Co.gfm,this.options.breaks?t.inline=Ri.breaks:t.inline=Ri.gfm),this.tokenizer.rules=t}static get rules(){return{block:Co,inline:Ri}}static lex(e,t){return new Gc(t).lex(e)}static lexInline(e,t){return new Gc(t).inlineTokens(e)}lex(e){e=e.replace(Le.carriageReturn,`
|
|
359
|
+
`),this.blockTokens(e,this.tokens);for(let t=0;t<this.inlineQueue.length;t++){let r=this.inlineQueue[t];this.inlineTokens(r.src,r.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],r=!1){var i,s,o;for(this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(Le.tabCharGlobal," ").replace(Le.spaceLine,""));e;){let a;if((s=(i=this.options.extensions)==null?void 0:i.block)!=null&&s.some(u=>(a=u.call({lexer:this},e,t))?(e=e.substring(a.raw.length),t.push(a),!0):!1))continue;if(a=this.tokenizer.space(e)){e=e.substring(a.raw.length);let u=t.at(-1);a.raw.length===1&&u!==void 0?u.raw+=`
|
|
360
|
+
`:t.push(a);continue}if(a=this.tokenizer.code(e)){e=e.substring(a.raw.length);let u=t.at(-1);(u==null?void 0:u.type)==="paragraph"||(u==null?void 0:u.type)==="text"?(u.raw+=(u.raw.endsWith(`
|
|
361
|
+
`)?"":`
|
|
362
|
+
`)+a.raw,u.text+=`
|
|
363
|
+
`+a.text,this.inlineQueue.at(-1).src=u.text):t.push(a);continue}if(a=this.tokenizer.fences(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.heading(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.hr(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.blockquote(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.list(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.html(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.def(e)){e=e.substring(a.raw.length);let u=t.at(-1);(u==null?void 0:u.type)==="paragraph"||(u==null?void 0:u.type)==="text"?(u.raw+=(u.raw.endsWith(`
|
|
364
|
+
`)?"":`
|
|
365
|
+
`)+a.raw,u.text+=`
|
|
366
|
+
`+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},t.push(a));continue}if(a=this.tokenizer.table(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.lheading(e)){e=e.substring(a.raw.length),t.push(a);continue}let c=e;if((o=this.options.extensions)!=null&&o.startBlock){let u=1/0,d=e.slice(1),f;this.options.extensions.startBlock.forEach(v=>{f=v.call({lexer:this},d),typeof f=="number"&&f>=0&&(u=Math.min(u,f))}),u<1/0&&u>=0&&(c=e.substring(0,u+1))}if(this.state.top&&(a=this.tokenizer.paragraph(c))){let u=t.at(-1);r&&(u==null?void 0:u.type)==="paragraph"?(u.raw+=(u.raw.endsWith(`
|
|
367
|
+
`)?"":`
|
|
368
|
+
`)+a.raw,u.text+=`
|
|
369
|
+
`+a.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=u.text):t.push(a),r=c.length!==e.length,e=e.substring(a.raw.length);continue}if(a=this.tokenizer.text(e)){e=e.substring(a.raw.length);let u=t.at(-1);(u==null?void 0:u.type)==="text"?(u.raw+=(u.raw.endsWith(`
|
|
370
|
+
`)?"":`
|
|
371
|
+
`)+a.raw,u.text+=`
|
|
372
|
+
`+a.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=u.text):t.push(a);continue}if(e){let u="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(u);break}else throw new Error(u)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){var c,u,d,f,v;this.tokenizer.lexer=this;let r=e,i=null;if(this.tokens.links){let y=Object.keys(this.tokens.links);if(y.length>0)for(;(i=this.tokenizer.rules.inline.reflinkSearch.exec(r))!=null;)y.includes(i[0].slice(i[0].lastIndexOf("[")+1,-1))&&(r=r.slice(0,i.index)+"["+"a".repeat(i[0].length-2)+"]"+r.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(i=this.tokenizer.rules.inline.anyPunctuation.exec(r))!=null;)r=r.slice(0,i.index)+"++"+r.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let s;for(;(i=this.tokenizer.rules.inline.blockSkip.exec(r))!=null;)s=i[2]?i[2].length:0,r=r.slice(0,i.index+s)+"["+"a".repeat(i[0].length-s-2)+"]"+r.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);r=((u=(c=this.options.hooks)==null?void 0:c.emStrongMask)==null?void 0:u.call({lexer:this},r))??r;let o=!1,a="";for(;e;){o||(a=""),o=!1;let y;if((f=(d=this.options.extensions)==null?void 0:d.inline)!=null&&f.some(k=>(y=k.call({lexer:this},e,t))?(e=e.substring(y.raw.length),t.push(y),!0):!1))continue;if(y=this.tokenizer.escape(e)){e=e.substring(y.raw.length),t.push(y);continue}if(y=this.tokenizer.tag(e)){e=e.substring(y.raw.length),t.push(y);continue}if(y=this.tokenizer.link(e)){e=e.substring(y.raw.length),t.push(y);continue}if(y=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(y.raw.length);let k=t.at(-1);y.type==="text"&&(k==null?void 0:k.type)==="text"?(k.raw+=y.raw,k.text+=y.text):t.push(y);continue}if(y=this.tokenizer.emStrong(e,r,a)){e=e.substring(y.raw.length),t.push(y);continue}if(y=this.tokenizer.codespan(e)){e=e.substring(y.raw.length),t.push(y);continue}if(y=this.tokenizer.br(e)){e=e.substring(y.raw.length),t.push(y);continue}if(y=this.tokenizer.del(e,r,a)){e=e.substring(y.raw.length),t.push(y);continue}if(y=this.tokenizer.autolink(e)){e=e.substring(y.raw.length),t.push(y);continue}if(!this.state.inLink&&(y=this.tokenizer.url(e))){e=e.substring(y.raw.length),t.push(y);continue}let A=e;if((v=this.options.extensions)!=null&&v.startInline){let k=1/0,I=e.slice(1),B;this.options.extensions.startInline.forEach(P=>{B=P.call({lexer:this},I),typeof B=="number"&&B>=0&&(k=Math.min(k,B))}),k<1/0&&k>=0&&(A=e.substring(0,k+1))}if(y=this.tokenizer.inlineText(A)){e=e.substring(y.raw.length),y.raw.slice(-1)!=="_"&&(a=y.raw.slice(-1)),o=!0;let k=t.at(-1);(k==null?void 0:k.type)==="text"?(k.raw+=y.raw,k.text+=y.text):t.push(y);continue}if(e){let k="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(k);break}else throw new Error(k)}}return t}},ca=class{constructor(n){b(this,"options");b(this,"parser");this.options=n||ur}space(n){return""}code({text:n,lang:e,escaped:t}){var s;let r=(s=(e||"").match(Le.notSpaceStart))==null?void 0:s[0],i=n.replace(Le.endingNewline,"")+`
|
|
373
|
+
`;return r?'<pre><code class="language-'+St(r)+'">'+(t?i:St(i,!0))+`</code></pre>
|
|
374
|
+
`:"<pre><code>"+(t?i:St(i,!0))+`</code></pre>
|
|
375
|
+
`}blockquote({tokens:n}){return`<blockquote>
|
|
376
|
+
${this.parser.parse(n)}</blockquote>
|
|
377
|
+
`}html({text:n}){return n}def(n){return""}heading({tokens:n,depth:e}){return`<h${e}>${this.parser.parseInline(n)}</h${e}>
|
|
378
|
+
`}hr(n){return`<hr>
|
|
379
|
+
`}list(n){let e=n.ordered,t=n.start,r="";for(let o=0;o<n.items.length;o++){let a=n.items[o];r+=this.listitem(a)}let i=e?"ol":"ul",s=e&&t!==1?' start="'+t+'"':"";return"<"+i+s+`>
|
|
380
|
+
`+r+"</"+i+`>
|
|
381
|
+
`}listitem(n){return`<li>${this.parser.parse(n.tokens)}</li>
|
|
382
|
+
`}checkbox({checked:n}){return"<input "+(n?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:n}){return`<p>${this.parser.parseInline(n)}</p>
|
|
383
|
+
`}table(n){let e="",t="";for(let i=0;i<n.header.length;i++)t+=this.tablecell(n.header[i]);e+=this.tablerow({text:t});let r="";for(let i=0;i<n.rows.length;i++){let s=n.rows[i];t="";for(let o=0;o<s.length;o++)t+=this.tablecell(s[o]);r+=this.tablerow({text:t})}return r&&(r=`<tbody>${r}</tbody>`),`<table>
|
|
384
|
+
<thead>
|
|
385
|
+
`+e+`</thead>
|
|
386
|
+
`+r+`</table>
|
|
387
|
+
`}tablerow({text:n}){return`<tr>
|
|
388
|
+
${n}</tr>
|
|
389
|
+
`}tablecell(n){let e=this.parser.parseInline(n.tokens),t=n.header?"th":"td";return(n.align?`<${t} align="${n.align}">`:`<${t}>`)+e+`</${t}>
|
|
390
|
+
`}strong({tokens:n}){return`<strong>${this.parser.parseInline(n)}</strong>`}em({tokens:n}){return`<em>${this.parser.parseInline(n)}</em>`}codespan({text:n}){return`<code>${St(n,!0)}</code>`}br(n){return"<br>"}del({tokens:n}){return`<del>${this.parser.parseInline(n)}</del>`}link({href:n,title:e,tokens:t}){let r=this.parser.parseInline(t),i=op(n);if(i===null)return r;n=i;let s='<a href="'+n+'"';return e&&(s+=' title="'+St(e)+'"'),s+=">"+r+"</a>",s}image({href:n,title:e,text:t,tokens:r}){r&&(t=this.parser.parseInline(r,this.parser.textRenderer));let i=op(n);if(i===null)return St(t);n=i;let s=`<img src="${n}" alt="${St(t)}"`;return e&&(s+=` title="${St(e)}"`),s+=">",s}text(n){return"tokens"in n&&n.tokens?this.parser.parseInline(n.tokens):"escaped"in n&&n.escaped?n.text:St(n.text)}},Xu=class{strong({text:n}){return n}em({text:n}){return n}codespan({text:n}){return n}del({text:n}){return n}html({text:n}){return n}text({text:n}){return n}link({text:n}){return""+n}image({text:n}){return""+n}br(){return""}checkbox({raw:n}){return n}},ft=class Wc{constructor(e){b(this,"options");b(this,"renderer");b(this,"textRenderer");this.options=e||ur,this.options.renderer=this.options.renderer||new ca,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Xu}static parse(e,t){return new Wc(t).parse(e)}static parseInline(e,t){return new Wc(t).parseInline(e)}parse(e){var r,i;this.renderer.parser=this;let t="";for(let s=0;s<e.length;s++){let o=e[s];if((i=(r=this.options.extensions)==null?void 0:r.renderers)!=null&&i[o.type]){let c=o,u=this.options.extensions.renderers[c.type].call({parser:this},c);if(u!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(c.type)){t+=u||"";continue}}let a=o;switch(a.type){case"space":{t+=this.renderer.space(a);break}case"hr":{t+=this.renderer.hr(a);break}case"heading":{t+=this.renderer.heading(a);break}case"code":{t+=this.renderer.code(a);break}case"table":{t+=this.renderer.table(a);break}case"blockquote":{t+=this.renderer.blockquote(a);break}case"list":{t+=this.renderer.list(a);break}case"checkbox":{t+=this.renderer.checkbox(a);break}case"html":{t+=this.renderer.html(a);break}case"def":{t+=this.renderer.def(a);break}case"paragraph":{t+=this.renderer.paragraph(a);break}case"text":{t+=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 t}parseInline(e,t=this.renderer){var i,s;this.renderer.parser=this;let r="";for(let o=0;o<e.length;o++){let a=e[o];if((s=(i=this.options.extensions)==null?void 0:i.renderers)!=null&&s[a.type]){let u=this.options.extensions.renderers[a.type].call({parser:this},a);if(u!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(a.type)){r+=u||"";continue}}let c=a;switch(c.type){case"escape":{r+=t.text(c);break}case"html":{r+=t.html(c);break}case"link":{r+=t.link(c);break}case"image":{r+=t.image(c);break}case"checkbox":{r+=t.checkbox(c);break}case"strong":{r+=t.strong(c);break}case"em":{r+=t.em(c);break}case"codespan":{r+=t.codespan(c);break}case"br":{r+=t.br(c);break}case"del":{r+=t.del(c);break}case"text":{r+=t.text(c);break}default:{let u='Token with "'+c.type+'" type was not found.';if(this.options.silent)return console.error(u),"";throw new Error(u)}}}return r}},Io,Vi=(Io=class{constructor(n){b(this,"options");b(this,"block");this.options=n||ur}preprocess(n){return n}postprocess(n){return n}processAllTokens(n){return n}emStrongMask(n){return n}provideLexer(){return this.block?dt.lex:dt.lexInline}provideParser(){return this.block?ft.parse:ft.parseInline}},b(Io,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),b(Io,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),Io),xz=class{constructor(...n){b(this,"defaults",ju());b(this,"options",this.setOptions);b(this,"parse",this.parseMarkdown(!0));b(this,"parseInline",this.parseMarkdown(!1));b(this,"Parser",ft);b(this,"Renderer",ca);b(this,"TextRenderer",Xu);b(this,"Lexer",dt);b(this,"Tokenizer",la);b(this,"Hooks",Vi);this.use(...n)}walkTokens(n,e){var r,i;let t=[];for(let s of n)switch(t=t.concat(e.call(this,s)),s.type){case"table":{let o=s;for(let a of o.header)t=t.concat(this.walkTokens(a.tokens,e));for(let a of o.rows)for(let c of a)t=t.concat(this.walkTokens(c.tokens,e));break}case"list":{let o=s;t=t.concat(this.walkTokens(o.items,e));break}default:{let o=s;(i=(r=this.defaults.extensions)==null?void 0:r.childTokens)!=null&&i[o.type]?this.defaults.extensions.childTokens[o.type].forEach(a=>{let c=o[a].flat(1/0);t=t.concat(this.walkTokens(c,e))}):o.tokens&&(t=t.concat(this.walkTokens(o.tokens,e)))}}return t}use(...n){let e=this.defaults.extensions||{renderers:{},childTokens:{}};return n.forEach(t=>{let r={...t};if(r.async=this.defaults.async||r.async||!1,t.extensions&&(t.extensions.forEach(i=>{if(!i.name)throw new Error("extension name required");if("renderer"in i){let s=e.renderers[i.name];s?e.renderers[i.name]=function(...o){let a=i.renderer.apply(this,o);return a===!1&&(a=s.apply(this,o)),a}:e.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=e[i.level];s?s.unshift(i.tokenizer):e[i.level]=[i.tokenizer],i.start&&(i.level==="block"?e.startBlock?e.startBlock.push(i.start):e.startBlock=[i.start]:i.level==="inline"&&(e.startInline?e.startInline.push(i.start):e.startInline=[i.start]))}"childTokens"in i&&i.childTokens&&(e.childTokens[i.name]=i.childTokens)}),r.extensions=e),t.renderer){let i=this.defaults.renderer||new ca(this.defaults);for(let s in t.renderer){if(!(s in i))throw new Error(`renderer '${s}' does not exist`);if(["options","parser"].includes(s))continue;let o=s,a=t.renderer[o],c=i[o];i[o]=(...u)=>{let d=a.apply(i,u);return d===!1&&(d=c.apply(i,u)),d||""}}r.renderer=i}if(t.tokenizer){let i=this.defaults.tokenizer||new la(this.defaults);for(let s in t.tokenizer){if(!(s in i))throw new Error(`tokenizer '${s}' does not exist`);if(["options","rules","lexer"].includes(s))continue;let o=s,a=t.tokenizer[o],c=i[o];i[o]=(...u)=>{let d=a.apply(i,u);return d===!1&&(d=c.apply(i,u)),d}}r.tokenizer=i}if(t.hooks){let i=this.defaults.hooks||new Vi;for(let s in t.hooks){if(!(s in i))throw new Error(`hook '${s}' does not exist`);if(["options","block"].includes(s))continue;let o=s,a=t.hooks[o],c=i[o];Vi.passThroughHooks.has(s)?i[o]=u=>{if(this.defaults.async&&Vi.passThroughHooksRespectAsync.has(s))return(async()=>{let f=await a.call(i,u);return c.call(i,f)})();let d=a.call(i,u);return c.call(i,d)}:i[o]=(...u)=>{if(this.defaults.async)return(async()=>{let f=await a.apply(i,u);return f===!1&&(f=await c.apply(i,u)),f})();let d=a.apply(i,u);return d===!1&&(d=c.apply(i,u)),d}}r.hooks=i}if(t.walkTokens){let i=this.defaults.walkTokens,s=t.walkTokens;r.walkTokens=function(o){let a=[];return a.push(s.call(this,o)),i&&(a=a.concat(i.call(this,o))),a}}this.defaults={...this.defaults,...r}}),this}setOptions(n){return this.defaults={...this.defaults,...n},this}lexer(n,e){return dt.lex(n,e??this.defaults)}parser(n,e){return ft.parse(n,e??this.defaults)}parseMarkdown(n){return(e,t)=>{let r={...t},i={...this.defaults,...r},s=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return s(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof e>"u"||e===null)return s(new Error("marked(): input parameter is undefined or null"));if(typeof e!="string")return s(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected"));if(i.hooks&&(i.hooks.options=i,i.hooks.block=n),i.async)return(async()=>{let o=i.hooks?await i.hooks.preprocess(e):e,a=await(i.hooks?await i.hooks.provideLexer():n?dt.lex:dt.lexInline)(o,i),c=i.hooks?await i.hooks.processAllTokens(a):a;i.walkTokens&&await Promise.all(this.walkTokens(c,i.walkTokens));let u=await(i.hooks?await i.hooks.provideParser():n?ft.parse:ft.parseInline)(c,i);return i.hooks?await i.hooks.postprocess(u):u})().catch(s);try{i.hooks&&(e=i.hooks.preprocess(e));let o=(i.hooks?i.hooks.provideLexer():n?dt.lex:dt.lexInline)(e,i);i.hooks&&(o=i.hooks.processAllTokens(o)),i.walkTokens&&this.walkTokens(o,i.walkTokens);let a=(i.hooks?i.hooks.provideParser():n?ft.parse:ft.parseInline)(o,i);return i.hooks&&(a=i.hooks.postprocess(a)),a}catch(o){return s(o)}}}onError(n,e){return t=>{if(t.message+=`
|
|
391
|
+
Please report this to https://github.com/markedjs/marked.`,n){let r="<p>An error occurred:</p><pre>"+St(t.message+"",!0)+"</pre>";return e?Promise.resolve(r):r}if(e)return Promise.reject(t);throw t}}},sr=new xz;function K(n,e){return sr.parse(n,e)}K.options=K.setOptions=function(n){return sr.setOptions(n),K.defaults=sr.defaults,uv(K.defaults),K};K.getDefaults=ju;K.defaults=ur;K.use=function(...n){return sr.use(...n),K.defaults=sr.defaults,uv(K.defaults),K};K.walkTokens=function(n,e){return sr.walkTokens(n,e)};K.parseInline=sr.parseInline;K.Parser=ft;K.parser=ft.parse;K.Renderer=ca;K.TextRenderer=Xu;K.Lexer=dt;K.lexer=dt.lex;K.Tokenizer=la;K.Hooks=Vi;K.parse=K;K.options;K.setOptions;K.use;K.walkTokens;K.parseInline;ft.parse;dt.lex;cv.addHook("afterSanitizeAttributes",n=>{n.tagName==="A"&&(n.setAttribute("target","_blank"),n.setAttribute("rel","noopener noreferrer"))});function Tz(n){const e=K.parse(n,{async:!1});return cv.sanitize(e,{USE_PROFILES:{html:!0}})}const Cz=8,cp=new WeakMap;function Iz(n){const e=cp.get(n);if(e&&e.text===n.text)return e.html;const t=Tz(n.text);return cp.set(n,{text:n.text,html:t}),t}function up(n){for(let e=n.length-1;e>=0;e-=1){const t=n[e];if(t&&t.kind==="user")return t.id}return null}var jt,Qn,xa,Ta,Ls,qc;class wv extends ts{constructor(){super(...arguments);_(this,Ls);b(this,"messages",[]);_(this,jt,!0);_(this,Qn,null);_(this,xa,()=>{const t=l(this,Qn);if(!t)return;const i=t.scrollHeight-t.clientHeight-t.scrollTop<=Cz;i!==l(this,jt)&&(E(this,jt,i),this.toggleAttribute("data-pinned",i))});_(this,Ta,()=>{E(this,jt,!0),this.toggleAttribute("data-pinned",!0),m(this,Ls,qc).call(this,!0)})}changed(t){let r=!1;if(t.has("messages")){const i=t.get("messages")??[],s=up(this.messages);r=s!==null&&s!==up(i),r&&E(this,jt,!0)}Pe(this.template(),this),l(this,Qn)||E(this,Qn,this.querySelector(".history-scroll")),this.toggleAttribute("data-pinned",l(this,jt)),m(this,Ls,qc).call(this,r)}template(){const t=this.messages.filter(r=>r.kind==="user"||r.kind==="assistant");return F`
|
|
392
|
+
<div class="history-scroll" @scroll=${l(this,xa)}>
|
|
393
|
+
${t.map(r=>{const i=r.kind==="assistant"?HR(Iz(r)):r.text;return F`<div
|
|
394
|
+
class="message message-${r.kind}"
|
|
395
|
+
data-message-id=${r.id}
|
|
396
|
+
>${i}</div>`})}
|
|
397
|
+
</div>
|
|
398
|
+
<button
|
|
399
|
+
type="button"
|
|
400
|
+
class="history-jump"
|
|
401
|
+
aria-label="Jump to latest message"
|
|
402
|
+
@click=${l(this,Ta)}
|
|
403
|
+
>
|
|
404
|
+
${_y({size:16})}
|
|
405
|
+
</button>
|
|
406
|
+
`}}jt=new WeakMap,Qn=new WeakMap,xa=new WeakMap,Ta=new WeakMap,Ls=new WeakSet,qc=function(t){requestAnimationFrame(()=>{const r=l(this,Qn);r&&(!l(this,jt)&&!t||(r.scrollTop=r.scrollHeight-r.clientHeight))})},b(wv,"properties",["messages"]);customElements.define("message-history",wv);var Ms,Ns,Kr,Us,vn,Kc,Jc,Fs,Zs;class Yc extends ts{constructor(){super(...arguments);_(this,vn);b(this,"placeholder","What do you want to do?");b(this,"open",!1);b(this,"messages",[]);_(this,Ms,Ge.resolve("ACPClientManager"));_(this,Ns,Ge.resolve("ShortcutService"));_(this,Kr,null);b(this,"handleTriggerActivate",()=>{this.open=!0});b(this,"handleKeydown",t=>{if(t.key!=="Enter"||t.shiftKey)return;const r=t.currentTarget,i=r.value.trim();if(t.preventDefault(),!i)return;r.value="";const s=l(this,Ms).getActiveClient();s&&s.sendMessage({text:i}).catch(o=>{console.error("ACPClient.sendMessage() failed",o)})});_(this,Us,t=>{if(t.shortcut!=="focusCommandInput")return;if(!this.open){this.open=!0;return}const r=this.querySelector("textarea");if(r){if(document.activeElement===r){this.open=!1;return}r.focus()}});_(this,Fs,t=>{t.target instanceof Node&&(this.contains(t.target)||(this.open=!1))});_(this,Zs,t=>{t.key==="Escape"&&(this.open=!1)})}connected(){const t=new DisposableStack;E(this,Kr,t);const r=bO(l(this,Ms),i=>{this.messages=i});t.defer(()=>r.dispose()),l(this,Ns).addEventListener("shortcut-triggered",l(this,Us)),t.defer(()=>l(this,Ns).removeEventListener("shortcut-triggered",l(this,Us))),this.open&&m(this,vn,Kc).call(this)}disconnected(){var t;(t=l(this,Kr))==null||t.dispose(),E(this,Kr,null),m(this,vn,Jc).call(this)}changed(t){if(Pe(this.template(),this),t.has("open"))if(this.open){m(this,vn,Kc).call(this);const r=this.querySelector("textarea");r==null||r.focus()}else m(this,vn,Jc).call(this)}template(){return this.open?F`
|
|
407
|
+
<message-history .messages=${this.messages}></message-history>
|
|
408
|
+
<textarea
|
|
409
|
+
class="input"
|
|
410
|
+
rows="1"
|
|
411
|
+
@keydown=${this.handleKeydown}
|
|
412
|
+
></textarea>
|
|
413
|
+
`:F`
|
|
414
|
+
<button
|
|
415
|
+
class="trigger"
|
|
416
|
+
type="button"
|
|
417
|
+
@click=${this.handleTriggerActivate}
|
|
418
|
+
@focus=${this.handleTriggerActivate}
|
|
419
|
+
>
|
|
420
|
+
<span class="label">${this.placeholder}</span>
|
|
421
|
+
<span class="kbd" aria-hidden="true">⌘K</span>
|
|
422
|
+
</button>
|
|
423
|
+
`}}Ms=new WeakMap,Ns=new WeakMap,Kr=new WeakMap,Us=new WeakMap,vn=new WeakSet,Kc=function(){document.addEventListener("mousedown",l(this,Fs)),document.addEventListener("keydown",l(this,Zs))},Jc=function(){document.removeEventListener("mousedown",l(this,Fs)),document.removeEventListener("keydown",l(this,Zs))},Fs=new WeakMap,Zs=new WeakMap,b(Yc,"properties",["placeholder","open","messages"]),b(Yc,"attributes",{placeholder:{type:String},open:{type:Boolean}});customElements.define("command-panel",Yc);class _v extends Event{constructor(t){super("auth-submit",{bubbles:!0,composed:!0});b(this,"token");this.token=t}}class Pz extends HTMLElement{constructor(){super(...arguments);b(this,"_invalid",!1);b(this,"_tokenValue","")}set invalid(t){this._invalid=t,this.render()}get invalid(){return this._invalid}set tokenValue(t){this._tokenValue=t,this.render()}get tokenValue(){return this._tokenValue}connectedCallback(){this.render()}handleInput(t){const r=t.currentTarget;this._tokenValue=r.value}handleSubmit(t){t.preventDefault();const r=this._tokenValue.trim();r&&this.dispatchEvent(new _v(r))}render(){Pe(F`
|
|
424
|
+
<modal-overlay open>
|
|
425
|
+
<section class="auth-modal">
|
|
426
|
+
<form class="auth-form" @submit=${t=>this.handleSubmit(t)}>
|
|
427
|
+
<h2 class="auth-modal-title">Enter access token</h2>
|
|
428
|
+
<p class="auth-modal-copy">This Television server requires a token.</p>
|
|
429
|
+
<label class="settings-field">
|
|
430
|
+
<span>Token</span>
|
|
431
|
+
<input
|
|
432
|
+
class=${this.invalid?"auth-token-input-invalid":""}
|
|
433
|
+
type="password"
|
|
434
|
+
name="token"
|
|
435
|
+
.value=${this.tokenValue}
|
|
436
|
+
@input=${t=>this.handleInput(t)}
|
|
437
|
+
required
|
|
438
|
+
/>
|
|
439
|
+
</label>
|
|
440
|
+
<button type="submit" class="settings-submit-button">Connect</button>
|
|
441
|
+
</form>
|
|
442
|
+
</section>
|
|
443
|
+
</modal-overlay>
|
|
444
|
+
`,this)}}customElements.get("auth-modal")||customElements.define("auth-modal",Pz);class Rz extends HTMLElement{constructor(){super(...arguments);b(this,"runtimeServerURL",hy());b(this,"electronMode",dy());b(this,"serverManager",Ge.resolve("ServerManager"));b(this,"screenManager",Ge.resolve("ScreenManager"));b(this,"connectError",null);b(this,"handleServerManagerChange",()=>{this.render()});b(this,"handleActiveScreenChanged",()=>{this.render()})}connectedCallback(){this.serverManager.addEventListener("change",this.handleServerManagerChange),this.screenManager.addEventListener("active-screen-changed",this.handleActiveScreenChanged),this.addEventListener("auth-submit",t=>{var i;const r=t instanceof _v?t.token:t instanceof CustomEvent&&typeof((i=t.detail)==null?void 0:i.token)=="string"?t.detail.token:null;r&&this.handleAuthSubmit(r)}),this.initializeConnection(),this.render()}disconnectedCallback(){this.serverManager.removeEventListener("change",this.handleServerManagerChange),this.screenManager.removeEventListener("active-screen-changed",this.handleActiveScreenChanged)}async initializeConnection(){if(this.electronMode){this.serverManager.connectConfiguredServers(this.runtimeServerURL,kc());return}if(this.serverManager.activeServer)return;const t=new mc({url:this.runtimeServerURL,name:"Server",token:kc()});this.serverManager.add(t),this.serverManager.setActive(t);try{await t.connect(),this.connectError=null}catch(r){this.connectError=r instanceof Error&&!(r instanceof gc)?r.message:null}this.render()}async handleAuthSubmit(t){const r=this.serverManager.activeServer;if(r){this.connectError=null,r.token=t,this.updateTokenQueryParam(t);try{await r.connect()}catch(i){i instanceof gc||(this.connectError=i instanceof Error?i.message:String(i))}this.render()}}updateTokenQueryParam(t){const r=new URL(window.location.href);r.searchParams.set("token",t),window.history.replaceState({},"",`${r.pathname}${r.search}${r.hash}`)}render(){const t=this.serverManager.activeServer,r=(t==null?void 0:t.status)??null;if(r==="connecting"){Pe(F`
|
|
445
|
+
<main class="auth-gate"><p>Connecting...</p></main>
|
|
446
|
+
`,this);return}if(r==="disconnected"){const o=t;if(!o)return;Pe(F`
|
|
447
|
+
<main class="auth-gate">
|
|
448
|
+
<auth-modal
|
|
449
|
+
.invalid=${!!o.token}
|
|
450
|
+
.tokenValue=${o.token??""}
|
|
451
|
+
></auth-modal>
|
|
452
|
+
</main>
|
|
453
|
+
`,this);return}const s=this.screenManager.activeScreen?F`<screen-view></screen-view>`:F`<home-screen></home-screen>`;Pe(F`
|
|
454
|
+
<main>
|
|
455
|
+
${this.connectError?F`<p data-testid="auth-error">${this.connectError}</p>`:F`
|
|
456
|
+
${s}
|
|
457
|
+
${r==="connected"?F`
|
|
458
|
+
<div class="chrome">
|
|
459
|
+
<div class="top-row electron-draggable">
|
|
460
|
+
<screen-breadcrumb></screen-breadcrumb>
|
|
461
|
+
<screen-create-button></screen-create-button>
|
|
462
|
+
</div>
|
|
463
|
+
<command-panel></command-panel>
|
|
464
|
+
</div>
|
|
465
|
+
`:null}
|
|
466
|
+
`}
|
|
467
|
+
</main>
|
|
468
|
+
`,this)}}customElements.get("television-app")||customElements.define("television-app",Rz);const Qu=dy(),Wa=hy(),Sv=new J0(Qu?"television-electron":"television-browser",K0(Wa)),kv=new VC({localStore:Sv,localServerURL:Wa}),Ev=new W0({localStore:Sv,serverManager:kv}),Dz=new ER({serverURL:Wa,token:kc()??"",screenManager:Ev}),Oz=new AR;Ge.register("ServerManager",()=>kv);Ge.register("ScreenManager",()=>Ev);Ge.register("ACPClientManager",()=>Dz);Ge.register("ShortcutService",()=>Oz);const eh=document.createElement("television-app");eh.runtimeServerURL=Wa;eh.electronMode=Qu;Qu&&document.body.classList.add("electron");document.body.appendChild(eh);
|