@telepath-computer/television 0.1.176 → 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 yS=Object.defineProperty;var qp=r=>{throw TypeError(r)};var bS=(r,t,e)=>t in r?yS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var g=(r,t,e)=>bS(r,typeof t!="symbol"?t+"":t,e),Qc=(r,t,e)=>t.has(r)||qp("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)?qp("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 Yp,a as tu,b as Kp,c as Jp,d as Xp,e as wS,U as SS,f as Qp,g as ef,A as _S,h as kS,j as xS}from"./artifact-bridge-C0H5cXgO.js";import{m as ES,a as AS,b as TS}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 $S(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 tf=Object.prototype.toString,cv=function(t){var e=tf.call(t),n=e==="[object Arguments]";return n||(n=e!=="[object Array]"&&t!==null&&typeof t=="object"&&typeof t.length=="number"&&t.length>=0&&tf.call(t.callee)==="[object Function]"),n},ru,rf;function IS(){if(rf)return ru;rf=1;var r;if(!Object.keys){var t=Object.prototype.hasOwnProperty,e=Object.prototype.toString,n=cv,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 CS=Array.prototype.slice,RS=cv,nf=Object.keys,cl=nf?function(t){return nf(t)}:IS(),sf=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 RS(n)?sf(CS.call(n)):sf(n)})}else Object.keys=cl;return Object.keys||cl};var PS=cl,ul=Object.defineProperty||!1;if(ul)try{ul({},"a",{value:1})}catch{ul=!1}var Sa=ul,Rr=SyntaxError,K=TypeError,LS=Object.getOwnPropertyDescriptor,hl=LS;if(hl)try{hl([],"length")}catch{hl=null}var bs=hl,of=Sa,DS=Rr,fi=K,af=bs,uv=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=!!af&&af(t,e);if(of)of(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 DS("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},eh=Sa,hv=function(){return!!eh};hv.hasArrayLengthDefineBug=function(){if(!eh)return null;try{return eh([],"length",{value:1}).length!==1}catch{return!0}};var bc=hv,zS=PS,OS=typeof Symbol=="function"&&typeof Symbol("foo")=="symbol",MS=Object.prototype.toString,NS=Array.prototype.concat,lf=uv,US=function(r){return typeof r=="function"&&MS.call(r)==="[object Function]"},dv=bc(),FS=function(r,t,e,n){if(t in r){if(n===!0){if(r[t]===e)return}else if(!US(n)||!n())return}dv?lf(r,t,e,!0):lf(r,t,e)},pv=function(r,t){var e=arguments.length>2?arguments[2]:{},n=zS(t);OS&&(n=NS.call(n,Object.getOwnPropertySymbols(t)));for(var i=0;i<n.length;i+=1)FS(r,n[i],t[n[i]],e[n[i]])};pv.supportsDescriptors=!!dv;var ii=pv,dl={exports:{}};typeof self<"u"?dl.exports=self:typeof window<"u"?dl.exports=window:dl.exports=Function("return this")();var fv=dl.exports,HS=fv,gv=function(){return typeof _n!="object"||!_n||_n.Math!==Math||_n.Array!==Array?HS:_n},ZS=ii,WS=bs,BS=gv,VS=function(){var t=BS();if(ZS.supportsDescriptors){var e=WS(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},jS=ii,GS=fv,mv=gv,qS=VS,YS=mv(),vv=function(){return YS};jS(vv,{getPolyfill:mv,implementation:GS,shim:qS});var wd=vv,Pr=function(t){return!!t&&(typeof t=="function"||typeof t=="object")},Sd=Object,yv=Error,KS=EvalError,JS=RangeError,_d=ReferenceError,XS=URIError,QS=Math.abs,e_=Math.floor,t_=Math.max,r_=Math.min,n_=Math.pow,i_=Math.round,kd=Number.isNaN||function(t){return t!==t},s_=kd,o_=function(t){return s_(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},cf=typeof Symbol<"u"&&Symbol,a_=ws,xd=function(){return typeof cf!="function"||typeof Symbol!="function"||typeof cf("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:a_()},bv=typeof Reflect<"u"&&Reflect.getPrototypeOf||null,nu,uf;function wv(){if(uf)return nu;uf=1;var r=Sd;return nu=r.getPrototypeOf||null,nu}var l_="Function.prototype.bind called on incompatible ",c_=Object.prototype.toString,u_=Math.max,h_="[object Function]",hf=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},d_=function(t,e){for(var n=[],i=e,s=0;i<t.length;i+=1,s+=1)n[s]=t[i];return n},p_=function(r,t){for(var e="",n=0;n<r.length;n+=1)e+=r[n],n+1<r.length&&(e+=t);return e},f_=function(t){var e=this;if(typeof e!="function"||c_.apply(e)!==h_)throw new TypeError(l_+e);for(var n=d_(arguments,1),i,s=function(){if(this instanceof i){var h=e.apply(this,hf(n,arguments));return Object(h)===h?h:this}return e.apply(t,hf(n,arguments))},o=u_(0,e.length-n.length),a=[],c=0;c<o;c++)a[c]="$"+c;if(i=Function("binder","return function ("+p_(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},g_=f_,_a=Function.prototype.bind||g_,Ed=Function.prototype.call,Ad=Function.prototype.apply,m_=typeof Reflect<"u"&&Reflect&&Reflect.apply,v_=_a,y_=Ad,b_=Ed,w_=m_,Sv=w_||v_.call(b_,y_),S_=_a,__=K,k_=Ed,x_=Sv,wc=function(t){if(t.length<1||typeof t[0]!="function")throw new __("a function is required");return x_(S_,k_,t)},E_=wc,df=bs,_v;try{_v=[].__proto__===Array.prototype}catch(r){if(!r||typeof r!="object"||!("code"in r)||r.code!=="ERR_PROTO_ACCESS")throw r}var iu=!!_v&&df&&df(Object.prototype,"__proto__"),kv=Object,pf=kv.getPrototypeOf,A_=iu&&typeof iu.get=="function"?E_([iu.get]):typeof pf=="function"?function(t){return pf(t==null?t:kv(t))}:!1,ff=bv,gf=wv(),mf=A_,xv=ff?function(t){return ff(t)}:gf?function(t){if(!t||typeof t!="object"&&typeof t!="function")throw new TypeError("getProto: not an object");return gf(t)}:mf?function(t){return mf(t)}:null,T_=Function.prototype.call,$_=Object.prototype.hasOwnProperty,I_=_a,Lr=I_.call(T_,$_),q,C_=Sd,R_=yv,P_=KS,L_=JS,D_=_d,ds=Rr,zi=K,z_=XS,O_=QS,M_=e_,N_=t_,U_=r_,F_=n_,H_=i_,Z_=o_,Ev=Function,su=function(r){try{return Ev('"use strict"; return ('+r+").constructor;")()}catch{}},uo=bs,W_=Sa,ou=function(){throw new zi},B_=uo?function(){try{return arguments.callee,ou}catch{try{return uo(arguments,"callee").get}catch{return ou}}}():ou,gi=xd(),Le=xv,V_=wv(),j_=bv,Av=Ad,ka=Ed,Si={},G_=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%":R_,"%eval%":eval,"%EvalError%":P_,"%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%":Ev,"%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%":C_,"%Object.getOwnPropertyDescriptor%":uo,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?q:Promise,"%Proxy%":typeof Proxy>"u"?q:Proxy,"%RangeError%":L_,"%ReferenceError%":D_,"%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%":B_,"%TypedArray%":G_,"%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%":z_,"%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%":Av,"%Object.defineProperty%":W_,"%Object.getPrototypeOf%":V_,"%Math.abs%":O_,"%Math.floor%":M_,"%Math.max%":N_,"%Math.min%":U_,"%Math.pow%":F_,"%Math.round%":H_,"%Math.sign%":Z_,"%Reflect.getPrototypeOf%":j_};if(Le)try{null.error}catch(r){var q_=Le(Le(r));Kn["%Error.prototype%"]=q_}var Y_=function r(t){var e;if(t==="%AsyncFunction%")e=su("async function () {}");else if(t==="%GeneratorFunction%")e=su("function* () {}");else if(t==="%AsyncGeneratorFunction%")e=su("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},vf={__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,K_=xa.call(ka,Array.prototype.concat),J_=xa.call(Av,Array.prototype.splice),yf=xa.call(ka,String.prototype.replace),Ml=xa.call(ka,String.prototype.slice),X_=xa.call(ka,RegExp.prototype.exec),Q_=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,ek=/\\(\\)?/g,tk=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 yf(t,Q_,function(s,o,a,c){i[i.length]=a?yf(c,ek,"$1"):o||s}),i},rk=function(t,e){var n=t,i;if(Ol(vf,n)&&(i=vf[n],n="%"+i[0]+"%"),Ol(Kn,n)){var s=Kn[n];if(s===Si&&(s=Y_(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(X_(/^%?[^%]*%?$/,t)===null)throw new ds("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var n=tk(t),i=n.length>0?n[0]:"",s=rk("%"+i+"%",e),o=s.name,a=s.value,c=!1,u=s.alias;u&&(i=u[0],J_(n,K_([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},au,bf;function an(){if(bf)return au;bf=1;var r=xt,t=wc,e=t([r("%String.prototype.indexOf%")]);return au=function(i,s){var o=r(i,!!s);return typeof o=="function"&&e(i,".prototype.")>-1?t([o]):o},au}var lu,wf;function Td(){if(wf)return lu;wf=1;var r=xt,t=r("%Array%"),e=!t.isArray&&an()("Object.prototype.toString");return lu=t.isArray||function(i){return e(i)==="[object Array]"},lu}var nk=bc,Sf=Sa,Tv=nk.hasArrayLengthDefineBug(),ik=Tv&&Td(),sk=an(),ok=sk("Object.prototype.propertyIsEnumerable"),$d=function(t,e,n,i,s,o){if(!Sf){if(!t(o)||!o["[[Configurable]]"]||!o["[[Writable]]"]||s in i&&ok(i,s)!==!!o["[[Enumerable]]"])return!1;var a=o["[[Value]]"];return i[s]=a,e(i[s],a)}return Tv&&s==="length"&&"[[Value]]"in o&&ik(i)&&i.length!==o["[[Value]]"]?(i.length=o["[[Value]]"],i.length===o["[[Value]]"]):(Sf(i,s,n(o)),!0)},ak=K,Ds=Lr,lk={__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)&&!lk[e])return!1;var n=Ds(t,"[[Value]]")||Ds(t,"[[Writable]]"),i=Ds(t,"[[Get]]")||Ds(t,"[[Set]]");if(n&&i)throw new ak("Property Descriptors may not be both accessor and data descriptors");return!0},$v=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},ck=K,uk=Ss,hk=$v,Iv=function(t){if(typeof t<"u"&&!uk(t))throw new ck("Assertion failed: `Desc` must be a Property Descriptor");return hk(t)},dk=K,_f=Lr,pk=Ss,Cv=function(t){if(typeof t>"u")return!1;if(!pk(t))throw new dk("Assertion failed: `Desc` must be a Property Descriptor");return!(!_f(t,"[[Value]]")&&!_f(t,"[[Writable]]"))},_s=function(t){return typeof t=="string"||typeof t=="symbol"},kf=kd,Rv=function(t,e){return t===e?t===0?1/t===1/e:!0:kf(t)&&kf(e)},xf=K,fk=Pr,gk=$d,mk=Iv,vk=Cv,yk=_s,bk=Rv,Id=function(t,e,n){if(!fk(t))throw new xf("Assertion failed: Type(O) is not Object");if(!yk(e))throw new xf("Assertion failed: P is not a Property Key");var i={"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Value]]":n,"[[Writable]]":!0};return gk(vk,bk,mk,t,e,i)},Pv=Function.prototype.toString,Ci=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,th,pl;if(typeof Ci=="function"&&typeof Object.defineProperty=="function")try{th=Object.defineProperty({},"length",{get:function(){throw pl}}),pl={},Ci(function(){throw 42},null,th)}catch(r){r!==pl&&(Ci=null)}else Ci=null;var wk=/^\s*class\b/,rh=function(t){try{var e=Pv.call(t);return wk.test(e)}catch{return!1}},cu=function(t){try{return rh(t)?!1:(Pv.call(t),!0)}catch{return!1}},fl=Object.prototype.toString,Sk="[object Object]",_k="[object Function]",kk="[object GeneratorFunction]",xk="[object HTMLAllCollection]",Ek="[object HTML document.all class]",Ak="[object HTMLCollection]",Tk=typeof Symbol=="function"&&!!Symbol.toStringTag,$k=!(0 in[,]),nh=function(){return!1};if(typeof document=="object"){var Ik=document.all;fl.call(Ik)===fl.call(document.all)&&(nh=function(t){if(($k||!t)&&(typeof t>"u"||typeof t=="object"))try{var e=fl.call(t);return(e===xk||e===Ek||e===Ak||e===Sk)&&t("")==null}catch{}return!1})}var Lv=Ci?function(t){if(nh(t))return!0;if(!t||typeof t!="function"&&typeof t!="object")return!1;try{Ci(t,null,th)}catch(e){if(e!==pl)return!1}return!rh(t)&&cu(t)}:function(t){if(nh(t))return!0;if(!t||typeof t!="function"&&typeof t!="object")return!1;if(Tk)return cu(t);if(rh(t))return!1;var e=fl.call(t);return e!==_k&&e!==kk&&!/^\[object HTML/.test(e)?!1:cu(t)},Ck=Lv,Rk=function(t){return!!t},Zt=Lr,Ba=K,Pk=Pr,Ef=Ck,uu=Rk,Lk=function(t){if(!Pk(t))throw new Ba("ToPropertyDescriptor requires an object");var e={};if(Zt(t,"enumerable")&&(e["[[Enumerable]]"]=uu(t.enumerable)),Zt(t,"configurable")&&(e["[[Configurable]]"]=uu(t.configurable)),Zt(t,"value")&&(e["[[Value]]"]=t.value),Zt(t,"writable")&&(e["[[Writable]]"]=uu(t.writable)),Zt(t,"get")){var n=t.get;if(typeof n<"u"&&!Ef(n))throw new Ba("getter must be a function");e["[[Get]]"]=n}if(Zt(t,"set")){var i=t.set;if(typeof i<"u"&&!Ef(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},hu=K,Dk=Pr,Af=Ss,zk=$d,Ok=Iv,Mk=Cv,Nk=_s,Uk=Rv,Fk=Lk,Hk=function(t,e,n){if(!Dk(t))throw new hu("Assertion failed: Type(O) is not Object");if(!Nk(e))throw new hu("Assertion failed: P is not a Property Key");var i=Af(n)?n:Fk(n);if(!Af(i))throw new hu("Assertion failed: Desc is not a valid Property Descriptor");return zk(Mk,Uk,Ok,t,e,i)},Tf=K,Zk=Pr,Wk=Hk,Bk=_s,Vk=function(t,e,n){if(!Zk(t))throw new Tf("Assertion failed: Type(O) is not Object");if(!Bk(e))throw new Tf("Assertion failed: P is not a Property Key");var i={"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Value]]":n,"[[Writable]]":!0};return Wk(t,e,i)},jk=typeof Reflect<"u"&&Reflect.setPrototypeOf||null,Gk=Sd,qk=Gk.setPrototypeOf||null,Yk=wc,$f=bs,Kk=K,Dv={};try{Dv.__proto__=null}catch(r){if(!r||typeof r!="object"||!("code"in r)||r.code!=="ERR_PROTO_ACCESS")throw r}var Jk=!("toString"in Dv),du=$f&&$f(Object.prototype,"__proto__"),Xk=Jk&&(!!du&&typeof du.set=="function"&&Yk([du.set])||function(t,e){if(t==null)throw new Kk("set Object.prototype.__proto__ called on null or undefined");return t.__proto__=e,e}),If=jk,Qk=qk,Cf=Xk,ex=K,tx=If?function(t,e){if(If(t,e))return t;throw new ex("Reflect.setPrototypeOf: failed to set [[Prototype]]")}:Qk||(Cf?function(t,e){return Cf(t,e),t}:null),Rf=K,rx=Pr,Pf=xv,nx=function(t){if(!rx(t))throw new Rf("Assertion failed: O must be an Object");if(!Pf)throw new Rf("This environment does not support fetching prototypes.");return Pf(t)},ix=K,sx=tx,ox=Pr,ax=nx,lx=function(t,e){if(e!==null&&!ox(e))throw new ix("Assertion failed: V must be Object or Null");try{sx(t,e)}catch{return!1}return ax(t)===e},pu=Id,Lf=Vk,zv=lx,cx=bc(),Cd=yv;function Ea(r,t,e){var n=new Cd(e);return zv(n,gl),delete n.constructor,Lf(n,"error",r),Lf(n,"suppressed",t),n}cx&&Object.defineProperty(Ea,"prototype",{writable:!1});var gl=Ea.prototype;if(!pu(gl,"constructor",Ea)||!pu(gl,"message","")||!pu(gl,"name","SuppressedError"))throw new Cd("unable to install SuppressedError.prototype properties; please report this!");zv(Ea.prototype,Cd.prototype);var ux=Ea,hx=ux,Ov=function(){return typeof SuppressedError=="function"?SuppressedError:hx},dx=ii,Df=wd(),px=Ov,fx=function(){var t=px();return dx(Df,{SuppressedError:t},{SuppressedError:function(){return Df.SuppressedError!==t}}),t};fx();var gx=K,mx=Ss,vx=$v,yx=function(t){if(typeof t<"u"&&!mx(t))throw new gx("Assertion failed: `Desc` must be a Property Descriptor");return vx(t)},bx=K,zf=Lr,wx=Ss,Sx=function(t){if(typeof t>"u")return!1;if(!wx(t))throw new bx("Assertion failed: `Desc` must be a Property Descriptor");return!(!zf(t,"[[Value]]")&&!zf(t,"[[Writable]]"))},Of=kd,_x=function(t,e){return t===e?t===0?1/t===1/e:!0:Of(t)&&Of(e)},ks=Lv,kx=function(t){return!!t},Wt=Lr,Va=K,xx=Pr,Mf=ks,fu=kx,Ex=function(t){if(!xx(t))throw new Va("ToPropertyDescriptor requires an object");var e={};if(Wt(t,"enumerable")&&(e["[[Enumerable]]"]=fu(t.enumerable)),Wt(t,"configurable")&&(e["[[Configurable]]"]=fu(t.configurable)),Wt(t,"value")&&(e["[[Value]]"]=t.value),Wt(t,"writable")&&(e["[[Writable]]"]=fu(t.writable)),Wt(t,"get")){var n=t.get;if(typeof n<"u"&&!Mf(n))throw new Va("getter must be a function");e["[[Get]]"]=n}if(Wt(t,"set")){var i=t.set;if(typeof i<"u"&&!Mf(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},gu=K,Ax=Pr,Nf=Ss,Tx=$d,$x=yx,Ix=Sx,Cx=_s,Rx=_x,Px=Ex,Aa=function(t,e,n){if(!Ax(t))throw new gu("Assertion failed: Type(O) is not Object");if(!Cx(e))throw new gu("Assertion failed: P is not a Property Key");var i=Nf(n)?n:Px(n);if(!Nf(i))throw new gu("Assertion failed: Desc is not a valid Property Descriptor");return Tx(Ix,Rx,$x,t,e,i)},Lx=ws(),Dx=Lx?Symbol.dispose||Symbol("Symbol.dispose"):null,zx=ws,Ox=Dx,Rd=function(){return zx()&&Symbol.dispose||Ox},Mx=xd,Nx=Aa,Ux=Rd,Fx=function(){var t=Ux();return Mx()&&Nx(Symbol,"dispose",{"[[Configurable]]":!1,"[[Enumerable]]":!1,"[[Writable]]":!1,"[[Value]]":t}),t},Hx=ws(),Zx=Hx?Symbol.asyncDispose||Symbol("Symbol.asyncDispose"):null,Wx=ws,Bx=Zx,Pd=function(){return Wx()&&Symbol.asyncDispose||Bx},Vx=xd,jx=Aa,Gx=Pd,qx=function(){var t=Gx();return Vx()&&jx(Symbol,"asyncDispose",{"[[Configurable]]":!1,"[[Enumerable]]":!1,"[[Writable]]":!1,"[[Value]]":t}),t},Yx=Td(),Kx=xt,Jx=an(),Xx=K,Qx=Yx,eE=Kx("%Reflect.apply%",!0)||Jx("Function.prototype.apply"),Sc=function(t,e){var n=arguments.length>2?arguments[2]:[];if(!Qx(n))throw new Xx("Assertion failed: optional `argumentsList`, if provided, must be a List");return eE(t,e,n)};const tE={},rE=Object.freeze(Object.defineProperty({__proto__:null,default:tE},Symbol.toStringTag,{value:"Module"})),nE=$S(rE);var Ld=typeof Map=="function"&&Map.prototype,mu=Object.getOwnPropertyDescriptor&&Ld?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,Nl=Ld&&mu&&typeof mu.get=="function"?mu.get:null,Uf=Ld&&Map.prototype.forEach,Dd=typeof Set=="function"&&Set.prototype,vu=Object.getOwnPropertyDescriptor&&Dd?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,Ul=Dd&&vu&&typeof vu.get=="function"?vu.get:null,Ff=Dd&&Set.prototype.forEach,iE=typeof WeakMap=="function"&&WeakMap.prototype,io=iE?WeakMap.prototype.has:null,sE=typeof WeakSet=="function"&&WeakSet.prototype,so=sE?WeakSet.prototype.has:null,oE=typeof WeakRef=="function"&&WeakRef.prototype,Hf=oE?WeakRef.prototype.deref:null,aE=Boolean.prototype.valueOf,lE=Object.prototype.toString,cE=Function.prototype.toString,uE=String.prototype.match,zd=String.prototype.slice,Xr=String.prototype.replace,hE=String.prototype.toUpperCase,Zf=String.prototype.toLowerCase,Mv=RegExp.prototype.test,Wf=Array.prototype.concat,lr=Array.prototype.join,dE=Array.prototype.slice,Bf=Math.floor,ih=typeof BigInt=="function"?BigInt.prototype.valueOf:null,yu=Object.getOwnPropertySymbols,sh=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,Nv=Object.prototype.propertyIsEnumerable,Vf=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(r){return r.__proto__}:null);function jf(r,t){if(r===1/0||r===-1/0||r!==r||r&&r>-1e3&&r<1e3||Mv.call(/e/,t))return t;var e=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof r=="number"){var n=r<0?-Bf(-r):Bf(r);if(n!==r){var i=String(n),s=zd.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 oh=nE,Gf=oh.custom,qf=Hv(Gf)?Gf:null,Uv={__proto__:null,double:'"',single:"'"},pE={__proto__:null,double:/(["\\])/g,single:/(['\\])/g},xs=function r(t,e,n,i){var s=e||{};if(wr(s,"quoteStyle")&&!wr(Uv,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 Wv(t,s);if(typeof t=="number"){if(t===0)return 1/0/t>0?"0":"-0";var c=String(t);return a?jf(t,c):c}if(typeof t=="bigint"){var u=String(t)+"n";return a?jf(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 ah(t)?"[Array]":"[Object]";var f=RE(s,n);if(typeof i>"u")i=[];else if(Zv(i,t)>=0)return"[Circular]";function y(Ut,Dr,Hc){if(Dr&&(i=dE.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"&&!Yf(t)){var m=_E(t),E=ja(t,y);return"[Function"+(m?": "+m:" (anonymous)")+"]"+(E.length>0?" { "+lr.call(E,", ")+" }":"")}if(Hv(t)){var x=ps?Xr.call(String(t),/^(Symbol\(.*\))_[^)]*$/,"$1"):sh.call(t);return typeof t=="object"&&!ps?zs(x):x}if($E(t)){for(var I="<"+Zf.call(String(t.nodeName)),P=t.attributes||[],R=0;R<P.length;R++)I+=" "+P[R].name+"="+Fv(fE(P[R].value),"double",s);return I+=">",t.childNodes&&t.childNodes.length&&(I+="..."),I+="</"+Zf.call(String(t.nodeName))+">",I}if(ah(t)){if(t.length===0)return"[]";var B=ja(t,y);return f&&!CE(B)?"["+lh(B,f)+"]":"[ "+lr.call(B,", ")+" ]"}if(mE(t)){var N=ja(t,y);return!("cause"in Error.prototype)&&"cause"in t&&!Nv.call(t,"cause")?"{ ["+String(t)+"] "+lr.call(Wf.call("[cause]: "+y(t.cause),N),", ")+" }":N.length===0?"["+String(t)+"]":"{ ["+String(t)+"] "+lr.call(N,", ")+" }"}if(typeof t=="object"&&o){if(qf&&typeof t[qf]=="function"&&oh)return oh(t,{depth:h-n});if(o!=="symbol"&&typeof t.inspect=="function")return t.inspect()}if(kE(t)){var F=[];return Uf&&Uf.call(t,function(Ut,Dr){F.push(y(Dr,t,!0)+" => "+y(Ut,t))}),Kf("Map",Nl.call(t),F,f)}if(AE(t)){var Y=[];return Ff&&Ff.call(t,function(Ut){Y.push(y(Ut,t))}),Kf("Set",Ul.call(t),Y,f)}if(xE(t))return bu("WeakMap");if(TE(t))return bu("WeakSet");if(EE(t))return bu("WeakRef");if(yE(t))return zs(y(Number(t)));if(wE(t))return zs(y(ih.call(t)));if(bE(t))return zs(aE.call(t));if(vE(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(!gE(t)&&!Yf(t)){var j=ja(t,y),ce=Vf?Vf(t)===Object.prototype:t instanceof Object||t.constructor===Object,At=t instanceof Object?"":"null prototype",hn=!ce&&oo&&Object(t)===t&&oo in t?zd.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(Wf.call([],hn||[],At||[]),": ")+"] ":"");return j.length===0?dn+"{}":f?dn+"{"+lh(j,f)+"}":dn+"{ "+lr.call(j,", ")+" }"}return String(t)};function Fv(r,t,e){var n=e.quoteStyle||t,i=Uv[n];return i+r+i}function fE(r){return Xr.call(String(r),/"/g,""")}function si(r){return!oo||!(typeof r=="object"&&(oo in r||typeof r[oo]<"u"))}function ah(r){return ln(r)==="[object Array]"&&si(r)}function gE(r){return ln(r)==="[object Date]"&&si(r)}function Yf(r){return ln(r)==="[object RegExp]"&&si(r)}function mE(r){return ln(r)==="[object Error]"&&si(r)}function vE(r){return ln(r)==="[object String]"&&si(r)}function yE(r){return ln(r)==="[object Number]"&&si(r)}function bE(r){return ln(r)==="[object Boolean]"&&si(r)}function Hv(r){if(ps)return r&&typeof r=="object"&&r instanceof Symbol;if(typeof r=="symbol")return!0;if(!r||typeof r!="object"||!sh)return!1;try{return sh.call(r),!0}catch{}return!1}function wE(r){if(!r||typeof r!="object"||!ih)return!1;try{return ih.call(r),!0}catch{}return!1}var SE=Object.prototype.hasOwnProperty||function(r){return r in this};function wr(r,t){return SE.call(r,t)}function ln(r){return lE.call(r)}function _E(r){if(r.name)return r.name;var t=uE.call(cE.call(r),/^function\s*([\w$]+)/);return t?t[1]:null}function Zv(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 kE(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 xE(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 EE(r){if(!Hf||!r||typeof r!="object")return!1;try{return Hf.call(r),!0}catch{}return!1}function AE(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 TE(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 $E(r){return!r||typeof r!="object"?!1:typeof HTMLElement<"u"&&r instanceof HTMLElement?!0:typeof r.nodeName=="string"&&typeof r.getAttribute=="function"}function Wv(r,t){if(r.length>t.maxStringLength){var e=r.length-t.maxStringLength,n="... "+e+" more character"+(e>1?"s":"");return Wv(zd.call(r,0,t.maxStringLength),t)+n}var i=pE[t.quoteStyle||"single"];i.lastIndex=0;var s=Xr.call(Xr.call(r,i,"\\$1"),/[\x00-\x1f]/g,IE);return Fv(s,"single",t)}function IE(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":"")+hE.call(t.toString(16))}function zs(r){return"Object("+r+")"}function bu(r){return r+" { ? }"}function Kf(r,t,e,n){var i=n?lh(e,n):lr.call(e,", ");return r+" ("+t+") {"+i+"}"}function CE(r){for(var t=0;t<r.length;t++)if(Zv(r[t],`
|
|
2
|
-
`)>=0)return!1;return!0}function RE(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 lh(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=ah(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 yu=="function"?yu(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||(Mv.call(/[^\w$]/,c)?n.push(t(c,r)+": "+t(r[c],r)):n.push(c+": "+t(r[c],r))));if(typeof yu=="function")for(var u=0;u<s.length;u++)Nv.call(r,s[u])&&n.push("["+t(s[u])+"]: "+t(r[s[u]],r));return n}var PE=xs,LE=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},DE=function(r,t){if(r){var e=_c(r,t);return e&&e.value}},zE=function(r,t,e){var n=_c(r,t);n?n.value=e:r.next={key:t,next:r.next,value:e}},OE=function(r,t){return r?!!_c(r,t):!1},ME=function(r,t){if(r)return _c(r,t,!0)},NE=function(){var t,e={assert:function(n){if(!e.has(n))throw new LE("Side channel does not contain "+PE(n))},delete:function(n){var i=t&&t.next,s=ME(t,n);return s&&i&&i===s&&(t=void 0),!!s},get:function(n){return DE(t,n)},has:function(n){return OE(t,n)},set:function(n,i){t||(t={next:void 0}),zE(t,n,i)}};return e},UE=xt,Ta=an(),FE=xs,HE=K,Jf=UE("%Map%",!0),ZE=Ta("Map.prototype.get",!0),WE=Ta("Map.prototype.set",!0),BE=Ta("Map.prototype.has",!0),VE=Ta("Map.prototype.delete",!0),jE=Ta("Map.prototype.size",!0),Bv=!!Jf&&function(){var t,e={assert:function(n){if(!e.has(n))throw new HE("Side channel does not contain "+FE(n))},delete:function(n){if(t){var i=VE(t,n);return jE(t)===0&&(t=void 0),i}return!1},get:function(n){if(t)return ZE(t,n)},has:function(n){return t?BE(t,n):!1},set:function(n,i){t||(t=new Jf),WE(t,n,i)}};return e},GE=xt,kc=an(),qE=xs,Ga=Bv,YE=K,mi=GE("%WeakMap%",!0),KE=kc("WeakMap.prototype.get",!0),JE=kc("WeakMap.prototype.set",!0),XE=kc("WeakMap.prototype.has",!0),QE=kc("WeakMap.prototype.delete",!0),eA=mi?function(){var t,e,n={assert:function(i){if(!n.has(i))throw new YE("Side channel does not contain "+qE(i))},delete:function(i){if(mi&&i&&(typeof i=="object"||typeof i=="function")){if(t)return QE(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?KE(t,i):e&&e.get(i)},has:function(i){return mi&&i&&(typeof i=="object"||typeof i=="function")&&t?XE(t,i):!!e&&e.has(i)},set:function(i,s){mi&&i&&(typeof i=="object"||typeof i=="function")?(t||(t=new mi),JE(t,i,s)):Ga&&(e||(e=Ga()),e.set(i,s))}};return n}:Ga,tA=K,rA=xs,nA=NE,iA=Bv,sA=eA,oA=sA||iA||nA,aA=function(){var t,e={assert:function(n){if(!e.has(n))throw new tA("Side channel does not contain "+rA(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=oA()),t.set(n,i)}};return e},lA=Lr,Os=aA(),gr=K,Od={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),!Od.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&&lA(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(Od);var Md=Od,Vv=Rr,en=Md,$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 Vv('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 Vv('Assertion failed: Completion Record is not of type "normal"');return en.get(this,"[[Value]]")};var Nd=$a,cA=Nd,Ud=function(t){return new cA("normal",t)},wu,Xf;function uA(){if(Xf)return wu;Xf=1;var r=ws;return wu=function(){return r()&&!!Symbol.toStringTag},wu}var hA=xt,Qf=hA("%Object.defineProperty%",!0),dA=uA()(),pA=Lr,fA=K,qa=dA?Symbol.toStringTag:null,jv=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 fA("if provided, the `overrideIfSet` and `nonConfigurable` options must be booleans");qa&&(n||!pA(t,qa))&&(Qf?Qf(t,qa,{configurable:!i,enumerable:!1,value:e,writable:!1}):t[qa]=e)},Gv={exports:{}},gA=xt,eg=uv,mA=bc(),tg=bs,rg=K,vA=gA("%Math.floor%"),yA=function(t,e){if(typeof t!="function")throw new rg("`fn` is not a function");if(typeof e!="number"||e<0||e>4294967295||vA(e)!==e)throw new rg("`length` must be a positive 32-bit integer");var n=arguments.length>2&&!!arguments[2],i=!0,s=!0;if("length"in t&&tg){var o=tg(t,"length");o&&!o.configurable&&(i=!1),o&&!o.writable&&(s=!1)}return(i||s||!n)&&(mA?eg(t,"length",e,!0,!0):eg(t,"length",e)),t},bA=_a,wA=Ad,SA=Sv,_A=function(){return SA(bA,wA,arguments)};(function(r){var t=yA,e=Sa,n=wc,i=_A;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})(Gv);var Fd=Gv.exports,kA=function(t,e){for(var n=0;n<t.length;n+=1)if(!e(t[n],n,t))return!1;return!0},xA=Object,EA=function(t){return t&&typeof t=="object"&&(typeof t["[[ResourceValue]]"]>"u"||xA(t["[[ResourceValue]]"])===t["[[ResourceValue]]"])&&(t["[[Hint]]"]==="SYNC-DISPOSE"||t["[[Hint]]"]==="ASYNC-DISPOSE")&&(typeof t["[[DisposeMethod]]"]=="function"||typeof t["[[DisposeMethod]]"]>"u")},AA=Lr,TA=Td(),$A=kA,IA=EA,CA=function(t){return t&&typeof t=="object"&&AA(t,"[[DisposableResourceStack]]")&&TA(t["[[DisposableResourceStack]]"])&&(t["[[DisposableResourceStack]]"].length===0||$A(t["[[DisposableResourceStack]]"],IA))},RA=Pr,PA=function(t){if(t===null)return"Null";if(typeof t>"u")return"Undefined";if(RA(t))return"Object";if(typeof t=="number")return"Number";if(typeof t=="boolean")return"Boolean";if(typeof t=="string")return"String"},LA=PA,Hd=function(t){return typeof t=="symbol"?"Symbol":typeof t=="bigint"?"BigInt":LA(t)},DA=K,zA=xs,OA=_s,MA=function(t,e){if(!OA(e))throw new DA("Assertion failed: P is not a Property Key, got "+zA(e));return t[e]},ng=K,NA=MA,UA=ks,FA=_s,ig=xs,HA=function(t,e){if(!FA(e))throw new ng("Assertion failed: P is not a Property Key");var n=NA(t,e);if(n!=null){if(!UA(n))throw new ng(ig(e)+" is not a function: "+ig(n));return n}},ch={exports:{}},ZA=xt,WA=ZA,sg=WA("%Reflect.construct%",!0),Fl=Aa;try{Fl({},"",{"[[Get]]":function(){}})}catch{Fl=null}if(Fl&&sg){var og={},ag={};Fl(ag,"length",{"[[Get]]":function(){throw og},"[[Enumerable]]":!0}),ch.exports=function(t){try{sg(t,ag)}catch(e){return e===og}}}else ch.exports=function(t){return typeof t=="function"&&!!t.prototype};var BA=ch.exports,Su=K,lg=ks,VA=BA,jA=function(t){if(!VA(t))throw new Su("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 Su("executor has already been called");e["[[Resolve]]"]=i,e["[[Reject]]"]=s});if(!lg(e["[[Resolve]]"])||!lg(e["[[Reject]]"]))throw new Su("executor must provide valid resolve and reject functions");return{"[[Promise]]":n,"[[Resolve]]":e["[[Resolve]]"],"[[Reject]]":e["[[Reject]]"]}},cg=Rr,GA=K,_u=Sc,ug=HA,qA=jA,YA=Hd,hg=Rd(),dg=Pd(),KA=function(t,e){if(YA(t)!=="Object")throw new GA("`V` must be an Object");if(e!=="SYNC-DISPOSE"&&e!=="ASYNC-DISPOSE")throw new cg("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");var n;if(e==="ASYNC-DISPOSE"&&dg&&(n=ug(t,dg)),!n){if(!hg)throw new cg("`Symbol.dispose` is not supported");if(n=ug(t,hg),typeof n<"u")return function(){var i=this;if(e==="ASYNC-DISPOSE"){var s=qA(Promise);try{_u(n,i),_u(s["[[Resolve]]"],void 0,[void 0])}catch(o){s["[[Reject]]"](o)}return s["[[Promise]]"]}_u(n,i)}}return n},JA=Rr,ku=K,XA=ks,QA=Hd,e1=KA,t1=function(t,e){if(e!=="SYNC-DISPOSE"&&e!=="ASYNC-DISPOSE")throw new JA("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"&&QA(t)!=="Object")throw new ku("`V` must be an Object, or `null` or `undefined`");if(n=e1(t,e),typeof n>"u")throw new ku("dispose method must not be `undefined` on `V` when an object `V` is provided")}else if(n=arguments[2],!XA(n))throw new ku("`method`, when provided, must be a function");return{"[[ResourceValue]]":t,"[[Hint]]":e,"[[DisposeMethod]]":n}},r1=Rr,Ya=K,n1=CA,pg=t1,i1=an(),s1=i1("Array.prototype.push"),qv=function(t,e,n){if(!n1(t))throw new Ya("Assertion failed: `disposeCapability` must be a DisposeCapability Record");if(n!=="SYNC-DISPOSE"&&n!=="ASYNC-DISPOSE")throw new r1("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=pg(e,n)}else{if(typeof e<"u")throw new Ya("Assertion failed: `V` must be undefined when `method` is present");s=pg(void 0,n,i)}return s1(t["[[DisposableResourceStack]]"],s),"UNUSED"},xu,fg;function Zd(){if(fg)return xu;fg=1;var r=xt,t=Fd,e=Rr,n=r("%Promise.resolve%",!0),i=n&&t(n);return xu=function(o,a){if(!i)throw new e("This environment does not support Promises.");return i(o,a)},xu}var Eu,gg;function o1(){if(gg)return Eu;gg=1;var r=xt,t=Rr,e=r("%Promise%",!0),n=Sc,i=Zd(),s=Hd;return Eu=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)},Eu}var Au,mg;function a1(){if(mg)return Au;mg=1;var r=Nd;return Au=function(e){return new r("throw",e)},Au}var l1=xt,Tu=Rr,vg=K,c1=l1("%Promise%",!0),u1=an(),yg=u1("Promise.prototype.then",!0),h1=Nd,bg=o1(),d1=Ud,p1=Zd(),wg=a1(),f1=Ov(),Yv=function(t,e){if(!(e instanceof h1))throw new vg("`completion` must be a Completion Record");var n=t["[[DisposableResourceStack]]"];if(!n)throw new vg("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 Tu("mixed hint stacks are not supported");for(var o=i==="ASYNC-DISPOSE"&&p1(c1,e),a=function(y){if(e.type()==="throw"){var m=e.value(),E=new f1(y,m);e=wg(E)}else e=wg(y)},c=i==="ASYNC-DISPOSE"&&function(m){return yg(o,function(){var E=bg(m["[[ResourceValue]]"],m["[[Hint]]"],m["[[DisposeMethod]]"]);if(!E)throw new Tu("Assertion failed: non-`~ASYNC-DISPOSE~` resource returned a promise from Dispose");return yg(E,d1)},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=bg(h["[[ResourceValue]]"],h["[[Hint]]"],h["[[DisposeMethod]]"]);if(f)throw new Tu("Assertion failed: `~SYNC-DISPOSE~` resource returned something from Dispose")}catch(y){a(y)}}return t["[[DisposableResourceStack]]"]=null,i==="ASYNC-DISPOSE"?o:e},Kv=function(){var t=[];return{"[[DisposableResourceStack]]":t}},xc=_d,Wd=K,g1=Sc,Es=Id,m1=Aa,Jv=ks,v1=Ud,at=Md,y1=jv,Xv=ii.supportsDescriptors,b1=Fd,Bd=qv,w1=Yv,Qv=Kv,Sg=Rd(),wt=function r(){if(!(this instanceof r)||at.has(this,"[[DisposableState]]")||at.has(this,"[[DisposeCapability]]"))throw new Wd("can only be used with new");at.set(this,"[[DisposableState]]","PENDING"),at.set(this,"[[DisposeCapability]]",Qv())},ey=function(){var t=this;return at.assert(t,"[[DisposableState]]"),at.get(t,"[[DisposableState]]")==="DISPOSED"},Ia=b1(ey);Xv?m1(wt.prototype,"disposed",{"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Get]]":ey}):wt.prototype.disposed=!1;var ty=function(t){at.set(t,"[[DisposableState]]","DISPOSED"),Xv||(t.disposed=!0)};Es(wt.prototype,"dispose",function(){var t=this;if(!Ia(t))return ty(t),w1(at.get(t,"[[DisposeCapability]]"),v1())["?"]()});Es(wt.prototype,"use",function(t){var e=this;if(Ia(e))throw new xc("a disposed stack can not use anything new");return Bd(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(!Jv(e))throw new Wd("`onDispose` must be a function");var i=function(){return g1(e,void 0,[t])};return Bd(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(!Jv(t))throw new Wd("`onDispose` must be a function");Bd(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]]",Qv()),ty(t),e});Sg&&Es(wt.prototype,Sg,wt.prototype.dispose);y1(wt.prototype,"DisposableStack");var S1=wt,_1=S1,k1=function(){return typeof DisposableStack=="function"?DisposableStack:_1},x1=ii,E1=wd(),A1=k1,T1=function(){var t=A1();return x1(E1,{DisposableStack:t},{DisposableStack:!0}),t},$1=xt,Ec=_d,Vd=K,_g=$1("%Promise%",!0),jd=qv,I1=Sc,As=Id,C1=Aa,R1=Yv,ry=ks,ny=Kv,P1=Ud,kg=Zd(),lt=Md,L1=jv,iy=ii.supportsDescriptors,D1=Fd,z1=an(),O1=z1("Promise.prototype.then",!0),xg=Pd(),St=function r(){if(!(this instanceof r)||lt.has(this,"[[AsyncDisposableState]]")||lt.has(this,"[[DisposeCapability]]"))throw new Vd("can only be used with new");lt.set(this,"[[AsyncDisposableState]]","pending"),lt.set(this,"[[DisposeCapability]]",ny())},sy=function(){var t=this;return lt.assert(t,"[[AsyncDisposableState]]"),lt.get(t,"[[AsyncDisposableState]]")==="disposed"},Ca=D1(sy);iy?C1(St.prototype,"disposed",{"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Get]]":sy}):St.prototype.disposed=!1;var oy=function(t){lt.set(t,"[[AsyncDisposableState]]","disposed"),iy||(t.disposed=!0)};As(St.prototype,"disposeAsync",function(){var t=this;return Ca(t)?kg(_g):(oy(t),O1(kg(_g,R1(lt.get(t,"[[DisposeCapability]]"),P1())),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 jd(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(!ry(e))throw new Vd("`onDisposeAsync` must be a function");var i=function(){return I1(e,void 0,[t])};return i.value=t,jd(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(!ry(t))throw new Vd("`onDispose` must be a function");jd(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]]",ny()),oy(t),e});xg&&As(St.prototype,xg,St.prototype.disposeAsync);L1(St.prototype,"AsyncDisposableStack");var M1=St,N1=M1,U1=function(){return typeof AsyncDisposableStack=="function"?AsyncDisposableStack:N1},F1=ii,H1=wd(),Z1=U1,W1=function(){var t=Z1();return F1(H1,{AsyncDisposableStack:t},{AsyncDisposableStack:!0}),t},B1=Fx,V1=qx,j1=T1,G1=W1,q1=function(){B1(),V1(),j1(),G1()};q1();const Eg=new WeakMap;function Y1(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 Ag(){return new Error("register(Key, factory) requires a factory function. Wrap existing instances as () => instance.")}function K1(){return new Error("register(Key, factory) does not accept async factories. Await setup before registering.")}class J1{constructor(){g(this,"entries",new Map);g(this,"constructionStack",[])}register(t,e){if(e===void 0){if(typeof t!="function")throw Ag();this.validateClassRegistration(t),this.storeFactory(t,()=>this.instantiateClass(t));return}if(typeof e!="function")throw Ag();if(e.constructor.name==="AsyncFunction")throw K1();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=Eg.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=Eg.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(Y1(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 J1,X1=.5,Tg=.1,$g=8,Q1=4,ay=3,ly=3,eT=4,En=255,cy=.2126,uy=.7152,hy=.0722;async function dy(r){const t=tT(r);if(!t)return"light";try{return await iT(r,t)>=X1?"light":"dark"}catch{return"light"}}function tT(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(rT(o))return s}return null}function rT(r){return py(r.backgroundImage)?!0:nT(r.backgroundColor)>0}function nT(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===eT?parseFloat(e[ay]):e.length===ly?1:0}async function iT(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=py(s.backgroundImage);return o?oT({url:o,surfaceWidth:n.width,surfaceHeight:n.height,region:i}):aT(s.backgroundColor)}function py(r){const t=r.match(/url\(\s*["']?([^"')]+)["']?\s*\)/);return t?t[1]:null}const Ig=new Map;function sT(r){let t=Ig.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}),Ig.set(r,t),t)}async function oT(r){const t=await sT(r.url),e=Math.max($g,Math.ceil(r.surfaceWidth*Tg)),n=Math.max($g,Math.ceil(r.surfaceHeight*Tg)),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+=Q1){const N=I[B]/En,F=I[B+1]/En,Y=I[B+2]/En,j=I[B+ay]/En;P+=j*(cy*N+uy*F+hy*Y),R+=1}return R>0?P/R:1}function aT(r){const t=r.match(/rgba?\(([^)]+)\)/);if(!t)return 1;const e=t[1].split(/[\s,/]+/).filter(Boolean).map(parseFloat);if(e.length<ly)return 1;const n=e[0]/En,i=e[1]/En,s=e[2]/En;return cy*n+uy*i+hy*s}function Ka(r){return r<0?0:r>1?1:r}const lT=["ghost","glass"],ho=[...lT.map(r=>`[variant="${r}"]`),'[material="glass"]'].join(", "),Ja=new WeakSet,Cg=new WeakSet;function fy(r){if(Cg.has(r))return;Cg.add(r);for(const e of r.querySelectorAll(ho))$u(e);if(typeof MutationObserver!="function")return;new MutationObserver(e=>{for(const n of e)if(n.type==="childList")for(const i of n.addedNodes)cT(i,$u);else n.type==="attributes"&&n.target instanceof HTMLElement&&n.target.matches(ho)&&$u(n.target)}).observe(r,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["variant","material"]})}function cT(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 $u(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 dy(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 uT="*,*: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)}',Gd=new CSSStyleSheet;Gd.replaceSync(uT);const qd=new CSSStyleSheet;try{document.adoptedStyleSheets=[...document.adoptedStyleSheets,Gd,qd]}catch{}fy(document);function gy(r){qd.replaceSync(r)}function Hl(){gy("")}function Yd(r){try{r.adoptedStyleSheets=[...r.adoptedStyleSheets,Gd,qd]}catch{}fy(r)}const hT=new Set(["target","currentTarget","eventPhase","defaultPrevented","isTrusted","timeStamp","srcElement","returnValue","cancelBubble","NONE","CAPTURING_PHASE","AT_TARGET","BUBBLING_PHASE","composedPath","stopPropagation","stopImmediatePropagation","preventDefault","initEvent"]);function dT(r){for(const t of Object.keys(r))if(hT.has(t))throw new Error(`Event payload key "${t}" is reserved; choose a different property name`)}function pT(r,t){dT(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}),pT(this,c)}}return r}class Mt extends globalThis.EventTarget{}function fT(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);fT(this,()=>l(this,e),()=>{b(this,e,!0)})}[Symbol.dispose](){this.dispose()}get disposed(){return l(this,e)}}return e=new WeakMap,t}const gT=Ve(),mT=Ve(),vT=Ve(),Gs=Ve(),my=Ve(),yT=Ve(),Iu=Ve(),qe=4,ft=6,po=2,uh=2,Kd=8,bT=ft,Jd="auto",tn="auto",Nr=128,Rg=50,ae=16,Jn=Nr*qe+ae*(qe-1),fo=Nr*ft+ae*(ft-1),wT=Jn+ae*2,ST=200,_T=4,Xa=150,kT=10,Pg=2,Lg=8,xT=300,ET=4;function vy(r){return wy(r)}function yy(r,t){return wy(r.flatMap(e=>_y(e,t)))}function by(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}ky(n,"strip",t,e)}return{valid:t.length===0,errors:t}}function An(r){const t=vy(r),e=by(t);if(!e.valid)throw new Error(`Invalid layout: ${e.errors.join("; ")}`);return{totalNodes:t.length,nodes:t.filter(n=>n.type!=="row").map(IT)}}function wy(r){const t=[];for(const e of r){const n=Sy(e);for(const i of n){if(i.type==="row"){t.push(...i.children.map(Ir));continue}t.push(i)}}return t}function Sy(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=Sy(e);for(const i of n){if(i.type==="stack"){t.push(...i.children.map(hh));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?[hh(t[0])]:[{...r,children:t}]}}}function _y(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=>_y(n,t).filter(s=>s.type!=="stack"));return e.length===0?[]:e.length===1?[hh(e[0])]:[{...r,children:e}]}}}function ky(r,t,e,n){switch(r.type){case"card":xy(r,t,e,n);return;case"row":AT(r,t,e,n);return;case"stack":TT(r,t,e,n);return}}function xy(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),$T(r.width)||e.push(`Card ${Ms(r)} width must be an integer in the range ${po}-${Kd}`),Ay(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 AT(r,t,e,n){if(Ey(r.id,e),t!=="stack"&&e.push(`Row ${r.id} may only appear inside a stack`),Ay(r.height,ET)||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}xy(s,"row",e,n),i+=Ri(s.width)}i!==qe&&e.push(`Row ${r.id} children must sum to 4 columns`)}function TT(r,t,e,n){if(Ey(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(ky(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*uh||o%s!==0){e.push(`Stack ${r.id} has auto-height children that cannot resolve to whole height >= 2`);return}o/s<uh&&e.push(`Stack ${r.id} has auto-height children below the minimum row size`)}function Ey(r,t){(typeof r!="string"||r.length===0)&&t.push(`Node id must be a non-empty string: ${String(r)}`)}function $T(r){return r===Jd||Number.isInteger(r)&&r>=po&&r<=Kd}function Ay(r,t=bT){return r===tn||Number.isInteger(r)&&r>=uh&&r<=t}function Ri(r){return r===Jd?qe:r}function IT(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:Ty(r.height,ft)}]};const t=CT(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 CT(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=>Ty(i.height,n))}function Ty(r,t){return r===tn?t:r}function Ir(r){return{...r}}function hh(r){return r.type==="card"?Ir(r):{...r,children:r.children.map(Ir)}}const RT="X-Television-Client-Meta",PT="telemetry-activity";function $y(r,t={}){return{type:"card",artifactID:r,width:t.width??Jd,height:t.height??tn}}function ml(r){return r.layout.flatMap(Iy)}function Iy(r){switch(r.type){case"card":return[r.artifactID];case"row":return r.children.map(t=>t.artifactID);case"stack":return r.children.flatMap(Iy)}}const oe=Ve(),dh=Ve(),yi=Ve(),Dg=Ve();function LT(r){class t extends Error{constructor(n,i){super(n),this.name=r,i&&Object.assign(this,i)}}return t}const Xd=LT("RequestError"),DT=200,zT=300,Qa=401;class OT{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 MT(i);if(!i.ok||i.status<DT||i.status>=zT)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 Cu(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 Cu(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 Cu(i,i.statusText),i.status)}createError(t,e){const n={serverURL:this.serverURL};return e!==void 0&&(n.status=e),new Xd(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[RT]=JSON.stringify(this.telemetryMeta)),Object.keys(e).length>0?e:void 0}}async function MT(r){try{return await r.json()}catch{const t=await r.text().catch(()=>"");return t?{message:t}:{}}}async function Cu(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 NT(r){return r.map(t=>`${t.name} (${t.id})`).join(", ")}var jt,tc,Cy;class UT{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,Cy).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,Cy=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: ${NT(e)}`)};var Sr;class FT{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 HT{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 ZT{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 WT{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 BT{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 OT(t,e)),this.screens=new UT(l(this,Gt)),this.artifacts=new FT(l(this,Gt)),this.display=new WT(l(this,Gt)),this.markdown=new HT(l(this,Gt)),this.telemetry=new ZT(l(this,Gt))}health(){return l(this,Gt).requestJSON("GET","/health")}}Gt=new WeakMap;const VT={focusCommandInput:{label:"Focus Command Input",trigger:{key:"k",meta:!0}}},jT="Local",GT="store-";function he(r){return new URL(r).origin}function qT(r){return{servers:[{url:he(r),name:jT}],activeServerURL:null,activeScreenID:null,tabs:{},screens:{},authTokens:{}}}function YT(r,t){return[...r.tabs[he(t)]??[]]}function KT(r,t,e){const n=he(t),i=r.tabs[n]??[];return i.includes(e)?r:{...r,tabs:{...r.tabs,[n]:[...i,e]}}}function JT(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 XT(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 QT extends Mt{constructor(e,n,i={}){super();w(this,Rn);w(this,Pn);w(this,Ln);b(this,Rn,`${GT}${e}`),b(this,Pn,i.storage??r$());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,n$(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 Ru(r,t){return r.authTokens[he(t)]??null}function e$(r,t,e){return{...r,authTokens:{...r.authTokens,[he(t)]:e}}}function t$(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 r$(){const r=globalThis.localStorage;if(!r)throw new Error("LocalStore: no storage adapter supplied and window.localStorage is unavailable");return r}function n$(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 i$ extends Event{constructor(){super("theme-changed")}}const s$=Ra(Mt);var Dn,Ne,Fr,Ge,Hr,_r,So,ee,bn,Ry,_o,Py,Ly,Dy,zy,ph,fh,gh,Oy;class o$ extends s${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,Py).call(this,n.screen);break;case"artifact-created":n.screenID===this.id&&p(this,ee,Ly).call(this,n.artifact);break;case"artifact-updated":p(this,ee,Dy).call(this,n.artifact);break;case"artifact-removed":n.screenID===this.id&&p(this,ee,zy).call(this,n.artifactID);break;case"artifact-content-changed":l(this,Ne).has(n.artifactID)&&this.dispatchEvent(new Dg("artifact-content-changed",{artifactID:n.artifactID}));break;case"theme-changed":this.dispatchEvent(new i$);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,Ry).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,Oy).call(this),this.dispatchEvent(new oe("change")))}setLayout(e){p(this,ee,bn).call(this);const n=vy(e);if(!by(n).valid)return;const s=p(this,ee,fh).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,gh).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,fh).call(this);p(this,ee,ph).call(this,e),this.dispatchEvent(new oe("change")),this.server.client.artifacts.delete({artifactID:e}).catch(()=>{this.disposed||(p(this,ee,gh).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 Dg("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")},Ry=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,Py=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"))},Ly=function(e){ml({layout:l(this,Ge)}).includes(e.id)||b(this,Ge,[...l(this,Ge),$y(e.id)]),l(this,Ne).set(e.id,e),this.dispatchEvent(new oe("change"))},Dy=function(e){const n=l(this,Ne).get(e.id);n&&(l(this,Ne).set(e.id,{...n,...e}),this.dispatchEvent(new oe("change")))},zy=function(e){p(this,ee,ph).call(this,e)&&this.dispatchEvent(new oe("change"))},ph=function(e){const n=l(this,Ne).delete(e),i=ml({layout:l(this,Ge)}).length,s=yy(l(this,Ge),e),o=ml({layout:s}).length;return b(this,Ge,s),n||i!==o},fh=function(){return{layout:structuredClone(l(this,Ge)),artifacts:new Map([...l(this,Ne).entries()].map(([e,n])=>[e,structuredClone(n)]))}},gh=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))},Oy=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 a$=Ra(Mt);var Pe,Ue,Tt,ko,xo,Eo,Ao,Xe,vl,mh,_i;class l$ extends a${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=YT(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,mh).call(this,KT(l(this,Pe).get(),i,n))}removeTab(e,n){p(this,Xe,mh).call(this,JT(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 o$({screen:s,server:i,localStore:l(this,Pe)}):null),i&&i.acpClient.setScreenContext(s?{screenID:s.id,screenName:s.name}:null),this.dispatchEvent(new gT("active-screen-changed")))},mh=function(e){e!==l(this,Pe).get()&&(l(this,Pe).set(e),this.dispatchEvent(new mT("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}:XT({...s,activeServerURL:i,activeScreenID:n},n);return l(this,Pe).set(o),!0};const My="0123456789ABCDEFGHJKMNPQRSTVWXYZ",Zl=32,c$=16,Ny=10,zg=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 u$(r){const t=Math.floor(r()*Zl)%Zl;return My.charAt(t)}function h$(r){const t=d$(),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 d$(){return g$()?self:typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:null}function p$(r,t){let e="";for(;r>0;r--)e=u$(t)+e;return e}function f$(r,t=Ny){if(isNaN(r))throw new qs(Tn.EncodeTimeValueMalformed,`Time must be a number: ${r}`);if(r>zg)throw new qs(Tn.EncodeTimeSizeExceeded,`Cannot encode a time larger than ${zg}: ${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=My.charAt(e)+n,r=(r-e)/Zl;return n}function g$(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}function Ac(r,t){const e=h$(),n=Date.now();return f$(n,Ny)+p$(c$,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 Uy extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const Fy={};function rn(r){return Fy}function Hy(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 vh(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 Qd(r){return r==null}function ep(r){const t=r.startsWith("^")?1:0,e=r.endsWith("$")?r.length-1:r.length;return r.slice(t,e)}function m$(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 Og=Symbol("evaluating");function te(r,t,e){let n;Object.defineProperty(r,t,{get(){if(n!==Og)return n===void 0&&(n=Og,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 Mg(r){return JSON.stringify(r)}function v$(r){return r.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Zy="captureStackTrace"in Error?Error.captureStackTrace:(...r)=>{};function go(r){return typeof r=="object"&&r!==null&&!Array.isArray(r)}const y$=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 Wy(r){return fs(r)?{...r}:Array.isArray(r)?[...r]:r}const b$=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 w$(r){return Object.keys(r).filter(t=>r[t]._zod.optin==="optional"&&r[t]._zod.optout==="optional")}const S$={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 _$(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 k$(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 x$(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 E$(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 A$(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 T$(r,t,e){const i=t._zod.def.checks;if(i&&i.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const o=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 $$(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 tp(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 By=(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,vh,2),Object.defineProperty(r,"toString",{value:()=>r.message,enumerable:!1})},Vy=A("$ZodError",By),jy=A("$ZodError",By,{Parent:Error});function I$(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 C$(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 rp=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 Zy(a,i==null?void 0:i.callee),a}return o.value},np=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 Zy(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??Vy)(s.issues.map(o=>nn(o,i,rn())))}:{success:!0,data:s.value}},R$=$c(jy),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}},P$=Ic(jy),L$=r=>(t,e,n)=>{const i=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return rp(r)(t,e,i)},D$=r=>(t,e,n)=>rp(r)(t,e,n),z$=r=>async(t,e,n)=>{const i=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return np(r)(t,e,i)},O$=r=>async(t,e,n)=>np(r)(t,e,n),M$=r=>(t,e,n)=>{const i=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return $c(r)(t,e,i)},N$=r=>(t,e,n)=>$c(r)(t,e,n),U$=r=>async(t,e,n)=>{const i=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return Ic(r)(t,e,i)},F$=r=>async(t,e,n)=>Ic(r)(t,e,n),H$=/^[cC][^\s-]{8,}$/,Z$=/^[0-9a-z]+$/,W$=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,B$=/^[0-9a-vA-V]{20}$/,V$=/^[A-Za-z0-9]{27}$/,j$=/^[a-zA-Z0-9_-]{21}$/,G$=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,q$=/^([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})$/,Ng=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)$/,Y$=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,K$="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function J$(){return new RegExp(K$,"u")}const X$=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Q$=/^(([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}|:))$/,eI=/^((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])$/,tI=/^(([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])$/,rI=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Gy=/^[A-Za-z0-9_-]*$/,nI=/^\+[1-9]\d{6,14}$/,qy="(?:(?:\\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])))",iI=new RegExp(`^${qy}$`);function Yy(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 sI(r){return new RegExp(`^${Yy(r)}$`)}function oI(r){const t=Yy({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(`^${qy}T(?:${n})$`)}const aI=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}$`)},lI=/^-?\d+$/,Ky=/^-?\d+(?:\.\d+)?$/,cI=/^(?:true|false)$/i,uI=/^[^A-Z]*$/,hI=/^[^a-z]*$/,ct=A("$ZodCheck",(r,t)=>{var e;r._zod??(r._zod={}),r._zod.def=t,(e=r._zod).onattach??(e.onattach=[])}),Jy={number:"number",bigint:"bigint",object:"date"},Xy=A("$ZodCheckLessThan",(r,t)=>{ct.init(r,t);const e=Jy[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})}}),Qy=A("$ZodCheckGreaterThan",(r,t)=>{ct.init(r,t);const e=Jy[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})}}),dI=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):m$(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})}}),pI=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]=S$[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=lI)}),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})}}),fI=A("$ZodCheckMaxLength",(r,t)=>{var e;ct.init(r,t),(e=r._zod.def).when??(e.when=n=>{const i=n.value;return!Qd(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=tp(i);n.issues.push({origin:o,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:r,continue:!t.abort})}}),gI=A("$ZodCheckMinLength",(r,t)=>{var e;ct.init(r,t),(e=r._zod.def).when??(e.when=n=>{const i=n.value;return!Qd(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=tp(i);n.issues.push({origin:o,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:r,continue:!t.abort})}}),mI=A("$ZodCheckLengthEquals",(r,t)=>{var e;ct.init(r,t),(e=r._zod.def).when??(e.when=n=>{const i=n.value;return!Qd(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=tp(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=()=>{})}),vI=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})}}),yI=A("$ZodCheckLowerCase",(r,t)=>{t.pattern??(t.pattern=uI),Cc.init(r,t)}),bI=A("$ZodCheckUpperCase",(r,t)=>{t.pattern??(t.pattern=hI),Cc.init(r,t)}),wI=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})}}),SI=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})}}),_I=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})}}),kI=A("$ZodCheckOverwrite",(r,t)=>{ct.init(r,t),r._zod.check=e=>{e.value=t.tx(e.value)}});class xI{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 EI={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=EI;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=R$(r,s);return a.success?{value:a.data}:{issues:(o=a.error)==null?void 0:o.issues}}catch{return P$(r,s).then(c=>{var u;return c.success?{value:c.data}:{issues:(u=c.error)==null?void 0:u.issues}})}},vendor:"zod",version:1}))}),ip=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()??aI(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),ip.init(r,t)}),AI=A("$ZodGUID",(r,t)=>{t.pattern??(t.pattern=q$),ge.init(r,t)}),TI=A("$ZodUUID",(r,t)=>{if(t.version){const n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(n===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Ng(n))}else t.pattern??(t.pattern=Ng());ge.init(r,t)}),$I=A("$ZodEmail",(r,t)=>{t.pattern??(t.pattern=Y$),ge.init(r,t)}),II=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})}}}),CI=A("$ZodEmoji",(r,t)=>{t.pattern??(t.pattern=J$()),ge.init(r,t)}),RI=A("$ZodNanoID",(r,t)=>{t.pattern??(t.pattern=j$),ge.init(r,t)}),PI=A("$ZodCUID",(r,t)=>{t.pattern??(t.pattern=H$),ge.init(r,t)}),LI=A("$ZodCUID2",(r,t)=>{t.pattern??(t.pattern=Z$),ge.init(r,t)}),DI=A("$ZodULID",(r,t)=>{t.pattern??(t.pattern=W$),ge.init(r,t)}),zI=A("$ZodXID",(r,t)=>{t.pattern??(t.pattern=B$),ge.init(r,t)}),OI=A("$ZodKSUID",(r,t)=>{t.pattern??(t.pattern=V$),ge.init(r,t)}),MI=A("$ZodISODateTime",(r,t)=>{t.pattern??(t.pattern=oI(t)),ge.init(r,t)}),NI=A("$ZodISODate",(r,t)=>{t.pattern??(t.pattern=iI),ge.init(r,t)}),UI=A("$ZodISOTime",(r,t)=>{t.pattern??(t.pattern=sI(t)),ge.init(r,t)}),FI=A("$ZodISODuration",(r,t)=>{t.pattern??(t.pattern=G$),ge.init(r,t)}),HI=A("$ZodIPv4",(r,t)=>{t.pattern??(t.pattern=X$),ge.init(r,t),r._zod.bag.format="ipv4"}),ZI=A("$ZodIPv6",(r,t)=>{t.pattern??(t.pattern=Q$),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})}}}),WI=A("$ZodCIDRv4",(r,t)=>{t.pattern??(t.pattern=eI),ge.init(r,t)}),BI=A("$ZodCIDRv6",(r,t)=>{t.pattern??(t.pattern=tI),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 eb(r){if(r==="")return!0;if(r.length%4!==0)return!1;try{return atob(r),!0}catch{return!1}}const VI=A("$ZodBase64",(r,t)=>{t.pattern??(t.pattern=rI),ge.init(r,t),r._zod.bag.contentEncoding="base64",r._zod.check=e=>{eb(e.value)||e.issues.push({code:"invalid_format",format:"base64",input:e.value,inst:r,continue:!t.abort})}});function jI(r){if(!Gy.test(r))return!1;const t=r.replace(/[-_]/g,n=>n==="-"?"+":"/"),e=t.padEnd(Math.ceil(t.length/4)*4,"=");return eb(e)}const GI=A("$ZodBase64URL",(r,t)=>{t.pattern??(t.pattern=Gy),ge.init(r,t),r._zod.bag.contentEncoding="base64url",r._zod.check=e=>{jI(e.value)||e.issues.push({code:"invalid_format",format:"base64url",input:e.value,inst:r,continue:!t.abort})}}),qI=A("$ZodE164",(r,t)=>{t.pattern??(t.pattern=nI),ge.init(r,t)});function YI(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 KI=A("$ZodJWT",(r,t)=>{ge.init(r,t),r._zod.check=e=>{YI(e.value,t.alg)||e.issues.push({code:"invalid_format",format:"jwt",input:e.value,inst:r,continue:!t.abort})}}),tb=A("$ZodNumber",(r,t)=>{ve.init(r,t),r._zod.pattern=r._zod.bag.pattern??Ky,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}}),JI=A("$ZodNumberFormat",(r,t)=>{pI.init(r,t),tb.init(r,t)}),XI=A("$ZodBoolean",(r,t)=>{ve.init(r,t),r._zod.pattern=cI,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}}),QI=A("$ZodUnknown",(r,t)=>{ve.init(r,t),r._zod.parse=e=>e}),eC=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 Ug(r,t,e){r.issues.length&&t.issues.push(...Li(e,r.issues)),t.value[e]=r.value}const tC=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=>Ug(u,e,o))):Ug(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 rb(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=w$(r.shape);return{...r,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(e)}}function nb(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 rC=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(()=>rb(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?nb(h,u,a,c,n.value,r):h.length?Promise.all(h).then(()=>a):a}}),nC=A("$ZodObjectJIT",(r,t)=>{rC.init(r,t);const e=r._zod.parse,n=Tc(()=>rb(t)),i=y=>{var B;const m=new xI(["shape","payload","ctx"]),E=n.value,x=N=>{const F=Mg(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=Mg(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=!Fy.jitless,u=a&&y$.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?nb([],E,y,m,f,r):y):e(y,m):(y.issues.push({expected:"object",code:"invalid_type",input:E,inst:r}),y)}});function Fg(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 ib=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=>ep(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=>Fg(c,i,r,s)):Fg(a,i,r,s)}}),iC=A("$ZodDiscriminatedUnion",(r,t)=>{t.inclusive=!1,ib.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)}}),sC=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])=>Hg(e,c,u)):Hg(e,s,o)}});function yh(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=yh(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=yh(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 Hg(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=yh(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 oC=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"&&Ky.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}}),aC=A("$ZodEnum",(r,t)=>{ve.init(r,t);const e=Hy(t.entries),n=new Set(e);r._zod.values=n,r._zod.pattern=new RegExp(`^(${e.filter(i=>b$.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}}),lC=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}}),cC=A("$ZodTransform",(r,t)=>{ve.init(r,t),r._zod.parse=(e,n)=>{if(n.direction==="backward")throw new Uy(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 Zg(r,t){return r.issues.length&&t===void 0?{issues:[],value:void 0}:r}const sb=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(`^(${ep(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=>Zg(s,e.value)):Zg(i,e.value)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),uC=A("$ZodExactOptional",(r,t)=>{sb.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)}),hC=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(`^(${ep(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)}),dC=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=>Wg(s,t)):Wg(i,t)}});function Wg(r,t){return r.value===void 0&&(r.value=t.defaultValue),r}const pC=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))}),fC=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=>Bg(s,r)):Bg(i,r)}});function Bg(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 gC=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)}}),mC=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 vC=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(Vg):Vg(i)}});function Vg(r){return r.value=Object.freeze(r.value),r}const yC=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=>jg(s,e,n,r));jg(i,e,n,r)}});function jg(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 Gg;class bC{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 wC(){return new bC}(Gg=globalThis).__zod_globalRegistry??(Gg.__zod_globalRegistry=wC());const Ys=globalThis.__zod_globalRegistry;function SC(r,t){return new r({type:"string",...O(t)})}function _C(r,t){return new r({type:"string",format:"email",check:"string_format",abort:!1,...O(t)})}function qg(r,t){return new r({type:"string",format:"guid",check:"string_format",abort:!1,...O(t)})}function kC(r,t){return new r({type:"string",format:"uuid",check:"string_format",abort:!1,...O(t)})}function xC(r,t){return new r({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...O(t)})}function EC(r,t){return new r({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...O(t)})}function AC(r,t){return new r({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...O(t)})}function TC(r,t){return new r({type:"string",format:"url",check:"string_format",abort:!1,...O(t)})}function $C(r,t){return new r({type:"string",format:"emoji",check:"string_format",abort:!1,...O(t)})}function IC(r,t){return new r({type:"string",format:"nanoid",check:"string_format",abort:!1,...O(t)})}function CC(r,t){return new r({type:"string",format:"cuid",check:"string_format",abort:!1,...O(t)})}function RC(r,t){return new r({type:"string",format:"cuid2",check:"string_format",abort:!1,...O(t)})}function PC(r,t){return new r({type:"string",format:"ulid",check:"string_format",abort:!1,...O(t)})}function LC(r,t){return new r({type:"string",format:"xid",check:"string_format",abort:!1,...O(t)})}function DC(r,t){return new r({type:"string",format:"ksuid",check:"string_format",abort:!1,...O(t)})}function zC(r,t){return new r({type:"string",format:"ipv4",check:"string_format",abort:!1,...O(t)})}function OC(r,t){return new r({type:"string",format:"ipv6",check:"string_format",abort:!1,...O(t)})}function MC(r,t){return new r({type:"string",format:"cidrv4",check:"string_format",abort:!1,...O(t)})}function NC(r,t){return new r({type:"string",format:"cidrv6",check:"string_format",abort:!1,...O(t)})}function UC(r,t){return new r({type:"string",format:"base64",check:"string_format",abort:!1,...O(t)})}function FC(r,t){return new r({type:"string",format:"base64url",check:"string_format",abort:!1,...O(t)})}function HC(r,t){return new r({type:"string",format:"e164",check:"string_format",abort:!1,...O(t)})}function ZC(r,t){return new r({type:"string",format:"jwt",check:"string_format",abort:!1,...O(t)})}function WC(r,t){return new r({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...O(t)})}function BC(r,t){return new r({type:"string",format:"date",check:"string_format",...O(t)})}function VC(r,t){return new r({type:"string",format:"time",check:"string_format",precision:null,...O(t)})}function jC(r,t){return new r({type:"string",format:"duration",check:"string_format",...O(t)})}function GC(r,t){return new r({type:"number",checks:[],...O(t)})}function qC(r,t){return new r({type:"number",check:"number_format",abort:!1,format:"safeint",...O(t)})}function YC(r,t){return new r({type:"boolean",...O(t)})}function KC(r){return new r({type:"unknown"})}function JC(r,t){return new r({type:"never",...O(t)})}function Yg(r,t){return new Xy({check:"less_than",...O(t),value:r,inclusive:!1})}function Pu(r,t){return new Xy({check:"less_than",...O(t),value:r,inclusive:!0})}function Kg(r,t){return new Qy({check:"greater_than",...O(t),value:r,inclusive:!1})}function Lu(r,t){return new Qy({check:"greater_than",...O(t),value:r,inclusive:!0})}function Jg(r,t){return new dI({check:"multiple_of",...O(t),value:r})}function ob(r,t){return new fI({check:"max_length",...O(t),maximum:r})}function Bl(r,t){return new gI({check:"min_length",...O(t),minimum:r})}function ab(r,t){return new mI({check:"length_equals",...O(t),length:r})}function XC(r,t){return new vI({check:"string_format",format:"regex",...O(t),pattern:r})}function QC(r){return new yI({check:"string_format",format:"lowercase",...O(r)})}function eR(r){return new bI({check:"string_format",format:"uppercase",...O(r)})}function tR(r,t){return new wI({check:"string_format",format:"includes",...O(t),includes:r})}function rR(r,t){return new SI({check:"string_format",format:"starts_with",...O(t),prefix:r})}function nR(r,t){return new _I({check:"string_format",format:"ends_with",...O(t),suffix:r})}function Ts(r){return new kI({check:"overwrite",tx:r})}function iR(r){return Ts(t=>t.normalize(r))}function sR(){return Ts(r=>r.trim())}function oR(){return Ts(r=>r.toLowerCase())}function aR(){return Ts(r=>r.toUpperCase())}function lR(){return Ts(r=>v$(r))}function cR(r,t,e){return new r({type:"array",element:t,...O(e)})}function uR(r,t,e){return new r({type:"custom",check:"custom",fn:t,...O(e)})}function hR(r){const t=dR(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 dR(r,t){const e=new ct({check:"custom",...O(t)});return e._zod.check=r,e}function lb(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 cb(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 ub(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 pR=(r,t={})=>e=>{const n=lb({...e,processors:t});return Ee(r,n),cb(n,r),ub(n,r)},Vl=(r,t,e={})=>n=>{const{libraryOptions:i,target:s}=n??{},o=lb({...i??{},target:s,io:t,processors:e});return Ee(r,o),cb(o,r),ub(o,r)},fR={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},gR=(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=fR[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}))])}},mR=(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)},vR=(r,t,e,n)=>{e.type="boolean"},yR=(r,t,e,n)=>{e.not={}},bR=(r,t,e,n)=>{},wR=(r,t,e,n)=>{const i=r._zod.def,s=Hy(i.entries);s.every(o=>typeof o=="number")&&(e.type="number"),s.every(o=>typeof o=="string")&&(e.type="string"),e.enum=s},SR=(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},_R=(r,t,e,n)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},kR=(r,t,e,n)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},xR=(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"]})},ER=(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)},AR=(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},TR=(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},$R=(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)}},IR=(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"}]},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},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,e.default=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,t.io==="input"&&(e._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},LR=(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},DR=(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},zR=(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},hb=(r,t,e,n)=>{const i=r._zod.def;Ee(i.innerType,t,n);const s=t.seen.get(r);s.ref=i.innerType},OR=A("ZodISODateTime",(r,t)=>{MI.init(r,t),be.init(r,t)});function MR(r){return WC(OR,r)}const NR=A("ZodISODate",(r,t)=>{NI.init(r,t),be.init(r,t)});function UR(r){return BC(NR,r)}const FR=A("ZodISOTime",(r,t)=>{UI.init(r,t),be.init(r,t)});function HR(r){return VC(FR,r)}const ZR=A("ZodISODuration",(r,t)=>{FI.init(r,t),be.init(r,t)});function WR(r){return jC(ZR,r)}const db=(r,t)=>{Vy.init(r,t),r.name="ZodError",Object.defineProperties(r,{format:{value:e=>C$(r,e)},flatten:{value:e=>I$(r,e)},addIssue:{value:e=>{r.issues.push(e),r.message=JSON.stringify(r.issues,vh,2)}},addIssues:{value:e=>{r.issues.push(...e),r.message=JSON.stringify(r.issues,vh,2)}},isEmpty:{get(){return r.issues.length===0}}})},Xg=A("ZodError",db),Et=A("ZodError",db,{Parent:Error}),BR=rp(Et),VR=np(Et),jR=$c(Et),GR=Ic(Et),qR=L$(Et),YR=D$(Et),KR=z$(Et),JR=O$(Et),XR=M$(Et),QR=N$(Et),eP=U$(Et),tP=F$(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=pR(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)=>BR(r,e,n,{callee:r.parse}),r.safeParse=(e,n)=>jR(r,e,n),r.parseAsync=async(e,n)=>VR(r,e,n,{callee:r.parseAsync}),r.safeParseAsync=async(e,n)=>GR(r,e,n),r.spa=r.safeParseAsync,r.encode=(e,n)=>qR(r,e,n),r.decode=(e,n)=>YR(r,e,n),r.encodeAsync=async(e,n)=>KR(r,e,n),r.decodeAsync=async(e,n)=>JR(r,e,n),r.safeEncode=(e,n)=>XR(r,e,n),r.safeDecode=(e,n)=>QR(r,e,n),r.safeEncodeAsync=async(e,n)=>eP(r,e,n),r.safeDecodeAsync=async(e,n)=>tP(r,e,n),r.refine=(e,n)=>r.check(GP(e,n)),r.superRefine=e=>r.check(qP(e)),r.overwrite=e=>r.check(Ts(e)),r.optional=()=>tm(r),r.exactOptional=()=>DP(r),r.nullable=()=>rm(r),r.nullish=()=>tm(rm(r)),r.nonoptional=e=>FP(r,e),r.array=()=>z(r),r.or=e=>V([r,e]),r.and=e=>Rc(r,e),r.transform=e=>nm(r,PP(e)),r.default=e=>MP(r,e),r.prefault=e=>UP(r,e),r.catch=e=>ZP(r,e),r.pipe=e=>nm(r,e),r.readonly=()=>VP(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)),pb=A("_ZodString",(r,t)=>{ip.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(n,i,s)=>gR(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(XC(...n)),r.includes=(...n)=>r.check(tR(...n)),r.startsWith=(...n)=>r.check(rR(...n)),r.endsWith=(...n)=>r.check(nR(...n)),r.min=(...n)=>r.check(Bl(...n)),r.max=(...n)=>r.check(ob(...n)),r.length=(...n)=>r.check(ab(...n)),r.nonempty=(...n)=>r.check(Bl(1,...n)),r.lowercase=n=>r.check(QC(n)),r.uppercase=n=>r.check(eR(n)),r.trim=()=>r.check(sR()),r.normalize=(...n)=>r.check(iR(...n)),r.toLowerCase=()=>r.check(oR()),r.toUpperCase=()=>r.check(aR()),r.slugify=()=>r.check(lR())}),rP=A("ZodString",(r,t)=>{ip.init(r,t),pb.init(r,t),r.email=e=>r.check(_C(nP,e)),r.url=e=>r.check(TC(iP,e)),r.jwt=e=>r.check(ZC(bP,e)),r.emoji=e=>r.check($C(sP,e)),r.guid=e=>r.check(qg(Qg,e)),r.uuid=e=>r.check(kC(rl,e)),r.uuidv4=e=>r.check(xC(rl,e)),r.uuidv6=e=>r.check(EC(rl,e)),r.uuidv7=e=>r.check(AC(rl,e)),r.nanoid=e=>r.check(IC(oP,e)),r.guid=e=>r.check(qg(Qg,e)),r.cuid=e=>r.check(CC(aP,e)),r.cuid2=e=>r.check(RC(lP,e)),r.ulid=e=>r.check(PC(cP,e)),r.base64=e=>r.check(UC(mP,e)),r.base64url=e=>r.check(FC(vP,e)),r.xid=e=>r.check(LC(uP,e)),r.ksuid=e=>r.check(DC(hP,e)),r.ipv4=e=>r.check(zC(dP,e)),r.ipv6=e=>r.check(OC(pP,e)),r.cidrv4=e=>r.check(MC(fP,e)),r.cidrv6=e=>r.check(NC(gP,e)),r.e164=e=>r.check(HC(yP,e)),r.datetime=e=>r.check(MR(e)),r.date=e=>r.check(UR(e)),r.time=e=>r.check(HR(e)),r.duration=e=>r.check(WR(e))});function d(r){return SC(rP,r)}const be=A("ZodStringFormat",(r,t)=>{ge.init(r,t),pb.init(r,t)}),nP=A("ZodEmail",(r,t)=>{$I.init(r,t),be.init(r,t)}),Qg=A("ZodGUID",(r,t)=>{AI.init(r,t),be.init(r,t)}),rl=A("ZodUUID",(r,t)=>{TI.init(r,t),be.init(r,t)}),iP=A("ZodURL",(r,t)=>{II.init(r,t),be.init(r,t)}),sP=A("ZodEmoji",(r,t)=>{CI.init(r,t),be.init(r,t)}),oP=A("ZodNanoID",(r,t)=>{RI.init(r,t),be.init(r,t)}),aP=A("ZodCUID",(r,t)=>{PI.init(r,t),be.init(r,t)}),lP=A("ZodCUID2",(r,t)=>{LI.init(r,t),be.init(r,t)}),cP=A("ZodULID",(r,t)=>{DI.init(r,t),be.init(r,t)}),uP=A("ZodXID",(r,t)=>{zI.init(r,t),be.init(r,t)}),hP=A("ZodKSUID",(r,t)=>{OI.init(r,t),be.init(r,t)}),dP=A("ZodIPv4",(r,t)=>{HI.init(r,t),be.init(r,t)}),pP=A("ZodIPv6",(r,t)=>{ZI.init(r,t),be.init(r,t)}),fP=A("ZodCIDRv4",(r,t)=>{WI.init(r,t),be.init(r,t)}),gP=A("ZodCIDRv6",(r,t)=>{BI.init(r,t),be.init(r,t)}),mP=A("ZodBase64",(r,t)=>{VI.init(r,t),be.init(r,t)}),vP=A("ZodBase64URL",(r,t)=>{GI.init(r,t),be.init(r,t)}),yP=A("ZodE164",(r,t)=>{qI.init(r,t),be.init(r,t)}),bP=A("ZodJWT",(r,t)=>{KI.init(r,t),be.init(r,t)}),fb=A("ZodNumber",(r,t)=>{tb.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(n,i,s)=>mR(r,n,i),r.gt=(n,i)=>r.check(Kg(n,i)),r.gte=(n,i)=>r.check(Lu(n,i)),r.min=(n,i)=>r.check(Lu(n,i)),r.lt=(n,i)=>r.check(Yg(n,i)),r.lte=(n,i)=>r.check(Pu(n,i)),r.max=(n,i)=>r.check(Pu(n,i)),r.int=n=>r.check(em(n)),r.safe=n=>r.check(em(n)),r.positive=n=>r.check(Kg(0,n)),r.nonnegative=n=>r.check(Lu(0,n)),r.negative=n=>r.check(Yg(0,n)),r.nonpositive=n=>r.check(Pu(0,n)),r.multipleOf=(n,i)=>r.check(Jg(n,i)),r.step=(n,i)=>r.check(Jg(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 GC(fb,r)}const wP=A("ZodNumberFormat",(r,t)=>{JI.init(r,t),fb.init(r,t)});function em(r){return qC(wP,r)}const SP=A("ZodBoolean",(r,t)=>{XI.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(e,n,i)=>vR(r,e,n)});function De(r){return YC(SP,r)}const _P=A("ZodUnknown",(r,t)=>{QI.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(e,n,i)=>bR()});function _(){return KC(_P)}const kP=A("ZodNever",(r,t)=>{eC.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(e,n,i)=>yR(r,e,n)});function xP(r){return JC(kP,r)}const EP=A("ZodArray",(r,t)=>{tC.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(e,n,i)=>xR(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(ob(e,n)),r.length=(e,n)=>r.check(ab(e,n)),r.unwrap=()=>r.element});function z(r,t){return cR(EP,r,t)}const gb=A("ZodObject",(r,t)=>{nC.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(e,n,i)=>ER(r,e,n,i),te(r,"shape",()=>t.shape),r.keyof=()=>yb(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:xP()}),r.strip=()=>r.clone({...r._zod.def,catchall:void 0}),r.extend=e=>x$(r,e),r.safeExtend=e=>E$(r,e),r.merge=e=>A$(r,e),r.pick=e=>_$(r,e),r.omit=e=>k$(r,e),r.partial=(...e)=>T$(bb,r,e[0]),r.required=(...e)=>$$(wb,r,e[0])});function mb(r,t){const e={type:"object",shape:r??{},...O(t)};return new gb(e)}function v(r,t){return new gb({type:"object",shape:r,catchall:_(),...O(t)})}const vb=A("ZodUnion",(r,t)=>{ib.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(e,n,i)=>AR(r,e,n,i),r.options=t.options});function V(r,t){return new vb({type:"union",options:r,...O(t)})}const AP=A("ZodDiscriminatedUnion",(r,t)=>{vb.init(r,t),iC.init(r,t)});function TP(r,t,e){return new AP({type:"union",options:t,discriminator:r,...O(e)})}const $P=A("ZodIntersection",(r,t)=>{sC.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(e,n,i)=>TR(r,e,n,i)});function Rc(r,t){return new $P({type:"intersection",left:r,right:t})}const IP=A("ZodRecord",(r,t)=>{oC.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(e,n,i)=>$R(r,e,n,i),r.keyType=t.keyType,r.valueType=t.valueType});function k(r,t,e){return new IP({type:"record",keyType:r,valueType:t,...O(e)})}const bh=A("ZodEnum",(r,t)=>{aC.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(n,i,s)=>wR(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 bh({...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 bh({...t,checks:[],...O(i),entries:s})}});function yb(r,t){const e=Array.isArray(r)?Object.fromEntries(r.map(n=>[n,n])):r;return new bh({type:"enum",entries:e,...O(t)})}const CP=A("ZodLiteral",(r,t)=>{lC.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(e,n,i)=>SR(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 CP({type:"literal",values:Array.isArray(r)?r:[r],...O(t)})}const RP=A("ZodTransform",(r,t)=>{cC.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(e,n,i)=>kR(r,e),r._zod.parse=(e,n)=>{if(n.direction==="backward")throw new Uy(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 PP(r){return new RP({type:"transform",transform:r})}const bb=A("ZodOptional",(r,t)=>{sb.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(e,n,i)=>hb(r,e,n,i),r.unwrap=()=>r._zod.def.innerType});function tm(r){return new bb({type:"optional",innerType:r})}const LP=A("ZodExactOptional",(r,t)=>{uC.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(e,n,i)=>hb(r,e,n,i),r.unwrap=()=>r._zod.def.innerType});function DP(r){return new LP({type:"optional",innerType:r})}const zP=A("ZodNullable",(r,t)=>{hC.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 rm(r){return new zP({type:"nullable",innerType:r})}const OP=A("ZodDefault",(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,r.removeDefault=r.unwrap});function MP(r,t){return new OP({type:"default",innerType:r,get defaultValue(){return typeof t=="function"?t():Wy(t)}})}const NP=A("ZodPrefault",(r,t)=>{pC.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(e,n,i)=>PR(r,e,n,i),r.unwrap=()=>r._zod.def.innerType});function UP(r,t){return new NP({type:"prefault",innerType:r,get defaultValue(){return typeof t=="function"?t():Wy(t)}})}const wb=A("ZodNonOptional",(r,t)=>{fC.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(e,n,i)=>CR(r,e,n,i),r.unwrap=()=>r._zod.def.innerType});function FP(r,t){return new wb({type:"nonoptional",innerType:r,...O(t)})}const HP=A("ZodCatch",(r,t)=>{gC.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(e,n,i)=>LR(r,e,n,i),r.unwrap=()=>r._zod.def.innerType,r.removeCatch=r.unwrap});function ZP(r,t){return new HP({type:"catch",innerType:r,catchValue:typeof t=="function"?t:()=>t})}const WP=A("ZodPipe",(r,t)=>{mC.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(e,n,i)=>DR(r,e,n,i),r.in=t.in,r.out=t.out});function nm(r,t){return new WP({type:"pipe",in:r,out:t})}const BP=A("ZodReadonly",(r,t)=>{vC.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(e,n,i)=>zR(r,e,n,i),r.unwrap=()=>r._zod.def.innerType});function VP(r){return new BP({type:"readonly",innerType:r})}const jP=A("ZodCustom",(r,t)=>{yC.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(e,n,i)=>_R(r,e)});function GP(r,t={}){return uR(jP,r,t)}function qP(r){return hR(r)}const YP=[".md",".markdown"];function Sb(r){if(r.length===0)return!1;const t=r.at(-1);return t==="/"||t==="\\"}function _b(r){const t=r.lastIndexOf("/"),e=r.lastIndexOf("\\");return r.slice(Math.max(t,e)+1)}function KP(r){return _b(r).toLowerCase()}function JP(r,t){const e=KP(r);return t.some(n=>e.endsWith(n))}function kb(r){return!Sb(r)&&JP(r,YP)}function XP(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 QP=mb({id:d().min(1),kind:T("path"),title:d(),path:d()}).strict(),eL=mb({id:d().min(1),kind:T("url"),title:d(),url:d().refine(XP,{message:"url must be an http(s) URL"})}).strict();TP("kind",[QP,eL]);function xb(r){return typeof r=="object"&&r!==null}function Eb(r){return!xb(r)||r.type!=="ready"?!1:!("id"in r)}function Ab(r){return!(!xb(r)||r.type!=="update-content"||typeof r.id!="string"||typeof r.content!="string")}const tL="/views/markdown/",rL="/views/url-unsupported/";function Tb(r){return`/artifact/${encodeURIComponent(r)}`}function nL(r,t){return`${Tb(r)}/${encodeURIComponent(t)}`}function iL(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:rL,contentURL:null};if(kb(r.path)){const n={viewURL:tL,contentURL:iL(r.id)};return t.electron?{renderer:"url-webview",...n}:{renderer:"markdown",...n}}const e=Sb(r.path)?`${Tb(r.id)}/`:nL(r.id,_b(r.path));return t.electron?{renderer:"url-webview",viewURL:e,contentURL:null}:{renderer:"proxy-iframe",viewURL:e,contentURL:null}}const sL="serverURL",oL="token",aL="mode",lL="desktopAppVersion",cL="electron";function $b(r=window.location.search,t=window.location.origin){const n=new URLSearchParams(r).get(sL);return n?new URL(n).origin:new URL(t).origin}function uL(r=window.location.search){return new URLSearchParams(r).get(oL)}function cr(r=typeof window>"u"?"":window.location.search){return new URLSearchParams(r).get(aL)===cL}function hL(r=typeof window>"u"?"":window.location.search){return new URLSearchParams(r).get(lL)}const im="tv.telemetry.clientId",dL=5,pL=60,fL=1e3,gL=dL*pL*fL,sm=["pointerdown","scroll","keydown"],om=["focus"],am=["visibilitychange"],mL="hidden";function vL(r,t=_L){const e=r.getItem(im);if(e)return e;const n=t();return r.setItem(im,n),n}function yL(r){return{clientId:vL(r.storage,r.idFactory),userAgent:r.userAgent??(typeof navigator>"u"?"":navigator.userAgent),clientApp:r.clientApp,...r.desktopAppVersion?{desktopAppVersion:r.desktopAppVersion}:{}}}function bL(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 wL(r){return new SL(r)}var To,kr,Zr,$o,Io,gt,zn,Co,rc,Ib;class SL{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,Ib).call(this))}start(){if(!l(this,zn)){b(this,zn,!0);for(const t of sm)l(this,Zr).addEventListener(t,l(this,gt)),l(this,kr).addEventListener(t,l(this,gt));for(const t of om)l(this,Zr).addEventListener(t,l(this,gt));for(const t of am)l(this,kr).addEventListener(t,l(this,gt))}}stop(){if(l(this,zn)){b(this,zn,!1);for(const t of sm)l(this,Zr).removeEventListener(t,l(this,gt)),l(this,kr).removeEventListener(t,l(this,gt));for(const t of om)l(this,Zr).removeEventListener(t,l(this,gt));for(const t of am)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,Ib=function(){if(l(this,kr).visibilityState===mL)return;const t=l(this,Io).call(this);t-l(this,Co)<gL||(b(this,Co,t),l(this,$o).call(this,{type:PT,clientId:l(this,To).clientId}))};function _L(){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"},kL=1,xL=v({_meta:k(d(),_()).nullish(),terminal:De().optional().default(!1)}),EL=v({_meta:k(d(),_()).nullish(),label:d().nullish(),name:d(),optional:De().optional().default(!1),secret:De().optional().default(!0)}),AL=v({_meta:k(d(),_()).nullish(),description:d().nullish(),id:d(),name:d()}),TL=v({_meta:k(d(),_()).nullish(),description:d().nullish(),id:d(),link:d().nullish(),name:d(),vars:z(EL)}),$L=v({_meta:k(d(),_()).nullish(),args:z(d()).optional(),description:d().nullish(),env:k(d(),d()).optional(),id:d(),name:d()}),IL=V([TL.and(v({type:T("env_var")})),$L.and(v({type:T("terminal")})),AL]),CL=v({_meta:k(d(),_()).nullish(),methodId:d()}),RL=v({_meta:k(d(),_()).nullish()}),PL=v({_meta:k(d(),_()).nullish(),blob:d(),mimeType:d().nullish(),uri:d()}),LL=v({default:De().nullish(),description:d().nullish(),title:d().nullish()}),DL=v({_meta:k(d(),_()).nullish()}),zL=v({_meta:k(d(),_()).nullish()}),OL=v({amount:H(),currency:d()}),ML=v({_meta:k(d(),_()).nullish(),terminalId:d()}),NL=v({_meta:k(d(),_()).nullish(),newText:d(),oldText:d().nullish(),path:d()}),UL=V([d(),H(),H(),De(),z(d())]),FL=v({content:k(d(),UL).nullish()}),HL=V([FL.and(v({action:T("accept")})),v({action:T("decline")}),v({action:T("cancel")})]),ZL=v({_meta:k(d(),_()).nullish()}),Cb=d(),WL=v({_meta:k(d(),_()).nullish(),elicitationId:Cb}),BL=v({_meta:k(d(),_()).nullish(),action:HL}),VL=T("object"),jL=T("string"),GL=v({_meta:k(d(),_()).nullish()}),qL=v({_meta:k(d(),_()).nullish(),form:ZL.nullish(),url:GL.nullish()}),YL=v({elicitationId:Cb,url:d().url()}),Rb=v({const:d(),title:d()}),Pb=v({_meta:k(d(),_()).nullish(),name:d(),value:d()}),KL=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"})]),Lb=v({code:KL,data:_().optional(),message:d()}),Db=_(),zb=_(),Ob=_(),JL=v({_meta:k(d(),_()).nullish(),readTextFile:De().optional().default(!1),writeTextFile:De().optional().default(!1)}),Mb=v({_meta:k(d(),_()).nullish(),name:d(),value:d()}),Nb=v({_meta:k(d(),_()).nullish(),name:d(),title:d().nullish(),version:d()}),XL=v({default:H().nullish(),description:d().nullish(),maximum:H().nullish(),minimum:H().nullish(),title:d().nullish()}),QL=v({_meta:k(d(),_()).nullish()}),eD=v({_meta:k(d(),_()).nullish(),additionalDirectories:z(d()).optional(),cursor:d().nullish(),cwd:d().nullish()}),tD=v({_meta:k(d(),_()).nullish()}),rD=v({_meta:k(d(),_()).nullish(),logout:tD.nullish()}),nD=v({_meta:k(d(),_()).nullish()}),iD=v({_meta:k(d(),_()).nullish()}),sD=v({_meta:k(d(),_()).nullish(),http:De().optional().default(!1),sse:De().optional().default(!1)}),oD=v({_meta:k(d(),_()).nullish(),headers:z(Mb),name:d(),url:d()}),aD=v({_meta:k(d(),_()).nullish(),headers:z(Mb),name:d(),url:d()}),lD=v({_meta:k(d(),_()).nullish(),args:z(d()),command:d(),env:z(Pb),name:d()}),Pc=V([oD.and(v({type:T("http")})),aD.and(v({type:T("sse")})),lD]),sp=d(),cD=v({_meta:k(d(),_()).nullish(),description:d().nullish(),modelId:sp,name:d()}),uD=V([T("error"),T("warning"),T("information"),T("hint")]),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()}),mD=v({_meta:k(d(),_()).nullish(),maxCount:H().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),vD=v({diff:d(),uri:d()}),yD=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()}),bD=v({_meta:k(d(),_()).nullish()}),wD=v({_meta:k(d(),_()).nullish()}),SD=v({languageId:d(),text:d(),uri:d()}),_D=v({_meta:k(d(),_()).nullish(),maxCount:H().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),kD=V([T("rejected"),T("ignored"),T("replaced"),T("cancelled")]),xD=v({excerpts:z(yD),uri:d()}),ED=v({_meta:k(d(),_()).nullish()}),AD=v({_meta:k(d(),_()).nullish()}),TD=v({name:d(),owner:d(),remoteUrl:d()}),$D=v({_meta:k(d(),_()).nullish()}),ID=v({_meta:k(d(),_()).nullish(),jump:bD.nullish(),rename:AD.nullish(),searchAndReplace:$D.nullish()}),CD=v({id:d(),isRegex:De().nullish(),replace:d(),search:d(),uri:d()}),RD=V([T("automatic"),T("diagnostic"),T("manual")]),PD=v({_meta:k(d(),_()).nullish(),maxCount:H().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),LD=v({_meta:k(d(),_()).nullish(),diagnostics:hD.nullish(),editHistory:mD.nullish(),openFiles:wD.nullish(),recentFiles:_D.nullish(),relatedSnippets:ED.nullish(),userActions:PD.nullish()}),DD=v({_meta:k(d(),_()).nullish(),additionalDirectories:z(d()).optional(),cwd:d(),mcpServers:z(Pc)}),zD=v({default:H().nullish(),description:d().nullish(),maximum:H().nullish(),minimum:H().nullish(),title:d().nullish()}),Ub=d(),OD=V([T("allow_once"),T("allow_always"),T("reject_once"),T("reject_always")]),MD=v({_meta:k(d(),_()).nullish(),kind:OD,name:d(),optionId:Ub}),ND=V([T("high"),T("medium"),T("low")]),UD=V([T("pending"),T("in_progress"),T("completed")]),FD=v({_meta:k(d(),_()).nullish(),content:d(),priority:ND,status:UD}),HD=v({_meta:k(d(),_()).nullish(),entries:z(FD)}),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"})}),ZD=v({id:d(),position:sn,uri:d()}),WD=v({id:d(),newName:d(),position:sn,uri:d()}),BD=v({action:d(),position:sn,timestampMs:H(),uri:d()}),Fb=V([T("utf-16"),T("utf-32"),T("utf-8")]),VD=v({_meta:k(d(),_()).nullish(),auth:xL.optional().default({terminal:!1}),elicitation:qL.nullish(),fs:JL.optional().default({readTextFile:!1,writeTextFile:!1}),nes:ID.nullish(),positionEncodings:z(Fb).optional(),terminal:De().optional().default(!1)}),jD=v({_meta:k(d(),_()).nullish(),audio:De().optional().default(!1),embeddedContext:De().optional().default(!1),image:De().optional().default(!1)}),Hb=H().int().gte(0).lte(65535),GD=v({_meta:k(d(),_()).nullish(),clientCapabilities:VD.optional().default({auth:{terminal:!1},fs:{readTextFile:!1,writeTextFile:!1},terminal:!1}),clientInfo:Nb.nullish(),protocolVersion:Hb}),$s=v({end:sn,start:sn}),qD=v({message:d(),range:$s,severity:uD,uri:d()}),YD=v({languageId:d(),lastFocusedMs:H().nullish(),uri:d(),visibleRange:$s.nullish()}),KD=v({_meta:k(d(),_()).nullish(),diagnostics:z(qD).nullish(),editHistory:z(vD).nullish(),openFiles:z(YD).nullish(),recentFiles:z(SD).nullish(),relatedSnippets:z(xD).nullish(),userActions:z(BD).nullish()}),JD=v({newText:d(),range:$s}),XD=v({cursorPosition:sn.nullish(),edits:z(JD),id:d(),uri:d()}),QD=V([XD.and(v({kind:T("edit")})),ZD.and(v({kind:T("jump")})),WD.and(v({kind:T("rename")})),CD.and(v({kind:T("searchAndReplace")}))]),e2=v({_meta:k(d(),_()).nullish(),content:d()}),t2=v({_meta:k(d(),_()).nullish()}),Xn=V([H(),d()]).nullable();v({_meta:k(d(),_()).nullish(),requestId:Xn});const r2=yb(["assistant","user"]),Pa=v({_meta:k(d(),_()).nullish(),audience:z(r2).nullish(),lastModified:d().nullish(),priority:H().nullish()}),n2=v({_meta:k(d(),_()).nullish(),annotations:Pa.nullish(),data:d(),mimeType:d()}),i2=v({_meta:k(d(),_()).nullish(),annotations:Pa.nullish(),data:d(),mimeType:d(),uri:d().nullish()}),s2=v({_meta:k(d(),_()).nullish(),annotations:Pa.nullish(),description:d().nullish(),mimeType:d().nullish(),name:d(),size:H().nullish(),title:d().nullish(),uri:d()}),o2=v({_meta:k(d(),_()).nullish(),optionId:Ub}),a2=V([v({outcome:T("cancelled")}),o2.and(v({outcome:T("selected")}))]),l2=v({_meta:k(d(),_()).nullish(),outcome:a2}),c2=v({_meta:k(d(),_()).nullish()}),u2=v({_meta:k(d(),_()).nullish()}),h2=v({currentValue:De()}),d2=d(),Zb=d(),p2=V([T("mode"),T("model"),T("thought_level"),d()]),op=d(),Wb=v({_meta:k(d(),_()).nullish(),description:d().nullish(),name:d(),value:op}),f2=v({_meta:k(d(),_()).nullish(),group:d2,name:d(),options:z(Wb)}),g2=V([z(Wb),z(f2)]),m2=v({currentValue:op,options:g2}),Is=Rc(V([m2.and(v({type:T("select")})),h2.and(v({type:T("boolean")}))]),v({_meta:k(d(),_()).nullish(),category:p2.nullish(),description:d().nullish(),id:Zb,name:d()})),v2=v({_meta:k(d(),_()).nullish(),configOptions:z(Is)}),y2=v({_meta:k(d(),_()).nullish()}),Q=d(),b2=v({_meta:k(d(),_()).nullish(),id:d(),sessionId:Q}),w2=v({_meta:k(d(),_()).nullish(),sessionId:Q}),S2=v({_meta:k(d(),_()).nullish(),sessionId:Q}),_2=v({_meta:k(d(),_()).nullish(),sessionId:Q}),Bb=v({_meta:k(d(),_()).nullish(),args:z(d()).optional(),command:d(),cwd:d().nullish(),env:z(Pb).optional(),outputByteLimit:H().nullish(),sessionId:Q}),k2=v({_meta:k(d(),_()).nullish(),sessionId:Q,uri:d()}),x2=v({_meta:k(d(),_()).nullish(),position:sn,sessionId:Q,uri:d(),version:H(),visibleRange:$s}),E2=v({_meta:k(d(),_()).nullish(),languageId:d(),sessionId:Q,text:d(),uri:d(),version:H()}),A2=v({_meta:k(d(),_()).nullish(),sessionId:Q,uri:d()}),T2=v({_meta:k(d(),_()).nullish(),additionalDirectories:z(d()).optional(),cwd:d(),mcpServers:z(Pc).optional(),sessionId:Q}),Vb=v({_meta:k(d(),_()).nullish(),sessionId:Q,terminalId:d()}),$2=v({_meta:k(d(),_()).nullish(),additionalDirectories:z(d()).optional(),cwd:d(),mcpServers:z(Pc),sessionId:Q}),jb=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}),I2=v({_meta:k(d(),_()).nullish(),id:d(),reason:kD.nullish(),sessionId:Q}),Gb=v({_meta:k(d(),_()).nullish(),sessionId:Q,terminalId:d()}),C2=v({_meta:k(d(),_()).nullish(),additionalDirectories:z(d()).optional(),cwd:d(),mcpServers:z(Pc).optional(),sessionId:Q}),R2=v({_meta:k(d(),_()).nullish(),additionalDirectories:z(d()).optional(),cwd:d(),sessionId:Q,title:d().nullish(),updatedAt:d().nullish()}),P2=v({_meta:k(d(),_()).nullish(),nextCursor:d().nullish(),sessions:z(R2)}),L2=v({_meta:k(d(),_()).nullish(),title:d().nullish(),updatedAt:d().nullish()}),D2=v({_meta:k(d(),_()).nullish()}),Lc=d(),z2=v({_meta:k(d(),_()).nullish(),currentModeId:Lc}),O2=v({_meta:k(d(),_()).nullish(),description:d().nullish(),id:Lc,name:d()}),Dc=v({_meta:k(d(),_()).nullish(),availableModes:z(O2),currentModeId:Lc}),zc=v({_meta:k(d(),_()).nullish(),availableModels:z(cD),currentModelId:sp}),M2=v({_meta:k(d(),_()).nullish(),configOptions:z(Is).nullish(),models:zc.nullish(),modes:Dc.nullish(),sessionId:Q}),N2=v({_meta:k(d(),_()).nullish(),configOptions:z(Is).nullish(),models:zc.nullish(),modes:Dc.nullish()}),U2=v({_meta:k(d(),_()).nullish(),configOptions:z(Is).nullish(),models:zc.nullish(),modes:Dc.nullish(),sessionId:Q}),F2=v({_meta:k(d(),_()).nullish(),configOptions:z(Is).nullish(),models:zc.nullish(),modes:Dc.nullish()}),H2=v({_meta:k(d(),_()).nullish()}),Z2=v({_meta:k(d(),_()).nullish(),additionalDirectories:c2.nullish(),close:u2.nullish(),fork:y2.nullish(),list:D2.nullish(),resume:H2.nullish()}),W2=Rc(V([v({type:T("boolean"),value:De()}),v({value:op})]),v({_meta:k(d(),_()).nullish(),configId:Zb,sessionId:Q})),B2=v({_meta:k(d(),_()).nullish(),configOptions:z(Is)}),V2=v({_meta:k(d(),_()).nullish(),modeId:Lc,sessionId:Q}),j2=v({_meta:k(d(),_()).nullish()}),G2=v({_meta:k(d(),_()).nullish(),modelId:sp,sessionId:Q}),q2=v({_meta:k(d(),_()).nullish()}),Y2=v({_meta:k(d(),_()).nullish(),sessionId:Q}),K2=V([T("end_turn"),T("max_tokens"),T("max_turn_requests"),T("refusal"),T("cancelled")]),J2=V([T("email"),T("uri"),T("date"),T("date-time")]),X2=v({default:d().nullish(),description:d().nullish(),enum:z(d()).nullish(),format:J2.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(Rb).nullish(),pattern:d().nullish(),title:d().nullish()}),Q2=v({_meta:k(d(),_()).nullish(),context:KD.nullish(),position:sn,selection:$s.nullish(),sessionId:Q,triggerKind:RD,uri:d(),version:H()}),ez=v({_meta:k(d(),_()).nullish(),suggestions:z(QD)}),tz=v({_meta:k(d(),_()).nullish(),terminalId:d()}),rz=v({_meta:k(d(),_()).nullish(),exitCode:H().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:d().nullish()}),qb=v({_meta:k(d(),_()).nullish(),sessionId:Q,terminalId:d()}),nz=v({_meta:k(d(),_()).nullish(),exitStatus:rz.nullish(),output:d(),truncated:De()}),iz=v({_meta:k(d(),_()).nullish(),annotations:Pa.nullish(),text:d()}),sz=v({range:$s.nullish(),text:d()}),oz=v({_meta:k(d(),_()).nullish(),contentChanges:z(sz),sessionId:Q,uri:d(),version:H()});v({method:d(),params:V([w2,E2,oz,k2,A2,x2,b2,I2,Db]).nullish()});const az=V([T("full"),T("incremental")]),lz=v({_meta:k(d(),_()).nullish(),syncKind:az}),cz=v({_meta:k(d(),_()).nullish(),didChange:lz.nullish(),didClose:dD.nullish(),didFocus:pD.nullish(),didOpen:fD.nullish(),didSave:gD.nullish()}),uz=v({_meta:k(d(),_()).nullish(),document:cz.nullish()}),hz=v({_meta:k(d(),_()).nullish(),context:LD.nullish(),events:uz.nullish()}),dz=v({_meta:k(d(),_()).nullish(),auth:rD.optional().default({}),loadSession:De().optional().default(!1),mcpCapabilities:sD.optional().default({http:!1,sse:!1}),nes:hz.nullish(),positionEncoding:Fb.nullish(),promptCapabilities:jD.optional().default({audio:!1,embeddedContext:!1,image:!1}),sessionCapabilities:Z2.optional().default({})}),pz=v({_meta:k(d(),_()).nullish(),agentCapabilities:dz.optional().default({auth:{},loadSession:!1,mcpCapabilities:{http:!1,sse:!1},promptCapabilities:{audio:!1,embeddedContext:!1,image:!1},sessionCapabilities:{}}),agentInfo:Nb.nullish(),authMethods:z(IL).optional().default([]),protocolVersion:Hb}),fz=v({_meta:k(d(),_()).nullish(),mimeType:d().nullish(),text:d(),uri:d()}),gz=V([fz,PL]),mz=v({_meta:k(d(),_()).nullish(),annotations:Pa.nullish(),resource:gz}),ap=V([iz.and(v({type:T("text")})),i2.and(v({type:T("image")})),n2.and(v({type:T("audio")})),s2.and(v({type:T("resource_link")})),mz.and(v({type:T("resource")}))]),vz=v({_meta:k(d(),_()).nullish(),content:ap}),Du=v({_meta:k(d(),_()).nullish(),content:ap,messageId:d().nullish()}),yz=v({_meta:k(d(),_()).nullish(),messageId:d().nullish(),prompt:z(ap),sessionId:Q}),bz=v({anyOf:z(Rb)}),Yb=V([vz.and(v({type:T("content")})),NL.and(v({type:T("diff")})),tz.and(v({type:T("terminal")}))]),Kb=d(),Jb=v({_meta:k(d(),_()).nullish(),line:H().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:d()}),Xb=V([T("pending"),T("in_progress"),T("completed"),T("failed")]),Qb=V([T("read"),T("edit"),T("delete"),T("move"),T("search"),T("execute"),T("think"),T("fetch"),T("switch_mode"),T("other")]),wz=v({_meta:k(d(),_()).nullish(),content:z(Yb).optional(),kind:Qb.optional(),locations:z(Jb).optional(),rawInput:_().optional(),rawOutput:_().optional(),status:Xb.optional(),title:d(),toolCallId:Kb}),ew=v({_meta:k(d(),_()).nullish(),content:z(Yb).nullish(),kind:Qb.nullish(),locations:z(Jb).nullish(),rawInput:_().optional(),rawOutput:_().optional(),status:Xb.nullish(),title:d().nullish(),toolCallId:Kb}),tw=v({_meta:k(d(),_()).nullish(),options:z(MD),sessionId:Q,toolCall:ew}),Sz=v({_meta:k(d(),_()).nullish(),hint:d()}),_z=Sz,kz=v({_meta:k(d(),_()).nullish(),description:d(),input:_z.nullish(),name:d()}),xz=v({_meta:k(d(),_()).nullish(),availableCommands:z(kz)}),Ez=v({enum:z(d()),type:jL}),Az=V([Ez,bz]),Tz=v({default:z(d()).nullish(),description:d().nullish(),items:Az,maxItems:H().nullish(),minItems:H().nullish(),title:d().nullish()}),$z=V([X2.and(v({type:T("string")})),zD.and(v({type:T("number")})),XL.and(v({type:T("integer")})),LL.and(v({type:T("boolean")})),Tz.and(v({type:T("array")}))]),Iz=v({description:d().nullish(),properties:k(d(),$z).optional().default({}),required:z(d()).nullish(),title:d().nullish(),type:VL.optional().default("object")}),Cz=v({requestedSchema:Iz}),Rz=Rc(V([Cz.and(v({mode:T("form")})),YL.and(v({mode:T("url")}))]),v({_meta:k(d(),_()).nullish(),message:d(),sessionId:Q})),Pz=v({cachedReadTokens:H().nullish(),cachedWriteTokens:H().nullish(),inputTokens:H(),outputTokens:H(),thoughtTokens:H().nullish(),totalTokens:H()}),Lz=v({_meta:k(d(),_()).nullish(),stopReason:K2,usage:Pz.nullish(),userMessageId:d().nullish()});V([v({id:Xn,result:V([pz,RL,iD,U2,N2,P2,M2,F2,zL,j2,B2,Lz,q2,Y2,ez,DL,Ob])}),v({error:Lb,id:Xn})]);const Dz=v({_meta:k(d(),_()).nullish(),cost:OL.nullish(),size:H(),used:H()}),zz=V([Du.and(v({sessionUpdate:T("user_message_chunk")})),Du.and(v({sessionUpdate:T("agent_message_chunk")})),Du.and(v({sessionUpdate:T("agent_thought_chunk")})),wz.and(v({sessionUpdate:T("tool_call")})),ew.and(v({sessionUpdate:T("tool_call_update")})),HD.and(v({sessionUpdate:T("plan")})),xz.and(v({sessionUpdate:T("available_commands_update")})),z2.and(v({sessionUpdate:T("current_mode_update")})),v2.and(v({sessionUpdate:T("config_option_update")})),L2.and(v({sessionUpdate:T("session_info_update")})),Dz.and(v({sessionUpdate:T("usage_update")}))]),rw=v({_meta:k(d(),_()).nullish(),sessionId:Q,update:zz});v({method:d(),params:V([rw,WL,Db]).nullish()});const nw=v({_meta:k(d(),_()).nullish(),sessionId:Q,terminalId:d()}),Oz=v({_meta:k(d(),_()).nullish(),exitCode:H().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:d().nullish()}),Mz=v({name:d(),uri:d()}),Nz=v({_meta:k(d(),_()).nullish(),repository:TD.nullish(),workspaceFolders:z(Mz).nullish(),workspaceUri:d().nullish()});v({id:Xn,method:d(),params:V([GD,CL,nD,DD,$2,eD,T2,C2,_2,V2,W2,yz,G2,Nz,Q2,S2,zb]).nullish()});const iw=v({_meta:k(d(),_()).nullish(),content:d(),path:d(),sessionId:Q});v({id:Xn,method:d(),params:V([iw,jb,tw,Bb,qb,Gb,nw,Vb,Rz,zb]).nullish()});const Uz=v({_meta:k(d(),_()).nullish()});V([v({id:Xn,result:V([Uz,e2,l2,ML,nz,t2,Oz,QL,BL,Ob])}),v({error:Lb,id:Xn})]);var X;class Fz{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=iw.parse(a);return(c=n.writeTextFile)==null?void 0:c.call(n,x)}case mr.fs_read_text_file:{const x=jb.parse(a);return(u=n.readTextFile)==null?void 0:u.call(n,x)}case mr.session_request_permission:{const x=tw.parse(a);return n.requestPermission(x)}case mr.terminal_create:{const x=Bb.parse(a);return(h=n.createTerminal)==null?void 0:h.call(n,x)}case mr.terminal_output:{const x=qb.parse(a);return(f=n.terminalOutput)==null?void 0:f.call(n,x)}case mr.terminal_release:{const x=Gb.parse(a);return await((y=n.releaseTerminal)==null?void 0:y.call(n,x))??{}}case mr.terminal_wait_for_exit:{const x=nw.parse(a);return(m=n.waitForTerminalExit)==null?void 0:m.call(n,x)}case mr.terminal_kill:{const x=Vb.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=rw.parse(a);return n.sessionUpdate(c)}default:if(n.extNotification)return n.extNotification(o,a);throw Ce.methodNotFound(o)}};b(this,X,new Hz(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,sw,wh,ow,aw,lw,cw,Sh,Ks;class Hz{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,sw).call(this)}get signal(){return l(this,qt).signal}get closed(){return l(this,Lo)}async sendRequest(t,e){p(this,me,Sh).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,Sh).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,sw=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,ow).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,wh).call(this,t)}},wh=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)},ow=async function(t){if("method"in t&&"id"in t){const e=await p(this,me,aw).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,lw).call(this,t.method,t.params);"error"in e&&console.error("Error handling notification",t,e.error)}else"id"in t?p(this,me,cw).call(this,t):console.error("Invalid message",{message:t})},aw=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 Xg)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()}}},lw=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 Xg)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()}}},cw=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)},Sh=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,wh).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 Zz=/^Sender \(untrusted metadata\):\n```json\n[\s\S]*?\n```\n\n?/,Wz=/^\[[^\n]*Working directory:[^\n]*\]\n\n?/,Bz=/\[Television screen context\][\s\S]*?\[\/Television screen context\]\n*/,Vz=/\b(tv|television|screen|artifact|artifacts|viewer|filmstrip|layout|focus)\b/i,jz=/\[\[\s*(?:reply_to_current|reply_to\s*:\s*[^\]\n]+|audio_as_voice)\s*\]\]\s*/gi,Gz="single_session",qz={name:"television-acp-client",version:"0.0.0"},uw="agent:main:television",Yz=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,$,_h,hw,dw,pw,yl,fw,gw,mw,vw,yw,bw,ww,wn,ki,xi,yr,Sw,Ei,kh,xh,bl,_w,wl,Eh,Ah,zo,Oo,Sl,Ai,Th,kw;class Kz extends Yz{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,$,dw).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??Gz),b(this,Vr,e.mappedSessionStore??Jz()),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,$,hw).call(this)));try{await l(this,Br),await p(this,$,yl).call(this)}catch(e){throw p(this,$,Ai).call(this,zu(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,$,_h).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,$,xh).call(this),prompt:[{type:"text",text:p(this,$,Sw).call(this,n)}]});p(this,$,wn).call(this,i.stopReason==="cancelled"?"cancelled":"final"),p(this,$,yr).call(this,"ready")}catch(i){throw p(this,$,kw).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,$,_h).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,$,Th).call(this)}async cancel(){this.status==="running"&&(p(this,$,yr).call(this,"cancelling"),await p(this,$,bl).call(this).cancel({sessionId:p(this,$,xh).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,$,Eh).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,zu(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,_h=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)})}},hw=async function(){try{const{stream:e,socket:n,metadata:i}=await tO({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 Fz(s=>({connection:s,sessionUpdate:async o=>{await p(this,$,gw).call(this,o)},requestPermission:async o=>p(this,$,mw).call(this,o)}),e)),await l(this,Kt).initialize({protocolVersion:kL,clientCapabilities:{},clientInfo:qz})}catch(e){throw e}},dw=function(e){p(this,$,Ai).call(this,zu(e))},pw=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,$,fw).call(this,e)),await l(this,$t)},fw=async function(e){var c;const n=p(this,$,bl).call(this);p(this,$,Th).call(this);let i,s=!1,o=null;const a={cwd:p(this,$,_w).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(Xz(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,$,pw).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")},gw=async function(e){const n=e.update;switch(n.sessionUpdate){case"user_message_chunk":n.content.type==="text"&&p(this,$,ww).call(this,n.content.text);return;case"agent_message_chunk":n.content.type==="text"&&p(this,$,vw).call(this,n.content.text);return;case"tool_call":p(this,$,yw).call(this,n);return;case"tool_call_update":p(this,$,bw).call(this,n);return;case"agent_thought_chunk":return;default:return}},mw=async function(e){return{outcome:{outcome:"cancelled"}}},vw=function(e){b(this,Ar,null);const n=eO(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"})},yw=function(e){p(this,$,wn).call(this,"final");const n=p(this,$,kh).call(this,e.toolCallId),i=cm("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)},bw=function(e){const n=p(this,$,kh).call(this,e.toolCallId),i=(n==null?void 0:n.text)??"",s=cm(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)},ww=function(e){if(p(this,$,wn).call(this,"final"),!e)return;const n=l(this,On)?l(this,Ar):null;if(!n){const s=lm(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:lm(`${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 Iu("messages-changed"))},xi=function(e){l(this,ht).set(e.id,e),this.dispatchEvent(new Iu("messages-changed"))},yr=function(e){l(this,Zi)!==e&&(b(this,Zi,e),this.dispatchEvent(new yT("status-changed")))},Sw=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||Vz.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},kh=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},xh=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)},_w=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,$,Ah).call(this,`${uw}-${(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,$,Eh).call(this,e)},Eh=function(e){return p(this,$,Ah).call(this,Qz(l(this,er),e,l(this,Ct).clientGUID??"default-client"))},Ah=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"))},Th=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 Iu("messages-changed"))},kw=function(){return this.status==="disconnected"};function Jz(){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 Xz(r){return r==null?!0:typeof r=="object"&&Object.keys(r).length===0}function Qz(r,t,e){return r==="single_session"?`${uw}-${e.toLowerCase()}`:`agent:main:television-${e.toLowerCase()}-${t.toLowerCase()}`}function xw(r){return r.replace(/^(?:\s*\n)+/,"")}function lm(r){let t=r;return t=t.replace(Zz,""),t=t.replace(Wz,""),t=t.replace(Bz,""),t=xw(t),t}function eO(r){let t=r;return t=t.replace(jz,""),t=xw(t),t}function cm(r){return!r||r.length===0?"":r.flatMap(t=>t.type==="content"&&t.content.type==="text"?[t.content.text]:[]).join("")}async function tO(r){const t=r.createSocket(iO(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=nO(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=rO(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 rO(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 nO(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 iO(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 zu(r){return r instanceof Error?r.message:String(r)}const um="television.acpClientGUID",hm="television.acpMappedSessions",dm=1;var ji;class sO{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,$h;class oO{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,$h).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,$h).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(hm);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!==dm?{}:typeof n.entries!="object"||n.entries===null||Array.isArray(n.entries)?{}:Object.fromEntries(Object.entries(n.entries).filter(i=>typeof i[1]=="string"))},$h=function(t){const e={version:dm,entries:t};l(this,Gi).setItem(hm,JSON.stringify(e))};function Ew(){return typeof window>"u"?null:window.localStorage}function aO(r){const t=r.getItem(um);if(t)return t;const e=Ac().toLowerCase();return r.setItem(um,e),e}const pm=4401,lO=401,nl=1e3,cO=3e4;class ao extends Error{constructor(t="Authentication required"){super(t),this.name="AuthError"}}class Aw 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 BT(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 oO(e.acpStorage,this.url):new sO);this.acpClient=new Kz({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?wL({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,$y(e.artifact.id)]);break}case"artifact-removed":{const n=this.screens.get(e.screenID);n&&(n.layout=yy(n.layout,e.artifactID));break}case"artifact-updated":case"artifact-content-changed":case"screen-changed":case"theme-changed":case"artifact-focus":break;default:return uO(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(hO(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 dh("server-event",{serverURL:this.url,event:{type:"screen-changed",screenID:m.activeScreenID}})),c(),f&&this.connectAttempt===e&&this.dispatchEvent(new my("server-reconnected",{serverURL:this.url}))}catch(y){if(fO(y)){u(new ao);return}u(y instanceof Error?y:new Error(String(y)))}};n.addEventListener("open",()=>{h()}),n.addEventListener("message",f=>{const y=pO(f);y&&(this.applyServerEvent(y),this.dispatchEvent(new dh("server-event",{serverURL:this.url,event:y})))}),n.addEventListener("close",f=>{if(this.connectAttempt!==e)return;this.socket=null;const y=dO(f);if(!a){u(y===pm?new ao:new Error("Connection closed before initialization"));return}if(y===pm){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,cO),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 uO(r,t){throw new Error(`Unexpected ${t}: ${JSON.stringify(r)}`)}function hO(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 bL(e))n.searchParams.set(i,s);return n.hash="",n.toString()}function dO(r){return typeof r=="object"&&r!==null&&"code"in r&&typeof r.code=="number"?r.code:null}function pO(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 fO(r){return r instanceof Xd&&r.status===lO}const gO="Local";var No,Ih;class mO 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?Ew():e.acpStorage;this.acpStorage=n,this.clientGUID=e.clientGUID??(n?aO(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 dh("server-event",{serverURL:u.serverURL,event:u.event}))},a=()=>{this.dispatchEvent(new Gs("screens-changed"))},c=u=>{this.dispatchEvent(new my("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 Ru(this.localStore.get(),e)}setStoredAuthToken(e,n){this.localStore.set(e$(this.localStore.get(),e,n))}clearStoredAuthToken(e){const n=this.localStore.get(),i=t$(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:gO}]})}const s=this.localStore.get().servers;for(const a of s){const c=he(a.url),h=i!==null&&c===i?n??Ru(this.localStore.get(),c):Ru(this.localStore.get(),c),f=p(this,No,Ih).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,Ih).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,Ih=function(e){return new Aw({url:e.url,name:e.name,token:e.token,createSocket:this.createSocket,clientGUID:this.clientGUID,acpStorage:this.acpStorage,telemetryMeta:this.telemetryMeta})};var Uo;class vO extends Mt{constructor(){super();w(this,Uo,e=>{const n=yO(e);n!==null&&(e.preventDefault(),this.dispatchEvent(new vT("shortcut-triggered",{shortcut:n})))});document.addEventListener("keydown",l(this,Uo))}dispose(){document.removeEventListener("keydown",l(this,Uo))}}Uo=new WeakMap;function yO(r){for(const[t,e]of Object.entries(VT))if(bO(r,e.trigger))return t;return null}function bO(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 Ch="tv-nav:",ms="tv-reload",fm=100,wO=1e3,SO=60,_O=60,kO=24,xO=30,EO=xO*kO*_O*SO*wO;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,Tw,Mr,$w,Rh,Ph;class AO 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,Tw).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,Rh).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,Tw=function(){const e=localStorage.getItem(l(this,ke,Ph));if(e!==null)try{const n=JSON.parse(e);if(!Iw(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,Rh).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,Ph),JSON.stringify(p(this,ke,$w).call(this)))}catch(e){if(!IO(e))throw e}this.dispatchEvent(new oe("change"))},$w=function(){return{v:1,entries:l(this,ue).map(e=>({...e})),cursor:l(this,ne),lastWritten:l(this,Mn)}},Rh=function(){if(l(this,ue).length<=fm)return;const e=l(this,ue).length-fm;b(this,ue,l(this,ue).slice(e)),b(this,ne,Math.max(-1,l(this,ne)-e))},Ph=function(){return TO(l(this,Fo))};function TO(r){return`${Ch}${r}`}function $O(r){const t=Date.now()-EO,e=[];for(let n=0;n<localStorage.length;n+=1){const i=localStorage.key(n);if(!(i!=null&&i.startsWith(Ch)))continue;const s=i.slice(Ch.length),o=localStorage.getItem(i);if(o===null)continue;let a;try{a=JSON.parse(o)}catch{e.push(i);continue}if(!Iw(a)){e.push(i);continue}!r.has(s)&&a.lastWritten<t&&e.push(i)}for(const n of e)localStorage.removeItem(n)}function IO(r){return r instanceof DOMException&&r.name==="QuotaExceededError"}function Iw(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 Cw(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;gy(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,gm=r=>r,Gl=lo.trustedTypes,mm=Gl?Gl.createPolicy("lit-html",{createHTML:r=>r}):void 0,Rw="$lit$",Ur=`lit$${Math.random().toFixed(9).slice(2)}$`,Pw="?"+Ur,CO=`<${Pw}>`,Qn=document,vo=()=>Qn.createComment(""),yo=r=>r===null||typeof r!="object"&&typeof r!="function",lp=Array.isArray,RO=r=>lp(r)||typeof(r==null?void 0:r[Symbol.iterator])=="function",Ou=`[
|
|
48
|
-
\f\r]`,Ns=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,vm=/-->/g,ym=/>/g,gn=RegExp(`>|${Ou}(?:([^\\s"'>=/]+)(${Ou}*=${Ou}*(?:[^
|
|
49
|
-
\f\r"'\`<>=]|("|')|))|$)`,"g"),bm=/'/g,wm=/"/g,Lw=/^(?:script|style|textarea|title)$/i,PO=r=>(t,...e)=>({_$litType$:r,strings:t,values:e}),D=PO(1),ei=Symbol.for("lit-noChange"),le=Symbol.for("lit-nothing"),Sm=new WeakMap,$n=Qn.createTreeWalker(Qn,129);function Dw(r,t){if(!lp(r)||!r.hasOwnProperty("raw"))throw Error("invalid template strings array");return mm!==void 0?mm.createHTML(t):t}const LO=(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=vm:h[1]!==void 0?o=ym:h[2]!==void 0?(Lw.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]==='"'?wm:bm):o===wm||o===bm?o=gn:o===vm||o===ym?o=Ns:(o=gn,i=void 0);const m=o===gn&&r[a+1].startsWith("/>")?" ":"";s+=o===Ns?c+CO:f>=0?(n.push(u),c.slice(0,f)+Rw+c.slice(f)+Ur+m):c+Ur+(f===-2?a:m)}return[Dw(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]=LO(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(Rw)){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]==="."?zO:E[1]==="?"?OO:E[1]==="@"?MO:Mc}),i.removeAttribute(f)}else f.startsWith(Ur)&&(c.push({type:6,index:s}),i.removeAttribute(f));if(Lw.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===Pw)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 DO{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 NO(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 zw{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):RO(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(Dw(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 DO(i,this),a=o.u(this.options);o.p(e),this.T(a),this._$AH=o}}_$AC(t){let e=Sm.get(t.strings);return e===void 0&&Sm.set(t.strings,e=new bo(t)),e}k(t){lp(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 zw(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=gm(t).nextSibling;gm(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??"")}},zO=class extends Mc{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===le?void 0:t}},OO=class extends Mc{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==le)}},MO=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 NO{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 UO={I:Oc},Mu=lo.litHtmlPolyfillSupport;Mu==null||Mu(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 cp={CHILD:2},Nc=r=>(...t)=>({_$litDirective$:r,values:t});let up=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 up{constructor(t){if(super(t),this.it=le,t.type!==cp.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 FO=Nc(ql);/**
|
|
58
|
-
* @license
|
|
59
|
-
* Copyright 2017 Google LLC
|
|
60
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
61
|
-
*/let Lh=class extends ql{};Lh.directiveName="unsafeSVG",Lh.resultType=2;const Ow=Nc(Lh),HO={size:16,color:"currentColor",weight:"regular"};function ZO(r){return typeof r=="string"?{regular:r}:r}function Nt(r,t="0 0 256 256"){const e=ZO(r);return n=>{const{size:i,color:s,weight:o}={...HO,...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
|
-
>${Ow(a)}</svg>`}}/**
|
|
69
|
-
* @license
|
|
70
|
-
* Copyright 2020 Google LLC
|
|
71
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
72
|
-
*/const{I:WO}=UO,_m=r=>r,BO=r=>r.strings===void 0,km=()=>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(km(),i),a=n.insertBefore(km(),i);e=new WO(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=_m(u).nextSibling;_m(n).insertBefore(u,i),u=h}}}return e},mn=(r,t,e=r)=>(r._$AI(t,e),r),VO={},jO=(r,t=VO)=>r._$AH=t,GO=r=>r._$AH,Nu=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)},Mw=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),KO(t)}};function qO(r){this._$AN!==void 0?(Yl(this),this._$AM=r,Mw(this)):this._$AM=r}function YO(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 KO=r=>{r.type==cp.CHILD&&(r._$AP??(r._$AP=YO),r._$AQ??(r._$AQ=qO))};class JO extends up{constructor(){super(...arguments),this._$AN=void 0}_$AT(t,e,n){super._$AT(t,e,n),Mw(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(BO(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 XO;class XO{}const Uu=new WeakMap,El=Nc(class extends JO{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=Uu.get(t);e===void 0&&(e=new WeakMap,Uu.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=Uu.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)}}),hp=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"/>'),QO=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"/>'),eM=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"/>'),tM=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"/>'),rM=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"/>'}),nM=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"/>'}),iM=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"/>'}),sM=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"/>'),Nw=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"/>'}),oM=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 aM extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}const xm='a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])',Fu=4;var Fe,it,Nn,st,Ho,Yi,Ki,W,Dh,zh,Fw,Al,Hw,Oh,Mh,Zo,Wo,Un,Zw,Nh,Ww,Bw,Tl,Ti;class Uw 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,Zw).call(this,e)}});w(this,Un,()=>{l(this,Fe)&&p(this,W,Tl).call(this)});b(this,Nn,this.attachShadow({mode:"open"})),Yd(l(this,Nn)),p(this,W,zh).call(this,"anchor")}connectedCallback(){this.removeAttribute("popover"),this.hasAttribute("tone")||this.setAttribute("tone","light"),p(this,W,zh).call(this,"open"),p(this,W,Ti).call(this),l(this,Fe)&&(p(this,W,Oh).call(this),p(this,W,Al).call(this))}disconnectedCallback(){var e;p(this,W,Mh).call(this),(e=l(this,it))==null||e.removeAttribute("aria-expanded")}attributeChangedCallback(e){e==="open"?p(this,W,Fw).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,Dh).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,Dh=function(){l(this,it)&&l(this,it).setAttribute("aria-expanded",l(this,Fe)?"true":"false")},zh=function(e){if(!Object.prototype.hasOwnProperty.call(this,e))return;const n=this,i=n[e];delete n[e],n[e]=i},Fw=function(e){var n,i,s;if(l(this,Fe)!==e){if(b(this,Fe,e),p(this,W,Dh).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,Oh).call(this),p(this,W,Al).call(this)):(p(this,W,Mh).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 aM))}},Al=function(){l(this,Ki)||(b(this,Ki,!0),queueMicrotask(()=>{b(this,Ki,!1),!(!l(this,Fe)||!this.isConnected)&&(p(this,W,Hw).call(this),p(this,W,Bw).call(this))}))},Hw=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)}},Oh=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)},Mh=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,Zw=function(e){const n=p(this,W,Nh).call(this);if(n.length===0){e.preventDefault();return}const i=n[0],s=n[n.length-1],o=p(this,W,Ww).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())},Nh=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(xm)&&n.push(i);for(const s of i.querySelectorAll(xm))n.push(s)}return n},Ww=function(){var n;let e=document.activeElement;for(;e&&((n=e.shadowRoot)!=null&&n.activeElement);)e=e.shadowRoot.activeElement;return e},Bw=function(){var n;const e=p(this,W,Nh).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+Fu,a=s<o&&e.top>o?"top-start":"bottom-start";b(this,Ho,a);const c=a==="bottom-start"?e.bottom+Fu:e.top-n.height-Fu,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(Uw,"observedAttributes",["open","material"]);customElements.get("ui-popover")||customElements.define("ui-popover",Uw);class Vw extends Event{constructor(e){super("dropdown-item-select",{bubbles:!0,composed:!0});g(this,"value");this.value=e}}class lM 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,Gw,Js,qw,Yw,Uh,Kw,Xs,Sn,Fn,jo,sc,Go,oc,Jw,Xw,Fh,Qs,Hh,Zh,br;class jw 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,Jw).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 Vw&&(e.stopPropagation(),b(this,ot,!1),p(this,M,Js).call(this,e.value),p(this,M,br).call(this),this.dispatchEvent(new lM(e.value)))});w(this,oc,()=>{p(this,M,Fh).call(this)});b(this,qr,this.attachShadow({mode:"open"})),Yd(l(this,qr))}connectedCallback(){this.addEventListener("dropdown-item-select",l(this,Go)),p(this,M,Gw).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,Zh).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,qw).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,Gw=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,Uh))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")},qw=function(){const e=this.querySelectorAll("dropdown-item[selected]");for(const n of e)n.removeAttribute("selected")},Yw=function(e){for(const n of l(this,M,Uh))if(n.value===e)return n;return null},Uh=function(){return this.querySelectorAll("dropdown-item")},Kw=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,Jw=function(e){e.every(i=>i.target instanceof Element?i.target.closest('[slot="trigger"]')!==null:!1)||p(this,M,Xw).call(this)},Xw=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,Yw).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)},Fh=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,Zh).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,Hh).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"))},Hh=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},Zh=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,Kw)}</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,Hh).call(this),queueMicrotask(()=>p(this,M,Fh).call(this))},g(jw,"observedAttributes",["title","open"]);class cM extends HTMLElement{}class uM extends HTMLElement{}class hM extends HTMLElement{}var ni,Wh,e0,qo,Yo;class Qw extends HTMLElement{constructor(){super(...arguments);w(this,ni);w(this,qo,()=>{this.action||p(this,ni,e0).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,Wh).call(this)}disconnectedCallback(){this.removeEventListener("click",l(this,qo)),this.removeEventListener("keydown",l(this,Yo))}attributeChangedCallback(){p(this,ni,Wh).call(this)}get value(){return this.getAttribute("value")??""}get selected(){return this.hasAttribute("selected")}get action(){return this.hasAttribute("action")}}ni=new WeakSet,Wh=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")},e0=function(){this.dispatchEvent(new Vw(this.value))},qo=new WeakMap,Yo=new WeakMap,g(Qw,"observedAttributes",["action","selected","value"]);customElements.get("dropdown-menu")||customElements.define("dropdown-menu",jw);customElements.get("dropdown-group")||customElements.define("dropdown-group",cM);customElements.get("dropdown-label")||customElements.define("dropdown-label",uM);customElements.get("dropdown-divider")||customElements.define("dropdown-divider",hM);customElements.get("dropdown-item")||customElements.define("dropdown-item",Qw);class dM extends Event{constructor(e){super("rename",{bubbles:!0,composed:!0});g(this,"value");this.value=e}}var rr,Pt,ie,He,eo,Ko,Bh,$l,Vh,Jo,Xo,Qo;class t0 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,Bh).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,Vh).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,Bh).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,Bh=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,Vh).call(this),e&&n.length>0&&n!==l(this,rr)&&(b(this,rr,n),this.dispatchEvent(new dM(n))),p(this,He,eo).call(this)},Vh=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(t0,"observedAttributes",["value"]);customElements.get("editable-text")||customElements.define("editable-text",t0);class pM extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}var ea,on,jh,ac,ta,Gh;class r0 extends HTMLElement{constructor(){super();w(this,on);w(this,ea);w(this,ac,e=>{e.target===e.currentTarget&&p(this,on,jh).call(this)});w(this,ta,e=>{this.open&&e.key==="Escape"&&p(this,on,jh).call(this)});b(this,ea,this.attachShadow({mode:"open"}))}connectedCallback(){document.addEventListener("keydown",l(this,ta)),p(this,on,Gh).call(this)}disconnectedCallback(){document.removeEventListener("keydown",l(this,ta))}attributeChangedCallback(){p(this,on,Gh).call(this)}get open(){return this.hasAttribute("open")}}ea=new WeakMap,on=new WeakSet,jh=function(){this.dispatchEvent(new pM)},ac=new WeakMap,ta=new WeakMap,Gh=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(r0,"observedAttributes",["open"]);customElements.get("modal-overlay")||customElements.define("modal-overlay",r0);const fM=16,Hu=24,gM=32;var Ji;class n0 extends HTMLElement{constructor(){super();w(this,Ji);b(this,Ji,this.attachShadow({mode:"open"})),Yd(l(this,Ji))}connectedCallback(){this.render()}attributeChangedCallback(){this.render()}getSize(){const e=this.getAttribute("size");if(e===null)return Hu;const n=Number(e);return n===fM||n===Hu||n===gM?n:Hu}getWeight(){return this.getAttribute("weight")==="bold"?"bold":"regular"}render(){Be(D`<span class="spin">${Nw({size:this.getSize(),weight:this.getWeight()})}</span>`,l(this,Ji))}}Ji=new WeakMap,g(n0,"observedAttributes",["size","weight"]);customElements.get("ui-spinner")||customElements.define("ui-spinner",n0);class mM extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}class vM extends HTMLElement{}var ra,na,qh;class i0 extends HTMLElement{constructor(){super();w(this,na);w(this,ra);b(this,ra,this.attachShadow({mode:"open"}))}connectedCallback(){p(this,na,qh).call(this)}attributeChangedCallback(){p(this,na,qh).call(this)}get closable(){return this.hasAttribute("closable")}}ra=new WeakMap,na=new WeakSet,qh=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 mM)}
|
|
135
|
-
>
|
|
136
|
-
<span class="close-icon" part="icon close-icon">${hp({size:16})}</span>
|
|
137
|
-
</button>
|
|
138
|
-
`:null}
|
|
139
|
-
</header>
|
|
140
|
-
<slot></slot>
|
|
141
|
-
</section>
|
|
142
|
-
`,l(this,ra))},g(i0,"observedAttributes",["closable"]);customElements.get("panel-view")||customElements.define("panel-view",i0);customElements.get("panel-page")||customElements.define("panel-page",vM);const yM=`
|
|
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
|
-
`,bM=`
|
|
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
|
-
`,wM=`
|
|
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 SM extends HTMLElement{constructor(){super();w(this,ia);b(this,ia,this.attachShadow({mode:"open"})),l(this,ia).innerHTML=`<style>${bM}</style><div part="list"><slot></slot></div>`}connectedCallback(){this.hasAttribute("role")||this.setAttribute("role","list")}}ia=new WeakMap;var Xi,sa,oa,Yh;class s0 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>${wM}</style>
|
|
239
|
-
<label part="label">
|
|
240
|
-
<input type="checkbox" disabled tabindex="-1">
|
|
241
|
-
<span part="box"><span part="check">${yM}</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,Yh).call(this)}attributeChangedCallback(){p(this,oa,Yh).call(this)}}Xi=new WeakMap,sa=new WeakMap,oa=new WeakSet,Yh=function(){const e=this.hasAttribute("checked");l(this,sa).checked=e,this.setAttribute("aria-checked",e?"true":"false")},g(s0,"observedAttributes",["checked"]);customElements.get("checkbox-list")||customElements.define("checkbox-list",SM);customElements.get("checkbox-item")||customElements.define("checkbox-item",s0);const o0=Ve(),a0="No handler registered for update-content",l0="handleUpdateContent: handler already registered",Em="television-artifact-bridge";function c0(r){return r instanceof Error&&typeof r.message=="string"?r.message:String(r)}const u0=Ra(Mt);var Qi,es,ts,Hn,Zn,aa,Ze,Kh,h0,d0,to,Jh,lv;let _M=(lv=class extends u0{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,h0).call(this,i)),l(this,es).addEventListener("message",l(this,ts))}get content(){return l(this,Zn)}set content(e){p(this,Ze,Jh).call(this),b(this,Zn,e),l(this,aa)&&p(this,Ze,Kh).call(this,e)}handleUpdateContent(e){if(p(this,Ze,Jh).call(this),l(this,Hn)!==null)throw new Error(l0);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,Kh=function(e){const n={type:"content-updated",content:e};p(this,Ze,to).call(this,n)},h0=function(e){if(this.disposed||e.source!==l(this,Qi).contentWindow)return;const n=e.data;if(Eb(n)){b(this,aa,!0),this.dispatchEvent(new o0("ready")),l(this,Zn)!==null&&p(this,Ze,Kh).call(this,l(this,Zn));return}if(Ab(n)){p(this,Ze,d0).call(this,n);return}},d0=async function(e){const n=l(this,Hn);if(n===null){p(this,Ze,to).call(this,{type:"response",id:e.id,error:{message:a0}});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:c0(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,"*")},Jh=function(){if(this.disposed)throw new Error("ArtifactView is disposed")},lv);var Wn,rs,Bn,Vn,la,We,Xh,p0,f0,ro,Qh;class kM extends u0{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,p0).call(this,n)),l(this,Wn).addEventListener("ipc-message",l(this,rs))}get content(){return l(this,Vn)}set content(e){p(this,We,Qh).call(this),b(this,Vn,e),l(this,la)&&p(this,We,Xh).call(this,e)}handleUpdateContent(e){if(p(this,We,Qh).call(this),l(this,Bn)!==null)throw new Error(l0);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,Xh=function(e){const n={type:"content-updated",content:e};p(this,We,ro).call(this,n)},p0=function(e){var s;if(this.disposed)return;const n=e.detail??e;if(!n||n.channel!==Em)return;const i=(s=n.args)==null?void 0:s[0];if(Eb(i)){b(this,la,!0),this.dispatchEvent(new o0("ready")),l(this,Vn)!==null&&p(this,We,Xh).call(this,l(this,Vn));return}if(Ab(i)){p(this,We,f0).call(this,i);return}},f0=async function(e){const n=l(this,Bn);if(n===null){p(this,We,ro).call(this,{type:"response",id:e.id,error:{message:a0}});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:c0(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,Em,e)},Qh=function(){if(this.disposed)throw new Error("WebviewArtifactViewRuntime is disposed")};const Am="television-artifact-bridge",Tm="/views/url-unsupported/",xM=404,g0=Ve(),EM=Ve(),AM=Ve();class TM 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=Yp(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(Kp(e.data)){this.handleBridgeReady(e.data,n);return}if(i){this.handleBridgeLeaving(e.data.guid);return}if(Jp(e.data)){this.dispatchArtifactWheel({deltaX:e.data.deltaX,shiftKey:e.data.shiftKey});return}if(Xp(e.data)){this.markLegacyBridgeProofOfLife(e.data,n),this.dispatchArtifactFilmstripKey(e.data.direction);return}if(wS(e.data)){this.markLegacyBridgeProofOfLife(e.data,n),(u=n.contentWindow)==null||u.postMessage({type:SS,url:this.currentExternalTargetURL()},"*");return}if(Qp(e.data)){this.markLegacyBridgeProofOfLife(e.data,n),(h=n.contentWindow)==null||h.postMessage(this.currentMissingArtifactMessage(),"*");return}if(ef(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!==Am)return;const i=(o=n.args)==null?void 0:o[0];if(!i)return;const s=this._subscribedWebview;if(s){if(Kp(i)){this.handleBridgeReady(i,s);return}if(Yp(i)){this.handleBridgeLeaving(i.guid);return}if(Qp(i)){this.markLegacyBridgeProofOfLife(i,s);const c=this.currentMissingArtifactMessage();c&&((a=s.send)==null||a.call(s,Am,c));return}if(tu(i)){this.handleNavigationRequest(i);return}if(Jp(i)){this.markLegacyBridgeProofOfLife(i,s),this.dispatchArtifactWheel({deltaX:i.deltaX,shiftKey:i.shiftKey});return}if(Xp(i)){this.markLegacyBridgeProofOfLife(i,s),this.dispatchArtifactFilmstripKey(i.direction);return}ef(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?!$M(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 g0("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&&Zu(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:_S,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||IM(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===Tm||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 AM("artifact-filmstrip-key",{bubbles:!0,composed:!0,direction:e}))}dispatchArtifactWheel(e){this._standaloneScroll||this.dispatchEvent(new EM("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 AO(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):$m(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 $m(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 kM(e):new _M(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 Xd&&a.status===xM){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"&&kb(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>${ES()}</h1>
|
|
248
|
-
<p>${AS()}</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>${TS()}</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&&(CM(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 Zu(i)&&!cr()?vr(i)?{renderer:"proxy-iframe",viewURL:i,contentURL:null}:{renderer:"proxy-iframe",viewURL:Tm,contentURL:null}:Zu(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
|
-
${QO({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
|
-
${nM({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
|
-
${hp({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 Zu(r){return r.startsWith("http://")||r.startsWith("https://")}function $M(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 IM(r){return typeof r=="object"&&r!==null&&"guid"in r}function CM(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 $m(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",TM);/**
|
|
299
|
-
* @license
|
|
300
|
-
* Copyright 2017 Google LLC
|
|
301
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
302
|
-
*/const Im=(r,t,e)=>{const n=new Map;for(let i=t;i<=e;i++)n.set(r[i],i);return n},Cm=Nc(class extends up{constructor(r){if(super(r),r.type!==cp.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=GO(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=Im(o,m,E),h=Im(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 Nu(i[y]),y--;else Nu(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&&Nu(x)}return this.ut=o,jO(r,c),ei}}),Ie=r=>({type:"px",...r}),$e=r=>({type:"unit",...r}),il=2;class RM{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<=wT,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,PM=40,LM=24;function m0(r,t){return Math.max(0,r-t*2)}function v0(r){const t=[0];for(const e of r)t.push((t[t.length-1]??0)+e);return t}function y0(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 b0(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 DM(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 zM(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 dp(r,t){if(r.length===0)return 0;const e=zM(r,t);return Math.max(0,r.length-e)}function Rm(r,t,e){if(r.length===0)return 0;const n=b0(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 ed(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=dp(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=y0(r),x=Rm(r,c,i),I=Rm(r,u,i),P=(n-x)/2,R=(n-I)/2,B=ed(E,c,P),N=ed(E,u,R);return B+(N-B)*m}function OM(r,t,e,n,i){const s=dp(r,n),o=t[s]??0;let a=0,c=o;for(let u=0;u<PM;u+=1){const h=(a+c)/2;$i(r,t,h,e,n)>i?a=h:c=h}return(a+c)/2}function MM(r,t,e){const n=y0(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 ed(n,i,c)}function NM(r,t,e){const n=b0(r,t,e);return[t,Math.min(r.length-1,t+n-1)]}function UM(r,t,e){const n=DM(r,t,e);return[Math.max(0,t-n+1),t]}function FM(r,t){return r[0]===t[0]&&r[1]===t[1]}function HM(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=m0(n,s),a=v0(t),c=dp(e,o),u=a[c]??0;function h(I){const P=MM(e,I,n),R=OM(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=NM(e,I,o);f.push(h(P)),I=P[1]+1}const y=h(UM(e,i-1,o)),m=f.filter(I=>I.nodeRange[0]<y.nodeRange[0]),E=m[m.length-1];return{viewspans:E&&FM(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 ZM(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 WM(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 BM(r,t,e){var i,s;if(r.length===0)return t;const n=WM(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 VM 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=HM({nodeCols:n,nodeWidthsPx:i,viewportWidthPx:s,gapPx:o});this._nodeWidthsPx=i,this._boundaryCols=v0(n),this._viewportWidthPx=s,this._framedViewportWidthPx=m0(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=ZM(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:BM(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<LM;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 Wu={"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}},jM=["stack-above","stack-below","reorder-before","reorder-after"];function Bu(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 td(r){return Number.isFinite(r)?Math.max(po,Math.min(Kd,Math.round(r))):po}function GM(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=td(e);if(i.width===s)return r;const o=[...r];return o[n]={...i,width:s},o}function w0(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 rd(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 nd(r){return r.height===tn?{...r,height:ft}:r}function qM(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"?nd(h):h}else c[i]={...s,children:a};const u=Math.max(0,Math.min(n,c.length));return c.splice(u,0,nd(o)),c}const YM=Ve(),KM=Ve(),JM=50;function XM(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 Pm(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 Lm(r){return r.map(eN)}function QM(r){return r.type==="drop-target"?{type:"card",artifactID:r.id,width:r.width,height:r.height}:r}function eN(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(QM)}:r}function S0(r,t){return r.find(n=>n.type==="card"&&Qe(n)===t)??null}function Dm(r,t){return r.find(n=>n.type==="stack"&&n.id===t)??null}function tN(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 rN(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=S0(n,t.nodeId);if(!a)return null;const c=rd(a),u=rd(o),h=La(c),f=e.position==="above"?[h,u]:[u,h];return i[s]={id:Qe(o),type:"stack",children:f},i}function Vu(r,t){return r.parentStackId?iN(r,t):nN(r,t)}function nN(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=tN(r,t);return n?rN(n,r,e,t)??[...t]:[...t]}return[...t]}function iN(r,t){const e=r.hitTarget;switch(e.type){case"stack-child-reorder":return sN(r,t,e.position);case"stack-child-extract":return oN(r,t,e.toIndex);case"stack-child-noop":return aN(r,t);default:return[...t]}}function sN(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 oN(r,t,e){if(!r.parentStackId)return[...t];const n=qM(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 aN(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 lN(r,t){return t.find(n=>n.type==="stack"&&n.id===r.id)?r.id:Ac()}function cN(r,t,e){if(r.type==="drop-target"){const n=w0(t,e);if(!n)throw new Error(`finalize: missing dragged card ${e}`);return rd(n)}return r}function uN(r,t,e){const n=r.children.map(s=>cN(s,t,e));return{id:lN(r,t),type:"stack",children:n}}function hN(r,t,e){if(r.type==="drop-target"){const n=w0(t,e);if(!n)throw new Error(`finalize: missing dragged card ${e}`);return S0(t,e)!==null?n:nd(n)}return r.type==="card"||r.type==="row"?r:uN(r,t,e)}function dN(r,t,e){return r.map(n=>hN(n,t,e))}function pN(r,t){return JSON.stringify(r)===JSON.stringify(t)}const fN=Ra(Mt);class gN extends fN{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)>=_T&&(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=Vu(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&&XM(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=Vu(this.active,e),s=dN(i,e,this.active.nodeId);pN(s,e)||(n=s)}catch{n=null}this.reset(),n&&this.dispatchEvent(new KM("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=Vu(this.active,this.active.baseLayout);this.dispatchEvent(new YM("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=Dm(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=Dm(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)<=JM;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=Bu(f.rect,Wu["reorder-before"]);if(yn(e,n,y))return f.logicalIndex;const m=Bu(f.rect,Wu["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=>[Pm(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:Pm(c),rect:a.rect,logicalIndex:o}),o+=1)}return s}resolveTopLevelTargetForCard(e,n,i,s,o){const a=i.rect;for(const c of jM){if(!o&&(c==="stack-above"||c==="stack-below"))continue;const u=Wu[c],h=Bu(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 mN=100,vN=1e3;class yN{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)<xT?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-mN;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*vN}}function Di(r){return r.artifactID}function bN(r){return r.type==="card"?Di(r):r.id}function wN({baseLayout:r,visibleLayout:t,resolved:e,cardsByID:n,grid:i,dragState:s,isForeground:o}){var E;const a=new Map(t.map(x=>[bN(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=SN(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 zm(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 SN(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 _N=2,Om=1e3,wi=1e-4,kN=120,Mm=!1;function Nm(r){return r.replace(/["\\]/g,"\\$&")}function we(r){return r.artifactID}function Ni(r){return r.type==="card"?we(r):r.id}function Um(r,t,e){if(r===0)return 0;const n=t.toPixels($e({y:ft})).y??0;return(e-n)/_N}function ju(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 xN(r){return r.shiftKey&&r.deltaX===0&&r.deltaY!==0?r.deltaY:r.deltaX}function EN(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 AN extends Event{constructor(e){super("scroll",{bubbles:!0,composed:!0});g(this,"scrollPosition");this.scrollPosition=e}}class _0 extends Event{constructor(e){super("layout-change",{bubbles:!0,composed:!0});g(this,"layout");this.layout=e}}class TN extends HTMLElement{constructor(){super();g(this,"_layout",[]);g(this,"_scrollPosition",0);g(this,"layoutGrid",null);g(this,"layoutScroll",new VM($e({x:0})));g(this,"scrollModelKey","");g(this,"resizeObserver",null);g(this,"renderPending",!1);g(this,"animateNextRender",!0);g(this,"swipeGesture",new yN(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 gN);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=zm(e),s=IN(e.projectedLayout);if(n!==this.lastProjectedDragLayoutSignature||i!==this.lastDragDropIntent||s!==this.lastActivePlaceholderId){const u=Lm(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"&&(EN(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=xN(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(kS(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(xS(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=CN(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=td(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(GM(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<Lg&&a<Lg)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)/Om;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="${Nm(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 RM({basis:Ie({x:Nr,y:Nr}),min:Ie({x:Rg,y:Rg}),viewport:Ie({x:e,y:n}),gap:Ie({x:ae,y:ae})})}syncScrollModel(){const e=ju(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:Mm}))}emitScrollPositionChanged(e){this.dispatchEvent(new AN(e))}emitLayoutChanged(){this.dispatchEvent(new _0([...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()},kN)}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=td(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):Lm(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
|
-
${Cm(e.slots,i=>i.key,i=>this.renderSlot(i,n))}
|
|
338
|
-
</div>
|
|
339
|
-
</div>
|
|
340
|
-
`}render(){var Y;const e=ju(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:Mm}),this._scrollPosition=this.layoutScroll.scroll.x??this._scrollPosition);const u=$N(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=Um(o.nodes.length,n,e.height),x=this.animateNextRender&&!s,I=[`transform: translate(${m}px, ${E}px);`,`transition-duration: ${x?ST: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=wN({baseLayout:this._layout,visibleLayout:i,resolved:o,cardsByID:u,grid:n,dragState:this.dragState,isForeground:B}),F=zm(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
|
-
${Cm(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*Om,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=kT*a;if(e<s){const h=Math.max(0,Math.min(1,(s-e)/Xa));return-(c*h**Pg)*i}if(e>o){const h=Math.max(0,Math.min(1,(e-o)/Xa));return c*h**Pg*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=ju(this),u=(this.layoutScroll.translate.x??0)+n,h=Um(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="${Nm(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?Hm(e,c,this.layoutGrid):Zm(e,c,this.layoutGrid),h=s?Hm(n,c,this.layoutGrid):Zm(n,c,this.layoutGrid);return u===null||h===null?a:a+(u-h)}getStableAnchorCardId(e,n,i){const s=Fm(e),o=new Set(Fm(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 $N(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 IN(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 CN(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 Fm(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 Hm(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 Zm(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",TN);class RN 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 g0&&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 _0&&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",RN);function Jl(r){return typeof r=="object"&&r!==null}const Gu=new WeakMap,Wm=Object.prototype.hasOwnProperty,PN=(()=>{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 LN(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 DN(r,t){return Jl(r)?t==null?null:r.serialize(t):r===Boolean?t?"":null:t==null?null:String(t)}var ca,id,jn,mt,nr,ns,Gn,is,xe,Ii,k0,x0,E0,A0,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,id).call(i,this.constructor),n=this;for(const s of e.properties)Wm.call(n,s)&&(l(this,nr).set(s,n[s]),delete n[s])}static get observedAttributes(){var e;return p(e=xn,ca,id).call(e,this).observedAttributes}connected(){}disconnected(){}changed(e){}connectedCallback(){if(p(this,xe,A0).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]=LN(s.type,i)))}};ca=new WeakSet,id=function(e){const n=Gu.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(PN.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,k0).call(this,u,f)}})}const c={properties:i,observedAttributes:Object.keys(s),byAttr:o,byProp:a};return Gu.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 Gu.get(this.constructor)},k0=function(e,n){if(!l(this,is)&&l(this,nr).has(e))return;const i=l(this,jn).get(e);p(this,xe,x0).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,E0).call(this,e,n),this.isConnected&&p(this,xe,Il).call(this))},x0=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}},E0=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=DN(o,n);if(a===null){this.hasAttribute(s)&&this.removeAttribute(s);return}this.getAttribute(s)!==a&&this.setAttribute(s,a)},A0=function(){const e=this,n=p(this,xe,Ii).call(this);for(const i of n.properties){if(!Wm.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,T0,ha,da,pa,fa,sd,od,ad,$0,I0,C0,R0,lc,cc,uc,hc,ld,P0,Cl,dc,Rl,pc,L0,D0,z0,O0,M0,dt;class zN 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,sd).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,P0).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,ld).call(this,o)}});w(this,hc,e=>{p(this,Z,ld).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,L0).call(this);if(e){b(this,as,!0);try{const n=await e.createScreen(ON(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,C0).call(this);Be(D`
|
|
354
|
-
${p(this,Z,D0).call(this)}
|
|
355
|
-
<div class="pills" role="group" aria-label="Open tabs">
|
|
356
|
-
${e.map(n=>p(this,Z,z0).call(this,n))}
|
|
357
|
-
</div>
|
|
358
|
-
${p(this,Z,O0).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,sd).call(this),l(this,dt).call(this),p(this,Z,T0).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,od).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,T0=async function(){const e=await dy(this);this.setAttribute("tone",e)},ha=new WeakMap,da=new WeakMap,pa=new WeakMap,fa=new WeakMap,sd=function(){var n;const e=l(this,fe).activeScreen;l(this,Kr)!==e&&(p(this,Z,od).call(this),b(this,Kr,e),(n=l(this,Kr))==null||n.addEventListener("change",l(this,fa)))},od=function(){var e;(e=l(this,Kr))==null||e.removeEventListener("change",l(this,fa)),b(this,Kr,null)},ad=function(e,n){l(this,fe).setActive(e,n)},$0=function(e,n,i){i.stopPropagation();const s=l(this,fe).getTabs(e),o=p(this,Z,R0).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())},I0=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(()=>{})},C0=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},R0=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,ld=function(e){l(this,fe).addTab(e.serverURL,e.screenID),l(this,fe).setActive(e.serverURL,e.screenID),p(this,Z,Rl).call(this)},P0=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,L0=function(){for(const e of l(this,Yr).servers.values())return e;return null},D0=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
|
-
${iM({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
|
-
${sM({size:16,weight:"regular"})}
|
|
377
|
-
</button>
|
|
378
|
-
</segmented-control>
|
|
379
|
-
`},z0=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,ad).call(this,e.serverURL,e.screenID)}}
|
|
389
|
-
@click=${()=>p(this,Z,ad).call(this,e.serverURL,e.screenID)}
|
|
390
|
-
>
|
|
391
|
-
<span class="tab-leading">
|
|
392
|
-
${rM({weight:"bold"})}
|
|
393
|
-
</span>
|
|
394
|
-
<editable-text
|
|
395
|
-
class="tab-name"
|
|
396
|
-
.value=${e.name}
|
|
397
|
-
@rename=${n=>p(this,Z,I0).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,$0).call(this,e.serverURL,e.screenID,n)}
|
|
408
|
-
>
|
|
409
|
-
${hp({weight:"bold"})}
|
|
410
|
-
</button>
|
|
411
|
-
</span>
|
|
412
|
-
`},O0=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,M0).call(this,s,n,i)}
|
|
434
|
-
</div>
|
|
435
|
-
</ui-popover>
|
|
436
|
-
`},M0=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",zN);function ON(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:N0,setPrototypeOf:Bm,isFrozen:MN,getPrototypeOf:NN,getOwnPropertyDescriptor:UN}=Object;let{freeze:tt,seal:_t,create:Pl}=Object,{apply:cd,construct:ud}=typeof Reflect<"u"&&Reflect;tt||(tt=function(t){return t});_t||(_t=function(t){return t});cd||(cd=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)});ud||(ud=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),FN=rt(Array.prototype.lastIndexOf),Vm=rt(Array.prototype.pop),Fs=rt(Array.prototype.push),HN=rt(Array.prototype.splice),Ll=rt(String.prototype.toLowerCase),qu=rt(String.prototype.toString),Yu=rt(String.prototype.match),Hs=rt(String.prototype.replace),ZN=rt(String.prototype.indexOf),WN=rt(String.prototype.trim),ut=rt(Object.prototype.hasOwnProperty),Ye=rt(RegExp.prototype.test),Zs=BN(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 cd(r,t,n)}}function BN(r){return function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return ud(r,e)}}function G(r,t){let e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Ll;Bm&&Bm(r,null);let n=t.length;for(;n--;){let i=t[n];if(typeof i=="string"){const s=e(i);s!==i&&(MN(t)||(t[n]=s),i=s)}r[i]=!0}return r}function VN(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 N0(r))ut(r,e)&&(Array.isArray(n)?t[e]=VN(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=UN(r,t);if(n){if(n.get)return rt(n.get);if(typeof n.value=="function")return rt(n.value)}r=NN(r)}function e(){return null}return e}const jm=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"]),Ku=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"]),Ju=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"]),jN=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"]),Xu=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"]),GN=tt(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Gm=tt(["#text"]),qm=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"]),Qu=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"]),Ym=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"]),qN=_t(/\{\{[\w\W]*|[\w\W]*\}\}/gm),YN=_t(/<%[\w\W]*|[\w\W]*%>/gm),KN=_t(/\$\{[\w\W]*/gm),JN=_t(/^data-[\-\w.\u00B7-\uFFFF]+$/),XN=_t(/^aria-[\-\w]+$/),U0=_t(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),QN=_t(/^(?:\w+script|data):/i),e6=_t(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),F0=_t(/^html$/i),t6=_t(/^[a-z][.\w]*(-[.\w]+)+$/i);var Km=Object.freeze({__proto__:null,ARIA_ATTR:XN,ATTR_WHITESPACE:e6,CUSTOM_ELEMENT:t6,DATA_ATTR:JN,DOCTYPE_NAME:F0,ERB_EXPR:YN,IS_ALLOWED_URI:U0,IS_SCRIPT_OR_DATA:QN,MUSTACHE_EXPR:qN,TMPLIT_EXPR:KN});const Bs={element:1,text:3,progressingInstruction:7,comment:8,document:9},r6=function(){return typeof window>"u"?null:window},n6=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}},Jm=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function H0(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:r6();const t=U=>H0(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=Jm();t.isSupported=typeof N0=="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:lS,ATTR_WHITESPACE:xp,CUSTOM_ELEMENT:cS}=Km;let{IS_ALLOWED_URI:Ep}=Km,Re=null;const Ap=G({},[...jm,...Ku,...Ju,...Xu,...Gm]);let Oe=null;const Tp=G({},[...qm,...Qu,...Ym,...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 $p=!0,Zc=!0,Ip=!1,Cp=!0,li=!1,Ma=!0,pn=!1,Wc=!1,Bc=!1,ci=!1,Na=!1,Ua=!1,Rp=!0,Pp=!1;const uS="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 Lp=null;const Dp=G({},["audio","video","img","source","image","track"]);let Gc=null;const zp=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 hS=G({},[Fa,Ha,dr],qu);let Za=G({},["mi","mo","mn","ms","mtext"]),Wa=G({},["annotation-xml"]);const dS=G({},["title","style","font","a","script"]);let Ls=null;const pS=["application/xhtml+xml","text/html"],fS="text/html";let Ae=null,di=null;const gS=e.createElement("form"),Op=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=pS.indexOf(S.PARSER_MEDIA_TYPE)===-1?fS:S.PARSER_MEDIA_TYPE,Ae=Ls==="application/xhtml+xml"?qu:Ll,Re=ut(S,"ALLOWED_TAGS")?G({},S.ALLOWED_TAGS,Ae):Ap,Oe=ut(S,"ALLOWED_ATTR")?G({},S.ALLOWED_ATTR,Ae):Tp,Yc=ut(S,"ALLOWED_NAMESPACES")?G({},S.ALLOWED_NAMESPACES,qu):hS,Gc=ut(S,"ADD_URI_SAFE_ATTR")?G(Bt(zp),S.ADD_URI_SAFE_ATTR,Ae):zp,Lp=ut(S,"ADD_DATA_URI_TAGS")?G(Bt(Dp),S.ADD_DATA_URI_TAGS,Ae):Dp,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,$p=S.ALLOW_ARIA_ATTR!==!1,Zc=S.ALLOW_DATA_ATTR!==!1,Ip=S.ALLOW_UNKNOWN_PROTOCOLS||!1,Cp=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,Rp=S.SANITIZE_DOM!==!1,Pp=S.SANITIZE_NAMED_PROPS||!1,Vc=S.KEEP_CONTENT!==!1,Ps=S.IN_PLACE||!1,Ep=S.ALLOWED_URI_REGEXP||U0,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&&Op(S.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(Se.tagNameCheck=S.CUSTOM_ELEMENT_HANDLING.tagNameCheck),S.CUSTOM_ELEMENT_HANDLING&&Op(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({},Gm),Oe=Pl(null),ui.html===!0&&(G(Re,jm),G(Oe,qm)),ui.svg===!0&&(G(Re,Ku),G(Oe,Qu),G(Oe,ol)),ui.svgFilters===!0&&(G(Re,Ju),G(Oe,Qu),G(Oe,ol)),ui.mathMl===!0&&(G(Re,Xu),G(Oe,Ym),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===Ap&&(Re=Bt(Re)),G(Re,S.ADD_TAGS,Ae))),S.ADD_ATTR&&(typeof S.ADD_ATTR=="function"?zr.attributeCheck=S.ADD_ATTR:(Oe===Tp&&(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=n6(m,i)),N!==null&&typeof F=="string"&&(F=N.createHTML(""));tt&&tt(S),di=S}},Mp=G({},[...Ku,...Ju,...jN]),Np=G({},[...Xu,...GN]),mS=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]):!!Mp[L]:S.namespaceURI===Fa?C.namespaceURI===dr?L==="math":C.namespaceURI===Ha?L==="math"&&Wa[de]:!!Np[L]:S.namespaceURI===dr?C.namespaceURI===Ha&&!Wa[de]||C.namespaceURI===Fa&&!Za[de]?!1:!Np[L]&&(dS[L]||!Mp[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{}},Up=function(S){let C=null,L=null;if(Bc)S="<remove></remove>"+S;else{const _e=Yu(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},Fp=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")},Hp=function(S){return typeof a=="function"&&S instanceof a};function pr(U,S,C){sl(U,L=>{L.call(t,S,C,di)})}const Zp=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()&&!Hp(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]&&Bp(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&&!mS(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)},Wp=function(S,C,L){if(Oa[C]||Rp&&(C==="id"||C==="name")&&(L in e||L in gS))return!1;if(!(Zc&&!Oa[C]&&Ye(Hc,C))){if(!($p&&Ye(za,C))){if(!(zr.attributeCheck instanceof Function&&zr.attributeCheck(C,S))){if(!Oe[C]||Oa[C]){if(!(Bp(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(Ep,Hs(L,xp,""))){if(!((C==="src"||C==="xlink:href"||C==="href")&&S!=="script"&&ZN(L,"data:")===0&&Lp[S])){if(!(Ip&&!Ye(lS,Hs(L,xp,"")))){if(L)return!1}}}}}}}return!0},Bp=function(S){return S!=="annotation-xml"&&Yu(S,cS)},Vp=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:WN(Xc);if(L.attrName=pi,L.attrValue=Me,L.keepAttr=!0,L.forceKeepAttr=void 0,pr(ze.uponSanitizeAttribute,S,L),Me=L.attrValue,Pp&&(pi==="id"||pi==="name")&&(fn(_e,S),Me=uS+Me),Ma&&Ye(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,Me)){fn(_e,S);continue}if(pi==="attributename"&&Yu(Me,"href")){fn(_e,S);continue}if(L.forceKeepAttr)continue;if(!L.keepAttr){fn(_e,S);continue}if(!Cp&&Ye(/\/>/i,Me)){fn(_e,S);continue}li&&sl([dn,Ut,Dr],Gp=>{Me=Hs(Me,Gp," ")});const jp=Ae(S.nodeName);if(!Wp(jp,pi,Me)){fn(_e,S);continue}if(N&&typeof m=="object"&&typeof m.getAttributeType=="function"&&!nt)switch(m.getAttributeType(jp,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):Vm(t.removed)}catch{fn(_e,S)}}pr(ze.afterSanitizeAttributes,S,null)},vS=function U(S){let C=null;const L=Fp(S);for(pr(ze.beforeSanitizeShadowDOM,S,null);C=L.nextNode();)pr(ze.uponSanitizeShadowNode,C,null),Zp(C),Vp(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"&&!Hp(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=Up("<!---->"),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=Up(U),!C)return ci?null:Ua?F:""}C&&Bc&&Ht(C.firstChild);const _e=Fp(Ps?U:C);for(;de=_e.nextNode();)Zp(de),Vp(de),de.content instanceof s&&vS(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(F0,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 Wp(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=FN(ze[U],S);return C===-1?void 0:HN(ze[U],C,1)[0]}return Vm(ze[U])},t.removeHooks=function(U){ze[U]=[]},t.removeAllHooks=function(){ze=Jm()},t}var Z0=H0();function pp(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var ai=pp();function W0(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 i6=(()=>{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)}}>`)},s6=/^(?:[ \t]*(?:\n|$))+/,o6=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,a6=/^ {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+|$)/,l6=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,fp=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,B0=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,V0=J(B0).replace(/bull/g,fp).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(),c6=J(B0).replace(/bull/g,fp).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(),gp=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,u6=/^[^\n]+/,mp=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,h6=J(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",mp).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),d6=J(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,fp).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",vp=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,p6=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",vp).replace("tag",Uc).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),j0=J(gp).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(),f6=J(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",j0).getRegex(),yp={blockquote:f6,code:o6,def:h6,fences:a6,heading:l6,hr:Da,html:p6,lheading:V0,list:d6,newline:s6,paragraph:j0,table:kn,text:u6},Xm=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(),g6={...yp,lheading:c6,table:Xm,paragraph:J(gp).replace("hr",Da).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Xm).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()},m6={...yp,html:J(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",vp).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(gp).replace("hr",Da).replace("heading",` *#{1,6} *[^
|
|
455
|
-
]`).replace("lheading",V0).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},v6=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,y6=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,G0=/^( {2,}|\\)\n(?!\s*$)/,b6=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Cs=/[\p{P}\p{S}]/u,Fc=/[\s\p{P}\p{S}]/u,bp=/[^\s\p{P}\p{S}]/u,w6=J(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Fc).getRegex(),q0=/(?!~)[\p{P}\p{S}]/u,S6=/(?!~)[\s\p{P}\p{S}]/u,_6=/(?:[^\s\p{P}\p{S}]|~)/u,k6=J(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",i6?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Y0=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,x6=J(Y0,"u").replace(/punct/g,Cs).getRegex(),E6=J(Y0,"u").replace(/punct/g,q0).getRegex(),K0="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",A6=J(K0,"gu").replace(/notPunctSpace/g,bp).replace(/punctSpace/g,Fc).replace(/punct/g,Cs).getRegex(),T6=J(K0,"gu").replace(/notPunctSpace/g,_6).replace(/punctSpace/g,S6).replace(/punct/g,q0).getRegex(),$6=J("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,bp).replace(/punctSpace/g,Fc).replace(/punct/g,Cs).getRegex(),I6=J(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,Cs).getRegex(),C6="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",R6=J(C6,"gu").replace(/notPunctSpace/g,bp).replace(/punctSpace/g,Fc).replace(/punct/g,Cs).getRegex(),P6=J(/\\(punct)/,"gu").replace(/punct/g,Cs).getRegex(),L6=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(),D6=J(vp).replace("(?:-->|$)","-->").getRegex(),z6=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",D6).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Xl=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,O6=J(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",Xl).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),J0=J(/^!?\[(label)\]\[(ref)\]/).replace("label",Xl).replace("ref",mp).getRegex(),X0=J(/^!?\[(ref)\](?:\[\])?/).replace("ref",mp).getRegex(),M6=J("reflink|nolink(?!\\()","g").replace("reflink",J0).replace("nolink",X0).getRegex(),Qm=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,wp={_backpedal:kn,anyPunctuation:P6,autolink:L6,blockSkip:k6,br:G0,code:y6,del:kn,delLDelim:kn,delRDelim:kn,emStrongLDelim:x6,emStrongRDelimAst:A6,emStrongRDelimUnd:$6,escape:v6,link:O6,nolink:X0,punctuation:w6,reflink:J0,reflinkSearch:M6,tag:z6,text:b6,url:kn},N6={...wp,link:J(/^!?\[(label)\]\((.*?)\)/).replace("label",Xl).getRegex(),reflink:J(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Xl).getRegex()},hd={...wp,emStrongRDelimAst:T6,emStrongLDelim:E6,delLDelim:I6,delRDelim:R6,url:J(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Qm).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",Qm).getRegex()},U6={...hd,br:J(G0).replace("{2,}","*").getRegex(),text:J(hd.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},al={normal:yp,gfm:g6,pedantic:m6},Vs={normal:wp,gfm:hd,breaks:U6,pedantic:N6},F6={"&":"&","<":"<",">":">",'"':""","'":"'"},ev=r=>F6[r];function Vt(r,t){if(t){if(et.escapeTest.test(r))return r.replace(et.escapeReplace,ev)}else if(et.escapeTestNoEncode.test(r))return r.replace(et.escapeReplaceNoEncode,ev);return r}function tv(r){try{r=encodeURI(r).replace(et.percentDecode,"%")}catch{return null}return r}function rv(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 H6(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 Z6(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 nv(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 W6(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=W6(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=Z6(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=rv(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(rv(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=H6(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)),nv(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 nv(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 dd{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 dd(e).lex(t)}static lexInline(t,e){return new dd(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=tv(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=tv(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)}},Sp=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 pd{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 Sp}static parse(t,e){return new pd(e).parse(t)}static parseInline(t,e){return new pd(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),B6=class{constructor(...r){g(this,"defaults",pp());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",Sp);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 B6;function re(r,t){return ri.parse(r,t)}re.options=re.setOptions=function(r){return ri.setOptions(r),re.defaults=ri.defaults,W0(re.defaults),re};re.getDefaults=pp;re.defaults=ai;re.use=function(...r){return ri.use(...r),re.defaults=ri.defaults,W0(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=Sp;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;Z0.addHook("afterSanitizeAttributes",r=>{r.tagName==="A"&&(r.setAttribute("target","_blank"),r.setAttribute("rel","noopener noreferrer"))});function V6(r){const t=re.parse(r,{async:!1});return Z0.sanitize(t,{USE_PROFILES:{html:!0}})}var ga,$r,sr,or,Qr,Q0,Dl;class fd 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-${++q6}`);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,Q0).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)},G6)))}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=${Y6(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?tM({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?Nw({size:16}):oM({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 j6(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,Q0=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)}}K6(this.overflowingTexts,e)||(this.overflowingTexts=e)},g(fd,"properties",["phase","toolCalls","expanded","expandedTexts","overflowingTexts"]),g(fd,"attributes",{expanded:{type:Boolean}});function j6(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 G6=160;let q6=0;function Y6(r){switch(r){case"completed":return"Completed";case"failed":return"Failed";case"in_progress":return"In progress";default:return"Pending"}}function K6(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",fd);function J6(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 iv=8,sv=new WeakMap;function X6(r){const t=sv.get(r);if(t&&t.text===r.text)return t.html;const e=V6(r.text);return sv.set(r,{text:r.text,html:e}),e}function ov(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,tS,gd,rS,fc,gc,md;class eS 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<=iv;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,md).call(this,!0)})}changed(e){let n=!1;if(e.has("messages")){const i=e.get("messages")??[],s=ov(this.messages);n=s!==null&&s!==ov(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,tS).call(this)),this.toggleAttribute("data-pinned",l(this,vt)),p(this,kt,gd).call(this),p(this,kt,md).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=J6(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"?FO(X6(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,tS=function(){l(this,yt)&&(typeof ResizeObserver>"u"||(b(this,qn,new ResizeObserver(()=>p(this,kt,rS).call(this))),b(this,Yn,new MutationObserver(()=>p(this,kt,gd).call(this))),l(this,Yn).observe(l(this,yt),{childList:!0})))},gd=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)}},rS=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<=iv;i!==l(this,vt)&&(b(this,vt,i),this.toggleAttribute("data-pinned",i))},fc=new WeakMap,gc=new WeakMap,md=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(eS,"properties",["messages"]);customElements.define("message-history",eS);var Lt,ma,ls,ar,cs,us,va,hs,mc,vc,yc,bt,zl,ya,yd,bd,ba,wa;class vd 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,yd).call(this)}disconnected(){var e;(e=l(this,ls))==null||e.dispose(),b(this,ls,null),p(this,bt,bd).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,yd).call(this);const n=this.querySelector("textarea");n&&(p(this,bt,zl).call(this,n),n.focus())}else p(this,bt,bd).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>`:eM({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,yd=function(){document.addEventListener("mousedown",l(this,ba)),document.addEventListener("keydown",l(this,wa))},bd=function(){document.removeEventListener("mousedown",l(this,ba)),document.removeEventListener("keydown",l(this,wa))},ba=new WeakMap,wa=new WeakMap,g(vd,"properties",["placeholder","open","messages","status"]),g(vd,"attributes",{placeholder:{type:String},open:{type:Boolean}});customElements.define("command-panel",vd);const Q6='<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 nS extends Event{constructor(e){super("auth-submit",{bubbles:!0,composed:!0});g(this,"token");this.token=e}}class eU 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 nS(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">${Ow(Q6)}</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",eU);const tU=250,rU=1e3;class iS 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()},tU))}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/rU)}s…`}}g(iS,"observedAttributes",["next-retry-at","has-ever-connected"]);customElements.get("connecting-overlay")||customElements.define("connecting-overlay",iS);class nU extends HTMLElement{constructor(){super(...arguments);g(this,"runtimeServerURL",$b());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 nS?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=uL();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 Aw({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",nU);const wo=cr(),_p=$b(),sS=new QT(wo?"television-electron":"television-browser",qT(_p)),av=Ew(),iU=av?yL({storage:av,clientApp:wo?"desktop":"browser",desktopAppVersion:wo?hL():null}):null,ur=new mO({localStore:sS,localServerURL:_p,telemetryMeta:iU}),oS=new l$({localStore:sS,serverManager:ur}),sU=new vO,oU=()=>{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)));$O(e)}).catch(()=>{})},aS=()=>{const r=ur.activeServer;if(!r||r.status!=="connected"){Hl();return}oU(),r.client.display.get().then(t=>{if(!(ur.activeServer!==r||r.status!=="connected"))return Cw(t.activeThemeName,r)}).catch(()=>{ur.activeServer===r&&Hl()})};aS();ur.addEventListener("change",aS);ur.addEventListener("server-event",r=>{if(r.event.type!=="theme-changed")return;const t=ur.activeServer;!t||t.url!==r.serverURL||Cw(r.event.themeName,t)});hr.register("ServerManager",()=>ur);hr.register("ScreenManager",()=>oS);hr.register("ShortcutService",()=>sU);globalThis.__telepath={screenManager:oS,serverManager:ur};const kp=document.createElement("television-app");kp.runtimeServerURL=_p;kp.electronMode=wo;wo&&document.body.classList.add("electron");document.body.appendChild(kp);
|