@telepath-computer/television 0.1.175 → 0.1.177
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.
|
@@ -1,718 +0,0 @@
|
|
|
1
|
-
var mS=Object.defineProperty;var Gp=r=>{throw TypeError(r)};var vS=(r,t,e)=>t in r?mS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var g=(r,t,e)=>vS(r,typeof t!="symbol"?t+"":t,e),Qc=(r,t,e)=>t.has(r)||Gp("Cannot "+e);var l=(r,t,e)=>(Qc(r,t,"read from private field"),e?e.call(r):t.get(r)),w=(r,t,e)=>t.has(r)?Gp("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(r):t.set(r,e),b=(r,t,e,n)=>(Qc(r,t,"write to private field"),n?n.call(r,e):t.set(r,e),e),p=(r,t,e)=>(Qc(r,t,"access private method"),e);var eu=(r,t,e,n)=>({set _(i){b(r,t,i,e)},get _(){return l(r,t,n)}});import{i as qp,a as tu,b as Yp,c as Kp,d as Jp,e as yS,U as bS,f as Xp,g as Qp,A as wS,h as SS,j as _S}from"./artifact-bridge-C0H5cXgO.js";import{m as kS,a as xS,b as ES}from"./missing-artifact-page-DVzJ41AE.js";var _n=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function AS(r){if(r.__esModule)return r;var t=r.default;if(typeof t=="function"){var e=function n(){return this instanceof n?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};e.prototype=t.prototype}else e={};return Object.defineProperty(e,"__esModule",{value:!0}),Object.keys(r).forEach(function(n){var i=Object.getOwnPropertyDescriptor(r,n);Object.defineProperty(e,n,i.get?i:{enumerable:!0,get:function(){return r[n]}})}),e}var ef=Object.prototype.toString,av=function(t){var e=ef.call(t),n=e==="[object Arguments]";return n||(n=e!=="[object Array]"&&t!==null&&typeof t=="object"&&typeof t.length=="number"&&t.length>=0&&ef.call(t.callee)==="[object Function]"),n},ru,tf;function TS(){if(tf)return ru;tf=1;var r;if(!Object.keys){var t=Object.prototype.hasOwnProperty,e=Object.prototype.toString,n=av,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(y){var m=y.constructor;return m&&m.prototype===y},u={$applicationCache:!0,$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$onmozfullscreenchange:!0,$onmozfullscreenerror:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},h=function(){if(typeof window>"u")return!1;for(var y in window)try{if(!u["$"+y]&&t.call(window,y)&&window[y]!==null&&typeof window[y]=="object")try{c(window[y])}catch{return!0}}catch{return!0}return!1}(),f=function(y){if(typeof window>"u"||!h)return c(y);try{return c(y)}catch{return!1}};r=function(m){var E=m!==null&&typeof m=="object",x=e.call(m)==="[object Function]",I=n(m),P=E&&e.call(m)==="[object String]",R=[];if(!E&&!x&&!I)throw new TypeError("Object.keys called on a non-object");var B=o&&x;if(P&&m.length>0&&!t.call(m,0))for(var N=0;N<m.length;++N)R.push(String(N));if(I&&m.length>0)for(var F=0;F<m.length;++F)R.push(String(F));else for(var Y in m)!(B&&Y==="prototype")&&t.call(m,Y)&&R.push(String(Y));if(s)for(var j=f(m),ce=0;ce<a.length;++ce)!(j&&a[ce]==="constructor")&&t.call(m,a[ce])&&R.push(a[ce]);return R}}return ru=r,ru}var $S=Array.prototype.slice,IS=av,rf=Object.keys,cl=rf?function(t){return rf(t)}:TS(),nf=Object.keys;cl.shim=function(){if(Object.keys){var t=function(){var e=Object.keys(arguments);return e&&e.length===arguments.length}(1,2);t||(Object.keys=function(n){return IS(n)?nf($S.call(n)):nf(n)})}else Object.keys=cl;return Object.keys||cl};var CS=cl,ul=Object.defineProperty||!1;if(ul)try{ul({},"a",{value:1})}catch{ul=!1}var Sa=ul,Rr=SyntaxError,K=TypeError,RS=Object.getOwnPropertyDescriptor,hl=RS;if(hl)try{hl([],"length")}catch{hl=null}var bs=hl,sf=Sa,PS=Rr,fi=K,of=bs,lv=function(t,e,n){if(!t||typeof t!="object"&&typeof t!="function")throw new fi("`obj` must be an object or a function`");if(typeof e!="string"&&typeof e!="symbol")throw new fi("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new fi("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new fi("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new fi("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new fi("`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=!!of&&of(t,e);if(sf)sf(t,e,{configurable:o===null&&c?c.configurable:!o,enumerable:i===null&&c?c.enumerable:!i,value:n,writable:s===null&&c?c.writable:!s});else if(a||!i&&!s&&!o)t[e]=n;else throw new PS("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},Qu=Sa,cv=function(){return!!Qu};cv.hasArrayLengthDefineBug=function(){if(!Qu)return null;try{return Qu([],"length",{value:1}).length!==1}catch{return!0}};var bc=cv,LS=CS,DS=typeof Symbol=="function"&&typeof Symbol("foo")=="symbol",zS=Object.prototype.toString,OS=Array.prototype.concat,af=lv,MS=function(r){return typeof r=="function"&&zS.call(r)==="[object Function]"},uv=bc(),NS=function(r,t,e,n){if(t in r){if(n===!0){if(r[t]===e)return}else if(!MS(n)||!n())return}uv?af(r,t,e,!0):af(r,t,e)},hv=function(r,t){var e=arguments.length>2?arguments[2]:{},n=LS(t);DS&&(n=OS.call(n,Object.getOwnPropertySymbols(t)));for(var i=0;i<n.length;i+=1)NS(r,n[i],t[n[i]],e[n[i]])};hv.supportsDescriptors=!!uv;var ii=hv,dl={exports:{}};typeof self<"u"?dl.exports=self:typeof window<"u"?dl.exports=window:dl.exports=Function("return this")();var dv=dl.exports,US=dv,pv=function(){return typeof _n!="object"||!_n||_n.Math!==Math||_n.Array!==Array?US:_n},FS=ii,HS=bs,ZS=pv,WS=function(){var t=ZS();if(FS.supportsDescriptors){var e=HS(t,"globalThis");(!e||e.configurable&&(e.enumerable||!e.writable||globalThis!==t))&&Object.defineProperty(t,"globalThis",{configurable:!0,enumerable:!1,value:t,writable:!0})}else(typeof globalThis!="object"||globalThis!==t)&&(t.globalThis=t);return t},BS=ii,VS=dv,fv=pv,jS=WS,GS=fv(),gv=function(){return GS};BS(gv,{getPolyfill:fv,implementation:VS,shim:jS});var bd=gv,Pr=function(t){return!!t&&(typeof t=="function"||typeof t=="object")},wd=Object,mv=Error,qS=EvalError,YS=RangeError,Sd=ReferenceError,KS=URIError,JS=Math.abs,XS=Math.floor,QS=Math.max,e_=Math.min,t_=Math.pow,r_=Math.round,_d=Number.isNaN||function(t){return t!==t},n_=_d,i_=function(t){return n_(t)||t===0?t:t<0?-1:1},ws=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var t={},e=Symbol("test"),n=Object(e);if(typeof e=="string"||Object.prototype.toString.call(e)!=="[object Symbol]"||Object.prototype.toString.call(n)!=="[object Symbol]")return!1;var i=42;t[e]=i;for(var s in t)return!1;if(typeof Object.keys=="function"&&Object.keys(t).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(t).length!==0)return!1;var o=Object.getOwnPropertySymbols(t);if(o.length!==1||o[0]!==e||!Object.prototype.propertyIsEnumerable.call(t,e))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var a=Object.getOwnPropertyDescriptor(t,e);if(a.value!==i||a.enumerable!==!0)return!1}return!0},lf=typeof Symbol<"u"&&Symbol,s_=ws,kd=function(){return typeof lf!="function"||typeof Symbol!="function"||typeof lf("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:s_()},vv=typeof Reflect<"u"&&Reflect.getPrototypeOf||null,o_=wd,yv=o_.getPrototypeOf||null,a_="Function.prototype.bind called on incompatible ",l_=Object.prototype.toString,c_=Math.max,u_="[object Function]",cf=function(t,e){for(var n=[],i=0;i<t.length;i+=1)n[i]=t[i];for(var s=0;s<e.length;s+=1)n[s+t.length]=e[s];return n},h_=function(t,e){for(var n=[],i=e,s=0;i<t.length;i+=1,s+=1)n[s]=t[i];return n},d_=function(r,t){for(var e="",n=0;n<r.length;n+=1)e+=r[n],n+1<r.length&&(e+=t);return e},p_=function(t){var e=this;if(typeof e!="function"||l_.apply(e)!==u_)throw new TypeError(a_+e);for(var n=h_(arguments,1),i,s=function(){if(this instanceof i){var h=e.apply(this,cf(n,arguments));return Object(h)===h?h:this}return e.apply(t,cf(n,arguments))},o=c_(0,e.length-n.length),a=[],c=0;c<o;c++)a[c]="$"+c;if(i=Function("binder","return function ("+d_(a,",")+"){ return binder.apply(this,arguments); }")(s),e.prototype){var u=function(){};u.prototype=e.prototype,i.prototype=new u,u.prototype=null}return i},f_=p_,_a=Function.prototype.bind||f_,xd=Function.prototype.call,Ed=Function.prototype.apply,g_=typeof Reflect<"u"&&Reflect&&Reflect.apply,m_=_a,v_=Ed,y_=xd,b_=g_,bv=b_||m_.call(y_,v_),w_=_a,S_=K,__=xd,k_=bv,wc=function(t){if(t.length<1||typeof t[0]!="function")throw new S_("a function is required");return k_(w_,__,t)},x_=wc,uf=bs,wv;try{wv=[].__proto__===Array.prototype}catch(r){if(!r||typeof r!="object"||!("code"in r)||r.code!=="ERR_PROTO_ACCESS")throw r}var nu=!!wv&&uf&&uf(Object.prototype,"__proto__"),Sv=Object,hf=Sv.getPrototypeOf,E_=nu&&typeof nu.get=="function"?x_([nu.get]):typeof hf=="function"?function(t){return hf(t==null?t:Sv(t))}:!1,df=vv,pf=yv,ff=E_,_v=df?function(t){return df(t)}:pf?function(t){if(!t||typeof t!="object"&&typeof t!="function")throw new TypeError("getProto: not an object");return pf(t)}:ff?function(t){return ff(t)}:null,A_=Function.prototype.call,T_=Object.prototype.hasOwnProperty,$_=_a,Lr=$_.call(A_,T_),q,I_=wd,C_=mv,R_=qS,P_=YS,L_=Sd,ds=Rr,zi=K,D_=KS,z_=JS,O_=XS,M_=QS,N_=e_,U_=t_,F_=r_,H_=i_,kv=Function,iu=function(r){try{return kv('"use strict"; return ('+r+").constructor;")()}catch{}},uo=bs,Z_=Sa,su=function(){throw new zi},W_=uo?function(){try{return arguments.callee,su}catch{try{return uo(arguments,"callee").get}catch{return su}}}():su,gi=kd(),Le=_v,B_=yv,V_=vv,xv=Ed,ka=xd,Si={},j_=typeof Uint8Array>"u"||!Le?q:Le(Uint8Array),Kn={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?q:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?q:ArrayBuffer,"%ArrayIteratorPrototype%":gi&&Le?Le([][Symbol.iterator]()):q,"%AsyncFromSyncIteratorPrototype%":q,"%AsyncFunction%":Si,"%AsyncGenerator%":Si,"%AsyncGeneratorFunction%":Si,"%AsyncIteratorPrototype%":Si,"%Atomics%":typeof Atomics>"u"?q:Atomics,"%BigInt%":typeof BigInt>"u"?q:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?q:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?q:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?q:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":C_,"%eval%":eval,"%EvalError%":R_,"%Float16Array%":typeof Float16Array>"u"?q:Float16Array,"%Float32Array%":typeof Float32Array>"u"?q:Float32Array,"%Float64Array%":typeof Float64Array>"u"?q:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?q:FinalizationRegistry,"%Function%":kv,"%GeneratorFunction%":Si,"%Int8Array%":typeof Int8Array>"u"?q:Int8Array,"%Int16Array%":typeof Int16Array>"u"?q:Int16Array,"%Int32Array%":typeof Int32Array>"u"?q:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":gi&&Le?Le(Le([][Symbol.iterator]())):q,"%JSON%":typeof JSON=="object"?JSON:q,"%Map%":typeof Map>"u"?q:Map,"%MapIteratorPrototype%":typeof Map>"u"||!gi||!Le?q:Le(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":I_,"%Object.getOwnPropertyDescriptor%":uo,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?q:Promise,"%Proxy%":typeof Proxy>"u"?q:Proxy,"%RangeError%":P_,"%ReferenceError%":L_,"%Reflect%":typeof Reflect>"u"?q:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?q:Set,"%SetIteratorPrototype%":typeof Set>"u"||!gi||!Le?q:Le(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?q:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":gi&&Le?Le(""[Symbol.iterator]()):q,"%Symbol%":gi?Symbol:q,"%SyntaxError%":ds,"%ThrowTypeError%":W_,"%TypedArray%":j_,"%TypeError%":zi,"%Uint8Array%":typeof Uint8Array>"u"?q:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?q:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?q:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?q:Uint32Array,"%URIError%":D_,"%WeakMap%":typeof WeakMap>"u"?q:WeakMap,"%WeakRef%":typeof WeakRef>"u"?q:WeakRef,"%WeakSet%":typeof WeakSet>"u"?q:WeakSet,"%Function.prototype.call%":ka,"%Function.prototype.apply%":xv,"%Object.defineProperty%":Z_,"%Object.getPrototypeOf%":B_,"%Math.abs%":z_,"%Math.floor%":O_,"%Math.max%":M_,"%Math.min%":N_,"%Math.pow%":U_,"%Math.round%":F_,"%Math.sign%":H_,"%Reflect.getPrototypeOf%":V_};if(Le)try{null.error}catch(r){var G_=Le(Le(r));Kn["%Error.prototype%"]=G_}var q_=function r(t){var e;if(t==="%AsyncFunction%")e=iu("async function () {}");else if(t==="%GeneratorFunction%")e=iu("function* () {}");else if(t==="%AsyncGeneratorFunction%")e=iu("async function* () {}");else if(t==="%AsyncGenerator%"){var n=r("%AsyncGeneratorFunction%");n&&(e=n.prototype)}else if(t==="%AsyncIteratorPrototype%"){var i=r("%AsyncGenerator%");i&&Le&&(e=Le(i.prototype))}return Kn[t]=e,e},gf={__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"]},xa=_a,Ol=Lr,Y_=xa.call(ka,Array.prototype.concat),K_=xa.call(xv,Array.prototype.splice),mf=xa.call(ka,String.prototype.replace),Ml=xa.call(ka,String.prototype.slice),J_=xa.call(ka,RegExp.prototype.exec),X_=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,Q_=/\\(\\)?/g,ek=function(t){var e=Ml(t,0,1),n=Ml(t,-1);if(e==="%"&&n!=="%")throw new ds("invalid intrinsic syntax, expected closing `%`");if(n==="%"&&e!=="%")throw new ds("invalid intrinsic syntax, expected opening `%`");var i=[];return mf(t,X_,function(s,o,a,c){i[i.length]=a?mf(c,Q_,"$1"):o||s}),i},tk=function(t,e){var n=t,i;if(Ol(gf,n)&&(i=gf[n],n="%"+i[0]+"%"),Ol(Kn,n)){var s=Kn[n];if(s===Si&&(s=q_(n)),typeof s>"u"&&!e)throw new zi("intrinsic "+t+" exists, but is not available. Please file an issue!");return{alias:i,name:n,value:s}}throw new ds("intrinsic "+t+" does not exist!")},xt=function(t,e){if(typeof t!="string"||t.length===0)throw new zi("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof e!="boolean")throw new zi('"allowMissing" argument must be a boolean');if(J_(/^%?[^%]*%?$/,t)===null)throw new ds("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var n=ek(t),i=n.length>0?n[0]:"",s=tk("%"+i+"%",e),o=s.name,a=s.value,c=!1,u=s.alias;u&&(i=u[0],K_(n,Y_([0,1],u)));for(var h=1,f=!0;h<n.length;h+=1){var y=n[h],m=Ml(y,0,1),E=Ml(y,-1);if((m==='"'||m==="'"||m==="`"||E==='"'||E==="'"||E==="`")&&m!==E)throw new ds("property names with quotes must have matching quotes");if((y==="constructor"||!f)&&(c=!0),i+="."+y,o="%"+i+"%",Ol(Kn,o))a=Kn[o];else if(a!=null){if(!(y in a)){if(!e)throw new zi("base intrinsic for "+t+" exists, but the property is not available.");return}if(uo&&h+1>=n.length){var x=uo(a,y);f=!!x,f&&"get"in x&&!("originalValue"in x.get)?a=x.get:a=a[y]}else f=Ol(a,y),a=a[y];f&&!c&&(Kn[o]=a)}}return a},ou,vf;function an(){if(vf)return ou;vf=1;var r=xt,t=wc,e=t([r("%String.prototype.indexOf%")]);return ou=function(i,s){var o=r(i,!!s);return typeof o=="function"&&e(i,".prototype.")>-1?t([o]):o},ou}var au,yf;function Ad(){if(yf)return au;yf=1;var r=xt,t=r("%Array%"),e=!t.isArray&&an()("Object.prototype.toString");return au=t.isArray||function(i){return e(i)==="[object Array]"},au}var rk=bc,bf=Sa,Ev=rk.hasArrayLengthDefineBug(),nk=Ev&&Ad(),ik=an(),sk=ik("Object.prototype.propertyIsEnumerable"),Td=function(t,e,n,i,s,o){if(!bf){if(!t(o)||!o["[[Configurable]]"]||!o["[[Writable]]"]||s in i&&sk(i,s)!==!!o["[[Enumerable]]"])return!1;var a=o["[[Value]]"];return i[s]=a,e(i[s],a)}return Ev&&s==="length"&&"[[Value]]"in o&&nk(i)&&i.length!==o["[[Value]]"]?(i.length=o["[[Value]]"],i.length===o["[[Value]]"]):(bf(i,s,n(o)),!0)},ok=K,Ds=Lr,ak={__proto__:null,"[[Configurable]]":!0,"[[Enumerable]]":!0,"[[Get]]":!0,"[[Set]]":!0,"[[Value]]":!0,"[[Writable]]":!0},Ss=function(t){if(!t||typeof t!="object")return!1;for(var e in t)if(Ds(t,e)&&!ak[e])return!1;var n=Ds(t,"[[Value]]")||Ds(t,"[[Writable]]"),i=Ds(t,"[[Get]]")||Ds(t,"[[Set]]");if(n&&i)throw new ok("Property Descriptors may not be both accessor and data descriptors");return!0},Av=function(t){if(typeof t>"u")return t;var e={};return"[[Value]]"in t&&(e.value=t["[[Value]]"]),"[[Writable]]"in t&&(e.writable=!!t["[[Writable]]"]),"[[Get]]"in t&&(e.get=t["[[Get]]"]),"[[Set]]"in t&&(e.set=t["[[Set]]"]),"[[Enumerable]]"in t&&(e.enumerable=!!t["[[Enumerable]]"]),"[[Configurable]]"in t&&(e.configurable=!!t["[[Configurable]]"]),e},lk=K,ck=Ss,uk=Av,Tv=function(t){if(typeof t<"u"&&!ck(t))throw new lk("Assertion failed: `Desc` must be a Property Descriptor");return uk(t)},hk=K,wf=Lr,dk=Ss,$v=function(t){if(typeof t>"u")return!1;if(!dk(t))throw new hk("Assertion failed: `Desc` must be a Property Descriptor");return!(!wf(t,"[[Value]]")&&!wf(t,"[[Writable]]"))},_s=function(t){return typeof t=="string"||typeof t=="symbol"},Sf=_d,Iv=function(t,e){return t===e?t===0?1/t===1/e:!0:Sf(t)&&Sf(e)},_f=K,pk=Pr,fk=Td,gk=Tv,mk=$v,vk=_s,yk=Iv,$d=function(t,e,n){if(!pk(t))throw new _f("Assertion failed: Type(O) is not Object");if(!vk(e))throw new _f("Assertion failed: P is not a Property Key");var i={"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Value]]":n,"[[Writable]]":!0};return fk(mk,yk,gk,t,e,i)},Cv=Function.prototype.toString,Ci=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,eh,pl;if(typeof Ci=="function"&&typeof Object.defineProperty=="function")try{eh=Object.defineProperty({},"length",{get:function(){throw pl}}),pl={},Ci(function(){throw 42},null,eh)}catch(r){r!==pl&&(Ci=null)}else Ci=null;var bk=/^\s*class\b/,th=function(t){try{var e=Cv.call(t);return bk.test(e)}catch{return!1}},lu=function(t){try{return th(t)?!1:(Cv.call(t),!0)}catch{return!1}},fl=Object.prototype.toString,wk="[object Object]",Sk="[object Function]",_k="[object GeneratorFunction]",kk="[object HTMLAllCollection]",xk="[object HTML document.all class]",Ek="[object HTMLCollection]",Ak=typeof Symbol=="function"&&!!Symbol.toStringTag,Tk=!(0 in[,]),rh=function(){return!1};if(typeof document=="object"){var $k=document.all;fl.call($k)===fl.call(document.all)&&(rh=function(t){if((Tk||!t)&&(typeof t>"u"||typeof t=="object"))try{var e=fl.call(t);return(e===kk||e===xk||e===Ek||e===wk)&&t("")==null}catch{}return!1})}var Rv=Ci?function(t){if(rh(t))return!0;if(!t||typeof t!="function"&&typeof t!="object")return!1;try{Ci(t,null,eh)}catch(e){if(e!==pl)return!1}return!th(t)&&lu(t)}:function(t){if(rh(t))return!0;if(!t||typeof t!="function"&&typeof t!="object")return!1;if(Ak)return lu(t);if(th(t))return!1;var e=fl.call(t);return e!==Sk&&e!==_k&&!/^\[object HTML/.test(e)?!1:lu(t)},Ik=Rv,Ck=function(t){return!!t},Zt=Lr,Ba=K,Rk=Pr,kf=Ik,cu=Ck,Pk=function(t){if(!Rk(t))throw new Ba("ToPropertyDescriptor requires an object");var e={};if(Zt(t,"enumerable")&&(e["[[Enumerable]]"]=cu(t.enumerable)),Zt(t,"configurable")&&(e["[[Configurable]]"]=cu(t.configurable)),Zt(t,"value")&&(e["[[Value]]"]=t.value),Zt(t,"writable")&&(e["[[Writable]]"]=cu(t.writable)),Zt(t,"get")){var n=t.get;if(typeof n<"u"&&!kf(n))throw new Ba("getter must be a function");e["[[Get]]"]=n}if(Zt(t,"set")){var i=t.set;if(typeof i<"u"&&!kf(i))throw new Ba("setter must be a function");e["[[Set]]"]=i}if((Zt(e,"[[Get]]")||Zt(e,"[[Set]]"))&&(Zt(e,"[[Value]]")||Zt(e,"[[Writable]]")))throw new Ba("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute");return e},uu=K,Lk=Pr,xf=Ss,Dk=Td,zk=Tv,Ok=$v,Mk=_s,Nk=Iv,Uk=Pk,Fk=function(t,e,n){if(!Lk(t))throw new uu("Assertion failed: Type(O) is not Object");if(!Mk(e))throw new uu("Assertion failed: P is not a Property Key");var i=xf(n)?n:Uk(n);if(!xf(i))throw new uu("Assertion failed: Desc is not a valid Property Descriptor");return Dk(Ok,Nk,zk,t,e,i)},Ef=K,Hk=Pr,Zk=Fk,Wk=_s,Bk=function(t,e,n){if(!Hk(t))throw new Ef("Assertion failed: Type(O) is not Object");if(!Wk(e))throw new Ef("Assertion failed: P is not a Property Key");var i={"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Value]]":n,"[[Writable]]":!0};return Zk(t,e,i)},Vk=typeof Reflect<"u"&&Reflect.setPrototypeOf||null,jk=wd,Gk=jk.setPrototypeOf||null,qk=wc,Af=bs,Yk=K,Pv={};try{Pv.__proto__=null}catch(r){if(!r||typeof r!="object"||!("code"in r)||r.code!=="ERR_PROTO_ACCESS")throw r}var Kk=!("toString"in Pv),hu=Af&&Af(Object.prototype,"__proto__"),Jk=Kk&&(!!hu&&typeof hu.set=="function"&&qk([hu.set])||function(t,e){if(t==null)throw new Yk("set Object.prototype.__proto__ called on null or undefined");return t.__proto__=e,e}),Tf=Vk,Xk=Gk,$f=Jk,Qk=K,ex=Tf?function(t,e){if(Tf(t,e))return t;throw new Qk("Reflect.setPrototypeOf: failed to set [[Prototype]]")}:Xk||($f?function(t,e){return $f(t,e),t}:null),If=K,tx=Pr,Cf=_v,rx=function(t){if(!tx(t))throw new If("Assertion failed: O must be an Object");if(!Cf)throw new If("This environment does not support fetching prototypes.");return Cf(t)},nx=K,ix=ex,sx=Pr,ox=rx,ax=function(t,e){if(e!==null&&!sx(e))throw new nx("Assertion failed: V must be Object or Null");try{ix(t,e)}catch{return!1}return ox(t)===e},du=$d,Rf=Bk,Lv=ax,lx=bc(),Id=mv;function Ea(r,t,e){var n=new Id(e);return Lv(n,gl),delete n.constructor,Rf(n,"error",r),Rf(n,"suppressed",t),n}lx&&Object.defineProperty(Ea,"prototype",{writable:!1});var gl=Ea.prototype;if(!du(gl,"constructor",Ea)||!du(gl,"message","")||!du(gl,"name","SuppressedError"))throw new Id("unable to install SuppressedError.prototype properties; please report this!");Lv(Ea.prototype,Id.prototype);var cx=Ea,ux=cx,Dv=function(){return typeof SuppressedError=="function"?SuppressedError:ux},hx=ii,Pf=bd(),dx=Dv,px=function(){var t=dx();return hx(Pf,{SuppressedError:t},{SuppressedError:function(){return Pf.SuppressedError!==t}}),t};px();var fx=K,gx=Ss,mx=Av,vx=function(t){if(typeof t<"u"&&!gx(t))throw new fx("Assertion failed: `Desc` must be a Property Descriptor");return mx(t)},yx=K,Lf=Lr,bx=Ss,wx=function(t){if(typeof t>"u")return!1;if(!bx(t))throw new yx("Assertion failed: `Desc` must be a Property Descriptor");return!(!Lf(t,"[[Value]]")&&!Lf(t,"[[Writable]]"))},Df=_d,Sx=function(t,e){return t===e?t===0?1/t===1/e:!0:Df(t)&&Df(e)},ks=Rv,_x=function(t){return!!t},Wt=Lr,Va=K,kx=Pr,zf=ks,pu=_x,xx=function(t){if(!kx(t))throw new Va("ToPropertyDescriptor requires an object");var e={};if(Wt(t,"enumerable")&&(e["[[Enumerable]]"]=pu(t.enumerable)),Wt(t,"configurable")&&(e["[[Configurable]]"]=pu(t.configurable)),Wt(t,"value")&&(e["[[Value]]"]=t.value),Wt(t,"writable")&&(e["[[Writable]]"]=pu(t.writable)),Wt(t,"get")){var n=t.get;if(typeof n<"u"&&!zf(n))throw new Va("getter must be a function");e["[[Get]]"]=n}if(Wt(t,"set")){var i=t.set;if(typeof i<"u"&&!zf(i))throw new Va("setter must be a function");e["[[Set]]"]=i}if((Wt(e,"[[Get]]")||Wt(e,"[[Set]]"))&&(Wt(e,"[[Value]]")||Wt(e,"[[Writable]]")))throw new Va("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute");return e},fu=K,Ex=Pr,Of=Ss,Ax=Td,Tx=vx,$x=wx,Ix=_s,Cx=Sx,Rx=xx,Aa=function(t,e,n){if(!Ex(t))throw new fu("Assertion failed: Type(O) is not Object");if(!Ix(e))throw new fu("Assertion failed: P is not a Property Key");var i=Of(n)?n:Rx(n);if(!Of(i))throw new fu("Assertion failed: Desc is not a valid Property Descriptor");return Ax($x,Cx,Tx,t,e,i)},Px=ws(),Lx=Px?Symbol.dispose||Symbol("Symbol.dispose"):null,Dx=ws,zx=Lx,Cd=function(){return Dx()&&Symbol.dispose||zx},Ox=kd,Mx=Aa,Nx=Cd,Ux=function(){var t=Nx();return Ox()&&Mx(Symbol,"dispose",{"[[Configurable]]":!1,"[[Enumerable]]":!1,"[[Writable]]":!1,"[[Value]]":t}),t},Fx=ws(),Hx=Fx?Symbol.asyncDispose||Symbol("Symbol.asyncDispose"):null,Zx=ws,Wx=Hx,Rd=function(){return Zx()&&Symbol.asyncDispose||Wx},Bx=kd,Vx=Aa,jx=Rd,Gx=function(){var t=jx();return Bx()&&Vx(Symbol,"asyncDispose",{"[[Configurable]]":!1,"[[Enumerable]]":!1,"[[Writable]]":!1,"[[Value]]":t}),t},qx=Ad(),Yx=xt,Kx=an(),Jx=K,Xx=qx,Qx=Yx("%Reflect.apply%",!0)||Kx("Function.prototype.apply"),Sc=function(t,e){var n=arguments.length>2?arguments[2]:[];if(!Xx(n))throw new Jx("Assertion failed: optional `argumentsList`, if provided, must be a List");return Qx(t,e,n)};const eE={},tE=Object.freeze(Object.defineProperty({__proto__:null,default:eE},Symbol.toStringTag,{value:"Module"})),rE=AS(tE);var Pd=typeof Map=="function"&&Map.prototype,gu=Object.getOwnPropertyDescriptor&&Pd?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,Nl=Pd&&gu&&typeof gu.get=="function"?gu.get:null,Mf=Pd&&Map.prototype.forEach,Ld=typeof Set=="function"&&Set.prototype,mu=Object.getOwnPropertyDescriptor&&Ld?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,Ul=Ld&&mu&&typeof mu.get=="function"?mu.get:null,Nf=Ld&&Set.prototype.forEach,nE=typeof WeakMap=="function"&&WeakMap.prototype,io=nE?WeakMap.prototype.has:null,iE=typeof WeakSet=="function"&&WeakSet.prototype,so=iE?WeakSet.prototype.has:null,sE=typeof WeakRef=="function"&&WeakRef.prototype,Uf=sE?WeakRef.prototype.deref:null,oE=Boolean.prototype.valueOf,aE=Object.prototype.toString,lE=Function.prototype.toString,cE=String.prototype.match,Dd=String.prototype.slice,Xr=String.prototype.replace,uE=String.prototype.toUpperCase,Ff=String.prototype.toLowerCase,zv=RegExp.prototype.test,Hf=Array.prototype.concat,lr=Array.prototype.join,hE=Array.prototype.slice,Zf=Math.floor,nh=typeof BigInt=="function"?BigInt.prototype.valueOf:null,vu=Object.getOwnPropertySymbols,ih=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,ps=typeof Symbol=="function"&&typeof Symbol.iterator=="object",oo=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===ps||!0)?Symbol.toStringTag:null,Ov=Object.prototype.propertyIsEnumerable,Wf=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(r){return r.__proto__}:null);function Bf(r,t){if(r===1/0||r===-1/0||r!==r||r&&r>-1e3&&r<1e3||zv.call(/e/,t))return t;var e=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof r=="number"){var n=r<0?-Zf(-r):Zf(r);if(n!==r){var i=String(n),s=Dd.call(t,i.length+1);return Xr.call(i,e,"$&_")+"."+Xr.call(Xr.call(s,/([0-9]{3})/g,"$&_"),/_$/,"")}}return Xr.call(t,e,"$&_")}var sh=rE,Vf=sh.custom,jf=Uv(Vf)?Vf:null,Mv={__proto__:null,double:'"',single:"'"},dE={__proto__:null,double:/(["\\])/g,single:/(['\\])/g},xs=function r(t,e,n,i){var s=e||{};if(wr(s,"quoteStyle")&&!wr(Mv,s.quoteStyle))throw new TypeError('option "quoteStyle" must be "single" or "double"');if(wr(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=wr(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(wr(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(wr(s,"numericSeparator")&&typeof s.numericSeparator!="boolean")throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var a=s.numericSeparator;if(typeof t>"u")return"undefined";if(t===null)return"null";if(typeof t=="boolean")return t?"true":"false";if(typeof t=="string")return Hv(t,s);if(typeof t=="number"){if(t===0)return 1/0/t>0?"0":"-0";var c=String(t);return a?Bf(t,c):c}if(typeof t=="bigint"){var u=String(t)+"n";return a?Bf(t,u):u}var h=typeof s.depth>"u"?5:s.depth;if(typeof n>"u"&&(n=0),n>=h&&h>0&&typeof t=="object")return oh(t)?"[Array]":"[Object]";var f=CE(s,n);if(typeof i>"u")i=[];else if(Fv(i,t)>=0)return"[Circular]";function y(Ut,Dr,Hc){if(Dr&&(i=hE.call(i),i.push(Dr)),Hc){var za={depth:s.depth};return wr(s,"quoteStyle")&&(za.quoteStyle=s.quoteStyle),r(Ut,za,n+1,i)}return r(Ut,s,n+1,i)}if(typeof t=="function"&&!Gf(t)){var m=SE(t),E=ja(t,y);return"[Function"+(m?": "+m:" (anonymous)")+"]"+(E.length>0?" { "+lr.call(E,", ")+" }":"")}if(Uv(t)){var x=ps?Xr.call(String(t),/^(Symbol\(.*\))_[^)]*$/,"$1"):ih.call(t);return typeof t=="object"&&!ps?zs(x):x}if(TE(t)){for(var I="<"+Ff.call(String(t.nodeName)),P=t.attributes||[],R=0;R<P.length;R++)I+=" "+P[R].name+"="+Nv(pE(P[R].value),"double",s);return I+=">",t.childNodes&&t.childNodes.length&&(I+="..."),I+="</"+Ff.call(String(t.nodeName))+">",I}if(oh(t)){if(t.length===0)return"[]";var B=ja(t,y);return f&&!IE(B)?"["+ah(B,f)+"]":"[ "+lr.call(B,", ")+" ]"}if(gE(t)){var N=ja(t,y);return!("cause"in Error.prototype)&&"cause"in t&&!Ov.call(t,"cause")?"{ ["+String(t)+"] "+lr.call(Hf.call("[cause]: "+y(t.cause),N),", ")+" }":N.length===0?"["+String(t)+"]":"{ ["+String(t)+"] "+lr.call(N,", ")+" }"}if(typeof t=="object"&&o){if(jf&&typeof t[jf]=="function"&&sh)return sh(t,{depth:h-n});if(o!=="symbol"&&typeof t.inspect=="function")return t.inspect()}if(_E(t)){var F=[];return Mf&&Mf.call(t,function(Ut,Dr){F.push(y(Dr,t,!0)+" => "+y(Ut,t))}),qf("Map",Nl.call(t),F,f)}if(EE(t)){var Y=[];return Nf&&Nf.call(t,function(Ut){Y.push(y(Ut,t))}),qf("Set",Ul.call(t),Y,f)}if(kE(t))return yu("WeakMap");if(AE(t))return yu("WeakSet");if(xE(t))return yu("WeakRef");if(vE(t))return zs(y(Number(t)));if(bE(t))return zs(y(nh.call(t)));if(yE(t))return zs(oE.call(t));if(mE(t))return zs(y(String(t)));if(typeof window<"u"&&t===window)return"{ [object Window] }";if(typeof globalThis<"u"&&t===globalThis||typeof _n<"u"&&t===_n)return"{ [object globalThis] }";if(!fE(t)&&!Gf(t)){var j=ja(t,y),ce=Wf?Wf(t)===Object.prototype:t instanceof Object||t.constructor===Object,At=t instanceof Object?"":"null prototype",hn=!ce&&oo&&Object(t)===t&&oo in t?Dd.call(ln(t),8,-1):At?"Object":"",ze=ce||typeof t.constructor!="function"?"":t.constructor.name?t.constructor.name+" ":"",dn=ze+(hn||At?"["+lr.call(Hf.call([],hn||[],At||[]),": ")+"] ":"");return j.length===0?dn+"{}":f?dn+"{"+ah(j,f)+"}":dn+"{ "+lr.call(j,", ")+" }"}return String(t)};function Nv(r,t,e){var n=e.quoteStyle||t,i=Mv[n];return i+r+i}function pE(r){return Xr.call(String(r),/"/g,""")}function si(r){return!oo||!(typeof r=="object"&&(oo in r||typeof r[oo]<"u"))}function oh(r){return ln(r)==="[object Array]"&&si(r)}function fE(r){return ln(r)==="[object Date]"&&si(r)}function Gf(r){return ln(r)==="[object RegExp]"&&si(r)}function gE(r){return ln(r)==="[object Error]"&&si(r)}function mE(r){return ln(r)==="[object String]"&&si(r)}function vE(r){return ln(r)==="[object Number]"&&si(r)}function yE(r){return ln(r)==="[object Boolean]"&&si(r)}function Uv(r){if(ps)return r&&typeof r=="object"&&r instanceof Symbol;if(typeof r=="symbol")return!0;if(!r||typeof r!="object"||!ih)return!1;try{return ih.call(r),!0}catch{}return!1}function bE(r){if(!r||typeof r!="object"||!nh)return!1;try{return nh.call(r),!0}catch{}return!1}var wE=Object.prototype.hasOwnProperty||function(r){return r in this};function wr(r,t){return wE.call(r,t)}function ln(r){return aE.call(r)}function SE(r){if(r.name)return r.name;var t=cE.call(lE.call(r),/^function\s*([\w$]+)/);return t?t[1]:null}function Fv(r,t){if(r.indexOf)return r.indexOf(t);for(var e=0,n=r.length;e<n;e++)if(r[e]===t)return e;return-1}function _E(r){if(!Nl||!r||typeof r!="object")return!1;try{Nl.call(r);try{Ul.call(r)}catch{return!0}return r instanceof Map}catch{}return!1}function kE(r){if(!io||!r||typeof r!="object")return!1;try{io.call(r,io);try{so.call(r,so)}catch{return!0}return r instanceof WeakMap}catch{}return!1}function xE(r){if(!Uf||!r||typeof r!="object")return!1;try{return Uf.call(r),!0}catch{}return!1}function EE(r){if(!Ul||!r||typeof r!="object")return!1;try{Ul.call(r);try{Nl.call(r)}catch{return!0}return r instanceof Set}catch{}return!1}function AE(r){if(!so||!r||typeof r!="object")return!1;try{so.call(r,so);try{io.call(r,io)}catch{return!0}return r instanceof WeakSet}catch{}return!1}function TE(r){return!r||typeof r!="object"?!1:typeof HTMLElement<"u"&&r instanceof HTMLElement?!0:typeof r.nodeName=="string"&&typeof r.getAttribute=="function"}function Hv(r,t){if(r.length>t.maxStringLength){var e=r.length-t.maxStringLength,n="... "+e+" more character"+(e>1?"s":"");return Hv(Dd.call(r,0,t.maxStringLength),t)+n}var i=dE[t.quoteStyle||"single"];i.lastIndex=0;var s=Xr.call(Xr.call(r,i,"\\$1"),/[\x00-\x1f]/g,$E);return Nv(s,"single",t)}function $E(r){var t=r.charCodeAt(0),e={8:"b",9:"t",10:"n",12:"f",13:"r"}[t];return e?"\\"+e:"\\x"+(t<16?"0":"")+uE.call(t.toString(16))}function zs(r){return"Object("+r+")"}function yu(r){return r+" { ? }"}function qf(r,t,e,n){var i=n?ah(e,n):lr.call(e,", ");return r+" ("+t+") {"+i+"}"}function IE(r){for(var t=0;t<r.length;t++)if(Fv(r[t],`
|
|
2
|
-
`)>=0)return!1;return!0}function CE(r,t){var e;if(r.indent===" ")e=" ";else if(typeof r.indent=="number"&&r.indent>0)e=lr.call(Array(r.indent+1)," ");else return null;return{base:e,prev:lr.call(Array(t+1),e)}}function ah(r,t){if(r.length===0)return"";var e=`
|
|
3
|
-
`+t.prev+t.base;return e+lr.call(r,","+e)+`
|
|
4
|
-
`+t.prev}function ja(r,t){var e=oh(r),n=[];if(e){n.length=r.length;for(var i=0;i<r.length;i++)n[i]=wr(r,i)?t(r[i],r):""}var s=typeof vu=="function"?vu(r):[],o;if(ps){o={};for(var a=0;a<s.length;a++)o["$"+s[a]]=s[a]}for(var c in r)wr(r,c)&&(e&&String(Number(c))===c&&c<r.length||ps&&o["$"+c]instanceof Symbol||(zv.call(/[^\w$]/,c)?n.push(t(c,r)+": "+t(r[c],r)):n.push(c+": "+t(r[c],r))));if(typeof vu=="function")for(var u=0;u<s.length;u++)Ov.call(r,s[u])&&n.push("["+t(s[u])+"]: "+t(r[s[u]],r));return n}var RE=xs,PE=K,_c=function(r,t,e){for(var n=r,i;(i=n.next)!=null;n=i)if(i.key===t)return n.next=i.next,e||(i.next=r.next,r.next=i),i},LE=function(r,t){if(r){var e=_c(r,t);return e&&e.value}},DE=function(r,t,e){var n=_c(r,t);n?n.value=e:r.next={key:t,next:r.next,value:e}},zE=function(r,t){return r?!!_c(r,t):!1},OE=function(r,t){if(r)return _c(r,t,!0)},ME=function(){var t,e={assert:function(n){if(!e.has(n))throw new PE("Side channel does not contain "+RE(n))},delete:function(n){var i=t&&t.next,s=OE(t,n);return s&&i&&i===s&&(t=void 0),!!s},get:function(n){return LE(t,n)},has:function(n){return zE(t,n)},set:function(n,i){t||(t={next:void 0}),DE(t,n,i)}};return e},NE=xt,Ta=an(),UE=xs,FE=K,Yf=NE("%Map%",!0),HE=Ta("Map.prototype.get",!0),ZE=Ta("Map.prototype.set",!0),WE=Ta("Map.prototype.has",!0),BE=Ta("Map.prototype.delete",!0),VE=Ta("Map.prototype.size",!0),Zv=!!Yf&&function(){var t,e={assert:function(n){if(!e.has(n))throw new FE("Side channel does not contain "+UE(n))},delete:function(n){if(t){var i=BE(t,n);return VE(t)===0&&(t=void 0),i}return!1},get:function(n){if(t)return HE(t,n)},has:function(n){return t?WE(t,n):!1},set:function(n,i){t||(t=new Yf),ZE(t,n,i)}};return e},jE=xt,kc=an(),GE=xs,Ga=Zv,qE=K,mi=jE("%WeakMap%",!0),YE=kc("WeakMap.prototype.get",!0),KE=kc("WeakMap.prototype.set",!0),JE=kc("WeakMap.prototype.has",!0),XE=kc("WeakMap.prototype.delete",!0),QE=mi?function(){var t,e,n={assert:function(i){if(!n.has(i))throw new qE("Side channel does not contain "+GE(i))},delete:function(i){if(mi&&i&&(typeof i=="object"||typeof i=="function")){if(t)return XE(t,i)}else if(Ga&&e)return e.delete(i);return!1},get:function(i){return mi&&i&&(typeof i=="object"||typeof i=="function")&&t?YE(t,i):e&&e.get(i)},has:function(i){return mi&&i&&(typeof i=="object"||typeof i=="function")&&t?JE(t,i):!!e&&e.has(i)},set:function(i,s){mi&&i&&(typeof i=="object"||typeof i=="function")?(t||(t=new mi),KE(t,i,s)):Ga&&(e||(e=Ga()),e.set(i,s))}};return n}:Ga,eA=K,tA=xs,rA=ME,nA=Zv,iA=QE,sA=iA||nA||rA,oA=function(){var t,e={assert:function(n){if(!e.has(n))throw new eA("Side channel does not contain "+tA(n))},delete:function(n){return!!t&&t.delete(n)},get:function(n){return t&&t.get(n)},has:function(n){return!!t&&t.has(n)},set:function(n,i){t||(t=sA()),t.set(n,i)}};return e},aA=Lr,Os=oA(),gr=K,zd={assert:function(r,t){if(!r||typeof r!="object"&&typeof r!="function")throw new gr("`O` is not an object");if(typeof t!="string")throw new gr("`slot` must be a string");if(Os.assert(r),!zd.has(r,t))throw new gr("`"+t+"` is not present on `O`")},get:function(r,t){if(!r||typeof r!="object"&&typeof r!="function")throw new gr("`O` is not an object");if(typeof t!="string")throw new gr("`slot` must be a string");var e=Os.get(r);return e&&e["$"+t]},has:function(r,t){if(!r||typeof r!="object"&&typeof r!="function")throw new gr("`O` is not an object");if(typeof t!="string")throw new gr("`slot` must be a string");var e=Os.get(r);return!!e&&aA(e,"$"+t)},set:function(r,t,e){if(!r||typeof r!="object"&&typeof r!="function")throw new gr("`O` is not an object");if(typeof t!="string")throw new gr("`slot` must be a string");var n=Os.get(r);n||(n={},Os.set(r,n)),n["$"+t]=e}};Object.freeze&&Object.freeze(zd);var Od=zd,Wv=Rr,en=Od,$a=function r(t,e){if(!(this instanceof r))return new r(t,e);if(t!=="normal"&&t!=="break"&&t!=="continue"&&t!=="return"&&t!=="throw")throw new Wv('Assertion failed: `type` must be one of "normal", "break", "continue", "return", or "throw"');en.set(this,"[[Type]]",t),en.set(this,"[[Value]]",e)};$a.prototype.type=function(){return en.get(this,"[[Type]]")};$a.prototype.value=function(){return en.get(this,"[[Value]]")};$a.prototype["?"]=function(){var t=en.get(this,"[[Type]]"),e=en.get(this,"[[Value]]");if(t==="throw")throw e;return e};$a.prototype["!"]=function(){var t=en.get(this,"[[Type]]");if(t!=="normal")throw new Wv('Assertion failed: Completion Record is not of type "normal"');return en.get(this,"[[Value]]")};var Md=$a,lA=Md,Nd=function(t){return new lA("normal",t)},bu,Kf;function cA(){if(Kf)return bu;Kf=1;var r=ws;return bu=function(){return r()&&!!Symbol.toStringTag},bu}var uA=xt,Jf=uA("%Object.defineProperty%",!0),hA=cA()(),dA=Lr,pA=K,qa=hA?Symbol.toStringTag:null,Bv=function(t,e){var n=arguments.length>2&&!!arguments[2]&&arguments[2].force,i=arguments.length>2&&!!arguments[2]&&arguments[2].nonConfigurable;if(typeof n<"u"&&typeof n!="boolean"||typeof i<"u"&&typeof i!="boolean")throw new pA("if provided, the `overrideIfSet` and `nonConfigurable` options must be booleans");qa&&(n||!dA(t,qa))&&(Jf?Jf(t,qa,{configurable:!i,enumerable:!1,value:e,writable:!1}):t[qa]=e)},Vv={exports:{}},fA=xt,Xf=lv,gA=bc(),Qf=bs,eg=K,mA=fA("%Math.floor%"),vA=function(t,e){if(typeof t!="function")throw new eg("`fn` is not a function");if(typeof e!="number"||e<0||e>4294967295||mA(e)!==e)throw new eg("`length` must be a positive 32-bit integer");var n=arguments.length>2&&!!arguments[2],i=!0,s=!0;if("length"in t&&Qf){var o=Qf(t,"length");o&&!o.configurable&&(i=!1),o&&!o.writable&&(s=!1)}return(i||s||!n)&&(gA?Xf(t,"length",e,!0,!0):Xf(t,"length",e)),t},yA=_a,bA=Ed,wA=bv,SA=function(){return wA(yA,bA,arguments)};(function(r){var t=vA,e=Sa,n=wc,i=SA;r.exports=function(o){var a=n(arguments),c=1+o.length-(arguments.length-1);return t(a,c>0?c:0,!0)},e?e(r.exports,"apply",{value:i}):r.exports.apply=i})(Vv);var Ud=Vv.exports,_A=function(t,e){for(var n=0;n<t.length;n+=1)if(!e(t[n],n,t))return!1;return!0},kA=Object,xA=function(t){return t&&typeof t=="object"&&(typeof t["[[ResourceValue]]"]>"u"||kA(t["[[ResourceValue]]"])===t["[[ResourceValue]]"])&&(t["[[Hint]]"]==="SYNC-DISPOSE"||t["[[Hint]]"]==="ASYNC-DISPOSE")&&(typeof t["[[DisposeMethod]]"]=="function"||typeof t["[[DisposeMethod]]"]>"u")},EA=Lr,AA=Ad(),TA=_A,$A=xA,IA=function(t){return t&&typeof t=="object"&&EA(t,"[[DisposableResourceStack]]")&&AA(t["[[DisposableResourceStack]]"])&&(t["[[DisposableResourceStack]]"].length===0||TA(t["[[DisposableResourceStack]]"],$A))},CA=Pr,RA=function(t){if(t===null)return"Null";if(typeof t>"u")return"Undefined";if(CA(t))return"Object";if(typeof t=="number")return"Number";if(typeof t=="boolean")return"Boolean";if(typeof t=="string")return"String"},PA=RA,Fd=function(t){return typeof t=="symbol"?"Symbol":typeof t=="bigint"?"BigInt":PA(t)},LA=K,DA=xs,zA=_s,OA=function(t,e){if(!zA(e))throw new LA("Assertion failed: P is not a Property Key, got "+DA(e));return t[e]},tg=K,MA=OA,NA=ks,UA=_s,rg=xs,FA=function(t,e){if(!UA(e))throw new tg("Assertion failed: P is not a Property Key");var n=MA(t,e);if(n!=null){if(!NA(n))throw new tg(rg(e)+" is not a function: "+rg(n));return n}},lh={exports:{}},HA=xt,ZA=HA,ng=ZA("%Reflect.construct%",!0),Fl=Aa;try{Fl({},"",{"[[Get]]":function(){}})}catch{Fl=null}if(Fl&&ng){var ig={},sg={};Fl(sg,"length",{"[[Get]]":function(){throw ig},"[[Enumerable]]":!0}),lh.exports=function(t){try{ng(t,sg)}catch(e){return e===ig}}}else lh.exports=function(t){return typeof t=="function"&&!!t.prototype};var WA=lh.exports,wu=K,og=ks,BA=WA,VA=function(t){if(!BA(t))throw new wu("C must be a constructor");var e={"[[Resolve]]":void 0,"[[Reject]]":void 0},n=new t(function(i,s){if(typeof e["[[Resolve]]"]<"u"||typeof e["[[Reject]]"]<"u")throw new wu("executor has already been called");e["[[Resolve]]"]=i,e["[[Reject]]"]=s});if(!og(e["[[Resolve]]"])||!og(e["[[Reject]]"]))throw new wu("executor must provide valid resolve and reject functions");return{"[[Promise]]":n,"[[Resolve]]":e["[[Resolve]]"],"[[Reject]]":e["[[Reject]]"]}},ag=Rr,jA=K,Su=Sc,lg=FA,GA=VA,qA=Fd,cg=Cd(),ug=Rd(),YA=function(t,e){if(qA(t)!=="Object")throw new jA("`V` must be an Object");if(e!=="SYNC-DISPOSE"&&e!=="ASYNC-DISPOSE")throw new ag("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");var n;if(e==="ASYNC-DISPOSE"&&ug&&(n=lg(t,ug)),!n){if(!cg)throw new ag("`Symbol.dispose` is not supported");if(n=lg(t,cg),typeof n<"u")return function(){var i=this;if(e==="ASYNC-DISPOSE"){var s=GA(Promise);try{Su(n,i),Su(s["[[Resolve]]"],void 0,[void 0])}catch(o){s["[[Reject]]"](o)}return s["[[Promise]]"]}Su(n,i)}}return n},KA=Rr,_u=K,JA=ks,XA=Fd,QA=YA,e1=function(t,e){if(e!=="SYNC-DISPOSE"&&e!=="ASYNC-DISPOSE")throw new KA("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");var n;if(arguments.length<3)if(t==null)t=void 0,n=void 0;else{if(typeof t<"u"&&XA(t)!=="Object")throw new _u("`V` must be an Object, or `null` or `undefined`");if(n=QA(t,e),typeof n>"u")throw new _u("dispose method must not be `undefined` on `V` when an object `V` is provided")}else if(n=arguments[2],!JA(n))throw new _u("`method`, when provided, must be a function");return{"[[ResourceValue]]":t,"[[Hint]]":e,"[[DisposeMethod]]":n}},t1=Rr,Ya=K,r1=IA,hg=e1,n1=an(),i1=n1("Array.prototype.push"),jv=function(t,e,n){if(!r1(t))throw new Ya("Assertion failed: `disposeCapability` must be a DisposeCapability Record");if(n!=="SYNC-DISPOSE"&&n!=="ASYNC-DISPOSE")throw new t1("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 Ya("Assertion failed: `method`, when present, must be a function");if(!t["[[DisposableResourceStack]]"])throw new Ya("Assertion failed: `disposeCapability.[[DisposableResourceStack]]` must not be ~EMPTY~");var s;if(arguments.length<4){if(e==null&&n==="SYNC_DISPOSE")return"UNUSED";s=hg(e,n)}else{if(typeof e<"u")throw new Ya("Assertion failed: `V` must be undefined when `method` is present");s=hg(void 0,n,i)}return i1(t["[[DisposableResourceStack]]"],s),"UNUSED"},ku,dg;function Hd(){if(dg)return ku;dg=1;var r=xt,t=Ud,e=Rr,n=r("%Promise.resolve%",!0),i=n&&t(n);return ku=function(o,a){if(!i)throw new e("This environment does not support Promises.");return i(o,a)},ku}var xu,pg;function s1(){if(pg)return xu;pg=1;var r=xt,t=Rr,e=r("%Promise%",!0),n=Sc,i=Hd(),s=Fd;return xu=function(a,c,u){if(typeof a<"u"&&s(a)!=="Object")throw new t("Assertion failed: `V` must be `undefined` or an Object");if(c!=="SYNC-DISPOSE"&&c!=="ASYNC-DISPOSE")throw new t("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");if(typeof u<"u"&&typeof u!="function")throw new t("Assertion failed: `method` must be `undefined` or a function");var h=typeof u>"u"?u:n(u,a);if(c==="ASYNC-DISPOSE")return i(e,h)},xu}var Eu,fg;function o1(){if(fg)return Eu;fg=1;var r=Md;return Eu=function(e){return new r("throw",e)},Eu}var a1=xt,Au=Rr,gg=K,l1=a1("%Promise%",!0),c1=an(),mg=c1("Promise.prototype.then",!0),u1=Md,vg=s1(),h1=Nd,d1=Hd(),yg=o1(),p1=Dv(),Gv=function(t,e){if(!(e instanceof u1))throw new gg("`completion` must be a Completion Record");var n=t["[[DisposableResourceStack]]"];if(!n)throw new gg("Assertion failed: `disposeCapability.[[DisposableResourceStack]]` must not be ~EMPTY~");for(var i,s=n.length-1;s>=0;s-=1)if(!i)i=n[s]["[[Hint]]"];else if(i!==n[s]["[[Hint]]"])throw new Au("mixed hint stacks are not supported");for(var o=i==="ASYNC-DISPOSE"&&d1(l1,e),a=function(y){if(e.type()==="throw"){var m=e.value(),E=new p1(y,m);e=yg(E)}else e=yg(y)},c=i==="ASYNC-DISPOSE"&&function(m){return mg(o,function(){var E=vg(m["[[ResourceValue]]"],m["[[Hint]]"],m["[[DisposeMethod]]"]);if(!E)throw new Au("Assertion failed: non-`~ASYNC-DISPOSE~` resource returned a promise from Dispose");return mg(E,h1)},a)},u=n.length-1;u>=0;u-=1)if(i==="ASYNC-DISPOSE")o=c(n[u]);else{var h=n[u];try{var f=vg(h["[[ResourceValue]]"],h["[[Hint]]"],h["[[DisposeMethod]]"]);if(f)throw new Au("Assertion failed: `~SYNC-DISPOSE~` resource returned something from Dispose")}catch(y){a(y)}}return t["[[DisposableResourceStack]]"]=null,i==="ASYNC-DISPOSE"?o:e},qv=function(){var t=[];return{"[[DisposableResourceStack]]":t}},xc=Sd,Zd=K,f1=Sc,Es=$d,g1=Aa,Yv=ks,m1=Nd,at=Od,v1=Bv,Kv=ii.supportsDescriptors,y1=Ud,Wd=jv,b1=Gv,Jv=qv,bg=Cd(),wt=function r(){if(!(this instanceof r)||at.has(this,"[[DisposableState]]")||at.has(this,"[[DisposeCapability]]"))throw new Zd("can only be used with new");at.set(this,"[[DisposableState]]","PENDING"),at.set(this,"[[DisposeCapability]]",Jv())},Xv=function(){var t=this;return at.assert(t,"[[DisposableState]]"),at.get(t,"[[DisposableState]]")==="DISPOSED"},Ia=y1(Xv);Kv?g1(wt.prototype,"disposed",{"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Get]]":Xv}):wt.prototype.disposed=!1;var Qv=function(t){at.set(t,"[[DisposableState]]","DISPOSED"),Kv||(t.disposed=!0)};Es(wt.prototype,"dispose",function(){var t=this;if(!Ia(t))return Qv(t),b1(at.get(t,"[[DisposeCapability]]"),m1())["?"]()});Es(wt.prototype,"use",function(t){var e=this;if(Ia(e))throw new xc("a disposed stack can not use anything new");return Wd(at.get(e,"[[DisposeCapability]]"),t,"SYNC-DISPOSE"),t});Es(wt.prototype,"adopt",function(t,e){var n=this;if(Ia(n))throw new xc("a disposed stack can not use anything new");if(!Yv(e))throw new Zd("`onDispose` must be a function");var i=function(){return f1(e,void 0,[t])};return Wd(at.get(n,"[[DisposeCapability]]"),void 0,"SYNC-DISPOSE",i),t});Es(wt.prototype,"defer",function(t){var e=this;if(Ia(e))throw new xc("a disposed stack can not defer anything new");if(!Yv(t))throw new Zd("`onDispose` must be a function");Wd(at.get(e,"[[DisposeCapability]]"),void 0,"SYNC-DISPOSE",t)});Es(wt.prototype,"move",function(){var t=this;if(Ia(t))throw new xc("a disposed stack can not use anything new");var e=new wt;return at.set(e,"[[DisposeCapability]]",at.get(t,"[[DisposeCapability]]")),at.set(t,"[[DisposeCapability]]",Jv()),Qv(t),e});bg&&Es(wt.prototype,bg,wt.prototype.dispose);v1(wt.prototype,"DisposableStack");var w1=wt,S1=w1,_1=function(){return typeof DisposableStack=="function"?DisposableStack:S1},k1=ii,x1=bd(),E1=_1,A1=function(){var t=E1();return k1(x1,{DisposableStack:t},{DisposableStack:!0}),t},T1=xt,Ec=Sd,Bd=K,wg=T1("%Promise%",!0),Vd=jv,$1=Sc,As=$d,I1=Aa,C1=Gv,ey=ks,ty=qv,R1=Nd,Sg=Hd(),lt=Od,P1=Bv,ry=ii.supportsDescriptors,L1=Ud,D1=an(),z1=D1("Promise.prototype.then",!0),_g=Rd(),St=function r(){if(!(this instanceof r)||lt.has(this,"[[AsyncDisposableState]]")||lt.has(this,"[[DisposeCapability]]"))throw new Bd("can only be used with new");lt.set(this,"[[AsyncDisposableState]]","pending"),lt.set(this,"[[DisposeCapability]]",ty())},ny=function(){var t=this;return lt.assert(t,"[[AsyncDisposableState]]"),lt.get(t,"[[AsyncDisposableState]]")==="disposed"},Ca=L1(ny);ry?I1(St.prototype,"disposed",{"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Get]]":ny}):St.prototype.disposed=!1;var iy=function(t){lt.set(t,"[[AsyncDisposableState]]","disposed"),ry||(t.disposed=!0)};As(St.prototype,"disposeAsync",function(){var t=this;return Ca(t)?Sg(wg):(iy(t),z1(Sg(wg,C1(lt.get(t,"[[DisposeCapability]]"),R1())),function(e){return e["?"]()}))});As(St.prototype,"use",function(t){var e=this;if(Ca(e))throw new Ec("a disposed stack can not use anything new");return Vd(lt.get(e,"[[DisposeCapability]]"),t,"ASYNC-DISPOSE"),t});As(St.prototype,"adopt",function(t,e){var n=this;if(Ca(n))throw new Ec("a disposed stack can not use anything new");if(!ey(e))throw new Bd("`onDisposeAsync` must be a function");var i=function(){return $1(e,void 0,[t])};return i.value=t,Vd(lt.get(n,"[[DisposeCapability]]"),void 0,"ASYNC-DISPOSE",i),t});As(St.prototype,"defer",function(t){var e=this;if(Ca(e))throw new Ec("a disposed stack can not defer anything new");if(!ey(t))throw new Bd("`onDispose` must be a function");Vd(lt.get(e,"[[DisposeCapability]]"),void 0,"ASYNC-DISPOSE",t)});As(St.prototype,"move",function(){var t=this;if(Ca(t))throw new Ec("a disposed stack can not use anything new");var e=new St;return lt.set(e,"[[DisposeCapability]]",lt.get(t,"[[DisposeCapability]]")),lt.set(t,"[[DisposeCapability]]",ty()),iy(t),e});_g&&As(St.prototype,_g,St.prototype.disposeAsync);P1(St.prototype,"AsyncDisposableStack");var O1=St,M1=O1,N1=function(){return typeof AsyncDisposableStack=="function"?AsyncDisposableStack:M1},U1=ii,F1=bd(),H1=N1,Z1=function(){var t=H1();return U1(F1,{AsyncDisposableStack:t},{AsyncDisposableStack:!0}),t},W1=Ux,B1=Gx,V1=A1,j1=Z1,G1=function(){W1(),B1(),V1(),j1()};G1();const kg=new WeakMap;function q1(r){return(typeof r=="object"||typeof r=="function")&&r!==null&&"then"in r&&typeof r.then=="function"}function vi(r){return typeof r=="string"?r:typeof r=="symbol"?r.description??r.toString():r.name||"(anonymous class)"}function xg(){return new Error("register(Key, factory) requires a factory function. Wrap existing instances as () => instance.")}function Y1(){return new Error("register(Key, factory) does not accept async factories. Await setup before registering.")}class K1{constructor(){g(this,"entries",new Map);g(this,"constructionStack",[])}register(t,e){if(e===void 0){if(typeof t!="function")throw xg();this.validateClassRegistration(t),this.storeFactory(t,()=>this.instantiateClass(t));return}if(typeof e!="function")throw xg();if(e.constructor.name==="AsyncFunction")throw Y1();this.storeFactory(t,e)}has(t){var e;return((e=this.entries.get(t))==null?void 0:e.factory)!==void 0}resolve(t){return this.resolveAny(t)}storeFactory(t,e){const n=this.getOrCreateEntry(t);n.factory=e,n.instance=void 0,n.error=void 0}validateClassRegistration(t){const e=kg.get(t);if(e){if(t.length!==e.length)throw new Error(`${vi(t)} cannot be registered with register(Class). @injectable(...) declared ${e.length} dependencies but constructor arity is ${t.length}. Use register(Key, () => value) instead.`);return}if(t.length!==0)throw new Error(`${vi(t)} cannot be registered with register(Class). Undecorated classes must have zero required constructor parameters. Use register(Key, () => value) instead.`)}instantiateClass(t){const e=kg.get(t);if(!e)return new t;const n=e.map(i=>this.resolveAny(i));return new t(...n)}resolveAny(t){return this.getOrCreateEntry(t).proxy}getOrCreateEntry(t){let e=this.entries.get(t);return e||(e={key:t},e.proxy=this.createProxy(e),this.entries.set(t,e),e)}createProxy(t){return new Proxy({},{get:(e,n)=>{if(n==="then")return;const i=this.getInstance(t),s=Reflect.get(i,n,i);return typeof s=="function"?s.bind(i):s},set:(e,n,i)=>{const s=this.getInstance(t);return Reflect.set(s,n,i,s)},has:(e,n)=>{const i=this.getInstance(t);return n in i}})}getInstance(t){if(t.instance)return t.instance;if(t.error)throw t.error;if(!t.factory)throw new Error(`${vi(t.key)} was resolved but never registered`);const e=this.constructionStack.indexOf(t.key);if(e!==-1){const n=[...this.constructionStack.slice(e),t.key].map(i=>vi(i)).join(" -> ");throw new Error(`Circular dependency detected: ${n}`)}this.constructionStack.push(t.key);try{const n=t.factory();if(q1(n))throw new Error(`Factory for ${vi(t.key)} returned a Promise. Await setup before registering.`);if(typeof n!="object"||n===null)throw new Error(`Factory for ${vi(t.key)} returned a non-object value. Wrap primitives in an object.`);return t.instance=n,n}catch(n){throw t.error=n,n}finally{this.constructionStack.pop()}}}const hr=new K1,J1=.5,Eg=.1,Ag=8,X1=4,sy=3,oy=3,Q1=4,En=255,ay=.2126,ly=.7152,cy=.0722;async function uy(r){const t=eT(r);if(!t)return"light";try{return await nT(r,t)>=J1?"light":"dark"}catch{return"light"}}function eT(r){if(typeof document.elementsFromPoint!="function")return null;const t=r.getBoundingClientRect(),e=t.left+t.width/2,n=t.top+t.height/2,i=document.elementsFromPoint(e,n);for(const s of i){if(!(s instanceof HTMLElement)||s===r||r.contains(s))continue;const o=window.getComputedStyle(s);if(tT(o))return s}return null}function tT(r){return hy(r.backgroundImage)?!0:rT(r.backgroundColor)>0}function rT(r){if(!r)return 0;const t=r.match(/rgba?\(([^)]+)\)/);if(!t)return 0;const e=t[1].split(/[\s,/]+/).filter(Boolean);return e.length===Q1?parseFloat(e[sy]):e.length===oy?1:0}async function nT(r,t){const e=r.getBoundingClientRect(),n=t.getBoundingClientRect(),i={x:Ka((e.left-n.left)/n.width),y:Ka((e.top-n.top)/n.height),width:Ka(e.width/n.width),height:Ka(e.height/n.height)},s=window.getComputedStyle(t),o=hy(s.backgroundImage);return o?sT({url:o,surfaceWidth:n.width,surfaceHeight:n.height,region:i}):oT(s.backgroundColor)}function hy(r){const t=r.match(/url\(\s*["']?([^"')]+)["']?\s*\)/);return t?t[1]:null}const Tg=new Map;function iT(r){let t=Tg.get(r);return t||(t=new Promise((e,n)=>{const i=new Image;i.crossOrigin="anonymous",i.onload=()=>e(i),i.onerror=()=>n(new Error(`Failed to load ${r}`)),i.src=r}),Tg.set(r,t),t)}async function sT(r){const t=await iT(r.url),e=Math.max(Ag,Math.ceil(r.surfaceWidth*Eg)),n=Math.max(Ag,Math.ceil(r.surfaceHeight*Eg)),i=document.createElement("canvas");i.width=e,i.height=n;const s=i.getContext("2d",{willReadFrequently:!0});if(!s)return 1;const o=r.surfaceWidth/r.surfaceHeight,a=t.naturalWidth/t.naturalHeight;let c,u;a>o?(u=n,c=n*a):(c=e,u=e/a);const h=(e-c)/2,f=(n-u)/2;s.drawImage(t,h,f,c,u);const y=Math.max(0,Math.floor(r.region.x*e)),m=Math.max(0,Math.floor(r.region.y*n)),E=Math.max(1,Math.min(e-y,Math.floor(r.region.width*e))),x=Math.max(1,Math.min(n-m,Math.floor(r.region.height*n))),I=s.getImageData(y,m,E,x).data;let P=0,R=0;for(let B=0;B<I.length;B+=X1){const N=I[B]/En,F=I[B+1]/En,Y=I[B+2]/En,j=I[B+sy]/En;P+=j*(ay*N+ly*F+cy*Y),R+=1}return R>0?P/R:1}function oT(r){const t=r.match(/rgba?\(([^)]+)\)/);if(!t)return 1;const e=t[1].split(/[\s,/]+/).filter(Boolean).map(parseFloat);if(e.length<oy)return 1;const n=e[0]/En,i=e[1]/En,s=e[2]/En;return ay*n+ly*i+cy*s}function Ka(r){return r<0?0:r>1?1:r}const aT=["ghost","glass"],ho=[...aT.map(r=>`[variant="${r}"]`),'[material="glass"]'].join(", "),Ja=new WeakSet,$g=new WeakSet;function dy(r){if($g.has(r))return;$g.add(r);for(const e of r.querySelectorAll(ho))Tu(e);if(typeof MutationObserver!="function")return;new MutationObserver(e=>{for(const n of e)if(n.type==="childList")for(const i of n.addedNodes)lT(i,Tu);else n.type==="attributes"&&n.target instanceof HTMLElement&&n.target.matches(ho)&&Tu(n.target)}).observe(r,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["variant","material"]})}function lT(r,t){if(r instanceof Element){r instanceof HTMLElement&&r.matches(ho)&&t(r);for(const e of r.querySelectorAll(ho))t(e)}}async function Tu(r){var e,n;if(Ja.has(r)||r.hasAttribute("tone")||(e=r.parentElement)!=null&&e.closest("[tone]"))return;Ja.add(r);const t=await uy(r);if(!r.matches(ho)){Ja.delete(r);return}if(r.hasAttribute("tone")||(n=r.parentElement)!=null&&n.closest("[tone]")){Ja.delete(r);return}r.setAttribute("tone",t)}const cT="*,*:before,*:after{box-sizing:border-box}html,body{margin:0;padding:0}h1,h2,h3,h4,h5,h6,p,ul,ol,blockquote,pre,hr{margin:0}button,input,textarea,select{font:inherit;color:inherit}@font-face{font-family:Hind;src:url("+new URL("Hind-Variable-C47b_dt9.woff2",import.meta.url).href+') format("woff2-variations");font-weight:300 700;font-style:normal;font-display:swap}:root{--font-sans: "Hind", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;--font-brand: var(--font-sans);--font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, monospace;--font-weight-body: 500;--text-base: 13.5px;--text-scale: 1.125;--text-sm: round(calc(var(--text-base) / var(--text-scale)), 1px);--text-lg: round(calc(var(--text-base) * var(--text-scale)), 1px);--text-xl: round(calc(var(--text-lg) * var(--text-scale)), 1px);--leading-base: 1.5;--control-height-xs: 18px;--control-height-sm: 24px;--control-height-md: 28px;--control-height-lg: 32px;--space-2: 2px;--space-4: 4px;--space-6: 6px;--space-8: 8px;--space-10: 10px;--space-12: 12px;--space-16: 16px;--space-20: 20px;--space-24: 24px;--space-32: 32px;--space-48: 48px;--space-64: 64px;--radius-4: 4px;--radius-8: 8px;--radius-12: 12px;--radius-16: 16px;--radius-24: 24px;--radius-full: 9999px;--layer-chrome: 100;--layer-panel: 500;--layer-overlay: 2000;--shadow-hairline: 0 0 0 .5px var(--color-border);--shadow-control: 0 1px 1px rgb(0 0 0 / .04), 0 2px 6px rgb(0 0 0 / .06);--alpha-50: 4%;--alpha-100: 8%;--alpha-150: 11%;--alpha-200: 15%;--alpha-300: 22%;--alpha-400: 30%;--alpha-500: 40%;--alpha-600: 50%;--alpha-700: 65%;--alpha-800: 80%;--alpha-900: 90%;--alpha-950: 95%;--tint-50: color-mix(in srgb, currentColor var(--alpha-50), transparent);--tint-100: color-mix(in srgb, currentColor var(--alpha-100), transparent);--tint-150: color-mix(in srgb, currentColor var(--alpha-150), transparent);--tint-200: color-mix(in srgb, currentColor var(--alpha-200), transparent);--tint-300: color-mix(in srgb, currentColor var(--alpha-300), transparent);--tint-400: color-mix(in srgb, currentColor var(--alpha-400), transparent);--tint-500: color-mix(in srgb, currentColor var(--alpha-500), transparent);--tint-600: color-mix(in srgb, currentColor var(--alpha-600), transparent);--tint-700: color-mix(in srgb, currentColor var(--alpha-700), transparent);--tint-800: color-mix(in srgb, currentColor var(--alpha-800), transparent);--tint-900: color-mix(in srgb, currentColor var(--alpha-900), transparent);--tint-950: color-mix(in srgb, currentColor var(--alpha-950), transparent);--color-overlay-hover: color-mix(in srgb, var(--black) var(--alpha-100), transparent);--color-overlay-active: color-mix(in srgb, var(--black) var(--alpha-300), transparent);--backdrop-blur-glass: blur(20px) saturate(1.4);--black: #000000;--white: #ffffff;--neutral-50: oklch(.985 0 0);--neutral-100: oklch(.97 0 0);--neutral-200: oklch(.923 0 0);--neutral-300: oklch(.869 0 0);--neutral-350: oklch(.79 0 0);--neutral-400: oklch(.709 0 0);--neutral-500: oklch(.553 0 0);--neutral-600: oklch(.444 0 0);--neutral-700: oklch(.374 0 0);--neutral-800: oklch(.268 0 0);--neutral-900: oklch(.216 0 0);--neutral-950: oklch(.147 0 0);--red-50: oklch(.969 .015 12.422);--red-100: oklch(.941 .03 12.58);--red-200: oklch(.892 .058 10.001);--red-300: oklch(.81 .117 11.638);--red-400: oklch(.712 .194 13.428);--red-500: oklch(.645 .246 16.439);--red-600: oklch(.586 .253 17.585);--red-700: oklch(.514 .222 16.935);--red-800: oklch(.455 .188 13.697);--red-900: oklch(.41 .159 10.272);--red-950: oklch(.271 .105 12.094);--orange-50: oklch(.98 .016 73.684);--orange-100: oklch(.954 .038 75.164);--orange-200: oklch(.901 .076 70.697);--orange-300: oklch(.837 .128 66.29);--orange-400: oklch(.75 .183 55.934);--orange-500: oklch(.705 .213 47.604);--orange-600: oklch(.646 .222 41.116);--orange-700: oklch(.553 .195 38.402);--orange-800: oklch(.47 .157 37.304);--orange-900: oklch(.408 .123 38.172);--orange-950: oklch(.266 .079 36.259);--yellow-50: oklch(.987 .026 102.212);--yellow-100: oklch(.973 .071 103.193);--yellow-200: oklch(.945 .129 101.54);--yellow-300: oklch(.905 .182 98.111);--yellow-400: oklch(.852 .199 91.936);--yellow-500: oklch(.795 .184 86.047);--yellow-600: oklch(.681 .162 75.834);--yellow-700: oklch(.554 .135 66.442);--yellow-800: oklch(.476 .114 61.907);--yellow-900: oklch(.421 .095 57.708);--yellow-950: oklch(.286 .066 53.813);--green-50: oklch(.979 .021 166.113);--green-100: oklch(.95 .052 163.051);--green-200: oklch(.905 .093 164.15);--green-300: oklch(.845 .143 164.978);--green-400: oklch(.765 .177 163.223);--green-500: oklch(.696 .17 162.48);--green-600: oklch(.596 .145 163.225);--green-700: oklch(.508 .118 165.612);--green-800: oklch(.432 .095 166.913);--green-900: oklch(.378 .077 168.94);--green-950: oklch(.262 .051 172.552);--blue-50: oklch(.97 .014 254.604);--blue-100: oklch(.932 .032 255.585);--blue-200: oklch(.882 .059 254.128);--blue-300: oklch(.809 .105 251.813);--blue-400: oklch(.707 .165 254.624);--blue-500: oklch(.623 .214 259.815);--blue-600: oklch(.546 .245 262.881);--blue-700: oklch(.488 .243 264.376);--blue-800: oklch(.424 .199 265.638);--blue-900: oklch(.379 .146 265.522);--blue-950: oklch(.282 .091 267.935);--purple-50: oklch(.969 .016 293.756);--purple-100: oklch(.943 .029 294.588);--purple-200: oklch(.894 .057 293.283);--purple-300: oklch(.811 .111 293.571);--purple-400: oklch(.702 .183 293.541);--purple-500: oklch(.606 .25 292.717);--purple-600: oklch(.541 .281 293.009);--purple-700: oklch(.491 .27 292.581);--purple-800: oklch(.432 .232 292.759);--purple-900: oklch(.38 .189 293.745);--purple-950: oklch(.283 .141 291.089)}@supports (corner-shape: squircle){:root{--radius-8: 10px;--radius-12: 15px;--radius-16: 20px;--radius-24: 30px}}:root[data-font=system]{--font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif}:root{--color-bg: var(--neutral-50);--color-bg-muted: var(--neutral-100);--color-surface: var(--white);--color-surface-muted: var(--neutral-100);--color-interactive: var(--neutral-200);--color-interactive-hover: var(--neutral-300);--color-border: rgba(0, 0, 0, .1);--color-border-muted: rgba(0, 0, 0, .06);--color-text: var(--neutral-900);--color-text-muted: var(--neutral-500);--color-link: inherit;--color-focus-ring: var(--neutral-500);--color-overlay-backdrop: rgb(0 0 0 / .5);--color-highlight: rgb(255 255 255 / .5);--color-primary: var(--blue-500);--color-danger: var(--red-600);color-scheme:light}body{font-family:var(--font-sans);font-size:var(--text-base);font-weight:var(--font-weight-body);line-height:var(--leading-base);letter-spacing:.015em;color:var(--color-text);background:var(--color-bg);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}a{color:var(--color-link);text-underline-offset:.15em;text-decoration-thickness:.08em}h1,h2,h3,h4,h5,h6{font-weight:600;color:inherit}code{font-family:var(--font-mono);font-size:.9em;background:var(--color-bg-muted);padding:var(--space-2) var(--space-4);border-radius:var(--radius-4)}pre{font-family:var(--font-mono);background:var(--color-bg-muted);padding:var(--space-12);border-radius:var(--radius-8);overflow-x:auto}pre code{background:none;padding:0}blockquote{padding-left:var(--space-16);border-left:3px solid var(--color-border);color:var(--color-text-muted)}hr{border:none;border-top:1px solid var(--color-border)}table{border-collapse:collapse}th,td{padding:var(--space-8) var(--space-12);border:1px solid var(--color-border);text-align:left}th{background:var(--color-bg-muted);font-weight:600}input,textarea{border:.5px solid var(--tint-300);border-radius:var(--radius-12);background:var(--tint-100);color:inherit;font:inherit;box-sizing:border-box;transition:background .12s ease,border-color .12s ease,box-shadow .12s ease}input{height:var(--control-height-lg);padding:0 12px}textarea{padding:6px 10px;resize:none}input::placeholder,textarea::placeholder{color:var(--tint-500)}input:focus,textarea:focus{background:color-mix(in srgb,var(--white) var(--alpha-300),transparent);border-color:var(--color-primary);outline:none;box-shadow:0 0 0 1.5px var(--color-primary)}label.field{display:grid;gap:4px;font-size:13px}label.field>span{font-size:11.5px;font-weight:450;color:var(--tint-800)}@supports (corner-shape: squircle){*{corner-shape:squircle}}button{display:inline-flex;align-items:center;justify-content:center;gap:var(--space-6);box-sizing:border-box;height:var(--control-height-md);padding:0 14px 2px;font:inherit;cursor:default}button,segmented-control{background:var(--color-surface);border:.5px solid var(--tint-200);border-radius:var(--radius-12);box-shadow:var(--shadow-control);color:inherit}button:not([material]):hover:not(:disabled){background:color-mix(in srgb,var(--color-surface) 96%,black)}button:not([material]):active:not(:disabled){background:color-mix(in srgb,var(--color-surface) 88%,black);box-shadow:inset 0 1px 2px #00000014}button:focus-visible{outline:2px solid var(--color-focus-ring);outline-offset:2px}button[variant=primary]{background:var(--color-primary);border-color:#0000002e;color:var(--white)}button[variant=primary]:hover:not(:disabled){background:color-mix(in srgb,var(--color-primary) 92%,black)}button[variant=primary]:active:not(:disabled){background:color-mix(in srgb,var(--color-primary) 82%,black);box-shadow:inset 0 1px 2px #0000002e}button[variant=danger]{background:var(--color-danger);border-color:#0000002e;color:var(--white)}button[variant=danger]:hover:not(:disabled){background:color-mix(in srgb,var(--color-danger) 92%,black)}button[variant=danger]:active:not(:disabled){background:color-mix(in srgb,var(--color-danger) 82%,black);box-shadow:inset 0 1px 2px #0000002e}button[variant=ghost]{background:transparent;border-color:transparent;color:inherit;box-shadow:none}button[variant=ghost]:hover:not(:disabled){background:var(--tint-150);backdrop-filter:saturate(1.2);-webkit-backdrop-filter:saturate(1.2)}button[variant=ghost]:active:not(:disabled){background:var(--tint-300);backdrop-filter:saturate(1.4);-webkit-backdrop-filter:saturate(1.4);box-shadow:none}button[variant=ghost][data-active]:not(:disabled),button[variant=ghost][data-active]:hover:not(:disabled),button[variant=ghost][aria-pressed=true]:not(:disabled),button[variant=ghost][aria-pressed=true]:hover:not(:disabled),button[variant=ghost][aria-expanded=true]:not(:disabled),button[variant=ghost][aria-expanded=true]:hover:not(:disabled){background:var(--color-overlay-active);backdrop-filter:saturate(1.3);-webkit-backdrop-filter:saturate(1.3);box-shadow:none}button[variant=glass],segmented-control[variant=glass]{background:transparent;border:.5px solid color-mix(in srgb,var(--black) var(--alpha-100),transparent);box-shadow:none}button[variant=glass]{backdrop-filter:blur(20px) brightness(.95) saturate(1.5);-webkit-backdrop-filter:blur(20px) brightness(.95) saturate(1.5)}button[variant=glass]:hover:not(:disabled){background:linear-gradient(var(--color-overlay-hover),var(--color-overlay-hover));backdrop-filter:blur(20px) brightness(.95) saturate(1.8);-webkit-backdrop-filter:blur(20px) brightness(.95) saturate(1.8)}button[variant=glass]:active:not(:disabled){background:linear-gradient(var(--color-overlay-active),var(--color-overlay-active));backdrop-filter:blur(20px) brightness(.95) saturate(2.2);-webkit-backdrop-filter:blur(20px) brightness(.95) saturate(2.2)}button[variant=glass][aria-pressed=true]:not(:disabled),button[variant=glass][aria-pressed=true]:hover:not(:disabled),button[variant=glass][aria-expanded=true]:not(:disabled),button[variant=glass][aria-expanded=true]:hover:not(:disabled){background:linear-gradient(var(--color-overlay-active),var(--color-overlay-active));backdrop-filter:blur(20px) brightness(.95) saturate(2);-webkit-backdrop-filter:blur(20px) brightness(.95) saturate(2)}[tone=dark] button[variant=glass],[tone=dark] segmented-control[variant=glass]{border-color:var(--tint-400)}button[material],segmented-control[material]{color:inherit;box-shadow:none}button[material]:hover:not(:disabled){background-image:linear-gradient(var(--color-overlay-hover),var(--color-overlay-hover))}button[material]:active:not(:disabled){background-image:linear-gradient(var(--color-overlay-active),var(--color-overlay-active))}[tone=dark] button[material],[tone=dark] segmented-control[material]{border-color:var(--tint-400)}button:disabled{background:var(--tint-300);border-color:transparent;color:var(--tint-700);box-shadow:none}button[variant=ghost]:disabled{background:transparent}:where([tone=dark]) button:not([variant]):not([material]):not(:disabled),:where([tone=dark]) button[variant=default]:not([material]):not(:disabled),:where([tone=dark]) segmented-control:not([variant]):not([material]),:where([tone=dark]) segmented-control[variant=default]:not([material]){background:var(--tint-200);border-color:var(--tint-300);box-shadow:inset 0 .5px 0 var(--tint-300)}:where([tone=dark]) button:not([variant]):hover:not(:disabled),:where([tone=dark]) button[variant=default]:hover:not(:disabled){background:var(--tint-300)}:where([tone=dark]) button:not([variant]):active:not(:disabled),:where([tone=dark]) button[variant=default]:active:not(:disabled){background:var(--tint-400);box-shadow:inset 0 1px 2px #0003}:where([tone=light]) button:not([variant]):not([material]):not(:disabled),:where([tone=light]) button[variant=default]:not([material]):not(:disabled),:where([tone=light]) segmented-control:not([variant]):not([material]),:where([tone=light]) segmented-control[variant=default]:not([material]){background:var(--color-surface);border-color:var(--tint-200);box-shadow:var(--shadow-control)}:where([tone=light]) button:not([variant]):hover:not(:disabled){background:color-mix(in srgb,var(--color-surface) 96%,black)}:where([tone=light]) button:not([variant]):active:not(:disabled){background:color-mix(in srgb,var(--color-surface) 88%,black);box-shadow:inset 0 1px 2px #00000014}button[size=sm],segmented-control[size=sm]{height:var(--control-height-sm)}button[size=sm][icon-only]{width:var(--control-height-sm)}button[size=xs]{height:var(--control-height-xs);padding:0 var(--space-6) 1px;border-radius:var(--radius-8)}button[size=xs][icon-only]{width:var(--control-height-xs);padding:0}button[icon-only]{width:var(--control-height-md);padding:0}[data-ui-icon]{display:inline-block;vertical-align:middle}[selectable],[selectable] *{user-select:text;-webkit-user-select:text}[unselectable],[unselectable] *{user-select:none;-webkit-user-select:none}.prose{line-height:var(--leading-base)}.prose h1{font-size:var(--text-xl);margin-bottom:var(--space-8)}.prose h2{font-size:var(--text-lg);margin-top:var(--space-24);margin-bottom:var(--space-8)}.prose h3,.prose h4,.prose h5,.prose h6{font-size:var(--text-base);margin-top:var(--space-24);margin-bottom:var(--space-8)}.prose p{margin:var(--space-12) 0}.prose ul,.prose ol{padding-left:var(--space-24);margin:var(--space-12) 0}.prose blockquote,.prose pre{margin:var(--space-12) 0}.prose hr{margin:var(--space-24) 0}.prose table{width:100%;margin:var(--space-12) 0}.prose img{max-width:100%;height:auto}.prose>:first-child{margin-top:0}.prose>:last-child{margin-bottom:0}[material=paper]{background:var(--white);border:.5px solid color-mix(in srgb,var(--black) var(--alpha-100),transparent);color:var(--color-text)}[material=glass]{background:transparent;border:.5px solid color-mix(in srgb,var(--black) var(--alpha-100),transparent);backdrop-filter:blur(20px) brightness(.95) saturate(1.5);-webkit-backdrop-filter:blur(20px) brightness(.95) saturate(1.5)}[material=glass-frosted]{background:color-mix(in srgb,var(--white) var(--alpha-800),transparent);border:.5px solid color-mix(in srgb,var(--black) var(--alpha-100),transparent);color:var(--color-text);backdrop-filter:var(--backdrop-blur-glass);-webkit-backdrop-filter:var(--backdrop-blur-glass)}[tone=dark]{color:color-mix(in srgb,var(--white) var(--alpha-950),transparent);border-color:color-mix(in srgb,var(--white) var(--alpha-200),transparent);--color-overlay-hover: color-mix(in srgb, var(--white) var(--alpha-100), transparent);--color-overlay-active: color-mix(in srgb, var(--white) var(--alpha-200), transparent)}[tone=dark][material=paper]{background:#000}[tone=dark][material=glass-frosted]{background:color-mix(in srgb,var(--black) 70%,transparent)}[tone=light]{color:var(--color-text);border-color:color-mix(in srgb,var(--black) var(--alpha-100),transparent);--color-overlay-hover: color-mix(in srgb, var(--black) var(--alpha-50), transparent);--color-overlay-active: color-mix(in srgb, var(--black) var(--alpha-100), transparent)}[level="1"]{box-shadow:0 12px 32px #00000024}[level="2"]{box-shadow:0 4px 6px -2px #0000001f,0 40px 60px -16px #00000038}dropdown-menu{position:relative;display:inline-block;color:inherit}dropdown-group{display:grid;gap:var(--space-4)}dropdown-label{display:block;padding:var(--space-4) var(--space-8);color:var(--color-text-muted);font:inherit;font-size:var(--text-sm);font-weight:600;letter-spacing:.04em;text-transform:uppercase}dropdown-divider{display:block;height:1px;margin:2px 0;background:var(--color-border)}[data-dropdown-trigger][aria-expanded=true],[data-dropdown-trigger][aria-expanded=true]:hover,dropdown-menu[open]::part(trigger),dropdown-menu[open]::part(trigger):hover{background:color-mix(in srgb,var(--color-surface) 88%,black);box-shadow:inset 0 1px 2px #00000014}[data-dropdown-trigger-label],dropdown-menu::part(trigger-label){min-width:0}[data-dropdown-trigger-icon],dropdown-menu::part(trigger-icon){display:inline-flex;align-items:center;justify-content:center;flex:none;color:var(--color-text-muted);transform:translateY(1px)}dropdown-item:focus-visible{outline:2px solid var(--color-focus-ring);outline-offset:2px}ui-popover.dropdown-popover::part(panel){min-width:192px;padding:var(--space-4)}.dropdown-list{display:flex;flex-direction:column;gap:2px}dropdown-item{display:flex;align-items:center;gap:var(--space-8);margin:0;padding:6px 12px;border-radius:var(--radius-8);font:inherit;line-height:1.2;color:inherit;font-weight:var(--font-weight-body);-webkit-user-select:none;user-select:none}dropdown-item>[data-ui-icon]{flex:none}dropdown-item[selected]{background:var(--color-overlay-active)}dropdown-item:hover,dropdown-item[action]:hover{background:var(--color-primary);color:var(--white)}dropdown-item[action]{color:inherit}dropdown-item[danger]{color:var(--color-danger)}dropdown-item[danger]:hover{background:var(--color-danger);color:var(--white)}editable-text{display:inline-block;max-width:100%;vertical-align:top}editable-text>.editable-text-span{display:inline-block;max-width:100%;outline:none;overflow:hidden;white-space:nowrap;cursor:inherit;vertical-align:top}editable-text:not([data-editing])>.editable-text-span{text-overflow:ellipsis}editable-text[data-editing]>.editable-text-span{cursor:text}modal-overlay{color:inherit}modal-overlay::part(backdrop){position:fixed;top:0;right:0;bottom:0;left:0;z-index:var(--layer-overlay);display:flex;align-items:center;justify-content:center;padding:var(--space-16);background:linear-gradient(to bottom,color-mix(in srgb,var(--black) var(--alpha-50),transparent),color-mix(in srgb,var(--black) var(--alpha-400),transparent));backdrop-filter:blur(1px);-webkit-backdrop-filter:blur(1px)}panel-view{display:block}panel-view::part(panel){display:flex;flex-direction:column;gap:var(--space-16);color:var(--color-text)}panel-view::part(header){display:flex;align-items:center;justify-content:space-between;gap:var(--space-12)}panel-view::part(title){margin:0;font:inherit;font-size:var(--text-lg);font-weight:600;color:var(--color-text)}panel-view::part(button){display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;margin:0;border:1px solid var(--color-border);border-radius:var(--radius-4);background:var(--color-surface);color:var(--color-text);box-shadow:none}panel-view::part(button):hover{background:var(--color-interactive-hover)}panel-view::part(button):focus-visible{outline:2px solid var(--color-focus-ring);outline-offset:2px}panel-view::part(icon){display:inline-flex;align-items:center;justify-content:center;flex:none}ui-popover{display:contents}ui-popover::part(panel){position:fixed;inset:0 auto auto 0;margin:0;min-width:192px;max-width:384px;padding:var(--space-16) var(--space-20);border-radius:var(--radius-12);outline:none;z-index:2000}segmented-control{display:inline-flex;align-items:stretch;box-sizing:border-box;height:var(--control-height-md)}segmented-control>button{height:auto}segmented-control[variant=ghost]{background:transparent;box-shadow:none}[tone=dark] segmented-control[variant=ghost]{border-color:var(--tint-400)}segmented-control>button{position:relative}segmented-control>button[icon-only]{width:auto;height:auto;padding:0 var(--space-6)}segmented-control>button:not([variant]):not(:disabled),[tone] segmented-control>button:not([variant]):not(:disabled){background:transparent;border:0;box-shadow:none}segmented-control>button:first-child{border-top-right-radius:0;border-bottom-right-radius:0}segmented-control>button:last-child{border-top-left-radius:0;border-bottom-left-radius:0}segmented-control>button:not(:first-child):not(:last-child){border-radius:0}segmented-control>button:not([variant]):hover:not(:disabled),[tone] segmented-control>button:not([variant]):hover:not(:disabled){background:var(--color-overlay-hover)}segmented-control>button:not([variant]):active:not(:disabled),[tone] segmented-control>button:not([variant]):active:not(:disabled){background:var(--color-overlay-active);box-shadow:none}segmented-control>button:not([variant])[aria-pressed=true]:not(:disabled),segmented-control>button:not([variant])[aria-current]:not([aria-current=false]):not(:disabled),segmented-control>button:not([variant])[aria-expanded=true]:not(:disabled),[tone] segmented-control>button:not([variant])[aria-pressed=true]:not(:disabled),[tone] segmented-control>button:not([variant])[aria-current]:not([aria-current=false]):not(:disabled),[tone] segmented-control>button:not([variant])[aria-expanded=true]:not(:disabled){background:linear-gradient(var(--color-overlay-active),var(--color-overlay-active))}segmented-control>button:not(:last-child):after{content:"";position:absolute;top:0;bottom:0;right:0;width:.5px;background:var(--tint-200);pointer-events:none}[tone=dark] segmented-control>button:not(:last-child):after{background:var(--tint-400)}segmented-control>dropdown-menu{display:inline-flex;align-items:stretch;height:auto}segmented-control>dropdown-menu>[slot=trigger]{height:auto;position:relative}segmented-control>dropdown-menu>[slot=trigger]:not([variant]):not(:disabled),[tone] segmented-control>dropdown-menu>[slot=trigger]:not([variant]):not(:disabled){background:transparent;border:0;box-shadow:none}segmented-control>dropdown-menu:first-child>[slot=trigger]{border-top-right-radius:0;border-bottom-right-radius:0}segmented-control>dropdown-menu:last-child>[slot=trigger]{border-top-left-radius:0;border-bottom-left-radius:0}segmented-control>dropdown-menu:not(:first-child):not(:last-child)>[slot=trigger]{border-radius:0}segmented-control>dropdown-menu>[slot=trigger]:not([variant]):hover:not(:disabled),[tone] segmented-control>dropdown-menu>[slot=trigger]:not([variant]):hover:not(:disabled){background:var(--color-overlay-hover)}segmented-control>dropdown-menu>[slot=trigger]:not([variant]):active:not(:disabled),[tone] segmented-control>dropdown-menu>[slot=trigger]:not([variant]):active:not(:disabled){background:var(--color-overlay-active);box-shadow:none}segmented-control>dropdown-menu>[slot=trigger]:not([variant])[aria-pressed=true]:not(:disabled),segmented-control>dropdown-menu>[slot=trigger]:not([variant])[aria-current]:not([aria-current=false]):not(:disabled),segmented-control>dropdown-menu>[slot=trigger]:not([variant])[aria-expanded=true]:not(:disabled),[tone] segmented-control>dropdown-menu>[slot=trigger]:not([variant])[aria-pressed=true]:not(:disabled),[tone] segmented-control>dropdown-menu>[slot=trigger]:not([variant])[aria-current]:not([aria-current=false]):not(:disabled),[tone] segmented-control>dropdown-menu>[slot=trigger]:not([variant])[aria-expanded=true]:not(:disabled){background:linear-gradient(var(--color-overlay-active),var(--color-overlay-active))}segmented-control[variant=glass]>button,segmented-control[variant=glass]>dropdown-menu{backdrop-filter:blur(20px) brightness(.95) saturate(1.5);-webkit-backdrop-filter:blur(20px) brightness(.95) saturate(1.5)}segmented-control[variant=glass]>button:not(:disabled):hover,segmented-control[variant=glass]>dropdown-menu:has(>[slot=trigger]:not(:disabled):hover){backdrop-filter:blur(20px) brightness(.95) saturate(1.8);-webkit-backdrop-filter:blur(20px) brightness(.95) saturate(1.8)}segmented-control[variant=glass]>button:not(:disabled):active,segmented-control[variant=glass]>dropdown-menu:has(>[slot=trigger]:not(:disabled):active){backdrop-filter:blur(20px) brightness(.95) saturate(2.2);-webkit-backdrop-filter:blur(20px) brightness(.95) saturate(2.2)}segmented-control[variant=glass]>button:not(:disabled)[aria-pressed=true],segmented-control[variant=glass]>button:not(:disabled)[aria-current]:not([aria-current=false]),segmented-control[variant=glass]>dropdown-menu:has(>[slot=trigger]:not(:disabled)[aria-pressed=true]),segmented-control[variant=glass]>dropdown-menu:has(>[slot=trigger]:not(:disabled)[aria-current]:not([aria-current=false])){backdrop-filter:blur(20px) brightness(.95) saturate(1.8);-webkit-backdrop-filter:blur(20px) brightness(.95) saturate(1.8)}segmented-control[variant=glass]>button:not(:disabled)[aria-expanded=true],segmented-control[variant=glass]>dropdown-menu:has(>[slot=trigger]:not(:disabled)[aria-expanded=true]){backdrop-filter:blur(20px) brightness(.95) saturate(2);-webkit-backdrop-filter:blur(20px) brightness(.95) saturate(2)}segmented-control>dropdown-menu:not(:last-child):after{content:"";position:absolute;top:0;bottom:0;right:0;width:.5px;background:var(--tint-200);pointer-events:none}[tone=dark] segmented-control>dropdown-menu:not(:last-child):after{background:var(--tint-400)}ui-spinner{display:inline-flex;align-items:center;justify-content:center;line-height:0;color:inherit}ui-spinner .spin,.spin{display:inline-flex;animation:ui-spinner-spin 1s steps(8,end) infinite}@keyframes ui-spinner-spin{to{transform:rotate(360deg)}}@media (prefers-reduced-motion: reduce){.spin{animation:none}}system-modal{display:flex;flex-direction:column;width:min(400px,100%);box-sizing:border-box;padding:var(--space-32) var(--space-24);border-radius:var(--radius-12)}system-modal header{display:flex;flex-direction:column;align-items:center;gap:var(--space-16);text-align:center}system-modal header>hgroup{display:flex;flex-direction:column;align-items:center;gap:var(--space-4);max-width:100%}system-modal header h2{margin:0;font-size:var(--text-lg);font-weight:600;letter-spacing:.01em;max-width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}system-modal header p{margin:0;font-size:var(--text-base);opacity:.7;max-width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}ui-pill{display:inline-block;vertical-align:baseline;margin:2px 0;padding:0 var(--space-8);font-size:var(--text-sm);font-weight:500;line-height:1.7;border-radius:var(--radius-full);border:1px solid var(--neutral-300);background:var(--neutral-200);color:var(--neutral-900);white-space:nowrap}ui-pill[color=gray]{border-color:var(--neutral-300);background:var(--neutral-200);color:var(--neutral-900)}ui-pill[color=red]{border-color:var(--red-200);background:var(--red-100);color:var(--red-950)}ui-pill[color=orange]{border-color:var(--orange-200);background:var(--orange-100);color:var(--orange-950)}ui-pill[color=yellow]{border-color:var(--yellow-200);background:var(--yellow-100);color:var(--yellow-950)}ui-pill[color=green]{border-color:var(--green-200);background:var(--green-100);color:var(--green-950)}ui-pill[color=blue]{border-color:var(--blue-200);background:var(--blue-100);color:var(--blue-950)}ui-pill[color=purple]{border-color:var(--purple-200);background:var(--purple-100);color:var(--purple-950)}',jd=new CSSStyleSheet;jd.replaceSync(cT);const Gd=new CSSStyleSheet;try{document.adoptedStyleSheets=[...document.adoptedStyleSheets,jd,Gd]}catch{}dy(document);function py(r){Gd.replaceSync(r)}function Hl(){py("")}function qd(r){try{r.adoptedStyleSheets=[...r.adoptedStyleSheets,jd,Gd]}catch{}dy(r)}const uT=new Set(["target","currentTarget","eventPhase","defaultPrevented","isTrusted","timeStamp","srcElement","returnValue","cancelBubble","NONE","CAPTURING_PHASE","AT_TARGET","BUBBLING_PHASE","composedPath","stopPropagation","stopImmediatePropagation","preventDefault","initEvent"]);function hT(r){for(const t of Object.keys(r))if(uT.has(t))throw new Error(`Event payload key "${t}" is reserved; choose a different property name`)}function dT(r,t){hT(t);for(const e of Object.keys(t))Object.defineProperty(r,e,{value:t[e],writable:!0,enumerable:!0,configurable:!0})}function Ve(){class r extends Event{constructor(e,n){const{type:i,bubbles:s,cancelable:o,composed:a,...c}=n??{};if(i!==void 0)throw new Error('Do not pass "type" in init; use the constructor argument instead');super(e,{bubbles:s,cancelable:o,composed:a}),dT(this,c)}}return r}class Mt extends globalThis.EventTarget{}function pT(r,t,e){const n=r.dispose.bind(r);r.dispose=()=>{if(!t())return e(),n()}}function Ra(r){var e;class t extends r{constructor(...s){super(...s);w(this,e,!1);pT(this,()=>l(this,e),()=>{b(this,e,!0)})}[Symbol.dispose](){this.dispose()}get disposed(){return l(this,e)}}return e=new WeakMap,t}const fT=Ve(),gT=Ve(),mT=Ve(),Gs=Ve(),fy=Ve(),vT=Ve(),$u=Ve(),qe=4,ft=6,po=2,ch=2,Yd=8,yT=ft,Kd="auto",tn="auto",Nr=128,Ig=50,ae=16,Jn=Nr*qe+ae*(qe-1),fo=Nr*ft+ae*(ft-1),bT=Jn+ae*2,wT=200,ST=4,Xa=150,_T=10,Cg=2,Rg=8,kT=300,xT=4;function gy(r){return yy(r)}function my(r,t){return yy(r.flatMap(e=>wy(e,t)))}function vy(r){const t=[],e=new Set;for(const n of r){if(n.type==="row"){t.push(`Top-level rows are invalid: ${n.id}`);continue}Sy(n,"strip",t,e)}return{valid:t.length===0,errors:t}}function An(r){const t=gy(r),e=vy(t);if(!e.valid)throw new Error(`Invalid layout: ${e.errors.join("; ")}`);return{totalNodes:t.length,nodes:t.filter(n=>n.type!=="row").map($T)}}function yy(r){const t=[];for(const e of r){const n=by(e);for(const i of n){if(i.type==="row"){t.push(...i.children.map(Ir));continue}t.push(i)}}return t}function by(r){switch(r.type){case"card":return[Ir(r)];case"row":{const t=r.children.map(Ir);return t.length===0?[]:t.length===1?[t[0]]:[{...r,children:t}]}case"stack":{const t=[];for(const e of r.children){const n=by(e);for(const i of n){if(i.type==="stack"){t.push(...i.children.map(uh));continue}if(i.type==="row"){t.push({...i,children:i.children.map(Ir)});continue}t.push(Ir(i))}}return t.length===0?[]:t.length===1?[uh(t[0])]:[{...r,children:t}]}}}function wy(r,t){switch(r.type){case"card":return r.artifactID===t?[]:[Ir(r)];case"row":{const e=r.children.filter(n=>n.artifactID!==t).map(Ir);return e.length===0?[]:e.length===1?[e[0]]:[{...r,children:e}]}case"stack":{const e=r.children.flatMap(n=>wy(n,t).filter(s=>s.type!=="stack"));return e.length===0?[]:e.length===1?[uh(e[0])]:[{...r,children:e}]}}}function Sy(r,t,e,n){switch(r.type){case"card":_y(r,t,e,n);return;case"row":ET(r,t,e,n);return;case"stack":AT(r,t,e,n);return}}function _y(r,t,e,n){"id"in r&&e.push(`Card ${Ms(r)} must not include id`),typeof r.artifactID!="string"||r.artifactID.length===0?e.push("Card is missing artifactID"):n.has(r.artifactID)?e.push(`Duplicate artifactID in layout: ${r.artifactID}`):n.add(r.artifactID),TT(r.width)||e.push(`Card ${Ms(r)} width must be an integer in the range ${po}-${Yd}`),xy(r.height)||e.push(`Card ${Ms(r)} height must be an integer in the range 2-6 or "auto"`);const i=Ri(r.width);t==="stack"&&i!==qe&&e.push(`Stack child ${Ms(r)} width must be ${qe}`),t==="row"&&i<po&&e.push(`Row child ${Ms(r)} must be at least 2 columns wide`)}function Ms(r){return typeof r.artifactID=="string"&&r.artifactID.length>0?r.artifactID:"<missing artifactID>"}function ET(r,t,e,n){if(ky(r.id,e),t!=="stack"&&e.push(`Row ${r.id} may only appear inside a stack`),xy(r.height,xT)||e.push(`Row ${r.id} height must be an integer in the range 2-4 or "auto"`),!Array.isArray(r.children)||r.children.length===0){e.push(`Row ${r.id} must contain card nodes`);return}let i=0;for(const s of r.children){if(s.type!=="card"){e.push(`Row ${r.id} must contain only card nodes`);continue}_y(s,"row",e,n),i+=Ri(s.width)}i!==qe&&e.push(`Row ${r.id} children must sum to 4 columns`)}function AT(r,t,e,n){if(ky(r.id,e),t!=="strip"&&e.push(`Invalid nested stack at ${r.id}; stack children cannot contain another nested stack`),!Array.isArray(r.children)||r.children.length===0){e.push(`Stack ${r.id} must contain at least one child`);return}let i=0,s=0;for(const a of r.children){if(a.type==="stack"){e.push(`Stack ${r.id} cannot contain another nested stack`);continue}if(Sy(a,"stack",e,n),a.height===tn){s+=1;continue}i+=a.height}if(i>ft&&e.push(`Stack ${r.id} exceeds the 6-row budget`),s===0)return;const o=ft-i;if(o<s*ch||o%s!==0){e.push(`Stack ${r.id} has auto-height children that cannot resolve to whole height >= 2`);return}o/s<ch&&e.push(`Stack ${r.id} has auto-height children below the minimum row size`)}function ky(r,t){(typeof r!="string"||r.length===0)&&t.push(`Node id must be a non-empty string: ${String(r)}`)}function TT(r){return r===Kd||Number.isInteger(r)&&r>=po&&r<=Yd}function xy(r,t=yT){return r===tn||Number.isInteger(r)&&r>=ch&&r<=t}function Ri(r){return r===Kd?qe:r}function $T(r){if(r.type==="card")return{id:r.artifactID,type:"card",width:Ri(r.width),cards:[{id:r.artifactID,artifactID:r.artifactID,col:1,row:1,width:Ri(r.width),height:Ey(r.height,ft)}]};const t=IT(r.children),e=[];let n=1;for(let i=0;i<r.children.length;i+=1){const s=r.children[i],o=t[i];if(s.type==="card")e.push({id:s.artifactID,artifactID:s.artifactID,col:1,row:n,width:qe,height:o});else{let a=1;for(const c of s.children)e.push({id:c.artifactID,artifactID:c.artifactID,col:a,row:n,width:Ri(c.width),height:o}),a+=Ri(c.width)}n+=o}return{id:r.id,type:"stack",width:e.reduce((i,s)=>Math.max(i,s.col+s.width-1),1),cards:e}}function IT(r){let t=0,e=0;for(const i of r)i.height===tn?e+=1:t+=i.height;const n=e>0?(ft-t)/e:0;return r.map(i=>Ey(i.height,n))}function Ey(r,t){return r===tn?t:r}function Ir(r){return{...r}}function uh(r){return r.type==="card"?Ir(r):{...r,children:r.children.map(Ir)}}const CT="X-Television-Client-Meta",RT="telemetry-activity";function Ay(r,t={}){return{type:"card",artifactID:r,width:t.width??Kd,height:t.height??tn}}function ml(r){return r.layout.flatMap(Ty)}function Ty(r){switch(r.type){case"card":return[r.artifactID];case"row":return r.children.map(t=>t.artifactID);case"stack":return r.children.flatMap(Ty)}}const oe=Ve(),hh=Ve(),yi=Ve(),Pg=Ve();function PT(r){class t extends Error{constructor(n,i){super(n),this.name=r,i&&Object.assign(this,i)}}return t}const Jd=PT("RequestError"),LT=200,DT=300,Qa=401;class zT{constructor(t,e){g(this,"serverURL");g(this,"token");g(this,"onUnauthorized");g(this,"telemetryMeta");this.serverURL=t.replace(/\/$/,""),this.token=e.token,this.onUnauthorized=e.onUnauthorized,this.telemetryMeta=e.telemetryMeta}async requestJSON(t,e,n){var o;const i=await this.request(t,e,n!==void 0?JSON.stringify(n):void 0,n!==void 0?{"content-type":"application/json"}:void 0),s=await OT(i);if(!i.ok||i.status<LT||i.status>=DT)throw i.status===Qa&&((o=this.onUnauthorized)==null||o.call(this)),this.createError(typeof s.error=="string"?s.error:i.statusText,i.status);return s}async requestVoid(t,e,n){var s;const i=await this.request(t,e,n!==void 0?JSON.stringify(n):void 0,n!==void 0?{"content-type":"application/json"}:void 0);if(!i.ok)throw i.status===Qa&&((s=this.onUnauthorized)==null||s.call(this)),this.createError(await Iu(i,i.statusText),i.status)}async requestText(t,e){var i;const n=await this.request(t,e);if(!n.ok)throw n.status===Qa&&((i=this.onUnauthorized)==null||i.call(this)),this.createError(await Iu(n,n.statusText),n.status);return n.text()}async requestRawVoid(t,e,n){var s;const i=await this.request(t,e,n,{"content-type":"text/markdown; charset=utf-8"});if(!i.ok)throw i.status===Qa&&((s=this.onUnauthorized)==null||s.call(this)),this.createError(await Iu(i,i.statusText),i.status)}createError(t,e){const n={serverURL:this.serverURL};return e!==void 0&&(n.status=e),new Jd(t,n)}async request(t,e,n,i){const s=`${this.serverURL}${e}`;try{return await fetch(s,{method:t,headers:this.buildHeaders(i),body:n})}catch(o){throw this.createError(o instanceof Error?o.message:"Failed to reach server")}}buildHeaders(t){const e={...t??{}};return this.token&&(e.Authorization=`Bearer ${this.token}`),this.telemetryMeta&&(e[CT]=JSON.stringify(this.telemetryMeta)),Object.keys(e).length>0?e:void 0}}async function OT(r){try{return await r.json()}catch{const t=await r.text().catch(()=>"");return t?{message:t}:{}}}async function Iu(r,t){try{const e=await r.json();if(typeof e.error=="string")return e.error;if(typeof e.message=="string")return e.message}catch{}return t}function MT(r){return r.map(t=>`${t.name} (${t.id})`).join(", ")}var jt,tc,$y;class NT{constructor(t){w(this,tc);w(this,jt);b(this,jt,t)}list(){return l(this,jt).requestJSON("GET","/screens")}async get(t={}){const e=await p(this,tc,$y).call(this,t.screenID);return l(this,jt).requestJSON("GET",`/screens/${encodeURIComponent(e)}`)}create(t){const e={name:t.name};return t.id!==void 0&&(e.id=t.id),l(this,jt).requestJSON("POST","/screens",e)}update(t){const{screenID:e,...n}=t;return l(this,jt).requestJSON("PATCH",`/screens/${encodeURIComponent(e)}`,n)}remove(t){return l(this,jt).requestJSON("DELETE",`/screens/${encodeURIComponent(t.screenID)}`)}}jt=new WeakMap,tc=new WeakSet,$y=async function(t){if(t!==void 0)return t;const{screens:e}=await this.list();if(e.length===1)return e[0].id;throw l(this,jt).createError(`screenID is required when multiple screens exist. Available screens: ${MT(e)}`)};var Sr;class UT{constructor(t){w(this,Sr);b(this,Sr,t)}create(t){const e={kind:t.kind,title:t.title};switch(t.kind){case"path":e.path=t.path;break;case"url":e.url=t.url;break}return e.screenID=t.screenID,l(this,Sr).requestJSON("POST","/artifacts",e)}list(t={}){const e=new URLSearchParams;t.screenID!==void 0&&e.set("screenID",t.screenID);const n=e.toString();return l(this,Sr).requestJSON("GET",n?`/artifacts?${n}`:"/artifacts")}get(t){return l(this,Sr).requestJSON("GET",`/artifacts/${encodeURIComponent(t.artifactID)}`)}update(t){const e={};return t.title!==void 0&&(e.title=t.title),t.path!==void 0&&(e.path=t.path),t.url!==void 0&&(e.url=t.url),l(this,Sr).requestJSON("PATCH",`/artifacts/${encodeURIComponent(t.artifactID)}`,e)}delete(t){return l(this,Sr).requestJSON("DELETE",`/artifacts/${encodeURIComponent(t.artifactID)}`)}}Sr=new WeakMap;var Ui;class FT{constructor(t){w(this,Ui);b(this,Ui,t)}get(t){return l(this,Ui).requestText("GET",`/markdown/${encodeURIComponent(t.artifactID)}`)}update(t){return l(this,Ui).requestRawVoid("PUT",`/markdown/${encodeURIComponent(t.artifactID)}`,t.content)}}Ui=new WeakMap;var In;class HT{constructor(t){w(this,In);b(this,In,t)}status(){return l(this,In).requestJSON("GET","/telemetry")}enable(){return l(this,In).requestJSON("POST","/telemetry/enable")}disable(){return l(this,In).requestJSON("POST","/telemetry/disable")}}In=new WeakMap;var Cn;class ZT{constructor(t){w(this,Cn);b(this,Cn,t)}get(){return l(this,Cn).requestJSON("GET","/display")}patch(t){const e={};return t.activeScreenID!==void 0&&(e.activeScreenID=t.activeScreenID),t.activeThemeName!==void 0&&(e.activeThemeName=t.activeThemeName),l(this,Cn).requestVoid("PATCH","/display",e)}focus(t){return l(this,Cn).requestJSON("POST","/display/focus",{artifactID:t.artifactID})}}Cn=new WeakMap;var Gt;class WT{constructor(t,e={}){g(this,"screens");g(this,"artifacts");g(this,"display");g(this,"markdown");g(this,"telemetry");w(this,Gt);b(this,Gt,new zT(t,e)),this.screens=new NT(l(this,Gt)),this.artifacts=new UT(l(this,Gt)),this.display=new ZT(l(this,Gt)),this.markdown=new FT(l(this,Gt)),this.telemetry=new HT(l(this,Gt))}health(){return l(this,Gt).requestJSON("GET","/health")}}Gt=new WeakMap;const BT={focusCommandInput:{label:"Focus Command Input",trigger:{key:"k",meta:!0}}},VT="Local",jT="store-";function he(r){return new URL(r).origin}function GT(r){return{servers:[{url:he(r),name:VT}],activeServerURL:null,activeScreenID:null,tabs:{},screens:{},authTokens:{}}}function qT(r,t){return[...r.tabs[he(t)]??[]]}function YT(r,t,e){const n=he(t),i=r.tabs[n]??[];return i.includes(e)?r:{...r,tabs:{...r.tabs,[n]:[...i,e]}}}function KT(r,t,e){const n=he(t),i=r.tabs[n]??[],s=i.filter(a=>a!==e);if(s.length===i.length)return r;const o={...r.tabs};return s.length===0?delete o[n]:o[n]=s,{...r,tabs:o}}function JT(r,t,e=Date.now()){const n=r.screens[t]??{scrollPosition:0};return{...r,screens:{...r.screens,[t]:{...n,lastActivatedAt:e}}}}var Rn,Pn,Ln;class XT extends Mt{constructor(e,n,i={}){super();w(this,Rn);w(this,Pn);w(this,Ln);b(this,Rn,`${jT}${e}`),b(this,Pn,i.storage??t$());const s=l(this,Pn).getItem(l(this,Rn));s===null?(b(this,Ln,n),l(this,Pn).setItem(l(this,Rn),JSON.stringify(n))):b(this,Ln,r$(JSON.parse(s),n))}get(){return l(this,Ln)}set(e){b(this,Ln,e),l(this,Pn).setItem(l(this,Rn),JSON.stringify(e)),this.dispatchEvent(new oe("change"))}}Rn=new WeakMap,Pn=new WeakMap,Ln=new WeakMap;function Cu(r,t){return r.authTokens[he(t)]??null}function QT(r,t,e){return{...r,authTokens:{...r.authTokens,[he(t)]:e}}}function e$(r,t){const e=he(t);if(!(e in r.authTokens))return r;const n={...r.authTokens};return delete n[e],{...r,authTokens:n}}function t$(){const r=globalThis.localStorage;if(!r)throw new Error("LocalStore: no storage adapter supplied and window.localStorage is unavailable");return r}function r$(r,t){return{servers:Array.isArray(r.servers)?r.servers:t.servers,activeServerURL:typeof r.activeServerURL=="string"||r.activeServerURL===null?r.activeServerURL:t.activeServerURL,activeScreenID:typeof r.activeScreenID=="string"||r.activeScreenID===null?r.activeScreenID:t.activeScreenID,tabs:r.tabs&&typeof r.tabs=="object"?r.tabs:t.tabs,screens:r.screens&&typeof r.screens=="object"?r.screens:t.screens,authTokens:r.authTokens&&typeof r.authTokens=="object"?r.authTokens:t.authTokens}}class n$ extends Event{constructor(){super("theme-changed")}}const i$=Ra(Mt);var Dn,Ne,Fr,Ge,Hr,_r,So,ee,bn,Iy,_o,Cy,Ry,Py,Ly,dh,ph,fh,Dy;class s$ extends i${constructor(e){var i;super();w(this,ee);g(this,"id");g(this,"server");w(this,Dn);w(this,Ne,new Map);w(this,Fr);w(this,Ge);w(this,Hr);w(this,_r,null);w(this,So,0);w(this,_o,e=>{if(this.disposed)return;const n=e.event;switch(n.type){case"screen-updated":n.screen.id===this.id&&p(this,ee,Cy).call(this,n.screen);break;case"artifact-created":n.screenID===this.id&&p(this,ee,Ry).call(this,n.artifact);break;case"artifact-updated":p(this,ee,Py).call(this,n.artifact);break;case"artifact-removed":n.screenID===this.id&&p(this,ee,Ly).call(this,n.artifactID);break;case"artifact-content-changed":l(this,Ne).has(n.artifactID)&&this.dispatchEvent(new Pg("artifact-content-changed",{artifactID:n.artifactID}));break;case"theme-changed":this.dispatchEvent(new n$);break}});this.id=e.screen.id,this.server=e.server,b(this,Dn,e.localStore),b(this,Fr,e.screen.name),b(this,Ge,structuredClone(e.screen.layout));const n=((i=l(this,Dn).get().screens[this.id])==null?void 0:i.scrollPosition)??0;b(this,Hr,Math.max(0,n)),this.server.addEventListener("server-event",l(this,_o)),p(this,ee,Iy).call(this)}get name(){return l(this,Fr)}get layout(){return l(this,Ge)}get scrollPosition(){return l(this,Hr)}get artifacts(){return l(this,Ne)}setScrollPosition(e){p(this,ee,bn).call(this);const n=Math.max(0,e);n!==l(this,Hr)&&(b(this,Hr,n),p(this,ee,Dy).call(this),this.dispatchEvent(new oe("change")))}setLayout(e){p(this,ee,bn).call(this);const n=gy(e);if(!vy(n).valid)return;const s=p(this,ee,ph).call(this);b(this,Ge,n),b(this,_r,{layout:n,snapshot:s}),this.dispatchEvent(new oe("change")),this.server.client.screens.update({screenID:this.id,layout:n.map(o=>structuredClone(o))}).catch(()=>{var o;this.disposed||((o=l(this,_r))==null?void 0:o.layout)===n&&(b(this,_r,null),p(this,ee,fh).call(this,s),this.dispatchEvent(new oe("change")))})}rename(e){p(this,ee,bn).call(this),b(this,Fr,e),this.dispatchEvent(new oe("change")),this.server.client.screens.update({screenID:this.id,name:e}).catch(()=>{})}async remove(){p(this,ee,bn).call(this),await this.server.client.screens.remove({screenID:this.id})}removeArtifact(e){if(p(this,ee,bn).call(this),!l(this,Ne).has(e))return;const n=p(this,ee,ph).call(this);p(this,ee,dh).call(this,e),this.dispatchEvent(new oe("change")),this.server.client.artifacts.delete({artifactID:e}).catch(()=>{this.disposed||(p(this,ee,fh).call(this,n),this.dispatchEvent(new oe("change")))})}async refreshFromServer(){p(this,ee,bn).call(this);const e=++eu(this,So)._;let n;try{n=await this.server.client.screens.get({screenID:this.id})}catch{return}if(this.disposed||e!==l(this,So))return;const i=new Set([...l(this,Ne).values()].filter(s=>s.kind==="path").map(s=>s.id));b(this,_r,null),b(this,Fr,n.screen.name),b(this,Ge,structuredClone(n.screen.layout)),l(this,Ne).clear();for(const s of n.artifacts)l(this,Ne).set(s.id,s);this.dispatchEvent(new oe("change"));for(const s of n.artifacts)s.kind==="path"&&i.has(s.id)&&this.dispatchEvent(new Pg("artifact-content-changed",{artifactID:s.id}))}dispose(){this.server.removeEventListener("server-event",l(this,_o))}}Dn=new WeakMap,Ne=new WeakMap,Fr=new WeakMap,Ge=new WeakMap,Hr=new WeakMap,_r=new WeakMap,So=new WeakMap,ee=new WeakSet,bn=function(){if(this.disposed)throw new Error("ScreenModel is disposed")},Iy=async function(){try{const e=await this.server.client.screens.get({screenID:this.id});if(this.disposed)return;for(const n of e.artifacts)l(this,Ne).set(n.id,n);this.dispatchEvent(new oe("change"))}catch{}},_o=new WeakMap,Cy=function(e){l(this,_r)&&b(this,_r,null),b(this,Fr,e.name),b(this,Ge,structuredClone(e.layout)),this.dispatchEvent(new oe("change"))},Ry=function(e){ml({layout:l(this,Ge)}).includes(e.id)||b(this,Ge,[...l(this,Ge),Ay(e.id)]),l(this,Ne).set(e.id,e),this.dispatchEvent(new oe("change"))},Py=function(e){const n=l(this,Ne).get(e.id);n&&(l(this,Ne).set(e.id,{...n,...e}),this.dispatchEvent(new oe("change")))},Ly=function(e){p(this,ee,dh).call(this,e)&&this.dispatchEvent(new oe("change"))},dh=function(e){const n=l(this,Ne).delete(e),i=ml({layout:l(this,Ge)}).length,s=my(l(this,Ge),e),o=ml({layout:s}).length;return b(this,Ge,s),n||i!==o},ph=function(){return{layout:structuredClone(l(this,Ge)),artifacts:new Map([...l(this,Ne).entries()].map(([e,n])=>[e,structuredClone(n)]))}},fh=function(e){b(this,Ge,structuredClone(e.layout)),l(this,Ne).clear();for(const[n,i]of e.artifacts)l(this,Ne).set(n,structuredClone(i))},Dy=function(){const e=l(this,Dn).get();l(this,Dn).set({...e,screens:{...e.screens,[this.id]:{...e.screens[this.id],scrollPosition:l(this,Hr)}}})};const o$=Ra(Mt);var Pe,Ue,Tt,ko,xo,Eo,Ao,Xe,vl,gh,_i;class a$ extends o${constructor(e){super();w(this,Xe);w(this,Pe);w(this,Ue);w(this,Tt,null);w(this,ko,()=>{this.disposed||p(this,Xe,vl).call(this)});w(this,xo,()=>{this.disposed||p(this,Xe,vl).call(this)});w(this,Eo,e=>{if(this.disposed)return;const n=e.event;if(n.type==="screen-removed"){this.removeTab(e.serverURL,n.screenID);const i=l(this,Pe).get();i.activeServerURL===he(e.serverURL)&&i.activeScreenID===n.screenID&&p(this,Xe,_i).call(this,e.serverURL,null);return}if(n.type==="screen-changed"){if(n.screenID===null){p(this,Xe,_i).call(this,e.serverURL,null);return}const i=l(this,Ue).servers.get(he(e.serverURL));if(!i||!i.screens.has(n.screenID))return;this.addTab(e.serverURL,n.screenID),p(this,Xe,_i).call(this,e.serverURL,n.screenID)}});w(this,Ao,e=>{if(this.disposed)return;const n=l(this,Tt);n&&he(e.serverURL)===he(n.server.url)&&n.refreshFromServer()});b(this,Pe,e.localStore),b(this,Ue,e.serverManager),l(this,Pe).addEventListener("change",l(this,ko)),l(this,Ue).addEventListener("change",l(this,xo)),l(this,Ue).addEventListener("server-event",l(this,Eo)),l(this,Ue).addEventListener("server-reconnected",l(this,Ao)),p(this,Xe,vl).call(this)}get activeScreen(){return l(this,Tt)}get screens(){const e=l(this,Pe).get().screens,n=[];let i=0;for(const s of l(this,Ue).servers.values())for(const o of s.screens.values())n.push({server:s,screen:o,local:e[o.id]??{scrollPosition:0},index:i}),i+=1;return n.sort((s,o)=>{const a=(o.local.lastActivatedAt??0)-(s.local.lastActivatedAt??0);return a===0?s.index-o.index:a}).map(({index:s,...o})=>o)}getTabs(e){const n=he(e),i=qT(l(this,Pe).get(),n),s=l(this,Ue).servers.get(n);return s?i.filter(o=>s.screens.has(o)):i}hasTab(e,n){return this.getTabs(e).includes(n)}addTab(e,n){const i=he(e),s=l(this,Ue).servers.get(i);s&&!s.screens.has(n)||p(this,Xe,gh).call(this,YT(l(this,Pe).get(),i,n))}removeTab(e,n){p(this,Xe,gh).call(this,KT(l(this,Pe).get(),e,n))}setActive(e,n){const i=he(e),s=l(this,Ue).servers.get(i);!s||!s.screens.has(n)||p(this,Xe,_i).call(this,i,n)&&s.client.display.patch({activeScreenID:n}).catch(()=>{})}clearActive(){const e=l(this,Pe).get().activeServerURL;if(!e||!p(this,Xe,_i).call(this,e,null))return;const n=l(this,Ue).servers.get(e);n==null||n.client.display.patch({activeScreenID:null}).catch(()=>{})}dispose(){var e;l(this,Pe).removeEventListener("change",l(this,ko)),l(this,Ue).removeEventListener("change",l(this,xo)),l(this,Ue).removeEventListener("server-event",l(this,Eo)),l(this,Ue).removeEventListener("server-reconnected",l(this,Ao)),(e=l(this,Tt))==null||e.dispose(),b(this,Tt,null)}}Pe=new WeakMap,Ue=new WeakMap,Tt=new WeakMap,ko=new WeakMap,xo=new WeakMap,Eo=new WeakMap,Ao=new WeakMap,Xe=new WeakSet,vl=function(){var c,u,h;const{activeServerURL:e,activeScreenID:n}=l(this,Pe).get(),i=e?l(this,Ue).servers.get(e)??null:null,s=i&&n?i.screens.get(n)??null:null,o=((c=l(this,Tt))==null?void 0:c.id)??null,a=(s==null?void 0:s.id)??null;o===a&&((u=l(this,Tt))==null?void 0:u.server)===i||((h=l(this,Tt))==null||h.dispose(),b(this,Tt,i&&s?new s$({screen:s,server:i,localStore:l(this,Pe)}):null),i&&i.acpClient.setScreenContext(s?{screenID:s.id,screenName:s.name}:null),this.dispatchEvent(new fT("active-screen-changed")))},gh=function(e){e!==l(this,Pe).get()&&(l(this,Pe).set(e),this.dispatchEvent(new gT("tabs-changed")))},_i=function(e,n){const i=he(e),s=l(this,Pe).get();if(s.activeServerURL===i&&s.activeScreenID===n)return!1;const o=n===null?{...s,activeServerURL:i,activeScreenID:n}:JT({...s,activeServerURL:i,activeScreenID:n},n);return l(this,Pe).set(o),!0};const zy="0123456789ABCDEFGHJKMNPQRSTVWXYZ",Zl=32,l$=16,Oy=10,Lg=0xffffffffffff;var Tn;(function(r){r.Base32IncorrectEncoding="B32_ENC_INVALID",r.DecodeTimeInvalidCharacter="DEC_TIME_CHAR",r.DecodeTimeValueMalformed="DEC_TIME_MALFORMED",r.EncodeTimeNegative="ENC_TIME_NEG",r.EncodeTimeSizeExceeded="ENC_TIME_SIZE_EXCEED",r.EncodeTimeValueMalformed="ENC_TIME_MALFORMED",r.PRNGDetectFailure="PRNG_DETECT",r.ULIDInvalid="ULID_INVALID",r.Unexpected="UNEXPECTED",r.UUIDInvalid="UUID_INVALID"})(Tn||(Tn={}));class qs extends Error{constructor(t,e){super(`${e} (${t})`),this.name="ULIDError",this.code=t}}function c$(r){const t=Math.floor(r()*Zl)%Zl;return zy.charAt(t)}function u$(r){const t=h$(),e=t&&(t.crypto||t.msCrypto)||null;if(typeof(e==null?void 0:e.getRandomValues)=="function")return()=>{const n=new Uint8Array(1);return e.getRandomValues(n),n[0]/256};if(typeof(e==null?void 0:e.randomBytes)=="function")return()=>e.randomBytes(1).readUInt8()/256;throw new qs(Tn.PRNGDetectFailure,"Failed to find a reliable PRNG")}function h$(){return f$()?self:typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:null}function d$(r,t){let e="";for(;r>0;r--)e=c$(t)+e;return e}function p$(r,t=Oy){if(isNaN(r))throw new qs(Tn.EncodeTimeValueMalformed,`Time must be a number: ${r}`);if(r>Lg)throw new qs(Tn.EncodeTimeSizeExceeded,`Cannot encode a time larger than ${Lg}: ${r}`);if(r<0)throw new qs(Tn.EncodeTimeNegative,`Time must be positive: ${r}`);if(Number.isInteger(r)===!1)throw new qs(Tn.EncodeTimeValueMalformed,`Time must be an integer: ${r}`);let e,n="";for(let i=t;i>0;i--)e=r%Zl,n=zy.charAt(e)+n,r=(r-e)/Zl;return n}function f$(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}function Ac(r,t){const e=u$(),n=Date.now();return p$(n,Oy)+d$(l$,e)}function A(r,t,e){function n(a,c){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:c,constr:o,traits:new Set},enumerable:!1}),a._zod.traits.has(r))return;a._zod.traits.add(r),t(a,c);const u=o.prototype,h=Object.keys(u);for(let f=0;f<h.length;f++){const y=h[f];y in a||(a[y]=u[y].bind(a))}}const i=(e==null?void 0:e.Parent)??Object;class s extends i{}Object.defineProperty(s,"name",{value:r});function o(a){var c;const u=e!=null&&e.Parent?new s:this;n(u,a),(c=u._zod).deferred??(c.deferred=[]);for(const h of u._zod.deferred)h();return u}return Object.defineProperty(o,"init",{value:n}),Object.defineProperty(o,Symbol.hasInstance,{value:a=>{var c,u;return e!=null&&e.Parent&&a instanceof e.Parent?!0:(u=(c=a==null?void 0:a._zod)==null?void 0:c.traits)==null?void 0:u.has(r)}}),Object.defineProperty(o,"name",{value:r}),o}class Oi extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class My extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const Ny={};function rn(r){return Ny}function Uy(r){const t=Object.values(r).filter(n=>typeof n=="number");return Object.entries(r).filter(([n,i])=>t.indexOf(+n)===-1).map(([n,i])=>i)}function mh(r,t){return typeof t=="bigint"?t.toString():t}function Tc(r){return{get value(){{const t=r();return Object.defineProperty(this,"value",{value:t}),t}}}}function Xd(r){return r==null}function Qd(r){const t=r.startsWith("^")?1:0,e=r.endsWith("$")?r.length-1:r.length;return r.slice(t,e)}function g$(r,t){const e=(r.toString().split(".")[1]||"").length,n=t.toString();let i=(n.split(".")[1]||"").length;if(i===0&&/\d?e-\d?/.test(n)){const c=n.match(/\d?e-(\d?)/);c!=null&&c[1]&&(i=Number.parseInt(c[1]))}const s=e>i?e:i,o=Number.parseInt(r.toFixed(s).replace(".","")),a=Number.parseInt(t.toFixed(s).replace(".",""));return o%a/10**s}const Dg=Symbol("evaluating");function te(r,t,e){let n;Object.defineProperty(r,t,{get(){if(n!==Dg)return n===void 0&&(n=Dg,n=e()),n},set(i){Object.defineProperty(r,t,{value:i})},configurable:!0})}function oi(r,t,e){Object.defineProperty(r,t,{value:e,writable:!0,enumerable:!0,configurable:!0})}function cn(...r){const t={};for(const e of r){const n=Object.getOwnPropertyDescriptors(e);Object.assign(t,n)}return Object.defineProperties({},t)}function zg(r){return JSON.stringify(r)}function m$(r){return r.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Fy="captureStackTrace"in Error?Error.captureStackTrace:(...r)=>{};function go(r){return typeof r=="object"&&r!==null&&!Array.isArray(r)}const v$=Tc(()=>{var r;if(typeof navigator<"u"&&((r=navigator==null?void 0:navigator.userAgent)!=null&&r.includes("Cloudflare")))return!1;try{const t=Function;return new t(""),!0}catch{return!1}});function fs(r){if(go(r)===!1)return!1;const t=r.constructor;if(t===void 0||typeof t!="function")return!0;const e=t.prototype;return!(go(e)===!1||Object.prototype.hasOwnProperty.call(e,"isPrototypeOf")===!1)}function Hy(r){return fs(r)?{...r}:Array.isArray(r)?[...r]:r}const y$=new Set(["string","number","symbol"]);function gs(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function un(r,t,e){const n=new r._zod.constr(t??r._zod.def);return(!t||e!=null&&e.parent)&&(n._zod.parent=r),n}function O(r){const t=r;if(!t)return{};if(typeof t=="string")return{error:()=>t};if((t==null?void 0:t.message)!==void 0){if((t==null?void 0:t.error)!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function b$(r){return Object.keys(r).filter(t=>r[t]._zod.optin==="optional"&&r[t]._zod.optout==="optional")}const w$={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$(r,t){const e=r._zod.def,n=e.checks;if(n&&n.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const s=cn(r._zod.def,{get shape(){const o={};for(const a in t){if(!(a in e.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&(o[a]=e.shape[a])}return oi(this,"shape",o),o},checks:[]});return un(r,s)}function _$(r,t){const e=r._zod.def,n=e.checks;if(n&&n.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const s=cn(r._zod.def,{get shape(){const o={...r._zod.def.shape};for(const a in t){if(!(a in e.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&delete o[a]}return oi(this,"shape",o),o},checks:[]});return un(r,s)}function k$(r,t){if(!fs(t))throw new Error("Invalid input to extend: expected a plain object");const e=r._zod.def.checks;if(e&&e.length>0){const s=r._zod.def.shape;for(const o in t)if(Object.getOwnPropertyDescriptor(s,o)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const i=cn(r._zod.def,{get shape(){const s={...r._zod.def.shape,...t};return oi(this,"shape",s),s}});return un(r,i)}function x$(r,t){if(!fs(t))throw new Error("Invalid input to safeExtend: expected a plain object");const e=cn(r._zod.def,{get shape(){const n={...r._zod.def.shape,...t};return oi(this,"shape",n),n}});return un(r,e)}function E$(r,t){const e=cn(r._zod.def,{get shape(){const n={...r._zod.def.shape,...t._zod.def.shape};return oi(this,"shape",n),n},get catchall(){return t._zod.def.catchall},checks:[]});return un(r,e)}function A$(r,t,e){const i=t._zod.def.checks;if(i&&i.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const o=cn(t._zod.def,{get shape(){const a=t._zod.def.shape,c={...a};if(e)for(const u in e){if(!(u in a))throw new Error(`Unrecognized key: "${u}"`);e[u]&&(c[u]=r?new r({type:"optional",innerType:a[u]}):a[u])}else for(const u in a)c[u]=r?new r({type:"optional",innerType:a[u]}):a[u];return oi(this,"shape",c),c},checks:[]});return un(t,o)}function T$(r,t,e){const n=cn(t._zod.def,{get shape(){const i=t._zod.def.shape,s={...i};if(e)for(const o in e){if(!(o in s))throw new Error(`Unrecognized key: "${o}"`);e[o]&&(s[o]=new r({type:"nonoptional",innerType:i[o]}))}else for(const o in i)s[o]=new r({type:"nonoptional",innerType:i[o]});return oi(this,"shape",s),s}});return un(t,n)}function Pi(r,t=0){var e;if(r.aborted===!0)return!0;for(let n=t;n<r.issues.length;n++)if(((e=r.issues[n])==null?void 0:e.continue)!==!0)return!0;return!1}function Li(r,t){return t.map(e=>{var n;return(n=e).path??(n.path=[]),e.path.unshift(r),e})}function el(r){return typeof r=="string"?r:r==null?void 0:r.message}function nn(r,t,e){var i,s,o,a,c,u;const n={...r,path:r.path??[]};if(!r.message){const h=el((o=(s=(i=r.inst)==null?void 0:i._zod.def)==null?void 0:s.error)==null?void 0:o.call(s,r))??el((a=t==null?void 0:t.error)==null?void 0:a.call(t,r))??el((c=e.customError)==null?void 0:c.call(e,r))??el((u=e.localeError)==null?void 0:u.call(e,r))??"Invalid input";n.message=h}return delete n.inst,delete n.continue,t!=null&&t.reportInput||delete n.input,n}function ep(r){return Array.isArray(r)?"array":typeof r=="string"?"string":"unknown"}function mo(...r){const[t,e,n]=r;return typeof t=="string"?{message:t,code:"custom",input:e,inst:n}:{...t}}const Zy=(r,t)=>{r.name="$ZodError",Object.defineProperty(r,"_zod",{value:r._zod,enumerable:!1}),Object.defineProperty(r,"issues",{value:t,enumerable:!1}),r.message=JSON.stringify(t,mh,2),Object.defineProperty(r,"toString",{value:()=>r.message,enumerable:!1})},Wy=A("$ZodError",Zy),By=A("$ZodError",Zy,{Parent:Error});function $$(r,t=e=>e.message){const e={},n=[];for(const i of r.issues)i.path.length>0?(e[i.path[0]]=e[i.path[0]]||[],e[i.path[0]].push(t(i))):n.push(t(i));return{formErrors:n,fieldErrors:e}}function I$(r,t=e=>e.message){const e={_errors:[]},n=i=>{for(const s of i.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(o=>n({issues:o}));else if(s.code==="invalid_key")n({issues:s.issues});else if(s.code==="invalid_element")n({issues:s.issues});else if(s.path.length===0)e._errors.push(t(s));else{let o=e,a=0;for(;a<s.path.length;){const c=s.path[a];a===s.path.length-1?(o[c]=o[c]||{_errors:[]},o[c]._errors.push(t(s))):o[c]=o[c]||{_errors:[]},o=o[c],a++}}};return n(r),e}const tp=r=>(t,e,n,i)=>{const s=n?Object.assign(n,{async:!1}):{async:!1},o=t._zod.run({value:e,issues:[]},s);if(o instanceof Promise)throw new Oi;if(o.issues.length){const a=new((i==null?void 0:i.Err)??r)(o.issues.map(c=>nn(c,s,rn())));throw Fy(a,i==null?void 0:i.callee),a}return o.value},rp=r=>async(t,e,n,i)=>{const s=n?Object.assign(n,{async:!0}):{async:!0};let o=t._zod.run({value:e,issues:[]},s);if(o instanceof Promise&&(o=await o),o.issues.length){const a=new((i==null?void 0:i.Err)??r)(o.issues.map(c=>nn(c,s,rn())));throw Fy(a,i==null?void 0:i.callee),a}return o.value},$c=r=>(t,e,n)=>{const i=n?{...n,async:!1}:{async:!1},s=t._zod.run({value:e,issues:[]},i);if(s instanceof Promise)throw new Oi;return s.issues.length?{success:!1,error:new(r??Wy)(s.issues.map(o=>nn(o,i,rn())))}:{success:!0,data:s.value}},C$=$c(By),Ic=r=>async(t,e,n)=>{const i=n?Object.assign(n,{async:!0}):{async:!0};let s=t._zod.run({value:e,issues:[]},i);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new r(s.issues.map(o=>nn(o,i,rn())))}:{success:!0,data:s.value}},R$=Ic(By),P$=r=>(t,e,n)=>{const i=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return tp(r)(t,e,i)},L$=r=>(t,e,n)=>tp(r)(t,e,n),D$=r=>async(t,e,n)=>{const i=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return rp(r)(t,e,i)},z$=r=>async(t,e,n)=>rp(r)(t,e,n),O$=r=>(t,e,n)=>{const i=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return $c(r)(t,e,i)},M$=r=>(t,e,n)=>$c(r)(t,e,n),N$=r=>async(t,e,n)=>{const i=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return Ic(r)(t,e,i)},U$=r=>async(t,e,n)=>Ic(r)(t,e,n),F$=/^[cC][^\s-]{8,}$/,H$=/^[0-9a-z]+$/,Z$=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,W$=/^[0-9a-vA-V]{20}$/,B$=/^[A-Za-z0-9]{27}$/,V$=/^[a-zA-Z0-9_-]{21}$/,j$=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,G$=/^([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})$/,Og=r=>r?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${r}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,q$=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Y$="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function K$(){return new RegExp(Y$,"u")}const J$=/^(?:(?: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])$/,X$=/^(([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}|:))$/,Q$=/^((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])$/,eI=/^(([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])$/,tI=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Vy=/^[A-Za-z0-9_-]*$/,rI=/^\+[1-9]\d{6,14}$/,jy="(?:(?:\\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])))",nI=new RegExp(`^${jy}$`);function Gy(r){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof r.precision=="number"?r.precision===-1?`${t}`:r.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${r.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function iI(r){return new RegExp(`^${Gy(r)}$`)}function sI(r){const t=Gy({precision:r.precision}),e=["Z"];r.local&&e.push(""),r.offset&&e.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const n=`${t}(?:${e.join("|")})`;return new RegExp(`^${jy}T(?:${n})$`)}const oI=r=>{const t=r?`[\\s\\S]{${(r==null?void 0:r.minimum)??0},${(r==null?void 0:r.maximum)??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},aI=/^-?\d+$/,qy=/^-?\d+(?:\.\d+)?$/,lI=/^(?:true|false)$/i,cI=/^[^A-Z]*$/,uI=/^[^a-z]*$/,ct=A("$ZodCheck",(r,t)=>{var e;r._zod??(r._zod={}),r._zod.def=t,(e=r._zod).onattach??(e.onattach=[])}),Yy={number:"number",bigint:"bigint",object:"date"},Ky=A("$ZodCheckLessThan",(r,t)=>{ct.init(r,t);const e=Yy[typeof t.value];r._zod.onattach.push(n=>{const i=n._zod.bag,s=(t.inclusive?i.maximum:i.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<s&&(t.inclusive?i.maximum=t.value:i.exclusiveMaximum=t.value)}),r._zod.check=n=>{(t.inclusive?n.value<=t.value:n.value<t.value)||n.issues.push({origin:e,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:r,continue:!t.abort})}}),Jy=A("$ZodCheckGreaterThan",(r,t)=>{ct.init(r,t);const e=Yy[typeof t.value];r._zod.onattach.push(n=>{const i=n._zod.bag,s=(t.inclusive?i.minimum:i.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>s&&(t.inclusive?i.minimum=t.value:i.exclusiveMinimum=t.value)}),r._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:e,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:r,continue:!t.abort})}}),hI=A("$ZodCheckMultipleOf",(r,t)=>{ct.init(r,t),r._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),r._zod.check=e=>{if(typeof e.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof e.value=="bigint"?e.value%t.value===BigInt(0):g$(e.value,t.value)===0)||e.issues.push({origin:typeof e.value,code:"not_multiple_of",divisor:t.value,input:e.value,inst:r,continue:!t.abort})}}),dI=A("$ZodCheckNumberFormat",(r,t)=>{var o;ct.init(r,t),t.format=t.format||"float64";const e=(o=t.format)==null?void 0:o.includes("int"),n=e?"int":"number",[i,s]=w$[t.format];r._zod.onattach.push(a=>{const c=a._zod.bag;c.format=t.format,c.minimum=i,c.maximum=s,e&&(c.pattern=aI)}),r._zod.check=a=>{const c=a.value;if(e){if(!Number.isInteger(c)){a.issues.push({expected:n,format:t.format,code:"invalid_type",continue:!1,input:c,inst:r});return}if(!Number.isSafeInteger(c)){c>0?a.issues.push({input:c,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:r,origin:n,inclusive:!0,continue:!t.abort}):a.issues.push({input:c,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:r,origin:n,inclusive:!0,continue:!t.abort});return}}c<i&&a.issues.push({origin:"number",input:c,code:"too_small",minimum:i,inclusive:!0,inst:r,continue:!t.abort}),c>s&&a.issues.push({origin:"number",input:c,code:"too_big",maximum:s,inclusive:!0,inst:r,continue:!t.abort})}}),pI=A("$ZodCheckMaxLength",(r,t)=>{var e;ct.init(r,t),(e=r._zod.def).when??(e.when=n=>{const i=n.value;return!Xd(i)&&i.length!==void 0}),r._zod.onattach.push(n=>{const i=n._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<i&&(n._zod.bag.maximum=t.maximum)}),r._zod.check=n=>{const i=n.value;if(i.length<=t.maximum)return;const o=ep(i);n.issues.push({origin:o,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:r,continue:!t.abort})}}),fI=A("$ZodCheckMinLength",(r,t)=>{var e;ct.init(r,t),(e=r._zod.def).when??(e.when=n=>{const i=n.value;return!Xd(i)&&i.length!==void 0}),r._zod.onattach.push(n=>{const i=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>i&&(n._zod.bag.minimum=t.minimum)}),r._zod.check=n=>{const i=n.value;if(i.length>=t.minimum)return;const o=ep(i);n.issues.push({origin:o,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:r,continue:!t.abort})}}),gI=A("$ZodCheckLengthEquals",(r,t)=>{var e;ct.init(r,t),(e=r._zod.def).when??(e.when=n=>{const i=n.value;return!Xd(i)&&i.length!==void 0}),r._zod.onattach.push(n=>{const i=n._zod.bag;i.minimum=t.length,i.maximum=t.length,i.length=t.length}),r._zod.check=n=>{const i=n.value,s=i.length;if(s===t.length)return;const o=ep(i),a=s>t.length;n.issues.push({origin:o,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:r,continue:!t.abort})}}),Cc=A("$ZodCheckStringFormat",(r,t)=>{var e,n;ct.init(r,t),r._zod.onattach.push(i=>{const s=i._zod.bag;s.format=t.format,t.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(t.pattern))}),t.pattern?(e=r._zod).check??(e.check=i=>{t.pattern.lastIndex=0,!t.pattern.test(i.value)&&i.issues.push({origin:"string",code:"invalid_format",format:t.format,input:i.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:r,continue:!t.abort})}):(n=r._zod).check??(n.check=()=>{})}),mI=A("$ZodCheckRegex",(r,t)=>{Cc.init(r,t),r._zod.check=e=>{t.pattern.lastIndex=0,!t.pattern.test(e.value)&&e.issues.push({origin:"string",code:"invalid_format",format:"regex",input:e.value,pattern:t.pattern.toString(),inst:r,continue:!t.abort})}}),vI=A("$ZodCheckLowerCase",(r,t)=>{t.pattern??(t.pattern=cI),Cc.init(r,t)}),yI=A("$ZodCheckUpperCase",(r,t)=>{t.pattern??(t.pattern=uI),Cc.init(r,t)}),bI=A("$ZodCheckIncludes",(r,t)=>{ct.init(r,t);const e=gs(t.includes),n=new RegExp(typeof t.position=="number"?`^.{${t.position}}${e}`:e);t.pattern=n,r._zod.onattach.push(i=>{const s=i._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(n)}),r._zod.check=i=>{i.value.includes(t.includes,t.position)||i.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:i.value,inst:r,continue:!t.abort})}}),wI=A("$ZodCheckStartsWith",(r,t)=>{ct.init(r,t);const e=new RegExp(`^${gs(t.prefix)}.*`);t.pattern??(t.pattern=e),r._zod.onattach.push(n=>{const i=n._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(e)}),r._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:r,continue:!t.abort})}}),SI=A("$ZodCheckEndsWith",(r,t)=>{ct.init(r,t);const e=new RegExp(`.*${gs(t.suffix)}$`);t.pattern??(t.pattern=e),r._zod.onattach.push(n=>{const i=n._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(e)}),r._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:r,continue:!t.abort})}}),_I=A("$ZodCheckOverwrite",(r,t)=>{ct.init(r,t),r._zod.check=e=>{e.value=t.tx(e.value)}});class kI{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const n=t.split(`
|
|
5
|
-
`).filter(o=>o),i=Math.min(...n.map(o=>o.length-o.trimStart().length)),s=n.map(o=>o.slice(i)).map(o=>" ".repeat(this.indent*2)+o);for(const o of s)this.content.push(o)}compile(){const t=Function,e=this==null?void 0:this.args,i=[...((this==null?void 0:this.content)??[""]).map(s=>` ${s}`)];return new t(...e,i.join(`
|
|
6
|
-
`))}}const xI={major:4,minor:3,patch:6},ve=A("$ZodType",(r,t)=>{var i;var e;r??(r={}),r._zod.def=t,r._zod.bag=r._zod.bag||{},r._zod.version=xI;const n=[...r._zod.def.checks??[]];r._zod.traits.has("$ZodCheck")&&n.unshift(r);for(const s of n)for(const o of s._zod.onattach)o(r);if(n.length===0)(e=r._zod).deferred??(e.deferred=[]),(i=r._zod.deferred)==null||i.push(()=>{r._zod.run=r._zod.parse});else{const s=(a,c,u)=>{let h=Pi(a),f;for(const y of c){if(y._zod.def.when){if(!y._zod.def.when(a))continue}else if(h)continue;const m=a.issues.length,E=y._zod.check(a);if(E instanceof Promise&&(u==null?void 0:u.async)===!1)throw new Oi;if(f||E instanceof Promise)f=(f??Promise.resolve()).then(async()=>{await E,a.issues.length!==m&&(h||(h=Pi(a,m)))});else{if(a.issues.length===m)continue;h||(h=Pi(a,m))}}return f?f.then(()=>a):a},o=(a,c,u)=>{if(Pi(a))return a.aborted=!0,a;const h=s(c,n,u);if(h instanceof Promise){if(u.async===!1)throw new Oi;return h.then(f=>r._zod.parse(f,u))}return r._zod.parse(h,u)};r._zod.run=(a,c)=>{if(c.skipChecks)return r._zod.parse(a,c);if(c.direction==="backward"){const h=r._zod.parse({value:a.value,issues:[]},{...c,skipChecks:!0});return h instanceof Promise?h.then(f=>o(f,a,c)):o(h,a,c)}const u=r._zod.parse(a,c);if(u instanceof Promise){if(c.async===!1)throw new Oi;return u.then(h=>s(h,n,c))}return s(u,n,c)}}te(r,"~standard",()=>({validate:s=>{var o;try{const a=C$(r,s);return a.success?{value:a.data}:{issues:(o=a.error)==null?void 0:o.issues}}catch{return R$(r,s).then(c=>{var u;return c.success?{value:c.data}:{issues:(u=c.error)==null?void 0:u.issues}})}},vendor:"zod",version:1}))}),np=A("$ZodString",(r,t)=>{var e;ve.init(r,t),r._zod.pattern=[...((e=r==null?void 0:r._zod.bag)==null?void 0:e.patterns)??[]].pop()??oI(r._zod.bag),r._zod.parse=(n,i)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:r}),n}}),ge=A("$ZodStringFormat",(r,t)=>{Cc.init(r,t),np.init(r,t)}),EI=A("$ZodGUID",(r,t)=>{t.pattern??(t.pattern=G$),ge.init(r,t)}),AI=A("$ZodUUID",(r,t)=>{if(t.version){const n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(n===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Og(n))}else t.pattern??(t.pattern=Og());ge.init(r,t)}),TI=A("$ZodEmail",(r,t)=>{t.pattern??(t.pattern=q$),ge.init(r,t)}),$I=A("$ZodURL",(r,t)=>{ge.init(r,t),r._zod.check=e=>{try{const n=e.value.trim(),i=new URL(n);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||e.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:e.value,inst:r,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(":")?i.protocol.slice(0,-1):i.protocol)||e.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:e.value,inst:r,continue:!t.abort})),t.normalize?e.value=i.href:e.value=n;return}catch{e.issues.push({code:"invalid_format",format:"url",input:e.value,inst:r,continue:!t.abort})}}}),II=A("$ZodEmoji",(r,t)=>{t.pattern??(t.pattern=K$()),ge.init(r,t)}),CI=A("$ZodNanoID",(r,t)=>{t.pattern??(t.pattern=V$),ge.init(r,t)}),RI=A("$ZodCUID",(r,t)=>{t.pattern??(t.pattern=F$),ge.init(r,t)}),PI=A("$ZodCUID2",(r,t)=>{t.pattern??(t.pattern=H$),ge.init(r,t)}),LI=A("$ZodULID",(r,t)=>{t.pattern??(t.pattern=Z$),ge.init(r,t)}),DI=A("$ZodXID",(r,t)=>{t.pattern??(t.pattern=W$),ge.init(r,t)}),zI=A("$ZodKSUID",(r,t)=>{t.pattern??(t.pattern=B$),ge.init(r,t)}),OI=A("$ZodISODateTime",(r,t)=>{t.pattern??(t.pattern=sI(t)),ge.init(r,t)}),MI=A("$ZodISODate",(r,t)=>{t.pattern??(t.pattern=nI),ge.init(r,t)}),NI=A("$ZodISOTime",(r,t)=>{t.pattern??(t.pattern=iI(t)),ge.init(r,t)}),UI=A("$ZodISODuration",(r,t)=>{t.pattern??(t.pattern=j$),ge.init(r,t)}),FI=A("$ZodIPv4",(r,t)=>{t.pattern??(t.pattern=J$),ge.init(r,t),r._zod.bag.format="ipv4"}),HI=A("$ZodIPv6",(r,t)=>{t.pattern??(t.pattern=X$),ge.init(r,t),r._zod.bag.format="ipv6",r._zod.check=e=>{try{new URL(`http://[${e.value}]`)}catch{e.issues.push({code:"invalid_format",format:"ipv6",input:e.value,inst:r,continue:!t.abort})}}}),ZI=A("$ZodCIDRv4",(r,t)=>{t.pattern??(t.pattern=Q$),ge.init(r,t)}),WI=A("$ZodCIDRv6",(r,t)=>{t.pattern??(t.pattern=eI),ge.init(r,t),r._zod.check=e=>{const n=e.value.split("/");try{if(n.length!==2)throw new Error;const[i,s]=n;if(!s)throw new Error;const o=Number(s);if(`${o}`!==s)throw new Error;if(o<0||o>128)throw new Error;new URL(`http://[${i}]`)}catch{e.issues.push({code:"invalid_format",format:"cidrv6",input:e.value,inst:r,continue:!t.abort})}}});function Xy(r){if(r==="")return!0;if(r.length%4!==0)return!1;try{return atob(r),!0}catch{return!1}}const BI=A("$ZodBase64",(r,t)=>{t.pattern??(t.pattern=tI),ge.init(r,t),r._zod.bag.contentEncoding="base64",r._zod.check=e=>{Xy(e.value)||e.issues.push({code:"invalid_format",format:"base64",input:e.value,inst:r,continue:!t.abort})}});function VI(r){if(!Vy.test(r))return!1;const t=r.replace(/[-_]/g,n=>n==="-"?"+":"/"),e=t.padEnd(Math.ceil(t.length/4)*4,"=");return Xy(e)}const jI=A("$ZodBase64URL",(r,t)=>{t.pattern??(t.pattern=Vy),ge.init(r,t),r._zod.bag.contentEncoding="base64url",r._zod.check=e=>{VI(e.value)||e.issues.push({code:"invalid_format",format:"base64url",input:e.value,inst:r,continue:!t.abort})}}),GI=A("$ZodE164",(r,t)=>{t.pattern??(t.pattern=rI),ge.init(r,t)});function qI(r,t=null){try{const e=r.split(".");if(e.length!==3)return!1;const[n]=e;if(!n)return!1;const i=JSON.parse(atob(n));return!("typ"in i&&(i==null?void 0:i.typ)!=="JWT"||!i.alg||t&&(!("alg"in i)||i.alg!==t))}catch{return!1}}const YI=A("$ZodJWT",(r,t)=>{ge.init(r,t),r._zod.check=e=>{qI(e.value,t.alg)||e.issues.push({code:"invalid_format",format:"jwt",input:e.value,inst:r,continue:!t.abort})}}),Qy=A("$ZodNumber",(r,t)=>{ve.init(r,t),r._zod.pattern=r._zod.bag.pattern??qy,r._zod.parse=(e,n)=>{if(t.coerce)try{e.value=Number(e.value)}catch{}const i=e.value;if(typeof i=="number"&&!Number.isNaN(i)&&Number.isFinite(i))return e;const s=typeof i=="number"?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:"Infinity":void 0;return e.issues.push({expected:"number",code:"invalid_type",input:i,inst:r,...s?{received:s}:{}}),e}}),KI=A("$ZodNumberFormat",(r,t)=>{dI.init(r,t),Qy.init(r,t)}),JI=A("$ZodBoolean",(r,t)=>{ve.init(r,t),r._zod.pattern=lI,r._zod.parse=(e,n)=>{if(t.coerce)try{e.value=!!e.value}catch{}const i=e.value;return typeof i=="boolean"||e.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:r}),e}}),XI=A("$ZodUnknown",(r,t)=>{ve.init(r,t),r._zod.parse=e=>e}),QI=A("$ZodNever",(r,t)=>{ve.init(r,t),r._zod.parse=(e,n)=>(e.issues.push({expected:"never",code:"invalid_type",input:e.value,inst:r}),e)});function Mg(r,t,e){r.issues.length&&t.issues.push(...Li(e,r.issues)),t.value[e]=r.value}const eC=A("$ZodArray",(r,t)=>{ve.init(r,t),r._zod.parse=(e,n)=>{const i=e.value;if(!Array.isArray(i))return e.issues.push({expected:"array",code:"invalid_type",input:i,inst:r}),e;e.value=Array(i.length);const s=[];for(let o=0;o<i.length;o++){const a=i[o],c=t.element._zod.run({value:a,issues:[]},n);c instanceof Promise?s.push(c.then(u=>Mg(u,e,o))):Mg(c,e,o)}return s.length?Promise.all(s).then(()=>e):e}});function Wl(r,t,e,n,i){if(r.issues.length){if(i&&!(e in n))return;t.issues.push(...Li(e,r.issues))}r.value===void 0?e in n&&(t.value[e]=void 0):t.value[e]=r.value}function eb(r){var n,i,s,o;const t=Object.keys(r.shape);for(const a of t)if(!((o=(s=(i=(n=r.shape)==null?void 0:n[a])==null?void 0:i._zod)==null?void 0:s.traits)!=null&&o.has("$ZodType")))throw new Error(`Invalid element at key "${a}": expected a Zod schema`);const e=b$(r.shape);return{...r,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(e)}}function tb(r,t,e,n,i,s){const o=[],a=i.keySet,c=i.catchall._zod,u=c.def.type,h=c.optout==="optional";for(const f in t){if(a.has(f))continue;if(u==="never"){o.push(f);continue}const y=c.run({value:t[f],issues:[]},n);y instanceof Promise?r.push(y.then(m=>Wl(m,e,f,t,h))):Wl(y,e,f,t,h)}return o.length&&e.issues.push({code:"unrecognized_keys",keys:o,input:t,inst:s}),r.length?Promise.all(r).then(()=>e):e}const tC=A("$ZodObject",(r,t)=>{ve.init(r,t);const e=Object.getOwnPropertyDescriptor(t,"shape");if(!(e!=null&&e.get)){const a=t.shape;Object.defineProperty(t,"shape",{get:()=>{const c={...a};return Object.defineProperty(t,"shape",{value:c}),c}})}const n=Tc(()=>eb(t));te(r._zod,"propValues",()=>{const a=t.shape,c={};for(const u in a){const h=a[u]._zod;if(h.values){c[u]??(c[u]=new Set);for(const f of h.values)c[u].add(f)}}return c});const i=go,s=t.catchall;let o;r._zod.parse=(a,c)=>{o??(o=n.value);const u=a.value;if(!i(u))return a.issues.push({expected:"object",code:"invalid_type",input:u,inst:r}),a;a.value={};const h=[],f=o.shape;for(const y of o.keys){const m=f[y],E=m._zod.optout==="optional",x=m._zod.run({value:u[y],issues:[]},c);x instanceof Promise?h.push(x.then(I=>Wl(I,a,y,u,E))):Wl(x,a,y,u,E)}return s?tb(h,u,a,c,n.value,r):h.length?Promise.all(h).then(()=>a):a}}),rC=A("$ZodObjectJIT",(r,t)=>{tC.init(r,t);const e=r._zod.parse,n=Tc(()=>eb(t)),i=y=>{var B;const m=new kI(["shape","payload","ctx"]),E=n.value,x=N=>{const F=zg(N);return`shape[${F}]._zod.run({ value: input[${F}], issues: [] }, ctx)`};m.write("const input = payload.value;");const I=Object.create(null);let P=0;for(const N of E.keys)I[N]=`key_${P++}`;m.write("const newResult = {};");for(const N of E.keys){const F=I[N],Y=zg(N),j=y[N],ce=((B=j==null?void 0:j._zod)==null?void 0:B.optout)==="optional";m.write(`const ${F} = ${x(N)};`),ce?m.write(`
|
|
7
|
-
if (${F}.issues.length) {
|
|
8
|
-
if (${Y} in input) {
|
|
9
|
-
payload.issues = payload.issues.concat(${F}.issues.map(iss => ({
|
|
10
|
-
...iss,
|
|
11
|
-
path: iss.path ? [${Y}, ...iss.path] : [${Y}]
|
|
12
|
-
})));
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
if (${F}.value === undefined) {
|
|
17
|
-
if (${Y} in input) {
|
|
18
|
-
newResult[${Y}] = undefined;
|
|
19
|
-
}
|
|
20
|
-
} else {
|
|
21
|
-
newResult[${Y}] = ${F}.value;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
`):m.write(`
|
|
25
|
-
if (${F}.issues.length) {
|
|
26
|
-
payload.issues = payload.issues.concat(${F}.issues.map(iss => ({
|
|
27
|
-
...iss,
|
|
28
|
-
path: iss.path ? [${Y}, ...iss.path] : [${Y}]
|
|
29
|
-
})));
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if (${F}.value === undefined) {
|
|
33
|
-
if (${Y} in input) {
|
|
34
|
-
newResult[${Y}] = undefined;
|
|
35
|
-
}
|
|
36
|
-
} else {
|
|
37
|
-
newResult[${Y}] = ${F}.value;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
`)}m.write("payload.value = newResult;"),m.write("return payload;");const R=m.compile();return(N,F)=>R(y,N,F)};let s;const o=go,a=!Ny.jitless,u=a&&v$.value,h=t.catchall;let f;r._zod.parse=(y,m)=>{f??(f=n.value);const E=y.value;return o(E)?a&&u&&(m==null?void 0:m.async)===!1&&m.jitless!==!0?(s||(s=i(t.shape)),y=s(y,m),h?tb([],E,y,m,f,r):y):e(y,m):(y.issues.push({expected:"object",code:"invalid_type",input:E,inst:r}),y)}});function Ng(r,t,e,n){for(const s of r)if(s.issues.length===0)return t.value=s.value,t;const i=r.filter(s=>!Pi(s));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:e,errors:r.map(s=>s.issues.map(o=>nn(o,n,rn())))}),t)}const rb=A("$ZodUnion",(r,t)=>{ve.init(r,t),te(r._zod,"optin",()=>t.options.some(i=>i._zod.optin==="optional")?"optional":void 0),te(r._zod,"optout",()=>t.options.some(i=>i._zod.optout==="optional")?"optional":void 0),te(r._zod,"values",()=>{if(t.options.every(i=>i._zod.values))return new Set(t.options.flatMap(i=>Array.from(i._zod.values)))}),te(r._zod,"pattern",()=>{if(t.options.every(i=>i._zod.pattern)){const i=t.options.map(s=>s._zod.pattern);return new RegExp(`^(${i.map(s=>Qd(s.source)).join("|")})$`)}});const e=t.options.length===1,n=t.options[0]._zod.run;r._zod.parse=(i,s)=>{if(e)return n(i,s);let o=!1;const a=[];for(const c of t.options){const u=c._zod.run({value:i.value,issues:[]},s);if(u instanceof Promise)a.push(u),o=!0;else{if(u.issues.length===0)return u;a.push(u)}}return o?Promise.all(a).then(c=>Ng(c,i,r,s)):Ng(a,i,r,s)}}),nC=A("$ZodDiscriminatedUnion",(r,t)=>{t.inclusive=!1,rb.init(r,t);const e=r._zod.parse;te(r._zod,"propValues",()=>{const i={};for(const s of t.options){const o=s._zod.propValues;if(!o||Object.keys(o).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(s)}"`);for(const[a,c]of Object.entries(o)){i[a]||(i[a]=new Set);for(const u of c)i[a].add(u)}}return i});const n=Tc(()=>{var o;const i=t.options,s=new Map;for(const a of i){const c=(o=a._zod.propValues)==null?void 0:o[t.discriminator];if(!c||c.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(a)}"`);for(const u of c){if(s.has(u))throw new Error(`Duplicate discriminator value "${String(u)}"`);s.set(u,a)}}return s});r._zod.parse=(i,s)=>{const o=i.value;if(!go(o))return i.issues.push({code:"invalid_type",expected:"object",input:o,inst:r}),i;const a=n.value.get(o==null?void 0:o[t.discriminator]);return a?a._zod.run(i,s):t.unionFallback?e(i,s):(i.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,input:o,path:[t.discriminator],inst:r}),i)}}),iC=A("$ZodIntersection",(r,t)=>{ve.init(r,t),r._zod.parse=(e,n)=>{const i=e.value,s=t.left._zod.run({value:i,issues:[]},n),o=t.right._zod.run({value:i,issues:[]},n);return s instanceof Promise||o instanceof Promise?Promise.all([s,o]).then(([c,u])=>Ug(e,c,u)):Ug(e,s,o)}});function vh(r,t){if(r===t)return{valid:!0,data:r};if(r instanceof Date&&t instanceof Date&&+r==+t)return{valid:!0,data:r};if(fs(r)&&fs(t)){const e=Object.keys(t),n=Object.keys(r).filter(s=>e.indexOf(s)!==-1),i={...r,...t};for(const s of n){const o=vh(r[s],t[s]);if(!o.valid)return{valid:!1,mergeErrorPath:[s,...o.mergeErrorPath]};i[s]=o.data}return{valid:!0,data:i}}if(Array.isArray(r)&&Array.isArray(t)){if(r.length!==t.length)return{valid:!1,mergeErrorPath:[]};const e=[];for(let n=0;n<r.length;n++){const i=r[n],s=t[n],o=vh(i,s);if(!o.valid)return{valid:!1,mergeErrorPath:[n,...o.mergeErrorPath]};e.push(o.data)}return{valid:!0,data:e}}return{valid:!1,mergeErrorPath:[]}}function Ug(r,t,e){const n=new Map;let i;for(const a of t.issues)if(a.code==="unrecognized_keys"){i??(i=a);for(const c of a.keys)n.has(c)||n.set(c,{}),n.get(c).l=!0}else r.issues.push(a);for(const a of e.issues)if(a.code==="unrecognized_keys")for(const c of a.keys)n.has(c)||n.set(c,{}),n.get(c).r=!0;else r.issues.push(a);const s=[...n].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(s.length&&i&&r.issues.push({...i,keys:s}),Pi(r))return r;const o=vh(t.value,e.value);if(!o.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return r.value=o.data,r}const sC=A("$ZodRecord",(r,t)=>{ve.init(r,t),r._zod.parse=(e,n)=>{const i=e.value;if(!fs(i))return e.issues.push({expected:"record",code:"invalid_type",input:i,inst:r}),e;const s=[],o=t.keyType._zod.values;if(o){e.value={};const a=new Set;for(const u of o)if(typeof u=="string"||typeof u=="number"||typeof u=="symbol"){a.add(typeof u=="number"?u.toString():u);const h=t.valueType._zod.run({value:i[u],issues:[]},n);h instanceof Promise?s.push(h.then(f=>{f.issues.length&&e.issues.push(...Li(u,f.issues)),e.value[u]=f.value})):(h.issues.length&&e.issues.push(...Li(u,h.issues)),e.value[u]=h.value)}let c;for(const u in i)a.has(u)||(c=c??[],c.push(u));c&&c.length>0&&e.issues.push({code:"unrecognized_keys",input:i,inst:r,keys:c})}else{e.value={};for(const a of Reflect.ownKeys(i)){if(a==="__proto__")continue;let c=t.keyType._zod.run({value:a,issues:[]},n);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof a=="string"&&qy.test(a)&&c.issues.length){const f=t.keyType._zod.run({value:Number(a),issues:[]},n);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){t.mode==="loose"?e.value[a]=i[a]:e.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(f=>nn(f,n,rn())),input:a,path:[a],inst:r});continue}const h=t.valueType._zod.run({value:i[a],issues:[]},n);h instanceof Promise?s.push(h.then(f=>{f.issues.length&&e.issues.push(...Li(a,f.issues)),e.value[c.value]=f.value})):(h.issues.length&&e.issues.push(...Li(a,h.issues)),e.value[c.value]=h.value)}}return s.length?Promise.all(s).then(()=>e):e}}),oC=A("$ZodEnum",(r,t)=>{ve.init(r,t);const e=Uy(t.entries),n=new Set(e);r._zod.values=n,r._zod.pattern=new RegExp(`^(${e.filter(i=>y$.has(typeof i)).map(i=>typeof i=="string"?gs(i):i.toString()).join("|")})$`),r._zod.parse=(i,s)=>{const o=i.value;return n.has(o)||i.issues.push({code:"invalid_value",values:e,input:o,inst:r}),i}}),aC=A("$ZodLiteral",(r,t)=>{if(ve.init(r,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");const e=new Set(t.values);r._zod.values=e,r._zod.pattern=new RegExp(`^(${t.values.map(n=>typeof n=="string"?gs(n):n?gs(n.toString()):String(n)).join("|")})$`),r._zod.parse=(n,i)=>{const s=n.value;return e.has(s)||n.issues.push({code:"invalid_value",values:t.values,input:s,inst:r}),n}}),lC=A("$ZodTransform",(r,t)=>{ve.init(r,t),r._zod.parse=(e,n)=>{if(n.direction==="backward")throw new My(r.constructor.name);const i=t.transform(e.value,e);if(n.async)return(i instanceof Promise?i:Promise.resolve(i)).then(o=>(e.value=o,e));if(i instanceof Promise)throw new Oi;return e.value=i,e}});function Fg(r,t){return r.issues.length&&t===void 0?{issues:[],value:void 0}:r}const nb=A("$ZodOptional",(r,t)=>{ve.init(r,t),r._zod.optin="optional",r._zod.optout="optional",te(r._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),te(r._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${Qd(e.source)})?$`):void 0}),r._zod.parse=(e,n)=>{if(t.innerType._zod.optin==="optional"){const i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(s=>Fg(s,e.value)):Fg(i,e.value)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),cC=A("$ZodExactOptional",(r,t)=>{nb.init(r,t),te(r._zod,"values",()=>t.innerType._zod.values),te(r._zod,"pattern",()=>t.innerType._zod.pattern),r._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),uC=A("$ZodNullable",(r,t)=>{ve.init(r,t),te(r._zod,"optin",()=>t.innerType._zod.optin),te(r._zod,"optout",()=>t.innerType._zod.optout),te(r._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${Qd(e.source)}|null)$`):void 0}),te(r._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),r._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),hC=A("$ZodDefault",(r,t)=>{ve.init(r,t),r._zod.optin="optional",te(r._zod,"values",()=>t.innerType._zod.values),r._zod.parse=(e,n)=>{if(n.direction==="backward")return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;const i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(s=>Hg(s,t)):Hg(i,t)}});function Hg(r,t){return r.value===void 0&&(r.value=t.defaultValue),r}const dC=A("$ZodPrefault",(r,t)=>{ve.init(r,t),r._zod.optin="optional",te(r._zod,"values",()=>t.innerType._zod.values),r._zod.parse=(e,n)=>(n.direction==="backward"||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),pC=A("$ZodNonOptional",(r,t)=>{ve.init(r,t),te(r._zod,"values",()=>{const e=t.innerType._zod.values;return e?new Set([...e].filter(n=>n!==void 0)):void 0}),r._zod.parse=(e,n)=>{const i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(s=>Zg(s,r)):Zg(i,r)}});function Zg(r,t){return!r.issues.length&&r.value===void 0&&r.issues.push({code:"invalid_type",expected:"nonoptional",input:r.value,inst:t}),r}const fC=A("$ZodCatch",(r,t)=>{ve.init(r,t),te(r._zod,"optin",()=>t.innerType._zod.optin),te(r._zod,"optout",()=>t.innerType._zod.optout),te(r._zod,"values",()=>t.innerType._zod.values),r._zod.parse=(e,n)=>{if(n.direction==="backward")return t.innerType._zod.run(e,n);const i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(s=>(e.value=s.value,s.issues.length&&(e.value=t.catchValue({...e,error:{issues:s.issues.map(o=>nn(o,n,rn()))},input:e.value}),e.issues=[]),e)):(e.value=i.value,i.issues.length&&(e.value=t.catchValue({...e,error:{issues:i.issues.map(s=>nn(s,n,rn()))},input:e.value}),e.issues=[]),e)}}),gC=A("$ZodPipe",(r,t)=>{ve.init(r,t),te(r._zod,"values",()=>t.in._zod.values),te(r._zod,"optin",()=>t.in._zod.optin),te(r._zod,"optout",()=>t.out._zod.optout),te(r._zod,"propValues",()=>t.in._zod.propValues),r._zod.parse=(e,n)=>{if(n.direction==="backward"){const s=t.out._zod.run(e,n);return s instanceof Promise?s.then(o=>tl(o,t.in,n)):tl(s,t.in,n)}const i=t.in._zod.run(e,n);return i instanceof Promise?i.then(s=>tl(s,t.out,n)):tl(i,t.out,n)}});function tl(r,t,e){return r.issues.length?(r.aborted=!0,r):t._zod.run({value:r.value,issues:r.issues},e)}const mC=A("$ZodReadonly",(r,t)=>{ve.init(r,t),te(r._zod,"propValues",()=>t.innerType._zod.propValues),te(r._zod,"values",()=>t.innerType._zod.values),te(r._zod,"optin",()=>{var e,n;return(n=(e=t.innerType)==null?void 0:e._zod)==null?void 0:n.optin}),te(r._zod,"optout",()=>{var e,n;return(n=(e=t.innerType)==null?void 0:e._zod)==null?void 0:n.optout}),r._zod.parse=(e,n)=>{if(n.direction==="backward")return t.innerType._zod.run(e,n);const i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(Wg):Wg(i)}});function Wg(r){return r.value=Object.freeze(r.value),r}const vC=A("$ZodCustom",(r,t)=>{ct.init(r,t),ve.init(r,t),r._zod.parse=(e,n)=>e,r._zod.check=e=>{const n=e.value,i=t.fn(n);if(i instanceof Promise)return i.then(s=>Bg(s,e,n,r));Bg(i,e,n,r)}});function Bg(r,t,e,n){if(!r){const i={code:"custom",input:e,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(i.params=n._zod.def.params),t.issues.push(mo(i))}}var Vg;class yC{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...e){const n=e[0];return this._map.set(t,n),n&&typeof n=="object"&&"id"in n&&this._idmap.set(n.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const e=this._map.get(t);return e&&typeof e=="object"&&"id"in e&&this._idmap.delete(e.id),this._map.delete(t),this}get(t){const e=t._zod.parent;if(e){const n={...this.get(e)??{}};delete n.id;const i={...n,...this._map.get(t)};return Object.keys(i).length?i:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function bC(){return new yC}(Vg=globalThis).__zod_globalRegistry??(Vg.__zod_globalRegistry=bC());const Ys=globalThis.__zod_globalRegistry;function wC(r,t){return new r({type:"string",...O(t)})}function SC(r,t){return new r({type:"string",format:"email",check:"string_format",abort:!1,...O(t)})}function jg(r,t){return new r({type:"string",format:"guid",check:"string_format",abort:!1,...O(t)})}function _C(r,t){return new r({type:"string",format:"uuid",check:"string_format",abort:!1,...O(t)})}function kC(r,t){return new r({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...O(t)})}function xC(r,t){return new r({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...O(t)})}function EC(r,t){return new r({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...O(t)})}function AC(r,t){return new r({type:"string",format:"url",check:"string_format",abort:!1,...O(t)})}function TC(r,t){return new r({type:"string",format:"emoji",check:"string_format",abort:!1,...O(t)})}function $C(r,t){return new r({type:"string",format:"nanoid",check:"string_format",abort:!1,...O(t)})}function IC(r,t){return new r({type:"string",format:"cuid",check:"string_format",abort:!1,...O(t)})}function CC(r,t){return new r({type:"string",format:"cuid2",check:"string_format",abort:!1,...O(t)})}function RC(r,t){return new r({type:"string",format:"ulid",check:"string_format",abort:!1,...O(t)})}function PC(r,t){return new r({type:"string",format:"xid",check:"string_format",abort:!1,...O(t)})}function LC(r,t){return new r({type:"string",format:"ksuid",check:"string_format",abort:!1,...O(t)})}function DC(r,t){return new r({type:"string",format:"ipv4",check:"string_format",abort:!1,...O(t)})}function zC(r,t){return new r({type:"string",format:"ipv6",check:"string_format",abort:!1,...O(t)})}function OC(r,t){return new r({type:"string",format:"cidrv4",check:"string_format",abort:!1,...O(t)})}function MC(r,t){return new r({type:"string",format:"cidrv6",check:"string_format",abort:!1,...O(t)})}function NC(r,t){return new r({type:"string",format:"base64",check:"string_format",abort:!1,...O(t)})}function UC(r,t){return new r({type:"string",format:"base64url",check:"string_format",abort:!1,...O(t)})}function FC(r,t){return new r({type:"string",format:"e164",check:"string_format",abort:!1,...O(t)})}function HC(r,t){return new r({type:"string",format:"jwt",check:"string_format",abort:!1,...O(t)})}function ZC(r,t){return new r({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...O(t)})}function WC(r,t){return new r({type:"string",format:"date",check:"string_format",...O(t)})}function BC(r,t){return new r({type:"string",format:"time",check:"string_format",precision:null,...O(t)})}function VC(r,t){return new r({type:"string",format:"duration",check:"string_format",...O(t)})}function jC(r,t){return new r({type:"number",checks:[],...O(t)})}function GC(r,t){return new r({type:"number",check:"number_format",abort:!1,format:"safeint",...O(t)})}function qC(r,t){return new r({type:"boolean",...O(t)})}function YC(r){return new r({type:"unknown"})}function KC(r,t){return new r({type:"never",...O(t)})}function Gg(r,t){return new Ky({check:"less_than",...O(t),value:r,inclusive:!1})}function Ru(r,t){return new Ky({check:"less_than",...O(t),value:r,inclusive:!0})}function qg(r,t){return new Jy({check:"greater_than",...O(t),value:r,inclusive:!1})}function Pu(r,t){return new Jy({check:"greater_than",...O(t),value:r,inclusive:!0})}function Yg(r,t){return new hI({check:"multiple_of",...O(t),value:r})}function ib(r,t){return new pI({check:"max_length",...O(t),maximum:r})}function Bl(r,t){return new fI({check:"min_length",...O(t),minimum:r})}function sb(r,t){return new gI({check:"length_equals",...O(t),length:r})}function JC(r,t){return new mI({check:"string_format",format:"regex",...O(t),pattern:r})}function XC(r){return new vI({check:"string_format",format:"lowercase",...O(r)})}function QC(r){return new yI({check:"string_format",format:"uppercase",...O(r)})}function eR(r,t){return new bI({check:"string_format",format:"includes",...O(t),includes:r})}function tR(r,t){return new wI({check:"string_format",format:"starts_with",...O(t),prefix:r})}function rR(r,t){return new SI({check:"string_format",format:"ends_with",...O(t),suffix:r})}function Ts(r){return new _I({check:"overwrite",tx:r})}function nR(r){return Ts(t=>t.normalize(r))}function iR(){return Ts(r=>r.trim())}function sR(){return Ts(r=>r.toLowerCase())}function oR(){return Ts(r=>r.toUpperCase())}function aR(){return Ts(r=>m$(r))}function lR(r,t,e){return new r({type:"array",element:t,...O(e)})}function cR(r,t,e){return new r({type:"custom",check:"custom",fn:t,...O(e)})}function uR(r){const t=hR(e=>(e.addIssue=n=>{if(typeof n=="string")e.issues.push(mo(n,e.value,t._zod.def));else{const i=n;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=e.value),i.inst??(i.inst=t),i.continue??(i.continue=!t._zod.def.abort),e.issues.push(mo(i))}},r(e.value,e)));return t}function hR(r,t){const e=new ct({check:"custom",...O(t)});return e._zod.check=r,e}function ob(r){let t=(r==null?void 0:r.target)??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:r.processors??{},metadataRegistry:(r==null?void 0:r.metadata)??Ys,target:t,unrepresentable:(r==null?void 0:r.unrepresentable)??"throw",override:(r==null?void 0:r.override)??(()=>{}),io:(r==null?void 0:r.io)??"output",counter:0,seen:new Map,cycles:(r==null?void 0:r.cycles)??"ref",reused:(r==null?void 0:r.reused)??"inline",external:(r==null?void 0:r.external)??void 0}}function Ee(r,t,e={path:[],schemaPath:[]}){var h,f;var n;const i=r._zod.def,s=t.seen.get(r);if(s)return s.count++,e.schemaPath.includes(r)&&(s.cycle=e.path),s.schema;const o={schema:{},count:1,cycle:void 0,path:e.path};t.seen.set(r,o);const a=(f=(h=r._zod).toJSONSchema)==null?void 0:f.call(h);if(a)o.schema=a;else{const y={...e,schemaPath:[...e.schemaPath,r],path:e.path};if(r._zod.processJSONSchema)r._zod.processJSONSchema(t,o.schema,y);else{const E=o.schema,x=t.processors[i.type];if(!x)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);x(r,t,E,y)}const m=r._zod.parent;m&&(o.ref||(o.ref=m),Ee(m,t,y),t.seen.get(m).isParent=!0)}const c=t.metadataRegistry.get(r);return c&&Object.assign(o.schema,c),t.io==="input"&&Ke(r)&&(delete o.schema.examples,delete o.schema.default),t.io==="input"&&o.schema._prefault&&((n=o.schema).default??(n.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(r).schema}function ab(r,t){var o,a,c,u;const e=r.seen.get(t);if(!e)throw new Error("Unprocessed schema. This is a bug in Zod.");const n=new Map;for(const h of r.seen.entries()){const f=(o=r.metadataRegistry.get(h[0]))==null?void 0:o.id;if(f){const y=n.get(f);if(y&&y!==h[0])throw new Error(`Duplicate schema id "${f}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);n.set(f,h[0])}}const i=h=>{var x;const f=r.target==="draft-2020-12"?"$defs":"definitions";if(r.external){const I=(x=r.external.registry.get(h[0]))==null?void 0:x.id,P=r.external.uri??(B=>B);if(I)return{ref:P(I)};const R=h[1].defId??h[1].schema.id??`schema${r.counter++}`;return h[1].defId=R,{defId:R,ref:`${P("__shared")}#/${f}/${R}`}}if(h[1]===e)return{ref:"#"};const m=`#/${f}/`,E=h[1].schema.id??`__schema${r.counter++}`;return{defId:E,ref:m+E}},s=h=>{if(h[1].schema.$ref)return;const f=h[1],{ref:y,defId:m}=i(h);f.def={...f.schema},m&&(f.defId=m);const E=f.schema;for(const x in E)delete E[x];E.$ref=y};if(r.cycles==="throw")for(const h of r.seen.entries()){const f=h[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 h of r.seen.entries()){const f=h[1];if(t===h[0]){s(h);continue}if(r.external){const m=(c=r.external.registry.get(h[0]))==null?void 0:c.id;if(t!==h[0]&&m){s(h);continue}}if((u=r.metadataRegistry.get(h[0]))==null?void 0:u.id){s(h);continue}if(f.cycle){s(h);continue}if(f.count>1&&r.reused==="ref"){s(h);continue}}}function lb(r,t){var o,a,c;const e=r.seen.get(t);if(!e)throw new Error("Unprocessed schema. This is a bug in Zod.");const n=u=>{const h=r.seen.get(u);if(h.ref===null)return;const f=h.def??h.schema,y={...f},m=h.ref;if(h.ref=null,m){n(m);const x=r.seen.get(m),I=x.schema;if(I.$ref&&(r.target==="draft-07"||r.target==="draft-04"||r.target==="openapi-3.0")?(f.allOf=f.allOf??[],f.allOf.push(I)):Object.assign(f,I),Object.assign(f,y),u._zod.parent===m)for(const R in f)R==="$ref"||R==="allOf"||R in y||delete f[R];if(I.$ref&&x.def)for(const R in f)R==="$ref"||R==="allOf"||R in x.def&&JSON.stringify(f[R])===JSON.stringify(x.def[R])&&delete f[R]}const E=u._zod.parent;if(E&&E!==m){n(E);const x=r.seen.get(E);if(x!=null&&x.schema.$ref&&(f.$ref=x.schema.$ref,x.def))for(const I in f)I==="$ref"||I==="allOf"||I in x.def&&JSON.stringify(f[I])===JSON.stringify(x.def[I])&&delete f[I]}r.override({zodSchema:u,jsonSchema:f,path:h.path??[]})};for(const u of[...r.seen.entries()].reverse())n(u[0]);const i={};if(r.target==="draft-2020-12"?i.$schema="https://json-schema.org/draft/2020-12/schema":r.target==="draft-07"?i.$schema="http://json-schema.org/draft-07/schema#":r.target==="draft-04"?i.$schema="http://json-schema.org/draft-04/schema#":r.target,(o=r.external)!=null&&o.uri){const u=(a=r.external.registry.get(t))==null?void 0:a.id;if(!u)throw new Error("Schema is missing an `id` property");i.$id=r.external.uri(u)}Object.assign(i,e.def??e.schema);const s=((c=r.external)==null?void 0:c.defs)??{};for(const u of r.seen.entries()){const h=u[1];h.def&&h.defId&&(s[h.defId]=h.def)}r.external||Object.keys(s).length>0&&(r.target==="draft-2020-12"?i.$defs=s:i.definitions=s);try{const u=JSON.parse(JSON.stringify(i));return Object.defineProperty(u,"~standard",{value:{...t["~standard"],jsonSchema:{input:Vl(t,"input",r.processors),output:Vl(t,"output",r.processors)}},enumerable:!1,writable:!1}),u}catch{throw new Error("Error converting schema to JSON.")}}function Ke(r,t){const e=t??{seen:new Set};if(e.seen.has(r))return!1;e.seen.add(r);const n=r._zod.def;if(n.type==="transform")return!0;if(n.type==="array")return Ke(n.element,e);if(n.type==="set")return Ke(n.valueType,e);if(n.type==="lazy")return Ke(n.getter(),e);if(n.type==="promise"||n.type==="optional"||n.type==="nonoptional"||n.type==="nullable"||n.type==="readonly"||n.type==="default"||n.type==="prefault")return Ke(n.innerType,e);if(n.type==="intersection")return Ke(n.left,e)||Ke(n.right,e);if(n.type==="record"||n.type==="map")return Ke(n.keyType,e)||Ke(n.valueType,e);if(n.type==="pipe")return Ke(n.in,e)||Ke(n.out,e);if(n.type==="object"){for(const i in n.shape)if(Ke(n.shape[i],e))return!0;return!1}if(n.type==="union"){for(const i of n.options)if(Ke(i,e))return!0;return!1}if(n.type==="tuple"){for(const i of n.items)if(Ke(i,e))return!0;return!!(n.rest&&Ke(n.rest,e))}return!1}const dR=(r,t={})=>e=>{const n=ob({...e,processors:t});return Ee(r,n),ab(n,r),lb(n,r)},Vl=(r,t,e={})=>n=>{const{libraryOptions:i,target:s}=n??{},o=ob({...i??{},target:s,io:t,processors:e});return Ee(r,o),ab(o,r),lb(o,r)},pR={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},fR=(r,t,e,n)=>{const i=e;i.type="string";const{minimum:s,maximum:o,format:a,patterns:c,contentEncoding:u}=r._zod.bag;if(typeof s=="number"&&(i.minLength=s),typeof o=="number"&&(i.maxLength=o),a&&(i.format=pR[a]??a,i.format===""&&delete i.format,a==="time"&&delete i.format),u&&(i.contentEncoding=u),c&&c.size>0){const h=[...c];h.length===1?i.pattern=h[0].source:h.length>1&&(i.allOf=[...h.map(f=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:f.source}))])}},gR=(r,t,e,n)=>{const i=e,{minimum:s,maximum:o,format:a,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:h}=r._zod.bag;typeof a=="string"&&a.includes("int")?i.type="integer":i.type="number",typeof h=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(i.minimum=h,i.exclusiveMinimum=!0):i.exclusiveMinimum=h),typeof s=="number"&&(i.minimum=s,typeof h=="number"&&t.target!=="draft-04"&&(h>=s?delete i.minimum:delete i.exclusiveMinimum)),typeof u=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(i.maximum=u,i.exclusiveMaximum=!0):i.exclusiveMaximum=u),typeof o=="number"&&(i.maximum=o,typeof u=="number"&&t.target!=="draft-04"&&(u<=o?delete i.maximum:delete i.exclusiveMaximum)),typeof c=="number"&&(i.multipleOf=c)},mR=(r,t,e,n)=>{e.type="boolean"},vR=(r,t,e,n)=>{e.not={}},yR=(r,t,e,n)=>{},bR=(r,t,e,n)=>{const i=r._zod.def,s=Uy(i.entries);s.every(o=>typeof o=="number")&&(e.type="number"),s.every(o=>typeof o=="string")&&(e.type="string"),e.enum=s},wR=(r,t,e,n)=>{const i=r._zod.def,s=[];for(const o of i.values)if(o===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof o=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");s.push(Number(o))}else s.push(o);if(s.length!==0)if(s.length===1){const o=s[0];e.type=o===null?"null":typeof o,t.target==="draft-04"||t.target==="openapi-3.0"?e.enum=[o]:e.const=o}else s.every(o=>typeof o=="number")&&(e.type="number"),s.every(o=>typeof o=="string")&&(e.type="string"),s.every(o=>typeof o=="boolean")&&(e.type="boolean"),s.every(o=>o===null)&&(e.type="null"),e.enum=s},SR=(r,t,e,n)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},_R=(r,t,e,n)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},kR=(r,t,e,n)=>{const i=e,s=r._zod.def,{minimum:o,maximum:a}=r._zod.bag;typeof o=="number"&&(i.minItems=o),typeof a=="number"&&(i.maxItems=a),i.type="array",i.items=Ee(s.element,t,{...n,path:[...n.path,"items"]})},xR=(r,t,e,n)=>{var u;const i=e,s=r._zod.def;i.type="object",i.properties={};const o=s.shape;for(const h in o)i.properties[h]=Ee(o[h],t,{...n,path:[...n.path,"properties",h]});const a=new Set(Object.keys(o)),c=new Set([...a].filter(h=>{const f=s.shape[h]._zod;return t.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=Ee(s.catchall,t,{...n,path:[...n.path,"additionalProperties"]})):t.io==="output"&&(i.additionalProperties=!1)},ER=(r,t,e,n)=>{const i=r._zod.def,s=i.inclusive===!1,o=i.options.map((a,c)=>Ee(a,t,{...n,path:[...n.path,s?"oneOf":"anyOf",c]}));s?e.oneOf=o:e.anyOf=o},AR=(r,t,e,n)=>{const i=r._zod.def,s=Ee(i.left,t,{...n,path:[...n.path,"allOf",0]}),o=Ee(i.right,t,{...n,path:[...n.path,"allOf",1]}),a=u=>"allOf"in u&&Object.keys(u).length===1,c=[...a(s)?s.allOf:[s],...a(o)?o.allOf:[o]];e.allOf=c},TR=(r,t,e,n)=>{const i=e,s=r._zod.def;i.type="object";const o=s.keyType,a=o._zod.bag,c=a==null?void 0:a.patterns;if(s.mode==="loose"&&c&&c.size>0){const h=Ee(s.valueType,t,{...n,path:[...n.path,"patternProperties","*"]});i.patternProperties={};for(const f of c)i.patternProperties[f.source]=h}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(i.propertyNames=Ee(s.keyType,t,{...n,path:[...n.path,"propertyNames"]})),i.additionalProperties=Ee(s.valueType,t,{...n,path:[...n.path,"additionalProperties"]});const u=o._zod.values;if(u){const h=[...u].filter(f=>typeof f=="string"||typeof f=="number");h.length>0&&(i.required=h)}},$R=(r,t,e,n)=>{const i=r._zod.def,s=Ee(i.innerType,t,n),o=t.seen.get(r);t.target==="openapi-3.0"?(o.ref=i.innerType,e.nullable=!0):e.anyOf=[s,{type:"null"}]},IR=(r,t,e,n)=>{const i=r._zod.def;Ee(i.innerType,t,n);const s=t.seen.get(r);s.ref=i.innerType},CR=(r,t,e,n)=>{const i=r._zod.def;Ee(i.innerType,t,n);const s=t.seen.get(r);s.ref=i.innerType,e.default=JSON.parse(JSON.stringify(i.defaultValue))},RR=(r,t,e,n)=>{const i=r._zod.def;Ee(i.innerType,t,n);const s=t.seen.get(r);s.ref=i.innerType,t.io==="input"&&(e._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},PR=(r,t,e,n)=>{const i=r._zod.def;Ee(i.innerType,t,n);const s=t.seen.get(r);s.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}e.default=o},LR=(r,t,e,n)=>{const i=r._zod.def,s=t.io==="input"?i.in._zod.def.type==="transform"?i.out:i.in:i.out;Ee(s,t,n);const o=t.seen.get(r);o.ref=s},DR=(r,t,e,n)=>{const i=r._zod.def;Ee(i.innerType,t,n);const s=t.seen.get(r);s.ref=i.innerType,e.readOnly=!0},cb=(r,t,e,n)=>{const i=r._zod.def;Ee(i.innerType,t,n);const s=t.seen.get(r);s.ref=i.innerType},zR=A("ZodISODateTime",(r,t)=>{OI.init(r,t),be.init(r,t)});function OR(r){return ZC(zR,r)}const MR=A("ZodISODate",(r,t)=>{MI.init(r,t),be.init(r,t)});function NR(r){return WC(MR,r)}const UR=A("ZodISOTime",(r,t)=>{NI.init(r,t),be.init(r,t)});function FR(r){return BC(UR,r)}const HR=A("ZodISODuration",(r,t)=>{UI.init(r,t),be.init(r,t)});function ZR(r){return VC(HR,r)}const ub=(r,t)=>{Wy.init(r,t),r.name="ZodError",Object.defineProperties(r,{format:{value:e=>I$(r,e)},flatten:{value:e=>$$(r,e)},addIssue:{value:e=>{r.issues.push(e),r.message=JSON.stringify(r.issues,mh,2)}},addIssues:{value:e=>{r.issues.push(...e),r.message=JSON.stringify(r.issues,mh,2)}},isEmpty:{get(){return r.issues.length===0}}})},Kg=A("ZodError",ub),Et=A("ZodError",ub,{Parent:Error}),WR=tp(Et),BR=rp(Et),VR=$c(Et),jR=Ic(Et),GR=P$(Et),qR=L$(Et),YR=D$(Et),KR=z$(Et),JR=O$(Et),XR=M$(Et),QR=N$(Et),eP=U$(Et),ye=A("ZodType",(r,t)=>(ve.init(r,t),Object.assign(r["~standard"],{jsonSchema:{input:Vl(r,"input"),output:Vl(r,"output")}}),r.toJSONSchema=dR(r,{}),r.def=t,r.type=t.type,Object.defineProperty(r,"_def",{value:t}),r.check=(...e)=>r.clone(cn(t,{checks:[...t.checks??[],...e.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0}),r.with=r.check,r.clone=(e,n)=>un(r,e,n),r.brand=()=>r,r.register=(e,n)=>(e.add(r,n),r),r.parse=(e,n)=>WR(r,e,n,{callee:r.parse}),r.safeParse=(e,n)=>VR(r,e,n),r.parseAsync=async(e,n)=>BR(r,e,n,{callee:r.parseAsync}),r.safeParseAsync=async(e,n)=>jR(r,e,n),r.spa=r.safeParseAsync,r.encode=(e,n)=>GR(r,e,n),r.decode=(e,n)=>qR(r,e,n),r.encodeAsync=async(e,n)=>YR(r,e,n),r.decodeAsync=async(e,n)=>KR(r,e,n),r.safeEncode=(e,n)=>JR(r,e,n),r.safeDecode=(e,n)=>XR(r,e,n),r.safeEncodeAsync=async(e,n)=>QR(r,e,n),r.safeDecodeAsync=async(e,n)=>eP(r,e,n),r.refine=(e,n)=>r.check(jP(e,n)),r.superRefine=e=>r.check(GP(e)),r.overwrite=e=>r.check(Ts(e)),r.optional=()=>Qg(r),r.exactOptional=()=>LP(r),r.nullable=()=>em(r),r.nullish=()=>Qg(em(r)),r.nonoptional=e=>UP(r,e),r.array=()=>z(r),r.or=e=>V([r,e]),r.and=e=>Rc(r,e),r.transform=e=>tm(r,RP(e)),r.default=e=>OP(r,e),r.prefault=e=>NP(r,e),r.catch=e=>HP(r,e),r.pipe=e=>tm(r,e),r.readonly=()=>BP(r),r.describe=e=>{const n=r.clone();return Ys.add(n,{description:e}),n},Object.defineProperty(r,"description",{get(){var e;return(e=Ys.get(r))==null?void 0:e.description},configurable:!0}),r.meta=(...e)=>{if(e.length===0)return Ys.get(r);const n=r.clone();return Ys.add(n,e[0]),n},r.isOptional=()=>r.safeParse(void 0).success,r.isNullable=()=>r.safeParse(null).success,r.apply=e=>e(r),r)),hb=A("_ZodString",(r,t)=>{np.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(n,i,s)=>fR(r,n,i);const e=r._zod.bag;r.format=e.format??null,r.minLength=e.minimum??null,r.maxLength=e.maximum??null,r.regex=(...n)=>r.check(JC(...n)),r.includes=(...n)=>r.check(eR(...n)),r.startsWith=(...n)=>r.check(tR(...n)),r.endsWith=(...n)=>r.check(rR(...n)),r.min=(...n)=>r.check(Bl(...n)),r.max=(...n)=>r.check(ib(...n)),r.length=(...n)=>r.check(sb(...n)),r.nonempty=(...n)=>r.check(Bl(1,...n)),r.lowercase=n=>r.check(XC(n)),r.uppercase=n=>r.check(QC(n)),r.trim=()=>r.check(iR()),r.normalize=(...n)=>r.check(nR(...n)),r.toLowerCase=()=>r.check(sR()),r.toUpperCase=()=>r.check(oR()),r.slugify=()=>r.check(aR())}),tP=A("ZodString",(r,t)=>{np.init(r,t),hb.init(r,t),r.email=e=>r.check(SC(rP,e)),r.url=e=>r.check(AC(nP,e)),r.jwt=e=>r.check(HC(yP,e)),r.emoji=e=>r.check(TC(iP,e)),r.guid=e=>r.check(jg(Jg,e)),r.uuid=e=>r.check(_C(rl,e)),r.uuidv4=e=>r.check(kC(rl,e)),r.uuidv6=e=>r.check(xC(rl,e)),r.uuidv7=e=>r.check(EC(rl,e)),r.nanoid=e=>r.check($C(sP,e)),r.guid=e=>r.check(jg(Jg,e)),r.cuid=e=>r.check(IC(oP,e)),r.cuid2=e=>r.check(CC(aP,e)),r.ulid=e=>r.check(RC(lP,e)),r.base64=e=>r.check(NC(gP,e)),r.base64url=e=>r.check(UC(mP,e)),r.xid=e=>r.check(PC(cP,e)),r.ksuid=e=>r.check(LC(uP,e)),r.ipv4=e=>r.check(DC(hP,e)),r.ipv6=e=>r.check(zC(dP,e)),r.cidrv4=e=>r.check(OC(pP,e)),r.cidrv6=e=>r.check(MC(fP,e)),r.e164=e=>r.check(FC(vP,e)),r.datetime=e=>r.check(OR(e)),r.date=e=>r.check(NR(e)),r.time=e=>r.check(FR(e)),r.duration=e=>r.check(ZR(e))});function d(r){return wC(tP,r)}const be=A("ZodStringFormat",(r,t)=>{ge.init(r,t),hb.init(r,t)}),rP=A("ZodEmail",(r,t)=>{TI.init(r,t),be.init(r,t)}),Jg=A("ZodGUID",(r,t)=>{EI.init(r,t),be.init(r,t)}),rl=A("ZodUUID",(r,t)=>{AI.init(r,t),be.init(r,t)}),nP=A("ZodURL",(r,t)=>{$I.init(r,t),be.init(r,t)}),iP=A("ZodEmoji",(r,t)=>{II.init(r,t),be.init(r,t)}),sP=A("ZodNanoID",(r,t)=>{CI.init(r,t),be.init(r,t)}),oP=A("ZodCUID",(r,t)=>{RI.init(r,t),be.init(r,t)}),aP=A("ZodCUID2",(r,t)=>{PI.init(r,t),be.init(r,t)}),lP=A("ZodULID",(r,t)=>{LI.init(r,t),be.init(r,t)}),cP=A("ZodXID",(r,t)=>{DI.init(r,t),be.init(r,t)}),uP=A("ZodKSUID",(r,t)=>{zI.init(r,t),be.init(r,t)}),hP=A("ZodIPv4",(r,t)=>{FI.init(r,t),be.init(r,t)}),dP=A("ZodIPv6",(r,t)=>{HI.init(r,t),be.init(r,t)}),pP=A("ZodCIDRv4",(r,t)=>{ZI.init(r,t),be.init(r,t)}),fP=A("ZodCIDRv6",(r,t)=>{WI.init(r,t),be.init(r,t)}),gP=A("ZodBase64",(r,t)=>{BI.init(r,t),be.init(r,t)}),mP=A("ZodBase64URL",(r,t)=>{jI.init(r,t),be.init(r,t)}),vP=A("ZodE164",(r,t)=>{GI.init(r,t),be.init(r,t)}),yP=A("ZodJWT",(r,t)=>{YI.init(r,t),be.init(r,t)}),db=A("ZodNumber",(r,t)=>{Qy.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(n,i,s)=>gR(r,n,i),r.gt=(n,i)=>r.check(qg(n,i)),r.gte=(n,i)=>r.check(Pu(n,i)),r.min=(n,i)=>r.check(Pu(n,i)),r.lt=(n,i)=>r.check(Gg(n,i)),r.lte=(n,i)=>r.check(Ru(n,i)),r.max=(n,i)=>r.check(Ru(n,i)),r.int=n=>r.check(Xg(n)),r.safe=n=>r.check(Xg(n)),r.positive=n=>r.check(qg(0,n)),r.nonnegative=n=>r.check(Pu(0,n)),r.negative=n=>r.check(Gg(0,n)),r.nonpositive=n=>r.check(Ru(0,n)),r.multipleOf=(n,i)=>r.check(Yg(n,i)),r.step=(n,i)=>r.check(Yg(n,i)),r.finite=()=>r;const e=r._zod.bag;r.minValue=Math.max(e.minimum??Number.NEGATIVE_INFINITY,e.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,r.maxValue=Math.min(e.maximum??Number.POSITIVE_INFINITY,e.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,r.isInt=(e.format??"").includes("int")||Number.isSafeInteger(e.multipleOf??.5),r.isFinite=!0,r.format=e.format??null});function H(r){return jC(db,r)}const bP=A("ZodNumberFormat",(r,t)=>{KI.init(r,t),db.init(r,t)});function Xg(r){return GC(bP,r)}const wP=A("ZodBoolean",(r,t)=>{JI.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(e,n,i)=>mR(r,e,n)});function De(r){return qC(wP,r)}const SP=A("ZodUnknown",(r,t)=>{XI.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(e,n,i)=>yR()});function _(){return YC(SP)}const _P=A("ZodNever",(r,t)=>{QI.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(e,n,i)=>vR(r,e,n)});function kP(r){return KC(_P,r)}const xP=A("ZodArray",(r,t)=>{eC.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(e,n,i)=>kR(r,e,n,i),r.element=t.element,r.min=(e,n)=>r.check(Bl(e,n)),r.nonempty=e=>r.check(Bl(1,e)),r.max=(e,n)=>r.check(ib(e,n)),r.length=(e,n)=>r.check(sb(e,n)),r.unwrap=()=>r.element});function z(r,t){return lR(xP,r,t)}const pb=A("ZodObject",(r,t)=>{rC.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(e,n,i)=>xR(r,e,n,i),te(r,"shape",()=>t.shape),r.keyof=()=>mb(Object.keys(r._zod.def.shape)),r.catchall=e=>r.clone({...r._zod.def,catchall:e}),r.passthrough=()=>r.clone({...r._zod.def,catchall:_()}),r.loose=()=>r.clone({...r._zod.def,catchall:_()}),r.strict=()=>r.clone({...r._zod.def,catchall:kP()}),r.strip=()=>r.clone({...r._zod.def,catchall:void 0}),r.extend=e=>k$(r,e),r.safeExtend=e=>x$(r,e),r.merge=e=>E$(r,e),r.pick=e=>S$(r,e),r.omit=e=>_$(r,e),r.partial=(...e)=>A$(vb,r,e[0]),r.required=(...e)=>T$(yb,r,e[0])});function fb(r,t){const e={type:"object",shape:r??{},...O(t)};return new pb(e)}function v(r,t){return new pb({type:"object",shape:r,catchall:_(),...O(t)})}const gb=A("ZodUnion",(r,t)=>{rb.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(e,n,i)=>ER(r,e,n,i),r.options=t.options});function V(r,t){return new gb({type:"union",options:r,...O(t)})}const EP=A("ZodDiscriminatedUnion",(r,t)=>{gb.init(r,t),nC.init(r,t)});function AP(r,t,e){return new EP({type:"union",options:t,discriminator:r,...O(e)})}const TP=A("ZodIntersection",(r,t)=>{iC.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(e,n,i)=>AR(r,e,n,i)});function Rc(r,t){return new TP({type:"intersection",left:r,right:t})}const $P=A("ZodRecord",(r,t)=>{sC.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(e,n,i)=>TR(r,e,n,i),r.keyType=t.keyType,r.valueType=t.valueType});function k(r,t,e){return new $P({type:"record",keyType:r,valueType:t,...O(e)})}const yh=A("ZodEnum",(r,t)=>{oC.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(n,i,s)=>bR(r,n,i),r.enum=t.entries,r.options=Object.values(t.entries);const e=new Set(Object.keys(t.entries));r.extract=(n,i)=>{const s={};for(const o of n)if(e.has(o))s[o]=t.entries[o];else throw new Error(`Key ${o} not found in enum`);return new yh({...t,checks:[],...O(i),entries:s})},r.exclude=(n,i)=>{const s={...t.entries};for(const o of n)if(e.has(o))delete s[o];else throw new Error(`Key ${o} not found in enum`);return new yh({...t,checks:[],...O(i),entries:s})}});function mb(r,t){const e=Array.isArray(r)?Object.fromEntries(r.map(n=>[n,n])):r;return new yh({type:"enum",entries:e,...O(t)})}const IP=A("ZodLiteral",(r,t)=>{aC.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(e,n,i)=>wR(r,e,n),r.values=new Set(t.values),Object.defineProperty(r,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function T(r,t){return new IP({type:"literal",values:Array.isArray(r)?r:[r],...O(t)})}const CP=A("ZodTransform",(r,t)=>{lC.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(e,n,i)=>_R(r,e),r._zod.parse=(e,n)=>{if(n.direction==="backward")throw new My(r.constructor.name);e.addIssue=s=>{if(typeof s=="string")e.issues.push(mo(s,e.value,t));else{const o=s;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=e.value),o.inst??(o.inst=r),e.issues.push(mo(o))}};const i=t.transform(e.value,e);return i instanceof Promise?i.then(s=>(e.value=s,e)):(e.value=i,e)}});function RP(r){return new CP({type:"transform",transform:r})}const vb=A("ZodOptional",(r,t)=>{nb.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(e,n,i)=>cb(r,e,n,i),r.unwrap=()=>r._zod.def.innerType});function Qg(r){return new vb({type:"optional",innerType:r})}const PP=A("ZodExactOptional",(r,t)=>{cC.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(e,n,i)=>cb(r,e,n,i),r.unwrap=()=>r._zod.def.innerType});function LP(r){return new PP({type:"optional",innerType:r})}const DP=A("ZodNullable",(r,t)=>{uC.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(e,n,i)=>$R(r,e,n,i),r.unwrap=()=>r._zod.def.innerType});function em(r){return new DP({type:"nullable",innerType:r})}const zP=A("ZodDefault",(r,t)=>{hC.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(e,n,i)=>CR(r,e,n,i),r.unwrap=()=>r._zod.def.innerType,r.removeDefault=r.unwrap});function OP(r,t){return new zP({type:"default",innerType:r,get defaultValue(){return typeof t=="function"?t():Hy(t)}})}const MP=A("ZodPrefault",(r,t)=>{dC.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(e,n,i)=>RR(r,e,n,i),r.unwrap=()=>r._zod.def.innerType});function NP(r,t){return new MP({type:"prefault",innerType:r,get defaultValue(){return typeof t=="function"?t():Hy(t)}})}const yb=A("ZodNonOptional",(r,t)=>{pC.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(e,n,i)=>IR(r,e,n,i),r.unwrap=()=>r._zod.def.innerType});function UP(r,t){return new yb({type:"nonoptional",innerType:r,...O(t)})}const FP=A("ZodCatch",(r,t)=>{fC.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(e,n,i)=>PR(r,e,n,i),r.unwrap=()=>r._zod.def.innerType,r.removeCatch=r.unwrap});function HP(r,t){return new FP({type:"catch",innerType:r,catchValue:typeof t=="function"?t:()=>t})}const ZP=A("ZodPipe",(r,t)=>{gC.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(e,n,i)=>LR(r,e,n,i),r.in=t.in,r.out=t.out});function tm(r,t){return new ZP({type:"pipe",in:r,out:t})}const WP=A("ZodReadonly",(r,t)=>{mC.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(e,n,i)=>DR(r,e,n,i),r.unwrap=()=>r._zod.def.innerType});function BP(r){return new WP({type:"readonly",innerType:r})}const VP=A("ZodCustom",(r,t)=>{vC.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(e,n,i)=>SR(r,e)});function jP(r,t={}){return cR(VP,r,t)}function GP(r){return uR(r)}const qP=[".md",".markdown"];function bb(r){if(r.length===0)return!1;const t=r.at(-1);return t==="/"||t==="\\"}function wb(r){const t=r.lastIndexOf("/"),e=r.lastIndexOf("\\");return r.slice(Math.max(t,e)+1)}function YP(r){return wb(r).toLowerCase()}function KP(r,t){const e=YP(r);return t.some(n=>e.endsWith(n))}function Sb(r){return!bb(r)&&KP(r,qP)}function JP(r){let t;try{t=new URL(r)}catch{return!1}return t.protocol==="http:"||t.protocol==="https:"}function vr(r){try{const{pathname:t}=new URL(r);return/^\/artifact\/[0-9A-Za-z]{26}(\/|$)/.test(t)}catch{return!1}}const XP=fb({id:d().min(1),kind:T("path"),title:d(),path:d()}).strict(),QP=fb({id:d().min(1),kind:T("url"),title:d(),url:d().refine(JP,{message:"url must be an http(s) URL"})}).strict();AP("kind",[XP,QP]);function _b(r){return typeof r=="object"&&r!==null}function kb(r){return!_b(r)||r.type!=="ready"?!1:!("id"in r)}function xb(r){return!(!_b(r)||r.type!=="update-content"||typeof r.id!="string"||typeof r.content!="string")}const eL="/views/markdown/",tL="/views/url-unsupported/";function Eb(r){return`/artifact/${encodeURIComponent(r)}`}function rL(r,t){return`${Eb(r)}/${encodeURIComponent(t)}`}function nL(r){return`/markdown/${encodeURIComponent(r)}`}function jl(r,t={electron:!1}){if(r.kind==="url")return t.electron?{renderer:"url-webview",viewURL:r.url,contentURL:null}:vr(r.url)?{renderer:"proxy-iframe",viewURL:r.url,contentURL:null}:{renderer:"url-unsupported",viewURL:tL,contentURL:null};if(Sb(r.path)){const n={viewURL:eL,contentURL:nL(r.id)};return t.electron?{renderer:"url-webview",...n}:{renderer:"markdown",...n}}const e=bb(r.path)?`${Eb(r.id)}/`:rL(r.id,wb(r.path));return t.electron?{renderer:"url-webview",viewURL:e,contentURL:null}:{renderer:"proxy-iframe",viewURL:e,contentURL:null}}const iL="serverURL",sL="token",oL="mode",aL="desktopAppVersion",lL="electron";function Ab(r=window.location.search,t=window.location.origin){const n=new URLSearchParams(r).get(iL);return n?new URL(n).origin:new URL(t).origin}function cL(r=window.location.search){return new URLSearchParams(r).get(sL)}function cr(r=typeof window>"u"?"":window.location.search){return new URLSearchParams(r).get(oL)===lL}function uL(r=typeof window>"u"?"":window.location.search){return new URLSearchParams(r).get(aL)}const rm="tv.telemetry.clientId",hL=5,dL=60,pL=1e3,fL=hL*dL*pL,nm=["pointerdown","scroll","keydown"],im=["focus"],sm=["visibilitychange"],gL="hidden";function mL(r,t=SL){const e=r.getItem(rm);if(e)return e;const n=t();return r.setItem(rm,n),n}function vL(r){return{clientId:mL(r.storage,r.idFactory),userAgent:r.userAgent??(typeof navigator>"u"?"":navigator.userAgent),clientApp:r.clientApp,...r.desktopAppVersion?{desktopAppVersion:r.desktopAppVersion}:{}}}function yL(r){const t=new URLSearchParams;return t.set("clientId",r.clientId),t.set("userAgent",r.userAgent),t.set("clientApp",r.clientApp),r.desktopAppVersion&&t.set("desktopAppVersion",r.desktopAppVersion),t}function bL(r){return new wL(r)}var To,kr,Zr,$o,Io,gt,zn,Co,rc,Tb;class wL{constructor(t){w(this,rc);w(this,To);w(this,kr);w(this,Zr);w(this,$o);w(this,Io);w(this,gt);w(this,zn,!1);w(this,Co,Number.NEGATIVE_INFINITY);b(this,To,t.meta),b(this,kr,t.documentTarget),b(this,Zr,t.windowTarget),b(this,$o,t.send),b(this,Io,t.nowMs??Date.now),b(this,gt,()=>p(this,rc,Tb).call(this))}start(){if(!l(this,zn)){b(this,zn,!0);for(const t of nm)l(this,Zr).addEventListener(t,l(this,gt)),l(this,kr).addEventListener(t,l(this,gt));for(const t of im)l(this,Zr).addEventListener(t,l(this,gt));for(const t of sm)l(this,kr).addEventListener(t,l(this,gt))}}stop(){if(l(this,zn)){b(this,zn,!1);for(const t of nm)l(this,Zr).removeEventListener(t,l(this,gt)),l(this,kr).removeEventListener(t,l(this,gt));for(const t of im)l(this,Zr).removeEventListener(t,l(this,gt));for(const t of sm)l(this,kr).removeEventListener(t,l(this,gt))}}}To=new WeakMap,kr=new WeakMap,Zr=new WeakMap,$o=new WeakMap,Io=new WeakMap,gt=new WeakMap,zn=new WeakMap,Co=new WeakMap,rc=new WeakSet,Tb=function(){if(l(this,kr).visibilityState===gL)return;const t=l(this,Io).call(this);t-l(this,Co)<fL||(b(this,Co,t),l(this,$o).call(this,{type:RT,clientId:l(this,To).clientId}))};function SL(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():Ac().toLowerCase()}const pe={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"},mr={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"},_L=1,kL=v({_meta:k(d(),_()).nullish(),terminal:De().optional().default(!1)}),xL=v({_meta:k(d(),_()).nullish(),label:d().nullish(),name:d(),optional:De().optional().default(!1),secret:De().optional().default(!0)}),EL=v({_meta:k(d(),_()).nullish(),description:d().nullish(),id:d(),name:d()}),AL=v({_meta:k(d(),_()).nullish(),description:d().nullish(),id:d(),link:d().nullish(),name:d(),vars:z(xL)}),TL=v({_meta:k(d(),_()).nullish(),args:z(d()).optional(),description:d().nullish(),env:k(d(),d()).optional(),id:d(),name:d()}),$L=V([AL.and(v({type:T("env_var")})),TL.and(v({type:T("terminal")})),EL]),IL=v({_meta:k(d(),_()).nullish(),methodId:d()}),CL=v({_meta:k(d(),_()).nullish()}),RL=v({_meta:k(d(),_()).nullish(),blob:d(),mimeType:d().nullish(),uri:d()}),PL=v({default:De().nullish(),description:d().nullish(),title:d().nullish()}),LL=v({_meta:k(d(),_()).nullish()}),DL=v({_meta:k(d(),_()).nullish()}),zL=v({amount:H(),currency:d()}),OL=v({_meta:k(d(),_()).nullish(),terminalId:d()}),ML=v({_meta:k(d(),_()).nullish(),newText:d(),oldText:d().nullish(),path:d()}),NL=V([d(),H(),H(),De(),z(d())]),UL=v({content:k(d(),NL).nullish()}),FL=V([UL.and(v({action:T("accept")})),v({action:T("decline")}),v({action:T("cancel")})]),HL=v({_meta:k(d(),_()).nullish()}),$b=d(),ZL=v({_meta:k(d(),_()).nullish(),elicitationId:$b}),WL=v({_meta:k(d(),_()).nullish(),action:FL}),BL=T("object"),VL=T("string"),jL=v({_meta:k(d(),_()).nullish()}),GL=v({_meta:k(d(),_()).nullish(),form:HL.nullish(),url:jL.nullish()}),qL=v({elicitationId:$b,url:d().url()}),Ib=v({const:d(),title:d()}),Cb=v({_meta:k(d(),_()).nullish(),name:d(),value:d()}),YL=V([T(-32700),T(-32600),T(-32601),T(-32602),T(-32603),T(-32800),T(-32e3),T(-32002),T(-32042),H().int().min(-2147483648,{message:"Invalid value: Expected int32 to be >= -2147483648"}).max(2147483647,{message:"Invalid value: Expected int32 to be <= 2147483647"})]),Rb=v({code:YL,data:_().optional(),message:d()}),Pb=_(),Lb=_(),Db=_(),KL=v({_meta:k(d(),_()).nullish(),readTextFile:De().optional().default(!1),writeTextFile:De().optional().default(!1)}),zb=v({_meta:k(d(),_()).nullish(),name:d(),value:d()}),Ob=v({_meta:k(d(),_()).nullish(),name:d(),title:d().nullish(),version:d()}),JL=v({default:H().nullish(),description:d().nullish(),maximum:H().nullish(),minimum:H().nullish(),title:d().nullish()}),XL=v({_meta:k(d(),_()).nullish()}),QL=v({_meta:k(d(),_()).nullish(),additionalDirectories:z(d()).optional(),cursor:d().nullish(),cwd:d().nullish()}),eD=v({_meta:k(d(),_()).nullish()}),tD=v({_meta:k(d(),_()).nullish(),logout:eD.nullish()}),rD=v({_meta:k(d(),_()).nullish()}),nD=v({_meta:k(d(),_()).nullish()}),iD=v({_meta:k(d(),_()).nullish(),http:De().optional().default(!1),sse:De().optional().default(!1)}),sD=v({_meta:k(d(),_()).nullish(),headers:z(zb),name:d(),url:d()}),oD=v({_meta:k(d(),_()).nullish(),headers:z(zb),name:d(),url:d()}),aD=v({_meta:k(d(),_()).nullish(),args:z(d()),command:d(),env:z(Cb),name:d()}),Pc=V([sD.and(v({type:T("http")})),oD.and(v({type:T("sse")})),aD]),ip=d(),lD=v({_meta:k(d(),_()).nullish(),description:d().nullish(),modelId:ip,name:d()}),cD=V([T("error"),T("warning"),T("information"),T("hint")]),uD=v({_meta:k(d(),_()).nullish()}),hD=v({_meta:k(d(),_()).nullish()}),dD=v({_meta:k(d(),_()).nullish()}),pD=v({_meta:k(d(),_()).nullish()}),fD=v({_meta:k(d(),_()).nullish()}),gD=v({_meta:k(d(),_()).nullish(),maxCount:H().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),mD=v({diff:d(),uri:d()}),vD=v({endLine:H().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),startLine:H().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),text:d()}),yD=v({_meta:k(d(),_()).nullish()}),bD=v({_meta:k(d(),_()).nullish()}),wD=v({languageId:d(),text:d(),uri:d()}),SD=v({_meta:k(d(),_()).nullish(),maxCount:H().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),_D=V([T("rejected"),T("ignored"),T("replaced"),T("cancelled")]),kD=v({excerpts:z(vD),uri:d()}),xD=v({_meta:k(d(),_()).nullish()}),ED=v({_meta:k(d(),_()).nullish()}),AD=v({name:d(),owner:d(),remoteUrl:d()}),TD=v({_meta:k(d(),_()).nullish()}),$D=v({_meta:k(d(),_()).nullish(),jump:yD.nullish(),rename:ED.nullish(),searchAndReplace:TD.nullish()}),ID=v({id:d(),isRegex:De().nullish(),replace:d(),search:d(),uri:d()}),CD=V([T("automatic"),T("diagnostic"),T("manual")]),RD=v({_meta:k(d(),_()).nullish(),maxCount:H().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),PD=v({_meta:k(d(),_()).nullish(),diagnostics:uD.nullish(),editHistory:gD.nullish(),openFiles:bD.nullish(),recentFiles:SD.nullish(),relatedSnippets:xD.nullish(),userActions:RD.nullish()}),LD=v({_meta:k(d(),_()).nullish(),additionalDirectories:z(d()).optional(),cwd:d(),mcpServers:z(Pc)}),DD=v({default:H().nullish(),description:d().nullish(),maximum:H().nullish(),minimum:H().nullish(),title:d().nullish()}),Mb=d(),zD=V([T("allow_once"),T("allow_always"),T("reject_once"),T("reject_always")]),OD=v({_meta:k(d(),_()).nullish(),kind:zD,name:d(),optionId:Mb}),MD=V([T("high"),T("medium"),T("low")]),ND=V([T("pending"),T("in_progress"),T("completed")]),UD=v({_meta:k(d(),_()).nullish(),content:d(),priority:MD,status:ND}),FD=v({_meta:k(d(),_()).nullish(),entries:z(UD)}),sn=v({character:H().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),line:H().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"})}),HD=v({id:d(),position:sn,uri:d()}),ZD=v({id:d(),newName:d(),position:sn,uri:d()}),WD=v({action:d(),position:sn,timestampMs:H(),uri:d()}),Nb=V([T("utf-16"),T("utf-32"),T("utf-8")]),BD=v({_meta:k(d(),_()).nullish(),auth:kL.optional().default({terminal:!1}),elicitation:GL.nullish(),fs:KL.optional().default({readTextFile:!1,writeTextFile:!1}),nes:$D.nullish(),positionEncodings:z(Nb).optional(),terminal:De().optional().default(!1)}),VD=v({_meta:k(d(),_()).nullish(),audio:De().optional().default(!1),embeddedContext:De().optional().default(!1),image:De().optional().default(!1)}),Ub=H().int().gte(0).lte(65535),jD=v({_meta:k(d(),_()).nullish(),clientCapabilities:BD.optional().default({auth:{terminal:!1},fs:{readTextFile:!1,writeTextFile:!1},terminal:!1}),clientInfo:Ob.nullish(),protocolVersion:Ub}),$s=v({end:sn,start:sn}),GD=v({message:d(),range:$s,severity:cD,uri:d()}),qD=v({languageId:d(),lastFocusedMs:H().nullish(),uri:d(),visibleRange:$s.nullish()}),YD=v({_meta:k(d(),_()).nullish(),diagnostics:z(GD).nullish(),editHistory:z(mD).nullish(),openFiles:z(qD).nullish(),recentFiles:z(wD).nullish(),relatedSnippets:z(kD).nullish(),userActions:z(WD).nullish()}),KD=v({newText:d(),range:$s}),JD=v({cursorPosition:sn.nullish(),edits:z(KD),id:d(),uri:d()}),XD=V([JD.and(v({kind:T("edit")})),HD.and(v({kind:T("jump")})),ZD.and(v({kind:T("rename")})),ID.and(v({kind:T("searchAndReplace")}))]),QD=v({_meta:k(d(),_()).nullish(),content:d()}),e2=v({_meta:k(d(),_()).nullish()}),Xn=V([H(),d()]).nullable();v({_meta:k(d(),_()).nullish(),requestId:Xn});const t2=mb(["assistant","user"]),Pa=v({_meta:k(d(),_()).nullish(),audience:z(t2).nullish(),lastModified:d().nullish(),priority:H().nullish()}),r2=v({_meta:k(d(),_()).nullish(),annotations:Pa.nullish(),data:d(),mimeType:d()}),n2=v({_meta:k(d(),_()).nullish(),annotations:Pa.nullish(),data:d(),mimeType:d(),uri:d().nullish()}),i2=v({_meta:k(d(),_()).nullish(),annotations:Pa.nullish(),description:d().nullish(),mimeType:d().nullish(),name:d(),size:H().nullish(),title:d().nullish(),uri:d()}),s2=v({_meta:k(d(),_()).nullish(),optionId:Mb}),o2=V([v({outcome:T("cancelled")}),s2.and(v({outcome:T("selected")}))]),a2=v({_meta:k(d(),_()).nullish(),outcome:o2}),l2=v({_meta:k(d(),_()).nullish()}),c2=v({_meta:k(d(),_()).nullish()}),u2=v({currentValue:De()}),h2=d(),Fb=d(),d2=V([T("mode"),T("model"),T("thought_level"),d()]),sp=d(),Hb=v({_meta:k(d(),_()).nullish(),description:d().nullish(),name:d(),value:sp}),p2=v({_meta:k(d(),_()).nullish(),group:h2,name:d(),options:z(Hb)}),f2=V([z(Hb),z(p2)]),g2=v({currentValue:sp,options:f2}),Is=Rc(V([g2.and(v({type:T("select")})),u2.and(v({type:T("boolean")}))]),v({_meta:k(d(),_()).nullish(),category:d2.nullish(),description:d().nullish(),id:Fb,name:d()})),m2=v({_meta:k(d(),_()).nullish(),configOptions:z(Is)}),v2=v({_meta:k(d(),_()).nullish()}),Q=d(),y2=v({_meta:k(d(),_()).nullish(),id:d(),sessionId:Q}),b2=v({_meta:k(d(),_()).nullish(),sessionId:Q}),w2=v({_meta:k(d(),_()).nullish(),sessionId:Q}),S2=v({_meta:k(d(),_()).nullish(),sessionId:Q}),Zb=v({_meta:k(d(),_()).nullish(),args:z(d()).optional(),command:d(),cwd:d().nullish(),env:z(Cb).optional(),outputByteLimit:H().nullish(),sessionId:Q}),_2=v({_meta:k(d(),_()).nullish(),sessionId:Q,uri:d()}),k2=v({_meta:k(d(),_()).nullish(),position:sn,sessionId:Q,uri:d(),version:H(),visibleRange:$s}),x2=v({_meta:k(d(),_()).nullish(),languageId:d(),sessionId:Q,text:d(),uri:d(),version:H()}),E2=v({_meta:k(d(),_()).nullish(),sessionId:Q,uri:d()}),A2=v({_meta:k(d(),_()).nullish(),additionalDirectories:z(d()).optional(),cwd:d(),mcpServers:z(Pc).optional(),sessionId:Q}),Wb=v({_meta:k(d(),_()).nullish(),sessionId:Q,terminalId:d()}),T2=v({_meta:k(d(),_()).nullish(),additionalDirectories:z(d()).optional(),cwd:d(),mcpServers:z(Pc),sessionId:Q}),Bb=v({_meta:k(d(),_()).nullish(),limit:H().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),line:H().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:d(),sessionId:Q}),$2=v({_meta:k(d(),_()).nullish(),id:d(),reason:_D.nullish(),sessionId:Q}),Vb=v({_meta:k(d(),_()).nullish(),sessionId:Q,terminalId:d()}),I2=v({_meta:k(d(),_()).nullish(),additionalDirectories:z(d()).optional(),cwd:d(),mcpServers:z(Pc).optional(),sessionId:Q}),C2=v({_meta:k(d(),_()).nullish(),additionalDirectories:z(d()).optional(),cwd:d(),sessionId:Q,title:d().nullish(),updatedAt:d().nullish()}),R2=v({_meta:k(d(),_()).nullish(),nextCursor:d().nullish(),sessions:z(C2)}),P2=v({_meta:k(d(),_()).nullish(),title:d().nullish(),updatedAt:d().nullish()}),L2=v({_meta:k(d(),_()).nullish()}),Lc=d(),D2=v({_meta:k(d(),_()).nullish(),currentModeId:Lc}),z2=v({_meta:k(d(),_()).nullish(),description:d().nullish(),id:Lc,name:d()}),Dc=v({_meta:k(d(),_()).nullish(),availableModes:z(z2),currentModeId:Lc}),zc=v({_meta:k(d(),_()).nullish(),availableModels:z(lD),currentModelId:ip}),O2=v({_meta:k(d(),_()).nullish(),configOptions:z(Is).nullish(),models:zc.nullish(),modes:Dc.nullish(),sessionId:Q}),M2=v({_meta:k(d(),_()).nullish(),configOptions:z(Is).nullish(),models:zc.nullish(),modes:Dc.nullish()}),N2=v({_meta:k(d(),_()).nullish(),configOptions:z(Is).nullish(),models:zc.nullish(),modes:Dc.nullish(),sessionId:Q}),U2=v({_meta:k(d(),_()).nullish(),configOptions:z(Is).nullish(),models:zc.nullish(),modes:Dc.nullish()}),F2=v({_meta:k(d(),_()).nullish()}),H2=v({_meta:k(d(),_()).nullish(),additionalDirectories:l2.nullish(),close:c2.nullish(),fork:v2.nullish(),list:L2.nullish(),resume:F2.nullish()}),Z2=Rc(V([v({type:T("boolean"),value:De()}),v({value:sp})]),v({_meta:k(d(),_()).nullish(),configId:Fb,sessionId:Q})),W2=v({_meta:k(d(),_()).nullish(),configOptions:z(Is)}),B2=v({_meta:k(d(),_()).nullish(),modeId:Lc,sessionId:Q}),V2=v({_meta:k(d(),_()).nullish()}),j2=v({_meta:k(d(),_()).nullish(),modelId:ip,sessionId:Q}),G2=v({_meta:k(d(),_()).nullish()}),q2=v({_meta:k(d(),_()).nullish(),sessionId:Q}),Y2=V([T("end_turn"),T("max_tokens"),T("max_turn_requests"),T("refusal"),T("cancelled")]),K2=V([T("email"),T("uri"),T("date"),T("date-time")]),J2=v({default:d().nullish(),description:d().nullish(),enum:z(d()).nullish(),format:K2.nullish(),maxLength:H().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),minLength:H().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),oneOf:z(Ib).nullish(),pattern:d().nullish(),title:d().nullish()}),X2=v({_meta:k(d(),_()).nullish(),context:YD.nullish(),position:sn,selection:$s.nullish(),sessionId:Q,triggerKind:CD,uri:d(),version:H()}),Q2=v({_meta:k(d(),_()).nullish(),suggestions:z(XD)}),ez=v({_meta:k(d(),_()).nullish(),terminalId:d()}),tz=v({_meta:k(d(),_()).nullish(),exitCode:H().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:d().nullish()}),jb=v({_meta:k(d(),_()).nullish(),sessionId:Q,terminalId:d()}),rz=v({_meta:k(d(),_()).nullish(),exitStatus:tz.nullish(),output:d(),truncated:De()}),nz=v({_meta:k(d(),_()).nullish(),annotations:Pa.nullish(),text:d()}),iz=v({range:$s.nullish(),text:d()}),sz=v({_meta:k(d(),_()).nullish(),contentChanges:z(iz),sessionId:Q,uri:d(),version:H()});v({method:d(),params:V([b2,x2,sz,_2,E2,k2,y2,$2,Pb]).nullish()});const oz=V([T("full"),T("incremental")]),az=v({_meta:k(d(),_()).nullish(),syncKind:oz}),lz=v({_meta:k(d(),_()).nullish(),didChange:az.nullish(),didClose:hD.nullish(),didFocus:dD.nullish(),didOpen:pD.nullish(),didSave:fD.nullish()}),cz=v({_meta:k(d(),_()).nullish(),document:lz.nullish()}),uz=v({_meta:k(d(),_()).nullish(),context:PD.nullish(),events:cz.nullish()}),hz=v({_meta:k(d(),_()).nullish(),auth:tD.optional().default({}),loadSession:De().optional().default(!1),mcpCapabilities:iD.optional().default({http:!1,sse:!1}),nes:uz.nullish(),positionEncoding:Nb.nullish(),promptCapabilities:VD.optional().default({audio:!1,embeddedContext:!1,image:!1}),sessionCapabilities:H2.optional().default({})}),dz=v({_meta:k(d(),_()).nullish(),agentCapabilities:hz.optional().default({auth:{},loadSession:!1,mcpCapabilities:{http:!1,sse:!1},promptCapabilities:{audio:!1,embeddedContext:!1,image:!1},sessionCapabilities:{}}),agentInfo:Ob.nullish(),authMethods:z($L).optional().default([]),protocolVersion:Ub}),pz=v({_meta:k(d(),_()).nullish(),mimeType:d().nullish(),text:d(),uri:d()}),fz=V([pz,RL]),gz=v({_meta:k(d(),_()).nullish(),annotations:Pa.nullish(),resource:fz}),op=V([nz.and(v({type:T("text")})),n2.and(v({type:T("image")})),r2.and(v({type:T("audio")})),i2.and(v({type:T("resource_link")})),gz.and(v({type:T("resource")}))]),mz=v({_meta:k(d(),_()).nullish(),content:op}),Lu=v({_meta:k(d(),_()).nullish(),content:op,messageId:d().nullish()}),vz=v({_meta:k(d(),_()).nullish(),messageId:d().nullish(),prompt:z(op),sessionId:Q}),yz=v({anyOf:z(Ib)}),Gb=V([mz.and(v({type:T("content")})),ML.and(v({type:T("diff")})),ez.and(v({type:T("terminal")}))]),qb=d(),Yb=v({_meta:k(d(),_()).nullish(),line:H().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:d()}),Kb=V([T("pending"),T("in_progress"),T("completed"),T("failed")]),Jb=V([T("read"),T("edit"),T("delete"),T("move"),T("search"),T("execute"),T("think"),T("fetch"),T("switch_mode"),T("other")]),bz=v({_meta:k(d(),_()).nullish(),content:z(Gb).optional(),kind:Jb.optional(),locations:z(Yb).optional(),rawInput:_().optional(),rawOutput:_().optional(),status:Kb.optional(),title:d(),toolCallId:qb}),Xb=v({_meta:k(d(),_()).nullish(),content:z(Gb).nullish(),kind:Jb.nullish(),locations:z(Yb).nullish(),rawInput:_().optional(),rawOutput:_().optional(),status:Kb.nullish(),title:d().nullish(),toolCallId:qb}),Qb=v({_meta:k(d(),_()).nullish(),options:z(OD),sessionId:Q,toolCall:Xb}),wz=v({_meta:k(d(),_()).nullish(),hint:d()}),Sz=wz,_z=v({_meta:k(d(),_()).nullish(),description:d(),input:Sz.nullish(),name:d()}),kz=v({_meta:k(d(),_()).nullish(),availableCommands:z(_z)}),xz=v({enum:z(d()),type:VL}),Ez=V([xz,yz]),Az=v({default:z(d()).nullish(),description:d().nullish(),items:Ez,maxItems:H().nullish(),minItems:H().nullish(),title:d().nullish()}),Tz=V([J2.and(v({type:T("string")})),DD.and(v({type:T("number")})),JL.and(v({type:T("integer")})),PL.and(v({type:T("boolean")})),Az.and(v({type:T("array")}))]),$z=v({description:d().nullish(),properties:k(d(),Tz).optional().default({}),required:z(d()).nullish(),title:d().nullish(),type:BL.optional().default("object")}),Iz=v({requestedSchema:$z}),Cz=Rc(V([Iz.and(v({mode:T("form")})),qL.and(v({mode:T("url")}))]),v({_meta:k(d(),_()).nullish(),message:d(),sessionId:Q})),Rz=v({cachedReadTokens:H().nullish(),cachedWriteTokens:H().nullish(),inputTokens:H(),outputTokens:H(),thoughtTokens:H().nullish(),totalTokens:H()}),Pz=v({_meta:k(d(),_()).nullish(),stopReason:Y2,usage:Rz.nullish(),userMessageId:d().nullish()});V([v({id:Xn,result:V([dz,CL,nD,N2,M2,R2,O2,U2,DL,V2,W2,Pz,G2,q2,Q2,LL,Db])}),v({error:Rb,id:Xn})]);const Lz=v({_meta:k(d(),_()).nullish(),cost:zL.nullish(),size:H(),used:H()}),Dz=V([Lu.and(v({sessionUpdate:T("user_message_chunk")})),Lu.and(v({sessionUpdate:T("agent_message_chunk")})),Lu.and(v({sessionUpdate:T("agent_thought_chunk")})),bz.and(v({sessionUpdate:T("tool_call")})),Xb.and(v({sessionUpdate:T("tool_call_update")})),FD.and(v({sessionUpdate:T("plan")})),kz.and(v({sessionUpdate:T("available_commands_update")})),D2.and(v({sessionUpdate:T("current_mode_update")})),m2.and(v({sessionUpdate:T("config_option_update")})),P2.and(v({sessionUpdate:T("session_info_update")})),Lz.and(v({sessionUpdate:T("usage_update")}))]),ew=v({_meta:k(d(),_()).nullish(),sessionId:Q,update:Dz});v({method:d(),params:V([ew,ZL,Pb]).nullish()});const tw=v({_meta:k(d(),_()).nullish(),sessionId:Q,terminalId:d()}),zz=v({_meta:k(d(),_()).nullish(),exitCode:H().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:d().nullish()}),Oz=v({name:d(),uri:d()}),Mz=v({_meta:k(d(),_()).nullish(),repository:AD.nullish(),workspaceFolders:z(Oz).nullish(),workspaceUri:d().nullish()});v({id:Xn,method:d(),params:V([jD,IL,rD,LD,T2,QL,A2,I2,S2,B2,Z2,vz,j2,Mz,X2,w2,Lb]).nullish()});const rw=v({_meta:k(d(),_()).nullish(),content:d(),path:d(),sessionId:Q});v({id:Xn,method:d(),params:V([rw,Bb,Qb,Zb,jb,Vb,tw,Wb,Cz,Lb]).nullish()});const Nz=v({_meta:k(d(),_()).nullish()});V([v({id:Xn,result:V([Nz,QD,a2,OL,rz,e2,zz,XL,WL,Db])}),v({error:Rb,id:Xn})]);var X;class Uz{constructor(t,e){w(this,X);const n=t(this),i=async(o,a)=>{var c,u,h,f,y,m,E;switch(o){case mr.fs_write_text_file:{const x=rw.parse(a);return(c=n.writeTextFile)==null?void 0:c.call(n,x)}case mr.fs_read_text_file:{const x=Bb.parse(a);return(u=n.readTextFile)==null?void 0:u.call(n,x)}case mr.session_request_permission:{const x=Qb.parse(a);return n.requestPermission(x)}case mr.terminal_create:{const x=Zb.parse(a);return(h=n.createTerminal)==null?void 0:h.call(n,x)}case mr.terminal_output:{const x=jb.parse(a);return(f=n.terminalOutput)==null?void 0:f.call(n,x)}case mr.terminal_release:{const x=Vb.parse(a);return await((y=n.releaseTerminal)==null?void 0:y.call(n,x))??{}}case mr.terminal_wait_for_exit:{const x=tw.parse(a);return(m=n.waitForTerminalExit)==null?void 0:m.call(n,x)}case mr.terminal_kill:{const x=Wb.parse(a);return await((E=n.killTerminal)==null?void 0:E.call(n,x))??{}}default:if(n.extMethod)return n.extMethod(o,a);throw Ce.methodNotFound(o)}},s=async(o,a)=>{switch(o){case mr.session_update:{const c=ew.parse(a);return n.sessionUpdate(c)}default:if(n.extNotification)return n.extNotification(o,a);throw Ce.methodNotFound(o)}};b(this,X,new Fz(i,s,e))}async initialize(t){return await l(this,X).sendRequest(pe.initialize,t)}async newSession(t){return await l(this,X).sendRequest(pe.session_new,t)}async loadSession(t){return await l(this,X).sendRequest(pe.session_load,t)??{}}async unstable_forkSession(t){return await l(this,X).sendRequest(pe.session_fork,t)}async listSessions(t){return await l(this,X).sendRequest(pe.session_list,t)}async unstable_resumeSession(t){return await l(this,X).sendRequest(pe.session_resume,t)}async unstable_closeSession(t){return await l(this,X).sendRequest(pe.session_close,t)}async setSessionMode(t){return await l(this,X).sendRequest(pe.session_set_mode,t)??{}}async unstable_setSessionModel(t){return await l(this,X).sendRequest(pe.session_set_model,t)??{}}async setSessionConfigOption(t){return await l(this,X).sendRequest(pe.session_set_config_option,t)}async authenticate(t){return await l(this,X).sendRequest(pe.authenticate,t)??{}}async unstable_logout(t){return await l(this,X).sendRequest(pe.logout,t)??{}}async prompt(t){return await l(this,X).sendRequest(pe.session_prompt,t)}async cancel(t){return await l(this,X).sendNotification(pe.session_cancel,t)}async unstable_startNes(t){return await l(this,X).sendRequest(pe.nes_start,t)}async unstable_suggestNes(t){return await l(this,X).sendRequest(pe.nes_suggest,t)}async unstable_closeNes(t){return await l(this,X).sendRequest(pe.nes_close,t)??{}}async unstable_didOpenDocument(t){return await l(this,X).sendNotification(pe.document_did_open,t)}async unstable_didChangeDocument(t){return await l(this,X).sendNotification(pe.document_did_change,t)}async unstable_didCloseDocument(t){return await l(this,X).sendNotification(pe.document_did_close,t)}async unstable_didSaveDocument(t){return await l(this,X).sendNotification(pe.document_did_save,t)}async unstable_didFocusDocument(t){return await l(this,X).sendNotification(pe.document_did_focus,t)}async unstable_acceptNes(t){return await l(this,X).sendNotification(pe.nes_accept,t)}async unstable_rejectNes(t){return await l(this,X).sendNotification(pe.nes_reject,t)}async extMethod(t,e){return await l(this,X).sendRequest(t,e)}async extNotification(t,e){return await l(this,X).sendNotification(t,e)}get signal(){return l(this,X).signal}get closed(){return l(this,X).closed}}X=new WeakMap;var Wr,nc,Ro,Po,Fi,Hi,qt,Lo,me,nw,bh,iw,sw,ow,aw,wh,Ks;class Fz{constructor(t,e,n){w(this,me);w(this,Wr,new Map);w(this,nc,0);w(this,Ro);w(this,Po);w(this,Fi);w(this,Hi,Promise.resolve());w(this,qt,new AbortController);w(this,Lo);b(this,Ro,t),b(this,Po,e),b(this,Fi,n),b(this,Lo,new Promise(i=>{l(this,qt).signal.addEventListener("abort",()=>i())})),p(this,me,nw).call(this)}get signal(){return l(this,qt).signal}get closed(){return l(this,Lo)}async sendRequest(t,e){p(this,me,wh).call(this);const n=eu(this,nc)._++,i=new Promise((s,o)=>{l(this,Wr).set(n,{resolve:s,reject:o})});return await p(this,me,Ks).call(this,{jsonrpc:"2.0",id:n,method:t,params:e}),i}async sendNotification(t,e){p(this,me,wh).call(this),await p(this,me,Ks).call(this,{jsonrpc:"2.0",method:t,params:e})}}Wr=new WeakMap,nc=new WeakMap,Ro=new WeakMap,Po=new WeakMap,Fi=new WeakMap,Hi=new WeakMap,qt=new WeakMap,Lo=new WeakMap,me=new WeakSet,nw=async function(){let t;try{const e=l(this,Fi).readable.getReader();try{for(;!l(this,qt).signal.aborted;){const{value:n,done:i}=await e.read();if(i)break;if(n)try{p(this,me,iw).call(this,n)}catch(s){console.error("Unexpected error during message processing:",n,s),"id"in n&&n.id!==void 0&&p(this,me,Ks).call(this,{jsonrpc:"2.0",id:n.id,error:{code:-32700,message:"Parse error"}})}}}finally{e.releaseLock()}}catch(e){t=e}finally{p(this,me,bh).call(this,t)}},bh=function(t){if(l(this,qt).signal.aborted)return;const e=t??new Error("ACP connection closed");for(const n of l(this,Wr).values())n.reject(e);l(this,Wr).clear(),l(this,qt).abort(e)},iw=async function(t){if("method"in t&&"id"in t){const e=await p(this,me,sw).call(this,t.method,t.params);"error"in e&&console.error("Error handling request",t,e.error),await p(this,me,Ks).call(this,{jsonrpc:"2.0",id:t.id,...e})}else if("method"in t){const e=await p(this,me,ow).call(this,t.method,t.params);"error"in e&&console.error("Error handling notification",t,e.error)}else"id"in t?p(this,me,aw).call(this,t):console.error("Invalid message",{message:t})},sw=async function(t,e){try{return{result:await l(this,Ro).call(this,t,e)??null}}catch(n){if(n instanceof Ce)return n.toResult();if(n instanceof Kg)return Ce.invalidParams(n.format()).toResult();let i;(n instanceof Error||typeof n=="object"&&n!=null&&"message"in n&&typeof n.message=="string")&&(i=n.message);try{return Ce.internalError(i?JSON.parse(i):{}).toResult()}catch{return Ce.internalError({details:i}).toResult()}}},ow=async function(t,e){try{return await l(this,Po).call(this,t,e),{result:null}}catch(n){if(n instanceof Ce)return n.toResult();if(n instanceof Kg)return Ce.invalidParams(n.format()).toResult();let i;(n instanceof Error||typeof n=="object"&&n!=null&&"message"in n&&typeof n.message=="string")&&(i=n.message);try{return Ce.internalError(i?JSON.parse(i):{}).toResult()}catch{return Ce.internalError({details:i}).toResult()}}},aw=function(t){const e=l(this,Wr).get(t.id);if(e){if("result"in t)e.resolve(t.result);else if("error"in t){const{code:n,message:i,data:s}=t.error;e.reject(new Ce(n,i,s))}l(this,Wr).delete(t.id)}else console.error("Got response to unknown request",t.id)},wh=function(){if(l(this,qt).signal.aborted)throw l(this,qt).signal.reason??new Error("ACP connection closed")},Ks=async function(t){return b(this,Hi,l(this,Hi).then(async()=>{const e=l(this,Fi).writable.getWriter();try{await e.write(t)}finally{e.releaseLock()}}).catch(e=>{p(this,me,bh).call(this,e)})),l(this,Hi)};class Ce extends Error{constructor(e,n,i){super(n);g(this,"code");g(this,"data");this.code=e,this.name="RequestError",this.data=i}static parseError(e,n){return new Ce(-32700,`Parse error${n?`: ${n}`:""}`,e)}static invalidRequest(e,n){return new Ce(-32600,`Invalid request${n?`: ${n}`:""}`,e)}static methodNotFound(e){return new Ce(-32601,`"Method not found": ${e}`,{method:e})}static invalidParams(e,n){return new Ce(-32602,`Invalid params${n?`: ${n}`:""}`,e)}static internalError(e,n){return new Ce(-32603,`Internal error${n?`: ${n}`:""}`,e)}static authRequired(e,n){return new Ce(-32e3,`Authentication required${n?`: ${n}`:""}`,e)}static resourceNotFound(e){return new Ce(-32002,`Resource not found${e?`: ${e}`:""}`,e&&{uri:e})}toResult(){return{error:{code:this.code,message:this.message,data:this.data}}}toErrorResponse(){return{code:this.code,message:this.message,data:this.data}}}const Hz=/^Sender \(untrusted metadata\):\n```json\n[\s\S]*?\n```\n\n?/,Zz=/^\[[^\n]*Working directory:[^\n]*\]\n\n?/,Wz=/\[Television screen context\][\s\S]*?\[\/Television screen context\]\n*/,Bz=/\b(tv|television|screen|artifact|artifacts|viewer|filmstrip|layout|focus)\b/i,Vz=/\[\[\s*(?:reply_to_current|reply_to\s*:\s*[^\]\n]+|audio_as_voice)\s*\]\]\s*/gi,jz="single_session",Gz={name:"television-acp-client",version:"0.0.0"},lw="agent:main:television",qz=Ra(Mt);var Zi,Yt,ht,Kt,Br,$t,xr,Jt,Xt,Vr,It,Wi,Bi,Qt,Je,Er,Vi,On,Ar,jr,Do,Ct,er,ic,tr,$,Sh,cw,uw,hw,yl,dw,pw,fw,gw,mw,vw,yw,wn,ki,xi,yr,bw,Ei,_h,kh,bl,ww,wl,xh,Eh,zo,Oo,Sl,Ai,Ah,Sw;class Yz extends qz{constructor(e){super();w(this,$);w(this,Zi,"disconnected");w(this,Yt,null);w(this,ht,new Map);w(this,Kt,null);w(this,Br,null);w(this,$t,null);w(this,xr,null);w(this,Jt,null);w(this,Xt,null);w(this,Vr);w(this,It,null);w(this,Wi,0);w(this,Bi,1);w(this,Qt,null);w(this,Je,null);w(this,Er,!1);w(this,Vi,!1);w(this,On,!1);w(this,Ar,null);w(this,jr,new Set);w(this,Do);w(this,Ct);w(this,er);w(this,ic,e=>{p(this,$,uw).call(this,e)});w(this,tr,null);w(this,zo,()=>{p(this,$,Ai).call(this,"ACP bridge websocket closed")});w(this,Oo,()=>{p(this,$,Ai).call(this,"ACP bridge websocket error")});b(this,Ct,e),b(this,er,e.sessionMode??jz),b(this,Vr,e.mappedSessionStore??Kz()),b(this,Do,e.createSocket??(n=>new WebSocket(n)))}get status(){return l(this,Zi)}get messages(){return[...l(this,ht).values()]}get enabled(){return l(this,Ct).enabled??!1}setToken(e){l(this,Ct).token=e??""}setEnabled(e){l(this,Ct).enabled=e,e||(p(this,$,Sl).call(this),b(this,Yt,null),p(this,$,yr).call(this,"disconnected"))}async connect(){if(this.disposed)throw new Error("ACPClient has been disposed");if(this.enabled&&this.status==="disconnected"){l(this,Br)===null&&(b(this,Yt,null),b(this,Br,p(this,$,cw).call(this)));try{await l(this,Br),await p(this,$,yl).call(this)}catch(e){throw p(this,$,Ai).call(this,Du(e)),e}}}dispose(){p(this,$,Sl).call(this),b(this,Yt,null),p(this,$,yr).call(this,"disposed")}async sendMessage(e){if(await this.connect(),(this.status==="running"||this.status==="cancelling")&&(await this.cancel(),await p(this,$,Sh).call(this,"ready")),(l(this,Jt)===null||l(this,It)!==p(this,$,wl).call(this))&&await p(this,$,yl).call(this),this.status!=="ready")throw new Error("ACPClient is not ready to send a new message");const n=e.text.trim();if(!n)throw new Error("Cannot send an empty message");p(this,$,ki).call(this,{id:p(this,$,Ei).call(this,"user"),kind:"user",text:n,status:"final"}),p(this,$,yr).call(this,"running");try{const i=await p(this,$,bl).call(this).prompt({sessionId:p(this,$,kh).call(this),prompt:[{type:"text",text:p(this,$,bw).call(this,n)}]});p(this,$,wn).call(this,i.stopReason==="cancelled"?"cancelled":"final"),p(this,$,yr).call(this,"ready")}catch(i){throw p(this,$,Sw).call(this)||(p(this,$,wn).call(this,"error"),p(this,$,yr).call(this,"ready")),i}}async startNewSession(){var n;await this.connect(),(this.status==="running"||this.status==="cancelling")&&(await this.cancel(),await p(this,$,Sh).call(this,"ready"));const e=p(this,$,wl).call(this);((n=l(this,Xt))==null?void 0:n.sessionIdStrategy)==="mapped"?l(this,Vr).clearActualSessionId(e):b(this,Wi,l(this,Wi)+1),b(this,$t,null),b(this,xr,null),b(this,Jt,null),b(this,It,null),p(this,$,Ah).call(this)}async cancel(){this.status==="running"&&(p(this,$,yr).call(this,"cancelling"),await p(this,$,bl).call(this).cancel({sessionId:p(this,$,kh).call(this)}))}setScreenContext(e){var s,o,a;if(e===null){if(l(this,Je)===null)return;b(this,Je,null),b(this,Er,!1);return}const n={screenID:e.screenID,screenName:e.screenName};if(((s=l(this,Je))==null?void 0:s.screenID)===n.screenID&&((o=l(this,Je))==null?void 0:o.screenName)===n.screenName)return;const i=((a=l(this,Je))==null?void 0:a.screenID)??null;if(b(this,Je,n),l(this,er)==="single_session"){(!l(this,It)||i!==n.screenID)&&b(this,Er,!0);return}l(this,It)!==p(this,$,xh).call(this,n.screenID)&&(b(this,$t,null),b(this,xr,null),l(this,Kt)&&this.status==="ready"&&p(this,$,yl).call(this).catch(c=>{p(this,$,Ai).call(this,Du(c))}))}}Zi=new WeakMap,Yt=new WeakMap,ht=new WeakMap,Kt=new WeakMap,Br=new WeakMap,$t=new WeakMap,xr=new WeakMap,Jt=new WeakMap,Xt=new WeakMap,Vr=new WeakMap,It=new WeakMap,Wi=new WeakMap,Bi=new WeakMap,Qt=new WeakMap,Je=new WeakMap,Er=new WeakMap,Vi=new WeakMap,On=new WeakMap,Ar=new WeakMap,jr=new WeakMap,Do=new WeakMap,Ct=new WeakMap,er=new WeakMap,ic=new WeakMap,tr=new WeakMap,$=new WeakSet,Sh=async function(e){if(this.status!==e){if(this.status==="disposed")throw new Error("ACPClient has been disposed");if(this.status==="disconnected")throw new Error(l(this,Yt)??"ACPClient is disconnected");await new Promise((n,i)=>{const s=()=>{this.removeEventListener("status-changed",o)},o=()=>{if(this.status===e){s(),n();return}if(this.status==="disposed"){s(),i(new Error("ACPClient has been disposed"));return}this.status==="disconnected"&&(s(),i(new Error(l(this,Yt)??"ACPClient is disconnected")))};this.addEventListener("status-changed",o)})}},cw=async function(){try{const{stream:e,socket:n,metadata:i}=await eO({serverURL:l(this,Ct).serverURL,token:l(this,Ct).token,createSocket:l(this,Do),onDisconnect:l(this,ic)});b(this,Xt,i),b(this,tr,n),n.addEventListener("close",l(this,zo)),n.addEventListener("error",l(this,Oo)),b(this,Kt,new Uz(s=>({connection:s,sessionUpdate:async o=>{await p(this,$,pw).call(this,o)},requestPermission:async o=>p(this,$,fw).call(this,o)}),e)),await l(this,Kt).initialize({protocolVersion:_L,clientCapabilities:{},clientInfo:Gz})}catch(e){throw e}},uw=function(e){p(this,$,Ai).call(this,Du(e))},hw=function(e){const n=e==null?void 0:e.models;if(!(n!=null&&n.currentModelId))return;const i=n.availableModels.find(s=>s.modelId===n.currentModelId);console.info("[ACPClient] Current model:",(i==null?void 0:i.name)??n.currentModelId,`(${n.currentModelId})`)},yl=async function(){const e=p(this,$,wl).call(this);if(l(this,$t)&&l(this,xr)===e){await l(this,$t);return}b(this,xr,e),b(this,$t,p(this,$,dw).call(this,e)),await l(this,$t)},dw=async function(e){var c;const n=p(this,$,bl).call(this);p(this,$,Ah).call(this);let i,s=!1,o=null;const a={cwd:p(this,$,ww).call(this),mcpServers:[],_meta:{sessionKey:e}};try{if(b(this,On,!0),b(this,Ar,null),((c=l(this,Xt))==null?void 0:c.sessionIdStrategy)==="mapped"){const u=l(this,Vr).getActualSessionId(e);if(u)try{const h=await n.loadSession({...a,sessionId:u});if(Jz(h))throw new Error("Mapped ACP session was not found");o=h,i=u,s=!0}catch{const h=await n.newSession(a);o=h,i=h.sessionId,l(this,Vr).setActualSessionId(e,i),s=!1}else{const h=await n.newSession(a);o=h,i=h.sessionId,l(this,Vr).setActualSessionId(e,i),s=!1}}else try{o=await n.loadSession({...a,sessionId:e}),i=e,s=l(this,ht).size>0}catch{const u=await n.newSession(a);o=u,i=u.sessionId,s=!1}}finally{b(this,On,!1),b(this,Ar,null),p(this,$,wn).call(this,"final")}p(this,$,hw).call(this,o),await n.setSessionConfigOption({sessionId:i,configId:"verbose_level",value:"full"}),b(this,Jt,i),b(this,It,e),b(this,Vi,!0),s?(l(this,jr).add(e),l(this,er)==="single_session"&&b(this,Er,!1)):(l(this,jr).delete(e),b(this,Er,l(this,er)==="single_session")),b(this,Yt,null),p(this,$,yr).call(this,"ready")},pw=async function(e){const n=e.update;switch(n.sessionUpdate){case"user_message_chunk":n.content.type==="text"&&p(this,$,yw).call(this,n.content.text);return;case"agent_message_chunk":n.content.type==="text"&&p(this,$,gw).call(this,n.content.text);return;case"tool_call":p(this,$,mw).call(this,n);return;case"tool_call_update":p(this,$,vw).call(this,n);return;case"agent_thought_chunk":return;default:return}},fw=async function(e){return{outcome:{outcome:"cancelled"}}},gw=function(e){b(this,Ar,null);const n=Qz(e);if(!n)return;if(!l(this,Qt)){const s={id:p(this,$,Ei).call(this,"assistant"),kind:"assistant",text:n,status:"streaming"};b(this,Qt,s.id),p(this,$,ki).call(this,s);return}const i=l(this,ht).get(l(this,Qt));if(!i||i.kind!=="assistant")throw new Error("Open assistant message invariant violated");p(this,$,xi).call(this,{...i,text:`${i.text}${n}`,status:"streaming"})},mw=function(e){p(this,$,wn).call(this,"final");const n=p(this,$,_h).call(this,e.toolCallId),i=am("content"in e?e.content:void 0),s={id:(n==null?void 0:n.id)??p(this,$,Ei).call(this,"tool"),kind:"tool_call",toolCallId:e.toolCallId,title:e.title,toolKind:e.kind??"other",status:e.status==="failed"?"failed":e.status==="completed"?"completed":"in_progress",text:(n==null?void 0:n.text)??i,locations:e.locations??(n==null?void 0:n.locations)};if(n){p(this,$,xi).call(this,s);return}p(this,$,ki).call(this,s)},vw=function(e){const n=p(this,$,_h).call(this,e.toolCallId),i=(n==null?void 0:n.text)??"",s=am(e.content),o=s?`${i}${s}`:i,a={id:(n==null?void 0:n.id)??p(this,$,Ei).call(this,"tool"),kind:"tool_call",toolCallId:e.toolCallId,title:(n==null?void 0:n.title)??e.toolCallId,toolKind:(n==null?void 0:n.toolKind)??"other",status:e.status==="failed"?"failed":e.status==="completed"?"completed":"in_progress",text:o,locations:e.locations??(n==null?void 0:n.locations)};if(n){p(this,$,xi).call(this,a);return}p(this,$,ki).call(this,a)},yw=function(e){if(p(this,$,wn).call(this,"final"),!e)return;const n=l(this,On)?l(this,Ar):null;if(!n){const s=om(e);if(!s)return;const o={id:p(this,$,Ei).call(this,"user"),kind:"user",text:s,status:"final"};p(this,$,ki).call(this,o),l(this,On)&&b(this,Ar,o.id);return}const i=l(this,ht).get(n);if(!i||i.kind!=="user")throw new Error("Replay user message invariant violated");p(this,$,xi).call(this,{...i,text:om(`${i.text}${e}`)})},wn=function(e){if(!l(this,Qt))return;const n=l(this,ht).get(l(this,Qt));(n==null?void 0:n.kind)==="assistant"&&p(this,$,xi).call(this,{...n,status:e}),b(this,Qt,null)},ki=function(e){l(this,ht).set(e.id,e),this.dispatchEvent(new $u("messages-changed"))},xi=function(e){l(this,ht).set(e.id,e),this.dispatchEvent(new $u("messages-changed"))},yr=function(e){l(this,Zi)!==e&&(b(this,Zi,e),this.dispatchEvent(new vT("status-changed")))},bw=function(e){const n=l(this,It);if(!n)return e;const i=l(this,Je)?l(this,er)==="single_session"?l(this,Er)||!l(this,jr).has(n):!l(this,jr).has(n):!1,s=l(this,Vi)&&(l(this,Je)!==null||Bz.test(e));if(!(s||i))return e;s&&b(this,Vi,!1),i&&(b(this,Er,!1),l(this,jr).add(n));const a=["[Television screen context]","This chat session is coming from a Television client.","Using Television requires the knowledge in the `television` skill. Re-read it only if it is not already in context or you know it changed.","If the skill is not installed, it can be installed via `tv skills install <your agent skills path>`."];return l(this,Je)?(a.push("This conversation is currently attached to the screen below."),a.push(`screen_id: ${l(this,Je).screenID}`),a.push(`screen_name: ${l(this,Je).screenName??""}`),a.push("When the user asks to inspect or change Television state with the tv CLI, use this screen ID with the --screen argument.")):a.push("There is currently no active Television screen."),a.push("[/Television screen context]","",e),a.join(`
|
|
43
|
-
`)},Ei=function(e){const n=`${e}-${l(this,Bi)}`;return b(this,Bi,l(this,Bi)+1),n},_h=function(e){for(const n of l(this,ht).values())if((n==null?void 0:n.kind)==="tool_call"&&n.toolCallId===e)return n;return null},kh=function(){if(!l(this,Jt))throw new Error("ACP session is not ready");return l(this,Jt)},bl=function(){if(!l(this,Kt))throw new Error("ACP connection is not ready");return l(this,Kt)},ww=function(){var n;const e=(n=l(this,Xt))==null?void 0:n.sessionCwd;if(!e)throw new Error("ACP bridge session cwd is not ready");return e},wl=function(){var n;if(l(this,er)==="single_session")return p(this,$,Eh).call(this,`${lw}-${(l(this,Ct).clientGUID??"default-client").toLowerCase()}`);const e=(n=l(this,Je))==null?void 0:n.screenID;if(!e)throw new Error("Screen context is required for per-screen session mode");return p(this,$,xh).call(this,e)},xh=function(e){return p(this,$,Eh).call(this,Xz(l(this,er),e,l(this,Ct).clientGUID??"default-client"))},Eh=function(e){var n;return((n=l(this,Xt))==null?void 0:n.sessionIdStrategy)==="deterministic"&&l(this,Wi)>0?`${e}:epoch-${l(this,Wi)}`:e},zo=new WeakMap,Oo=new WeakMap,Sl=function(){b(this,Kt,null),b(this,Br,null),b(this,$t,null),b(this,xr,null),b(this,Jt,null),b(this,It,null),b(this,Xt,null),l(this,tr)&&(l(this,tr).removeEventListener("close",l(this,zo)),l(this,tr).removeEventListener("error",l(this,Oo)),l(this,tr).close(),b(this,tr,null))},Ai=function(e){const n=l(this,Kt)!==null||l(this,Br)!==null||l(this,$t)!==null||l(this,xr)!==null||l(this,Jt)!==null||l(this,It)!==null||l(this,Xt)!==null||l(this,tr)!==null;this.disposed||this.status==="disconnected"&&!n||(p(this,$,wn).call(this,"error"),p(this,$,Sl).call(this),b(this,Yt,e??null),p(this,$,yr).call(this,"disconnected"))},Ah=function(){const e=l(this,ht).size>0;b(this,Qt,null),b(this,Ar,null),b(this,Bi,1),l(this,ht).clear(),e&&this.dispatchEvent(new $u("messages-changed"))},Sw=function(){return this.status==="disconnected"};function Kz(){const r=new Map;return{getActualSessionId(t){return r.get(t)??null},setActualSessionId(t,e){r.set(t,e)},clearActualSessionId(t){r.delete(t)}}}function Jz(r){return r==null?!0:typeof r=="object"&&Object.keys(r).length===0}function Xz(r,t,e){return r==="single_session"?`${lw}-${e.toLowerCase()}`:`agent:main:television-${e.toLowerCase()}-${t.toLowerCase()}`}function _w(r){return r.replace(/^(?:\s*\n)+/,"")}function om(r){let t=r;return t=t.replace(Hz,""),t=t.replace(Zz,""),t=t.replace(Wz,""),t=_w(t),t}function Qz(r){let t=r;return t=t.replace(Vz,""),t=_w(t),t}function am(r){return!r||r.length===0?"":r.flatMap(t=>t.type==="content"&&t.content.type==="text"?[t.content.text]:[]).join("")}async function eO(r){const t=r.createSocket(nO(r.serverURL,r.token));let e=!1,n,i;const s=new Promise((u,h)=>{n=u,i=h}),o=new ReadableStream({start(u){let h=!1;const f=()=>{t.send(JSON.stringify({type:"acp-bridge-connect"}))},y=x=>{const I=rO(x);if(!I)return;let P;try{P=JSON.parse(I)}catch(R){const B=R instanceof Error?R:new Error(String(R));i(B),u.error(B);return}switch(P.type){case"acp-bridge-status":if(P.status==="ready"){let R;try{R=tO(P)}catch(B){const N=B instanceof Error?B:new Error(String(B));e||i(N),u.error(N);return}e||(e=!0,n(R));return}if(P.status==="error"||P.status==="exited"){const R=new Error(P.error??`ACP bridge ${P.status}`);e||i(R),u.error(R)}return;case"acp-bridge-message":u.enqueue(P.message);return}},m=()=>{var I;if(h)return;h=!0;const x=new Error("ACP bridge websocket closed");e||i(x),(I=r.onDisconnect)==null||I.call(r,x),u.close()},E=()=>{var I;if(h)return;h=!0;const x=new Error("ACP bridge websocket error");e||i(x),(I=r.onDisconnect)==null||I.call(r,x),u.error(x)};t.addEventListener("open",f),t.addEventListener("message",y),t.addEventListener("close",m),t.addEventListener("error",E)}}),a=new WritableStream({async write(u){await s,t.send(JSON.stringify({type:"acp-bridge-message",message:u}))},close(){t.close()},abort(){t.close()}}),c=await s;return{stream:{readable:o,writable:a},socket:t,metadata:c}}function tO(r){const{agent:t,sessionIdStrategy:e,sessionCwd:n}=r;if((t==="openclaw"||t==="hermes")&&(e==="deterministic"||e==="mapped")&&typeof n=="string"&&n.length>0)return{agent:t,sessionIdStrategy:e,sessionCwd:n};throw new Error("ACP bridge ready status missing bootstrap metadata")}function rO(r){if(typeof r=="string")return r;if(r instanceof Uint8Array)return new TextDecoder().decode(r);if(typeof Buffer<"u"&&r instanceof Buffer)return r.toString("utf8");if(typeof r=="object"&&r!==null&&"data"in r){const t=r.data;if(typeof t=="string")return t;if(t instanceof Uint8Array)return new TextDecoder().decode(t);if(Array.isArray(t))return Buffer.concat(t).toString("utf8")}return null}function nO(r,t){const e=new URL(r);return e.protocol=e.protocol==="https:"?"wss:":"ws:",e.pathname="/acp",e.search="",e.searchParams.set("token",t),e.hash="",e.toString()}function Du(r){return r instanceof Error?r.message:String(r)}const lm="television.acpClientGUID",cm="television.acpMappedSessions",um=1;var ji;class iO{constructor(){w(this,ji,new Map)}getActualSessionId(t){return l(this,ji).get(t)??null}setActualSessionId(t,e){l(this,ji).set(t,e)}clearActualSessionId(t){l(this,ji).delete(t)}}ji=new WeakMap;var Gi,Mo,pt,_l,kl,Th;class sO{constructor(t,e){w(this,pt);w(this,Gi);w(this,Mo);b(this,Gi,t),b(this,Mo,e)}getActualSessionId(t){const e=p(this,pt,kl).call(this)[p(this,pt,_l).call(this,t)];return typeof e=="string"&&e.length>0?e:null}setActualSessionId(t,e){const n=p(this,pt,kl).call(this);n[p(this,pt,_l).call(this,t)]=e,p(this,pt,Th).call(this,n)}clearActualSessionId(t){const e=p(this,pt,kl).call(this);delete e[p(this,pt,_l).call(this,t)],p(this,pt,Th).call(this,e)}}Gi=new WeakMap,Mo=new WeakMap,pt=new WeakSet,_l=function(t){return JSON.stringify([l(this,Mo),t])},kl=function(){const t=l(this,Gi).getItem(cm);if(!t)return{};let e;try{e=JSON.parse(t)}catch{return{}}if(typeof e!="object"||e===null||Array.isArray(e))return{};const n=e;return n.version!==um?{}:typeof n.entries!="object"||n.entries===null||Array.isArray(n.entries)?{}:Object.fromEntries(Object.entries(n.entries).filter(i=>typeof i[1]=="string"))},Th=function(t){const e={version:um,entries:t};l(this,Gi).setItem(cm,JSON.stringify(e))};function kw(){return typeof window>"u"?null:window.localStorage}function oO(r){const t=r.getItem(lm);if(t)return t;const e=Ac().toLowerCase();return r.setItem(lm,e),e}const hm=4401,aO=401,nl=1e3,lO=3e4;class ao extends Error{constructor(t="Authentication required"){super(t),this.name="AuthError"}}class xw extends Mt{constructor(e){var o,a;super();g(this,"url");g(this,"name");g(this,"telemetryMeta");g(this,"status","unauthorized");g(this,"screens",new Map);g(this,"client");g(this,"acpClient");g(this,"_token");g(this,"attempting",!1);g(this,"nextRetryAt",null);g(this,"hasEverConnected",!1);g(this,"hasAuthRejected",!1);g(this,"createSocket");g(this,"createClient");g(this,"socket",null);g(this,"connectAttempt",0);g(this,"autoReconnect",!1);g(this,"retryTimer",null);g(this,"retryDelay",nl);g(this,"visibilityEventTarget");g(this,"networkEventTarget");g(this,"onVisibilityChange");g(this,"onNetworkOnline");g(this,"telemetryActivityAgent");this.url=he(e.url),this.name=e.name,this._token=e.token??null,this.telemetryMeta=e.telemetryMeta??null,this.createSocket=e.createSocket??(c=>new WebSocket(c)),this.createClient=e.createClient??((c,u,h)=>new WT(c,{token:u??void 0,onUnauthorized:()=>this.handleAuthRejected(),...h?{telemetryMeta:h}:{}})),this.client=this.createClient(this.url,this._token,this.telemetryMeta);const n=e.mappedSessionStore??(e.acpStorage?new sO(e.acpStorage,this.url):new iO);this.acpClient=new Yz({serverURL:this.url,token:this._token??"",...e.createACPSocket?{createSocket:e.createACPSocket}:e.createSocket?{createSocket:e.createSocket}:{},...e.clientGUID?{clientGUID:e.clientGUID}:{},mappedSessionStore:n}),this.visibilityEventTarget=e.visibilityEventTarget!==void 0?e.visibilityEventTarget:typeof document<"u"?document:null,this.networkEventTarget=e.networkEventTarget!==void 0?e.networkEventTarget:typeof window<"u"?window:null,this.onVisibilityChange=()=>{this.isPageVisible()&&this.kickReconnect()},this.onNetworkOnline=()=>{this.kickReconnect()},(o=this.visibilityEventTarget)==null||o.addEventListener("visibilitychange",this.onVisibilityChange),(a=this.networkEventTarget)==null||a.addEventListener("online",this.onNetworkOnline);const i=e.telemetryDocumentTarget!==void 0?e.telemetryDocumentTarget:typeof document<"u"?document:null,s=e.telemetryWindowTarget!==void 0?e.telemetryWindowTarget:typeof window<"u"?window:null;this.telemetryActivityAgent=this.telemetryMeta&&i&&s?bL({meta:this.telemetryMeta,documentTarget:i,windowTarget:s,send:c=>this.sendTelemetryActivity(c)}):null}get token(){return this._token}clearToken(){this._token=null,this.acpClient.setToken(null),this.client=this.createClient(this.url,null,this.telemetryMeta)}async connect(e){this._token=e,this.hasAuthRejected=!1,this.acpClient.setToken(e),this.cancelRetryTimer(),this.retryDelay=nl,this.autoReconnect=!0,await this.attempt()}dispose(){var e,n,i,s;this.autoReconnect=!1,this.connectAttempt+=1,this.cancelRetryTimer(),(e=this.socket)==null||e.close(),this.socket=null,this.setStatus("unauthorized"),(n=this.visibilityEventTarget)==null||n.removeEventListener("visibilitychange",this.onVisibilityChange),(i=this.networkEventTarget)==null||i.removeEventListener("online",this.onNetworkOnline),(s=this.telemetryActivityAgent)==null||s.stop(),this.acpClient.dispose()}getViewURL(e){const n=jl(e,{electron:cr()});return cr()?new URL(n.viewURL,this.url).toString():n.renderer==="proxy-iframe"?new URL(n.viewURL,this.url).toString():n.viewURL}getContentURL(e){const n=jl(e,{electron:cr()}).contentURL;return n===null?null:new URL(n,this.url).toString()}async createScreen(e){const{screen:n}=await this.client.screens.create({name:e});return this.screens.set(n.id,structuredClone(n)),n}applyServerEvent(e){switch(e.type){case"screen-created":this.screens.set(e.screen.id,structuredClone(e.screen)),this.dispatchEvent(new Gs("screens-changed"));break;case"screen-updated":this.screens.set(e.screen.id,structuredClone(e.screen)),this.dispatchEvent(new Gs("screens-changed"));break;case"screen-removed":this.screens.delete(e.screenID),this.dispatchEvent(new Gs("screens-changed"));break;case"artifact-created":{const n=this.screens.get(e.screenID);n&&!ml(n).includes(e.artifact.id)&&(n.layout=[...n.layout,Ay(e.artifact.id)]);break}case"artifact-removed":{const n=this.screens.get(e.screenID);n&&(n.layout=my(n.layout,e.artifactID));break}case"artifact-updated":case"artifact-content-changed":case"screen-changed":case"theme-changed":case"artifact-focus":break;default:return cO(e,"server event")}}async attempt(){var i;this.attempting=!0,this.nextRetryAt=null,this.connectAttempt+=1;const e=this.connectAttempt;(i=this.socket)==null||i.close(),this.client=this.createClient(this.url,this._token,this.telemetryMeta),this.setStatus("disconnected"),this.dispatchEvent(new oe("change"));const n=this.createSocket(uO(this.url,this._token,this.telemetryMeta));return this.socket=n,await new Promise((s,o)=>{let a=!1;const c=()=>{var f;a||this.connectAttempt!==e||(a=!0,this.retryDelay=nl,this.hasEverConnected=!0,this.setStatus("connected"),(f=this.telemetryActivityAgent)==null||f.start(),s())},u=f=>{a||this.connectAttempt!==e||(a=!0,o(f))},h=async()=>{const f=this.hasEverConnected;try{const[{screens:y},m]=await Promise.all([this.client.screens.list(),this.client.display.get()]);this.screens=new Map(y.map(E=>[E.id,structuredClone(E)])),this.acpClient.setEnabled(m.acpEnabled),this.dispatchEvent(new oe("change")),f&&this.dispatchEvent(new Gs("screens-changed")),this.dispatchEvent(new hh("server-event",{serverURL:this.url,event:{type:"screen-changed",screenID:m.activeScreenID}})),c(),f&&this.connectAttempt===e&&this.dispatchEvent(new fy("server-reconnected",{serverURL:this.url}))}catch(y){if(pO(y)){u(new ao);return}u(y instanceof Error?y:new Error(String(y)))}};n.addEventListener("open",()=>{h()}),n.addEventListener("message",f=>{const y=dO(f);y&&(this.applyServerEvent(y),this.dispatchEvent(new hh("server-event",{serverURL:this.url,event:y})))}),n.addEventListener("close",f=>{if(this.connectAttempt!==e)return;this.socket=null;const y=hO(f);if(!a){u(y===hm?new ao:new Error("Connection closed before initialization"));return}if(y===hm){this.handleAuthRejected();return}this.handleTransportFailure(new Error("Connection closed"))}),n.addEventListener("error",()=>{if(this.connectAttempt===e){if(a){this.handleTransportFailure(new Error("WebSocket error"));return}u(new Error("WebSocket connection failed"))}})}).then(()=>{this.attempting=!1},s=>{throw this.attempting=!1,this.handleAttemptFailure(s),s})}handleAuthRejected(){this.hasAuthRejected=!0,this.autoReconnect=!1,this.cancelRetryTimer(),this.setStatus("unauthorized")}handleAttemptFailure(e){if(e instanceof ao){this.handleAuthRejected();return}this.autoReconnect&&this.scheduleRetry()}handleTransportFailure(e){this.autoReconnect&&(this.setStatus("disconnected"),this.scheduleRetry())}scheduleRetry(){this.cancelRetryTimer(),this.connectAttempt+=1;const e=this.retryDelay;this.retryDelay=Math.min(this.retryDelay*2,lO),this.nextRetryAt=Date.now()+e,this.retryTimer=setTimeout(()=>{this.retryTimer=null,this.attempt().catch(()=>{})},e),this.dispatchEvent(new oe("change"))}cancelRetryTimer(){this.retryTimer!==null&&(clearTimeout(this.retryTimer),this.retryTimer=null),this.nextRetryAt!==null&&(this.nextRetryAt=null,this.dispatchEvent(new oe("change")))}kickReconnect(){this.autoReconnect&&this.status!=="connected"&&(this.attempting||(this.cancelRetryTimer(),this.retryDelay=nl,this.attempt().catch(()=>{})))}sendTelemetryActivity(e){var n;this.status==="connected"&&((n=this.socket)==null||n.send(JSON.stringify(e)))}setStatus(e){this.status!==e&&(this.status=e,this.dispatchEvent(new oe("change")))}isPageVisible(){return this.visibilityEventTarget===null?!0:this.visibilityEventTarget.visibilityState==="visible"}}function cO(r,t){throw new Error(`Unexpected ${t}: ${JSON.stringify(r)}`)}function uO(r,t,e=null){const n=new URL(r);if(n.protocol=n.protocol==="https:"?"wss:":"ws:",n.pathname="/events",n.search="",t&&n.searchParams.set("token",t),e)for(const[i,s]of yL(e))n.searchParams.set(i,s);return n.hash="",n.toString()}function hO(r){return typeof r=="object"&&r!==null&&"code"in r&&typeof r.code=="number"?r.code:null}function dO(r){const t=typeof r=="string"?r:typeof r=="object"&&r!==null&&"data"in r&&typeof r.data=="string"?r.data:"";if(!t)return null;try{return JSON.parse(t)}catch{return null}}function pO(r){return r instanceof Jd&&r.status===aO}const fO="Local";var No,$h;class gO extends Mt{constructor(e){super();w(this,No);g(this,"servers",new Map);g(this,"localServerURL");g(this,"clientGUID");g(this,"acpStorage");g(this,"telemetryMeta");g(this,"localStore");g(this,"createSocket");g(this,"lastActiveServerURL");g(this,"serverListeners",new Map);g(this,"handleLocalStoreChange",()=>{const e=this.localStore.get().activeServerURL;e!==this.lastActiveServerURL&&(this.lastActiveServerURL=e,this.dispatchEvent(new oe("change")))});this.localStore=e.localStore,this.localServerURL=e.localServerURL?he(e.localServerURL):null,this.createSocket=e.createSocket??(i=>new WebSocket(i)),this.lastActiveServerURL=this.localStore.get().activeServerURL;const n=e.acpStorage===void 0?kw():e.acpStorage;this.acpStorage=n,this.clientGUID=e.clientGUID??(n?oO(n):Ac().toLowerCase()),this.telemetryMeta=e.telemetryMeta??null,this.localStore.addEventListener("change",this.handleLocalStoreChange)}get activeServer(){const e=this.localStore.get().activeServerURL;return e===null?null:this.servers.get(e)??null}add(e){const n=he(e.url);this.servers.get(n)&&this.remove(n),this.servers.set(n,e);const s=()=>{this.dispatchEvent(new oe("change"))},o=u=>{this.dispatchEvent(new hh("server-event",{serverURL:u.serverURL,event:u.event}))},a=()=>{this.dispatchEvent(new Gs("screens-changed"))},c=u=>{this.dispatchEvent(new fy("server-reconnected",{serverURL:u.serverURL}))};e.addEventListener("change",s),e.addEventListener("server-event",o),e.addEventListener("screens-changed",a),e.addEventListener("server-reconnected",c),this.serverListeners.set(n,{onServerChange:s,onServerEvent:o,onScreensChanged:a,onServerReconnected:c}),this.dispatchEvent(new oe("change"))}remove(e){const n=he(e);if(this.localServerURL&&n===this.localServerURL)return;const i=this.servers.get(n);if(!i)return;const s=this.serverListeners.get(n);s&&(i.removeEventListener("change",s.onServerChange),i.removeEventListener("server-event",s.onServerEvent),i.removeEventListener("screens-changed",s.onScreensChanged),i.removeEventListener("server-reconnected",s.onServerReconnected),this.serverListeners.delete(n)),i.dispose(),this.servers.delete(n);const o=this.localStore.get(),a=o.activeServerURL===n;this.localStore.set({...o,servers:o.servers.filter(c=>c.url!==n),activeServerURL:a?null:o.activeServerURL}),this.dispatchEvent(new oe("change"))}getStoredAuthToken(e){return Cu(this.localStore.get(),e)}setStoredAuthToken(e,n){this.localStore.set(QT(this.localStore.get(),e,n))}clearStoredAuthToken(e){const n=this.localStore.get(),i=e$(n,e);i!==n&&this.localStore.set(i)}setActive(e){const n=this.localStore.get(),i=e?he(e.url):null;n.activeServerURL!==i&&this.localStore.set({...n,activeServerURL:i})}connectConfiguredServers(e,n){const i=e?he(e):null;if(i){const a=this.localStore.get();a.servers.some(u=>he(u.url)===i)||this.localStore.set({...a,servers:[...a.servers,{url:i,name:fO}]})}const s=this.localStore.get().servers;for(const a of s){const c=he(a.url),h=i!==null&&c===i?n??Cu(this.localStore.get(),c):Cu(this.localStore.get(),c),f=p(this,No,$h).call(this,{url:a.url,name:a.name,token:h});this.add(f),f.connect(h).catch(()=>{})}const o=i?this.servers.get(i)??null:null;this.setActive(o??this.servers.values().next().value??null)}addServer(e,n){const i=he(e);this.remove(i);const s=this.localStore.get();this.localStore.set({...s,servers:[...s.servers.filter(a=>he(a.url)!==i),{url:i,name:n}]});const o=p(this,No,$h).call(this,{url:i,name:n,token:this.getStoredAuthToken(i)});this.add(o),this.setActive(o),o.connect(o.token).catch(()=>{})}removeServer(e){this.remove(e)}}No=new WeakSet,$h=function(e){return new xw({url:e.url,name:e.name,token:e.token,createSocket:this.createSocket,clientGUID:this.clientGUID,acpStorage:this.acpStorage,telemetryMeta:this.telemetryMeta})};var Uo;class mO extends Mt{constructor(){super();w(this,Uo,e=>{const n=vO(e);n!==null&&(e.preventDefault(),this.dispatchEvent(new mT("shortcut-triggered",{shortcut:n})))});document.addEventListener("keydown",l(this,Uo))}dispose(){document.removeEventListener("keydown",l(this,Uo))}}Uo=new WeakMap;function vO(r){for(const[t,e]of Object.entries(BT))if(yO(r,e.trigger))return t;return null}function yO(r,t){return!(r.key.toLowerCase()!==t.key.toLowerCase()||r.metaKey!==!!t.meta||r.ctrlKey!==!!t.ctrl||r.shiftKey!==!!t.shift||r.altKey!==!!t.alt)}const Ih="tv-nav:",ms="tv-reload",dm=100,bO=1e3,wO=60,SO=60,_O=24,kO=30,xO=kO*_O*SO*wO*bO;function Cr(r){try{const t=new URL(r,window.location.href),e=t.searchParams.has(ms);return t.searchParams.delete(ms),t.origin===window.location.origin?`${t.pathname}${t.search}${t.hash}`:e?t.toString():r}catch{return r}}var Fo,qi,ue,ne,Mn,ke,Ew,Mr,Aw,Ch,Rh;class EO extends Mt{constructor(e,n){super();w(this,ke);w(this,Fo);w(this,qi);w(this,ue,[]);w(this,ne,-1);w(this,Mn,0);b(this,Fo,e),b(this,qi,Cr(n)),p(this,ke,Ew).call(this)}get currentURL(){var e;return l(this,ne)===-1?null:((e=l(this,ue)[l(this,ne)])==null?void 0:e.url)??null}get canGoBack(){return l(this,ne)>-1}get canGoForward(){return l(this,ne)<l(this,ue).length-1}get entries(){return l(this,ue).map(e=>({...e}))}get cursor(){return l(this,ne)}navigate(e){const n=Cr(e);if(n===l(this,qi)){if(l(this,ne)===-1)return;b(this,ne,-1),p(this,ke,Mr).call(this);return}l(this,ne)<l(this,ue).length-1&&b(this,ue,l(this,ue).slice(0,l(this,ne)+1)),l(this,ue).push({url:n}),b(this,ne,l(this,ue).length-1),p(this,ke,Ch).call(this),p(this,ke,Mr).call(this)}replace(e){var i;if(l(this,ne)===-1){this.navigate(e);return}const n=Cr(e);if(n===l(this,qi)){b(this,ue,l(this,ue).filter((s,o)=>o!==l(this,ne))),b(this,ne,-1),p(this,ke,Mr).call(this);return}((i=l(this,ue)[l(this,ne)])==null?void 0:i.url)!==n&&(b(this,ue,l(this,ue).map((s,o)=>o===l(this,ne)?{url:n}:s)),p(this,ke,Mr).call(this))}back(){l(this,ne)!==-1&&(b(this,ne,l(this,ne)-1),p(this,ke,Mr).call(this))}forward(){this.canGoForward&&(b(this,ne,l(this,ne)+1),p(this,ke,Mr).call(this))}reset(){l(this,ne)===-1&&l(this,ue).length===0||(b(this,ue,[]),b(this,ne,-1),p(this,ke,Mr).call(this))}}Fo=new WeakMap,qi=new WeakMap,ue=new WeakMap,ne=new WeakMap,Mn=new WeakMap,ke=new WeakSet,Ew=function(){const e=localStorage.getItem(l(this,ke,Rh));if(e!==null)try{const n=JSON.parse(e);if(!Tw(n))return;b(this,ue,n.entries.map(i=>({url:i.url}))),b(this,ne,n.cursor),b(this,Mn,n.lastWritten),p(this,ke,Ch).call(this)}catch{b(this,ue,[]),b(this,ne,-1),b(this,Mn,0)}},Mr=function(){b(this,Mn,Date.now());try{localStorage.setItem(l(this,ke,Rh),JSON.stringify(p(this,ke,Aw).call(this)))}catch(e){if(!$O(e))throw e}this.dispatchEvent(new oe("change"))},Aw=function(){return{v:1,entries:l(this,ue).map(e=>({...e})),cursor:l(this,ne),lastWritten:l(this,Mn)}},Ch=function(){if(l(this,ue).length<=dm)return;const e=l(this,ue).length-dm;b(this,ue,l(this,ue).slice(e)),b(this,ne,Math.max(-1,l(this,ne)-e))},Rh=function(){return AO(l(this,Fo))};function AO(r){return`${Ih}${r}`}function TO(r){const t=Date.now()-xO,e=[];for(let n=0;n<localStorage.length;n+=1){const i=localStorage.key(n);if(!(i!=null&&i.startsWith(Ih)))continue;const s=i.slice(Ih.length),o=localStorage.getItem(i);if(o===null)continue;let a;try{a=JSON.parse(o)}catch{e.push(i);continue}if(!Tw(a)){e.push(i);continue}!r.has(s)&&a.lastWritten<t&&e.push(i)}for(const n of e)localStorage.removeItem(n)}function $O(r){return r instanceof DOMException&&r.name==="QuotaExceededError"}function Tw(r){if(typeof r!="object"||r===null)return!1;const t=r;if(t.v!==1||!Array.isArray(t.entries))return!1;const e=t.cursor;return typeof e!="number"||!Number.isInteger(e)||typeof t.lastWritten!="number"||!Number.isFinite(t.lastWritten)||e<-1||e>=t.entries.length?!1:t.entries.every(n=>typeof n=="object"&&n!==null&&typeof n.url=="string")}let Or=null;async function $w(r,t){if(Or==null||Or.abort(),r===null){Or=null,Hl();return}const e=new AbortController;Or=e;try{const n=t.token?{Authorization:`Bearer ${t.token}`}:void 0,i=new URL(`/themes/${r}/theme.css`,t.url).toString(),s=await fetch(i,{signal:e.signal,...n?{headers:n}:{}});if(!s.ok)throw new Error(`Theme fetch failed: ${s.status}`);const o=await s.text();if(Or!==e)return;py(o)}catch(n){if(n.name==="AbortError")return;Hl();const i=n instanceof Error?n.message:String(n);console.warn(`applyTheme: ${i}`)}finally{Or===e&&(Or=null)}}/**
|
|
44
|
-
* @license
|
|
45
|
-
* Copyright 2017 Google LLC
|
|
46
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
47
|
-
*/const lo=globalThis,pm=r=>r,Gl=lo.trustedTypes,fm=Gl?Gl.createPolicy("lit-html",{createHTML:r=>r}):void 0,Iw="$lit$",Ur=`lit$${Math.random().toFixed(9).slice(2)}$`,Cw="?"+Ur,IO=`<${Cw}>`,Qn=document,vo=()=>Qn.createComment(""),yo=r=>r===null||typeof r!="object"&&typeof r!="function",ap=Array.isArray,CO=r=>ap(r)||typeof(r==null?void 0:r[Symbol.iterator])=="function",zu=`[
|
|
48
|
-
\f\r]`,Ns=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,gm=/-->/g,mm=/>/g,gn=RegExp(`>|${zu}(?:([^\\s"'>=/]+)(${zu}*=${zu}*(?:[^
|
|
49
|
-
\f\r"'\`<>=]|("|')|))|$)`,"g"),vm=/'/g,ym=/"/g,Rw=/^(?:script|style|textarea|title)$/i,RO=r=>(t,...e)=>({_$litType$:r,strings:t,values:e}),D=RO(1),ei=Symbol.for("lit-noChange"),le=Symbol.for("lit-nothing"),bm=new WeakMap,$n=Qn.createTreeWalker(Qn,129);function Pw(r,t){if(!ap(r)||!r.hasOwnProperty("raw"))throw Error("invalid template strings array");return fm!==void 0?fm.createHTML(t):t}const PO=(r,t)=>{const e=r.length-1,n=[];let i,s=t===2?"<svg>":t===3?"<math>":"",o=Ns;for(let a=0;a<e;a++){const c=r[a];let u,h,f=-1,y=0;for(;y<c.length&&(o.lastIndex=y,h=o.exec(c),h!==null);)y=o.lastIndex,o===Ns?h[1]==="!--"?o=gm:h[1]!==void 0?o=mm:h[2]!==void 0?(Rw.test(h[2])&&(i=RegExp("</"+h[2],"g")),o=gn):h[3]!==void 0&&(o=gn):o===gn?h[0]===">"?(o=i??Ns,f=-1):h[1]===void 0?f=-2:(f=o.lastIndex-h[2].length,u=h[1],o=h[3]===void 0?gn:h[3]==='"'?ym:vm):o===ym||o===vm?o=gn:o===gm||o===mm?o=Ns:(o=gn,i=void 0);const m=o===gn&&r[a+1].startsWith("/>")?" ":"";s+=o===Ns?c+IO:f>=0?(n.push(u),c.slice(0,f)+Iw+c.slice(f)+Ur+m):c+Ur+(f===-2?a:m)}return[Pw(r,s+(r[e]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),n]};class bo{constructor({strings:t,_$litType$:e},n){let i;this.parts=[];let s=0,o=0;const a=t.length-1,c=this.parts,[u,h]=PO(t,e);if(this.el=bo.createElement(u,n),$n.currentNode=this.el.content,e===2||e===3){const f=this.el.content.firstChild;f.replaceWith(...f.childNodes)}for(;(i=$n.nextNode())!==null&&c.length<a;){if(i.nodeType===1){if(i.hasAttributes())for(const f of i.getAttributeNames())if(f.endsWith(Iw)){const y=h[o++],m=i.getAttribute(f).split(Ur),E=/([.?@])?(.*)/.exec(y);c.push({type:1,index:s,name:E[2],strings:m,ctor:E[1]==="."?DO:E[1]==="?"?zO:E[1]==="@"?OO:Mc}),i.removeAttribute(f)}else f.startsWith(Ur)&&(c.push({type:6,index:s}),i.removeAttribute(f));if(Rw.test(i.tagName)){const f=i.textContent.split(Ur),y=f.length-1;if(y>0){i.textContent=Gl?Gl.emptyScript:"";for(let m=0;m<y;m++)i.append(f[m],vo()),$n.nextNode(),c.push({type:2,index:++s});i.append(f[y],vo())}}}else if(i.nodeType===8)if(i.data===Cw)c.push({type:2,index:s});else{let f=-1;for(;(f=i.data.indexOf(Ur,f+1))!==-1;)c.push({type:7,index:s}),f+=Ur.length-1}s++}}static createElement(t,e){const n=Qn.createElement("template");return n.innerHTML=t,n}}function vs(r,t,e=r,n){var o,a;if(t===ei)return t;let i=n!==void 0?(o=e._$Co)==null?void 0:o[n]:e._$Cl;const s=yo(t)?void 0:t._$litDirective$;return(i==null?void 0:i.constructor)!==s&&((a=i==null?void 0:i._$AO)==null||a.call(i,!1),s===void 0?i=void 0:(i=new s(r),i._$AT(r,e,n)),n!==void 0?(e._$Co??(e._$Co=[]))[n]=i:e._$Cl=i),i!==void 0&&(t=vs(r,i._$AS(r,t.values),i,n)),t}class LO{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:e},parts:n}=this._$AD,i=((t==null?void 0:t.creationScope)??Qn).importNode(e,!0);$n.currentNode=i;let s=$n.nextNode(),o=0,a=0,c=n[0];for(;c!==void 0;){if(o===c.index){let u;c.type===2?u=new Oc(s,s.nextSibling,this,t):c.type===1?u=new c.ctor(s,c.name,c.strings,this,t):c.type===6&&(u=new MO(s,this,t)),this._$AV.push(u),c=n[++a]}o!==(c==null?void 0:c.index)&&(s=$n.nextNode(),o++)}return $n.currentNode=Qn,i}p(t){let e=0;for(const n of this._$AV)n!==void 0&&(n.strings!==void 0?(n._$AI(t,n,e),e+=n.strings.length-2):n._$AI(t[e])),e++}}let Oc=class Lw{get _$AU(){var t;return((t=this._$AM)==null?void 0:t._$AU)??this._$Cv}constructor(t,e,n,i){this.type=2,this._$AH=le,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=n,this.options=i,this._$Cv=(i==null?void 0:i.isConnected)??!0}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return e!==void 0&&(t==null?void 0:t.nodeType)===11&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=vs(this,t,e),yo(t)?t===le||t==null||t===""?(this._$AH!==le&&this._$AR(),this._$AH=le):t!==this._$AH&&t!==ei&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):CO(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==le&&yo(this._$AH)?this._$AA.nextSibling.data=t:this.T(Qn.createTextNode(t)),this._$AH=t}$(t){var s;const{values:e,_$litType$:n}=t,i=typeof n=="number"?this._$AC(t):(n.el===void 0&&(n.el=bo.createElement(Pw(n.h,n.h[0]),this.options)),n);if(((s=this._$AH)==null?void 0:s._$AD)===i)this._$AH.p(e);else{const o=new LO(i,this),a=o.u(this.options);o.p(e),this.T(a),this._$AH=o}}_$AC(t){let e=bm.get(t.strings);return e===void 0&&bm.set(t.strings,e=new bo(t)),e}k(t){ap(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let n,i=0;for(const s of t)i===e.length?e.push(n=new Lw(this.O(vo()),this.O(vo()),this,this.options)):n=e[i],n._$AI(s),i++;i<e.length&&(this._$AR(n&&n._$AB.nextSibling,i),e.length=i)}_$AR(t=this._$AA.nextSibling,e){var n;for((n=this._$AP)==null?void 0:n.call(this,!1,!0,e);t!==this._$AB;){const i=pm(t).nextSibling;pm(t).remove(),t=i}}setConnected(t){var e;this._$AM===void 0&&(this._$Cv=t,(e=this._$AP)==null||e.call(this,t))}},Mc=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,n,i,s){this.type=1,this._$AH=le,this._$AN=void 0,this.element=t,this.name=e,this._$AM=i,this.options=s,n.length>2||n[0]!==""||n[1]!==""?(this._$AH=Array(n.length-1).fill(new String),this.strings=n):this._$AH=le}_$AI(t,e=this,n,i){const s=this.strings;let o=!1;if(s===void 0)t=vs(this,t,e,0),o=!yo(t)||t!==this._$AH&&t!==ei,o&&(this._$AH=t);else{const a=t;let c,u;for(t=s[0],c=0;c<s.length-1;c++)u=vs(this,a[n+c],e,c),u===ei&&(u=this._$AH[c]),o||(o=!yo(u)||u!==this._$AH[c]),u===le?t=le:t!==le&&(t+=(u??"")+s[c+1]),this._$AH[c]=u}o&&!i&&this.j(t)}j(t){t===le?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}},DO=class extends Mc{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===le?void 0:t}},zO=class extends Mc{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==le)}},OO=class extends Mc{constructor(t,e,n,i,s){super(t,e,n,i,s),this.type=5}_$AI(t,e=this){if((t=vs(this,t,e,0)??le)===ei)return;const n=this._$AH,i=t===le&&n!==le||t.capture!==n.capture||t.once!==n.once||t.passive!==n.passive,s=t!==le&&(n===le||i);i&&this.element.removeEventListener(this.name,this,n),s&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var e;typeof this._$AH=="function"?this._$AH.call(((e=this.options)==null?void 0:e.host)??this.element,t):this._$AH.handleEvent(t)}};class MO{constructor(t,e,n){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=n}get _$AU(){return this._$AM._$AU}_$AI(t){vs(this,t)}}const NO={I:Oc},Ou=lo.litHtmlPolyfillSupport;Ou==null||Ou(bo,Oc),(lo.litHtmlVersions??(lo.litHtmlVersions=[])).push("3.3.2");const Be=(r,t,e)=>{const n=t;let i=n._$litPart$;return i===void 0&&(n._$litPart$=i=new Oc(t.insertBefore(vo(),null),null,void 0,{})),i._$AI(r),i};/**
|
|
50
|
-
* @license
|
|
51
|
-
* Copyright 2017 Google LLC
|
|
52
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
53
|
-
*/const lp={CHILD:2},Nc=r=>(...t)=>({_$litDirective$:r,values:t});let cp=class{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,n){this._$Ct=t,this._$AM=e,this._$Ci=n}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}};/**
|
|
54
|
-
* @license
|
|
55
|
-
* Copyright 2017 Google LLC
|
|
56
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
57
|
-
*/let ql=class extends cp{constructor(t){if(super(t),this.it=le,t.type!==lp.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(t){if(t===le||t==null)return this._t=void 0,this.it=t;if(t===ei)return t;if(typeof t!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(t===this.it)return this._t;this.it=t;const e=[t];return e.raw=e,this._t={_$litType$:this.constructor.resultType,strings:e,values:[]}}};ql.directiveName="unsafeHTML",ql.resultType=1;const UO=Nc(ql);/**
|
|
58
|
-
* @license
|
|
59
|
-
* Copyright 2017 Google LLC
|
|
60
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
61
|
-
*/let Ph=class extends ql{};Ph.directiveName="unsafeSVG",Ph.resultType=2;const Dw=Nc(Ph),FO={size:16,color:"currentColor",weight:"regular"};function HO(r){return typeof r=="string"?{regular:r}:r}function Nt(r,t="0 0 256 256"){const e=HO(r);return n=>{const{size:i,color:s,weight:o}={...FO,...n},a=e[o]??e.regular;return D`<svg
|
|
62
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
63
|
-
data-ui-icon=""
|
|
64
|
-
width="${i}"
|
|
65
|
-
height="${i}"
|
|
66
|
-
viewBox="${t}"
|
|
67
|
-
fill="${s}"
|
|
68
|
-
>${Dw(a)}</svg>`}}/**
|
|
69
|
-
* @license
|
|
70
|
-
* Copyright 2020 Google LLC
|
|
71
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
72
|
-
*/const{I:ZO}=NO,wm=r=>r,WO=r=>r.strings===void 0,Sm=()=>document.createComment(""),Us=(r,t,e)=>{var s;const n=r._$AA.parentNode,i=t===void 0?r._$AB:t._$AA;if(e===void 0){const o=n.insertBefore(Sm(),i),a=n.insertBefore(Sm(),i);e=new ZO(o,a,r,r.options)}else{const o=e._$AB.nextSibling,a=e._$AM,c=a!==r;if(c){let u;(s=e._$AQ)==null||s.call(e,r),e._$AM=r,e._$AP!==void 0&&(u=r._$AU)!==a._$AU&&e._$AP(u)}if(o!==i||c){let u=e._$AA;for(;u!==o;){const h=wm(u).nextSibling;wm(n).insertBefore(u,i),u=h}}}return e},mn=(r,t,e=r)=>(r._$AI(t,e),r),BO={},VO=(r,t=BO)=>r._$AH=t,jO=r=>r._$AH,Mu=r=>{r._$AR(),r._$AA.remove()};/**
|
|
73
|
-
* @license
|
|
74
|
-
* Copyright 2017 Google LLC
|
|
75
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
76
|
-
*/const co=(r,t)=>{var n;const e=r._$AN;if(e===void 0)return!1;for(const i of e)(n=i._$AO)==null||n.call(i,t,!1),co(i,t);return!0},Yl=r=>{let t,e;do{if((t=r._$AM)===void 0)break;e=t._$AN,e.delete(r),r=t}while((e==null?void 0:e.size)===0)},zw=r=>{for(let t;t=r._$AM;r=t){let e=t._$AN;if(e===void 0)t._$AN=e=new Set;else if(e.has(r))break;e.add(r),YO(t)}};function GO(r){this._$AN!==void 0?(Yl(this),this._$AM=r,zw(this)):this._$AM=r}function qO(r,t=!1,e=0){const n=this._$AH,i=this._$AN;if(i!==void 0&&i.size!==0)if(t)if(Array.isArray(n))for(let s=e;s<n.length;s++)co(n[s],!1),Yl(n[s]);else n!=null&&(co(n,!1),Yl(n));else co(this,r)}const YO=r=>{r.type==lp.CHILD&&(r._$AP??(r._$AP=qO),r._$AQ??(r._$AQ=GO))};class KO extends cp{constructor(){super(...arguments),this._$AN=void 0}_$AT(t,e,n){super._$AT(t,e,n),zw(this),this.isConnected=t._$AU}_$AO(t,e=!0){var n,i;t!==this.isConnected&&(this.isConnected=t,t?(n=this.reconnected)==null||n.call(this):(i=this.disconnected)==null||i.call(this)),e&&(co(this,t),Yl(this))}setValue(t){if(WO(this._$Ct))this._$Ct._$AI(t,this);else{const e=[...this._$Ct._$AH];e[this._$Ci]=t,this._$Ct._$AI(e,this,0)}}disconnected(){}reconnected(){}}/**
|
|
77
|
-
* @license
|
|
78
|
-
* Copyright 2020 Google LLC
|
|
79
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
80
|
-
*/const xl=()=>new JO;class JO{}const Nu=new WeakMap,El=Nc(class extends KO{render(r){return le}update(r,[t]){var n;const e=t!==this.G;return e&&this.G!==void 0&&this.rt(void 0),(e||this.lt!==this.ct)&&(this.G=t,this.ht=(n=r.options)==null?void 0:n.host,this.rt(this.ct=r.element)),le}rt(r){if(this.isConnected||(r=void 0),typeof this.G=="function"){const t=this.ht??globalThis;let e=Nu.get(t);e===void 0&&(e=new WeakMap,Nu.set(t,e)),e.get(this.G)!==void 0&&this.G.call(this.ht,void 0),e.set(this.G,r),r!==void 0&&this.G.call(this.ht,r)}else this.G.value=r}get lt(){var r,t;return typeof this.G=="function"?(r=Nu.get(this.ht??globalThis))==null?void 0:r.get(this.G):(t=this.G)==null?void 0:t.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}}),up=Nt('<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"/>'),XO=Nt('<path d="M224,128a8,8,0,0,1-8,8H59.31l58.35,58.34a8,8,0,0,1-11.32,11.32l-72-72a8,8,0,0,1,0-11.32l72-72a8,8,0,0,1,11.32,11.32L59.31,120H216A8,8,0,0,1,224,128Z"/>'),QO=Nt('<path d="M216,56V200a16,16,0,0,1-16,16H56a16,16,0,0,1-16-16V56A16,16,0,0,1,56,40H200A16,16,0,0,1,216,56Z"/>'),Kl=Nt('<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"/>'),eM=Nt('<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"/>'),tM=Nt({regular:'<path d="M216,64H147.31l34.35-34.34a8,8,0,1,0-11.32-11.32L128,60.69,85.66,18.34A8,8,0,0,0,74.34,29.66L108.69,64H40A16,16,0,0,0,24,80V200a16,16,0,0,0,16,16H216a16,16,0,0,0,16-16V80A16,16,0,0,0,216,64Zm0,136H40V80H216V200Z"/>',bold:'<path d="M216,60H157l27.52-27.52a12,12,0,0,0-17-17L128,55,88.49,15.51a12,12,0,0,0-17,17L99,60H40A20,20,0,0,0,20,80V200a20,20,0,0,0,20,20H216a20,20,0,0,0,20-20V80A20,20,0,0,0,216,60Zm-4,136H44V84H212Z"/>'}),rM=Nt({regular:'<path d="M224,160V96a8,8,0,0,0-8-8H168V40a8,8,0,0,0-8-8H40a8,8,0,0,0-8,8V160a8,8,0,0,0,8,8H88v48a8,8,0,0,0,8,8H216a8,8,0,0,0,8-8V160Zm-60.69,48-40-40h33.38l40,40ZM168,156.69V123.31l40,40v33.38Zm40-16L171.31,104H208ZM48,48H152v56h0v48H48Zm56,123.31L140.69,208H104Z"/>',duotone:'<path d="M216,96V216H96V160h64V96Z" opacity="0.2"/><path d="M216,88H168V40a8,8,0,0,0-8-8H40a8,8,0,0,0-8,8V160a8,8,0,0,0,8,8H88v48a8,8,0,0,0,8,8H216a8,8,0,0,0,8-8V96A8,8,0,0,0,216,88ZM48,48H152V152H48ZM208,208H104V168h56a8,8,0,0,0,8-8V104h40Z"/>'}),nM=Nt({regular:'<path d="M104,40H56A16,16,0,0,0,40,56v48a16,16,0,0,0,16,16h48a16,16,0,0,0,16-16V56A16,16,0,0,0,104,40Zm0,64H56V56h48v48Zm96-64H152a16,16,0,0,0-16,16v48a16,16,0,0,0,16,16h48a16,16,0,0,0,16-16V56A16,16,0,0,0,200,40Zm0,64H152V56h48v48Zm-96,32H56a16,16,0,0,0-16,16v48a16,16,0,0,0,16,16h48a16,16,0,0,0,16-16V152A16,16,0,0,0,104,136Zm0,64H56V152h48v48Zm96-64H152a16,16,0,0,0-16,16v48a16,16,0,0,0,16,16h48a16,16,0,0,0,16-16V152A16,16,0,0,0,200,136Zm0,64H152V152h48v48Z"/>',bold:'<path d="M100,36H56A20,20,0,0,0,36,56v44a20,20,0,0,0,20,20h44a20,20,0,0,0,20-20V56A20,20,0,0,0,100,36ZM96,96H60V60H96ZM200,36H156a20,20,0,0,0-20,20v44a20,20,0,0,0,20,20h44a20,20,0,0,0,20-20V56A20,20,0,0,0,200,36Zm-4,60H160V60h36Zm-96,40H56a20,20,0,0,0-20,20v44a20,20,0,0,0,20,20h44a20,20,0,0,0,20-20V156A20,20,0,0,0,100,136Zm-4,60H60V160H96Zm104-60H156a20,20,0,0,0-20,20v44a20,20,0,0,0,20,20h44a20,20,0,0,0,20-20V156A20,20,0,0,0,200,136Zm-4,60H160V160h36Z"/>',duotone:'<path d="M112,56v48a8,8,0,0,1-8,8H56a8,8,0,0,1-8-8V56a8,8,0,0,1,8-8h48A8,8,0,0,1,112,56Zm88-8H152a8,8,0,0,0-8,8v48a8,8,0,0,0,8,8h48a8,8,0,0,0,8-8V56A8,8,0,0,0,200,48Zm-96,96H56a8,8,0,0,0-8,8v48a8,8,0,0,0,8,8h48a8,8,0,0,0,8-8V152A8,8,0,0,0,104,144Zm96,0H152a8,8,0,0,0-8,8v48a8,8,0,0,0,8,8h48a8,8,0,0,0,8-8V152A8,8,0,0,0,200,144Z" opacity="0.2"/><path d="M200,136H152a16,16,0,0,0-16,16v48a16,16,0,0,0,16,16h48a16,16,0,0,0,16-16V152A16,16,0,0,0,200,136Zm0,64H152V152h48v48ZM104,40H56A16,16,0,0,0,40,56v48a16,16,0,0,0,16,16h48a16,16,0,0,0,16-16V56A16,16,0,0,0,104,40Zm0,64H56V56h48v48Zm96-64H152a16,16,0,0,0-16,16v48a16,16,0,0,0,16,16h48a16,16,0,0,0,16-16V56A16,16,0,0,0,200,40Zm0,64H152V56h48v48Zm-96,32H56a16,16,0,0,0-16,16v48a16,16,0,0,0,16,16h48a16,16,0,0,0,16-16V152A16,16,0,0,0,104,136Zm0,64H56V152h48v48Z"/>'}),iM=Nt('<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"/>'),Ow=Nt({regular:'<path d="M136,32V64a8,8,0,0,1-16,0V32a8,8,0,0,1,16,0Zm88,88H192a8,8,0,0,0,0,16h32a8,8,0,0,0,0-16Zm-45.09,47.6a8,8,0,0,0-11.31,11.31l22.62,22.63a8,8,0,0,0,11.32-11.32ZM128,184a8,8,0,0,0-8,8v32a8,8,0,0,0,16,0V192A8,8,0,0,0,128,184ZM77.09,167.6,54.46,190.22a8,8,0,0,0,11.32,11.32L88.4,178.91A8,8,0,0,0,77.09,167.6ZM72,128a8,8,0,0,0-8-8H32a8,8,0,0,0,0,16H64A8,8,0,0,0,72,128ZM65.78,54.46A8,8,0,0,0,54.46,65.78L77.09,88.4A8,8,0,0,0,88.4,77.09Z"/>',bold:'<path d="M140,32V64a12,12,0,0,1-24,0V32a12,12,0,0,1,24,0Zm84,84H192a12,12,0,0,0,0,24h32a12,12,0,0,0,0-24Zm-42.26,48.77a12,12,0,1,0-17,17l22.63,22.63a12,12,0,0,0,17-17ZM128,180a12,12,0,0,0-12,12v32a12,12,0,0,0,24,0V192A12,12,0,0,0,128,180ZM74.26,164.77,51.63,187.4a12,12,0,0,0,17,17l22.63-22.63a12,12,0,1,0-17-17ZM76,128a12,12,0,0,0-12-12H32a12,12,0,0,0,0,24H64A12,12,0,0,0,76,128ZM68.6,51.63a12,12,0,1,0-17,17L74.26,91.23a12,12,0,0,0,17-17Z"/>'}),sM=Nt('<path d="M173.66,98.34a8,8,0,0,1,0,11.32l-56,56a8,8,0,0,1-11.32,0l-24-24a8,8,0,0,1,11.32-11.32L112,148.69l50.34-50.35A8,8,0,0,1,173.66,98.34ZM232,128A104,104,0,1,1,128,24,104.11,104.11,0,0,1,232,128Zm-16,0a88,88,0,1,0-88,88A88.1,88.1,0,0,0,216,128Z"/>');class oM extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}const _m='a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])',Uu=4;var Fe,it,Nn,st,Ho,Yi,Ki,W,Lh,Dh,Nw,Al,Uw,zh,Oh,Zo,Wo,Un,Fw,Mh,Hw,Zw,Tl,Ti;class Mw extends HTMLElement{constructor(){super();w(this,W);w(this,Fe,!1);w(this,it,null);w(this,Nn);w(this,st,null);w(this,Ho,"bottom-start");w(this,Yi,!1);w(this,Ki,!1);w(this,Zo,e=>{l(this,Fe)&&(l(this,Yi)||e.composedPath().includes(this)||(this.open=!1))});w(this,Wo,e=>{if(l(this,Fe)){if(e.key==="Escape"){e.preventDefault(),this.open=!1;return}e.key==="Tab"&&p(this,W,Fw).call(this,e)}});w(this,Un,()=>{l(this,Fe)&&p(this,W,Tl).call(this)});b(this,Nn,this.attachShadow({mode:"open"})),qd(l(this,Nn)),p(this,W,Dh).call(this,"anchor")}connectedCallback(){this.removeAttribute("popover"),this.hasAttribute("tone")||this.setAttribute("tone","light"),p(this,W,Dh).call(this,"open"),p(this,W,Ti).call(this),l(this,Fe)&&(p(this,W,zh).call(this),p(this,W,Al).call(this))}disconnectedCallback(){var e;p(this,W,Oh).call(this),(e=l(this,it))==null||e.removeAttribute("aria-expanded")}attributeChangedCallback(e){e==="open"?p(this,W,Nw).call(this,this.hasAttribute("open")):e==="material"&&l(this,Fe)&&(p(this,W,Ti).call(this),p(this,W,Al).call(this))}get open(){return l(this,Fe)}set open(e){this.toggleAttribute("open",e)}get anchor(){return l(this,it)}set anchor(e){l(this,it)!==e&&(l(this,it)&&l(this,it).removeAttribute("aria-expanded"),b(this,it,e),p(this,W,Lh).call(this),l(this,Fe)&&p(this,W,Tl).call(this))}}Fe=new WeakMap,it=new WeakMap,Nn=new WeakMap,st=new WeakMap,Ho=new WeakMap,Yi=new WeakMap,Ki=new WeakMap,W=new WeakSet,Lh=function(){l(this,it)&&l(this,it).setAttribute("aria-expanded",l(this,Fe)?"true":"false")},Dh=function(e){if(!Object.prototype.hasOwnProperty.call(this,e))return;const n=this,i=n[e];delete n[e],n[e]=i},Nw=function(e){var n,i,s;if(l(this,Fe)!==e){if(b(this,Fe,e),p(this,W,Lh).call(this),!this.isConnected){p(this,W,Ti).call(this);return}e?(b(this,Yi,!0),setTimeout(()=>{b(this,Yi,!1)},0),p(this,W,Ti).call(this),p(this,W,zh).call(this),p(this,W,Al).call(this)):(p(this,W,Oh).call(this),(i=(n=l(this,st))==null?void 0:n.hidePopover)==null||i.call(n),p(this,W,Ti).call(this),(s=l(this,it))==null||s.focus(),this.dispatchEvent(new oM))}},Al=function(){l(this,Ki)||(b(this,Ki,!0),queueMicrotask(()=>{b(this,Ki,!1),!(!l(this,Fe)||!this.isConnected)&&(p(this,W,Uw).call(this),p(this,W,Zw).call(this))}))},Uw=function(){var e,n;if(l(this,st)){try{(n=(e=l(this,st)).showPopover)==null||n.call(e)}catch{}p(this,W,Tl).call(this)}},zh=function(){document.addEventListener("click",l(this,Zo)),document.addEventListener("keydown",l(this,Wo),!0),window.addEventListener("resize",l(this,Un)),window.addEventListener("scroll",l(this,Un),!0)},Oh=function(){document.removeEventListener("click",l(this,Zo)),document.removeEventListener("keydown",l(this,Wo),!0),window.removeEventListener("resize",l(this,Un)),window.removeEventListener("scroll",l(this,Un),!0)},Zo=new WeakMap,Wo=new WeakMap,Un=new WeakMap,Fw=function(e){const n=p(this,W,Mh).call(this);if(n.length===0){e.preventDefault();return}const i=n[0],s=n[n.length-1],o=p(this,W,Hw).call(this),a=o instanceof HTMLElement&&n.includes(o);e.shiftKey?(!a||o===i)&&(e.preventDefault(),s.focus()):(!a||o===s)&&(e.preventDefault(),i.focus())},Mh=function(){if(!l(this,st))return[];const e=l(this,st).querySelector("slot");if(!(e instanceof HTMLSlotElement))return[];const n=[];for(const i of e.assignedElements({flatten:!0}))if(i instanceof HTMLElement){i.matches(_m)&&n.push(i);for(const s of i.querySelectorAll(_m))n.push(s)}return n},Hw=function(){var n;let e=document.activeElement;for(;e&&((n=e.shadowRoot)!=null&&n.activeElement);)e=e.shadowRoot.activeElement;return e},Zw=function(){var n;const e=p(this,W,Mh).call(this);e.length>0?e[0].focus():(n=l(this,st))==null||n.focus()},Tl=function(){if(!l(this,Fe)||!l(this,it)||!l(this,st))return;const e=l(this,it).getBoundingClientRect(),n=l(this,st).getBoundingClientRect(),s=window.innerHeight-e.bottom,o=n.height+Uu,a=s<o&&e.top>o?"top-start":"bottom-start";b(this,Ho,a);const c=a==="bottom-start"?e.bottom+Uu:e.top-n.height-Uu,u=e.left;l(this,st).style.transform=`translate(${u}px, ${c}px)`,l(this,st).setAttribute("data-placement",a)},Ti=function(){this.toggleAttribute("open",l(this,Fe));const e=this.getAttribute("material")??"paper";Be(l(this,Fe)?D`<div
|
|
81
|
-
class="panel"
|
|
82
|
-
part="panel"
|
|
83
|
-
popover="manual"
|
|
84
|
-
data-placement=${l(this,Ho)}
|
|
85
|
-
tabindex="-1"
|
|
86
|
-
role="dialog"
|
|
87
|
-
material=${e}
|
|
88
|
-
level="1"
|
|
89
|
-
>
|
|
90
|
-
<slot></slot>
|
|
91
|
-
</div>`:le,l(this,Nn)),b(this,st,l(this,Nn).querySelector(".panel"))},g(Mw,"observedAttributes",["open","material"]);customElements.get("ui-popover")||customElements.define("ui-popover",Mw);class Ww extends Event{constructor(e){super("dropdown-item-select",{bubbles:!0,composed:!0});g(this,"value");this.value=e}}class aM extends Event{constructor(e){super("select",{bubbles:!0,composed:!0});g(this,"value");this.value=e}}var ot,Rt,Gr,qr,se,Bo,Vo,M,Vw,Js,jw,Gw,Nh,qw,Xs,Sn,Fn,jo,sc,Go,oc,Yw,Kw,Uh,Qs,Fh,Hh,br;class Bw extends HTMLElement{constructor(){super();w(this,M);w(this,ot,!1);w(this,Rt,null);w(this,Gr,null);w(this,qr);w(this,se,null);w(this,Bo,xl());w(this,Vo,new MutationObserver(e=>p(this,M,Yw).call(this,e)));w(this,Fn,()=>{p(this,M,Xs).call(this,!l(this,ot))});w(this,jo,e=>{e.key!=="Enter"&&e.key!==" "||(e.preventDefault(),l(this,Fn).call(this))});w(this,sc,()=>{l(this,ot)&&p(this,M,Xs).call(this,!1)});w(this,Go,e=>{e instanceof Ww&&(e.stopPropagation(),b(this,ot,!1),p(this,M,Js).call(this,e.value),p(this,M,br).call(this),this.dispatchEvent(new aM(e.value)))});w(this,oc,()=>{p(this,M,Uh).call(this)});b(this,qr,this.attachShadow({mode:"open"})),qd(l(this,qr))}connectedCallback(){this.addEventListener("dropdown-item-select",l(this,Go)),p(this,M,Vw).call(this),l(this,Vo).observe(this,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["selected","value","slot"]}),p(this,M,br).call(this)}disconnectedCallback(){this.removeEventListener("dropdown-item-select",l(this,Go)),l(this,Vo).disconnect(),p(this,M,Hh).call(this)}attributeChangedCallback(e){if(e==="open"){p(this,M,Xs).call(this,this.hasAttribute("open"));return}p(this,M,br).call(this)}get open(){return l(this,ot)}set open(e){this.toggleAttribute("open",e)}get title(){return this.getAttribute("title")??""}get value(){return l(this,Rt)}set value(e){e===null?(p(this,M,Sn).call(this,null,null),p(this,M,jw).call(this)):p(this,M,Js).call(this,e),p(this,M,br).call(this)}close(){p(this,M,Xs).call(this,!1)}}ot=new WeakMap,Rt=new WeakMap,Gr=new WeakMap,qr=new WeakMap,se=new WeakMap,Bo=new WeakMap,Vo=new WeakMap,M=new WeakSet,Vw=function(){var n;const e=this.querySelector("dropdown-item[selected]");e&&p(this,M,Sn).call(this,e.value,((n=e.textContent)==null?void 0:n.trim())??null)},Js=function(e){var n;for(const i of l(this,M,Nh))i.value===e?(p(this,M,Sn).call(this,e,((n=i.textContent)==null?void 0:n.trim())??null),i.hasAttribute("selected")||i.setAttribute("selected","")):i.hasAttribute("selected")&&i.removeAttribute("selected")},jw=function(){const e=this.querySelectorAll("dropdown-item[selected]");for(const n of e)n.removeAttribute("selected")},Gw=function(e){for(const n of l(this,M,Nh))if(n.value===e)return n;return null},Nh=function(){return this.querySelectorAll("dropdown-item")},qw=function(){return l(this,Gr)??this.title},Xs=function(e){l(this,ot)!==e&&(b(this,ot,e),p(this,M,br).call(this))},Sn=function(e,n){b(this,Rt,e),b(this,Gr,n)},Fn=new WeakMap,jo=new WeakMap,sc=new WeakMap,Go=new WeakMap,oc=new WeakMap,Yw=function(e){e.every(i=>i.target instanceof Element?i.target.closest('[slot="trigger"]')!==null:!1)||p(this,M,Kw).call(this)},Kw=function(){var n,i;const e=this.querySelector("dropdown-item[selected]");if(e){const s=e.value,o=((n=e.textContent)==null?void 0:n.trim())??null,a=l(this,Rt)!==s||l(this,Gr)!==o;p(this,M,Sn).call(this,s,o),p(this,M,Js).call(this,s),a?p(this,M,br).call(this):p(this,M,Qs).call(this);return}if(l(this,Rt)!==null){const s=p(this,M,Gw).call(this,l(this,Rt));if(s){const o=((i=s.textContent)==null?void 0:i.trim())??null,a=l(this,Gr)!==o;p(this,M,Sn).call(this,l(this,Rt),o),p(this,M,Js).call(this,l(this,Rt)),a?p(this,M,br).call(this):p(this,M,Qs).call(this);return}}if(l(this,Rt)!==null||l(this,Gr)!==null){p(this,M,Sn).call(this,null,null),p(this,M,br).call(this);return}p(this,M,Qs).call(this)},Uh=function(){const e=l(this,qr).querySelector('slot[name="trigger"]'),n=e instanceof HTMLSlotElement?e.assignedElements()[0]??null:null;l(this,se)!==n&&(p(this,M,Hh).call(this),b(this,se,n),l(this,se)&&(l(this,se).addEventListener("click",l(this,Fn)),l(this,se)instanceof HTMLButtonElement?l(this,se).hasAttribute("type")||(l(this,se).type="button"):(l(this,se).hasAttribute("role")||l(this,se).setAttribute("role","button"),l(this,se).hasAttribute("tabindex")||(l(this,se).tabIndex=0),l(this,se).addEventListener("keydown",l(this,jo))))),p(this,M,Qs).call(this),p(this,M,Fh).call(this)},Qs=function(){l(this,se)&&(l(this,se).setAttribute("data-dropdown-trigger",""),l(this,se).setAttribute("aria-haspopup","listbox"),l(this,se).setAttribute("aria-expanded",l(this,ot)?"true":"false"))},Fh=function(){const e=l(this,Bo).value;if(!e)return;const n=l(this,qr).querySelector("button.fallback-trigger");e.anchor=l(this,se)??n??null},Hh=function(){l(this,se)&&(l(this,se).removeEventListener("click",l(this,Fn)),l(this,se).removeEventListener("keydown",l(this,jo)),l(this,se).removeAttribute("data-dropdown-trigger"),l(this,se).removeAttribute("aria-haspopup"),l(this,se).removeAttribute("aria-expanded"),b(this,se,null))},br=function(){this.toggleAttribute("open",l(this,ot)),Be(D`
|
|
92
|
-
<slot name="trigger" @slotchange=${l(this,oc)}>
|
|
93
|
-
<button
|
|
94
|
-
class="fallback-trigger"
|
|
95
|
-
part="trigger"
|
|
96
|
-
type="button"
|
|
97
|
-
aria-haspopup="listbox"
|
|
98
|
-
aria-expanded=${l(this,ot)?"true":"false"}
|
|
99
|
-
@click=${l(this,Fn)}
|
|
100
|
-
>
|
|
101
|
-
<span class="trigger-label" part="trigger-label">${l(this,M,qw)}</span>
|
|
102
|
-
<span class="trigger-icon" part="trigger-icon" aria-hidden="true">
|
|
103
|
-
${Kl({size:16})}
|
|
104
|
-
</span>
|
|
105
|
-
</button>
|
|
106
|
-
</slot>
|
|
107
|
-
<ui-popover
|
|
108
|
-
class="dropdown-popover"
|
|
109
|
-
material="glass-frosted"
|
|
110
|
-
?open=${l(this,ot)}
|
|
111
|
-
@close=${l(this,sc)}
|
|
112
|
-
${El(l(this,Bo))}
|
|
113
|
-
>
|
|
114
|
-
${l(this,ot)?D`<div class="dropdown-list" part="list" role="listbox">
|
|
115
|
-
<slot></slot>
|
|
116
|
-
</div>`:le}
|
|
117
|
-
</ui-popover>
|
|
118
|
-
`,l(this,qr)),p(this,M,Fh).call(this),queueMicrotask(()=>p(this,M,Uh).call(this))},g(Bw,"observedAttributes",["title","open"]);class lM extends HTMLElement{}class cM extends HTMLElement{}class uM extends HTMLElement{}var ni,Zh,Xw,qo,Yo;class Jw extends HTMLElement{constructor(){super(...arguments);w(this,ni);w(this,qo,()=>{this.action||p(this,ni,Xw).call(this)});w(this,Yo,e=>{e.key!=="Enter"&&e.key!==" "||(e.preventDefault(),this.click())})}connectedCallback(){this.hasAttribute("role")||this.setAttribute("role","option"),this.hasAttribute("tabindex")||(this.tabIndex=0),this.addEventListener("click",l(this,qo)),this.addEventListener("keydown",l(this,Yo)),p(this,ni,Zh).call(this)}disconnectedCallback(){this.removeEventListener("click",l(this,qo)),this.removeEventListener("keydown",l(this,Yo))}attributeChangedCallback(){p(this,ni,Zh).call(this)}get value(){return this.getAttribute("value")??""}get selected(){return this.hasAttribute("selected")}get action(){return this.hasAttribute("action")}}ni=new WeakSet,Zh=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")},Xw=function(){this.dispatchEvent(new Ww(this.value))},qo=new WeakMap,Yo=new WeakMap,g(Jw,"observedAttributes",["action","selected","value"]);customElements.get("dropdown-menu")||customElements.define("dropdown-menu",Bw);customElements.get("dropdown-group")||customElements.define("dropdown-group",lM);customElements.get("dropdown-label")||customElements.define("dropdown-label",cM);customElements.get("dropdown-divider")||customElements.define("dropdown-divider",uM);customElements.get("dropdown-item")||customElements.define("dropdown-item",Jw);class hM extends Event{constructor(e){super("rename",{bubbles:!0,composed:!0});g(this,"value");this.value=e}}var rr,Pt,ie,He,eo,Ko,Wh,$l,Bh,Jo,Xo,Qo;class Qw extends HTMLElement{constructor(){super(...arguments);w(this,He);w(this,rr,"");w(this,Pt,!1);w(this,ie,null);w(this,Ko,e=>{l(this,Pt)||(e.preventDefault(),p(this,He,Wh).call(this))});w(this,Jo,e=>{e.stopPropagation()});w(this,Xo,e=>{var n,i;e.key==="Enter"?(e.preventDefault(),p(this,He,$l).call(this,!0),(n=l(this,ie))==null||n.blur()):e.key==="Escape"&&(e.preventDefault(),p(this,He,$l).call(this,!1),(i=l(this,ie))==null||i.blur())});w(this,Qo,()=>{p(this,He,$l).call(this,!0)})}connectedCallback(){l(this,ie)||(b(this,ie,document.createElement("span")),l(this,ie).className="editable-text-span",this.append(l(this,ie)));const e=this.getAttribute("value");e!==null&&b(this,rr,e),p(this,He,eo).call(this),this.addEventListener("dblclick",l(this,Ko))}disconnectedCallback(){this.removeEventListener("dblclick",l(this,Ko)),l(this,Pt)&&p(this,He,Bh).call(this)}attributeChangedCallback(e){if(e==="value"){const n=this.getAttribute("value")??"";b(this,rr,n),l(this,Pt)||p(this,He,eo).call(this)}}get value(){return l(this,rr)}set value(e){b(this,rr,e),l(this,Pt)||p(this,He,eo).call(this)}startEditing(){l(this,Pt)||p(this,He,Wh).call(this)}}rr=new WeakMap,Pt=new WeakMap,ie=new WeakMap,He=new WeakSet,eo=function(){l(this,ie)&&(l(this,ie).textContent=l(this,rr),l(this,ie).scrollLeft=0)},Ko=new WeakMap,Wh=function(){l(this,ie)&&(b(this,Pt,!0),l(this,ie).setAttribute("contenteditable","plaintext-only"),l(this,ie).setAttribute("spellcheck","false"),l(this,ie).addEventListener("keydown",l(this,Xo)),l(this,ie).addEventListener("blur",l(this,Qo)),l(this,ie).addEventListener("mousedown",l(this,Jo)),this.toggleAttribute("data-editing",!0),queueMicrotask(()=>{var n;if(!l(this,ie))return;l(this,ie).focus();const e=(n=this.ownerDocument.defaultView)==null?void 0:n.getSelection();e==null||e.selectAllChildren(l(this,ie))}))},$l=function(e){if(!l(this,Pt)||!l(this,ie))return;const n=(l(this,ie).textContent??"").trim();b(this,Pt,!1),l(this,ie).removeAttribute("contenteditable"),l(this,ie).removeAttribute("spellcheck"),this.toggleAttribute("data-editing",!1),p(this,He,Bh).call(this),e&&n.length>0&&n!==l(this,rr)&&(b(this,rr,n),this.dispatchEvent(new hM(n))),p(this,He,eo).call(this)},Bh=function(){var e,n,i;(e=l(this,ie))==null||e.removeEventListener("keydown",l(this,Xo)),(n=l(this,ie))==null||n.removeEventListener("blur",l(this,Qo)),(i=l(this,ie))==null||i.removeEventListener("mousedown",l(this,Jo))},Jo=new WeakMap,Xo=new WeakMap,Qo=new WeakMap,g(Qw,"observedAttributes",["value"]);customElements.get("editable-text")||customElements.define("editable-text",Qw);class dM extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}var ea,on,Vh,ac,ta,jh;class e0 extends HTMLElement{constructor(){super();w(this,on);w(this,ea);w(this,ac,e=>{e.target===e.currentTarget&&p(this,on,Vh).call(this)});w(this,ta,e=>{this.open&&e.key==="Escape"&&p(this,on,Vh).call(this)});b(this,ea,this.attachShadow({mode:"open"}))}connectedCallback(){document.addEventListener("keydown",l(this,ta)),p(this,on,jh).call(this)}disconnectedCallback(){document.removeEventListener("keydown",l(this,ta))}attributeChangedCallback(){p(this,on,jh).call(this)}get open(){return this.hasAttribute("open")}}ea=new WeakMap,on=new WeakSet,Vh=function(){this.dispatchEvent(new dM)},ac=new WeakMap,ta=new WeakMap,jh=function(){Be(D`
|
|
119
|
-
${this.open?D`
|
|
120
|
-
<div class="backdrop" part="backdrop" @click=${l(this,ac)}>
|
|
121
|
-
<slot></slot>
|
|
122
|
-
</div>
|
|
123
|
-
`:null}
|
|
124
|
-
`,l(this,ea))},g(e0,"observedAttributes",["open"]);customElements.get("modal-overlay")||customElements.define("modal-overlay",e0);const pM=16,Fu=24,fM=32;var Ji;class t0 extends HTMLElement{constructor(){super();w(this,Ji);b(this,Ji,this.attachShadow({mode:"open"})),qd(l(this,Ji))}connectedCallback(){this.render()}attributeChangedCallback(){this.render()}getSize(){const e=this.getAttribute("size");if(e===null)return Fu;const n=Number(e);return n===pM||n===Fu||n===fM?n:Fu}getWeight(){return this.getAttribute("weight")==="bold"?"bold":"regular"}render(){Be(D`<span class="spin">${Ow({size:this.getSize(),weight:this.getWeight()})}</span>`,l(this,Ji))}}Ji=new WeakMap,g(t0,"observedAttributes",["size","weight"]);customElements.get("ui-spinner")||customElements.define("ui-spinner",t0);class gM extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}class mM extends HTMLElement{}var ra,na,Gh;class r0 extends HTMLElement{constructor(){super();w(this,na);w(this,ra);b(this,ra,this.attachShadow({mode:"open"}))}connectedCallback(){p(this,na,Gh).call(this)}attributeChangedCallback(){p(this,na,Gh).call(this)}get closable(){return this.hasAttribute("closable")}}ra=new WeakMap,na=new WeakSet,Gh=function(){const e=this.querySelector("panel-page");Be(D`
|
|
125
|
-
<section class="panel" part="panel">
|
|
126
|
-
<header class="title-bar" part="header">
|
|
127
|
-
<h2 class="title" part="title">${(e==null?void 0:e.getAttribute("title"))??""}</h2>
|
|
128
|
-
${this.closable?D`
|
|
129
|
-
<button
|
|
130
|
-
type="button"
|
|
131
|
-
class="title-button"
|
|
132
|
-
part="button close-button"
|
|
133
|
-
aria-label="Close"
|
|
134
|
-
@click=${()=>this.dispatchEvent(new gM)}
|
|
135
|
-
>
|
|
136
|
-
<span class="close-icon" part="icon close-icon">${up({size:16})}</span>
|
|
137
|
-
</button>
|
|
138
|
-
`:null}
|
|
139
|
-
</header>
|
|
140
|
-
<slot></slot>
|
|
141
|
-
</section>
|
|
142
|
-
`,l(this,ra))},g(r0,"observedAttributes",["closable"]);customElements.get("panel-view")||customElements.define("panel-view",r0);customElements.get("panel-page")||customElements.define("panel-page",mM);const vM=`
|
|
143
|
-
<svg viewBox="0 0 12 12" aria-hidden="true" focusable="false">
|
|
144
|
-
<path d="M10.2 3.1 5.1 8.2 2.4 5.5" />
|
|
145
|
-
</svg>
|
|
146
|
-
`,yM=`
|
|
147
|
-
:host {
|
|
148
|
-
display: block;
|
|
149
|
-
margin: var(--checkbox-list-margin, var(--space-12) 0);
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
[part~="list"] {
|
|
153
|
-
display: grid;
|
|
154
|
-
gap: var(--checkbox-list-gap, var(--space-6));
|
|
155
|
-
}
|
|
156
|
-
`,bM=`
|
|
157
|
-
:host {
|
|
158
|
-
display: block;
|
|
159
|
-
--checkbox-size: 1em;
|
|
160
|
-
--checkbox-gap: var(--space-8);
|
|
161
|
-
--checkbox-color: var(--color-primary);
|
|
162
|
-
--checkbox-border-color: var(--color-border);
|
|
163
|
-
--checkbox-bg: transparent;
|
|
164
|
-
--checkbox-check-color: var(--color-bg);
|
|
165
|
-
--checkbox-checked-content-color: var(--color-text-muted);
|
|
166
|
-
--checkbox-checked-decoration: line-through;
|
|
167
|
-
--checkbox-checked-decoration-thickness: 0.08em;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
[part~="label"] {
|
|
171
|
-
display: grid;
|
|
172
|
-
grid-template-columns: var(--checkbox-size) minmax(0, 1fr);
|
|
173
|
-
gap: var(--checkbox-gap);
|
|
174
|
-
align-items: baseline;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
input {
|
|
178
|
-
position: absolute;
|
|
179
|
-
opacity: 0;
|
|
180
|
-
pointer-events: none;
|
|
181
|
-
width: 1px;
|
|
182
|
-
height: 1px;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
[part~="box"] {
|
|
186
|
-
display: inline-grid;
|
|
187
|
-
place-items: center;
|
|
188
|
-
width: var(--checkbox-size);
|
|
189
|
-
height: var(--checkbox-size);
|
|
190
|
-
border: 1px solid var(--checkbox-border-color);
|
|
191
|
-
border-radius: var(--checkbox-radius, var(--radius-4));
|
|
192
|
-
background: var(--checkbox-bg);
|
|
193
|
-
color: var(--checkbox-check-color);
|
|
194
|
-
transform: translateY(0.12em);
|
|
195
|
-
cursor: not-allowed;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
[part~="check"] {
|
|
199
|
-
display: block;
|
|
200
|
-
width: calc(var(--checkbox-size) * 0.72);
|
|
201
|
-
height: calc(var(--checkbox-size) * 0.72);
|
|
202
|
-
opacity: 0;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
[part~="check"] svg {
|
|
206
|
-
display: block;
|
|
207
|
-
width: 100%;
|
|
208
|
-
height: 100%;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
[part~="check"] path {
|
|
212
|
-
fill: none;
|
|
213
|
-
stroke: currentColor;
|
|
214
|
-
stroke-width: 2;
|
|
215
|
-
stroke-linecap: round;
|
|
216
|
-
stroke-linejoin: round;
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
[part~="content"] {
|
|
220
|
-
min-width: 0;
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
:host([checked]) [part~="box"] {
|
|
224
|
-
border-color: var(--checkbox-color);
|
|
225
|
-
background: var(--checkbox-color);
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
:host([checked]) [part~="check"] {
|
|
229
|
-
opacity: 1;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
:host([checked]) [part~="content"] {
|
|
233
|
-
color: var(--checkbox-checked-content-color);
|
|
234
|
-
text-decoration-line: var(--checkbox-checked-decoration);
|
|
235
|
-
text-decoration-thickness: var(--checkbox-checked-decoration-thickness);
|
|
236
|
-
}
|
|
237
|
-
`;var ia;class wM extends HTMLElement{constructor(){super();w(this,ia);b(this,ia,this.attachShadow({mode:"open"})),l(this,ia).innerHTML=`<style>${yM}</style><div part="list"><slot></slot></div>`}connectedCallback(){this.hasAttribute("role")||this.setAttribute("role","list")}}ia=new WeakMap;var Xi,sa,oa,qh;class n0 extends HTMLElement{constructor(){super();w(this,oa);w(this,Xi);w(this,sa);b(this,Xi,this.attachShadow({mode:"open"})),l(this,Xi).innerHTML=`
|
|
238
|
-
<style>${bM}</style>
|
|
239
|
-
<label part="label">
|
|
240
|
-
<input type="checkbox" disabled tabindex="-1">
|
|
241
|
-
<span part="box"><span part="check">${vM}</span></span>
|
|
242
|
-
<span part="content"><slot></slot></span>
|
|
243
|
-
</label>
|
|
244
|
-
`;const e=l(this,Xi).querySelector("input");if(!(e instanceof HTMLInputElement))throw new Error("checkbox-item failed to initialize input");b(this,sa,e)}connectedCallback(){this.hasAttribute("role")||this.setAttribute("role","listitem"),this.setAttribute("aria-disabled","true"),p(this,oa,qh).call(this)}attributeChangedCallback(){p(this,oa,qh).call(this)}}Xi=new WeakMap,sa=new WeakMap,oa=new WeakSet,qh=function(){const e=this.hasAttribute("checked");l(this,sa).checked=e,this.setAttribute("aria-checked",e?"true":"false")},g(n0,"observedAttributes",["checked"]);customElements.get("checkbox-list")||customElements.define("checkbox-list",wM);customElements.get("checkbox-item")||customElements.define("checkbox-item",n0);const i0=Ve(),s0="No handler registered for update-content",o0="handleUpdateContent: handler already registered",km="television-artifact-bridge";function a0(r){return r instanceof Error&&typeof r.message=="string"?r.message:String(r)}const l0=Ra(Mt);var Qi,es,ts,Hn,Zn,aa,Ze,Yh,c0,u0,to,Kh,ov;let SM=(ov=class extends l0{constructor(e){super();w(this,Ze);w(this,Qi);w(this,es);w(this,ts);w(this,Hn,null);w(this,Zn,null);w(this,aa,!1);b(this,Qi,e);const n=e.ownerDocument.defaultView;if(!n)throw new Error("ArtifactView: iframe has no owner window");b(this,es,n),b(this,ts,i=>p(this,Ze,c0).call(this,i)),l(this,es).addEventListener("message",l(this,ts))}get content(){return l(this,Zn)}set content(e){p(this,Ze,Kh).call(this),b(this,Zn,e),l(this,aa)&&p(this,Ze,Yh).call(this,e)}handleUpdateContent(e){if(p(this,Ze,Kh).call(this),l(this,Hn)!==null)throw new Error(o0);b(this,Hn,e)}dispose(){l(this,es).removeEventListener("message",l(this,ts)),b(this,Hn,null)}},Qi=new WeakMap,es=new WeakMap,ts=new WeakMap,Hn=new WeakMap,Zn=new WeakMap,aa=new WeakMap,Ze=new WeakSet,Yh=function(e){const n={type:"content-updated",content:e};p(this,Ze,to).call(this,n)},c0=function(e){if(this.disposed||e.source!==l(this,Qi).contentWindow)return;const n=e.data;if(kb(n)){b(this,aa,!0),this.dispatchEvent(new i0("ready")),l(this,Zn)!==null&&p(this,Ze,Yh).call(this,l(this,Zn));return}if(xb(n)){p(this,Ze,u0).call(this,n);return}},u0=async function(e){const n=l(this,Hn);if(n===null){p(this,Ze,to).call(this,{type:"response",id:e.id,error:{message:s0}});return}try{await n(e.content)}catch(i){if(this.disposed)return;p(this,Ze,to).call(this,{type:"response",id:e.id,error:{message:a0(i)}});return}this.disposed||p(this,Ze,to).call(this,{type:"response",id:e.id,result:{}})},to=function(e){const n=l(this,Qi).contentWindow;n&&n.postMessage(e,"*")},Kh=function(){if(this.disposed)throw new Error("ArtifactView is disposed")},ov);var Wn,rs,Bn,Vn,la,We,Jh,h0,d0,ro,Xh;class _M extends l0{constructor(e){super();w(this,We);w(this,Wn);w(this,rs);w(this,Bn,null);w(this,Vn,null);w(this,la,!1);b(this,Wn,e),b(this,rs,n=>p(this,We,h0).call(this,n)),l(this,Wn).addEventListener("ipc-message",l(this,rs))}get content(){return l(this,Vn)}set content(e){p(this,We,Xh).call(this),b(this,Vn,e),l(this,la)&&p(this,We,Jh).call(this,e)}handleUpdateContent(e){if(p(this,We,Xh).call(this),l(this,Bn)!==null)throw new Error(o0);b(this,Bn,e)}dispose(){l(this,Wn).removeEventListener("ipc-message",l(this,rs)),b(this,Bn,null)}}Wn=new WeakMap,rs=new WeakMap,Bn=new WeakMap,Vn=new WeakMap,la=new WeakMap,We=new WeakSet,Jh=function(e){const n={type:"content-updated",content:e};p(this,We,ro).call(this,n)},h0=function(e){var s;if(this.disposed)return;const n=e.detail??e;if(!n||n.channel!==km)return;const i=(s=n.args)==null?void 0:s[0];if(kb(i)){b(this,la,!0),this.dispatchEvent(new i0("ready")),l(this,Vn)!==null&&p(this,We,Jh).call(this,l(this,Vn));return}if(xb(i)){p(this,We,d0).call(this,i);return}},d0=async function(e){const n=l(this,Bn);if(n===null){p(this,We,ro).call(this,{type:"response",id:e.id,error:{message:s0}});return}try{await n(e.content)}catch(i){if(this.disposed)return;p(this,We,ro).call(this,{type:"response",id:e.id,error:{message:a0(i)}});return}this.disposed||p(this,We,ro).call(this,{type:"response",id:e.id,result:{}})},ro=function(e){var n,i;(i=(n=l(this,Wn)).send)==null||i.call(n,km,e)},Xh=function(){if(this.disposed)throw new Error("WebviewArtifactViewRuntime is disposed")};const xm="television-artifact-bridge",Em="/views/url-unsupported/",kM=404,p0=Ve(),xM=Ve(),EM=Ve();class AM extends HTMLElement{constructor(){super(...arguments);g(this,"_artifact",null);g(this,"_viewURL",null);g(this,"_contentURL",null);g(this,"_screen",null);g(this,"_standaloneScroll",!1);g(this,"_subscribedWebview",null);g(this,"_embedLoadFrame",null);g(this,"_embedLoadKey",null);g(this,"_bridgePending",!0);g(this,"_bridgeCurrentGuid",null);g(this,"_bridgeLifecycleWindow",null);g(this,"_activeReloadFrameSrc",null);g(this,"_markdownFrame",null);g(this,"_markdownHost",null);g(this,"_markdownContentURL",null);g(this,"_markdownArtifactID",null);g(this,"_markdownContent",null);g(this,"_markdownFetchedArtifactID",null);g(this,"_markdownFetchedScreen",null);g(this,"_screenSubscriptionsAttached",!1);g(this,"_proxyReloadVersion",0);g(this,"_navigationState",null);g(this,"_navigationArtifactId",null);g(this,"_navigationCanonicalURL",null);g(this,"_preserveFrameSrcOnNavigationRender",!1);g(this,"_missingArtifactID",null);g(this,"handleIframeMessage",e=>{var u,h;const n=this.querySelector("iframe.artifact-frame");if(!n)return;const i=qp(e.data),s=tu(e.data)&&e.data.native===!0&&e.data.sameDocument!==!0,o=n.contentWindow===e.source,a=(i||s)&&this._bridgeLifecycleWindow!==null&&this._bridgeLifecycleWindow===e.source,c=i&&this.isArtifactFrameMessageOrigin(n,e.origin);if(!(!o&&!a&&!c)){if(Yp(e.data)){this.handleBridgeReady(e.data,n);return}if(i){this.handleBridgeLeaving(e.data.guid);return}if(Kp(e.data)){this.dispatchArtifactWheel({deltaX:e.data.deltaX,shiftKey:e.data.shiftKey});return}if(Jp(e.data)){this.markLegacyBridgeProofOfLife(e.data,n),this.dispatchArtifactFilmstripKey(e.data.direction);return}if(yS(e.data)){this.markLegacyBridgeProofOfLife(e.data,n),(u=n.contentWindow)==null||u.postMessage({type:bS,url:this.currentExternalTargetURL()},"*");return}if(Xp(e.data)){this.markLegacyBridgeProofOfLife(e.data,n),(h=n.contentWindow)==null||h.postMessage(this.currentMissingArtifactMessage(),"*");return}if(Qp(e.data)){this.markLegacyBridgeProofOfLife(e.data,n),this.handleProxyContentChanged();return}if(tu(e.data)){const f=e.data.native===!0&&e.data.sameDocument!==!0;this.handleNavigationRequest(e.data),f||this.markLegacyBridgeProofOfLife(e.data,n);return}}});g(this,"handleNavigationChange",()=>{const e=this._preserveFrameSrcOnNavigationRender,n=!e;n&&this.closeBridgeGate({render:!1}),this.render({preserveFrameSrc:e}),this._preserveFrameSrcOnNavigationRender=!1,n&&window.setTimeout(()=>this.forceCurrentFrameSrc(),0)});g(this,"handleArtifactContentChanged",e=>{var i;if(e.artifactID===((i=this._artifact)==null?void 0:i.id)){if(this._markdownHost&&this._markdownContentURL||this.isCurrentMarkdownMissing()){this.fetchMarkdownContent();return}this.reloadProxyFrame()}});g(this,"handleThemeChanged",()=>{var e;((e=this._artifact)==null?void 0:e.kind)==="url"&&vr(this._artifact.url)||this.reloadProxyFrame()});g(this,"handleWebviewIpcMessage",e=>{var o,a;const n=e.detail??e;if(!n||n.channel!==xm)return;const i=(o=n.args)==null?void 0:o[0];if(!i)return;const s=this._subscribedWebview;if(s){if(Yp(i)){this.handleBridgeReady(i,s);return}if(qp(i)){this.handleBridgeLeaving(i.guid);return}if(Xp(i)){this.markLegacyBridgeProofOfLife(i,s);const c=this.currentMissingArtifactMessage();c&&((a=s.send)==null||a.call(s,xm,c));return}if(tu(i)){this.handleNavigationRequest(i);return}if(Kp(i)){this.markLegacyBridgeProofOfLife(i,s),this.dispatchArtifactWheel({deltaX:i.deltaX,shiftKey:i.shiftKey});return}if(Jp(i)){this.markLegacyBridgeProofOfLife(i,s),this.dispatchArtifactFilmstripKey(i.direction);return}Qp(i)&&(this.markLegacyBridgeProofOfLife(i,s),this.handleProxyContentChanged())}});g(this,"handleWebviewDidStartNavigation",e=>{const n=e.detail??e;n.isMainFrame===!0&&n.isInPlace!==!0&&this.closeBridgeGate()});g(this,"handleWebviewDidFailLoad",e=>{(e.detail??e).isMainFrame!==!1&&this.closeBridgeGate()});g(this,"handleWebviewDidNavigate",e=>{this.handleWebviewNavigationEvent(e)});g(this,"handleWebviewDidNavigateInPage",e=>{this._preserveFrameSrcOnNavigationRender=!0,this.handleWebviewNavigationEvent(e)||(this._preserveFrameSrcOnNavigationRender=!1)});g(this,"handleEmbedLoad",()=>{const e=this.querySelector(".artifact-frame");!e||e!==this._embedLoadFrame||this.setAttribute("data-embed-loaded","")})}set artifact(e){const n=this._artifact,i=n?!TM(n,e):!0;((n==null?void 0:n.id)!==e.id||n.kind==="path"&&e.kind==="path"&&n.path!==e.path)&&(this._missingArtifactID=null),i&&(this._bridgePending=!0,this._bridgeCurrentGuid=null,this._bridgeLifecycleWindow=null,this._activeReloadFrameSrc=null,this._markdownContent=null,this._markdownHost&&(this._markdownHost.content=""),this._markdownFetchedArtifactID=null,this._markdownFetchedScreen=null),this._artifact=e,this.syncNavigationState(),this.render(),this.syncWebviewSubscription()}get artifact(){return this._artifact}set viewURL(e){this._viewURL=e,this.syncNavigationState(),this.render(),this.syncWebviewSubscription()}get viewURL(){return this._viewURL}set contentURL(e){this._contentURL=e,this.render()}get contentURL(){return this._contentURL}set screen(e){this._screen!==e&&(this.detachScreenSubscriptions(),this._screen=e,this.attachScreenSubscriptions(),this.syncMarkdownHost())}get screen(){return this._screen}attachScreenSubscriptions(){!this._screen||this._screenSubscriptionsAttached||(this._screen.addEventListener("artifact-content-changed",this.handleArtifactContentChanged),this._screen.addEventListener("theme-changed",this.handleThemeChanged),this._screenSubscriptionsAttached=!0)}detachScreenSubscriptions(){!this._screen||!this._screenSubscriptionsAttached||(this._screen.removeEventListener("artifact-content-changed",this.handleArtifactContentChanged),this._screen.removeEventListener("theme-changed",this.handleThemeChanged),this._screenSubscriptionsAttached=!1)}get activeView(){return null}set standaloneScroll(e){this._standaloneScroll=e}get standaloneScroll(){return this._standaloneScroll}connectedCallback(){this.setAttribute("level","2"),window.addEventListener("message",this.handleIframeMessage),this.attachScreenSubscriptions(),this.rearmArtifactFrameOnConnect(),this.render(),this.syncWebviewSubscription(),this.syncNavigationState()}disconnectedCallback(){window.removeEventListener("message",this.handleIframeMessage),this.unsubscribeFromWebview(),this.unsubscribeFromEmbedLoad(),this.syncNavigationState(),this.detachScreenSubscriptions(),this.disposeMarkdownHost()}handleClose(){this._artifact&&this.dispatchEvent(new p0("close-artifact",{artifactID:this._artifact.id,bubbles:!0,composed:!0}))}currentExternalTargetURL(){var n,i;const e=((n=this._navigationState)==null?void 0:n.currentURL)??null;return e&&Hu(e)?e:((i=this._artifact)==null?void 0:i.kind)==="url"?this._artifact.url:null}currentMissingArtifactMessage(){const e=this._artifact;return(e==null?void 0:e.kind)!=="path"?null:{type:wS,title:e.title,path:e.path}}handleBridgeReady(e,n=this.querySelector(".artifact-frame")){if(this.isArtifactFrame(n)){if(typeof e.guid=="string"){(e.guid!==this._bridgeCurrentGuid||this._bridgePending)&&(this._bridgeCurrentGuid=e.guid,this._bridgeLifecycleWindow=n.tagName.toLowerCase()==="iframe"?n.contentWindow:null,this._bridgePending=!1,this.render({preserveFrameSrc:!0}));return}this.markLegacyBridgeProofOfLife(e,n)}}handleBridgeLeaving(e){e===this._bridgeCurrentGuid&&this.closeBridgeGate()}markLegacyBridgeProofOfLife(e,n=this.querySelector(".artifact-frame")){this.isArtifactFrame(n)&&(!this._bridgePending||$M(e)||(this._bridgePending=!1,this.render({preserveFrameSrc:!0})))}closeBridgeGate(e={}){const n=!this._bridgePending||this._bridgeCurrentGuid!==null;this._bridgePending=!0,this._bridgeCurrentGuid=null,this._bridgeLifecycleWindow=null,n&&e.render!==!1&&this.render({preserveFrameSrc:!0})}isArtifactFrame(e){if(!e)return!1;const n=e.tagName.toLowerCase();return n==="iframe"||n==="webview"}isArtifactFrameMessageOrigin(e,n){try{return new URL(e.getAttribute("src")??e.src,window.location.href).origin===n}catch{return!1}}shouldGateFrame(){return this._bridgePending}rearmArtifactFrameOnConnect(){const e=this.querySelector(".artifact-frame");this.isArtifactFrame(e)&&this.closeBridgeGate({render:!1})}handleProxyContentChanged(){var e;((e=this._artifact)==null?void 0:e.kind)!=="url"||!vr(this._artifact.url)||this.reloadProxyFrame()}handleNavigationRequest(e){this.syncNavigationState();const n=this._navigationState;if(!n)return;const i=this.convertIframeNavigationURL(e.url);if(i===Em||i===n.currentURL)return;const s=e.native===!0;(e.sameDocument||s)&&(this._preserveFrameSrcOnNavigationRender=!0),s&&e.sameDocument!==!0&&this.closeBridgeGate({render:!1}),e.replace?n.replace(i):n.navigate(i)}dispatchArtifactFilmstripKey(e){this._standaloneScroll||this.dispatchEvent(new EM("artifact-filmstrip-key",{bubbles:!0,composed:!0,direction:e}))}dispatchArtifactWheel(e){this._standaloneScroll||this.dispatchEvent(new xM("artifact-wheel",{bubbles:!0,composed:!0,deltaX:e.deltaX,shiftKey:e.shiftKey}))}syncNavigationState(){if(!this.isConnected||!this._artifact){this.disposeNavigationState();return}const e=this.canonicalURLForArtifact(this._artifact);this._navigationState&&this._navigationArtifactId===this._artifact.id&&this._navigationCanonicalURL===e||(this.disposeNavigationState(),this._navigationState=new EO(this._artifact.id,e),this._navigationArtifactId=this._artifact.id,this._navigationCanonicalURL=e,this._navigationState.addEventListener("change",this.handleNavigationChange),this._navigationState.currentURL!==null&&this.render())}disposeNavigationState(){var e;(e=this._navigationState)==null||e.removeEventListener("change",this.handleNavigationChange),this._navigationState=null,this._navigationArtifactId=null,this._navigationCanonicalURL=null,this._preserveFrameSrcOnNavigationRender=!1}canonicalURLForArtifact(e){const n=jl(e,{electron:cr()}),i=this._viewURL??n.viewURL;return e.kind==="url"&&vr(e.url)||n.renderer==="url-webview"?Cr(i):Am(i,i)}convertIframeNavigationURL(e){var i,s;if(((i=this._artifact)==null?void 0:i.kind)==="url"&&vr(this._artifact.url)&&vr(e))return Cr(e);const n=(s=this.querySelector(".artifact-frame"))==null?void 0:s.getAttribute("src");return Am(e,n??this._viewURL??null)}handleWebviewNavigationEvent(e){const n=e.url;if(typeof n!="string")return!1;this.syncNavigationState();const i=this._navigationState;if(!i)return!1;const s=Cr(n);return s===i.currentURL?!1:(i.navigate(s),!0)}viewURLForInternalNavigation(e){if(!e.startsWith("/")||!this._viewURL)return e;try{return new URL(e,this._viewURL).toString()}catch{return e}}syncWebviewSubscription(){const e=this.querySelector("webview");e!==this._subscribedWebview&&(this.unsubscribeFromWebview(),e&&(e.addEventListener("ipc-message",this.handleWebviewIpcMessage),e.addEventListener("did-start-navigation",this.handleWebviewDidStartNavigation),e.addEventListener("did-fail-load",this.handleWebviewDidFailLoad),e.addEventListener("did-navigate",this.handleWebviewDidNavigate),e.addEventListener("did-navigate-in-page",this.handleWebviewDidNavigateInPage),this._subscribedWebview=e))}unsubscribeFromWebview(){this._subscribedWebview&&(this._subscribedWebview.removeEventListener("ipc-message",this.handleWebviewIpcMessage),this._subscribedWebview.removeEventListener("did-start-navigation",this.handleWebviewDidStartNavigation),this._subscribedWebview.removeEventListener("did-fail-load",this.handleWebviewDidFailLoad),this._subscribedWebview.removeEventListener("did-navigate",this.handleWebviewDidNavigate),this._subscribedWebview.removeEventListener("did-navigate-in-page",this.handleWebviewDidNavigateInPage),this._subscribedWebview=null)}syncEmbedLoadState(){var s;const e=this.querySelector(".artifact-frame"),n=e?`${e.tagName.toLowerCase()}:${e.getAttribute("src")??""}:${e.dataset.contentUrl??""}`:null;if(e&&e===this._embedLoadFrame&&n===this._embedLoadKey||(this.unsubscribeFromEmbedLoad(),this.removeAttribute("data-embed-loaded"),!e||!n))return;if(this._embedLoadFrame=e,this._embedLoadKey=n,e.tagName.toLowerCase()==="webview"){e.addEventListener("did-finish-load",this.handleEmbedLoad),e.addEventListener("did-fail-load",this.handleEmbedLoad);return}e.addEventListener("load",this.handleEmbedLoad);const i=e;try{((s=i.contentDocument)==null?void 0:s.readyState)==="complete"&&this.handleEmbedLoad()}catch{}}unsubscribeFromEmbedLoad(){if(!this._embedLoadFrame){this._embedLoadKey=null;return}this._embedLoadFrame.removeEventListener("load",this.handleEmbedLoad),this._embedLoadFrame.removeEventListener("did-finish-load",this.handleEmbedLoad),this._embedLoadFrame.removeEventListener("did-fail-load",this.handleEmbedLoad),this._embedLoadFrame=null,this._embedLoadKey=null}iframeTargetOrigin(e){const n=e.getAttribute("sandbox")??"";if(!new Set(n.split(/\s+/).filter(Boolean)).has("allow-same-origin"))return"*";const s=e.getAttribute("src")??e.src;if(!s)return"*";try{return new URL(s,window.location.href).origin}catch{return"*"}}syncMarkdownHost(){var s;const e=this.querySelector("[data-content-url]"),n=(e==null?void 0:e.dataset.contentUrl)??null,i=((s=this._artifact)==null?void 0:s.id)??null;if(!e||!n||!i){this.disposeMarkdownHost({clearContent:!0});return}if(e!==this._markdownFrame||i!==this._markdownArtifactID){this.disposeMarkdownHost(),this._markdownFrame=e,this._markdownContentURL=n,this._markdownArtifactID=i;const o=e.tagName.toLowerCase()==="webview"?new _M(e):new SM(e);this._markdownHost=o,o.handleUpdateContent(async a=>{const c=this._artifact,u=this._screen;if(!c||!u)throw new Error("No markdown artifact selected");await u.server.client.markdown.update({artifactID:c.id,content:a}),this._markdownContent=a,this._markdownHost===o&&(o.content=a)}),this._markdownContent!==null&&(o.content=this._markdownContent)}else this._markdownContentURL=n;this.ensureMarkdownContentFetched()}ensureMarkdownContentFetched(){const e=this._artifact,n=this._screen;!e||!n||!this._markdownHost||this._markdownFetchedArtifactID===e.id&&this._markdownFetchedScreen===n||(this._markdownFetchedArtifactID=e.id,this._markdownFetchedScreen=n,this.fetchMarkdownContent())}async fetchMarkdownContent(){var s,o;const e=this._artifact,n=this._screen;if(!e||!n)return;const i=e.id;try{const a=await n.server.client.markdown.get({artifactID:i});if(((s=this._artifact)==null?void 0:s.id)!==i||this._screen!==n)return;this._missingArtifactID=null,this._markdownContent=a;const c=this._markdownHost;if(!c){this.render();return}c.content=a}catch(a){if(((o=this._artifact)==null?void 0:o.id)!==i||this._screen!==n)return;if(a instanceof Jd&&a.status===kM){this._missingArtifactID=i,this._markdownContent=null,this.disposeMarkdownHost(),this.render();return}this._markdownFetchedArtifactID=null,this._markdownFetchedScreen=null}}isCurrentMarkdownMissing(){var e;return this._missingArtifactID===((e=this._artifact)==null?void 0:e.id)&&this._artifact.kind==="path"&&Sb(this._artifact.path)}missingArtifactTemplate(e){return D`
|
|
245
|
-
<section class="artifact-missing artifact-content" role="status" aria-label="Artifact file not found">
|
|
246
|
-
<div class="artifact-missing-wrapper">
|
|
247
|
-
<h1>${kS()}</h1>
|
|
248
|
-
<p>${xS()}</p>
|
|
249
|
-
<section class="artifact-missing-path" aria-label="Missing artifact path">
|
|
250
|
-
<p class="artifact-missing-path-label">Registered path:</p>
|
|
251
|
-
<p><code>${e.path}</code></p>
|
|
252
|
-
</section>
|
|
253
|
-
<p>${ES()}</p>
|
|
254
|
-
</div>
|
|
255
|
-
</section>
|
|
256
|
-
`}disposeMarkdownHost(e={}){var n;(n=this._markdownHost)==null||n.dispose(),this._markdownHost=null,this._markdownFrame=null,this._markdownContentURL=null,this._markdownArtifactID=null,this._markdownFetchedArtifactID=null,this._markdownFetchedScreen=null,e.clearContent&&(this._markdownContent=null)}reloadProxyFrame(){var o,a,c,u;const e=this.querySelector(".artifact-frame:not([data-content-url])");if(!e||e.tagName.toLowerCase()==="webview"&&!(((o=this._artifact)==null?void 0:o.kind)==="path"||((a=this._artifact)==null?void 0:a.kind)==="url"&&vr(this._artifact.url)))return;const n=((c=this._artifact)==null?void 0:c.kind)==="url"&&vr(this._artifact.url)?((u=this._navigationState)==null?void 0:u.currentURL)??e.getAttribute("src"):e.getAttribute("src");if(n===null)return;this.closeBridgeGate({render:!1});const i=new URL(n,window.location.href);i.searchParams.set(ms,String(++this._proxyReloadVersion));const s=n.startsWith("/")?`${i.pathname}${i.search}${i.hash}`:i.href;this._activeReloadFrameSrc=s,this.removeAttribute("data-embed-loaded"),this.render({frameSrcOverride:s})}contentTemplate(e,n){var h;if(e.kind==="path"&&this.isCurrentMarkdownMissing())return this.missingArtifactTemplate(e);const i=this.routeForCurrentNavigation(e),s=(h=this.querySelector(".artifact-frame"))==null?void 0:h.getAttribute("src");let o=null;this._activeReloadFrameSrc&&(IM(this._activeReloadFrameSrc,i.viewURL)?o=this._activeReloadFrameSrc:this._activeReloadFrameSrc=null);const a=n.frameSrcOverride??o??(n.preserveFrameSrc&&s?s:i.viewURL),c=this._contentURL??i.contentURL,u=this.shouldGateFrame();return i.renderer==="url-webview"?i.contentURL?D`<webview allowpopups class="artifact-frame artifact-content" src=${a} data-content-url=${c} ?data-bridge-pending=${u}></webview>`:D`<webview allowpopups class="artifact-frame artifact-content" src=${a} ?data-bridge-pending=${u}></webview>`:i.renderer==="markdown"?D`<iframe class="artifact-frame artifact-content" src=${a} data-content-url=${c} ?data-bridge-pending=${u}></iframe>`:D`<iframe class="artifact-frame artifact-content" src=${a} ?data-bridge-pending=${u}></iframe>`}routeForCurrentNavigation(e){var s;const n=jl(e,{electron:cr()}),i=((s=this._navigationState)==null?void 0:s.currentURL)??null;if(i===null){const o=this._viewURL??n.viewURL;return n.renderer==="markdown"?{renderer:"markdown",viewURL:o,contentURL:this._contentURL??n.contentURL}:{...n,viewURL:o}}return Hu(i)&&!cr()?vr(i)?{renderer:"proxy-iframe",viewURL:i,contentURL:null}:{renderer:"proxy-iframe",viewURL:Em,contentURL:null}:Hu(i)&&cr()?{renderer:"url-webview",viewURL:i,contentURL:null}:cr()?{renderer:"url-webview",viewURL:this.viewURLForInternalNavigation(i),contentURL:null}:{renderer:"proxy-iframe",viewURL:this.viewURLForInternalNavigation(i),contentURL:null}}forceCurrentFrameSrc(){if(!this._artifact)return;const e=this.routeForCurrentNavigation(this._artifact);if(e.renderer==="url-webview")return;const n=this.querySelector("iframe.artifact-frame");if(n){this.closeBridgeGate(),this._activeReloadFrameSrc=null,this.removeAttribute("data-embed-loaded");try{n.contentWindow&&(n.contentWindow.location.href=e.viewURL)}catch{n.src=e.viewURL}n.src=e.viewURL,n.setAttribute("src",e.viewURL),this.syncEmbedLoadState()}}titleIconTemplate(){const e=this._navigationState;return e!=null&&e.canGoBack?D`
|
|
257
|
-
<button
|
|
258
|
-
icon-only
|
|
259
|
-
size="sm"
|
|
260
|
-
variant="ghost"
|
|
261
|
-
class="artifact-title-icon artifact-history-back"
|
|
262
|
-
@click=${()=>e.back()}
|
|
263
|
-
aria-label="Back"
|
|
264
|
-
>
|
|
265
|
-
${XO({size:16})}
|
|
266
|
-
</button>
|
|
267
|
-
`:D`
|
|
268
|
-
<button
|
|
269
|
-
icon-only
|
|
270
|
-
size="sm"
|
|
271
|
-
variant="ghost"
|
|
272
|
-
class="artifact-title-icon"
|
|
273
|
-
disabled
|
|
274
|
-
aria-label="No history"
|
|
275
|
-
>
|
|
276
|
-
${rM({size:16,weight:"duotone"})}
|
|
277
|
-
</button>
|
|
278
|
-
`}template(e={preserveFrameSrc:!1}){const n=this._artifact;return D`
|
|
279
|
-
${this.contentTemplate(n,e)}
|
|
280
|
-
<footer class="artifact-title-bar" drag-handle material="glass-frosted">
|
|
281
|
-
<div class="artifact-title-group">
|
|
282
|
-
${this.titleIconTemplate()}
|
|
283
|
-
<span class="artifact-title">${n.title}</span>
|
|
284
|
-
</div>
|
|
285
|
-
<div class="artifact-title-actions">
|
|
286
|
-
<button
|
|
287
|
-
icon-only
|
|
288
|
-
size="sm"
|
|
289
|
-
variant="ghost"
|
|
290
|
-
class="artifact-close-btn"
|
|
291
|
-
@click=${()=>this.handleClose()}
|
|
292
|
-
aria-label="Close"
|
|
293
|
-
>
|
|
294
|
-
${up({size:16})}
|
|
295
|
-
</button>
|
|
296
|
-
</div>
|
|
297
|
-
</footer>
|
|
298
|
-
`}render(e={}){this._artifact&&(this.setAttribute("kind",this._artifact.kind),Be(this.template({preserveFrameSrc:e.preserveFrameSrc??!1,frameSrcOverride:e.frameSrcOverride}),this),e.forceFrameSrc&&this.forceCurrentFrameSrc(),this.syncWebviewSubscription(),this.syncEmbedLoadState(),this.syncMarkdownHost())}}function Hu(r){return r.startsWith("http://")||r.startsWith("https://")}function TM(r,t){return r.id!==t.id||r.kind!==t.kind?!1:r.kind==="path"&&t.kind==="path"?r.path===t.path:r.kind==="url"&&t.kind==="url"?r.url===t.url:!0}function $M(r){return typeof r=="object"&&r!==null&&"guid"in r}function IM(r,t){try{const e=new URL(r,window.location.href),n=new URL(t,window.location.href);return e.searchParams.delete(ms),n.searchParams.delete(ms),e.origin===n.origin&&e.pathname===n.pathname&&e.search===n.search}catch{return!1}}function Am(r,t){try{const e=new URL(r,window.location.href);if(t){const n=new URL(t,window.location.href);if(e.origin===n.origin)return e.searchParams.delete(ms),`${e.pathname}${e.search}${e.hash}`}}catch{return Cr(r)}return Cr(r)}customElements.define("artifact-view",AM);/**
|
|
299
|
-
* @license
|
|
300
|
-
* Copyright 2017 Google LLC
|
|
301
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
302
|
-
*/const Tm=(r,t,e)=>{const n=new Map;for(let i=t;i<=e;i++)n.set(r[i],i);return n},$m=Nc(class extends cp{constructor(r){if(super(r),r.type!==lp.CHILD)throw Error("repeat() can only be used in text expressions")}dt(r,t,e){let n;e===void 0?e=t:t!==void 0&&(n=t);const i=[],s=[];let o=0;for(const a of r)i[o]=n?n(a,o):o,s[o]=e(a,o),o++;return{values:s,keys:i}}render(r,t,e){return this.dt(r,t,e).values}update(r,[t,e,n]){const i=jO(r),{values:s,keys:o}=this.dt(t,e,n);if(!Array.isArray(i))return this.ut=o,s;const a=this.ut??(this.ut=[]),c=[];let u,h,f=0,y=i.length-1,m=0,E=s.length-1;for(;f<=y&&m<=E;)if(i[f]===null)f++;else if(i[y]===null)y--;else if(a[f]===o[m])c[m]=mn(i[f],s[m]),f++,m++;else if(a[y]===o[E])c[E]=mn(i[y],s[E]),y--,E--;else if(a[f]===o[E])c[E]=mn(i[f],s[E]),Us(r,c[E+1],i[f]),f++,E--;else if(a[y]===o[m])c[m]=mn(i[y],s[m]),Us(r,i[f],i[y]),y--,m++;else if(u===void 0&&(u=Tm(o,m,E),h=Tm(a,f,y)),u.has(a[f]))if(u.has(a[y])){const x=h.get(o[m]),I=x!==void 0?i[x]:null;if(I===null){const P=Us(r,i[f]);mn(P,s[m]),c[m]=P}else c[m]=mn(I,s[m]),Us(r,i[f],I),i[x]=null;m++}else Mu(i[y]),y--;else Mu(i[f]),f++;for(;m<=E;){const x=Us(r,c[E+1]);mn(x,s[m]),c[m++]=x}for(;f<=y;){const x=i[f++];x!==null&&Mu(x)}return this.ut=o,VO(r,c),ei}}),Ie=r=>({type:"px",...r}),$e=r=>({type:"unit",...r}),il=2;class CM{constructor(t){g(this,"basis");g(this,"min");g(this,"_gap");g(this,"_viewport");g(this,"_unit");this.basis=t.basis,this.min=t.min,this._viewport=t.viewport,this._gap=t.gap??Ie({x:ae,y:ae});const e=this._viewport.x??Jn,n=this._viewport.y??fo,i=this._gap.x??ae,s=this._gap.y??ae,o=e<=bT,a=o?e-i*il:Math.min(Jn,e-i*il),c=o?n-s*il:Math.min(fo,n-s*il),u=(a-i*(qe-1))/qe,h=(c-s*(ft-1))/ft,f=this.basis.x??0,y=this.basis.y??0,m=this.min.x??0,E=this.min.y??0;this._unit=Ie(o?{x:Math.max(m,u),y:Math.max(E,h)}:{x:Math.max(m,Math.min(f,u)),y:Math.max(E,Math.min(y,h))})}get unit(){return this._unit}get viewport(){return this._viewport}get gap(){return this._gap}toUnits(t){return $e({x:t.x==null?void 0:t.x/(this._unit.x??1),y:t.y==null?void 0:t.y/(this._unit.y??1)})}toPixels(t){const e=this._unit.x??0,n=this._unit.y??0,i=this._gap.x??ae,s=this._gap.y??ae,o=t.x==null?void 0:t.x*e+Math.max(0,t.x-1)*i,a=t.y==null?void 0:t.y*n+Math.max(0,t.y-1)*s;return Ie({x:o,y:a})}}const ti=1e-4,Dt=1e-6,RM=40,PM=24;function f0(r,t){return Math.max(0,r-t*2)}function g0(r){const t=[0];for(const e of r)t.push((t[t.length-1]??0)+e);return t}function m0(r){const t=[0];for(let e=0;e<r.length;e+=1){const n=t[e]??0;t.push(n+r[e]+ae)}return t}function v0(r,t,e){if(t<0||t>=r.length)return 0;let n=0,i=0;for(let s=t;s<r.length;s+=1){const o=r[s],a=i===0?o:n+ae+o;if(a>e+ti)break;n=a,i+=1}return Math.max(1,i)}function LM(r,t,e){if(t<0||t>=r.length)return 0;let n=0,i=0;for(let s=t;s>=0;s-=1){const o=r[s],a=i===0?o:n+ae+o;if(a>e+ti)break;n=a,i+=1}return Math.max(1,i)}function DM(r,t){if(r.length===0)return 0;let e=0,n=0;for(let i=r.length-1;i>=0;i-=1){const s=r[i],o=n===0?s:e+ae+s;if(o>t+ti)break;e=o,n+=1}return Math.max(1,n)}function hp(r,t){if(r.length===0)return 0;const e=DM(r,t);return Math.max(0,r.length-e)}function Im(r,t,e){if(r.length===0)return 0;const n=v0(r,t,e),i=Math.min(r.length,t+n);if(i<=t)return 0;const s=r.slice(t,i);return s.reduce((o,a)=>o+a,0)+Math.max(0,s.length-1)*ae}function Qh(r,t,e){const n=r[t]??0;return e-n}function $i(r,t,e,n,i){if(r.length===0)return 0;const s=hp(r,i),o=t[s]??0,a=Math.max(0,Math.min(o,e));let c=0;for(let F=0;F<s;F+=1){const Y=t[F]??0,j=t[F+1]??Y;if(a>=Y&&a<=j+ti){c=F;break}c=F+1}const u=Math.min(c+1,s),h=t[c]??0,f=t[u]??h,y=Math.max(f-h,ti),m=u===c?0:(a-h)/y,E=m0(r),x=Im(r,c,i),I=Im(r,u,i),P=(n-x)/2,R=(n-I)/2,B=Qh(E,c,P),N=Qh(E,u,R);return B+(N-B)*m}function zM(r,t,e,n,i){const s=hp(r,n),o=t[s]??0;let a=0,c=o;for(let u=0;u<RM;u+=1){const h=(a+c)/2;$i(r,t,h,e,n)>i?a=h:c=h}return(a+c)/2}function OM(r,t,e){const n=m0(r),[i,s]=t,o=r.slice(i,s+1),a=o.reduce((u,h)=>u+h,0)+Math.max(0,o.length-1)*ae,c=(e-a)/2;return Qh(n,i,c)}function MM(r,t,e){const n=v0(r,t,e);return[t,Math.min(r.length-1,t+n-1)]}function NM(r,t,e){const n=LM(r,t,e);return[Math.max(0,t-n+1),t]}function UM(r,t){return r[0]===t[0]&&r[1]===t[1]}function FM(r){const{nodeCols:t,nodeWidthsPx:e,viewportWidthPx:n}=r;if(t.length===0||e.length===0)return{viewspans:[],minScroll:0,maxScroll:0};const i=e.length,s=r.gapPx??ae,o=f0(n,s),a=g0(t),c=hp(e,o),u=a[c]??0;function h(I){const P=OM(e,I,n),R=zM(e,a,n,o,P);return{nodeRange:I,anchor:Math.max(0,Math.min(u,R))}}const f=[];for(let I=0;I<i;){const P=MM(e,I,o);f.push(h(P)),I=P[1]+1}const y=h(NM(e,i-1,o)),m=f.filter(I=>I.nodeRange[0]<y.nodeRange[0]),E=m[m.length-1];return{viewspans:E&&UM(E.nodeRange,y.nodeRange)?m:[...m,y],minScroll:0,maxScroll:u}}function bi(r,t){var i;let e=0,n=Number.POSITIVE_INFINITY;for(let s=0;s<r.length;s+=1){const o=Math.abs((((i=r[s])==null?void 0:i.anchor)??0)-t);if(o+Dt<n){n=o,e=s;continue}Math.abs(o-n)<=Dt&&s<e&&(e=s)}return e}function HM(r,t,e){return e<=0?0:Math.max(0,Math.min(e-1,r+t))}function vn(r,t,e){return Math.max(t,Math.min(e,r))}function ZM(r,t){var e;for(let n=0;n<r.length;n+=1)if(Math.abs((((e=r[n])==null?void 0:e.anchor)??0)-t)<=Dt)return n;return-1}function WM(r,t,e){var i,s;if(r.length===0)return t;const n=ZM(r,t);if(n>=0){const o=r[n+e];return(o==null?void 0:o.anchor)??r[e>0?r.length-1:0].anchor}if(e>0){for(const o of r)if(o.anchor>t+Dt)return o.anchor;return((i=r[r.length-1])==null?void 0:i.anchor)??t}for(let o=r.length-1;o>=0;o-=1){const a=r[o];if(a&&a.anchor<t-Dt)return a.anchor}return((s=r[0])==null?void 0:s.anchor)??t}class BM extends Mt{constructor(e){super();g(this,"_scroll",0);g(this,"_minScroll",0);g(this,"_maxScroll",0);g(this,"_viewspans",[]);g(this,"_activeViewspanIndex",0);g(this,"_nodeWidthsPx",[]);g(this,"_boundaryCols",[0]);g(this,"_viewportWidthPx",0);g(this,"_framedViewportWidthPx",0);this._scroll=(e==null?void 0:e.x)??0}get scroll(){return $e({x:this._scroll})}get translate(){return Ie({x:$i(this._nodeWidthsPx,this._boundaryCols,this._scroll,this._viewportWidthPx,this._framedViewportWidthPx)})}get activeViewspan(){return this._viewspans[this._activeViewspanIndex]??null}get viewspans(){return this._viewspans}set scroll(e){const n=vn(e.x??this._scroll,this._minScroll,this._maxScroll);Math.abs(n-this._scroll)<=Dt||(this._scroll=n,this._activeViewspanIndex=bi(this._viewspans,this._scroll),this.dispatchEvent(new yi("layout-scroll",{scroll:this.scroll})))}rebuild(e){var y;const n=e.nodeWidths.map(m=>Math.max(0,m.x??0)),i=n.map(m=>e.grid.toPixels($e({x:m})).x??0),s=e.grid.viewport.x??0,o=e.grid.gap.x??ae,a=FM({nodeCols:n,nodeWidthsPx:i,viewportWidthPx:s,gapPx:o});this._nodeWidthsPx=i,this._boundaryCols=g0(n),this._viewportWidthPx=s,this._framedViewportWidthPx=f0(s,o),this._viewspans=a.viewspans,this._minScroll=a.minScroll,this._maxScroll=a.maxScroll;const c=vn(this._scroll,this._minScroll,this._maxScroll);this._activeViewspanIndex=bi(this._viewspans,c);const h=e.snap!==!1?((y=this._viewspans[this._activeViewspanIndex])==null?void 0:y.anchor)??c:c,f=vn(h,this._minScroll,this._maxScroll);Math.abs(f-this._scroll)>Dt&&(this._scroll=f,this.dispatchEvent(new yi("layout-scroll",{scroll:this.scroll})))}step(e){var o;if(this._viewspans.length===0)return;const n=HM(this._activeViewspanIndex,e,this._viewspans.length),i=((o=this._viewspans[n])==null?void 0:o.anchor)??this._scroll,s=vn(i,this._minScroll,this._maxScroll);this._activeViewspanIndex=n,!(Math.abs(s-this._scroll)<=Dt)&&(this._scroll=s,this.dispatchEvent(new yi("layout-scroll",{scroll:this.scroll})))}snap(e){var s;if(this._viewspans.length===0)return;const n=e===void 0?((s=this._viewspans[bi(this._viewspans,this._scroll)])==null?void 0:s.anchor)??this._scroll:WM(this._viewspans,this._scroll,e),i=vn(n,this._minScroll,this._maxScroll);this._activeViewspanIndex=bi(this._viewspans,i),!(Math.abs(i-this._scroll)<=Dt)&&(this._scroll=i,this.dispatchEvent(new yi("layout-scroll",{scroll:this.scroll})))}wheel(e){const n=vn(this._scroll+(e.x??0),this._minScroll,this._maxScroll);Math.abs(n-this._scroll)<=Dt||(this._scroll=n,this._activeViewspanIndex=bi(this._viewspans,this._scroll),this.dispatchEvent(new yi("layout-scroll",{scroll:this.scroll})))}wheelPixels(e){const n=e.x??0;if(Math.abs(n)<=ti)return;const i=$i(this._nodeWidthsPx,this._boundaryCols,this._scroll,this._viewportWidthPx,this._framedViewportWidthPx),s=i-n,o=$i(this._nodeWidthsPx,this._boundaryCols,this._maxScroll,this._viewportWidthPx,this._framedViewportWidthPx),a=$i(this._nodeWidthsPx,this._boundaryCols,this._minScroll,this._viewportWidthPx,this._framedViewportWidthPx),c=Math.max(o,Math.min(a,s));if(Math.abs(c-i)<=ti)return;let u=this._minScroll,h=this._maxScroll;for(let y=0;y<PM;y+=1){const m=(u+h)/2;$i(this._nodeWidthsPx,this._boundaryCols,m,this._viewportWidthPx,this._framedViewportWidthPx)>c?u=m:h=m}const f=vn((u+h)/2,this._minScroll,this._maxScroll);Math.abs(f-this._scroll)<=Dt||(this._scroll=f,this._activeViewspanIndex=bi(this._viewspans,this._scroll),this.dispatchEvent(new yi("layout-scroll",{scroll:this.scroll})))}}const Zu={"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}},VM=["stack-above","stack-below","reorder-before","reorder-after"];function Wu(r,t){return{left:r.left+r.width*t.left,top:r.top+r.height*t.top,width:r.width*t.width,height:r.height*t.height}}function yn(r,t,e){return r>=e.left&&r<e.left+e.width&&t>=e.top&&t<e.top+e.height}function Mi(r){return r.artifactID}function ed(r){return Number.isFinite(r)?Math.max(po,Math.min(Yd,Math.round(r))):po}function jM(r,t,e){const n=r.findIndex(a=>a.type==="card"&&Mi(a)===t);if(n===-1)return r;const i=r[n];if(!i||i.type!=="card")return r;const s=ed(e);if(i.width===s)return r;const o=[...r];return o[n]={...i,width:s},o}function y0(r,t){for(const e of r){if(e.type==="card"&&Mi(e)===t)return e;if(e.type==="stack")for(const n of e.children){if(n.type==="card"&&Mi(n)===t)return n;if(n.type==="row"){for(const i of n.children)if(Mi(i)===t)return i}}}return null}function td(r){const t=r.height===ft||r.height===tn?tn:r.height;return r.width===qe&&r.height===t?r:{...r,width:qe,height:t}}function rd(r){return r.height===tn?{...r,height:ft}:r}function GM(r,t,e,n){const i=r.findIndex(h=>h.type==="stack"&&h.id===t);if(i===-1)return r;const s=r[i];if(!s||s.type!=="stack")return r;const o=s.children.find(h=>h.type==="card"&&Mi(h)===e);if(!o||o.type!=="card")return r;const a=s.children.filter(h=>h.type!=="card"||Mi(h)!==e);if(a.length===s.children.length||a.length<1)return r;const c=[...r];if(a.length===1){const[h]=a;c[i]=h.type==="card"?rd(h):h}else c[i]={...s,children:a};const u=Math.max(0,Math.min(n,c.length));return c.splice(u,0,rd(o)),c}const qM=Ve(),YM=Ve(),KM=50;function JM(r,t){if(r.type!==t.type)return!1;switch(r.type){case"reorder":return t.index===r.index;case"stack":return t.targetCardId===r.targetCardId&&t.position===r.position;case"stack-child-noop":return!0;case"stack-child-extract":return t.toIndex===r.toIndex;case"stack-child-reorder":return t.position===r.position;default:return!1}}function Qe(r){return r.artifactID}function Cm(r){return r.type==="card"?Qe(r):r.id}function La(r){return{id:Qe(r),type:"drop-target",width:r.width,height:r.height}}function Rm(r){return r.map(QM)}function XM(r){return r.type==="drop-target"?{type:"card",artifactID:r.id,width:r.width,height:r.height}:r}function QM(r){return r.type==="drop-target"?{type:"card",artifactID:r.id,width:r.width,height:r.height}:r.type==="stack"?{...r,children:r.children.map(XM)}:r}function b0(r,t){return r.find(n=>n.type==="card"&&Qe(n)===t)??null}function Pm(r,t){return r.find(n=>n.type==="stack"&&n.id===t)??null}function eN(r,t){const e=[...t],n=e.findIndex(a=>a.type==="card"&&Qe(a)===r.nodeId);if(n===-1)return null;const i=e[n];if(!i||i.type!=="card")return null;e.splice(n,1);const s=Math.max(0,Math.min(r.lastReorderIndex,e.length));e.splice(s,0,i);const o=e.findIndex(a=>a.type==="card"&&Qe(a)===r.nodeId);return o===-1?null:{base:e,visualDraggedIndex:o}}function tN(r,t,e,n){const i=[...r.base];i.splice(r.visualDraggedIndex,1);const s=i.findIndex(y=>y.type==="card"&&Qe(y)===e.targetCardId),o=s===-1?null:i[s];if(!o||o.type!=="card")return null;const a=b0(n,t.nodeId);if(!a)return null;const c=td(a),u=td(o),h=La(c),f=e.position==="above"?[h,u]:[u,h];return i[s]={id:Qe(o),type:"stack",children:f},i}function Bu(r,t){return r.parentStackId?nN(r,t):rN(r,t)}function rN(r,t){const e=r.hitTarget;if(e.type==="reorder"){const n=t[r.sourceIndex];if(!n||n.type!=="card")return[...t];const i=[...t];return i.splice(r.sourceIndex,1),i.splice(e.index,0,La(n)),i}if(e.type==="stack"){const n=eN(r,t);return n?tN(n,r,e,t)??[...t]:[...t]}return[...t]}function nN(r,t){const e=r.hitTarget;switch(e.type){case"stack-child-reorder":return iN(r,t,e.position);case"stack-child-extract":return sN(r,t,e.toIndex);case"stack-child-noop":return oN(r,t);default:return[...t]}}function iN(r,t,e){const n=t.findIndex(y=>y.type==="stack"&&y.id===r.parentStackId);if(n===-1)return[...t];const i=t[n];if(!i||i.type!=="stack")return[...t];if(!i.children.every(y=>y.type==="card"))return[...t];const s=i.children,o=s.findIndex(y=>Qe(y)===r.nodeId);if(o===-1)return[...t];const a=s[o],c=s.filter(y=>Qe(y)!==r.nodeId),u=La(a),h=e==="above"?[u,...c]:[...c,u],f=[...t];return f[n]={...i,children:h},f}function sN(r,t,e){if(!r.parentStackId)return[...t];const n=GM(t,r.parentStackId,r.nodeId,e);if(n===t)return[...t];const i=n.findIndex(a=>a.type==="card"&&Qe(a)===r.nodeId);if(i===-1)return[...t];const s=n[i];if(!s||s.type!=="card")return[...t];const o=[...n];return o[i]=La(s),o}function oN(r,t){const e=t.findIndex(c=>c.type==="stack"&&c.id===r.parentStackId);if(e===-1)return[...t];const n=t[e];if(!n||n.type!=="stack")return[...t];const i=n.children.findIndex(c=>c.type==="card"&&Qe(c)===r.nodeId);if(i===-1)return[...t];const s=n.children[i];if(!s||s.type!=="card")return[...t];const o=[...t],a=[...n.children];return a[i]=La(s),o[e]={...n,children:a},o}function aN(r,t){return t.find(n=>n.type==="stack"&&n.id===r.id)?r.id:Ac()}function lN(r,t,e){if(r.type==="drop-target"){const n=y0(t,e);if(!n)throw new Error(`finalize: missing dragged card ${e}`);return td(n)}return r}function cN(r,t,e){const n=r.children.map(s=>lN(s,t,e));return{id:aN(r,t),type:"stack",children:n}}function uN(r,t,e){if(r.type==="drop-target"){const n=y0(t,e);if(!n)throw new Error(`finalize: missing dragged card ${e}`);return b0(t,e)!==null?n:rd(n)}return r.type==="card"||r.type==="row"?r:cN(r,t,e)}function hN(r,t,e){return r.map(n=>uN(n,t,e))}function dN(r,t){return JSON.stringify(r)===JSON.stringify(t)}const pN=Ra(Mt);class fN extends pN{constructor(e={}){super();g(this,"pending",null);g(this,"active",null)}start(e){if(this.pending||this.active)return;const n=e.pointer.x??0,i=e.pointer.y??0;this.pending={startX:n,startY:i,grabOffsetX:e.grabOffset.x??0,grabOffsetY:e.grabOffset.y??0,nodeId:e.nodeId,sourceIndex:e.source.index,parentStackId:e.source.parentId,width:e.size.x??0,height:e.size.y??0,baseLayout:e.layout}}update(e){const n=e.pointer.x??0,i=e.pointer.y??0,s=this.pending;if(s){const u=n-s.startX,h=i-s.startY;Math.hypot(u,h)>=ST&&(this.pending=null,this.active={...s,pointerX:n,pointerY:i,hitTarget:{type:"reorder",index:s.sourceIndex},lastReorderIndex:s.sourceIndex},this.emitDrag(),this.dispatchEvent(new oe("change")));return}if(!this.active)return;const o=Bu(this.active,this.active.baseLayout),a=this.getHitTargetForPointer(n,i,e,o),c=a.type==="reorder"?a.index:this.active.lastReorderIndex;this.active.pointerX===n&&this.active.pointerY===i&&JM(this.active.hitTarget,a)&&this.active.lastReorderIndex===c||(this.active={...this.active,pointerX:n,pointerY:i,hitTarget:a,lastReorderIndex:c},this.emitDrag(),this.dispatchEvent(new oe("change")))}drop(){if(this.pending){this.cancel();return}if(!this.active)return;const e=this.active.baseLayout;let n=null;try{const i=Bu(this.active,e),s=hN(i,e,this.active.nodeId);dN(s,e)||(n=s)}catch{n=null}this.reset(),n&&this.dispatchEvent(new YM("drop",{layout:n})),this.dispatchEvent(new oe("change"))}cancel(){!this.pending&&!this.active||(this.reset(),this.dispatchEvent(new oe("change")))}dispose(){this.reset()}get status(){return this.active?"active":this.pending?"pending":"idle"}reset(){this.pending=null,this.active=null}emitDrag(){if(!this.active)return;const e=Bu(this.active,this.active.baseLayout);this.dispatchEvent(new qM("drag",{nodeId:this.active.nodeId,source:{index:this.active.sourceIndex,parentId:this.active.parentStackId},grabOffset:Ie({x:this.active.grabOffsetX,y:this.active.grabOffsetY}),pointer:Ie({x:this.active.pointerX,y:this.active.pointerY}),size:Ie({x:this.active.width,y:this.active.height}),projectedLayout:e}))}getHitTargetForPointer(e,n,i,s){return this.active?this.isPointerInsideDragBounds(e,n,i.viewport)?this.active.parentStackId?this.getStackChildHitTarget(e,n,i,s):this.getTopLevelCardHitTarget(e,n,i,s):{type:"reorder",index:this.active.sourceIndex}:{type:"reorder",index:0}}getStackChildHitTarget(e,n,i,s){var u;if(!((u=this.active)!=null&&u.parentStackId))return{type:"stack-child-noop"};const o=this.getSourceStackInteractionRect(i.geometry);if(o&&yn(e,n,o)){const h=o.top+o.height/2;return{type:"stack-child-reorder",position:n<h?"above":"below"}}const a=this.getSourceRemainingSiblingRect(i.geometry);if(a&&yn(e,n,a)){const h=a.top+a.height/2;return{type:"stack-child-reorder",position:n<h?"above":"below"}}return{type:"stack-child-extract",toIndex:this.getTopLevelReorderIndexForPointer(e,n,i,s)}}getSourceRemainingSiblingRect(e){var s,o;if(!((s=this.active)!=null&&s.parentStackId))return;const n=Pm(this.active.baseLayout,this.active.parentStackId);if(!n)return;const i=n.children.find(a=>{var c;return a.type==="card"&&Qe(a)!==((c=this.active)==null?void 0:c.nodeId)});if(i)return(o=e.find(a=>a.id===Qe(i)))==null?void 0:o.rect}getSourceStackInteractionRect(e){var o;if(!((o=this.active)!=null&&o.parentStackId))return;const n=e.find(a=>{var c;return a.id===((c=this.active)==null?void 0:c.parentStackId)});if(n)return this.active.sourceStackRect=n.rect,n.rect;const i=Pm(this.active.baseLayout,this.active.parentStackId);if(!i)return this.active.sourceStackRect;const s=i.children.find(a=>{var c;return a.type==="card"&&Qe(a)!==((c=this.active)==null?void 0:c.nodeId)});if(s){const a=e.find(c=>c.id===Qe(s));if(a)return a.rect}return this.active.sourceStackRect}getTopLevelCardHitTarget(e,n,i,s){var m,E,x;const o=this.getTopLevelZoneNodes(i.geometry,s);if(o.length===0)return{type:"reorder",index:((m=this.active)==null?void 0:m.sourceIndex)??0};const c=(i.effectiveVelocity??0)<=KM;for(const I of o){const P=I.rect;if(!yn(e,n,P))continue;const R=this.resolveTopLevelTargetForCard(e,n,I,I.logicalIndex,c);if(R)return R;if(!c&&((E=this.active)!=null&&E.hitTarget))return this.active.hitTarget.type==="reorder"?this.active.hitTarget:this.active.hitTarget.type==="stack"&&this.active.hitTarget.targetCardId===I.id?this.active.hitTarget:{type:"reorder",index:e<this.active.pointerX?I.logicalIndex:I.logicalIndex+1}}const u=this.getNearestTargetableZone(e,o);if(!u)return{type:"reorder",index:((x=this.active)==null?void 0:x.sourceIndex)??0};const h=Math.max(u.rect.left,Math.min(u.rect.left+u.rect.width,e)),f=this.resolveTopLevelTargetForCard(h,n,u,u.logicalIndex,c);if(f)return f;const y=u.rect.left+u.rect.width/2;return{type:"reorder",index:e<y?u.logicalIndex:u.logicalIndex+1}}getTopLevelReorderIndexForPointer(e,n,i,s){var u,h;const o=this.getTopLevelZoneNodes(i.geometry,s);if(o.length===0)return((u=this.active)==null?void 0:u.sourceIndex)??0;for(const f of o){if(!yn(e,n,f.rect))continue;const y=Wu(f.rect,Zu["reorder-before"]);if(yn(e,n,y))return f.logicalIndex;const m=Wu(f.rect,Zu["reorder-after"]);if(yn(e,n,m))return f.logicalIndex+1}const a=this.getNearestTargetableZone(e,o);if(!a)return((h=this.active)==null?void 0:h.sourceIndex)??0;const c=a.rect.left+a.rect.width/2;return e<c?a.logicalIndex:a.logicalIndex+1}getTopLevelZoneNodes(e,n){const i=new Map(n.map(a=>[Cm(a),a])),s=[];let o=0;for(const a of e){const c=i.get(a.id);c&&c.type!=="drop-target"&&(c.type==="card"||c.type==="stack")&&(s.push({id:Cm(c),rect:a.rect,logicalIndex:o}),o+=1)}return s}resolveTopLevelTargetForCard(e,n,i,s,o){const a=i.rect;for(const c of VM){if(!o&&(c==="stack-above"||c==="stack-below"))continue;const u=Zu[c],h=Wu(a,u);if(yn(e,n,h))return c==="stack-above"?{type:"stack",targetCardId:i.id,position:"above"}:c==="stack-below"?{type:"stack",targetCardId:i.id,position:"below"}:c==="reorder-before"?{type:"reorder",index:s}:{type:"reorder",index:s+1}}return null}getNearestTargetableZone(e,n){let i=null,s=Number.POSITIVE_INFINITY;for(const o of n){const a=o.rect.left,c=o.rect.left+o.rect.width,u=e<a?a-e:e>c?e-c:0;u<s&&(s=u,i=o)}return i}isPointerInsideDragBounds(e,n,i){return e>=i.left&&e<=i.left+i.width&&n>=i.top&&n<=i.top+i.height}}const gN=100,mN=1e3;class vN{constructor(t,e){g(this,"_status","idle");g(this,"cumulativeOffset",0);g(this,"samples",[]);g(this,"scroll");g(this,"setAnimating");this.scroll=t,this.setAnimating=e}get status(){return this._status}start(t){this._status="active",this.cumulativeOffset=0,this.samples=[{time:t,offset:0}]}move(t,e){this._status==="active"&&(this.cumulativeOffset+=e,this.samples.push({time:t,offset:this.cumulativeOffset}),this.pruneSamples(t),this.setAnimating(!1),this.scroll.wheelPixels(Ie({x:-e})))}end(){if(this._status!=="active")return;const t=this.computeVelocityPxPerSec();this.setAnimating(!0),Math.abs(t)<kT?this.scroll.snap():this.scroll.snap(t>0?-1:1),this.reset()}cancel(){this._status==="active"&&(this.setAnimating(!0),this.scroll.snap(),this.reset())}reset(){this._status="idle",this.cumulativeOffset=0,this.samples=[]}pruneSamples(t){const e=t-gN;let n=0;for(let i=0;i<this.samples.length;i+=1){if(this.samples[i].time>=e){n=i;break}n=i+1}if(n>0){const i=Math.max(0,n-1);this.samples=this.samples.slice(i)}}computeVelocityPxPerSec(){if(this.samples.length<2)return 0;const t=this.samples[0],e=this.samples[this.samples.length-1],n=e.time-t.time;return n<=0?0:(e.offset-t.offset)/n*mN}}function Di(r){return r.artifactID}function yN(r){return r.type==="card"?Di(r):r.id}function bN({baseLayout:r,visibleLayout:t,resolved:e,cardsByID:n,grid:i,dragState:s,isForeground:o}){var E;const a=new Map(t.map(x=>[yN(x),x])),c=e.nodes.map((x,I)=>{const P=a.get(x.id),R=[];for(const N of x.cards){if(s&&N.artifactID===s.nodeId){R.push({key:`placeholder:${N.artifactID}`,kind:"placeholder",card:null,placement:N,isTopLevelCard:!1,isDragged:!1,sourceStackId:s.source.parentId??null});continue}const F=n.get(N.artifactID);F&&R.push({key:Di(F),kind:"card",card:F,placement:N,isTopLevelCard:(P==null?void 0:P.type)==="card",isDragged:!1,sourceStackId:null})}if(s!=null&&s.source.parentId&&x.id===s.source.parentId){const N=n.get(s.nodeId);if(N){const F={key:Di(N),kind:"card",card:N,placement:null,isTopLevelCard:!1,isDragged:!0,sourceStackId:s.source.parentId},Y=wN(r,s.source.parentId,s.nodeId),j=Y<0?R.length:Math.min(Y,R.length);R.splice(j,0,F)}}const B=!!(s&&(P==null?void 0:P.type)==="card"&&Di(P)===s.nodeId);return{key:B?`placeholder:${x.id}`:x.id,kind:"visible",nodeId:x.id,widthPx:i.toPixels($e({x:x.width})).x??0,widthUnits:x.width,layoutIndex:I,isForeground:o(I),isPlaceholder:B,slots:R}});if(!s||s.source.parentId&&a.has(s.source.parentId))return c;const u=n.get(s.nodeId);if(!u)return c;const h=s.source.parentId??s.nodeId,f=((E=An(r).nodes[s.source.index])==null?void 0:E.width)??qe,y={key:h,kind:"ghost",nodeId:h,widthPx:0,widthUnits:f,layoutIndex:null,isForeground:!1,isPlaceholder:!1,slots:[{key:Di(u),kind:"card",card:u,placement:null,isTopLevelCard:!s.source.parentId,isDragged:!0,sourceStackId:s.source.parentId??null}]},m=Math.max(0,Math.min(s.source.index,c.length));return c.splice(m,0,y),c}function Lm(r){if(!r)return null;const t=r.projectedLayout,e=r.source.parentId;for(const i of t){if(i.type!=="stack")continue;const s=i.children.findIndex(u=>u.type==="drop-target");if(s===-1)continue;const o=s===0?"above":"below";if(e&&e===i.id)return`stack-child-reorder:${o}`;const a=i.children.find(u=>u.type!=="drop-target");return`stack:${(a==null?void 0:a.type)==="card"?a.artifactID:(a==null?void 0:a.id)??""}:${o}`}const n=t.findIndex(i=>i.type==="drop-target");return n===-1?"none":e?`stack-child-extract:${n}`:`reorder:${n}`}function wN(r,t,e){const n=r.find(i=>i.type==="stack"&&i.id===t);return!n||n.type!=="stack"?-1:n.children.findIndex(i=>i.type==="card"&&Di(i)===e)}const SN=2,Dm=1e3,wi=1e-4,_N=120,zm=!1;function Om(r){return r.replace(/["\\]/g,"\\$&")}function we(r){return r.artifactID}function Ni(r){return r.type==="card"?we(r):r.id}function Mm(r,t,e){if(r===0)return 0;const n=t.toPixels($e({y:ft})).y??0;return(e-n)/SN}function Vu(r){const t=r.clientWidth>0?r.clientWidth:Jn,e=r.clientHeight>0?r.clientHeight:fo;let n=0,i=0;if(r.isConnected){const u=getComputedStyle(r);n=parseFloat(u.paddingTop)||0,i=parseFloat(u.paddingBottom)||0}const s=Math.max(1,e-n-i),o=r.isConnected&&parseFloat(getComputedStyle(r).getPropertyValue("--layout-virtual-bottom-balance"))||0,a=fo+ae*2,c=Math.min(o,Math.max(0,s-a));return{width:t,height:s-c,offsetY:n}}function kN(r){return r.shiftKey&&r.deltaX===0&&r.deltaY!==0?r.deltaY:r.deltaX}function xN(r){var e;if(!(r instanceof Element))return!1;const t=r.closest("input, textarea, select, [contenteditable], [role='textbox'], [role='searchbox'], [role='combobox'], [role='spinbutton'], [role='slider']");return t?t.hasAttribute("contenteditable")?((e=t.getAttribute("contenteditable"))==null?void 0:e.toLowerCase())!=="false":!0:!1}class EN extends Event{constructor(e){super("scroll",{bubbles:!0,composed:!0});g(this,"scrollPosition");this.scrollPosition=e}}class w0 extends Event{constructor(e){super("layout-change",{bubbles:!0,composed:!0});g(this,"layout");this.layout=e}}class AN extends HTMLElement{constructor(){super();g(this,"_layout",[]);g(this,"_scrollPosition",0);g(this,"layoutGrid",null);g(this,"layoutScroll",new BM($e({x:0})));g(this,"scrollModelKey","");g(this,"resizeObserver",null);g(this,"renderPending",!1);g(this,"animateNextRender",!0);g(this,"swipeGesture",new vN(this.layoutScroll,e=>{this.animateNextRender=e}));g(this,"swipePointerId",null);g(this,"swipeStartX",0);g(this,"swipeStartY",0);g(this,"swipeLastX",0);g(this,"swipeActive",!1);g(this,"swipeShouldSuppressClick",!1);g(this,"swipeListenersAttached",!1);g(this,"wheelIdleSnapTimer",null);g(this,"dragController",new fN);g(this,"dragState",null);g(this,"activeDragPointerId",null);g(this,"dragListenersAttached",!1);g(this,"dragFrame",0);g(this,"lastDragFrameTime",0);g(this,"lastPointerX",0);g(this,"lastPointerY",0);g(this,"pointerVelocityPxPerSec",0);g(this,"scrollVelocityPxPerSec",0);g(this,"motionSampleTime",0);g(this,"motionSampleX",0);g(this,"motionSampleY",0);g(this,"lastDragControllerStatus","idle");g(this,"lastProjectedDragLayoutSignature","");g(this,"lastDragDropIntent",null);g(this,"lastActivePlaceholderId",null);g(this,"draggedSlotElement",null);g(this,"draggedSlotContainingBlock",null);g(this,"currentDragPreviewSize",null);g(this,"dragTrackOffsetXPx",0);g(this,"previousProjectedLayoutForOffset",null);g(this,"resizeState",null);g(this,"resizeListenersAttached",!1);g(this,"_cards",new Map);g(this,"onDragControllerChange",()=>{const e=this.dragController.status;e!==this.lastDragControllerStatus&&(this.lastDragControllerStatus=e,e==="idle"&&(this.dragState=null,this.resetDragPreviewState()),this.scheduleRender())});g(this,"onDragControllerDrag",e=>{var c;const n=JSON.stringify(e.projectedLayout),i=Lm(e),s=$N(e.projectedLayout);if(n!==this.lastProjectedDragLayoutSignature||i!==this.lastDragDropIntent||s!==this.lastActivePlaceholderId){const u=Rm(e.projectedLayout),h=this.shouldApplyTrackOffset(e.projectedLayout,e.source.parentId),f=e.source.parentId?this.getStackChildAnchorCardId(e.source.parentId,e.nodeId):null;this.dragTrackOffsetXPx=h?this.computeDragTrackOffset(this.previousProjectedLayoutForOffset,u,e.nodeId,e.source.parentId,f,this.dragTrackOffsetXPx):0,this.previousProjectedLayoutForOffset=u,this.lastProjectedDragLayoutSignature=n,this.lastDragDropIntent=i,this.lastActivePlaceholderId=s,this.dragState={nodeId:e.nodeId,source:e.source,grabOffset:e.grabOffset,pointer:e.pointer,size:e.size,projectedLayout:e.projectedLayout},this.scheduleRender();return}this.dragState={nodeId:e.nodeId,source:e.source,grabOffset:e.grabOffset,pointer:e.pointer,size:e.size,projectedLayout:((c=this.dragState)==null?void 0:c.projectedLayout)??e.projectedLayout};const a=this.getCachedDraggedSlotElement(e.nodeId);a&&this.writeDraggedSlotPosition(a,this.dragState)});g(this,"onDragControllerDrop",e=>{this.dragState=null,this.resetDragPreviewState(),this.commitLayout(e.layout)});g(this,"onLayoutScrollInternal",e=>{const i=e.scroll.x??0;Math.abs(i-this._scrollPosition)<wi||(this._scrollPosition=i,this.emitScrollPositionChanged(i),this.scheduleRender())});g(this,"handleKeyDown",e=>{if(e.key==="Escape"&&this.dragController.status!=="idle"){e.preventDefault(),this.stopDragFrameLoop(),this.releaseActiveDragPointerCapture(),this.dragController.cancel(),this.detachDragListeners();return}this.dragController.status==="idle"&&(xN(e.target)||(e.key==="ArrowRight"?(e.preventDefault(),this.stepFilmstrip(1)):e.key==="ArrowLeft"&&(e.preventDefault(),this.stepFilmstrip(-1))))});g(this,"handleWheel",e=>{if(this._layout.length===0)return;const n=kN(e);Math.abs(n)<wi||(e.preventDefault(),this.applyHorizontalWheel(n))});g(this,"handleWindowMessage",e=>{if(this._layout.length===0)return;const n=this.findManagedArtifactFrame(e.source);if(n&&this.isTrustedArtifactFrameMessage(e,n)){if(SS(e.data)){const i=typeof performance<"u"?performance.now():Date.now();this.swipeGesture.status==="idle"&&this.swipeGesture.start(i),this.swipeGesture.move(i,e.data.deltaX);return}if(_S(e.data)){this.swipeGesture.status==="active"&&this.swipeGesture.end();return}}});g(this,"handleArtifactFilmstripKey",e=>{this._layout.length!==0&&this.stepFilmstrip(e.direction)});g(this,"handleArtifactWheel",e=>{this._layout.length!==0&&(Math.abs(e.deltaX)<wi||this.applyHorizontalWheel(e.deltaX))});g(this,"handlePointerDown",e=>{if(e.button!==0||this.dragController.status!=="idle"||this.resizeState)return;const n=e.target;if(!(n instanceof Element))return;const i=n.closest("[data-resize-handle]");if(i){this.beginResize(e,i);return}const s=n.closest("[drag-handle]")!==null,o=n.closest("button, input, textarea, select, a, [role='button']")!==null;if(e.pointerType==="touch"&&!s&&!o&&this._layout.length>0){this.beginSwipeTracking(e);return}if(!s){if(!o){const f=n.closest(".node");if(f&&!f.hasAttribute("data-foreground")){const y=f.getAttribute("layout-node");if(y!==null){const m=parseInt(y,10);if(!isNaN(m)){const E=this.findViewspanContainingNode(m);if(E){this.clearWheelIdleSnap(),this.animateNextRender=!0,this.layoutScroll.scroll=$e({x:E.anchor}),e.preventDefault(),e.stopPropagation();return}}}}}return}if(o)return;const a=n.closest(".card-slot");if(!a)return;const c=a.getAttribute("data-layout-card-id");if(!c)return;const u=IN(this._layout,c);if(!u)return;const h=a.getBoundingClientRect();this.lastPointerX=e.clientX,this.lastPointerY=e.clientY,this.resetMotionTracking(e.clientX,e.clientY),this.focus(),this.dragController.start({nodeId:c,source:{index:u.topLevelIndex,parentId:u.sourceStackId},pointer:Ie({x:e.clientX,y:e.clientY}),grabOffset:Ie({x:e.clientX-h.left,y:e.clientY-h.top}),size:Ie({x:h.width,y:h.height}),layout:this._layout}),this.attachDragListeners(),this.activeDragPointerId=e.pointerId;try{this.setPointerCapture(e.pointerId)}catch{}e.preventDefault()});g(this,"handleResizePointerMove",e=>{const n=this.resizeState;if(!n||e.pointerId!==n.pointerId)return;const i=this.layoutGrid,s=((i==null?void 0:i.unit.x)??Nr)+ae;if(s<=0)return;const o=e.clientX-n.startClientX,a=ed(n.startWidth+o/s);a!==n.currentWidth&&(n.currentWidth=a,this.scheduleRender())});g(this,"handleResizePointerUp",e=>{const n=this.resizeState;if(!n||e.pointerId!==n.pointerId)return;const i=n.currentWidth,s=n.startWidth,o=n.cardId;this.endResize(e.pointerId),i!==s?this.commitLayout(jM(this._layout,o,i)):this.scheduleRender()});g(this,"handleResizePointerCancel",e=>{!this.resizeState||e.pointerId!==this.resizeState.pointerId||(this.endResize(e.pointerId),this.scheduleRender())});g(this,"handleResizeWindowBlur",()=>{this.resizeState&&(this.endResize(this.resizeState.pointerId),this.scheduleRender())});g(this,"handleResizeKeyDown",e=>{this.resizeState&&e.key==="Escape"&&(e.preventDefault(),this.endResize(this.resizeState.pointerId),this.scheduleRender())});g(this,"handleSwipePointerMove",e=>{if(this.swipePointerId===null||e.pointerId!==this.swipePointerId)return;if(!this.swipeActive){const i=e.clientX-this.swipeStartX,s=e.clientY-this.swipeStartY,o=Math.abs(i),a=Math.abs(s);if(o<Rg&&a<Rg)return;if(a>=o){this.endSwipeTracking();return}this.swipeActive=!0,this.swipeShouldSuppressClick=!0;try{this.setPointerCapture(e.pointerId)}catch{}this.swipeGesture.start(e.timeStamp)}const n=e.clientX-this.swipeLastX;this.swipeLastX=e.clientX,this.swipeGesture.move(e.timeStamp,n),e.preventDefault()});g(this,"handleSwipePointerUp",e=>{this.swipePointerId===null||e.pointerId!==this.swipePointerId||(this.swipeActive&&this.swipeGesture.end(),this.releaseSwipePointerCapture(e.pointerId),this.endSwipeTracking())});g(this,"handleSwipePointerCancel",e=>{this.swipePointerId===null||e.pointerId!==this.swipePointerId||(this.swipeActive&&this.swipeGesture.cancel(),this.releaseSwipePointerCapture(e.pointerId),this.endSwipeTracking())});g(this,"handleSwipeWindowBlur",()=>{this.swipePointerId!==null&&this.swipeActive&&this.swipeGesture.cancel(),this.swipePointerId!==null&&this.releaseSwipePointerCapture(this.swipePointerId),this.endSwipeTracking()});g(this,"handleSwipeClick",e=>{this.swipeShouldSuppressClick&&(this.swipeShouldSuppressClick=!1,e.preventDefault(),e.stopPropagation(),typeof e.stopImmediatePropagation=="function"&&e.stopImmediatePropagation())});g(this,"handleWindowPointerMove",e=>{this.activeDragPointerId!==null&&e.pointerId!==this.activeDragPointerId||(this.lastPointerX=e.clientX,this.lastPointerY=e.clientY,this.updatePointerVelocity(e.clientX,e.clientY),this.syncDragTargetForLatestPointer(),this.ensureDragFrameLoop())});g(this,"handleWindowPointerUp",e=>{this.activeDragPointerId!==null&&e.pointerId!==this.activeDragPointerId||(this.stopDragFrameLoop(),this.releasePointerCaptureForEvent(e.pointerId),this.dragController.drop(),this.clearMotionTracking(),this.detachDragListeners())});g(this,"handleWindowPointerCancel",e=>{if(!(this.activeDragPointerId!==null&&e.pointerId!==this.activeDragPointerId)){if(this.dragController.status==="active"){this.ensureDragFrameLoop();return}this.stopDragFrameLoop(),this.releasePointerCaptureForEvent(e.pointerId),this.dragController.cancel(),this.clearMotionTracking(),this.detachDragListeners()}});g(this,"handleWindowBlur",()=>{this.releaseActiveDragPointerCapture(),this.stopDragFrameLoop(),this.dragController.cancel(),this.clearMotionTracking(),this.detachDragListeners()});g(this,"runDragFrame",e=>{if(this.dragController.status==="idle"){this.dragFrame=0;return}const n=Math.max(0,e-this.lastDragFrameTime)/Dm;this.lastDragFrameTime=e,this.samplePointerVelocityAt(e,this.lastPointerX,this.lastPointerY);const i=this.getBoundingClientRect(),s=this.clampPointerToViewport(this.lastPointerX,this.lastPointerY,i),o=this.getDragEdgeScrollDeltaPixels(s.x,i,n);this.scrollVelocityPxPerSec=n>wi?Math.abs(o)/n:0,Math.abs(o)>wi&&(this.animateNextRender=!1,this.layoutScroll.wheelPixels(Ie({x:o}))),this.dragController.status==="active"&&this.syncDragTarget(s.x,s.y,i),this.dragFrame=requestAnimationFrame(this.runDragFrame)});this.dragController.addEventListener("change",this.onDragControllerChange),this.dragController.addEventListener("drag",this.onDragControllerDrag),this.dragController.addEventListener("drop",this.onDragControllerDrop),this.layoutScroll.addEventListener("layout-scroll",this.onLayoutScrollInternal)}set cards(e){this._cards!==e&&(this._cards=e,this.scheduleRender())}get cards(){return this._cards}set layout(e){const n=[...e];this.dragController.status!=="idle"&&JSON.stringify(n)===JSON.stringify(this._layout)||(this._layout=n,this.stopDragFrameLoop(),this.dragController.cancel(),this.resizeState&&this.endResize(this.resizeState.pointerId),this.scrollModelKey="",this.syncScrollModel(),this.layoutScroll.scroll=$e({x:this._scrollPosition}),this.scheduleRender())}get layout(){return this._layout}commitLayout(e){this.layout=e,this.emitLayoutChanged()}set scrollPosition(e){Math.abs(e-this._scrollPosition)<wi||(this.animateNextRender=!1,this.syncScrollModel(),this.layoutScroll.scroll=$e({x:e}))}get scrollPosition(){return this._scrollPosition}focusArtifact(e){const n=An(this._layout),i=n.nodes.findIndex(o=>o.cards.some(a=>a.artifactID===e));if(i<0)return;let s=0;for(let o=0;o<i;o+=1)s+=n.nodes[o].width;this.scrollPosition=s,queueMicrotask(()=>{const o=this.querySelector(`.card-slot[data-layout-card-id="${Om(e)}"]`);if(!o)return;o.classList.remove("card-focus-pulse"),o.offsetHeight,o.classList.add("card-focus-pulse");const a=()=>{o.classList.remove("card-focus-pulse"),o.removeEventListener("animationend",a)};o.addEventListener("animationend",a)})}connectedCallback(){this.hasAttribute("tabindex")||(this.tabIndex=0),this.focus(),this.addEventListener("keydown",this.handleKeyDown),this.addEventListener("wheel",this.handleWheel,{passive:!1}),this.addEventListener("pointerdown",this.handlePointerDown),this.addEventListener("artifact-wheel",this.handleArtifactWheel),this.addEventListener("artifact-filmstrip-key",this.handleArtifactFilmstripKey),window.addEventListener("message",this.handleWindowMessage),typeof ResizeObserver<"u"&&(this.resizeObserver=new ResizeObserver(()=>this.render()),this.resizeObserver.observe(this)),this.render()}disconnectedCallback(){var e;this.removeEventListener("keydown",this.handleKeyDown),this.removeEventListener("wheel",this.handleWheel),this.removeEventListener("pointerdown",this.handlePointerDown),this.removeEventListener("artifact-wheel",this.handleArtifactWheel),this.removeEventListener("artifact-filmstrip-key",this.handleArtifactFilmstripKey),window.removeEventListener("message",this.handleWindowMessage),(e=this.resizeObserver)==null||e.disconnect(),this.resizeObserver=null,this.clearWheelIdleSnap(),this.detachDragListeners(),this.swipeGesture.status==="active"&&this.swipeGesture.cancel(),this.swipePointerId!==null&&this.releaseSwipePointerCapture(this.swipePointerId),this.endSwipeTracking(),this.dragController.removeEventListener("change",this.onDragControllerChange),this.dragController.removeEventListener("drag",this.onDragControllerDrag),this.dragController.removeEventListener("drop",this.onDragControllerDrop),this.layoutScroll.removeEventListener("layout-scroll",this.onLayoutScrollInternal),this.dragController.dispose(),this.stopDragFrameLoop(),this.resizeState&&this.endResize(this.resizeState.pointerId)}scheduleRender(){this.renderPending||(this.renderPending=!0,queueMicrotask(()=>{this.renderPending=!1,this.render()}))}createGrid(e,n){return new CM({basis:Ie({x:Nr,y:Nr}),min:Ie({x:Ig,y:Ig}),viewport:Ie({x:e,y:n}),gap:Ie({x:ae,y:ae})})}syncScrollModel(){const e=Vu(this),i=An(this._layout).nodes.map(o=>o.width),s=`${e.width}x${e.height}:${i.join(",")}`;s===this.scrollModelKey&&this.layoutGrid||(this.scrollModelKey=s,this.layoutGrid=this.createGrid(e.width,e.height),this.layoutScroll.rebuild({grid:this.layoutGrid,nodeWidths:i.map(o=>$e({x:o})),snap:zm}))}emitScrollPositionChanged(e){this.dispatchEvent(new EN(e))}emitLayoutChanged(){this.dispatchEvent(new w0([...this._layout]))}stepFilmstrip(e){this.clearWheelIdleSnap(),this.syncScrollModel(),this.animateNextRender=!0,this.layoutScroll.step(e)}applyHorizontalWheel(e){this.syncScrollModel();const n=this.layoutGrid;if(!n)return;this.animateNextRender=!1;const i=n.toUnits(Ie({x:e}));this.layoutScroll.wheel($e({x:i.x??0}))}scheduleWheelIdleSnap(){this.clearWheelIdleSnap(),this.wheelIdleSnapTimer=setTimeout(()=>{this.wheelIdleSnapTimer=null,this.animateNextRender=!0,this.layoutScroll.snap()},_N)}clearWheelIdleSnap(){this.wheelIdleSnapTimer!==null&&(clearTimeout(this.wheelIdleSnapTimer),this.wheelIdleSnapTimer=null)}findViewspanContainingNode(e){const n=this.layoutScroll.viewspans,i=this._scrollPosition;let s=null,o=Number.POSITIVE_INFINITY;for(const a of n)if(e>=a.nodeRange[0]&&e<=a.nodeRange[1]){const c=Math.abs(a.anchor-i);c<o&&(o=c,s=a)}return s}findManagedArtifactFrame(e){if(!e)return null;const n=this.querySelectorAll("iframe.artifact-frame");for(const i of n)if(i.contentWindow===e)return i;return null}isTrustedArtifactFrameMessage(e,n){if(e.origin==="null")return!0;const i=this.getArtifactFrameOrigin(n);return i===null||e.origin===i}getArtifactFrameOrigin(e){const n=e.getAttribute("src")??e.src;if(!n)return null;try{return new URL(n,window.location.href).origin}catch{return null}}beginResize(e,n){const i=n.getAttribute("data-resize-handle");if(!i)return;const s=this._layout.find(a=>a.type==="card"&&we(a)===i);if(!s)return;const o=ed(typeof s.width=="number"?s.width:qe);this.resizeState={cardId:i,pointerId:e.pointerId,startClientX:e.clientX,startWidth:o,currentWidth:o},this.attachResizeListeners();try{this.setPointerCapture(e.pointerId)}catch{}e.preventDefault(),e.stopPropagation()}attachResizeListeners(){this.resizeListenersAttached||(window.addEventListener("pointermove",this.handleResizePointerMove),window.addEventListener("pointerup",this.handleResizePointerUp),window.addEventListener("pointercancel",this.handleResizePointerCancel),window.addEventListener("blur",this.handleResizeWindowBlur),this.addEventListener("keydown",this.handleResizeKeyDown),this.resizeListenersAttached=!0)}detachResizeListeners(){this.resizeListenersAttached&&(window.removeEventListener("pointermove",this.handleResizePointerMove),window.removeEventListener("pointerup",this.handleResizePointerUp),window.removeEventListener("pointercancel",this.handleResizePointerCancel),window.removeEventListener("blur",this.handleResizeWindowBlur),this.removeEventListener("keydown",this.handleResizeKeyDown),this.resizeListenersAttached=!1)}endResize(e){this.resizeState=null,this.detachResizeListeners();try{this.hasPointerCapture(e)&&this.releasePointerCapture(e)}catch{}}beginSwipeTracking(e){this.swipePointerId=e.pointerId,this.swipeStartX=e.clientX,this.swipeStartY=e.clientY,this.swipeLastX=e.clientX,this.swipeActive=!1,this.swipeShouldSuppressClick=!1,this.attachSwipeListeners()}attachSwipeListeners(){this.swipeListenersAttached||(window.addEventListener("pointermove",this.handleSwipePointerMove),window.addEventListener("pointerup",this.handleSwipePointerUp),window.addEventListener("pointercancel",this.handleSwipePointerCancel),this.addEventListener("pointermove",this.handleSwipePointerMove),this.addEventListener("pointerup",this.handleSwipePointerUp),this.addEventListener("pointercancel",this.handleSwipePointerCancel),window.addEventListener("blur",this.handleSwipeWindowBlur),this.addEventListener("click",this.handleSwipeClick,{capture:!0}),this.swipeListenersAttached=!0)}detachSwipeListeners(){this.swipeListenersAttached&&(window.removeEventListener("pointermove",this.handleSwipePointerMove),window.removeEventListener("pointerup",this.handleSwipePointerUp),window.removeEventListener("pointercancel",this.handleSwipePointerCancel),this.removeEventListener("pointermove",this.handleSwipePointerMove),this.removeEventListener("pointerup",this.handleSwipePointerUp),this.removeEventListener("pointercancel",this.handleSwipePointerCancel),window.removeEventListener("blur",this.handleSwipeWindowBlur),this.removeEventListener("click",this.handleSwipeClick,{capture:!0}),this.swipeListenersAttached=!1)}endSwipeTracking(){this.swipePointerId=null,this.swipeActive=!1,this.detachSwipeListeners()}releaseSwipePointerCapture(e){try{this.hasPointerCapture(e)&&this.releasePointerCapture(e)}catch{}}releaseActiveDragPointerCapture(){this.activeDragPointerId!==null&&this.releasePointerCaptureForEvent(this.activeDragPointerId)}releasePointerCaptureForEvent(e){try{this.hasPointerCapture(e)&&this.releasePointerCapture(e)}catch{}}attachDragListeners(){this.dragListenersAttached||(window.addEventListener("pointermove",this.handleWindowPointerMove),window.addEventListener("pointerup",this.handleWindowPointerUp),window.addEventListener("pointercancel",this.handleWindowPointerCancel),this.addEventListener("pointermove",this.handleWindowPointerMove),this.addEventListener("pointerup",this.handleWindowPointerUp),this.addEventListener("pointercancel",this.handleWindowPointerCancel),window.addEventListener("blur",this.handleWindowBlur),this.dragListenersAttached=!0)}detachDragListeners(){this.dragListenersAttached&&(window.removeEventListener("pointermove",this.handleWindowPointerMove),window.removeEventListener("pointerup",this.handleWindowPointerUp),window.removeEventListener("pointercancel",this.handleWindowPointerCancel),this.removeEventListener("pointermove",this.handleWindowPointerMove),this.removeEventListener("pointerup",this.handleWindowPointerUp),this.removeEventListener("pointercancel",this.handleWindowPointerCancel),window.removeEventListener("blur",this.handleWindowBlur),this.dragListenersAttached=!1,this.activeDragPointerId=null)}getVisibleLayout(){return this.dragController.status!=="active"||!this.dragState?this.applyResizeOverride(this._layout):Rm(this.dragState.projectedLayout)}applyResizeOverride(e){const n=this.resizeState;if(!n)return e;const i=e.findIndex(a=>a.type==="card"&&we(a)===n.cardId);if(i===-1)return e;const s=e[i];if(!s||s.type!=="card"||s.width===n.currentWidth)return e;const o=[...e];return o[i]={...s,width:n.currentWidth},o}getGridSlotStyle(e){return`grid-column: ${e.col} / span ${e.width}; grid-row: ${e.row} / span ${e.height};`}findContainingBlock(e){let n=e.parentElement;for(;n;){const i=getComputedStyle(n);if(i.transform!=="none"||i.perspective!=="none"||i.filter!=="none")return n;const s=i.willChange;if(s.includes("transform")||s.includes("perspective")||s.includes("filter"))return n;const o=i.contain;if(o.includes("layout")||o.includes("paint")||o.includes("strict"))return n;n=n.parentElement}return document.documentElement}getDraggedSlotStyle(e){const n=this.currentDragPreviewSize??{width:e.size.x??0,height:e.size.y??0};return["position: fixed;",`width: ${n.width}px;`,`height: ${n.height}px;`,"pointer-events: none;","z-index: 10;"].join(" ")}writeDraggedSlotPosition(e,n){(!this.draggedSlotContainingBlock||!this.draggedSlotContainingBlock.isConnected||!this.draggedSlotContainingBlock.contains(e))&&(this.draggedSlotContainingBlock=this.findContainingBlock(e));const i=this.draggedSlotContainingBlock.getBoundingClientRect(),s=n.pointer.x??0,o=n.pointer.y??0,a=n.grabOffset.x??0,c=n.grabOffset.y??0,u=this.currentDragPreviewSize??{width:n.size.x??0,height:n.size.y??0},h=n.size.x??0,f=n.size.y??0,y=h>0?a*(u.width/h):a,m=f>0?c*(u.height/f):c;e.style.left=`${s-y-i.left}px`,e.style.top=`${o-m-i.top}px`,e.style.width=`${u.width}px`,e.style.height=`${u.height}px`}renderSlot(e,n){var o,a;if(e.kind==="placeholder")return e.placement?D`
|
|
303
|
-
<div
|
|
304
|
-
class="card-slot card-placeholder"
|
|
305
|
-
data-layout-placeholder-for=${(n==null?void 0:n.nodeId)??""}
|
|
306
|
-
data-layout-placeholder-ghost="false"
|
|
307
|
-
data-layout-source-stack=${e.sourceStackId??""}
|
|
308
|
-
style=${this.getGridSlotStyle(e.placement)}
|
|
309
|
-
></div>
|
|
310
|
-
`:null;const i=e.card;if(!i)return null;const s=e.isDragged&&n?this.getDraggedSlotStyle(n):e.placement?this.getGridSlotStyle(e.placement):"";return D`
|
|
311
|
-
<div
|
|
312
|
-
class="card-slot"
|
|
313
|
-
data-layout-card-id=${we(i)}
|
|
314
|
-
data-layout-drag-source=${String(e.isDragged)}
|
|
315
|
-
layout-cols=${String(((o=e.placement)==null?void 0:o.width)??"")}
|
|
316
|
-
layout-rows=${String(((a=e.placement)==null?void 0:a.height)??"")}
|
|
317
|
-
style=${s}
|
|
318
|
-
>
|
|
319
|
-
<div class="card-content-mount" data-mount-for=${we(i)}></div>
|
|
320
|
-
${e.isTopLevelCard&&!e.isDragged?D`<div
|
|
321
|
-
class="resize-handle"
|
|
322
|
-
data-resize-handle=${we(i)}
|
|
323
|
-
data-test-resize-handle=${we(i)}
|
|
324
|
-
></div>`:null}
|
|
325
|
-
</div>
|
|
326
|
-
`}renderNode(e,n){return D`
|
|
327
|
-
<div
|
|
328
|
-
class=${e.kind==="ghost"?"drag-source-node":"node"}
|
|
329
|
-
layout-node=${String(e.layoutIndex??"")}
|
|
330
|
-
data-layout-node-id=${e.nodeId}
|
|
331
|
-
data-layout-placeholder=${String(e.kind==="visible"&&e.isPlaceholder)}
|
|
332
|
-
layout-node-cols=${String(e.widthUnits)}
|
|
333
|
-
?data-foreground=${e.kind==="visible"&&e.isForeground}
|
|
334
|
-
style=${e.kind==="visible"?`width: ${e.widthPx}px; --card-width-px: ${e.widthPx};`:""}
|
|
335
|
-
>
|
|
336
|
-
<div class="node-inner" style=${`grid-template-columns: repeat(${e.widthUnits}, var(--layout-unit-x));`}>
|
|
337
|
-
${$m(e.slots,i=>i.key,i=>this.renderSlot(i,n))}
|
|
338
|
-
</div>
|
|
339
|
-
</div>
|
|
340
|
-
`}render(){var Y;const e=Vu(this),n=this.createGrid(e.width,e.height);this.layoutGrid=n;const i=this.getVisibleLayout(),s=this.dragController.status==="active",o=An(i),a=o.nodes.map(j=>j.width),c=`${e.width}x${e.height}:${a.join(",")}`;!s&&c!==this.scrollModelKey&&(this.scrollModelKey=c,this.layoutScroll.rebuild({grid:n,nodeWidths:a.map(j=>$e({x:j})),snap:zm}),this._scrollPosition=this.layoutScroll.scroll.x??this._scrollPosition);const u=TN(this._layout),h=n.unit.x??Nr,f=n.unit.y??Nr,y=s?this.dragTrackOffsetXPx:0,m=(this.layoutScroll.translate.x??0)+y,E=Mm(o.nodes.length,n,e.height),x=this.animateNextRender&&!s,I=[`transform: translate(${m}px, ${E}px);`,`transition-duration: ${x?wT:0}ms;`,`pointer-events: ${s?"none":"auto"};`].join(" ");this.animateNextRender=!0,this.style.setProperty("--layout-unit-x",`${h}px`),this.style.setProperty("--layout-unit-y",`${f}px`),this.style.setProperty("--layout-gap",`${ae}px`);const P=this.dragState,R=new Set;{let j=m;for(let ce=0;ce<o.nodes.length;ce+=1){const At=n.toPixels($e({x:o.nodes[ce].width})).x??0,hn=j+At;j>=-1&&hn<=e.width+1&&R.add(ce),j=hn+ae}}const B=j=>R.has(j),N=bN({baseLayout:this._layout,visibleLayout:i,resolved:o,cardsByID:u,grid:n,dragState:this.dragState,isForeground:B}),F=Lm(this.dragState);if(F?this.setAttribute("data-test-drop-intent",F):this.removeAttribute("data-test-drop-intent"),this.dragState){let j=null;for(const ce of o.nodes){for(const At of ce.cards)if(At.artifactID===this.dragState.nodeId){j={width:n.toPixels($e({x:At.width})).x??0,height:n.toPixels($e({y:At.height})).y??0};break}if(j)break}this.currentDragPreviewSize=j??{width:this.dragState.size.x??0,height:this.dragState.size.y??0}}else this.currentDragPreviewSize=null;Be(D`
|
|
341
|
-
<div class="track" style=${I}>
|
|
342
|
-
${$m(N,j=>j.key,j=>this.renderNode(j,P))}
|
|
343
|
-
</div>
|
|
344
|
-
`,this),this.syncCardElements(u,P?((Y=u.get(P.nodeId))==null?void 0:Y.artifactID)??null:null),this.syncDraggedSlotElement(P)}syncCardElements(e,n){var o;const i=new Map;for(const a of this.querySelectorAll(".card-content-mount[data-mount-for]")){const c=a.getAttribute("data-mount-for");c&&i.set(c,a)}const s=new Set;for(const a of e.values()){const c=this._cards.get(a.artifactID);if(!c)continue;s.add(a.artifactID);const u=i.get(we(a));if(!u){c.removeAttribute("data-dragging");continue}const h=(o=u.parentElement)==null?void 0:o.getAttribute("data-layout-card-id");console.assert(h===we(a),`layout-view: mount mismatch for ${we(a)}`),c.parentElement!==u&&u.appendChild(c),console.assert(u.children.length<=1,`layout-view: multiple children for ${we(a)}`),c.toggleAttribute("data-dragging",a.artifactID===n)}for(const[a,c]of this._cards)s.has(a)||c.removeAttribute("data-dragging")}ensureDragFrameLoop(){this.dragFrame!==0||this.dragController.status==="idle"||(this.lastDragFrameTime=performance.now(),this.dragFrame=requestAnimationFrame(this.runDragFrame))}stopDragFrameLoop(){this.dragFrame!==0&&(cancelAnimationFrame(this.dragFrame),this.dragFrame=0,this.scrollVelocityPxPerSec=0)}syncDragTargetForLatestPointer(){if(this.dragController.status==="idle")return;const e=this.getBoundingClientRect();if(this.dragController.status==="active"){const i=this.clampPointerToViewport(this.lastPointerX,this.lastPointerY,e);this.syncDragTarget(i.x,i.y,e);return}if(this.syncDragTarget(this.lastPointerX,this.lastPointerY,e),this.dragController.status==="pending")return;const n=this.clampPointerToViewport(this.lastPointerX,this.lastPointerY,e);(n.x!==this.lastPointerX||n.y!==this.lastPointerY)&&this.syncDragTarget(n.x,n.y,e)}syncDragTarget(e,n,i=this.getBoundingClientRect()){if(this.dragController.status==="idle")return;const s=this.getVisibleLayout(),o=this.dragController.status==="active"?this.dragTrackOffsetXPx:0,a=this.measureLayoutGeometry(s,o);this.dragController.update({pointer:Ie({x:e,y:n}),viewport:{left:i.left,top:i.top,width:i.width,height:i.height},geometry:a,effectiveVelocity:Math.max(this.pointerVelocityPxPerSec,this.scrollVelocityPxPerSec)})}resetMotionTracking(e,n){this.pointerVelocityPxPerSec=0,this.scrollVelocityPxPerSec=0,this.motionSampleTime=performance.now(),this.motionSampleX=e,this.motionSampleY=n}clearMotionTracking(){this.pointerVelocityPxPerSec=0,this.scrollVelocityPxPerSec=0,this.motionSampleTime=0}updatePointerVelocity(e,n){this.samplePointerVelocityAt(performance.now(),e,n)}samplePointerVelocityAt(e,n,i){if(this.motionSampleTime===0){this.motionSampleTime=e,this.motionSampleX=n,this.motionSampleY=i,this.pointerVelocityPxPerSec=0;return}const s=e-this.motionSampleTime;if(s<100)return;const o=n-this.motionSampleX;this.pointerVelocityPxPerSec=Math.abs(o)/s*Dm,this.motionSampleTime=e,this.motionSampleX=n,this.motionSampleY=i}clampPointerToViewport(e,n,i){return{x:Math.max(i.left,Math.min(i.left+i.width,e)),y:Math.max(i.top,Math.min(i.top+i.height,n))}}getDragEdgeScrollDeltaPixels(e,n,i){var u;const s=n.left+Xa,o=n.left+n.width-Xa,a=((u=this.layoutGrid)==null?void 0:u.unit.x)??Nr,c=_T*a;if(e<s){const h=Math.max(0,Math.min(1,(s-e)/Xa));return-(c*h**Cg)*i}if(e>o){const h=Math.max(0,Math.min(1,(e-o)/Xa));return c*h**Cg*i}return 0}measureLayoutGeometry(e,n=0){const i=this.layoutGrid;if(!i)return[];const s=An(e),o=new Map(s.nodes.map(E=>[E.id,E.width])),a=i.toPixels($e({y:ft})).y??fo,c=Vu(this),u=(this.layoutScroll.translate.x??0)+n,h=Mm(s.nodes.length,i,c.height),f=c.offsetY+h,y=[];let m=u;for(const E of e){const x=Ni(E),I=o.get(x)??qe,P=i.toPixels($e({x:I})).x??Jn,R={left:m,top:f,width:P,height:a};y.push({id:x,rect:R}),m+=P+ae}return y}resetDragPreviewState(){this.dragTrackOffsetXPx=0,this.previousProjectedLayoutForOffset=null,this.lastProjectedDragLayoutSignature="",this.lastDragDropIntent=null,this.lastActivePlaceholderId=null,this.draggedSlotElement=null,this.draggedSlotContainingBlock=null,this.currentDragPreviewSize=null}getCachedDraggedSlotElement(e){var n;return(n=this.draggedSlotElement)!=null&&n.isConnected&&this.draggedSlotElement.getAttribute("data-layout-card-id")===e&&this.draggedSlotElement.getAttribute("data-layout-drag-source")==="true"?this.draggedSlotElement:(this.draggedSlotElement=this.querySelector(`.card-slot[data-layout-card-id="${Om(e)}"][data-layout-drag-source="true"]`),this.draggedSlotElement)}syncDraggedSlotElement(e){if(!e||this.dragController.status!=="active"){this.draggedSlotElement=null;return}const n=this.getCachedDraggedSlotElement(e.nodeId);n&&this.writeDraggedSlotPosition(n,e)}shouldApplyTrackOffset(e,n){if(n)return!0;for(const i of e){if(i.type!=="stack")continue;if(i.children.some(o=>o.type==="drop-target")&&n!==i.id)return!0}return!1}computeDragTrackOffset(e,n,i,s,o,a){if(!e)return a;const c=s?o??this.getStableAnchorCardId(e,n,i):this.getStableAnchorNodeId(e,n,i);if(!c)return a;const u=s?Um(e,c,this.layoutGrid):Fm(e,c,this.layoutGrid),h=s?Um(n,c,this.layoutGrid):Fm(n,c,this.layoutGrid);return u===null||h===null?a:a+(u-h)}getStableAnchorCardId(e,n,i){const s=Nm(e),o=new Set(Nm(n));for(const a of s)if(a!==i&&o.has(a))return a;return null}getStableAnchorNodeId(e,n,i){const s=new Set(n.map(Ni));for(const o of e){const a=Ni(o);if(a!==i&&s.has(a))return a}return null}getStackChildAnchorCardId(e,n){const i=this._layout.find(o=>o.type==="stack"&&o.id===e);if(!i||i.type!=="stack")return null;const s=i.children.find(o=>o.type==="card"&&we(o)!==n);return s?we(s):null}}function TN(r){const t=new Map;for(const e of r){if(e.type==="card"){t.set(we(e),e);continue}for(const n of e.children)if(n.type==="card")t.set(we(n),n);else for(const i of n.children)t.set(we(i),i)}return t}function $N(r){for(const t of r)if(t.type==="drop-target"||t.type==="stack"&&t.children.some(e=>e.type==="drop-target"))return t.id;return null}function IN(r,t){const e=r.findIndex(n=>n.type==="card"&&we(n)===t);if(e!==-1)return{topLevelIndex:e};for(let n=0;n<r.length;n+=1){const i=r[n];if(!(!i||i.type!=="stack")&&i.children.some(s=>s.type==="card"&&we(s)===t))return{topLevelIndex:n,sourceStackId:i.id}}return null}function Nm(r){const t=[];for(const e of r){if(e.type==="card"){t.push(we(e));continue}if(e.type==="stack"){const n=e.children.find(i=>i.type==="card");n&&t.push(we(n))}}return t}function Um(r,t,e){if(!e)return null;const n=An(r),i=new Map(n.nodes.map(o=>[o.id,o.width]));let s=0;for(const o of r){if(o.type==="card"&&we(o)===t||o.type==="stack"&&o.children.some(u=>u.type==="card"&&we(u)===t))return s;const a=i.get(Ni(o))??qe,c=e.toPixels($e({x:a})).x??Jn;s+=c+ae}return null}function Fm(r,t,e){if(!e)return null;const n=An(r),i=new Map(n.nodes.map(o=>[o.id,o.width]));let s=0;for(const o of r){if(Ni(o)===t)return s;const a=i.get(Ni(o))??qe,c=e.toPixels($e({x:a})).x??Jn;s+=c+ae}return null}customElements.get("layout-view")||customElements.define("layout-view",AN);class CN extends HTMLElement{constructor(){super(...arguments);g(this,"screenManager",hr.resolve("ScreenManager"));g(this,"boundModel",null);g(this,"cardEls",new Map);g(this,"handleActiveScreenChanged",()=>{this.rebindModel(),this.render()});g(this,"handleModelChange",()=>{this.render()});g(this,"handleCloseArtifact",e=>{e instanceof p0&&this.screenManager.activeScreen&&this.screenManager.activeScreen.removeArtifact(e.artifactID)});g(this,"handleScrollPositionChanged",e=>{const n=e;typeof n.scrollPosition=="number"&&Number.isFinite(n.scrollPosition)&&this.screenManager.activeScreen&&this.screenManager.activeScreen.setScrollPosition(n.scrollPosition)});g(this,"handleLayoutChanged",e=>{e instanceof w0&&this.screenManager.activeScreen&&this.screenManager.activeScreen.setLayout(e.layout)});g(this,"handleGlobalArrowKey",e=>{var s;if(e.key!=="ArrowLeft"&&e.key!=="ArrowRight"||e.metaKey||e.ctrlKey||e.altKey||e.shiftKey||this.isTextEditingTarget(e.target))return;const n=e.target;if(n instanceof Node&&((s=this.querySelector("layout-view"))!=null&&s.contains(n)))return;const i=this.querySelector("layout-view");i&&(e.preventDefault(),i.stepFilmstrip(e.key==="ArrowRight"?1:-1))});g(this,"handleServerEvent",e=>{const n=e.event;if(n.type!=="artifact-focus"||!this.boundModel||n.screenID!==this.boundModel.id)return;const i=this.querySelector("layout-view");i&&i.focusArtifact(n.artifactID)})}connectedCallback(){this.screenManager.addEventListener("active-screen-changed",this.handleActiveScreenChanged),window.addEventListener("keydown",this.handleGlobalArrowKey,{capture:!0}),this.rebindModel(),this.render()}disconnectedCallback(){this.screenManager.removeEventListener("active-screen-changed",this.handleActiveScreenChanged),window.removeEventListener("keydown",this.handleGlobalArrowKey,{capture:!0}),this.unbindModel(),this.disposeCardElements()}rebindModel(){const e=this.screenManager.activeScreen;this.boundModel!==e&&(this.unbindModel(),this.boundModel=e,e&&(e.addEventListener("change",this.handleModelChange),e.server.addEventListener("server-event",this.handleServerEvent)))}unbindModel(){this.boundModel&&(this.boundModel.removeEventListener("change",this.handleModelChange),this.boundModel.server.removeEventListener("server-event",this.handleServerEvent),this.boundModel=null)}isTextEditingTarget(e){var i;if(!(e instanceof Element))return!1;const n=e.closest("input, textarea, select, [contenteditable], [role='textbox'], [role='searchbox'], [role='combobox'], [role='spinbutton'], [role='slider']");return n?n.hasAttribute("contenteditable")?((i=n.getAttribute("contenteditable"))==null?void 0:i.toLowerCase())!=="false":!0:!1}buildCards(e){if(!e)return this.disposeCardElements(),new Map;const n=new Map;for(const i of e.artifacts.values()){let s=this.cardEls.get(i.id);s||(s=document.createElement("artifact-view"),this.cardEls.set(i.id,s)),s.artifact=i,s.screen=e,s.viewURL=e.server.getViewURL(i),s.contentURL=e.server.getContentURL(i),n.set(i.id,s)}for(const[i,s]of this.cardEls)n.has(i)||(s.remove(),this.cardEls.delete(i));return n}disposeCardElements(){for(const e of this.cardEls.values())e.remove();this.cardEls.clear()}render(){const e=this.screenManager.activeScreen,n=(e==null?void 0:e.layout)??[],i=this.buildCards(e);if(n.length===0){Be(D``,this);return}Be(D`
|
|
345
|
-
<layout-view
|
|
346
|
-
.layout=${n}
|
|
347
|
-
.cards=${i}
|
|
348
|
-
.scrollPosition=${(e==null?void 0:e.scrollPosition)??0}
|
|
349
|
-
@scroll=${this.handleScrollPositionChanged}
|
|
350
|
-
@layout-change=${this.handleLayoutChanged}
|
|
351
|
-
@close-artifact=${this.handleCloseArtifact}
|
|
352
|
-
></layout-view>
|
|
353
|
-
`,this)}}customElements.define("screen-view",CN);function Jl(r){return typeof r=="object"&&r!==null}const ju=new WeakMap,Hm=Object.prototype.hasOwnProperty,RN=(()=>{const r=new Set;let t=HTMLElement.prototype;for(;t;){for(const e of Object.getOwnPropertyNames(t))r.add(e);if(t===Node.prototype)break;t=Object.getPrototypeOf(t)}return r})();function PN(r,t){if(Jl(r))return t===null?void 0:r.parse(t);if(r===Boolean)return t!==null;if(t!==null)return r===Number?Number(t):t}function LN(r,t){return Jl(r)?t==null?null:r.serialize(t):r===Boolean?t?"":null:t==null?null:String(t)}var ca,nd,jn,mt,nr,ns,Gn,is,xe,Ii,S0,_0,k0,x0,Il;const xn=class xn extends HTMLElement{constructor(){var i;super();w(this,xe);w(this,jn,new Map);w(this,mt,new Map);w(this,nr,new Map);w(this,ns,!1);w(this,Gn,!1);w(this,is,!1);const e=p(i=xn,ca,nd).call(i,this.constructor),n=this;for(const s of e.properties)Hm.call(n,s)&&(l(this,nr).set(s,n[s]),delete n[s])}static get observedAttributes(){var e;return p(e=xn,ca,nd).call(e,this).observedAttributes}connected(){}disconnected(){}changed(e){}connectedCallback(){if(p(this,xe,x0).call(this),!l(this,Gn))for(const e of p(this,xe,Ii).call(this).properties)l(this,mt).has(e)||l(this,mt).set(e,void 0);this.dispatchEvent(new Event("reactive:connect")),this.connected(),p(this,xe,Il).call(this)}disconnectedCallback(){this.dispatchEvent(new Event("reactive:disconnect")),this.disconnected()}attributeChangedCallback(e,n,i){if(n===i)return;const s=p(this,xe,Ii).call(this).byAttr.get(e);s&&(l(this,nr).has(s.property)||(this[s.property]=PN(s.type,i)))}};ca=new WeakSet,nd=function(e){const n=ju.get(e);if(n)return n;const i=[...e.properties??[]],s=e.attributes??{},o=new Map,a=new Map;for(const u of i)if(RN.has(u))throw new Error(`Reactive property "${u}" collides with a built-in DOM property. Rename it to avoid shadowing the platform API.`);for(const[u,h]of Object.entries(s)){if(u.includes("-")&&h.property===void 0)throw new Error(`Attribute "${u}" must declare a "property" name because kebab-case cannot be a property.`);const f=h.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.`);if(Jl(h.type)){if(typeof h.type.parse!="function")throw new Error(`Attribute "${u}" custom coercer is missing a \`parse\` function.`);if(typeof h.type.serialize!="function")throw new Error(`Attribute "${u}" custom coercer is missing a \`serialize\` function.`)}const y={attribute:u,property:f,type:h.type};o.set(u,y),a.set(f,y)}for(const u of i){const h=Object.getOwnPropertyDescriptor(e.prototype,u);if((h==null?void 0:h.get)!==void 0||(h==null?void 0:h.set)!==void 0)throw new Error(`Observed property "${u}" cannot define a custom getter/setter. Use changed() for side effects instead.`);h===void 0&&Object.defineProperty(e.prototype,u,{configurable:!0,enumerable:!0,get(){return l(this,jn).get(u)},set(f){p(this,xe,S0).call(this,u,f)}})}const c={properties:i,observedAttributes:Object.keys(s),byAttr:o,byProp:a};return ju.set(e,c),c},jn=new WeakMap,mt=new WeakMap,nr=new WeakMap,ns=new WeakMap,Gn=new WeakMap,is=new WeakMap,xe=new WeakSet,Ii=function(){return ju.get(this.constructor)},S0=function(e,n){if(!l(this,is)&&l(this,nr).has(e))return;const i=l(this,jn).get(e);p(this,xe,_0).call(this,e,i,n)||(l(this,mt).has(e)||l(this,mt).set(e,i),l(this,jn).set(e,n),l(this,nr).delete(e),p(this,xe,k0).call(this,e,n),this.isConnected&&p(this,xe,Il).call(this))},_0=function(e,n,i){if(Object.is(n,i))return!0;const s=p(this,xe,Ii).call(this).byProp.get(e);if(!s||!Jl(s.type))return!1;const o=n==null,a=i==null;if(o||a)return o&&a;try{return s.type.serialize(n)===s.type.serialize(i)}catch{return!1}},k0=function(e,n){const i=p(this,xe,Ii).call(this).byProp.get(e);if(!i)return;const{attribute:s,type:o}=i;if(o===Boolean){const c=this.hasAttribute(s);n&&!c?this.setAttribute(s,""):!n&&c&&this.removeAttribute(s);return}const a=LN(o,n);if(a===null){this.hasAttribute(s)&&this.removeAttribute(s);return}this.getAttribute(s)!==a&&this.setAttribute(s,a)},x0=function(){const e=this,n=p(this,xe,Ii).call(this);for(const i of n.properties){if(!Hm.call(e,i))continue;const s=e[i];delete e[i],!(l(this,nr).has(i)||l(this,jn).has(i))&&(e[i]=s)}b(this,is,!0);try{for(const[i,s]of l(this,nr))e[i]=s;l(this,nr).clear()}finally{b(this,is,!1)}},Il=function(){l(this,ns)||!this.isConnected||l(this,Gn)&&l(this,mt).size===0||(b(this,ns,!0),queueMicrotask(()=>{if(b(this,ns,!1),!this.isConnected||l(this,Gn)&&l(this,mt).size===0)return;const e=new Map(l(this,mt));l(this,mt).clear(),b(this,Gn,!0);try{this.changed(e)}catch(n){console.error(n)}this.isConnected&&l(this,mt).size>0&&p(this,xe,Il).call(this)}))},w(xn,ca),g(xn,"properties"),g(xn,"attributes");let ys=xn;var fe,Yr,Kr,ss,os,Tr,ua,Te,as,ir,Z,E0,ha,da,pa,fa,id,sd,od,A0,T0,$0,I0,lc,cc,uc,hc,ad,C0,Cl,dc,Rl,pc,R0,P0,L0,D0,z0,dt;class DN extends ys{constructor(){super(...arguments);w(this,Z);w(this,fe,hr.resolve("ScreenManager"));w(this,Yr,hr.resolve("ServerManager"));w(this,Kr,null);w(this,ss,new DisposableStack);w(this,os,xl());w(this,Tr,xl());w(this,ua,xl());w(this,Te,{kind:"none"});w(this,as,!1);w(this,ir,[]);w(this,ha,()=>{p(this,Z,id).call(this),b(this,Te,{kind:"none"}),l(this,dt).call(this)});w(this,da,()=>{l(this,dt).call(this)});w(this,pa,()=>{l(this,dt).call(this)});w(this,fa,()=>{l(this,dt).call(this)});w(this,lc,()=>{var i,s;if(l(this,Te).kind==="picker"){p(this,Z,Rl).call(this);return}b(this,ir,p(this,Z,C0).call(this));const e=((i=l(this,fe).activeScreen)==null?void 0:i.id)??null,n=e&&l(this,ir).some(o=>o.screenID===e)?e:((s=l(this,ir)[0])==null?void 0:s.screenID)??null;b(this,Te,{kind:"picker",filter:"",highlightedID:n}),l(this,dt).call(this),queueMicrotask(()=>{var o;(o=l(this,ua).value)==null||o.focus()})});w(this,cc,e=>{var u;const n=l(this,Te);if(n.kind!=="picker")return;const i=e.target;if(!(i instanceof HTMLInputElement))return;const s=i.value,o=p(this,Z,Cl).call(this,l(this,ir),s),c=n.highlightedID!==null&&o.some(h=>h.screenID===n.highlightedID)?n.highlightedID:((u=o[0])==null?void 0:u.screenID)??null;b(this,Te,{kind:"picker",filter:s,highlightedID:c}),l(this,dt).call(this)});w(this,uc,e=>{var s;const n=l(this,Te);if(n.kind!=="picker")return;if(e.key==="Escape"){e.preventDefault(),p(this,Z,Rl).call(this),(s=l(this,os).value)==null||s.focus();return}const i=p(this,Z,Cl).call(this,l(this,ir),n.filter);if(e.key==="ArrowDown"||e.key==="ArrowUp"){if(e.preventDefault(),i.length===0)return;const o=i.findIndex(u=>u.screenID===n.highlightedID),a=e.key==="ArrowDown"?1:-1,c=o<0?0:Math.max(0,Math.min(i.length-1,o+a));b(this,Te,{kind:"picker",filter:n.filter,highlightedID:i[c].screenID}),l(this,dt).call(this);return}if(e.key==="Enter"){e.preventDefault();const o=i.find(a=>a.screenID===n.highlightedID);o&&p(this,Z,ad).call(this,o)}});w(this,hc,e=>{p(this,Z,ad).call(this,e)});w(this,dc,e=>{l(this,Te).kind==="picker"&&e.target===l(this,Tr).value&&(b(this,Te,{kind:"none"}),l(this,dt).call(this))});w(this,pc,async()=>{if(l(this,as))return;const e=p(this,Z,R0).call(this);if(e){b(this,as,!0);try{const n=await e.createScreen(zN(new Date));l(this,fe).addTab(e.url,n.id),l(this,fe).setActive(e.url,n.id)}catch{}finally{b(this,as,!1)}}});w(this,dt,()=>{const e=p(this,Z,$0).call(this);Be(D`
|
|
354
|
-
${p(this,Z,P0).call(this)}
|
|
355
|
-
<div class="pills" role="group" aria-label="Open tabs">
|
|
356
|
-
${e.map(n=>p(this,Z,L0).call(this,n))}
|
|
357
|
-
</div>
|
|
358
|
-
${p(this,Z,D0).call(this)}
|
|
359
|
-
`,this),l(this,Tr).value&&(l(this,Tr).value.anchor=l(this,os).value??null)})}connected(){l(this,fe).addEventListener("active-screen-changed",l(this,ha)),l(this,fe).addEventListener("tabs-changed",l(this,da)),l(this,Yr).addEventListener("screens-changed",l(this,pa)),p(this,Z,id).call(this),l(this,dt).call(this),p(this,Z,E0).call(this),l(this,ss).defer(()=>{l(this,fe).removeEventListener("active-screen-changed",l(this,ha)),l(this,fe).removeEventListener("tabs-changed",l(this,da)),l(this,Yr).removeEventListener("screens-changed",l(this,pa)),p(this,Z,sd).call(this)})}disconnected(){l(this,ss).dispose(),b(this,ss,new DisposableStack)}}fe=new WeakMap,Yr=new WeakMap,Kr=new WeakMap,ss=new WeakMap,os=new WeakMap,Tr=new WeakMap,ua=new WeakMap,Te=new WeakMap,as=new WeakMap,ir=new WeakMap,Z=new WeakSet,E0=async function(){const e=await uy(this);this.setAttribute("tone",e)},ha=new WeakMap,da=new WeakMap,pa=new WeakMap,fa=new WeakMap,id=function(){var n;const e=l(this,fe).activeScreen;l(this,Kr)!==e&&(p(this,Z,sd).call(this),b(this,Kr,e),(n=l(this,Kr))==null||n.addEventListener("change",l(this,fa)))},sd=function(){var e;(e=l(this,Kr))==null||e.removeEventListener("change",l(this,fa)),b(this,Kr,null)},od=function(e,n){l(this,fe).setActive(e,n)},A0=function(e,n,i){i.stopPropagation();const s=l(this,fe).getTabs(e),o=p(this,Z,I0).call(this,s,n),a=l(this,fe).activeScreen,c=(a==null?void 0:a.id)===n&&a.server.url===e;l(this,fe).removeTab(e,n),c&&(o?l(this,fe).setActive(e,o):l(this,fe).clearActive())},T0=function(e,n,i){const s=l(this,fe).activeScreen;if((s==null?void 0:s.id)===n){s.rename(i.value);return}const o=l(this,Yr).servers.get(e),a=o==null?void 0:o.screens.get(n);!o||!a||o.client.screens.update({screenID:n,name:i.value}).catch(()=>{})},$0=function(){const e=l(this,fe).activeScreen,n=[];for(const i of l(this,Yr).servers.values())for(const s of l(this,fe).getTabs(i.url)){const o=i.screens.get(s);o&&n.push({serverURL:i.url,screenID:o.id,name:o.name,isActive:(e==null?void 0:e.id)===o.id&&e.server.url===i.url})}return n},I0=function(e,n){const i=e.indexOf(n);if(i<0)return null;const s=e.filter(a=>a!==n);if(s.length===0)return null;const o=Math.max(0,i-1);return s[o]??null},lc=new WeakMap,cc=new WeakMap,uc=new WeakMap,hc=new WeakMap,ad=function(e){l(this,fe).addTab(e.serverURL,e.screenID),l(this,fe).setActive(e.serverURL,e.screenID),p(this,Z,Rl).call(this)},C0=function(){return l(this,fe).screens.map(e=>({serverURL:e.server.url,screenID:e.screen.id,name:e.screen.name}))},Cl=function(e,n){const i=n.trim().toLowerCase();return i.length===0?e:e.filter(s=>s.name.toLowerCase().includes(i))},dc=new WeakMap,Rl=function(){l(this,Te).kind==="picker"&&(l(this,Tr).value&&(l(this,Tr).value.open=!1),b(this,Te,{kind:"none"}),l(this,dt).call(this))},pc=new WeakMap,R0=function(){for(const e of l(this,Yr).servers.values())return e;return null},P0=function(){return D`
|
|
360
|
-
<segmented-control variant="glass" role="group" aria-label="Screens">
|
|
361
|
-
<button
|
|
362
|
-
type="button"
|
|
363
|
-
?icon-only=${!0}
|
|
364
|
-
aria-label="Choose screen"
|
|
365
|
-
@click=${l(this,lc)}
|
|
366
|
-
${El(l(this,os))}
|
|
367
|
-
>
|
|
368
|
-
${nM({size:16,weight:"regular"})}
|
|
369
|
-
</button>
|
|
370
|
-
<button
|
|
371
|
-
type="button"
|
|
372
|
-
?icon-only=${!0}
|
|
373
|
-
aria-label="New screen"
|
|
374
|
-
@click=${l(this,pc)}
|
|
375
|
-
>
|
|
376
|
-
${iM({size:16,weight:"regular"})}
|
|
377
|
-
</button>
|
|
378
|
-
</segmented-control>
|
|
379
|
-
`},L0=function(e){return D`
|
|
380
|
-
<span class="tab" ?data-active=${e.isActive}>
|
|
381
|
-
<button
|
|
382
|
-
type="button"
|
|
383
|
-
variant="glass"
|
|
384
|
-
class="screen-name tab-body"
|
|
385
|
-
aria-pressed=${e.isActive?"true":"false"}
|
|
386
|
-
aria-current=${e.isActive?"page":le}
|
|
387
|
-
aria-label=${e.isActive?`Current tab: ${e.name}`:`Switch to ${e.name}`}
|
|
388
|
-
@mousedown=${n=>{n.button===0&&p(this,Z,od).call(this,e.serverURL,e.screenID)}}
|
|
389
|
-
@click=${()=>p(this,Z,od).call(this,e.serverURL,e.screenID)}
|
|
390
|
-
>
|
|
391
|
-
<span class="tab-leading">
|
|
392
|
-
${tM({weight:"bold"})}
|
|
393
|
-
</span>
|
|
394
|
-
<editable-text
|
|
395
|
-
class="tab-name"
|
|
396
|
-
.value=${e.name}
|
|
397
|
-
@rename=${n=>p(this,Z,T0).call(this,e.serverURL,e.screenID,n)}
|
|
398
|
-
></editable-text>
|
|
399
|
-
</button>
|
|
400
|
-
<button
|
|
401
|
-
type="button"
|
|
402
|
-
variant="ghost"
|
|
403
|
-
size="xs"
|
|
404
|
-
icon-only
|
|
405
|
-
class="tab-close"
|
|
406
|
-
aria-label=${`Close ${e.name}`}
|
|
407
|
-
@click=${n=>p(this,Z,A0).call(this,e.serverURL,e.screenID,n)}
|
|
408
|
-
>
|
|
409
|
-
${up({weight:"bold"})}
|
|
410
|
-
</button>
|
|
411
|
-
</span>
|
|
412
|
-
`},D0=function(){var o;const e=l(this,Te).kind==="picker"?l(this,Te).filter:"",n=l(this,Te).kind==="picker"?l(this,Te).highlightedID:null,i=((o=l(this,fe).activeScreen)==null?void 0:o.id)??null,s=p(this,Z,Cl).call(this,l(this,ir),e);return D`
|
|
413
|
-
<ui-popover
|
|
414
|
-
class="picker-popover"
|
|
415
|
-
material="glass-frosted"
|
|
416
|
-
?open=${l(this,Te).kind==="picker"}
|
|
417
|
-
@close=${l(this,dc)}
|
|
418
|
-
@keydown=${l(this,uc)}
|
|
419
|
-
${El(l(this,Tr))}
|
|
420
|
-
>
|
|
421
|
-
<div class="picker">
|
|
422
|
-
<input
|
|
423
|
-
type="text"
|
|
424
|
-
class="picker-filter"
|
|
425
|
-
placeholder="Filter screens"
|
|
426
|
-
aria-label="Filter screens"
|
|
427
|
-
.value=${e}
|
|
428
|
-
@input=${l(this,cc)}
|
|
429
|
-
${El(l(this,ua))}
|
|
430
|
-
/>
|
|
431
|
-
${s.length===0?D`<p class="picker-empty">
|
|
432
|
-
${l(this,ir).length===0?"No screens":"No matches"}
|
|
433
|
-
</p>`:p(this,Z,z0).call(this,s,n,i)}
|
|
434
|
-
</div>
|
|
435
|
-
</ui-popover>
|
|
436
|
-
`},z0=function(e,n,i){return D`
|
|
437
|
-
<ul class="picker-list" role="listbox">
|
|
438
|
-
<li class="picker-section-label" role="presentation">Recent</li>
|
|
439
|
-
${e.map(s=>{const o=s.screenID===i;return D`
|
|
440
|
-
<li
|
|
441
|
-
class="picker-row"
|
|
442
|
-
role="option"
|
|
443
|
-
aria-selected=${s.screenID===n}
|
|
444
|
-
aria-current=${o?"true":le}
|
|
445
|
-
?data-highlighted=${s.screenID===n}
|
|
446
|
-
?data-active=${o}
|
|
447
|
-
@click=${()=>l(this,hc).call(this,s)}
|
|
448
|
-
>
|
|
449
|
-
<span class="picker-name">${s.name}</span>
|
|
450
|
-
</li>
|
|
451
|
-
`})}
|
|
452
|
-
</ul>
|
|
453
|
-
`},dt=new WeakMap;customElements.define("screen-select",DN);function zN(r){const t=r.toLocaleDateString("en-US",{month:"long",day:"numeric",year:"numeric"}),e=12,n=r.getHours(),i=n%e===0?e:n%e,s=r.getMinutes().toString().padStart(2,"0"),o=n>=e?"pm":"am";return`${t} at ${i}:${s}${o}`}/*! @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:O0,setPrototypeOf:Zm,isFrozen:ON,getPrototypeOf:MN,getOwnPropertyDescriptor:NN}=Object;let{freeze:tt,seal:_t,create:Pl}=Object,{apply:ld,construct:cd}=typeof Reflect<"u"&&Reflect;tt||(tt=function(t){return t});_t||(_t=function(t){return t});ld||(ld=function(t,e){for(var n=arguments.length,i=new Array(n>2?n-2:0),s=2;s<n;s++)i[s-2]=arguments[s];return t.apply(e,i)});cd||(cd=function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),i=1;i<e;i++)n[i-1]=arguments[i];return new t(...n)});const sl=rt(Array.prototype.forEach),UN=rt(Array.prototype.lastIndexOf),Wm=rt(Array.prototype.pop),Fs=rt(Array.prototype.push),FN=rt(Array.prototype.splice),Ll=rt(String.prototype.toLowerCase),Gu=rt(String.prototype.toString),qu=rt(String.prototype.match),Hs=rt(String.prototype.replace),HN=rt(String.prototype.indexOf),ZN=rt(String.prototype.trim),ut=rt(Object.prototype.hasOwnProperty),Ye=rt(RegExp.prototype.test),Zs=WN(TypeError);function rt(r){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var e=arguments.length,n=new Array(e>1?e-1:0),i=1;i<e;i++)n[i-1]=arguments[i];return ld(r,t,n)}}function WN(r){return function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return cd(r,e)}}function G(r,t){let e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Ll;Zm&&Zm(r,null);let n=t.length;for(;n--;){let i=t[n];if(typeof i=="string"){const s=e(i);s!==i&&(ON(t)||(t[n]=s),i=s)}r[i]=!0}return r}function BN(r){for(let t=0;t<r.length;t++)ut(r,t)||(r[t]=null);return r}function Bt(r){const t=Pl(null);for(const[e,n]of O0(r))ut(r,e)&&(Array.isArray(n)?t[e]=BN(n):n&&typeof n=="object"&&n.constructor===Object?t[e]=Bt(n):t[e]=n);return t}function Ws(r,t){for(;r!==null;){const n=NN(r,t);if(n){if(n.get)return rt(n.get);if(typeof n.value=="function")return rt(n.value)}r=MN(r)}function e(){return null}return e}const Bm=tt(["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"]),Yu=tt(["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"]),Ku=tt(["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"]),VN=tt(["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"]),Ju=tt(["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"]),jN=tt(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Vm=tt(["#text"]),jm=tt(["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"]),Xu=tt(["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"]),Gm=tt(["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"]),ol=tt(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),GN=_t(/\{\{[\w\W]*|[\w\W]*\}\}/gm),qN=_t(/<%[\w\W]*|[\w\W]*%>/gm),YN=_t(/\$\{[\w\W]*/gm),KN=_t(/^data-[\-\w.\u00B7-\uFFFF]+$/),JN=_t(/^aria-[\-\w]+$/),M0=_t(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),XN=_t(/^(?:\w+script|data):/i),QN=_t(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),N0=_t(/^html$/i),e6=_t(/^[a-z][.\w]*(-[.\w]+)+$/i);var qm=Object.freeze({__proto__:null,ARIA_ATTR:JN,ATTR_WHITESPACE:QN,CUSTOM_ELEMENT:e6,DATA_ATTR:KN,DOCTYPE_NAME:N0,ERB_EXPR:qN,IS_ALLOWED_URI:M0,IS_SCRIPT_OR_DATA:XN,MUSTACHE_EXPR:GN,TMPLIT_EXPR:YN});const Bs={element:1,text:3,progressingInstruction:7,comment:8,document:9},t6=function(){return typeof window>"u"?null:window},r6=function(t,e){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let n=null;const i="data-tt-policy-suffix";e&&e.hasAttribute(i)&&(n=e.getAttribute(i));const s="dompurify"+(n?"#"+n:"");try{return t.createPolicy(s,{createHTML(o){return o},createScriptURL(o){return o}})}catch{return console.warn("TrustedTypes policy "+s+" could not be created."),null}},Ym=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function U0(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:t6();const t=U=>U0(U);if(t.version="3.3.3",t.removed=[],!r||!r.document||r.document.nodeType!==Bs.document||!r.Element)return t.isSupported=!1,t;let{document:e}=r;const n=e,i=n.currentScript,{DocumentFragment:s,HTMLTemplateElement:o,Node:a,Element:c,NodeFilter:u,NamedNodeMap:h=r.NamedNodeMap||r.MozNamedAttrMap,HTMLFormElement:f,DOMParser:y,trustedTypes:m}=r,E=c.prototype,x=Ws(E,"cloneNode"),I=Ws(E,"remove"),P=Ws(E,"nextSibling"),R=Ws(E,"childNodes"),B=Ws(E,"parentNode");if(typeof o=="function"){const U=e.createElement("template");U.content&&U.content.ownerDocument&&(e=U.content.ownerDocument)}let N,F="";const{implementation:Y,createNodeIterator:j,createDocumentFragment:ce,getElementsByTagName:At}=e,{importNode:hn}=n;let ze=Ym();t.isSupported=typeof O0=="function"&&typeof B=="function"&&Y&&Y.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:dn,ERB_EXPR:Ut,TMPLIT_EXPR:Dr,DATA_ATTR:Hc,ARIA_ATTR:za,IS_SCRIPT_OR_DATA:oS,ATTR_WHITESPACE:kp,CUSTOM_ELEMENT:aS}=qm;let{IS_ALLOWED_URI:xp}=qm,Re=null;const Ep=G({},[...Bm,...Yu,...Ku,...Ju,...Vm]);let Oe=null;const Ap=G({},[...jm,...Xu,...Gm,...ol]);let Se=Object.seal(Pl(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}})),Rs=null,Oa=null;const zr=Object.seal(Pl(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Tp=!0,Zc=!0,$p=!1,Ip=!0,li=!1,Ma=!0,pn=!1,Wc=!1,Bc=!1,ci=!1,Na=!1,Ua=!1,Cp=!0,Rp=!1;const lS="user-content-";let Vc=!0,Ps=!1,ui={},Ft=null;const jc=G({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let Pp=null;const Lp=G({},["audio","video","img","source","image","track"]);let Gc=null;const Dp=G({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Fa="http://www.w3.org/1998/Math/MathML",Ha="http://www.w3.org/2000/svg",dr="http://www.w3.org/1999/xhtml";let hi=dr,qc=!1,Yc=null;const cS=G({},[Fa,Ha,dr],Gu);let Za=G({},["mi","mo","mn","ms","mtext"]),Wa=G({},["annotation-xml"]);const uS=G({},["title","style","font","a","script"]);let Ls=null;const hS=["application/xhtml+xml","text/html"],dS="text/html";let Ae=null,di=null;const pS=e.createElement("form"),zp=function(S){return S instanceof RegExp||S instanceof Function},Kc=function(){let S=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(di&&di===S)){if((!S||typeof S!="object")&&(S={}),S=Bt(S),Ls=hS.indexOf(S.PARSER_MEDIA_TYPE)===-1?dS:S.PARSER_MEDIA_TYPE,Ae=Ls==="application/xhtml+xml"?Gu:Ll,Re=ut(S,"ALLOWED_TAGS")?G({},S.ALLOWED_TAGS,Ae):Ep,Oe=ut(S,"ALLOWED_ATTR")?G({},S.ALLOWED_ATTR,Ae):Ap,Yc=ut(S,"ALLOWED_NAMESPACES")?G({},S.ALLOWED_NAMESPACES,Gu):cS,Gc=ut(S,"ADD_URI_SAFE_ATTR")?G(Bt(Dp),S.ADD_URI_SAFE_ATTR,Ae):Dp,Pp=ut(S,"ADD_DATA_URI_TAGS")?G(Bt(Lp),S.ADD_DATA_URI_TAGS,Ae):Lp,Ft=ut(S,"FORBID_CONTENTS")?G({},S.FORBID_CONTENTS,Ae):jc,Rs=ut(S,"FORBID_TAGS")?G({},S.FORBID_TAGS,Ae):Bt({}),Oa=ut(S,"FORBID_ATTR")?G({},S.FORBID_ATTR,Ae):Bt({}),ui=ut(S,"USE_PROFILES")?S.USE_PROFILES:!1,Tp=S.ALLOW_ARIA_ATTR!==!1,Zc=S.ALLOW_DATA_ATTR!==!1,$p=S.ALLOW_UNKNOWN_PROTOCOLS||!1,Ip=S.ALLOW_SELF_CLOSE_IN_ATTR!==!1,li=S.SAFE_FOR_TEMPLATES||!1,Ma=S.SAFE_FOR_XML!==!1,pn=S.WHOLE_DOCUMENT||!1,ci=S.RETURN_DOM||!1,Na=S.RETURN_DOM_FRAGMENT||!1,Ua=S.RETURN_TRUSTED_TYPE||!1,Bc=S.FORCE_BODY||!1,Cp=S.SANITIZE_DOM!==!1,Rp=S.SANITIZE_NAMED_PROPS||!1,Vc=S.KEEP_CONTENT!==!1,Ps=S.IN_PLACE||!1,xp=S.ALLOWED_URI_REGEXP||M0,hi=S.NAMESPACE||dr,Za=S.MATHML_TEXT_INTEGRATION_POINTS||Za,Wa=S.HTML_INTEGRATION_POINTS||Wa,Se=S.CUSTOM_ELEMENT_HANDLING||{},S.CUSTOM_ELEMENT_HANDLING&&zp(S.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(Se.tagNameCheck=S.CUSTOM_ELEMENT_HANDLING.tagNameCheck),S.CUSTOM_ELEMENT_HANDLING&&zp(S.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(Se.attributeNameCheck=S.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),S.CUSTOM_ELEMENT_HANDLING&&typeof S.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(Se.allowCustomizedBuiltInElements=S.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),li&&(Zc=!1),Na&&(ci=!0),ui&&(Re=G({},Vm),Oe=Pl(null),ui.html===!0&&(G(Re,Bm),G(Oe,jm)),ui.svg===!0&&(G(Re,Yu),G(Oe,Xu),G(Oe,ol)),ui.svgFilters===!0&&(G(Re,Ku),G(Oe,Xu),G(Oe,ol)),ui.mathMl===!0&&(G(Re,Ju),G(Oe,Gm),G(Oe,ol))),ut(S,"ADD_TAGS")||(zr.tagCheck=null),ut(S,"ADD_ATTR")||(zr.attributeCheck=null),S.ADD_TAGS&&(typeof S.ADD_TAGS=="function"?zr.tagCheck=S.ADD_TAGS:(Re===Ep&&(Re=Bt(Re)),G(Re,S.ADD_TAGS,Ae))),S.ADD_ATTR&&(typeof S.ADD_ATTR=="function"?zr.attributeCheck=S.ADD_ATTR:(Oe===Ap&&(Oe=Bt(Oe)),G(Oe,S.ADD_ATTR,Ae))),S.ADD_URI_SAFE_ATTR&&G(Gc,S.ADD_URI_SAFE_ATTR,Ae),S.FORBID_CONTENTS&&(Ft===jc&&(Ft=Bt(Ft)),G(Ft,S.FORBID_CONTENTS,Ae)),S.ADD_FORBID_CONTENTS&&(Ft===jc&&(Ft=Bt(Ft)),G(Ft,S.ADD_FORBID_CONTENTS,Ae)),Vc&&(Re["#text"]=!0),pn&&G(Re,["html","head","body"]),Re.table&&(G(Re,["tbody"]),delete Rs.tbody),S.TRUSTED_TYPES_POLICY){if(typeof S.TRUSTED_TYPES_POLICY.createHTML!="function")throw Zs('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof S.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Zs('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');N=S.TRUSTED_TYPES_POLICY,F=N.createHTML("")}else N===void 0&&(N=r6(m,i)),N!==null&&typeof F=="string"&&(F=N.createHTML(""));tt&&tt(S),di=S}},Op=G({},[...Yu,...Ku,...VN]),Mp=G({},[...Ju,...jN]),fS=function(S){let C=B(S);(!C||!C.tagName)&&(C={namespaceURI:hi,tagName:"template"});const L=Ll(S.tagName),de=Ll(C.tagName);return Yc[S.namespaceURI]?S.namespaceURI===Ha?C.namespaceURI===dr?L==="svg":C.namespaceURI===Fa?L==="svg"&&(de==="annotation-xml"||Za[de]):!!Op[L]:S.namespaceURI===Fa?C.namespaceURI===dr?L==="math":C.namespaceURI===Ha?L==="math"&&Wa[de]:!!Mp[L]:S.namespaceURI===dr?C.namespaceURI===Ha&&!Wa[de]||C.namespaceURI===Fa&&!Za[de]?!1:!Mp[L]&&(uS[L]||!Op[L]):!!(Ls==="application/xhtml+xml"&&Yc[S.namespaceURI]):!1},Ht=function(S){Fs(t.removed,{element:S});try{B(S).removeChild(S)}catch{I(S)}},fn=function(S,C){try{Fs(t.removed,{attribute:C.getAttributeNode(S),from:C})}catch{Fs(t.removed,{attribute:null,from:C})}if(C.removeAttribute(S),S==="is")if(ci||Na)try{Ht(C)}catch{}else try{C.setAttribute(S,"")}catch{}},Np=function(S){let C=null,L=null;if(Bc)S="<remove></remove>"+S;else{const _e=qu(S,/^[\r\n\t ]+/);L=_e&&_e[0]}Ls==="application/xhtml+xml"&&hi===dr&&(S='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+S+"</body></html>");const de=N?N.createHTML(S):S;if(hi===dr)try{C=new y().parseFromString(de,Ls)}catch{}if(!C||!C.documentElement){C=Y.createDocument(hi,"template",null);try{C.documentElement.innerHTML=qc?F:de}catch{}}const je=C.body||C.documentElement;return S&&L&&je.insertBefore(e.createTextNode(L),je.childNodes[0]||null),hi===dr?At.call(C,pn?"html":"body")[0]:pn?C.documentElement:je},Up=function(S){return j.call(S.ownerDocument||S,S,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},Jc=function(S){return S instanceof f&&(typeof S.nodeName!="string"||typeof S.textContent!="string"||typeof S.removeChild!="function"||!(S.attributes instanceof h)||typeof S.removeAttribute!="function"||typeof S.setAttribute!="function"||typeof S.namespaceURI!="string"||typeof S.insertBefore!="function"||typeof S.hasChildNodes!="function")},Fp=function(S){return typeof a=="function"&&S instanceof a};function pr(U,S,C){sl(U,L=>{L.call(t,S,C,di)})}const Hp=function(S){let C=null;if(pr(ze.beforeSanitizeElements,S,null),Jc(S))return Ht(S),!0;const L=Ae(S.nodeName);if(pr(ze.uponSanitizeElement,S,{tagName:L,allowedTags:Re}),Ma&&S.hasChildNodes()&&!Fp(S.firstElementChild)&&Ye(/<[/\w!]/g,S.innerHTML)&&Ye(/<[/\w!]/g,S.textContent)||S.nodeType===Bs.progressingInstruction||Ma&&S.nodeType===Bs.comment&&Ye(/<[/\w]/g,S.data))return Ht(S),!0;if(!(zr.tagCheck instanceof Function&&zr.tagCheck(L))&&(!Re[L]||Rs[L])){if(!Rs[L]&&Wp(L)&&(Se.tagNameCheck instanceof RegExp&&Ye(Se.tagNameCheck,L)||Se.tagNameCheck instanceof Function&&Se.tagNameCheck(L)))return!1;if(Vc&&!Ft[L]){const de=B(S)||S.parentNode,je=R(S)||S.childNodes;if(je&&de){const _e=je.length;for(let nt=_e-1;nt>=0;--nt){const fr=x(je[nt],!0);fr.__removalCount=(S.__removalCount||0)+1,de.insertBefore(fr,P(S))}}}return Ht(S),!0}return S instanceof c&&!fS(S)||(L==="noscript"||L==="noembed"||L==="noframes")&&Ye(/<\/no(script|embed|frames)/i,S.innerHTML)?(Ht(S),!0):(li&&S.nodeType===Bs.text&&(C=S.textContent,sl([dn,Ut,Dr],de=>{C=Hs(C,de," ")}),S.textContent!==C&&(Fs(t.removed,{element:S.cloneNode()}),S.textContent=C)),pr(ze.afterSanitizeElements,S,null),!1)},Zp=function(S,C,L){if(Oa[C]||Cp&&(C==="id"||C==="name")&&(L in e||L in pS))return!1;if(!(Zc&&!Oa[C]&&Ye(Hc,C))){if(!(Tp&&Ye(za,C))){if(!(zr.attributeCheck instanceof Function&&zr.attributeCheck(C,S))){if(!Oe[C]||Oa[C]){if(!(Wp(S)&&(Se.tagNameCheck instanceof RegExp&&Ye(Se.tagNameCheck,S)||Se.tagNameCheck instanceof Function&&Se.tagNameCheck(S))&&(Se.attributeNameCheck instanceof RegExp&&Ye(Se.attributeNameCheck,C)||Se.attributeNameCheck instanceof Function&&Se.attributeNameCheck(C,S))||C==="is"&&Se.allowCustomizedBuiltInElements&&(Se.tagNameCheck instanceof RegExp&&Ye(Se.tagNameCheck,L)||Se.tagNameCheck instanceof Function&&Se.tagNameCheck(L))))return!1}else if(!Gc[C]){if(!Ye(xp,Hs(L,kp,""))){if(!((C==="src"||C==="xlink:href"||C==="href")&&S!=="script"&&HN(L,"data:")===0&&Pp[S])){if(!($p&&!Ye(oS,Hs(L,kp,"")))){if(L)return!1}}}}}}}return!0},Wp=function(S){return S!=="annotation-xml"&&qu(S,aS)},Bp=function(S){pr(ze.beforeSanitizeAttributes,S,null);const{attributes:C}=S;if(!C||Jc(S))return;const L={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Oe,forceKeepAttr:void 0};let de=C.length;for(;de--;){const je=C[de],{name:_e,namespaceURI:nt,value:fr}=je,pi=Ae(_e),Xc=fr;let Me=_e==="value"?Xc:ZN(Xc);if(L.attrName=pi,L.attrValue=Me,L.keepAttr=!0,L.forceKeepAttr=void 0,pr(ze.uponSanitizeAttribute,S,L),Me=L.attrValue,Rp&&(pi==="id"||pi==="name")&&(fn(_e,S),Me=lS+Me),Ma&&Ye(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,Me)){fn(_e,S);continue}if(pi==="attributename"&&qu(Me,"href")){fn(_e,S);continue}if(L.forceKeepAttr)continue;if(!L.keepAttr){fn(_e,S);continue}if(!Ip&&Ye(/\/>/i,Me)){fn(_e,S);continue}li&&sl([dn,Ut,Dr],jp=>{Me=Hs(Me,jp," ")});const Vp=Ae(S.nodeName);if(!Zp(Vp,pi,Me)){fn(_e,S);continue}if(N&&typeof m=="object"&&typeof m.getAttributeType=="function"&&!nt)switch(m.getAttributeType(Vp,pi)){case"TrustedHTML":{Me=N.createHTML(Me);break}case"TrustedScriptURL":{Me=N.createScriptURL(Me);break}}if(Me!==Xc)try{nt?S.setAttributeNS(nt,_e,Me):S.setAttribute(_e,Me),Jc(S)?Ht(S):Wm(t.removed)}catch{fn(_e,S)}}pr(ze.afterSanitizeAttributes,S,null)},gS=function U(S){let C=null;const L=Up(S);for(pr(ze.beforeSanitizeShadowDOM,S,null);C=L.nextNode();)pr(ze.uponSanitizeShadowNode,C,null),Hp(C),Bp(C),C.content instanceof s&&U(C.content);pr(ze.afterSanitizeShadowDOM,S,null)};return t.sanitize=function(U){let S=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},C=null,L=null,de=null,je=null;if(qc=!U,qc&&(U="<!-->"),typeof U!="string"&&!Fp(U))if(typeof U.toString=="function"){if(U=U.toString(),typeof U!="string")throw Zs("dirty is not a string, aborting")}else throw Zs("toString is not a function");if(!t.isSupported)return U;if(Wc||Kc(S),t.removed=[],typeof U=="string"&&(Ps=!1),Ps){if(U.nodeName){const fr=Ae(U.nodeName);if(!Re[fr]||Rs[fr])throw Zs("root node is forbidden and cannot be sanitized in-place")}}else if(U instanceof a)C=Np("<!---->"),L=C.ownerDocument.importNode(U,!0),L.nodeType===Bs.element&&L.nodeName==="BODY"||L.nodeName==="HTML"?C=L:C.appendChild(L);else{if(!ci&&!li&&!pn&&U.indexOf("<")===-1)return N&&Ua?N.createHTML(U):U;if(C=Np(U),!C)return ci?null:Ua?F:""}C&&Bc&&Ht(C.firstChild);const _e=Up(Ps?U:C);for(;de=_e.nextNode();)Hp(de),Bp(de),de.content instanceof s&&gS(de.content);if(Ps)return U;if(ci){if(Na)for(je=ce.call(C.ownerDocument);C.firstChild;)je.appendChild(C.firstChild);else je=C;return(Oe.shadowroot||Oe.shadowrootmode)&&(je=hn.call(n,je,!0)),je}let nt=pn?C.outerHTML:C.innerHTML;return pn&&Re["!doctype"]&&C.ownerDocument&&C.ownerDocument.doctype&&C.ownerDocument.doctype.name&&Ye(N0,C.ownerDocument.doctype.name)&&(nt="<!DOCTYPE "+C.ownerDocument.doctype.name+`>
|
|
454
|
-
`+nt),li&&sl([dn,Ut,Dr],fr=>{nt=Hs(nt,fr," ")}),N&&Ua?N.createHTML(nt):nt},t.setConfig=function(){let U=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Kc(U),Wc=!0},t.clearConfig=function(){di=null,Wc=!1},t.isValidAttribute=function(U,S,C){di||Kc({});const L=Ae(U),de=Ae(S);return Zp(L,de,C)},t.addHook=function(U,S){typeof S=="function"&&Fs(ze[U],S)},t.removeHook=function(U,S){if(S!==void 0){const C=UN(ze[U],S);return C===-1?void 0:FN(ze[U],C,1)[0]}return Wm(ze[U])},t.removeHooks=function(U){ze[U]=[]},t.removeAllHooks=function(){ze=Ym()},t}var F0=U0();function dp(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var ai=dp();function H0(r){ai=r}var kn={exec:()=>null};function J(r,t=""){let e=typeof r=="string"?r:r.source,n={replace:(i,s)=>{let o=typeof s=="string"?s:s.source;return o=o.replace(et.caret,"$1"),e=e.replace(i,o),n},getRegex:()=>new RegExp(e,t)};return n}var n6=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),et={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:r=>new RegExp(`^( {0,3}${r})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:r=>new RegExp(`^ {0,${Math.min(3,r-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:r=>new RegExp(`^ {0,${Math.min(3,r-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:r=>new RegExp(`^ {0,${Math.min(3,r-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:r=>new RegExp(`^ {0,${Math.min(3,r-1)}}#`),htmlBeginRegex:r=>new RegExp(`^ {0,${Math.min(3,r-1)}}<(?:[a-z].*>|!--)`,"i"),blockquoteBeginRegex:r=>new RegExp(`^ {0,${Math.min(3,r-1)}}>`)},i6=/^(?:[ \t]*(?:\n|$))+/,s6=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,o6=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Da=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,a6=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,pp=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Z0=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,W0=J(Z0).replace(/bull/g,pp).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(),l6=J(Z0).replace(/bull/g,pp).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(),fp=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,c6=/^[^\n]+/,gp=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,u6=J(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",gp).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),h6=J(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,pp).getRegex(),Uc="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",mp=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,d6=J("^ {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",mp).replace("tag",Uc).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),B0=J(fp).replace("hr",Da).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",Uc).getRegex(),p6=J(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",B0).getRegex(),vp={blockquote:p6,code:s6,def:u6,fences:o6,heading:a6,hr:Da,html:d6,lheading:W0,list:h6,newline:i6,paragraph:B0,table:kn,text:c6},Km=J("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Da).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",Uc).getRegex(),f6={...vp,lheading:l6,table:Km,paragraph:J(fp).replace("hr",Da).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Km).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",Uc).getRegex()},g6={...vp,html:J(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",mp).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:kn,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:J(fp).replace("hr",Da).replace("heading",` *#{1,6} *[^
|
|
455
|
-
]`).replace("lheading",W0).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},m6=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,v6=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,V0=/^( {2,}|\\)\n(?!\s*$)/,y6=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Cs=/[\p{P}\p{S}]/u,Fc=/[\s\p{P}\p{S}]/u,yp=/[^\s\p{P}\p{S}]/u,b6=J(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Fc).getRegex(),j0=/(?!~)[\p{P}\p{S}]/u,w6=/(?!~)[\s\p{P}\p{S}]/u,S6=/(?:[^\s\p{P}\p{S}]|~)/u,_6=J(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",n6?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),G0=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,k6=J(G0,"u").replace(/punct/g,Cs).getRegex(),x6=J(G0,"u").replace(/punct/g,j0).getRegex(),q0="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",E6=J(q0,"gu").replace(/notPunctSpace/g,yp).replace(/punctSpace/g,Fc).replace(/punct/g,Cs).getRegex(),A6=J(q0,"gu").replace(/notPunctSpace/g,S6).replace(/punctSpace/g,w6).replace(/punct/g,j0).getRegex(),T6=J("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,yp).replace(/punctSpace/g,Fc).replace(/punct/g,Cs).getRegex(),$6=J(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,Cs).getRegex(),I6="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",C6=J(I6,"gu").replace(/notPunctSpace/g,yp).replace(/punctSpace/g,Fc).replace(/punct/g,Cs).getRegex(),R6=J(/\\(punct)/,"gu").replace(/punct/g,Cs).getRegex(),P6=J(/^<(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(),L6=J(mp).replace("(?:-->|$)","-->").getRegex(),D6=J("^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",L6).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Xl=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,z6=J(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",Xl).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Y0=J(/^!?\[(label)\]\[(ref)\]/).replace("label",Xl).replace("ref",gp).getRegex(),K0=J(/^!?\[(ref)\](?:\[\])?/).replace("ref",gp).getRegex(),O6=J("reflink|nolink(?!\\()","g").replace("reflink",Y0).replace("nolink",K0).getRegex(),Jm=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,bp={_backpedal:kn,anyPunctuation:R6,autolink:P6,blockSkip:_6,br:V0,code:v6,del:kn,delLDelim:kn,delRDelim:kn,emStrongLDelim:k6,emStrongRDelimAst:E6,emStrongRDelimUnd:T6,escape:m6,link:z6,nolink:K0,punctuation:b6,reflink:Y0,reflinkSearch:O6,tag:D6,text:y6,url:kn},M6={...bp,link:J(/^!?\[(label)\]\((.*?)\)/).replace("label",Xl).getRegex(),reflink:J(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Xl).getRegex()},ud={...bp,emStrongRDelimAst:A6,emStrongLDelim:x6,delLDelim:$6,delRDelim:C6,url:J(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Jm).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:J(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",Jm).getRegex()},N6={...ud,br:J(V0).replace("{2,}","*").getRegex(),text:J(ud.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},al={normal:vp,gfm:f6,pedantic:g6},Vs={normal:bp,gfm:ud,breaks:N6,pedantic:M6},U6={"&":"&","<":"<",">":">",'"':""","'":"'"},Xm=r=>U6[r];function Vt(r,t){if(t){if(et.escapeTest.test(r))return r.replace(et.escapeReplace,Xm)}else if(et.escapeTestNoEncode.test(r))return r.replace(et.escapeReplaceNoEncode,Xm);return r}function Qm(r){try{r=encodeURI(r).replace(et.percentDecode,"%")}catch{return null}return r}function ev(r,t){var s;let e=r.replace(et.findPipe,(o,a,c)=>{let u=!1,h=a;for(;--h>=0&&c[h]==="\\";)u=!u;return u?"|":" |"}),n=e.split(et.splitPipe),i=0;if(n[0].trim()||n.shift(),n.length>0&&!((s=n.at(-1))!=null&&s.trim())&&n.pop(),t)if(n.length>t)n.splice(t);else for(;n.length<t;)n.push("");for(;i<n.length;i++)n[i]=n[i].trim().replace(et.slashPipe,"|");return n}function js(r,t,e){let n=r.length;if(n===0)return"";let i=0;for(;i<n&&r.charAt(n-i-1)===t;)i++;return r.slice(0,n-i)}function F6(r,t){if(r.indexOf(t[1])===-1)return-1;let e=0;for(let n=0;n<r.length;n++)if(r[n]==="\\")n++;else if(r[n]===t[0])e++;else if(r[n]===t[1]&&(e--,e<0))return n;return e>0?-2:-1}function H6(r,t=0){let e=t,n="";for(let i of r)if(i===" "){let s=4-e%4;n+=" ".repeat(s),e+=s}else n+=i,e++;return n}function tv(r,t,e,n,i){let s=t.href,o=t.title||null,a=r[1].replace(i.other.outputLinkReplace,"$1");n.state.inLink=!0;let c={type:r[0].charAt(0)==="!"?"image":"link",raw:e,href:s,title:o,text:a,tokens:n.inlineTokens(a)};return n.state.inLink=!1,c}function Z6(r,t,e){let n=r.match(e.other.indentCodeCompensation);if(n===null)return t;let i=n[1];return t.split(`
|
|
456
|
-
`).map(s=>{let o=s.match(e.other.beginningSpace);if(o===null)return s;let[a]=o;return a.length>=i.length?s.slice(i.length):s}).join(`
|
|
457
|
-
`)}var Ql=class{constructor(r){g(this,"options");g(this,"rules");g(this,"lexer");this.options=r||ai}space(r){let t=this.rules.block.newline.exec(r);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(r){let t=this.rules.block.code.exec(r);if(t){let e=t[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?e:js(e,`
|
|
458
|
-
`)}}}fences(r){let t=this.rules.block.fences.exec(r);if(t){let e=t[0],n=Z6(e,t[3]||"",this.rules);return{type:"code",raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:n}}}heading(r){let t=this.rules.block.heading.exec(r);if(t){let e=t[2].trim();if(this.rules.other.endingHash.test(e)){let n=js(e,"#");(this.options.pedantic||!n||this.rules.other.endingSpaceChar.test(n))&&(e=n.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(r){let t=this.rules.block.hr.exec(r);if(t)return{type:"hr",raw:js(t[0],`
|
|
459
|
-
`)}}blockquote(r){let t=this.rules.block.blockquote.exec(r);if(t){let e=js(t[0],`
|
|
460
|
-
`).split(`
|
|
461
|
-
`),n="",i="",s=[];for(;e.length>0;){let o=!1,a=[],c;for(c=0;c<e.length;c++)if(this.rules.other.blockquoteStart.test(e[c]))a.push(e[c]),o=!0;else if(!o)a.push(e[c]);else break;e=e.slice(c);let u=a.join(`
|
|
462
|
-
`),h=u.replace(this.rules.other.blockquoteSetextReplace,`
|
|
463
|
-
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");n=n?`${n}
|
|
464
|
-
${u}`:u,i=i?`${i}
|
|
465
|
-
${h}`:h;let f=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(h,s,!0),this.lexer.state.top=f,e.length===0)break;let y=s.at(-1);if((y==null?void 0:y.type)==="code")break;if((y==null?void 0:y.type)==="blockquote"){let m=y,E=m.raw+`
|
|
466
|
-
`+e.join(`
|
|
467
|
-
`),x=this.blockquote(E);s[s.length-1]=x,n=n.substring(0,n.length-m.raw.length)+x.raw,i=i.substring(0,i.length-m.text.length)+x.text;break}else if((y==null?void 0:y.type)==="list"){let m=y,E=m.raw+`
|
|
468
|
-
`+e.join(`
|
|
469
|
-
`),x=this.list(E);s[s.length-1]=x,n=n.substring(0,n.length-y.raw.length)+x.raw,i=i.substring(0,i.length-m.raw.length)+x.raw,e=E.substring(s.at(-1).raw.length).split(`
|
|
470
|
-
`);continue}}return{type:"blockquote",raw:n,tokens:s,text:i}}}list(r){var e,n;let t=this.rules.block.list.exec(r);if(t){let i=t[1].trim(),s=i.length>1,o={type:"list",raw:"",ordered:s,start:s?+i.slice(0,-1):"",loose:!1,items:[]};i=s?`\\d{1,9}\\${i.slice(-1)}`:`\\${i}`,this.options.pedantic&&(i=s?i:"[*+-]");let a=this.rules.other.listItemRegex(i),c=!1;for(;r;){let h=!1,f="",y="";if(!(t=a.exec(r))||this.rules.block.hr.test(r))break;f=t[0],r=r.substring(f.length);let m=H6(t[2].split(`
|
|
471
|
-
`,1)[0],t[1].length),E=r.split(`
|
|
472
|
-
`,1)[0],x=!m.trim(),I=0;if(this.options.pedantic?(I=2,y=m.trimStart()):x?I=t[1].length+1:(I=m.search(this.rules.other.nonSpaceChar),I=I>4?1:I,y=m.slice(I),I+=t[1].length),x&&this.rules.other.blankLine.test(E)&&(f+=E+`
|
|
473
|
-
`,r=r.substring(E.length+1),h=!0),!h){let P=this.rules.other.nextBulletRegex(I),R=this.rules.other.hrRegex(I),B=this.rules.other.fencesBeginRegex(I),N=this.rules.other.headingBeginRegex(I),F=this.rules.other.htmlBeginRegex(I),Y=this.rules.other.blockquoteBeginRegex(I);for(;r;){let j=r.split(`
|
|
474
|
-
`,1)[0],ce;if(E=j,this.options.pedantic?(E=E.replace(this.rules.other.listReplaceNesting," "),ce=E):ce=E.replace(this.rules.other.tabCharGlobal," "),B.test(E)||N.test(E)||F.test(E)||Y.test(E)||P.test(E)||R.test(E))break;if(ce.search(this.rules.other.nonSpaceChar)>=I||!E.trim())y+=`
|
|
475
|
-
`+ce.slice(I);else{if(x||m.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||B.test(m)||N.test(m)||R.test(m))break;y+=`
|
|
476
|
-
`+E}x=!E.trim(),f+=j+`
|
|
477
|
-
`,r=r.substring(j.length+1),m=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(y),loose:!1,text:y,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 h of o.items){if(this.lexer.state.top=!1,h.tokens=this.lexer.blockTokens(h.text,[]),h.task){if(h.text=h.text.replace(this.rules.other.listReplaceTask,""),((e=h.tokens[0])==null?void 0:e.type)==="text"||((n=h.tokens[0])==null?void 0:n.type)==="paragraph"){h.tokens[0].raw=h.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),h.tokens[0].text=h.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let y=this.lexer.inlineQueue.length-1;y>=0;y--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[y].src)){this.lexer.inlineQueue[y].src=this.lexer.inlineQueue[y].src.replace(this.rules.other.listReplaceTask,"");break}}let f=this.rules.other.listTaskCheckbox.exec(h.raw);if(f){let y={type:"checkbox",raw:f[0]+" ",checked:f[0]!=="[ ]"};h.checked=y.checked,o.loose?h.tokens[0]&&["paragraph","text"].includes(h.tokens[0].type)&&"tokens"in h.tokens[0]&&h.tokens[0].tokens?(h.tokens[0].raw=y.raw+h.tokens[0].raw,h.tokens[0].text=y.raw+h.tokens[0].text,h.tokens[0].tokens.unshift(y)):h.tokens.unshift({type:"paragraph",raw:y.raw,text:y.raw,tokens:[y]}):h.tokens.unshift(y)}}if(!o.loose){let f=h.tokens.filter(m=>m.type==="space"),y=f.length>0&&f.some(m=>this.rules.other.anyLine.test(m.raw));o.loose=y}}if(o.loose)for(let h of o.items){h.loose=!0;for(let f of h.tokens)f.type==="text"&&(f.type="paragraph")}return o}}html(r){let t=this.rules.block.html.exec(r);if(t)return{type:"html",block:!0,raw:t[0],pre:t[1]==="pre"||t[1]==="script"||t[1]==="style",text:t[0]}}def(r){let t=this.rules.block.def.exec(r);if(t){let e=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),n=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",i=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:e,raw:t[0],href:n,title:i}}}table(r){var o;let t=this.rules.block.table.exec(r);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let e=ev(t[1]),n=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),i=(o=t[3])!=null&&o.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
478
|
-
`):[],s={type:"table",raw:t[0],header:[],align:[],rows:[]};if(e.length===n.length){for(let a of n)this.rules.other.tableAlignRight.test(a)?s.align.push("right"):this.rules.other.tableAlignCenter.test(a)?s.align.push("center"):this.rules.other.tableAlignLeft.test(a)?s.align.push("left"):s.align.push(null);for(let a=0;a<e.length;a++)s.header.push({text:e[a],tokens:this.lexer.inline(e[a]),header:!0,align:s.align[a]});for(let a of i)s.rows.push(ev(a,s.header.length).map((c,u)=>({text:c,tokens:this.lexer.inline(c),header:!1,align:s.align[u]})));return s}}lheading(r){let t=this.rules.block.lheading.exec(r);if(t){let e=t[1].trim();return{type:"heading",raw:t[0],depth:t[2].charAt(0)==="="?1:2,text:e,tokens:this.lexer.inline(e)}}}paragraph(r){let t=this.rules.block.paragraph.exec(r);if(t){let e=t[1].charAt(t[1].length-1)===`
|
|
479
|
-
`?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(r){let t=this.rules.block.text.exec(r);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(r){let t=this.rules.inline.escape.exec(r);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(r){let t=this.rules.inline.tag.exec(r);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(r){let t=this.rules.inline.link.exec(r);if(t){let e=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(e)){if(!this.rules.other.endAngleBracket.test(e))return;let s=js(e.slice(0,-1),"\\");if((e.length-s.length)%2===0)return}else{let s=F6(t[2],"()");if(s===-2)return;if(s>-1){let o=(t[0].indexOf("!")===0?5:4)+t[1].length+s;t[2]=t[2].substring(0,s),t[0]=t[0].substring(0,o).trim(),t[3]=""}}let n=t[2],i="";if(this.options.pedantic){let s=this.rules.other.pedanticHrefTitle.exec(n);s&&(n=s[1],i=s[3])}else i=t[3]?t[3].slice(1,-1):"";return n=n.trim(),this.rules.other.startAngleBracket.test(n)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(e)?n=n.slice(1):n=n.slice(1,-1)),tv(t,{href:n&&n.replace(this.rules.inline.anyPunctuation,"$1"),title:i&&i.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(r,t){let e;if((e=this.rules.inline.reflink.exec(r))||(e=this.rules.inline.nolink.exec(r))){let n=(e[2]||e[1]).replace(this.rules.other.multipleSpaceGlobal," "),i=t[n.toLowerCase()];if(!i){let s=e[0].charAt(0);return{type:"text",raw:s,text:s}}return tv(e,i,e[0],this.lexer,this.rules)}}emStrong(r,t,e=""){let n=this.rules.inline.emStrongLDelim.exec(r);if(!(!n||!n[1]&&!n[2]&&!n[3]&&!n[4]||n[4]&&e.match(this.rules.other.unicodeAlphaNumeric))&&(!(n[1]||n[3])||!e||this.rules.inline.punctuation.exec(e))){let i=[...n[0]].length-1,s,o,a=i,c=0,u=n[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(u.lastIndex=0,t=t.slice(-1*r.length+i);(n=u.exec(t))!=null;){if(s=n[1]||n[2]||n[3]||n[4]||n[5]||n[6],!s)continue;if(o=[...s].length,n[3]||n[4]){a+=o;continue}else if((n[5]||n[6])&&i%3&&!((i+o)%3)){c+=o;continue}if(a-=o,a>0)continue;o=Math.min(o,o+a+c);let h=[...n[0]][0].length,f=r.slice(0,i+n.index+h+o);if(Math.min(i,o)%2){let m=f.slice(1,-1);return{type:"em",raw:f,text:m,tokens:this.lexer.inlineTokens(m)}}let y=f.slice(2,-2);return{type:"strong",raw:f,text:y,tokens:this.lexer.inlineTokens(y)}}}}codespan(r){let t=this.rules.inline.code.exec(r);if(t){let e=t[2].replace(this.rules.other.newLineCharGlobal," "),n=this.rules.other.nonSpaceChar.test(e),i=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return n&&i&&(e=e.substring(1,e.length-1)),{type:"codespan",raw:t[0],text:e}}}br(r){let t=this.rules.inline.br.exec(r);if(t)return{type:"br",raw:t[0]}}del(r,t,e=""){let n=this.rules.inline.delLDelim.exec(r);if(n&&(!n[1]||!e||this.rules.inline.punctuation.exec(e))){let i=[...n[0]].length-1,s,o,a=i,c=this.rules.inline.delRDelim;for(c.lastIndex=0,t=t.slice(-1*r.length+i);(n=c.exec(t))!=null;){if(s=n[1]||n[2]||n[3]||n[4]||n[5]||n[6],!s||(o=[...s].length,o!==i))continue;if(n[3]||n[4]){a+=o;continue}if(a-=o,a>0)continue;o=Math.min(o,o+a);let u=[...n[0]][0].length,h=r.slice(0,i+n.index+u+o),f=h.slice(i,-i);return{type:"del",raw:h,text:f,tokens:this.lexer.inlineTokens(f)}}}}autolink(r){let t=this.rules.inline.autolink.exec(r);if(t){let e,n;return t[2]==="@"?(e=t[1],n="mailto:"+e):(e=t[1],n=e),{type:"link",raw:t[0],text:e,href:n,tokens:[{type:"text",raw:e,text:e}]}}}url(r){var e;let t;if(t=this.rules.inline.url.exec(r)){let n,i;if(t[2]==="@")n=t[0],i="mailto:"+n;else{let s;do s=t[0],t[0]=((e=this.rules.inline._backpedal.exec(t[0]))==null?void 0:e[0])??"";while(s!==t[0]);n=t[0],t[1]==="www."?i="http://"+t[0]:i=t[0]}return{type:"link",raw:t[0],text:n,href:i,tokens:[{type:"text",raw:n,text:n}]}}}inlineText(r){let t=this.rules.inline.text.exec(r);if(t){let e=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:e}}}},zt=class hd{constructor(t){g(this,"tokens");g(this,"options");g(this,"state");g(this,"inlineQueue");g(this,"tokenizer");this.tokens=[],this.tokens.links=Object.create(null),this.options=t||ai,this.options.tokenizer=this.options.tokenizer||new Ql,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let e={other:et,block:al.normal,inline:Vs.normal};this.options.pedantic?(e.block=al.pedantic,e.inline=Vs.pedantic):this.options.gfm&&(e.block=al.gfm,this.options.breaks?e.inline=Vs.breaks:e.inline=Vs.gfm),this.tokenizer.rules=e}static get rules(){return{block:al,inline:Vs}}static lex(t,e){return new hd(e).lex(t)}static lexInline(t,e){return new hd(e).inlineTokens(t)}lex(t){t=t.replace(et.carriageReturn,`
|
|
480
|
-
`),this.blockTokens(t,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){let n=this.inlineQueue[e];this.inlineTokens(n.src,n.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(t,e=[],n=!1){var i,s,o;for(this.tokenizer.lexer=this,this.options.pedantic&&(t=t.replace(et.tabCharGlobal," ").replace(et.spaceLine,""));t;){let a;if((s=(i=this.options.extensions)==null?void 0:i.block)!=null&&s.some(u=>(a=u.call({lexer:this},t,e))?(t=t.substring(a.raw.length),e.push(a),!0):!1))continue;if(a=this.tokenizer.space(t)){t=t.substring(a.raw.length);let u=e.at(-1);a.raw.length===1&&u!==void 0?u.raw+=`
|
|
481
|
-
`:e.push(a);continue}if(a=this.tokenizer.code(t)){t=t.substring(a.raw.length);let u=e.at(-1);(u==null?void 0:u.type)==="paragraph"||(u==null?void 0:u.type)==="text"?(u.raw+=(u.raw.endsWith(`
|
|
482
|
-
`)?"":`
|
|
483
|
-
`)+a.raw,u.text+=`
|
|
484
|
-
`+a.text,this.inlineQueue.at(-1).src=u.text):e.push(a);continue}if(a=this.tokenizer.fences(t)){t=t.substring(a.raw.length),e.push(a);continue}if(a=this.tokenizer.heading(t)){t=t.substring(a.raw.length),e.push(a);continue}if(a=this.tokenizer.hr(t)){t=t.substring(a.raw.length),e.push(a);continue}if(a=this.tokenizer.blockquote(t)){t=t.substring(a.raw.length),e.push(a);continue}if(a=this.tokenizer.list(t)){t=t.substring(a.raw.length),e.push(a);continue}if(a=this.tokenizer.html(t)){t=t.substring(a.raw.length),e.push(a);continue}if(a=this.tokenizer.def(t)){t=t.substring(a.raw.length);let u=e.at(-1);(u==null?void 0:u.type)==="paragraph"||(u==null?void 0:u.type)==="text"?(u.raw+=(u.raw.endsWith(`
|
|
485
|
-
`)?"":`
|
|
486
|
-
`)+a.raw,u.text+=`
|
|
487
|
-
`+a.raw,this.inlineQueue.at(-1).src=u.text):this.tokens.links[a.tag]||(this.tokens.links[a.tag]={href:a.href,title:a.title},e.push(a));continue}if(a=this.tokenizer.table(t)){t=t.substring(a.raw.length),e.push(a);continue}if(a=this.tokenizer.lheading(t)){t=t.substring(a.raw.length),e.push(a);continue}let c=t;if((o=this.options.extensions)!=null&&o.startBlock){let u=1/0,h=t.slice(1),f;this.options.extensions.startBlock.forEach(y=>{f=y.call({lexer:this},h),typeof f=="number"&&f>=0&&(u=Math.min(u,f))}),u<1/0&&u>=0&&(c=t.substring(0,u+1))}if(this.state.top&&(a=this.tokenizer.paragraph(c))){let u=e.at(-1);n&&(u==null?void 0:u.type)==="paragraph"?(u.raw+=(u.raw.endsWith(`
|
|
488
|
-
`)?"":`
|
|
489
|
-
`)+a.raw,u.text+=`
|
|
490
|
-
`+a.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=u.text):e.push(a),n=c.length!==t.length,t=t.substring(a.raw.length);continue}if(a=this.tokenizer.text(t)){t=t.substring(a.raw.length);let u=e.at(-1);(u==null?void 0:u.type)==="text"?(u.raw+=(u.raw.endsWith(`
|
|
491
|
-
`)?"":`
|
|
492
|
-
`)+a.raw,u.text+=`
|
|
493
|
-
`+a.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=u.text):e.push(a);continue}if(t){let u="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(u);break}else throw new Error(u)}}return this.state.top=!0,e}inline(t,e=[]){return this.inlineQueue.push({src:t,tokens:e}),e}inlineTokens(t,e=[]){var c,u,h,f,y;this.tokenizer.lexer=this;let n=t,i=null;if(this.tokens.links){let m=Object.keys(this.tokens.links);if(m.length>0)for(;(i=this.tokenizer.rules.inline.reflinkSearch.exec(n))!=null;)m.includes(i[0].slice(i[0].lastIndexOf("[")+1,-1))&&(n=n.slice(0,i.index)+"["+"a".repeat(i[0].length-2)+"]"+n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(i=this.tokenizer.rules.inline.anyPunctuation.exec(n))!=null;)n=n.slice(0,i.index)+"++"+n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let s;for(;(i=this.tokenizer.rules.inline.blockSkip.exec(n))!=null;)s=i[2]?i[2].length:0,n=n.slice(0,i.index+s)+"["+"a".repeat(i[0].length-s-2)+"]"+n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);n=((u=(c=this.options.hooks)==null?void 0:c.emStrongMask)==null?void 0:u.call({lexer:this},n))??n;let o=!1,a="";for(;t;){o||(a=""),o=!1;let m;if((f=(h=this.options.extensions)==null?void 0:h.inline)!=null&&f.some(x=>(m=x.call({lexer:this},t,e))?(t=t.substring(m.raw.length),e.push(m),!0):!1))continue;if(m=this.tokenizer.escape(t)){t=t.substring(m.raw.length),e.push(m);continue}if(m=this.tokenizer.tag(t)){t=t.substring(m.raw.length),e.push(m);continue}if(m=this.tokenizer.link(t)){t=t.substring(m.raw.length),e.push(m);continue}if(m=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(m.raw.length);let x=e.at(-1);m.type==="text"&&(x==null?void 0:x.type)==="text"?(x.raw+=m.raw,x.text+=m.text):e.push(m);continue}if(m=this.tokenizer.emStrong(t,n,a)){t=t.substring(m.raw.length),e.push(m);continue}if(m=this.tokenizer.codespan(t)){t=t.substring(m.raw.length),e.push(m);continue}if(m=this.tokenizer.br(t)){t=t.substring(m.raw.length),e.push(m);continue}if(m=this.tokenizer.del(t,n,a)){t=t.substring(m.raw.length),e.push(m);continue}if(m=this.tokenizer.autolink(t)){t=t.substring(m.raw.length),e.push(m);continue}if(!this.state.inLink&&(m=this.tokenizer.url(t))){t=t.substring(m.raw.length),e.push(m);continue}let E=t;if((y=this.options.extensions)!=null&&y.startInline){let x=1/0,I=t.slice(1),P;this.options.extensions.startInline.forEach(R=>{P=R.call({lexer:this},I),typeof P=="number"&&P>=0&&(x=Math.min(x,P))}),x<1/0&&x>=0&&(E=t.substring(0,x+1))}if(m=this.tokenizer.inlineText(E)){t=t.substring(m.raw.length),m.raw.slice(-1)!=="_"&&(a=m.raw.slice(-1)),o=!0;let x=e.at(-1);(x==null?void 0:x.type)==="text"?(x.raw+=m.raw,x.text+=m.text):e.push(m);continue}if(t){let x="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(x);break}else throw new Error(x)}}return e}},ec=class{constructor(r){g(this,"options");g(this,"parser");this.options=r||ai}space(r){return""}code({text:r,lang:t,escaped:e}){var s;let n=(s=(t||"").match(et.notSpaceStart))==null?void 0:s[0],i=r.replace(et.endingNewline,"")+`
|
|
494
|
-
`;return n?'<pre><code class="language-'+Vt(n)+'">'+(e?i:Vt(i,!0))+`</code></pre>
|
|
495
|
-
`:"<pre><code>"+(e?i:Vt(i,!0))+`</code></pre>
|
|
496
|
-
`}blockquote({tokens:r}){return`<blockquote>
|
|
497
|
-
${this.parser.parse(r)}</blockquote>
|
|
498
|
-
`}html({text:r}){return r}def(r){return""}heading({tokens:r,depth:t}){return`<h${t}>${this.parser.parseInline(r)}</h${t}>
|
|
499
|
-
`}hr(r){return`<hr>
|
|
500
|
-
`}list(r){let t=r.ordered,e=r.start,n="";for(let o=0;o<r.items.length;o++){let a=r.items[o];n+=this.listitem(a)}let i=t?"ol":"ul",s=t&&e!==1?' start="'+e+'"':"";return"<"+i+s+`>
|
|
501
|
-
`+n+"</"+i+`>
|
|
502
|
-
`}listitem(r){return`<li>${this.parser.parse(r.tokens)}</li>
|
|
503
|
-
`}checkbox({checked:r}){return"<input "+(r?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:r}){return`<p>${this.parser.parseInline(r)}</p>
|
|
504
|
-
`}table(r){let t="",e="";for(let i=0;i<r.header.length;i++)e+=this.tablecell(r.header[i]);t+=this.tablerow({text:e});let n="";for(let i=0;i<r.rows.length;i++){let s=r.rows[i];e="";for(let o=0;o<s.length;o++)e+=this.tablecell(s[o]);n+=this.tablerow({text:e})}return n&&(n=`<tbody>${n}</tbody>`),`<table>
|
|
505
|
-
<thead>
|
|
506
|
-
`+t+`</thead>
|
|
507
|
-
`+n+`</table>
|
|
508
|
-
`}tablerow({text:r}){return`<tr>
|
|
509
|
-
${r}</tr>
|
|
510
|
-
`}tablecell(r){let t=this.parser.parseInline(r.tokens),e=r.header?"th":"td";return(r.align?`<${e} align="${r.align}">`:`<${e}>`)+t+`</${e}>
|
|
511
|
-
`}strong({tokens:r}){return`<strong>${this.parser.parseInline(r)}</strong>`}em({tokens:r}){return`<em>${this.parser.parseInline(r)}</em>`}codespan({text:r}){return`<code>${Vt(r,!0)}</code>`}br(r){return"<br>"}del({tokens:r}){return`<del>${this.parser.parseInline(r)}</del>`}link({href:r,title:t,tokens:e}){let n=this.parser.parseInline(e),i=Qm(r);if(i===null)return n;r=i;let s='<a href="'+r+'"';return t&&(s+=' title="'+Vt(t)+'"'),s+=">"+n+"</a>",s}image({href:r,title:t,text:e,tokens:n}){n&&(e=this.parser.parseInline(n,this.parser.textRenderer));let i=Qm(r);if(i===null)return Vt(e);r=i;let s=`<img src="${r}" alt="${Vt(e)}"`;return t&&(s+=` title="${Vt(t)}"`),s+=">",s}text(r){return"tokens"in r&&r.tokens?this.parser.parseInline(r.tokens):"escaped"in r&&r.escaped?r.text:Vt(r.text)}},wp=class{strong({text:r}){return r}em({text:r}){return r}codespan({text:r}){return r}del({text:r}){return r}html({text:r}){return r}text({text:r}){return r}link({text:r}){return""+r}image({text:r}){return""+r}br(){return""}checkbox({raw:r}){return r}},Ot=class dd{constructor(t){g(this,"options");g(this,"renderer");g(this,"textRenderer");this.options=t||ai,this.options.renderer=this.options.renderer||new ec,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new wp}static parse(t,e){return new dd(e).parse(t)}static parseInline(t,e){return new dd(e).parseInline(t)}parse(t){var n,i;this.renderer.parser=this;let e="";for(let s=0;s<t.length;s++){let o=t[s];if((i=(n=this.options.extensions)==null?void 0:n.renderers)!=null&&i[o.type]){let c=o,u=this.options.extensions.renderers[c.type].call({parser:this},c);if(u!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(c.type)){e+=u||"";continue}}let a=o;switch(a.type){case"space":{e+=this.renderer.space(a);break}case"hr":{e+=this.renderer.hr(a);break}case"heading":{e+=this.renderer.heading(a);break}case"code":{e+=this.renderer.code(a);break}case"table":{e+=this.renderer.table(a);break}case"blockquote":{e+=this.renderer.blockquote(a);break}case"list":{e+=this.renderer.list(a);break}case"checkbox":{e+=this.renderer.checkbox(a);break}case"html":{e+=this.renderer.html(a);break}case"def":{e+=this.renderer.def(a);break}case"paragraph":{e+=this.renderer.paragraph(a);break}case"text":{e+=this.renderer.text(a);break}default:{let c='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(c),"";throw new Error(c)}}}return e}parseInline(t,e=this.renderer){var i,s;this.renderer.parser=this;let n="";for(let o=0;o<t.length;o++){let a=t[o];if((s=(i=this.options.extensions)==null?void 0:i.renderers)!=null&&s[a.type]){let u=this.options.extensions.renderers[a.type].call({parser:this},a);if(u!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(a.type)){n+=u||"";continue}}let c=a;switch(c.type){case"escape":{n+=e.text(c);break}case"html":{n+=e.html(c);break}case"link":{n+=e.link(c);break}case"image":{n+=e.image(c);break}case"checkbox":{n+=e.checkbox(c);break}case"strong":{n+=e.strong(c);break}case"em":{n+=e.em(c);break}case"codespan":{n+=e.codespan(c);break}case"br":{n+=e.br(c);break}case"del":{n+=e.del(c);break}case"text":{n+=e.text(c);break}default:{let u='Token with "'+c.type+'" type was not found.';if(this.options.silent)return console.error(u),"";throw new Error(u)}}}return n}},ll,no=(ll=class{constructor(r){g(this,"options");g(this,"block");this.options=r||ai}preprocess(r){return r}postprocess(r){return r}processAllTokens(r){return r}emStrongMask(r){return r}provideLexer(){return this.block?zt.lex:zt.lexInline}provideParser(){return this.block?Ot.parse:Ot.parseInline}},g(ll,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),g(ll,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),ll),W6=class{constructor(...r){g(this,"defaults",dp());g(this,"options",this.setOptions);g(this,"parse",this.parseMarkdown(!0));g(this,"parseInline",this.parseMarkdown(!1));g(this,"Parser",Ot);g(this,"Renderer",ec);g(this,"TextRenderer",wp);g(this,"Lexer",zt);g(this,"Tokenizer",Ql);g(this,"Hooks",no);this.use(...r)}walkTokens(r,t){var n,i;let e=[];for(let s of r)switch(e=e.concat(t.call(this,s)),s.type){case"table":{let o=s;for(let a of o.header)e=e.concat(this.walkTokens(a.tokens,t));for(let a of o.rows)for(let c of a)e=e.concat(this.walkTokens(c.tokens,t));break}case"list":{let o=s;e=e.concat(this.walkTokens(o.items,t));break}default:{let o=s;(i=(n=this.defaults.extensions)==null?void 0:n.childTokens)!=null&&i[o.type]?this.defaults.extensions.childTokens[o.type].forEach(a=>{let c=o[a].flat(1/0);e=e.concat(this.walkTokens(c,t))}):o.tokens&&(e=e.concat(this.walkTokens(o.tokens,t)))}}return e}use(...r){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return r.forEach(e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(i=>{if(!i.name)throw new Error("extension name required");if("renderer"in i){let s=t.renderers[i.name];s?t.renderers[i.name]=function(...o){let a=i.renderer.apply(this,o);return a===!1&&(a=s.apply(this,o)),a}:t.renderers[i.name]=i.renderer}if("tokenizer"in i){if(!i.level||i.level!=="block"&&i.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let s=t[i.level];s?s.unshift(i.tokenizer):t[i.level]=[i.tokenizer],i.start&&(i.level==="block"?t.startBlock?t.startBlock.push(i.start):t.startBlock=[i.start]:i.level==="inline"&&(t.startInline?t.startInline.push(i.start):t.startInline=[i.start]))}"childTokens"in i&&i.childTokens&&(t.childTokens[i.name]=i.childTokens)}),n.extensions=t),e.renderer){let i=this.defaults.renderer||new ec(this.defaults);for(let s in e.renderer){if(!(s in i))throw new Error(`renderer '${s}' does not exist`);if(["options","parser"].includes(s))continue;let o=s,a=e.renderer[o],c=i[o];i[o]=(...u)=>{let h=a.apply(i,u);return h===!1&&(h=c.apply(i,u)),h||""}}n.renderer=i}if(e.tokenizer){let i=this.defaults.tokenizer||new Ql(this.defaults);for(let s in e.tokenizer){if(!(s in i))throw new Error(`tokenizer '${s}' does not exist`);if(["options","rules","lexer"].includes(s))continue;let o=s,a=e.tokenizer[o],c=i[o];i[o]=(...u)=>{let h=a.apply(i,u);return h===!1&&(h=c.apply(i,u)),h}}n.tokenizer=i}if(e.hooks){let i=this.defaults.hooks||new no;for(let s in e.hooks){if(!(s in i))throw new Error(`hook '${s}' does not exist`);if(["options","block"].includes(s))continue;let o=s,a=e.hooks[o],c=i[o];no.passThroughHooks.has(s)?i[o]=u=>{if(this.defaults.async&&no.passThroughHooksRespectAsync.has(s))return(async()=>{let f=await a.call(i,u);return c.call(i,f)})();let h=a.call(i,u);return c.call(i,h)}: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 h=a.apply(i,u);return h===!1&&(h=c.apply(i,u)),h}}n.hooks=i}if(e.walkTokens){let i=this.defaults.walkTokens,s=e.walkTokens;n.walkTokens=function(o){let a=[];return a.push(s.call(this,o)),i&&(a=a.concat(i.call(this,o))),a}}this.defaults={...this.defaults,...n}}),this}setOptions(r){return this.defaults={...this.defaults,...r},this}lexer(r,t){return zt.lex(r,t??this.defaults)}parser(r,t){return Ot.parse(r,t??this.defaults)}parseMarkdown(r){return(t,e)=>{let n={...e},i={...this.defaults,...n},s=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&n.async===!1)return s(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof t>"u"||t===null)return s(new Error("marked(): input parameter is undefined or null"));if(typeof t!="string")return s(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(i.hooks&&(i.hooks.options=i,i.hooks.block=r),i.async)return(async()=>{let o=i.hooks?await i.hooks.preprocess(t):t,a=await(i.hooks?await i.hooks.provideLexer():r?zt.lex:zt.lexInline)(o,i),c=i.hooks?await i.hooks.processAllTokens(a):a;i.walkTokens&&await Promise.all(this.walkTokens(c,i.walkTokens));let u=await(i.hooks?await i.hooks.provideParser():r?Ot.parse:Ot.parseInline)(c,i);return i.hooks?await i.hooks.postprocess(u):u})().catch(s);try{i.hooks&&(t=i.hooks.preprocess(t));let o=(i.hooks?i.hooks.provideLexer():r?zt.lex:zt.lexInline)(t,i);i.hooks&&(o=i.hooks.processAllTokens(o)),i.walkTokens&&this.walkTokens(o,i.walkTokens);let a=(i.hooks?i.hooks.provideParser():r?Ot.parse:Ot.parseInline)(o,i);return i.hooks&&(a=i.hooks.postprocess(a)),a}catch(o){return s(o)}}}onError(r,t){return e=>{if(e.message+=`
|
|
512
|
-
Please report this to https://github.com/markedjs/marked.`,r){let n="<p>An error occurred:</p><pre>"+Vt(e.message+"",!0)+"</pre>";return t?Promise.resolve(n):n}if(t)return Promise.reject(e);throw e}}},ri=new W6;function re(r,t){return ri.parse(r,t)}re.options=re.setOptions=function(r){return ri.setOptions(r),re.defaults=ri.defaults,H0(re.defaults),re};re.getDefaults=dp;re.defaults=ai;re.use=function(...r){return ri.use(...r),re.defaults=ri.defaults,H0(re.defaults),re};re.walkTokens=function(r,t){return ri.walkTokens(r,t)};re.parseInline=ri.parseInline;re.Parser=Ot;re.parser=Ot.parse;re.Renderer=ec;re.TextRenderer=wp;re.Lexer=zt;re.lexer=zt.lex;re.Tokenizer=Ql;re.Hooks=no;re.parse=re;re.options;re.setOptions;re.use;re.walkTokens;re.parseInline;Ot.parse;zt.lex;F0.addHook("afterSanitizeAttributes",r=>{r.tagName==="A"&&(r.setAttribute("target","_blank"),r.setAttribute("rel","noopener noreferrer"))});function B6(r){const t=re.parse(r,{async:!1});return F0.sanitize(t,{USE_PROFILES:{html:!0}})}var ga,$r,sr,or,Qr,J0,Dl;class pd extends ys{constructor(){super(...arguments);w(this,Qr);g(this,"phase","thinking");g(this,"toolCalls",[]);g(this,"expanded",!1);g(this,"expandedTexts",new Set);w(this,ga,`agent-activity-panel-${++G6}`);g(this,"overflowingTexts",new Set);w(this,$r,null);w(this,sr,null);w(this,or,null);g(this,"handleToggle",()=>{this.toolCalls.length!==0&&(this.expanded=!this.expanded)})}changed(e){Be(this.template(),this),p(this,Qr,J0).call(this),l(this,sr)!==null&&cancelAnimationFrame(l(this,sr)),b(this,sr,requestAnimationFrame(()=>{b(this,sr,null),p(this,Qr,Dl).call(this)})),e.has("expanded")&&(l(this,or)!==null&&clearTimeout(l(this,or)),b(this,or,window.setTimeout(()=>{b(this,or,null),p(this,Qr,Dl).call(this)},j6)))}disconnected(){var e;(e=l(this,$r))==null||e.disconnect(),b(this,$r,null),l(this,sr)!==null&&(cancelAnimationFrame(l(this,sr)),b(this,sr,null)),l(this,or)!==null&&(clearTimeout(l(this,or)),b(this,or,null))}template(){const e=this.toolCalls.length>0;return D`
|
|
513
|
-
${this.barTemplate()}
|
|
514
|
-
${e?this.panelTemplate():null}
|
|
515
|
-
`}barTemplate(){return this.phase==="thinking"?D`<div class="bar bar-static" unselectable>${this.indicator()}${this.label({expanded:this.expanded})}</div>`:D`
|
|
516
|
-
<button
|
|
517
|
-
type="button"
|
|
518
|
-
variant="ghost"
|
|
519
|
-
class="bar"
|
|
520
|
-
unselectable
|
|
521
|
-
aria-expanded=${this.expanded?"true":"false"}
|
|
522
|
-
aria-controls=${l(this,ga)}
|
|
523
|
-
@click=${this.handleToggle}
|
|
524
|
-
>
|
|
525
|
-
${this.indicator()}${this.label({expanded:this.expanded})}
|
|
526
|
-
</button>
|
|
527
|
-
`}panelTemplate(){return D`
|
|
528
|
-
<div
|
|
529
|
-
class="panel"
|
|
530
|
-
id=${l(this,ga)}
|
|
531
|
-
role="region"
|
|
532
|
-
?inert=${!this.expanded}
|
|
533
|
-
aria-hidden=${this.expanded?"false":"true"}
|
|
534
|
-
>
|
|
535
|
-
<div class="panel-inner">
|
|
536
|
-
<ol class="tool-list">
|
|
537
|
-
${this.toolCalls.map(e=>this.toolItemTemplate(e))}
|
|
538
|
-
</ol>
|
|
539
|
-
</div>
|
|
540
|
-
</div>
|
|
541
|
-
`}toolItemTemplate(e){const n=this.expandedTexts.has(e.toolCallId),i=this.overflowingTexts.has(e.toolCallId),s=n?"Show less":"Show more";return D`
|
|
542
|
-
<li class="tool-item">
|
|
543
|
-
<span
|
|
544
|
-
class="tool-dot"
|
|
545
|
-
data-status=${e.status}
|
|
546
|
-
role="img"
|
|
547
|
-
aria-label=${q6(e.status)}
|
|
548
|
-
></span>
|
|
549
|
-
<span class="tool-title">${e.title}</span>
|
|
550
|
-
${e.text?D`
|
|
551
|
-
<div class="tool-output">
|
|
552
|
-
<pre
|
|
553
|
-
class="tool-text"
|
|
554
|
-
data-tool-call-id=${e.toolCallId}
|
|
555
|
-
?data-expanded=${n}
|
|
556
|
-
>${e.text}</pre>
|
|
557
|
-
${i?D`<button
|
|
558
|
-
type="button"
|
|
559
|
-
variant="ghost"
|
|
560
|
-
class="tool-text-toggle"
|
|
561
|
-
@click=${()=>this.toggleTextExpand(e.toolCallId)}
|
|
562
|
-
>
|
|
563
|
-
<span>${s}</span>
|
|
564
|
-
${n?eM({size:16}):Kl({size:16})}
|
|
565
|
-
</button>`:null}
|
|
566
|
-
</div>
|
|
567
|
-
`:null}
|
|
568
|
-
</li>
|
|
569
|
-
`}toggleTextExpand(e){const n=new Set(this.expandedTexts);n.has(e)?n.delete(e):n.add(e),this.expandedTexts=n}indicator(){if(this.expanded)return D`<span class="indicator">${Kl({size:16})}</span>`;const e=this.phase==="thinking"||this.phase==="using";return D`<span class=${e?"indicator indicator-active":"indicator"}
|
|
570
|
-
>${e?Ow({size:16}):sM({size:16})}</span>`}label(e){var s;if(this.phase==="thinking")return"Thinking…";const n=this.toolCalls.length;if(this.phase==="using"){if(e.expanded)return`Using ${n} ${n===1?"tool":"tools"}…`;const o=[...this.toolCalls].reverse().find(c=>c.status==="in_progress"),a=(o==null?void 0:o.toolKind)??((s=this.toolCalls.at(-1))==null?void 0:s.toolKind)??"other";return V6(a)}return`${e.expanded?"Showing":"Used"} ${n} ${n===1?"tool":"tools"}`}}ga=new WeakMap,$r=new WeakMap,sr=new WeakMap,or=new WeakMap,Qr=new WeakSet,J0=function(){if(!(typeof ResizeObserver>"u")){l(this,$r)||b(this,$r,new ResizeObserver(()=>p(this,Qr,Dl).call(this))),l(this,$r).disconnect();for(const e of this.querySelectorAll(".tool-text"))l(this,$r).observe(e)}},Dl=function(){const e=new Set;for(const n of this.querySelectorAll(".tool-text")){const i=n.dataset.toolCallId;if(i){if(this.expandedTexts.has(i)){e.add(i);continue}n.scrollHeight>n.clientHeight+1&&e.add(i)}}Y6(this.overflowingTexts,e)||(this.overflowingTexts=e)},g(pd,"properties",["phase","toolCalls","expanded","expandedTexts","overflowingTexts"]),g(pd,"attributes",{expanded:{type:Boolean}});function V6(r){switch(r){case"read":return"Reading files…";case"edit":return"Editing files…";case"delete":return"Deleting files…";case"move":return"Moving files…";case"search":return"Searching files…";case"execute":return"Running commands…";case"think":return"Thinking…";case"fetch":return"Fetching content…";case"switch_mode":return"Switching modes…";default:return"Working…"}}const j6=160;let G6=0;function q6(r){switch(r){case"completed":return"Completed";case"failed":return"Failed";case"in_progress":return"In progress";default:return"Pending"}}function Y6(r,t){if(r.size!==t.size)return!1;for(const e of r)if(!t.has(e))return!1;return!0}customElements.define("agent-activity",pd);function K6(r){const t=[];let e=0;for(;e<r.length;)if(r[e].kind==="tool_call"){const i=[];for(;e<r.length&&r[e].kind==="tool_call";)i.push(r[e]),e+=1;const s=e>=r.length;t.push({kind:"tool-run",toolCalls:i,live:s})}else t.push({kind:"message",message:r[e]}),e+=1;const n=r[r.length-1];return n&&n.kind==="user"&&t.push({kind:"thinking"}),t}const rv=8,nv=new WeakMap;function J6(r){const t=nv.get(r);if(t&&t.text===r.text)return t.html;const e=B6(r.text);return nv.set(r,{text:r.text,html:e}),e}function iv(r){for(let t=r.length-1;t>=0;t-=1){const e=r[t];if(e&&e.kind==="user")return e.id}return null}var vt,yt,qn,Yn,Jr,kt,Q0,fd,eS,fc,gc,gd;class X0 extends ys{constructor(){super(...arguments);w(this,kt);g(this,"messages",[]);w(this,vt,!0);w(this,yt,null);w(this,qn,null);w(this,Yn,null);w(this,Jr,!1);w(this,fc,()=>{if(l(this,Jr))return;const e=l(this,yt);if(!e)return;const i=e.scrollHeight-e.clientHeight-e.scrollTop<=rv;i!==l(this,vt)&&(b(this,vt,i),this.toggleAttribute("data-pinned",i))});w(this,gc,()=>{b(this,vt,!0),this.toggleAttribute("data-pinned",!0),p(this,kt,gd).call(this,!0)})}changed(e){let n=!1;if(e.has("messages")){const i=e.get("messages")??[],s=iv(this.messages);n=s!==null&&s!==iv(i),n&&b(this,vt,!0)}Be(this.template(),this),l(this,yt)||(b(this,yt,this.querySelector(".history-scroll")),l(this,yt)&&p(this,kt,Q0).call(this)),this.toggleAttribute("data-pinned",l(this,vt)),p(this,kt,fd).call(this),p(this,kt,gd).call(this,n)}disconnected(){var e,n;(e=l(this,qn))==null||e.disconnect(),b(this,qn,null),(n=l(this,Yn))==null||n.disconnect(),b(this,Yn,null)}template(){const e=K6(this.messages);return D`
|
|
571
|
-
<div class="history-scroll" @scroll=${l(this,fc)}>
|
|
572
|
-
${e.map(n=>{if(n.kind==="tool-run")return D`<agent-activity
|
|
573
|
-
.phase=${n.live?"using":"final"}
|
|
574
|
-
.toolCalls=${n.toolCalls}
|
|
575
|
-
></agent-activity>`;if(n.kind==="thinking")return D`<agent-activity
|
|
576
|
-
.phase=${"thinking"}
|
|
577
|
-
.toolCalls=${[]}
|
|
578
|
-
></agent-activity>`;const i=n.message,s=i.kind==="assistant"?UO(J6(i)):i.text;return D`<div
|
|
579
|
-
class="message message-${i.kind}"
|
|
580
|
-
data-message-id=${i.id}
|
|
581
|
-
>${s}</div>`})}
|
|
582
|
-
</div>
|
|
583
|
-
<button
|
|
584
|
-
type="button"
|
|
585
|
-
class="history-jump"
|
|
586
|
-
aria-label="Jump to latest message"
|
|
587
|
-
@click=${l(this,gc)}
|
|
588
|
-
>
|
|
589
|
-
${Kl({size:16})}
|
|
590
|
-
</button>
|
|
591
|
-
`}}vt=new WeakMap,yt=new WeakMap,qn=new WeakMap,Yn=new WeakMap,Jr=new WeakMap,kt=new WeakSet,Q0=function(){l(this,yt)&&(typeof ResizeObserver>"u"||(b(this,qn,new ResizeObserver(()=>p(this,kt,eS).call(this))),b(this,Yn,new MutationObserver(()=>p(this,kt,fd).call(this))),l(this,Yn).observe(l(this,yt),{childList:!0})))},fd=function(){const e=l(this,yt),n=l(this,qn);if(!(!e||!n)){n.disconnect();for(const i of Array.from(e.children))n.observe(i)}},eS=function(){const e=l(this,yt);if(!e)return;if(l(this,vt)){b(this,Jr,!0),e.scrollTop=e.scrollHeight-e.clientHeight,requestAnimationFrame(()=>{b(this,Jr,!1)});return}const i=e.scrollHeight-e.clientHeight-e.scrollTop<=rv;i!==l(this,vt)&&(b(this,vt,i),this.toggleAttribute("data-pinned",i))},fc=new WeakMap,gc=new WeakMap,gd=function(e){requestAnimationFrame(()=>{const n=l(this,yt);n&&(!l(this,vt)&&!e||(b(this,Jr,!0),n.scrollTop=n.scrollHeight-n.clientHeight,requestAnimationFrame(()=>{b(this,Jr,!1)})))})},g(X0,"properties",["messages"]);customElements.define("message-history",X0);var Lt,ma,ls,ar,cs,us,va,hs,mc,vc,yc,bt,zl,ya,vd,yd,ba,wa;class md extends ys{constructor(){super(...arguments);w(this,bt);g(this,"placeholder","What do you want to do?");g(this,"open",!1);g(this,"messages",[]);g(this,"status","disconnected");w(this,Lt,hr.resolve("ServerManager"));w(this,ma,hr.resolve("ShortcutService"));w(this,ls,null);w(this,ar,null);w(this,cs,()=>{var e;this.status=((e=l(this,ar))==null?void 0:e.status)??"disconnected"});w(this,us,()=>{var e;this.messages=((e=l(this,ar))==null?void 0:e.messages)??[]});w(this,va,()=>{var e,n;(e=l(this,ar))==null||e.removeEventListener("status-changed",l(this,cs)),(n=l(this,ar))==null||n.removeEventListener("messages-changed",l(this,us)),b(this,ar,null)});w(this,hs,()=>{var n;const e=((n=l(this,Lt).activeServer)==null?void 0:n.acpClient)??null;e!==l(this,ar)&&(l(this,va).call(this),b(this,ar,e),e==null||e.addEventListener("status-changed",l(this,cs)),e==null||e.addEventListener("messages-changed",l(this,us)),l(this,cs).call(this),l(this,us).call(this),e!=null&&e.enabled&&e.status==="disconnected"&&e.connect().catch(i=>{console.error("ACPClient.connect() failed",i)}))});g(this,"handleTriggerActivate",()=>{var n;const e=(n=l(this,Lt).activeServer)==null?void 0:n.acpClient;e&&!e.enabled||(this.open=!0)});g(this,"handleKeydown",e=>{var o;if(e.key!=="Enter"||e.shiftKey)return;const n=e.currentTarget,i=n.value.trim();if(e.preventDefault(),!i)return;n.value="",p(this,bt,zl).call(this,n);const s=(o=l(this,Lt).activeServer)==null?void 0:o.acpClient;if(s!=null&&s.enabled){if(i==="/new"){s.startNewSession().catch(a=>{console.error("ACPClient.startNewSession() failed",a)});return}s.sendMessage({text:i}).catch(a=>{console.error("ACPClient.sendMessage() failed",a)})}});w(this,mc,e=>{p(this,bt,zl).call(this,e.currentTarget)});w(this,vc,e=>{var i;e.stopPropagation();const n=(i=l(this,Lt).activeServer)==null?void 0:i.acpClient;n&&n.cancel().catch(s=>{console.error("ACPClient.cancel() failed",s)})});w(this,yc,e=>{if(e.target instanceof HTMLTextAreaElement)return;const n=e.currentTarget.querySelector("textarea");n==null||n.focus()});w(this,ya,e=>{var s;if(e.shortcut!=="focusCommandInput")return;const n=(s=l(this,Lt).activeServer)==null?void 0:s.acpClient;if(n&&!n.enabled)return;if(!this.open){this.open=!0;return}const i=this.querySelector("textarea");if(i){if(document.activeElement===i){this.open=!1;return}i.focus()}});w(this,ba,e=>{e.target instanceof Node&&(this.contains(e.target)||(this.open=!1))});w(this,wa,e=>{e.key==="Escape"&&(this.open=!1)})}connected(){const e=new DisposableStack;b(this,ls,e),l(this,Lt).addEventListener("change",l(this,hs)),e.defer(()=>{l(this,Lt).removeEventListener("change",l(this,hs)),l(this,va).call(this)}),l(this,hs).call(this),l(this,ma).addEventListener("shortcut-triggered",l(this,ya)),e.defer(()=>l(this,ma).removeEventListener("shortcut-triggered",l(this,ya))),this.open&&p(this,bt,vd).call(this)}disconnected(){var e;(e=l(this,ls))==null||e.dispose(),b(this,ls,null),p(this,bt,yd).call(this)}changed(e){if(this.open&&this.status!=="disconnected"?(this.removeAttribute("material"),this.removeAttribute("tone"),this.removeAttribute("level")):(this.setAttribute("material","paper"),this.setAttribute("tone","dark"),this.setAttribute("level","overlay")),Be(this.template(),this),e.has("open"))if(this.open){p(this,bt,vd).call(this);const n=this.querySelector("textarea");n&&(p(this,bt,zl).call(this,n),n.focus())}else p(this,bt,yd).call(this)}template(){var i;const e=(i=l(this,Lt).activeServer)==null?void 0:i.acpClient;if(e&&!e.enabled||this.status==="disposed")return null;if(this.status==="disconnected")return D`
|
|
592
|
-
<div class="connecting" aria-disabled="true">
|
|
593
|
-
<ui-spinner size="16" weight="bold"></ui-spinner>
|
|
594
|
-
<span class="label">Connecting<span class="dots" aria-hidden="true"></span></span>
|
|
595
|
-
</div>
|
|
596
|
-
`;if(this.open){const s=this.status==="running"||this.status==="cancelling",o=this.status==="cancelling";return D`
|
|
597
|
-
<div class="open">
|
|
598
|
-
<div
|
|
599
|
-
class="chat"
|
|
600
|
-
material="paper"
|
|
601
|
-
tone="dark"
|
|
602
|
-
level="overlay"
|
|
603
|
-
>
|
|
604
|
-
<message-history selectable .messages=${this.messages}></message-history>
|
|
605
|
-
</div>
|
|
606
|
-
<div
|
|
607
|
-
class="input"
|
|
608
|
-
material="paper"
|
|
609
|
-
tone="dark"
|
|
610
|
-
level="overlay"
|
|
611
|
-
@click=${l(this,yc)}
|
|
612
|
-
>
|
|
613
|
-
<textarea
|
|
614
|
-
class="textarea"
|
|
615
|
-
rows="1"
|
|
616
|
-
@keydown=${this.handleKeydown}
|
|
617
|
-
@input=${l(this,mc)}
|
|
618
|
-
></textarea>
|
|
619
|
-
${s?D`
|
|
620
|
-
<button
|
|
621
|
-
type="button"
|
|
622
|
-
icon-only
|
|
623
|
-
variant="ghost"
|
|
624
|
-
aria-label=${o?"Cancelling…":"Stop generating"}
|
|
625
|
-
?disabled=${o}
|
|
626
|
-
@click=${l(this,vc)}
|
|
627
|
-
>
|
|
628
|
-
${o?D`<ui-spinner size="16" weight="bold"></ui-spinner>`:QO({size:16})}
|
|
629
|
-
</button>
|
|
630
|
-
`:null}
|
|
631
|
-
</div>
|
|
632
|
-
</div>
|
|
633
|
-
`}return D`
|
|
634
|
-
<div
|
|
635
|
-
class="trigger"
|
|
636
|
-
tabindex="0"
|
|
637
|
-
role="button"
|
|
638
|
-
@click=${this.handleTriggerActivate}
|
|
639
|
-
@focus=${this.handleTriggerActivate}
|
|
640
|
-
>
|
|
641
|
-
<span class="label">${this.placeholder}</span>
|
|
642
|
-
<span class="kbd" aria-hidden="true">⌘K</span>
|
|
643
|
-
</div>
|
|
644
|
-
`}}Lt=new WeakMap,ma=new WeakMap,ls=new WeakMap,ar=new WeakMap,cs=new WeakMap,us=new WeakMap,va=new WeakMap,hs=new WeakMap,mc=new WeakMap,vc=new WeakMap,yc=new WeakMap,bt=new WeakSet,zl=function(e){e.style.height="auto",e.style.height=`${e.scrollHeight}px`},ya=new WeakMap,vd=function(){document.addEventListener("mousedown",l(this,ba)),document.addEventListener("keydown",l(this,wa))},yd=function(){document.removeEventListener("mousedown",l(this,ba)),document.removeEventListener("keydown",l(this,wa))},ba=new WeakMap,wa=new WeakMap,g(md,"properties",["placeholder","open","messages","status"]),g(md,"attributes",{placeholder:{type:String},open:{type:Boolean}});customElements.define("command-panel",md);const X6='<path d="M128,112a28,28,0,0,0-8,54.83V184a8,8,0,0,0,16,0V166.83A28,28,0,0,0,128,112Zm0,40a12,12,0,1,1,12-12A12,12,0,0,1,128,152Zm80-72H176V56a48,48,0,0,0-96,0V80H48A16,16,0,0,0,32,96V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V96A16,16,0,0,0,208,80ZM96,56a32,32,0,0,1,64,0V80H96ZM208,208H48V96H208V208Z"/>';class tS extends Event{constructor(e){super("auth-submit",{bubbles:!0,composed:!0});g(this,"token");this.token=e}}class Q6 extends HTMLElement{constructor(){super(...arguments);g(this,"_invalid",!1);g(this,"_tokenValue","")}set invalid(e){this._invalid=e,this.render()}get invalid(){return this._invalid}set tokenValue(e){this._tokenValue=e,this.render()}get tokenValue(){return this._tokenValue}connectedCallback(){this.render()}handleInput(e){const n=e.currentTarget;this._tokenValue=n.value}handleSubmit(e){e.preventDefault();const n=this._tokenValue.trim();n&&this.dispatchEvent(new tS(n))}render(){Be(D`
|
|
645
|
-
<modal-overlay open>
|
|
646
|
-
<system-modal material="glass-frosted" level="1" class="auth-modal">
|
|
647
|
-
<form class="auth-form" @submit=${n=>this.handleSubmit(n)}>
|
|
648
|
-
<header>
|
|
649
|
-
<span class="auth-modal-icon" aria-hidden="true">
|
|
650
|
-
<svg width="32" height="32" viewBox="0 0 256 256" fill="currentColor">${Dw(X6)}</svg>
|
|
651
|
-
</span>
|
|
652
|
-
<hgroup>
|
|
653
|
-
<h2>Enter access token</h2>
|
|
654
|
-
<p>${"This server requires an access token to connect."}</p>
|
|
655
|
-
</hgroup>
|
|
656
|
-
</header>
|
|
657
|
-
<div class="auth-input-row">
|
|
658
|
-
<input
|
|
659
|
-
class=${this.invalid?"auth-token-input auth-token-input-invalid":"auth-token-input"}
|
|
660
|
-
type="password"
|
|
661
|
-
name="token"
|
|
662
|
-
placeholder="paste token here"
|
|
663
|
-
aria-label="Access token"
|
|
664
|
-
.value=${this.tokenValue}
|
|
665
|
-
@input=${n=>this.handleInput(n)}
|
|
666
|
-
autofocus
|
|
667
|
-
required
|
|
668
|
-
/>
|
|
669
|
-
${this.invalid?D`<p class="auth-modal-error" role="alert">
|
|
670
|
-
The previous token was rejected. Try again.
|
|
671
|
-
</p>`:null}
|
|
672
|
-
</div>
|
|
673
|
-
<button variant="primary" class="auth-submit">
|
|
674
|
-
Connect
|
|
675
|
-
</button>
|
|
676
|
-
</form>
|
|
677
|
-
</system-modal>
|
|
678
|
-
</modal-overlay>
|
|
679
|
-
`,this)}}customElements.get("auth-modal")||customElements.define("auth-modal",Q6);const eU=250,tU=1e3;class rS extends HTMLElement{constructor(){super(...arguments);g(this,"_nextRetryAt",null);g(this,"_hasEverConnected",!1);g(this,"tickHandle",null)}set nextRetryAt(e){e!==this._nextRetryAt&&(this._nextRetryAt=e,this.updateTickerState(),this.render())}get nextRetryAt(){return this._nextRetryAt}set hasEverConnected(e){e!==this._hasEverConnected&&(this._hasEverConnected=e,this.render())}get hasEverConnected(){return this._hasEverConnected}connectedCallback(){if(this._nextRetryAt===null&&this.hasAttribute("next-retry-at")){const e=Number(this.getAttribute("next-retry-at"));this._nextRetryAt=Number.isFinite(e)?e:null}this.updateTickerState(),this.render()}disconnectedCallback(){this.stopTicker()}attributeChangedCallback(e,n,i){if(e==="next-retry-at"){if(i===null||i==="")this._nextRetryAt=null;else{const s=Number(i);this._nextRetryAt=Number.isFinite(s)?s:null}this.updateTickerState()}else e==="has-ever-connected"&&(this._hasEverConnected=i!==null&&i!=="false");this.render()}updateTickerState(){this._nextRetryAt!==null?this.startTicker():this.stopTicker()}startTicker(){this.tickHandle===null&&(this.tickHandle=setInterval(()=>{this.render()},eU))}stopTicker(){this.tickHandle!==null&&(clearInterval(this.tickHandle),this.tickHandle=null)}render(){const e=this._hasEverConnected,n=e?"Disconnected":"Connecting",i=this._nextRetryAt!==null?this.formatCountdown(this._nextRetryAt):"Reattempting now…";Be(D`
|
|
680
|
-
<modal-overlay open role="status" aria-live="polite">
|
|
681
|
-
<system-modal material="glass-frosted" level="1" class="connecting-overlay-panel">
|
|
682
|
-
<header>
|
|
683
|
-
<ui-spinner size="32"></ui-spinner>
|
|
684
|
-
<hgroup>
|
|
685
|
-
<h2>${n}</h2>
|
|
686
|
-
${e?D`<p>${i}</p>`:null}
|
|
687
|
-
</hgroup>
|
|
688
|
-
</header>
|
|
689
|
-
</system-modal>
|
|
690
|
-
</modal-overlay>
|
|
691
|
-
`,this)}formatCountdown(e){const n=e-Date.now();return n<=0?"Reattempting now…":`Reattempting in ${Math.ceil(n/tU)}s…`}}g(rS,"observedAttributes",["next-retry-at","has-ever-connected"]);customElements.get("connecting-overlay")||customElements.define("connecting-overlay",rS);class rU extends HTMLElement{constructor(){super(...arguments);g(this,"runtimeServerURL",Ab());g(this,"electronMode",cr());g(this,"serverManager",hr.resolve("ServerManager"));g(this,"screenManager",hr.resolve("ScreenManager"));g(this,"connectError",null);g(this,"topRowResizeObserver",null);g(this,"observedTopRow",null);g(this,"handleServerManagerChange",()=>{var e;this.clearStoredTokenIfUnauthorized(),this.connectError!==null&&((e=this.serverManager.activeServer)==null?void 0:e.status)==="connected"&&(this.connectError=null),this.render()});g(this,"handleScreenManagerChange",()=>{this.render()})}connectedCallback(){this.serverManager.addEventListener("change",this.handleServerManagerChange),this.screenManager.addEventListener("active-screen-changed",this.handleScreenManagerChange),this.screenManager.addEventListener("tabs-changed",this.handleScreenManagerChange),this.addEventListener("auth-submit",e=>{var i;const n=e instanceof tS?e.token:e instanceof CustomEvent&&typeof((i=e.detail)==null?void 0:i.token)=="string"?e.detail.token:null;n&&this.handleAuthSubmit(n)}),this.initializeConnection(),this.render()}disconnectedCallback(){var e;this.serverManager.removeEventListener("change",this.handleServerManagerChange),this.screenManager.removeEventListener("active-screen-changed",this.handleScreenManagerChange),this.screenManager.removeEventListener("tabs-changed",this.handleScreenManagerChange),(e=this.topRowResizeObserver)==null||e.disconnect(),this.topRowResizeObserver=null,this.observedTopRow=null}async initializeConnection(){const e=cL();if(this.electronMode){e&&(this.serverManager.setStoredAuthToken(this.runtimeServerURL,e),this.stripTokenQueryParam()),this.serverManager.connectConfiguredServers(this.runtimeServerURL,e);return}if(this.serverManager.activeServer)return;e&&(this.serverManager.setStoredAuthToken(this.runtimeServerURL,e),this.stripTokenQueryParam());const n=e??this.serverManager.getStoredAuthToken(this.runtimeServerURL),i=new xw({url:this.runtimeServerURL,name:"Server",token:n,telemetryMeta:this.serverManager.telemetryMeta});this.serverManager.add(i),this.serverManager.setActive(i);try{await i.connect(n),this.connectError=null}catch(s){this.connectError=s instanceof Error&&!(s instanceof ao)?s.message:null}this.render()}async handleAuthSubmit(e){const n=this.serverManager.activeServer;if(n){this.connectError=null,this.serverManager.setStoredAuthToken(n.url,e);try{await n.connect(e)}catch(i){i instanceof ao||(this.connectError=i instanceof Error?i.message:String(i))}this.render()}}stripTokenQueryParam(){const e=new URL(window.location.href);e.searchParams.delete("token"),window.history.replaceState({},"",`${e.pathname}${e.search}${e.hash}`)}clearStoredTokenIfUnauthorized(){const e=this.serverManager.activeServer;!e||e.status!=="unauthorized"||!e.token||!e.hasAuthRejected||(this.serverManager.clearStoredAuthToken(e.url),e.clearToken())}render(){const e=this.serverManager.activeServer,n=(e==null?void 0:e.status)??null,i=this.screenManager.activeScreen,s=!!(e&&i&&this.screenManager.hasTab(e.url,i.id));if(n==="unauthorized"){const h=e;if(!h)return;Be(D`
|
|
692
|
-
<main class="auth-gate">
|
|
693
|
-
<auth-modal
|
|
694
|
-
.invalid=${!!h.token}
|
|
695
|
-
.tokenValue=${h.token??""}
|
|
696
|
-
></auth-modal>
|
|
697
|
-
</main>
|
|
698
|
-
`,this),this.updateLayoutChromeBalance();return}const o=n==="disconnected",a=(e==null?void 0:e.hasEverConnected)??!1,u=n==="connected"||o&&a;Be(D`
|
|
699
|
-
<main>
|
|
700
|
-
${this.connectError?D`<p data-testid="auth-error">${this.connectError}</p>`:D`
|
|
701
|
-
${u?D`
|
|
702
|
-
<div class="top-row" electron-draggable>
|
|
703
|
-
<screen-select></screen-select>
|
|
704
|
-
</div>
|
|
705
|
-
`:null}
|
|
706
|
-
${s?D`<screen-view></screen-view>`:null}
|
|
707
|
-
${u&&(e!=null&&e.acpClient.enabled)?D`
|
|
708
|
-
<div class="command-panel-region">
|
|
709
|
-
<command-panel></command-panel>
|
|
710
|
-
</div>
|
|
711
|
-
`:null}
|
|
712
|
-
`}
|
|
713
|
-
${o?D`<connecting-overlay
|
|
714
|
-
.nextRetryAt=${(e==null?void 0:e.nextRetryAt)??null}
|
|
715
|
-
.hasEverConnected=${(e==null?void 0:e.hasEverConnected)??!1}
|
|
716
|
-
></connecting-overlay>`:null}
|
|
717
|
-
</main>
|
|
718
|
-
`,this),this.updateLayoutChromeBalance()}updateLayoutChromeBalance(){var o;const e=this.querySelector("main"),n=this.querySelector(".top-row"),i=this.querySelector(".command-panel-region"),s=n&&!i?n.getBoundingClientRect().height:0;e==null||e.style.setProperty("--layout-virtual-bottom-balance",`${s}px`),n!==this.observedTopRow&&((o=this.topRowResizeObserver)==null||o.disconnect(),this.observedTopRow=n,n&&typeof ResizeObserver<"u"?(this.topRowResizeObserver=new ResizeObserver(()=>this.updateLayoutChromeBalance()),this.topRowResizeObserver.observe(n)):this.topRowResizeObserver=null)}}customElements.get("television-app")||customElements.define("television-app",rU);const wo=cr(),Sp=Ab(),nS=new XT(wo?"television-electron":"television-browser",GT(Sp)),sv=kw(),nU=sv?vL({storage:sv,clientApp:wo?"desktop":"browser",desktopAppVersion:wo?uL():null}):null,ur=new gO({localStore:nS,localServerURL:Sp,telemetryMeta:nU}),iS=new a$({localStore:nS,serverManager:ur}),iU=new mO,sU=()=>{const r=[...ur.servers.values()].filter(t=>t.status==="connected");r.length!==0&&Promise.all(r.map(t=>t.client.artifacts.list())).then(t=>{const e=new Set(t.flatMap(({artifacts:n})=>n.map(i=>i.id)));TO(e)}).catch(()=>{})},sS=()=>{const r=ur.activeServer;if(!r||r.status!=="connected"){Hl();return}sU(),r.client.display.get().then(t=>{if(!(ur.activeServer!==r||r.status!=="connected"))return $w(t.activeThemeName,r)}).catch(()=>{ur.activeServer===r&&Hl()})};sS();ur.addEventListener("change",sS);ur.addEventListener("server-event",r=>{if(r.event.type!=="theme-changed")return;const t=ur.activeServer;!t||t.url!==r.serverURL||$w(r.event.themeName,t)});hr.register("ServerManager",()=>ur);hr.register("ScreenManager",()=>iS);hr.register("ShortcutService",()=>iU);globalThis.__telepath={screenManager:iS,serverManager:ur};const _p=document.createElement("television-app");_p.runtimeServerURL=Sp;_p.electronMode=wo;wo&&document.body.classList.add("electron");document.body.appendChild(_p);
|