@telepath-computer/television 0.1.176 → 0.1.178
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/canonical/v1/components.js +13 -7
- package/dist/canonical/v1/styles.css +17 -1
- package/dist/cli.cjs +4 -4
- package/dist/onboarding/television-onboarding/index.html +3 -3
- package/dist/skills/television/SKILL.md +40 -0
- package/dist/skills/tv-tasks/SKILL.md +241 -0
- package/dist/skills/tv-tasks/task.css +205 -0
- package/dist/skills/tv-tasks/task.js +307 -0
- package/dist/web/assets/{main-B9wZ7ysf.js → main-FDJtlHD7.js} +203 -153
- package/dist/web/assets/main-o9Z-XUYA.css +1 -0
- package/dist/web/index.html +2 -2
- package/package.json +1 -1
- package/dist/web/assets/main-CyvFRuCC.css +0 -1
|
@@ -1,149 +1,149 @@
|
|
|
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
|
|
1
|
+
var _S=Object.defineProperty;var ef=r=>{throw TypeError(r)};var kS=(r,t,e)=>t in r?_S(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var g=(r,t,e)=>kS(r,typeof t!="symbol"?t+"":t,e),nu=(r,t,e)=>t.has(r)||ef("Cannot "+e);var l=(r,t,e)=>(nu(r,t,"read from private field"),e?e.call(r):t.get(r)),w=(r,t,e)=>t.has(r)?ef("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(r):t.set(r,e),b=(r,t,e,n)=>(nu(r,t,"write to private field"),n?n.call(r,e):t.set(r,e),e),p=(r,t,e)=>(nu(r,t,"access private method"),e);var iu=(r,t,e,n)=>({set _(i){b(r,t,i,e)},get _(){return l(r,t,n)}});import{i as tf,a as su,b as rf,c as nf,d as sf,e as xS,U as ES,f as of,g as af,A as AS,h as TS,j as $S}from"./artifact-bridge-C0H5cXgO.js";import{m as IS,a as CS,b as RS}from"./missing-artifact-page-DVzJ41AE.js";var xn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function PS(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 lf=Object.prototype.toString,pv=function(t){var e=lf.call(t),n=e==="[object Arguments]";return n||(n=e!=="[object Array]"&&t!==null&&typeof t=="object"&&typeof t.length=="number"&&t.length>=0&&lf.call(t.callee)==="[object Function]"),n},ou,cf;function LS(){if(cf)return ou;cf=1;var r;if(!Object.keys){var t=Object.prototype.hasOwnProperty,e=Object.prototype.toString,n=pv,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),L=E&&e.call(m)==="[object String]",R=[];if(!E&&!x&&!I)throw new TypeError("Object.keys called on a non-object");var V=o&&x;if(L&&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 H=0;H<m.length;++H)R.push(String(H));else for(var Y in m)!(V&&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 ou=r,ou}var DS=Array.prototype.slice,zS=pv,uf=Object.keys,gl=uf?function(t){return uf(t)}:LS(),hf=Object.keys;gl.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 zS(n)?hf(DS.call(n)):hf(n)})}else Object.keys=gl;return Object.keys||gl};var OS=gl,ml=Object.defineProperty||!1;if(ml)try{ml({},"a",{value:1})}catch{ml=!1}var Ta=ml,Lr=SyntaxError,K=TypeError,MS=Object.getOwnPropertyDescriptor,vl=MS;if(vl)try{vl([],"length")}catch{vl=null}var ws=vl,df=Ta,NS=Lr,mi=K,pf=ws,fv=function(t,e,n){if(!t||typeof t!="object"&&typeof t!="function")throw new mi("`obj` must be an object or a function`");if(typeof e!="string"&&typeof e!="symbol")throw new mi("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new mi("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new mi("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new mi("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new mi("`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=!!pf&&pf(t,e);if(df)df(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 NS("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},oh=Ta,gv=function(){return!!oh};gv.hasArrayLengthDefineBug=function(){if(!oh)return null;try{return oh([],"length",{value:1}).length!==1}catch{return!0}};var kc=gv,US=OS,FS=typeof Symbol=="function"&&typeof Symbol("foo")=="symbol",HS=Object.prototype.toString,ZS=Array.prototype.concat,ff=fv,WS=function(r){return typeof r=="function"&&HS.call(r)==="[object Function]"},mv=kc(),VS=function(r,t,e,n){if(t in r){if(n===!0){if(r[t]===e)return}else if(!WS(n)||!n())return}mv?ff(r,t,e,!0):ff(r,t,e)},vv=function(r,t){var e=arguments.length>2?arguments[2]:{},n=US(t);FS&&(n=ZS.call(n,Object.getOwnPropertySymbols(t)));for(var i=0;i<n.length;i+=1)VS(r,n[i],t[n[i]],e[n[i]])};vv.supportsDescriptors=!!mv;var oi=vv,yl={exports:{}};typeof self<"u"?yl.exports=self:typeof window<"u"?yl.exports=window:yl.exports=Function("return this")();var yv=yl.exports,BS=yv,bv=function(){return typeof xn!="object"||!xn||xn.Math!==Math||xn.Array!==Array?BS:xn},jS=oi,GS=ws,qS=bv,YS=function(){var t=qS();if(jS.supportsDescriptors){var e=GS(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},KS=oi,JS=yv,wv=bv,XS=YS,QS=wv(),Sv=function(){return QS};KS(Sv,{getPolyfill:wv,implementation:JS,shim:XS});var Ad=Sv,Dr=function(t){return!!t&&(typeof t=="function"||typeof t=="object")},Td=Object,_v=Error,e_=EvalError,t_=RangeError,$d=ReferenceError,r_=URIError,n_=Math.abs,i_=Math.floor,s_=Math.max,o_=Math.min,a_=Math.pow,l_=Math.round,Id=Number.isNaN||function(t){return t!==t},c_=Id,u_=function(t){return c_(t)||t===0?t:t<0?-1:1},Ss=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},gf=typeof Symbol<"u"&&Symbol,h_=Ss,Cd=function(){return typeof gf!="function"||typeof Symbol!="function"||typeof gf("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:h_()},au,mf;function kv(){return mf||(mf=1,au=typeof Reflect<"u"&&Reflect.getPrototypeOf||null),au}var lu,vf;function xv(){if(vf)return lu;vf=1;var r=Td;return lu=r.getPrototypeOf||null,lu}var d_="Function.prototype.bind called on incompatible ",p_=Object.prototype.toString,f_=Math.max,g_="[object Function]",yf=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},m_=function(t,e){for(var n=[],i=e,s=0;i<t.length;i+=1,s+=1)n[s]=t[i];return n},v_=function(r,t){for(var e="",n=0;n<r.length;n+=1)e+=r[n],n+1<r.length&&(e+=t);return e},y_=function(t){var e=this;if(typeof e!="function"||p_.apply(e)!==g_)throw new TypeError(d_+e);for(var n=m_(arguments,1),i,s=function(){if(this instanceof i){var h=e.apply(this,yf(n,arguments));return Object(h)===h?h:this}return e.apply(t,yf(n,arguments))},o=f_(0,e.length-n.length),a=[],c=0;c<o;c++)a[c]="$"+c;if(i=Function("binder","return function ("+v_(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},b_=y_,$a=Function.prototype.bind||b_,Rd=Function.prototype.call,Pd=Function.prototype.apply,w_=typeof Reflect<"u"&&Reflect&&Reflect.apply,S_=$a,__=Pd,k_=Rd,x_=w_,Ev=x_||S_.call(k_,__),E_=$a,A_=K,T_=Rd,$_=Ev,xc=function(t){if(t.length<1||typeof t[0]!="function")throw new A_("a function is required");return $_(E_,T_,t)},cu,bf;function I_(){if(bf)return cu;bf=1;var r=xc,t=ws,e;try{e=[].__proto__===Array.prototype}catch(o){if(!o||typeof o!="object"||!("code"in o)||o.code!=="ERR_PROTO_ACCESS")throw o}var n=!!e&&t&&t(Object.prototype,"__proto__"),i=Object,s=i.getPrototypeOf;return cu=n&&typeof n.get=="function"?r([n.get]):typeof s=="function"?function(a){return s(a==null?a:i(a))}:!1,cu}var uu,wf;function Av(){if(wf)return uu;wf=1;var r=kv(),t=xv(),e=I_();return uu=r?function(i){return r(i)}:t?function(i){if(!i||typeof i!="object"&&typeof i!="function")throw new TypeError("getProto: not an object");return t(i)}:e?function(i){return e(i)}:null,uu}var C_=Function.prototype.call,R_=Object.prototype.hasOwnProperty,P_=$a,zr=P_.call(C_,R_),q,L_=Td,D_=_v,z_=e_,O_=t_,M_=$d,ps=Lr,Mi=K,N_=r_,U_=n_,F_=i_,H_=s_,Z_=o_,W_=a_,V_=l_,B_=u_,Tv=Function,hu=function(r){try{return Tv('"use strict"; return ('+r+").constructor;")()}catch{}},go=ws,j_=Ta,du=function(){throw new Mi},G_=go?function(){try{return arguments.callee,du}catch{try{return go(arguments,"callee").get}catch{return du}}}():du,vi=Cd(),Le=Av(),q_=xv(),Y_=kv(),$v=Pd,Ia=Rd,ki={},K_=typeof Uint8Array>"u"||!Le?q:Le(Uint8Array),Xn={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?q:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?q:ArrayBuffer,"%ArrayIteratorPrototype%":vi&&Le?Le([][Symbol.iterator]()):q,"%AsyncFromSyncIteratorPrototype%":q,"%AsyncFunction%":ki,"%AsyncGenerator%":ki,"%AsyncGeneratorFunction%":ki,"%AsyncIteratorPrototype%":ki,"%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%":D_,"%eval%":eval,"%EvalError%":z_,"%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%":Tv,"%GeneratorFunction%":ki,"%Int8Array%":typeof Int8Array>"u"?q:Int8Array,"%Int16Array%":typeof Int16Array>"u"?q:Int16Array,"%Int32Array%":typeof Int32Array>"u"?q:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":vi&&Le?Le(Le([][Symbol.iterator]())):q,"%JSON%":typeof JSON=="object"?JSON:q,"%Map%":typeof Map>"u"?q:Map,"%MapIteratorPrototype%":typeof Map>"u"||!vi||!Le?q:Le(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":L_,"%Object.getOwnPropertyDescriptor%":go,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?q:Promise,"%Proxy%":typeof Proxy>"u"?q:Proxy,"%RangeError%":O_,"%ReferenceError%":M_,"%Reflect%":typeof Reflect>"u"?q:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?q:Set,"%SetIteratorPrototype%":typeof Set>"u"||!vi||!Le?q:Le(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?q:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":vi&&Le?Le(""[Symbol.iterator]()):q,"%Symbol%":vi?Symbol:q,"%SyntaxError%":ps,"%ThrowTypeError%":G_,"%TypedArray%":K_,"%TypeError%":Mi,"%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%":N_,"%WeakMap%":typeof WeakMap>"u"?q:WeakMap,"%WeakRef%":typeof WeakRef>"u"?q:WeakRef,"%WeakSet%":typeof WeakSet>"u"?q:WeakSet,"%Function.prototype.call%":Ia,"%Function.prototype.apply%":$v,"%Object.defineProperty%":j_,"%Object.getPrototypeOf%":q_,"%Math.abs%":U_,"%Math.floor%":F_,"%Math.max%":H_,"%Math.min%":Z_,"%Math.pow%":W_,"%Math.round%":V_,"%Math.sign%":B_,"%Reflect.getPrototypeOf%":Y_};if(Le)try{null.error}catch(r){var J_=Le(Le(r));Xn["%Error.prototype%"]=J_}var X_=function r(t){var e;if(t==="%AsyncFunction%")e=hu("async function () {}");else if(t==="%GeneratorFunction%")e=hu("function* () {}");else if(t==="%AsyncGeneratorFunction%")e=hu("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 Xn[t]=e,e},Sf={__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"]},Ca=$a,Ul=zr,Q_=Ca.call(Ia,Array.prototype.concat),ek=Ca.call($v,Array.prototype.splice),_f=Ca.call(Ia,String.prototype.replace),Fl=Ca.call(Ia,String.prototype.slice),tk=Ca.call(Ia,RegExp.prototype.exec),rk=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,nk=/\\(\\)?/g,ik=function(t){var e=Fl(t,0,1),n=Fl(t,-1);if(e==="%"&&n!=="%")throw new ps("invalid intrinsic syntax, expected closing `%`");if(n==="%"&&e!=="%")throw new ps("invalid intrinsic syntax, expected opening `%`");var i=[];return _f(t,rk,function(s,o,a,c){i[i.length]=a?_f(c,nk,"$1"):o||s}),i},sk=function(t,e){var n=t,i;if(Ul(Sf,n)&&(i=Sf[n],n="%"+i[0]+"%"),Ul(Xn,n)){var s=Xn[n];if(s===ki&&(s=X_(n)),typeof s>"u"&&!e)throw new Mi("intrinsic "+t+" exists, but is not available. Please file an issue!");return{alias:i,name:n,value:s}}throw new ps("intrinsic "+t+" does not exist!")},xt=function(t,e){if(typeof t!="string"||t.length===0)throw new Mi("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof e!="boolean")throw new Mi('"allowMissing" argument must be a boolean');if(tk(/^%?[^%]*%?$/,t)===null)throw new ps("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var n=ik(t),i=n.length>0?n[0]:"",s=sk("%"+i+"%",e),o=s.name,a=s.value,c=!1,u=s.alias;u&&(i=u[0],ek(n,Q_([0,1],u)));for(var h=1,f=!0;h<n.length;h+=1){var y=n[h],m=Fl(y,0,1),E=Fl(y,-1);if((m==='"'||m==="'"||m==="`"||E==='"'||E==="'"||E==="`")&&m!==E)throw new ps("property names with quotes must have matching quotes");if((y==="constructor"||!f)&&(c=!0),i+="."+y,o="%"+i+"%",Ul(Xn,o))a=Xn[o];else if(a!=null){if(!(y in a)){if(!e)throw new Mi("base intrinsic for "+t+" exists, but the property is not available.");return}if(go&&h+1>=n.length){var x=go(a,y);f=!!x,f&&"get"in x&&!("originalValue"in x.get)?a=x.get:a=a[y]}else f=Ul(a,y),a=a[y];f&&!c&&(Xn[o]=a)}}return a},pu,kf;function cn(){if(kf)return pu;kf=1;var r=xt,t=xc,e=t([r("%String.prototype.indexOf%")]);return pu=function(i,s){var o=r(i,!!s);return typeof o=="function"&&e(i,".prototype.")>-1?t([o]):o},pu}var fu,xf;function Ld(){if(xf)return fu;xf=1;var r=xt,t=r("%Array%"),e=!t.isArray&&cn()("Object.prototype.toString");return fu=t.isArray||function(i){return e(i)==="[object Array]"},fu}var ok=kc,Ef=Ta,Iv=ok.hasArrayLengthDefineBug(),ak=Iv&&Ld(),lk=cn(),ck=lk("Object.prototype.propertyIsEnumerable"),Dd=function(t,e,n,i,s,o){if(!Ef){if(!t(o)||!o["[[Configurable]]"]||!o["[[Writable]]"]||s in i&&ck(i,s)!==!!o["[[Enumerable]]"])return!1;var a=o["[[Value]]"];return i[s]=a,e(i[s],a)}return Iv&&s==="length"&&"[[Value]]"in o&&ak(i)&&i.length!==o["[[Value]]"]?(i.length=o["[[Value]]"],i.length===o["[[Value]]"]):(Ef(i,s,n(o)),!0)},uk=K,zs=zr,hk={__proto__:null,"[[Configurable]]":!0,"[[Enumerable]]":!0,"[[Get]]":!0,"[[Set]]":!0,"[[Value]]":!0,"[[Writable]]":!0},_s=function(t){if(!t||typeof t!="object")return!1;for(var e in t)if(zs(t,e)&&!hk[e])return!1;var n=zs(t,"[[Value]]")||zs(t,"[[Writable]]"),i=zs(t,"[[Get]]")||zs(t,"[[Set]]");if(n&&i)throw new uk("Property Descriptors may not be both accessor and data descriptors");return!0},Cv=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},dk=K,pk=_s,fk=Cv,Rv=function(t){if(typeof t<"u"&&!pk(t))throw new dk("Assertion failed: `Desc` must be a Property Descriptor");return fk(t)},gk=K,Af=zr,mk=_s,Pv=function(t){if(typeof t>"u")return!1;if(!mk(t))throw new gk("Assertion failed: `Desc` must be a Property Descriptor");return!(!Af(t,"[[Value]]")&&!Af(t,"[[Writable]]"))},ks=function(t){return typeof t=="string"||typeof t=="symbol"},Tf=Id,Lv=function(t,e){return t===e?t===0?1/t===1/e:!0:Tf(t)&&Tf(e)},$f=K,vk=Dr,yk=Dd,bk=Rv,wk=Pv,Sk=ks,_k=Lv,zd=function(t,e,n){if(!vk(t))throw new $f("Assertion failed: Type(O) is not Object");if(!Sk(e))throw new $f("Assertion failed: P is not a Property Key");var i={"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Value]]":n,"[[Writable]]":!0};return yk(wk,_k,bk,t,e,i)},Dv=Function.prototype.toString,Pi=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,ah,bl;if(typeof Pi=="function"&&typeof Object.defineProperty=="function")try{ah=Object.defineProperty({},"length",{get:function(){throw bl}}),bl={},Pi(function(){throw 42},null,ah)}catch(r){r!==bl&&(Pi=null)}else Pi=null;var kk=/^\s*class\b/,lh=function(t){try{var e=Dv.call(t);return kk.test(e)}catch{return!1}},gu=function(t){try{return lh(t)?!1:(Dv.call(t),!0)}catch{return!1}},wl=Object.prototype.toString,xk="[object Object]",Ek="[object Function]",Ak="[object GeneratorFunction]",Tk="[object HTMLAllCollection]",$k="[object HTML document.all class]",Ik="[object HTMLCollection]",Ck=typeof Symbol=="function"&&!!Symbol.toStringTag,Rk=!(0 in[,]),ch=function(){return!1};if(typeof document=="object"){var Pk=document.all;wl.call(Pk)===wl.call(document.all)&&(ch=function(t){if((Rk||!t)&&(typeof t>"u"||typeof t=="object"))try{var e=wl.call(t);return(e===Tk||e===$k||e===Ik||e===xk)&&t("")==null}catch{}return!1})}var zv=Pi?function(t){if(ch(t))return!0;if(!t||typeof t!="function"&&typeof t!="object")return!1;try{Pi(t,null,ah)}catch(e){if(e!==bl)return!1}return!lh(t)&&gu(t)}:function(t){if(ch(t))return!0;if(!t||typeof t!="function"&&typeof t!="object")return!1;if(Ck)return gu(t);if(lh(t))return!1;var e=wl.call(t);return e!==Ek&&e!==Ak&&!/^\[object HTML/.test(e)?!1:gu(t)},Lk=zv,Dk=function(t){return!!t},Zt=zr,Ka=K,zk=Dr,If=Lk,mu=Dk,Ok=function(t){if(!zk(t))throw new Ka("ToPropertyDescriptor requires an object");var e={};if(Zt(t,"enumerable")&&(e["[[Enumerable]]"]=mu(t.enumerable)),Zt(t,"configurable")&&(e["[[Configurable]]"]=mu(t.configurable)),Zt(t,"value")&&(e["[[Value]]"]=t.value),Zt(t,"writable")&&(e["[[Writable]]"]=mu(t.writable)),Zt(t,"get")){var n=t.get;if(typeof n<"u"&&!If(n))throw new Ka("getter must be a function");e["[[Get]]"]=n}if(Zt(t,"set")){var i=t.set;if(typeof i<"u"&&!If(i))throw new Ka("setter must be a function");e["[[Set]]"]=i}if((Zt(e,"[[Get]]")||Zt(e,"[[Set]]"))&&(Zt(e,"[[Value]]")||Zt(e,"[[Writable]]")))throw new Ka("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute");return e},vu=K,Mk=Dr,Cf=_s,Nk=Dd,Uk=Rv,Fk=Pv,Hk=ks,Zk=Lv,Wk=Ok,Vk=function(t,e,n){if(!Mk(t))throw new vu("Assertion failed: Type(O) is not Object");if(!Hk(e))throw new vu("Assertion failed: P is not a Property Key");var i=Cf(n)?n:Wk(n);if(!Cf(i))throw new vu("Assertion failed: Desc is not a valid Property Descriptor");return Nk(Fk,Zk,Uk,t,e,i)},Rf=K,Bk=Dr,jk=Vk,Gk=ks,qk=function(t,e,n){if(!Bk(t))throw new Rf("Assertion failed: Type(O) is not Object");if(!Gk(e))throw new Rf("Assertion failed: P is not a Property Key");var i={"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Value]]":n,"[[Writable]]":!0};return jk(t,e,i)},Yk=typeof Reflect<"u"&&Reflect.setPrototypeOf||null,Kk=Td,Jk=Kk.setPrototypeOf||null,Xk=xc,Pf=ws,Qk=K,Ov={};try{Ov.__proto__=null}catch(r){if(!r||typeof r!="object"||!("code"in r)||r.code!=="ERR_PROTO_ACCESS")throw r}var ex=!("toString"in Ov),yu=Pf&&Pf(Object.prototype,"__proto__"),tx=ex&&(!!yu&&typeof yu.set=="function"&&Xk([yu.set])||function(t,e){if(t==null)throw new Qk("set Object.prototype.__proto__ called on null or undefined");return t.__proto__=e,e}),Lf=Yk,rx=Jk,Df=tx,nx=K,ix=Lf?function(t,e){if(Lf(t,e))return t;throw new nx("Reflect.setPrototypeOf: failed to set [[Prototype]]")}:rx||(Df?function(t,e){return Df(t,e),t}:null),zf=K,sx=Dr,Of=Av(),ox=function(t){if(!sx(t))throw new zf("Assertion failed: O must be an Object");if(!Of)throw new zf("This environment does not support fetching prototypes.");return Of(t)},ax=K,lx=ix,cx=Dr,ux=ox,hx=function(t,e){if(e!==null&&!cx(e))throw new ax("Assertion failed: V must be Object or Null");try{lx(t,e)}catch{return!1}return ux(t)===e},bu=zd,Mf=qk,Mv=hx,dx=kc(),Od=_v;function Ra(r,t,e){var n=new Od(e);return Mv(n,Sl),delete n.constructor,Mf(n,"error",r),Mf(n,"suppressed",t),n}dx&&Object.defineProperty(Ra,"prototype",{writable:!1});var Sl=Ra.prototype;if(!bu(Sl,"constructor",Ra)||!bu(Sl,"message","")||!bu(Sl,"name","SuppressedError"))throw new Od("unable to install SuppressedError.prototype properties; please report this!");Mv(Ra.prototype,Od.prototype);var px=Ra,fx=px,Nv=function(){return typeof SuppressedError=="function"?SuppressedError:fx},gx=oi,Nf=Ad(),mx=Nv,vx=function(){var t=mx();return gx(Nf,{SuppressedError:t},{SuppressedError:function(){return Nf.SuppressedError!==t}}),t};vx();var yx=K,bx=_s,wx=Cv,Sx=function(t){if(typeof t<"u"&&!bx(t))throw new yx("Assertion failed: `Desc` must be a Property Descriptor");return wx(t)},_x=K,Uf=zr,kx=_s,xx=function(t){if(typeof t>"u")return!1;if(!kx(t))throw new _x("Assertion failed: `Desc` must be a Property Descriptor");return!(!Uf(t,"[[Value]]")&&!Uf(t,"[[Writable]]"))},Ff=Id,Ex=function(t,e){return t===e?t===0?1/t===1/e:!0:Ff(t)&&Ff(e)},xs=zv,Ax=function(t){return!!t},Wt=zr,Ja=K,Tx=Dr,Hf=xs,wu=Ax,$x=function(t){if(!Tx(t))throw new Ja("ToPropertyDescriptor requires an object");var e={};if(Wt(t,"enumerable")&&(e["[[Enumerable]]"]=wu(t.enumerable)),Wt(t,"configurable")&&(e["[[Configurable]]"]=wu(t.configurable)),Wt(t,"value")&&(e["[[Value]]"]=t.value),Wt(t,"writable")&&(e["[[Writable]]"]=wu(t.writable)),Wt(t,"get")){var n=t.get;if(typeof n<"u"&&!Hf(n))throw new Ja("getter must be a function");e["[[Get]]"]=n}if(Wt(t,"set")){var i=t.set;if(typeof i<"u"&&!Hf(i))throw new Ja("setter must be a function");e["[[Set]]"]=i}if((Wt(e,"[[Get]]")||Wt(e,"[[Set]]"))&&(Wt(e,"[[Value]]")||Wt(e,"[[Writable]]")))throw new Ja("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute");return e},Su=K,Ix=Dr,Zf=_s,Cx=Dd,Rx=Sx,Px=xx,Lx=ks,Dx=Ex,zx=$x,Pa=function(t,e,n){if(!Ix(t))throw new Su("Assertion failed: Type(O) is not Object");if(!Lx(e))throw new Su("Assertion failed: P is not a Property Key");var i=Zf(n)?n:zx(n);if(!Zf(i))throw new Su("Assertion failed: Desc is not a valid Property Descriptor");return Cx(Px,Dx,Rx,t,e,i)},Ox=Ss(),Mx=Ox?Symbol.dispose||Symbol("Symbol.dispose"):null,Nx=Ss,Ux=Mx,Md=function(){return Nx()&&Symbol.dispose||Ux},Fx=Cd,Hx=Pa,Zx=Md,Wx=function(){var t=Zx();return Fx()&&Hx(Symbol,"dispose",{"[[Configurable]]":!1,"[[Enumerable]]":!1,"[[Writable]]":!1,"[[Value]]":t}),t},Vx=Ss(),Bx=Vx?Symbol.asyncDispose||Symbol("Symbol.asyncDispose"):null,jx=Ss,Gx=Bx,Nd=function(){return jx()&&Symbol.asyncDispose||Gx},qx=Cd,Yx=Pa,Kx=Nd,Jx=function(){var t=Kx();return qx()&&Yx(Symbol,"asyncDispose",{"[[Configurable]]":!1,"[[Enumerable]]":!1,"[[Writable]]":!1,"[[Value]]":t}),t},Xx=Ld(),Qx=xt,eE=cn(),tE=K,rE=Xx,nE=Qx("%Reflect.apply%",!0)||eE("Function.prototype.apply"),Ec=function(t,e){var n=arguments.length>2?arguments[2]:[];if(!rE(n))throw new tE("Assertion failed: optional `argumentsList`, if provided, must be a List");return nE(t,e,n)};const iE={},sE=Object.freeze(Object.defineProperty({__proto__:null,default:iE},Symbol.toStringTag,{value:"Module"})),oE=PS(sE);var Ud=typeof Map=="function"&&Map.prototype,_u=Object.getOwnPropertyDescriptor&&Ud?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,Hl=Ud&&_u&&typeof _u.get=="function"?_u.get:null,Wf=Ud&&Map.prototype.forEach,Fd=typeof Set=="function"&&Set.prototype,ku=Object.getOwnPropertyDescriptor&&Fd?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,Zl=Fd&&ku&&typeof ku.get=="function"?ku.get:null,Vf=Fd&&Set.prototype.forEach,aE=typeof WeakMap=="function"&&WeakMap.prototype,lo=aE?WeakMap.prototype.has:null,lE=typeof WeakSet=="function"&&WeakSet.prototype,co=lE?WeakSet.prototype.has:null,cE=typeof WeakRef=="function"&&WeakRef.prototype,Bf=cE?WeakRef.prototype.deref:null,uE=Boolean.prototype.valueOf,hE=Object.prototype.toString,dE=Function.prototype.toString,pE=String.prototype.match,Hd=String.prototype.slice,en=String.prototype.replace,fE=String.prototype.toUpperCase,jf=String.prototype.toLowerCase,Uv=RegExp.prototype.test,Gf=Array.prototype.concat,lr=Array.prototype.join,gE=Array.prototype.slice,qf=Math.floor,uh=typeof BigInt=="function"?BigInt.prototype.valueOf:null,xu=Object.getOwnPropertySymbols,hh=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,fs=typeof Symbol=="function"&&typeof Symbol.iterator=="object",uo=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===fs||!0)?Symbol.toStringTag:null,Fv=Object.prototype.propertyIsEnumerable,Yf=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(r){return r.__proto__}:null);function Kf(r,t){if(r===1/0||r===-1/0||r!==r||r&&r>-1e3&&r<1e3||Uv.call(/e/,t))return t;var e=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof r=="number"){var n=r<0?-qf(-r):qf(r);if(n!==r){var i=String(n),s=Hd.call(t,i.length+1);return en.call(i,e,"$&_")+"."+en.call(en.call(s,/([0-9]{3})/g,"$&_"),/_$/,"")}}return en.call(t,e,"$&_")}var dh=oE,Jf=dh.custom,Xf=Wv(Jf)?Jf:null,Hv={__proto__:null,double:'"',single:"'"},mE={__proto__:null,double:/(["\\])/g,single:/(['\\])/g},Es=function r(t,e,n,i){var s=e||{};if(wr(s,"quoteStyle")&&!wr(Hv,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 Bv(t,s);if(typeof t=="number"){if(t===0)return 1/0/t>0?"0":"-0";var c=String(t);return a?Kf(t,c):c}if(typeof t=="bigint"){var u=String(t)+"n";return a?Kf(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 ph(t)?"[Array]":"[Object]";var f=DE(s,n);if(typeof i>"u")i=[];else if(Vv(i,t)>=0)return"[Circular]";function y(Ut,Or,Bc){if(Or&&(i=gE.call(i),i.push(Or)),Bc){var Ha={depth:s.depth};return wr(s,"quoteStyle")&&(Ha.quoteStyle=s.quoteStyle),r(Ut,Ha,n+1,i)}return r(Ut,s,n+1,i)}if(typeof t=="function"&&!Qf(t)){var m=EE(t),E=Xa(t,y);return"[Function"+(m?": "+m:" (anonymous)")+"]"+(E.length>0?" { "+lr.call(E,", ")+" }":"")}if(Wv(t)){var x=fs?en.call(String(t),/^(Symbol\(.*\))_[^)]*$/,"$1"):hh.call(t);return typeof t=="object"&&!fs?Os(x):x}if(RE(t)){for(var I="<"+jf.call(String(t.nodeName)),L=t.attributes||[],R=0;R<L.length;R++)I+=" "+L[R].name+"="+Zv(vE(L[R].value),"double",s);return I+=">",t.childNodes&&t.childNodes.length&&(I+="..."),I+="</"+jf.call(String(t.nodeName))+">",I}if(ph(t)){if(t.length===0)return"[]";var V=Xa(t,y);return f&&!LE(V)?"["+fh(V,f)+"]":"[ "+lr.call(V,", ")+" ]"}if(bE(t)){var N=Xa(t,y);return!("cause"in Error.prototype)&&"cause"in t&&!Fv.call(t,"cause")?"{ ["+String(t)+"] "+lr.call(Gf.call("[cause]: "+y(t.cause),N),", ")+" }":N.length===0?"["+String(t)+"]":"{ ["+String(t)+"] "+lr.call(N,", ")+" }"}if(typeof t=="object"&&o){if(Xf&&typeof t[Xf]=="function"&&dh)return dh(t,{depth:h-n});if(o!=="symbol"&&typeof t.inspect=="function")return t.inspect()}if(AE(t)){var H=[];return Wf&&Wf.call(t,function(Ut,Or){H.push(y(Or,t,!0)+" => "+y(Ut,t))}),eg("Map",Hl.call(t),H,f)}if(IE(t)){var Y=[];return Vf&&Vf.call(t,function(Ut){Y.push(y(Ut,t))}),eg("Set",Zl.call(t),Y,f)}if(TE(t))return Eu("WeakMap");if(CE(t))return Eu("WeakSet");if($E(t))return Eu("WeakRef");if(SE(t))return Os(y(Number(t)));if(kE(t))return Os(y(uh.call(t)));if(_E(t))return Os(uE.call(t));if(wE(t))return Os(y(String(t)));if(typeof window<"u"&&t===window)return"{ [object Window] }";if(typeof globalThis<"u"&&t===globalThis||typeof xn<"u"&&t===xn)return"{ [object globalThis] }";if(!yE(t)&&!Qf(t)){var j=Xa(t,y),ce=Yf?Yf(t)===Object.prototype:t instanceof Object||t.constructor===Object,Tt=t instanceof Object?"":"null prototype",pn=!ce&&uo&&Object(t)===t&&uo in t?Hd.call(un(t),8,-1):Tt?"Object":"",ze=ce||typeof t.constructor!="function"?"":t.constructor.name?t.constructor.name+" ":"",fn=ze+(pn||Tt?"["+lr.call(Gf.call([],pn||[],Tt||[]),": ")+"] ":"");return j.length===0?fn+"{}":f?fn+"{"+fh(j,f)+"}":fn+"{ "+lr.call(j,", ")+" }"}return String(t)};function Zv(r,t,e){var n=e.quoteStyle||t,i=Hv[n];return i+r+i}function vE(r){return en.call(String(r),/"/g,""")}function ai(r){return!uo||!(typeof r=="object"&&(uo in r||typeof r[uo]<"u"))}function ph(r){return un(r)==="[object Array]"&&ai(r)}function yE(r){return un(r)==="[object Date]"&&ai(r)}function Qf(r){return un(r)==="[object RegExp]"&&ai(r)}function bE(r){return un(r)==="[object Error]"&&ai(r)}function wE(r){return un(r)==="[object String]"&&ai(r)}function SE(r){return un(r)==="[object Number]"&&ai(r)}function _E(r){return un(r)==="[object Boolean]"&&ai(r)}function Wv(r){if(fs)return r&&typeof r=="object"&&r instanceof Symbol;if(typeof r=="symbol")return!0;if(!r||typeof r!="object"||!hh)return!1;try{return hh.call(r),!0}catch{}return!1}function kE(r){if(!r||typeof r!="object"||!uh)return!1;try{return uh.call(r),!0}catch{}return!1}var xE=Object.prototype.hasOwnProperty||function(r){return r in this};function wr(r,t){return xE.call(r,t)}function un(r){return hE.call(r)}function EE(r){if(r.name)return r.name;var t=pE.call(dE.call(r),/^function\s*([\w$]+)/);return t?t[1]:null}function Vv(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 AE(r){if(!Hl||!r||typeof r!="object")return!1;try{Hl.call(r);try{Zl.call(r)}catch{return!0}return r instanceof Map}catch{}return!1}function TE(r){if(!lo||!r||typeof r!="object")return!1;try{lo.call(r,lo);try{co.call(r,co)}catch{return!0}return r instanceof WeakMap}catch{}return!1}function $E(r){if(!Bf||!r||typeof r!="object")return!1;try{return Bf.call(r),!0}catch{}return!1}function IE(r){if(!Zl||!r||typeof r!="object")return!1;try{Zl.call(r);try{Hl.call(r)}catch{return!0}return r instanceof Set}catch{}return!1}function CE(r){if(!co||!r||typeof r!="object")return!1;try{co.call(r,co);try{lo.call(r,lo)}catch{return!0}return r instanceof WeakSet}catch{}return!1}function RE(r){return!r||typeof r!="object"?!1:typeof HTMLElement<"u"&&r instanceof HTMLElement?!0:typeof r.nodeName=="string"&&typeof r.getAttribute=="function"}function Bv(r,t){if(r.length>t.maxStringLength){var e=r.length-t.maxStringLength,n="... "+e+" more character"+(e>1?"s":"");return Bv(Hd.call(r,0,t.maxStringLength),t)+n}var i=mE[t.quoteStyle||"single"];i.lastIndex=0;var s=en.call(en.call(r,i,"\\$1"),/[\x00-\x1f]/g,PE);return Zv(s,"single",t)}function PE(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":"")+fE.call(t.toString(16))}function Os(r){return"Object("+r+")"}function Eu(r){return r+" { ? }"}function eg(r,t,e,n){var i=n?fh(e,n):lr.call(e,", ");return r+" ("+t+") {"+i+"}"}function LE(r){for(var t=0;t<r.length;t++)if(Vv(r[t],`
|
|
2
|
+
`)>=0)return!1;return!0}function DE(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 fh(r,t){if(r.length===0)return"";var e=`
|
|
3
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(`
|
|
4
|
+
`+t.prev}function Xa(r,t){var e=ph(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 xu=="function"?xu(r):[],o;if(fs){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||fs&&o["$"+c]instanceof Symbol||(Uv.call(/[^\w$]/,c)?n.push(t(c,r)+": "+t(r[c],r)):n.push(c+": "+t(r[c],r))));if(typeof xu=="function")for(var u=0;u<s.length;u++)Fv.call(r,s[u])&&n.push("["+t(s[u])+"]: "+t(r[s[u]],r));return n}var zE=Es,OE=K,Ac=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},ME=function(r,t){if(r){var e=Ac(r,t);return e&&e.value}},NE=function(r,t,e){var n=Ac(r,t);n?n.value=e:r.next={key:t,next:r.next,value:e}},UE=function(r,t){return r?!!Ac(r,t):!1},FE=function(r,t){if(r)return Ac(r,t,!0)},HE=function(){var t,e={assert:function(n){if(!e.has(n))throw new OE("Side channel does not contain "+zE(n))},delete:function(n){var i=t&&t.next,s=FE(t,n);return s&&i&&i===s&&(t=void 0),!!s},get:function(n){return ME(t,n)},has:function(n){return UE(t,n)},set:function(n,i){t||(t={next:void 0}),NE(t,n,i)}};return e},ZE=xt,La=cn(),WE=Es,VE=K,tg=ZE("%Map%",!0),BE=La("Map.prototype.get",!0),jE=La("Map.prototype.set",!0),GE=La("Map.prototype.has",!0),qE=La("Map.prototype.delete",!0),YE=La("Map.prototype.size",!0),jv=!!tg&&function(){var t,e={assert:function(n){if(!e.has(n))throw new VE("Side channel does not contain "+WE(n))},delete:function(n){if(t){var i=qE(t,n);return YE(t)===0&&(t=void 0),i}return!1},get:function(n){if(t)return BE(t,n)},has:function(n){return t?GE(t,n):!1},set:function(n,i){t||(t=new tg),jE(t,n,i)}};return e},KE=xt,Tc=cn(),JE=Es,Qa=jv,XE=K,yi=KE("%WeakMap%",!0),QE=Tc("WeakMap.prototype.get",!0),eA=Tc("WeakMap.prototype.set",!0),tA=Tc("WeakMap.prototype.has",!0),rA=Tc("WeakMap.prototype.delete",!0),nA=yi?function(){var t,e,n={assert:function(i){if(!n.has(i))throw new XE("Side channel does not contain "+JE(i))},delete:function(i){if(yi&&i&&(typeof i=="object"||typeof i=="function")){if(t)return rA(t,i)}else if(Qa&&e)return e.delete(i);return!1},get:function(i){return yi&&i&&(typeof i=="object"||typeof i=="function")&&t?QE(t,i):e&&e.get(i)},has:function(i){return yi&&i&&(typeof i=="object"||typeof i=="function")&&t?tA(t,i):!!e&&e.has(i)},set:function(i,s){yi&&i&&(typeof i=="object"||typeof i=="function")?(t||(t=new yi),eA(t,i,s)):Qa&&(e||(e=Qa()),e.set(i,s))}};return n}:Qa,iA=K,sA=Es,oA=HE,aA=jv,lA=nA,cA=lA||aA||oA,uA=function(){var t,e={assert:function(n){if(!e.has(n))throw new iA("Side channel does not contain "+sA(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=cA()),t.set(n,i)}};return e},hA=zr,Ms=uA(),gr=K,Zd={assert:function(r,t){if(!r||typeof r!="object"&&typeof r!="function")throw new gr("`O` is not an object");if(typeof t!="string")throw new gr("`slot` must be a string");if(Ms.assert(r),!Zd.has(r,t))throw new gr("`"+t+"` is not present on `O`")},get:function(r,t){if(!r||typeof r!="object"&&typeof r!="function")throw new gr("`O` is not an object");if(typeof t!="string")throw new gr("`slot` must be a string");var e=Ms.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=Ms.get(r);return!!e&&hA(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=Ms.get(r);n||(n={},Ms.set(r,n)),n["$"+t]=e}};Object.freeze&&Object.freeze(Zd);var Wd=Zd,Gv=Lr,rn=Wd,Da=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 Gv('Assertion failed: `type` must be one of "normal", "break", "continue", "return", or "throw"');rn.set(this,"[[Type]]",t),rn.set(this,"[[Value]]",e)};Da.prototype.type=function(){return rn.get(this,"[[Type]]")};Da.prototype.value=function(){return rn.get(this,"[[Value]]")};Da.prototype["?"]=function(){var t=rn.get(this,"[[Type]]"),e=rn.get(this,"[[Value]]");if(t==="throw")throw e;return e};Da.prototype["!"]=function(){var t=rn.get(this,"[[Type]]");if(t!=="normal")throw new Gv('Assertion failed: Completion Record is not of type "normal"');return rn.get(this,"[[Value]]")};var Vd=Da,dA=Vd,Bd=function(t){return new dA("normal",t)},Au,rg;function pA(){if(rg)return Au;rg=1;var r=Ss;return Au=function(){return r()&&!!Symbol.toStringTag},Au}var fA=xt,ng=fA("%Object.defineProperty%",!0),gA=pA()(),mA=zr,vA=K,el=gA?Symbol.toStringTag:null,qv=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 vA("if provided, the `overrideIfSet` and `nonConfigurable` options must be booleans");el&&(n||!mA(t,el))&&(ng?ng(t,el,{configurable:!i,enumerable:!1,value:e,writable:!1}):t[el]=e)},Yv={exports:{}},yA=xt,ig=fv,bA=kc(),sg=ws,og=K,wA=yA("%Math.floor%"),SA=function(t,e){if(typeof t!="function")throw new og("`fn` is not a function");if(typeof e!="number"||e<0||e>4294967295||wA(e)!==e)throw new og("`length` must be a positive 32-bit integer");var n=arguments.length>2&&!!arguments[2],i=!0,s=!0;if("length"in t&&sg){var o=sg(t,"length");o&&!o.configurable&&(i=!1),o&&!o.writable&&(s=!1)}return(i||s||!n)&&(bA?ig(t,"length",e,!0,!0):ig(t,"length",e)),t},_A=$a,kA=Pd,xA=Ev,EA=function(){return xA(_A,kA,arguments)};(function(r){var t=SA,e=Ta,n=xc,i=EA;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})(Yv);var jd=Yv.exports,AA=function(t,e){for(var n=0;n<t.length;n+=1)if(!e(t[n],n,t))return!1;return!0},TA=Object,$A=function(t){return t&&typeof t=="object"&&(typeof t["[[ResourceValue]]"]>"u"||TA(t["[[ResourceValue]]"])===t["[[ResourceValue]]"])&&(t["[[Hint]]"]==="SYNC-DISPOSE"||t["[[Hint]]"]==="ASYNC-DISPOSE")&&(typeof t["[[DisposeMethod]]"]=="function"||typeof t["[[DisposeMethod]]"]>"u")},IA=zr,CA=Ld(),RA=AA,PA=$A,LA=function(t){return t&&typeof t=="object"&&IA(t,"[[DisposableResourceStack]]")&&CA(t["[[DisposableResourceStack]]"])&&(t["[[DisposableResourceStack]]"].length===0||RA(t["[[DisposableResourceStack]]"],PA))},DA=Dr,zA=function(t){if(t===null)return"Null";if(typeof t>"u")return"Undefined";if(DA(t))return"Object";if(typeof t=="number")return"Number";if(typeof t=="boolean")return"Boolean";if(typeof t=="string")return"String"},OA=zA,Gd=function(t){return typeof t=="symbol"?"Symbol":typeof t=="bigint"?"BigInt":OA(t)},MA=K,NA=Es,UA=ks,FA=function(t,e){if(!UA(e))throw new MA("Assertion failed: P is not a Property Key, got "+NA(e));return t[e]},ag=K,HA=FA,ZA=xs,WA=ks,lg=Es,VA=function(t,e){if(!WA(e))throw new ag("Assertion failed: P is not a Property Key");var n=HA(t,e);if(n!=null){if(!ZA(n))throw new ag(lg(e)+" is not a function: "+lg(n));return n}},gh={exports:{}},BA=xt,jA=BA,cg=jA("%Reflect.construct%",!0),Wl=Pa;try{Wl({},"",{"[[Get]]":function(){}})}catch{Wl=null}if(Wl&&cg){var ug={},hg={};Wl(hg,"length",{"[[Get]]":function(){throw ug},"[[Enumerable]]":!0}),gh.exports=function(t){try{cg(t,hg)}catch(e){return e===ug}}}else gh.exports=function(t){return typeof t=="function"&&!!t.prototype};var GA=gh.exports,Tu=K,dg=xs,qA=GA,YA=function(t){if(!qA(t))throw new Tu("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 Tu("executor has already been called");e["[[Resolve]]"]=i,e["[[Reject]]"]=s});if(!dg(e["[[Resolve]]"])||!dg(e["[[Reject]]"]))throw new Tu("executor must provide valid resolve and reject functions");return{"[[Promise]]":n,"[[Resolve]]":e["[[Resolve]]"],"[[Reject]]":e["[[Reject]]"]}},pg=Lr,KA=K,$u=Ec,fg=VA,JA=YA,XA=Gd,gg=Md(),mg=Nd(),QA=function(t,e){if(XA(t)!=="Object")throw new KA("`V` must be an Object");if(e!=="SYNC-DISPOSE"&&e!=="ASYNC-DISPOSE")throw new pg("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");var n;if(e==="ASYNC-DISPOSE"&&mg&&(n=fg(t,mg)),!n){if(!gg)throw new pg("`Symbol.dispose` is not supported");if(n=fg(t,gg),typeof n<"u")return function(){var i=this;if(e==="ASYNC-DISPOSE"){var s=JA(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},e1=Lr,Iu=K,t1=xs,r1=Gd,n1=QA,i1=function(t,e){if(e!=="SYNC-DISPOSE"&&e!=="ASYNC-DISPOSE")throw new e1("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"&&r1(t)!=="Object")throw new Iu("`V` must be an Object, or `null` or `undefined`");if(n=n1(t,e),typeof n>"u")throw new Iu("dispose method must not be `undefined` on `V` when an object `V` is provided")}else if(n=arguments[2],!t1(n))throw new Iu("`method`, when provided, must be a function");return{"[[ResourceValue]]":t,"[[Hint]]":e,"[[DisposeMethod]]":n}},s1=Lr,tl=K,o1=LA,vg=i1,a1=cn(),l1=a1("Array.prototype.push"),Kv=function(t,e,n){if(!o1(t))throw new tl("Assertion failed: `disposeCapability` must be a DisposeCapability Record");if(n!=="SYNC-DISPOSE"&&n!=="ASYNC-DISPOSE")throw new s1("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 tl("Assertion failed: `method`, when present, must be a function");if(!t["[[DisposableResourceStack]]"])throw new tl("Assertion failed: `disposeCapability.[[DisposableResourceStack]]` must not be ~EMPTY~");var s;if(arguments.length<4){if(e==null&&n==="SYNC_DISPOSE")return"UNUSED";s=vg(e,n)}else{if(typeof e<"u")throw new tl("Assertion failed: `V` must be undefined when `method` is present");s=vg(void 0,n,i)}return l1(t["[[DisposableResourceStack]]"],s),"UNUSED"},Cu,yg;function qd(){if(yg)return Cu;yg=1;var r=xt,t=jd,e=Lr,n=r("%Promise.resolve%",!0),i=n&&t(n);return Cu=function(o,a){if(!i)throw new e("This environment does not support Promises.");return i(o,a)},Cu}var Ru,bg;function c1(){if(bg)return Ru;bg=1;var r=xt,t=Lr,e=r("%Promise%",!0),n=Ec,i=qd(),s=Gd;return Ru=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)},Ru}var Pu,wg;function u1(){if(wg)return Pu;wg=1;var r=Vd;return Pu=function(e){return new r("throw",e)},Pu}var h1=xt,Lu=Lr,Sg=K,d1=h1("%Promise%",!0),p1=cn(),_g=p1("Promise.prototype.then",!0),f1=Vd,kg=c1(),g1=Bd,m1=qd(),xg=u1(),v1=Nv(),Jv=function(t,e){if(!(e instanceof f1))throw new Sg("`completion` must be a Completion Record");var n=t["[[DisposableResourceStack]]"];if(!n)throw new Sg("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 Lu("mixed hint stacks are not supported");for(var o=i==="ASYNC-DISPOSE"&&m1(d1,e),a=function(y){if(e.type()==="throw"){var m=e.value(),E=new v1(y,m);e=xg(E)}else e=xg(y)},c=i==="ASYNC-DISPOSE"&&function(m){return _g(o,function(){var E=kg(m["[[ResourceValue]]"],m["[[Hint]]"],m["[[DisposeMethod]]"]);if(!E)throw new Lu("Assertion failed: non-`~ASYNC-DISPOSE~` resource returned a promise from Dispose");return _g(E,g1)},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=kg(h["[[ResourceValue]]"],h["[[Hint]]"],h["[[DisposeMethod]]"]);if(f)throw new Lu("Assertion failed: `~SYNC-DISPOSE~` resource returned something from Dispose")}catch(y){a(y)}}return t["[[DisposableResourceStack]]"]=null,i==="ASYNC-DISPOSE"?o:e},Xv=function(){var t=[];return{"[[DisposableResourceStack]]":t}},$c=$d,Yd=K,y1=Ec,As=zd,b1=Pa,Qv=xs,w1=Bd,lt=Wd,S1=qv,ey=oi.supportsDescriptors,_1=jd,Kd=Kv,k1=Jv,ty=Xv,Eg=Md(),wt=function r(){if(!(this instanceof r)||lt.has(this,"[[DisposableState]]")||lt.has(this,"[[DisposeCapability]]"))throw new Yd("can only be used with new");lt.set(this,"[[DisposableState]]","PENDING"),lt.set(this,"[[DisposeCapability]]",ty())},ry=function(){var t=this;return lt.assert(t,"[[DisposableState]]"),lt.get(t,"[[DisposableState]]")==="DISPOSED"},za=_1(ry);ey?b1(wt.prototype,"disposed",{"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Get]]":ry}):wt.prototype.disposed=!1;var ny=function(t){lt.set(t,"[[DisposableState]]","DISPOSED"),ey||(t.disposed=!0)};As(wt.prototype,"dispose",function(){var t=this;if(!za(t))return ny(t),k1(lt.get(t,"[[DisposeCapability]]"),w1())["?"]()});As(wt.prototype,"use",function(t){var e=this;if(za(e))throw new $c("a disposed stack can not use anything new");return Kd(lt.get(e,"[[DisposeCapability]]"),t,"SYNC-DISPOSE"),t});As(wt.prototype,"adopt",function(t,e){var n=this;if(za(n))throw new $c("a disposed stack can not use anything new");if(!Qv(e))throw new Yd("`onDispose` must be a function");var i=function(){return y1(e,void 0,[t])};return Kd(lt.get(n,"[[DisposeCapability]]"),void 0,"SYNC-DISPOSE",i),t});As(wt.prototype,"defer",function(t){var e=this;if(za(e))throw new $c("a disposed stack can not defer anything new");if(!Qv(t))throw new Yd("`onDispose` must be a function");Kd(lt.get(e,"[[DisposeCapability]]"),void 0,"SYNC-DISPOSE",t)});As(wt.prototype,"move",function(){var t=this;if(za(t))throw new $c("a disposed stack can not use anything new");var e=new wt;return lt.set(e,"[[DisposeCapability]]",lt.get(t,"[[DisposeCapability]]")),lt.set(t,"[[DisposeCapability]]",ty()),ny(t),e});Eg&&As(wt.prototype,Eg,wt.prototype.dispose);S1(wt.prototype,"DisposableStack");var x1=wt,E1=x1,A1=function(){return typeof DisposableStack=="function"?DisposableStack:E1},T1=oi,$1=Ad(),I1=A1,C1=function(){var t=I1();return T1($1,{DisposableStack:t},{DisposableStack:!0}),t},R1=xt,Ic=$d,Jd=K,Ag=R1("%Promise%",!0),Xd=Kv,P1=Ec,Ts=zd,L1=Pa,D1=Jv,iy=xs,sy=Xv,z1=Bd,Tg=qd(),ct=Wd,O1=qv,oy=oi.supportsDescriptors,M1=jd,N1=cn(),U1=N1("Promise.prototype.then",!0),$g=Nd(),St=function r(){if(!(this instanceof r)||ct.has(this,"[[AsyncDisposableState]]")||ct.has(this,"[[DisposeCapability]]"))throw new Jd("can only be used with new");ct.set(this,"[[AsyncDisposableState]]","pending"),ct.set(this,"[[DisposeCapability]]",sy())},ay=function(){var t=this;return ct.assert(t,"[[AsyncDisposableState]]"),ct.get(t,"[[AsyncDisposableState]]")==="disposed"},Oa=M1(ay);oy?L1(St.prototype,"disposed",{"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Get]]":ay}):St.prototype.disposed=!1;var ly=function(t){ct.set(t,"[[AsyncDisposableState]]","disposed"),oy||(t.disposed=!0)};Ts(St.prototype,"disposeAsync",function(){var t=this;return Oa(t)?Tg(Ag):(ly(t),U1(Tg(Ag,D1(ct.get(t,"[[DisposeCapability]]"),z1())),function(e){return e["?"]()}))});Ts(St.prototype,"use",function(t){var e=this;if(Oa(e))throw new Ic("a disposed stack can not use anything new");return Xd(ct.get(e,"[[DisposeCapability]]"),t,"ASYNC-DISPOSE"),t});Ts(St.prototype,"adopt",function(t,e){var n=this;if(Oa(n))throw new Ic("a disposed stack can not use anything new");if(!iy(e))throw new Jd("`onDisposeAsync` must be a function");var i=function(){return P1(e,void 0,[t])};return i.value=t,Xd(ct.get(n,"[[DisposeCapability]]"),void 0,"ASYNC-DISPOSE",i),t});Ts(St.prototype,"defer",function(t){var e=this;if(Oa(e))throw new Ic("a disposed stack can not defer anything new");if(!iy(t))throw new Jd("`onDispose` must be a function");Xd(ct.get(e,"[[DisposeCapability]]"),void 0,"ASYNC-DISPOSE",t)});Ts(St.prototype,"move",function(){var t=this;if(Oa(t))throw new Ic("a disposed stack can not use anything new");var e=new St;return ct.set(e,"[[DisposeCapability]]",ct.get(t,"[[DisposeCapability]]")),ct.set(t,"[[DisposeCapability]]",sy()),ly(t),e});$g&&Ts(St.prototype,$g,St.prototype.disposeAsync);O1(St.prototype,"AsyncDisposableStack");var F1=St,H1=F1,Z1=function(){return typeof AsyncDisposableStack=="function"?AsyncDisposableStack:H1},W1=oi,V1=Ad(),B1=Z1,j1=function(){var t=B1();return W1(V1,{AsyncDisposableStack:t},{AsyncDisposableStack:!0}),t},G1=Wx,q1=Jx,Y1=C1,K1=j1,J1=function(){G1(),q1(),Y1(),K1()};J1();const Ig=new WeakMap;function X1(r){return(typeof r=="object"||typeof r=="function")&&r!==null&&"then"in r&&typeof r.then=="function"}function bi(r){return typeof r=="string"?r:typeof r=="symbol"?r.description??r.toString():r.name||"(anonymous class)"}function Cg(){return new Error("register(Key, factory) requires a factory function. Wrap existing instances as () => instance.")}function Q1(){return new Error("register(Key, factory) does not accept async factories. Await setup before registering.")}class eT{constructor(){g(this,"entries",new Map);g(this,"constructionStack",[])}register(t,e){if(e===void 0){if(typeof t!="function")throw Cg();this.validateClassRegistration(t),this.storeFactory(t,()=>this.instantiateClass(t));return}if(typeof e!="function")throw Cg();if(e.constructor.name==="AsyncFunction")throw Q1();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=Ig.get(t);if(e){if(t.length!==e.length)throw new Error(`${bi(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(`${bi(t)} cannot be registered with register(Class). Undecorated classes must have zero required constructor parameters. Use register(Key, () => value) instead.`)}instantiateClass(t){const e=Ig.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(`${bi(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=>bi(i)).join(" -> ");throw new Error(`Circular dependency detected: ${n}`)}this.constructionStack.push(t.key);try{const n=t.factory();if(X1(n))throw new Error(`Factory for ${bi(t.key)} returned a Promise. Await setup before registering.`);if(typeof n!="object"||n===null)throw new Error(`Factory for ${bi(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 eT,tT=.5,Rg=.1,Pg=8,rT=4,cy=3,uy=3,nT=4,Tn=255,hy=.2126,dy=.7152,py=.0722;async function fy(r){const t=iT(r);if(!t)return"light";try{return await aT(r,t)>=tT?"light":"dark"}catch{return"light"}}function iT(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(sT(o))return s}return null}function sT(r){return gy(r.backgroundImage)?!0:oT(r.backgroundColor)>0}function oT(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===nT?parseFloat(e[cy]):e.length===uy?1:0}async function aT(r,t){const e=r.getBoundingClientRect(),n=t.getBoundingClientRect(),i={x:rl((e.left-n.left)/n.width),y:rl((e.top-n.top)/n.height),width:rl(e.width/n.width),height:rl(e.height/n.height)},s=window.getComputedStyle(t),o=gy(s.backgroundImage);return o?cT({url:o,surfaceWidth:n.width,surfaceHeight:n.height,region:i}):uT(s.backgroundColor)}function gy(r){const t=r.match(/url\(\s*["']?([^"')]+)["']?\s*\)/);return t?t[1]:null}const Lg=new Map;function lT(r){let t=Lg.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}),Lg.set(r,t),t)}async function cT(r){const t=await lT(r.url),e=Math.max(Pg,Math.ceil(r.surfaceWidth*Rg)),n=Math.max(Pg,Math.ceil(r.surfaceHeight*Rg)),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 L=0,R=0;for(let V=0;V<I.length;V+=rT){const N=I[V]/Tn,H=I[V+1]/Tn,Y=I[V+2]/Tn,j=I[V+cy]/Tn;L+=j*(hy*N+dy*H+py*Y),R+=1}return R>0?L/R:1}function uT(r){const t=r.match(/rgba?\(([^)]+)\)/);if(!t)return 1;const e=t[1].split(/[\s,/]+/).filter(Boolean).map(parseFloat);if(e.length<uy)return 1;const n=e[0]/Tn,i=e[1]/Tn,s=e[2]/Tn;return hy*n+dy*i+py*s}function rl(r){return r<0?0:r>1?1:r}const hT=["ghost","glass"],mo=[...hT.map(r=>`[variant="${r}"]`),'[material="glass"]'].join(", "),nl=new WeakSet,Dg=new WeakSet;function my(r){if(Dg.has(r))return;Dg.add(r);for(const e of r.querySelectorAll(mo))Du(e);if(typeof MutationObserver!="function")return;new MutationObserver(e=>{for(const n of e)if(n.type==="childList")for(const i of n.addedNodes)dT(i,Du);else n.type==="attributes"&&n.target instanceof HTMLElement&&n.target.matches(mo)&&Du(n.target)}).observe(r,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["variant","material"]})}function dT(r,t){if(r instanceof Element){r instanceof HTMLElement&&r.matches(mo)&&t(r);for(const e of r.querySelectorAll(mo))t(e)}}async function Du(r){var e,n;if(nl.has(r)||r.hasAttribute("tone")||(e=r.parentElement)!=null&&e.closest("[tone]"))return;nl.add(r);const t=await fy(r);if(!r.matches(mo)){nl.delete(r);return}if(r.hasAttribute("tone")||(n=r.parentElement)!=null&&n.closest("[tone]")){nl.delete(r);return}r.setAttribute("tone",t)}const pT="*,*: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)}',Qd=new CSSStyleSheet;Qd.replaceSync(pT);const ep=new CSSStyleSheet;try{document.adoptedStyleSheets=[...document.adoptedStyleSheets,Qd,ep]}catch{}my(document);function vy(r){ep.replaceSync(r)}function Vl(){vy("")}function tp(r){try{r.adoptedStyleSheets=[...r.adoptedStyleSheets,Qd,ep]}catch{}my(r)}const fT=new Set(["target","currentTarget","eventPhase","defaultPrevented","isTrusted","timeStamp","srcElement","returnValue","cancelBubble","NONE","CAPTURING_PHASE","AT_TARGET","BUBBLING_PHASE","composedPath","stopPropagation","stopImmediatePropagation","preventDefault","initEvent"]);function gT(r){for(const t of Object.keys(r))if(fT.has(t))throw new Error(`Event payload key "${t}" is reserved; choose a different property name`)}function mT(r,t){gT(t);for(const e of Object.keys(t))Object.defineProperty(r,e,{value:t[e],writable:!0,enumerable:!0,configurable:!0})}function Be(){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}),mT(this,c)}}return r}class Nt extends globalThis.EventTarget{}function vT(r,t,e){const n=r.dispose.bind(r);r.dispose=()=>{if(!t())return e(),n()}}function Ma(r){var e;class t extends r{constructor(...s){super(...s);w(this,e,!1);vT(this,()=>l(this,e),()=>{b(this,e,!0)})}[Symbol.dispose](){this.dispose()}get disposed(){return l(this,e)}}return e=new WeakMap,t}const yT=Be(),bT=Be(),wT=Be(),qs=Be(),yy=Be(),ST=Be(),zu=Be(),Ye=4,ft=6,vo=2,mh=2,rp=8,_T=ft,np="auto",nn="auto",Fr=128,zg=50,ae=16,Qn=Fr*Ye+ae*(Ye-1),yo=Fr*ft+ae*(ft-1),kT=Qn+ae*2,xT=200,ET=4,il=150,AT=10,Og=2,Mg=8,TT=300,$T=4;function by(r){return _y(r)}function wy(r,t){return _y(r.flatMap(e=>xy(e,t)))}function Sy(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}Ey(n,"strip",t,e)}return{valid:t.length===0,errors:t}}function $n(r){const t=by(r),e=Sy(t);if(!e.valid)throw new Error(`Invalid layout: ${e.errors.join("; ")}`);return{totalNodes:t.length,nodes:t.filter(n=>n.type!=="row").map(PT)}}function _y(r){const t=[];for(const e of r){const n=ky(e);for(const i of n){if(i.type==="row"){t.push(...i.children.map(Rr));continue}t.push(i)}}return t}function ky(r){switch(r.type){case"card":return[Rr(r)];case"row":{const t=r.children.map(Rr);return t.length===0?[]:t.length===1?[t[0]]:[{...r,children:t}]}case"stack":{const t=[];for(const e of r.children){const n=ky(e);for(const i of n){if(i.type==="stack"){t.push(...i.children.map(vh));continue}if(i.type==="row"){t.push({...i,children:i.children.map(Rr)});continue}t.push(Rr(i))}}return t.length===0?[]:t.length===1?[vh(t[0])]:[{...r,children:t}]}}}function xy(r,t){switch(r.type){case"card":return r.artifactID===t?[]:[Rr(r)];case"row":{const e=r.children.filter(n=>n.artifactID!==t).map(Rr);return e.length===0?[]:e.length===1?[e[0]]:[{...r,children:e}]}case"stack":{const e=r.children.flatMap(n=>xy(n,t).filter(s=>s.type!=="stack"));return e.length===0?[]:e.length===1?[vh(e[0])]:[{...r,children:e}]}}}function Ey(r,t,e,n){switch(r.type){case"card":Ay(r,t,e,n);return;case"row":IT(r,t,e,n);return;case"stack":CT(r,t,e,n);return}}function Ay(r,t,e,n){"id"in r&&e.push(`Card ${Ns(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),RT(r.width)||e.push(`Card ${Ns(r)} width must be an integer in the range ${vo}-${rp}`),$y(r.height)||e.push(`Card ${Ns(r)} height must be an integer in the range 2-6 or "auto"`);const i=Li(r.width);t==="stack"&&i!==Ye&&e.push(`Stack child ${Ns(r)} width must be ${Ye}`),t==="row"&&i<vo&&e.push(`Row child ${Ns(r)} must be at least 2 columns wide`)}function Ns(r){return typeof r.artifactID=="string"&&r.artifactID.length>0?r.artifactID:"<missing artifactID>"}function IT(r,t,e,n){if(Ty(r.id,e),t!=="stack"&&e.push(`Row ${r.id} may only appear inside a stack`),$y(r.height,$T)||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}Ay(s,"row",e,n),i+=Li(s.width)}i!==Ye&&e.push(`Row ${r.id} children must sum to 4 columns`)}function CT(r,t,e,n){if(Ty(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(Ey(a,"stack",e,n),a.height===nn){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*mh||o%s!==0){e.push(`Stack ${r.id} has auto-height children that cannot resolve to whole height >= 2`);return}o/s<mh&&e.push(`Stack ${r.id} has auto-height children below the minimum row size`)}function Ty(r,t){(typeof r!="string"||r.length===0)&&t.push(`Node id must be a non-empty string: ${String(r)}`)}function RT(r){return r===np||Number.isInteger(r)&&r>=vo&&r<=rp}function $y(r,t=_T){return r===nn||Number.isInteger(r)&&r>=mh&&r<=t}function Li(r){return r===np?Ye:r}function PT(r){if(r.type==="card")return{id:r.artifactID,type:"card",width:Li(r.width),cards:[{id:r.artifactID,artifactID:r.artifactID,col:1,row:1,width:Li(r.width),height:Iy(r.height,ft)}]};const t=LT(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:Ye,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:Li(c.width),height:o}),a+=Li(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 LT(r){let t=0,e=0;for(const i of r)i.height===nn?e+=1:t+=i.height;const n=e>0?(ft-t)/e:0;return r.map(i=>Iy(i.height,n))}function Iy(r,t){return r===nn?t:r}function Rr(r){return{...r}}function vh(r){return r.type==="card"?Rr(r):{...r,children:r.children.map(Rr)}}const DT="X-Television-Client-Meta",zT="telemetry-activity";function Cy(r,t={}){return{type:"card",artifactID:r,width:t.width??np,height:t.height??nn}}function _l(r){return r.layout.flatMap(Ry)}function Ry(r){switch(r.type){case"card":return[r.artifactID];case"row":return r.children.map(t=>t.artifactID);case"stack":return r.children.flatMap(Ry)}}const oe=Be(),yh=Be(),wi=Be(),Ng=Be();function OT(r){class t extends Error{constructor(n,i){super(n),this.name=r,i&&Object.assign(this,i)}}return t}const ip=OT("RequestError"),MT=200,NT=300,sl=401;class UT{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 FT(i);if(!i.ok||i.status<MT||i.status>=NT)throw i.status===sl&&((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===sl&&((s=this.onUnauthorized)==null||s.call(this)),this.createError(await Ou(i,i.statusText),i.status)}async requestText(t,e){var i;const n=await this.request(t,e);if(!n.ok)throw n.status===sl&&((i=this.onUnauthorized)==null||i.call(this)),this.createError(await Ou(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===sl&&((s=this.onUnauthorized)==null||s.call(this)),this.createError(await Ou(i,i.statusText),i.status)}createError(t,e){const n={serverURL:this.serverURL};return e!==void 0&&(n.status=e),new ip(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[DT]=JSON.stringify(this.telemetryMeta)),Object.keys(e).length>0?e:void 0}}async function FT(r){try{return await r.json()}catch{const t=await r.text().catch(()=>"");return t?{message:t}:{}}}async function Ou(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 HT(r){return r.map(t=>`${t.name} (${t.id})`).join(", ")}var jt,ic,Py;class ZT{constructor(t){w(this,ic);w(this,jt);b(this,jt,t)}list(){return l(this,jt).requestJSON("GET","/screens")}async get(t={}){const e=await p(this,ic,Py).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,ic=new WeakSet,Py=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: ${HT(e)}`)};var Sr;class WT{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 Hi;class VT{constructor(t){w(this,Hi);b(this,Hi,t)}get(t){return l(this,Hi).requestText("GET",`/markdown/${encodeURIComponent(t.artifactID)}`)}update(t){return l(this,Hi).requestRawVoid("PUT",`/markdown/${encodeURIComponent(t.artifactID)}`,t.content)}}Hi=new WeakMap;var Rn;class BT{constructor(t){w(this,Rn);b(this,Rn,t)}status(){return l(this,Rn).requestJSON("GET","/telemetry")}enable(){return l(this,Rn).requestJSON("POST","/telemetry/enable")}disable(){return l(this,Rn).requestJSON("POST","/telemetry/disable")}}Rn=new WeakMap;var Pn;class jT{constructor(t){w(this,Pn);b(this,Pn,t)}get(){return l(this,Pn).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,Pn).requestVoid("PATCH","/display",e)}focus(t){return l(this,Pn).requestJSON("POST","/display/focus",{artifactID:t.artifactID})}}Pn=new WeakMap;var Gt;class GT{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 UT(t,e)),this.screens=new ZT(l(this,Gt)),this.artifacts=new WT(l(this,Gt)),this.display=new jT(l(this,Gt)),this.markdown=new VT(l(this,Gt)),this.telemetry=new BT(l(this,Gt))}health(){return l(this,Gt).requestJSON("GET","/health")}}Gt=new WeakMap;const qT={focusCommandInput:{label:"Focus Command Input",trigger:{key:"k",meta:!0}}},YT="Local",KT="store-";function he(r){return new URL(r).origin}function JT(r){return{servers:[{url:he(r),name:YT}],activeServerURL:null,activeScreenID:null,tabs:{},screens:{},authTokens:{}}}function XT(r,t){return[...r.tabs[he(t)]??[]]}function QT(r,t,e){const n=he(t),i=r.tabs[n]??[];return i.includes(e)?r:{...r,tabs:{...r.tabs,[n]:[...i,e]}}}function e$(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 t$(r,t,e=Date.now()){const n=r.screens[t]??{scrollPosition:0};return{...r,screens:{...r.screens,[t]:{...n,lastActivatedAt:e}}}}var Ln,Dn,zn;class r$ extends Nt{constructor(e,n,i={}){super();w(this,Ln);w(this,Dn);w(this,zn);b(this,Ln,`${KT}${e}`),b(this,Dn,i.storage??s$());const s=l(this,Dn).getItem(l(this,Ln));s===null?(b(this,zn,n),l(this,Dn).setItem(l(this,Ln),JSON.stringify(n))):b(this,zn,o$(JSON.parse(s),n))}get(){return l(this,zn)}set(e){b(this,zn,e),l(this,Dn).setItem(l(this,Ln),JSON.stringify(e)),this.dispatchEvent(new oe("change"))}}Ln=new WeakMap,Dn=new WeakMap,zn=new WeakMap;function Mu(r,t){return r.authTokens[he(t)]??null}function n$(r,t,e){return{...r,authTokens:{...r.authTokens,[he(t)]:e}}}function i$(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 s$(){const r=globalThis.localStorage;if(!r)throw new Error("LocalStore: no storage adapter supplied and window.localStorage is unavailable");return r}function o$(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 a$ extends Event{constructor(){super("theme-changed")}}const l$=Ma(Nt);var On,Ne,Zr,Ge,Wr,_r,Eo,ee,Sn,Ly,Ao,Dy,zy,Oy,My,bh,wh,Sh,Ny;class c$ extends l${constructor(e){var i;super();w(this,ee);g(this,"id");g(this,"server");w(this,On);w(this,Ne,new Map);w(this,Zr);w(this,Ge);w(this,Wr);w(this,_r,null);w(this,Eo,0);w(this,Ao,e=>{if(this.disposed)return;const n=e.event;switch(n.type){case"screen-updated":n.screen.id===this.id&&p(this,ee,Dy).call(this,n.screen);break;case"artifact-created":n.screenID===this.id&&p(this,ee,zy).call(this,n.artifact);break;case"artifact-updated":p(this,ee,Oy).call(this,n.artifact);break;case"artifact-removed":n.screenID===this.id&&p(this,ee,My).call(this,n.artifactID);break;case"artifact-content-changed":l(this,Ne).has(n.artifactID)&&this.dispatchEvent(new Ng("artifact-content-changed",{artifactID:n.artifactID}));break;case"theme-changed":this.dispatchEvent(new a$);break}});this.id=e.screen.id,this.server=e.server,b(this,On,e.localStore),b(this,Zr,e.screen.name),b(this,Ge,structuredClone(e.screen.layout));const n=((i=l(this,On).get().screens[this.id])==null?void 0:i.scrollPosition)??0;b(this,Wr,Math.max(0,n)),this.server.addEventListener("server-event",l(this,Ao)),p(this,ee,Ly).call(this)}get name(){return l(this,Zr)}get layout(){return l(this,Ge)}get scrollPosition(){return l(this,Wr)}get artifacts(){return l(this,Ne)}setScrollPosition(e){p(this,ee,Sn).call(this);const n=Math.max(0,e);n!==l(this,Wr)&&(b(this,Wr,n),p(this,ee,Ny).call(this),this.dispatchEvent(new oe("change")))}setLayout(e){p(this,ee,Sn).call(this);const n=by(e);if(!Sy(n).valid)return;const s=p(this,ee,wh).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,Sh).call(this,s),this.dispatchEvent(new oe("change")))})}rename(e){p(this,ee,Sn).call(this),b(this,Zr,e),this.dispatchEvent(new oe("change")),this.server.client.screens.update({screenID:this.id,name:e}).catch(()=>{})}async remove(){p(this,ee,Sn).call(this),await this.server.client.screens.remove({screenID:this.id})}removeArtifact(e){if(p(this,ee,Sn).call(this),!l(this,Ne).has(e))return;const n=p(this,ee,wh).call(this);p(this,ee,bh).call(this,e),this.dispatchEvent(new oe("change")),this.server.client.artifacts.delete({artifactID:e}).catch(()=>{this.disposed||(p(this,ee,Sh).call(this,n),this.dispatchEvent(new oe("change")))})}async refreshFromServer(){p(this,ee,Sn).call(this);const e=++iu(this,Eo)._;let n;try{n=await this.server.client.screens.get({screenID:this.id})}catch{return}if(this.disposed||e!==l(this,Eo))return;const i=new Set([...l(this,Ne).values()].filter(s=>s.kind==="path").map(s=>s.id));b(this,_r,null),b(this,Zr,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 Ng("artifact-content-changed",{artifactID:s.id}))}dispose(){this.server.removeEventListener("server-event",l(this,Ao))}}On=new WeakMap,Ne=new WeakMap,Zr=new WeakMap,Ge=new WeakMap,Wr=new WeakMap,_r=new WeakMap,Eo=new WeakMap,ee=new WeakSet,Sn=function(){if(this.disposed)throw new Error("ScreenModel is disposed")},Ly=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{}},Ao=new WeakMap,Dy=function(e){l(this,_r)&&b(this,_r,null),b(this,Zr,e.name),b(this,Ge,structuredClone(e.layout)),this.dispatchEvent(new oe("change"))},zy=function(e){_l({layout:l(this,Ge)}).includes(e.id)||b(this,Ge,[...l(this,Ge),Cy(e.id)]),l(this,Ne).set(e.id,e),this.dispatchEvent(new oe("change"))},Oy=function(e){const n=l(this,Ne).get(e.id);n&&(l(this,Ne).set(e.id,{...n,...e}),this.dispatchEvent(new oe("change")))},My=function(e){p(this,ee,bh).call(this,e)&&this.dispatchEvent(new oe("change"))},bh=function(e){const n=l(this,Ne).delete(e),i=_l({layout:l(this,Ge)}).length,s=wy(l(this,Ge),e),o=_l({layout:s}).length;return b(this,Ge,s),n||i!==o},wh=function(){return{layout:structuredClone(l(this,Ge)),artifacts:new Map([...l(this,Ne).entries()].map(([e,n])=>[e,structuredClone(n)]))}},Sh=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))},Ny=function(){const e=l(this,On).get();l(this,On).set({...e,screens:{...e.screens,[this.id]:{...e.screens[this.id],scrollPosition:l(this,Wr)}}})};const u$=Ma(Nt);var Pe,Ue,$t,To,$o,Io,Co,Qe,kl,_h,xi;class h$ extends u${constructor(e){super();w(this,Qe);w(this,Pe);w(this,Ue);w(this,$t,null);w(this,To,()=>{this.disposed||p(this,Qe,kl).call(this)});w(this,$o,()=>{this.disposed||p(this,Qe,kl).call(this)});w(this,Io,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,Qe,xi).call(this,e.serverURL,null);return}if(n.type==="screen-changed"){if(n.screenID===null){p(this,Qe,xi).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,Qe,xi).call(this,e.serverURL,n.screenID)}});w(this,Co,e=>{if(this.disposed)return;const n=l(this,$t);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,To)),l(this,Ue).addEventListener("change",l(this,$o)),l(this,Ue).addEventListener("server-event",l(this,Io)),l(this,Ue).addEventListener("server-reconnected",l(this,Co)),p(this,Qe,kl).call(this)}get activeScreen(){return l(this,$t)}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=XT(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,Qe,_h).call(this,QT(l(this,Pe).get(),i,n))}removeTab(e,n){p(this,Qe,_h).call(this,e$(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,Qe,xi).call(this,i,n)&&s.client.display.patch({activeScreenID:n}).catch(()=>{})}clearActive(){const e=l(this,Pe).get().activeServerURL;if(!e||!p(this,Qe,xi).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,To)),l(this,Ue).removeEventListener("change",l(this,$o)),l(this,Ue).removeEventListener("server-event",l(this,Io)),l(this,Ue).removeEventListener("server-reconnected",l(this,Co)),(e=l(this,$t))==null||e.dispose(),b(this,$t,null)}}Pe=new WeakMap,Ue=new WeakMap,$t=new WeakMap,To=new WeakMap,$o=new WeakMap,Io=new WeakMap,Co=new WeakMap,Qe=new WeakSet,kl=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,$t))==null?void 0:c.id)??null,a=(s==null?void 0:s.id)??null;o===a&&((u=l(this,$t))==null?void 0:u.server)===i||((h=l(this,$t))==null||h.dispose(),b(this,$t,i&&s?new c$({screen:s,server:i,localStore:l(this,Pe)}):null),i&&i.acpClient.setScreenContext(s?{screenID:s.id,screenName:s.name}:null),this.dispatchEvent(new yT("active-screen-changed")))},_h=function(e){e!==l(this,Pe).get()&&(l(this,Pe).set(e),this.dispatchEvent(new bT("tabs-changed")))},xi=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}:t$({...s,activeServerURL:i,activeScreenID:n},n);return l(this,Pe).set(o),!0};const Uy="0123456789ABCDEFGHJKMNPQRSTVWXYZ",Bl=32,d$=16,Fy=10,Ug=0xffffffffffff;var In;(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"})(In||(In={}));class Ys extends Error{constructor(t,e){super(`${e} (${t})`),this.name="ULIDError",this.code=t}}function p$(r){const t=Math.floor(r()*Bl)%Bl;return Uy.charAt(t)}function f$(r){const t=g$(),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 Ys(In.PRNGDetectFailure,"Failed to find a reliable PRNG")}function g$(){return y$()?self:typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:null}function m$(r,t){let e="";for(;r>0;r--)e=p$(t)+e;return e}function v$(r,t=Fy){if(isNaN(r))throw new Ys(In.EncodeTimeValueMalformed,`Time must be a number: ${r}`);if(r>Ug)throw new Ys(In.EncodeTimeSizeExceeded,`Cannot encode a time larger than ${Ug}: ${r}`);if(r<0)throw new Ys(In.EncodeTimeNegative,`Time must be positive: ${r}`);if(Number.isInteger(r)===!1)throw new Ys(In.EncodeTimeValueMalformed,`Time must be an integer: ${r}`);let e,n="";for(let i=t;i>0;i--)e=r%Bl,n=Uy.charAt(e)+n,r=(r-e)/Bl;return n}function y$(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}function Cc(r,t){const e=f$(),n=Date.now();return v$(n,Fy)+m$(d$,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 Ni extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Hy extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const Zy={};function sn(r){return Zy}function Wy(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 kh(r,t){return typeof t=="bigint"?t.toString():t}function Rc(r){return{get value(){{const t=r();return Object.defineProperty(this,"value",{value:t}),t}}}}function sp(r){return r==null}function op(r){const t=r.startsWith("^")?1:0,e=r.endsWith("$")?r.length-1:r.length;return r.slice(t,e)}function b$(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 Fg=Symbol("evaluating");function te(r,t,e){let n;Object.defineProperty(r,t,{get(){if(n!==Fg)return n===void 0&&(n=Fg,n=e()),n},set(i){Object.defineProperty(r,t,{value:i})},configurable:!0})}function li(r,t,e){Object.defineProperty(r,t,{value:e,writable:!0,enumerable:!0,configurable:!0})}function hn(...r){const t={};for(const e of r){const n=Object.getOwnPropertyDescriptors(e);Object.assign(t,n)}return Object.defineProperties({},t)}function Hg(r){return JSON.stringify(r)}function w$(r){return r.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Vy="captureStackTrace"in Error?Error.captureStackTrace:(...r)=>{};function bo(r){return typeof r=="object"&&r!==null&&!Array.isArray(r)}const S$=Rc(()=>{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 gs(r){if(bo(r)===!1)return!1;const t=r.constructor;if(t===void 0||typeof t!="function")return!0;const e=t.prototype;return!(bo(e)===!1||Object.prototype.hasOwnProperty.call(e,"isPrototypeOf")===!1)}function By(r){return gs(r)?{...r}:Array.isArray(r)?[...r]:r}const _$=new Set(["string","number","symbol"]);function ms(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function dn(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 k$(r){return Object.keys(r).filter(t=>r[t]._zod.optin==="optional"&&r[t]._zod.optout==="optional")}const x$={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 E$(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=hn(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 li(this,"shape",o),o},checks:[]});return dn(r,s)}function A$(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=hn(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 li(this,"shape",o),o},checks:[]});return dn(r,s)}function T$(r,t){if(!gs(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=hn(r._zod.def,{get shape(){const s={...r._zod.def.shape,...t};return li(this,"shape",s),s}});return dn(r,i)}function $$(r,t){if(!gs(t))throw new Error("Invalid input to safeExtend: expected a plain object");const e=hn(r._zod.def,{get shape(){const n={...r._zod.def.shape,...t};return li(this,"shape",n),n}});return dn(r,e)}function I$(r,t){const e=hn(r._zod.def,{get shape(){const n={...r._zod.def.shape,...t._zod.def.shape};return li(this,"shape",n),n},get catchall(){return t._zod.def.catchall},checks:[]});return dn(r,e)}function C$(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=hn(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 li(this,"shape",c),c},checks:[]});return dn(t,o)}function R$(r,t,e){const n=hn(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 li(this,"shape",s),s}});return dn(t,n)}function Di(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 zi(r,t){return t.map(e=>{var n;return(n=e).path??(n.path=[]),e.path.unshift(r),e})}function ol(r){return typeof r=="string"?r:r==null?void 0:r.message}function on(r,t,e){var i,s,o,a,c,u;const n={...r,path:r.path??[]};if(!r.message){const h=ol((o=(s=(i=r.inst)==null?void 0:i._zod.def)==null?void 0:s.error)==null?void 0:o.call(s,r))??ol((a=t==null?void 0:t.error)==null?void 0:a.call(t,r))??ol((c=e.customError)==null?void 0:c.call(e,r))??ol((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 ap(r){return Array.isArray(r)?"array":typeof r=="string"?"string":"unknown"}function wo(...r){const[t,e,n]=r;return typeof t=="string"?{message:t,code:"custom",input:e,inst:n}:{...t}}const jy=(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,kh,2),Object.defineProperty(r,"toString",{value:()=>r.message,enumerable:!1})},Gy=A("$ZodError",jy),qy=A("$ZodError",jy,{Parent:Error});function P$(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 L$(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 lp=r=>(t,e,n,i)=>{const s=n?Object.assign(n,{async:!1}):{async:!1},o=t._zod.run({value:e,issues:[]},s);if(o instanceof Promise)throw new Ni;if(o.issues.length){const a=new((i==null?void 0:i.Err)??r)(o.issues.map(c=>on(c,s,sn())));throw Vy(a,i==null?void 0:i.callee),a}return o.value},cp=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=>on(c,s,sn())));throw Vy(a,i==null?void 0:i.callee),a}return o.value},Pc=r=>(t,e,n)=>{const i=n?{...n,async:!1}:{async:!1},s=t._zod.run({value:e,issues:[]},i);if(s instanceof Promise)throw new Ni;return s.issues.length?{success:!1,error:new(r??Gy)(s.issues.map(o=>on(o,i,sn())))}:{success:!0,data:s.value}},D$=Pc(qy),Lc=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=>on(o,i,sn())))}:{success:!0,data:s.value}},z$=Lc(qy),O$=r=>(t,e,n)=>{const i=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return lp(r)(t,e,i)},M$=r=>(t,e,n)=>lp(r)(t,e,n),N$=r=>async(t,e,n)=>{const i=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return cp(r)(t,e,i)},U$=r=>async(t,e,n)=>cp(r)(t,e,n),F$=r=>(t,e,n)=>{const i=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return Pc(r)(t,e,i)},H$=r=>(t,e,n)=>Pc(r)(t,e,n),Z$=r=>async(t,e,n)=>{const i=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return Lc(r)(t,e,i)},W$=r=>async(t,e,n)=>Lc(r)(t,e,n),V$=/^[cC][^\s-]{8,}$/,B$=/^[0-9a-z]+$/,j$=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,G$=/^[0-9a-vA-V]{20}$/,q$=/^[A-Za-z0-9]{27}$/,Y$=/^[a-zA-Z0-9_-]{21}$/,K$=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,J$=/^([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})$/,Zg=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)$/,X$=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Q$="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function eI(){return new RegExp(Q$,"u")}const tI=/^(?:(?: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])$/,rI=/^(([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}|:))$/,nI=/^((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])$/,iI=/^(([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])$/,sI=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Yy=/^[A-Za-z0-9_-]*$/,oI=/^\+[1-9]\d{6,14}$/,Ky="(?:(?:\\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])))",aI=new RegExp(`^${Ky}$`);function Jy(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 lI(r){return new RegExp(`^${Jy(r)}$`)}function cI(r){const t=Jy({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(`^${Ky}T(?:${n})$`)}const uI=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}$`)},hI=/^-?\d+$/,Xy=/^-?\d+(?:\.\d+)?$/,dI=/^(?:true|false)$/i,pI=/^[^A-Z]*$/,fI=/^[^a-z]*$/,ut=A("$ZodCheck",(r,t)=>{var e;r._zod??(r._zod={}),r._zod.def=t,(e=r._zod).onattach??(e.onattach=[])}),Qy={number:"number",bigint:"bigint",object:"date"},eb=A("$ZodCheckLessThan",(r,t)=>{ut.init(r,t);const e=Qy[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})}}),tb=A("$ZodCheckGreaterThan",(r,t)=>{ut.init(r,t);const e=Qy[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})}}),gI=A("$ZodCheckMultipleOf",(r,t)=>{ut.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):b$(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})}}),mI=A("$ZodCheckNumberFormat",(r,t)=>{var o;ut.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]=x$[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=hI)}),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})}}),vI=A("$ZodCheckMaxLength",(r,t)=>{var e;ut.init(r,t),(e=r._zod.def).when??(e.when=n=>{const i=n.value;return!sp(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=ap(i);n.issues.push({origin:o,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:r,continue:!t.abort})}}),yI=A("$ZodCheckMinLength",(r,t)=>{var e;ut.init(r,t),(e=r._zod.def).when??(e.when=n=>{const i=n.value;return!sp(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=ap(i);n.issues.push({origin:o,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:r,continue:!t.abort})}}),bI=A("$ZodCheckLengthEquals",(r,t)=>{var e;ut.init(r,t),(e=r._zod.def).when??(e.when=n=>{const i=n.value;return!sp(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=ap(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})}}),Dc=A("$ZodCheckStringFormat",(r,t)=>{var e,n;ut.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=()=>{})}),wI=A("$ZodCheckRegex",(r,t)=>{Dc.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})}}),SI=A("$ZodCheckLowerCase",(r,t)=>{t.pattern??(t.pattern=pI),Dc.init(r,t)}),_I=A("$ZodCheckUpperCase",(r,t)=>{t.pattern??(t.pattern=fI),Dc.init(r,t)}),kI=A("$ZodCheckIncludes",(r,t)=>{ut.init(r,t);const e=ms(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})}}),xI=A("$ZodCheckStartsWith",(r,t)=>{ut.init(r,t);const e=new RegExp(`^${ms(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})}}),EI=A("$ZodCheckEndsWith",(r,t)=>{ut.init(r,t);const e=new RegExp(`.*${ms(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})}}),AI=A("$ZodCheckOverwrite",(r,t)=>{ut.init(r,t),r._zod.check=e=>{e.value=t.tx(e.value)}});class TI{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
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
|
|
7
|
-
if (${
|
|
6
|
+
`))}}const $I={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=$I;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=Di(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 Ni;if(f||E instanceof Promise)f=(f??Promise.resolve()).then(async()=>{await E,a.issues.length!==m&&(h||(h=Di(a,m)))});else{if(a.issues.length===m)continue;h||(h=Di(a,m))}}return f?f.then(()=>a):a},o=(a,c,u)=>{if(Di(a))return a.aborted=!0,a;const h=s(c,n,u);if(h instanceof Promise){if(u.async===!1)throw new Ni;return h.then(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 Ni;return u.then(h=>s(h,n,c))}return s(u,n,c)}}te(r,"~standard",()=>({validate:s=>{var o;try{const a=D$(r,s);return a.success?{value:a.data}:{issues:(o=a.error)==null?void 0:o.issues}}catch{return z$(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}))}),up=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()??uI(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)=>{Dc.init(r,t),up.init(r,t)}),II=A("$ZodGUID",(r,t)=>{t.pattern??(t.pattern=J$),ge.init(r,t)}),CI=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=Zg(n))}else t.pattern??(t.pattern=Zg());ge.init(r,t)}),RI=A("$ZodEmail",(r,t)=>{t.pattern??(t.pattern=X$),ge.init(r,t)}),PI=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})}}}),LI=A("$ZodEmoji",(r,t)=>{t.pattern??(t.pattern=eI()),ge.init(r,t)}),DI=A("$ZodNanoID",(r,t)=>{t.pattern??(t.pattern=Y$),ge.init(r,t)}),zI=A("$ZodCUID",(r,t)=>{t.pattern??(t.pattern=V$),ge.init(r,t)}),OI=A("$ZodCUID2",(r,t)=>{t.pattern??(t.pattern=B$),ge.init(r,t)}),MI=A("$ZodULID",(r,t)=>{t.pattern??(t.pattern=j$),ge.init(r,t)}),NI=A("$ZodXID",(r,t)=>{t.pattern??(t.pattern=G$),ge.init(r,t)}),UI=A("$ZodKSUID",(r,t)=>{t.pattern??(t.pattern=q$),ge.init(r,t)}),FI=A("$ZodISODateTime",(r,t)=>{t.pattern??(t.pattern=cI(t)),ge.init(r,t)}),HI=A("$ZodISODate",(r,t)=>{t.pattern??(t.pattern=aI),ge.init(r,t)}),ZI=A("$ZodISOTime",(r,t)=>{t.pattern??(t.pattern=lI(t)),ge.init(r,t)}),WI=A("$ZodISODuration",(r,t)=>{t.pattern??(t.pattern=K$),ge.init(r,t)}),VI=A("$ZodIPv4",(r,t)=>{t.pattern??(t.pattern=tI),ge.init(r,t),r._zod.bag.format="ipv4"}),BI=A("$ZodIPv6",(r,t)=>{t.pattern??(t.pattern=rI),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})}}}),jI=A("$ZodCIDRv4",(r,t)=>{t.pattern??(t.pattern=nI),ge.init(r,t)}),GI=A("$ZodCIDRv6",(r,t)=>{t.pattern??(t.pattern=iI),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 rb(r){if(r==="")return!0;if(r.length%4!==0)return!1;try{return atob(r),!0}catch{return!1}}const qI=A("$ZodBase64",(r,t)=>{t.pattern??(t.pattern=sI),ge.init(r,t),r._zod.bag.contentEncoding="base64",r._zod.check=e=>{rb(e.value)||e.issues.push({code:"invalid_format",format:"base64",input:e.value,inst:r,continue:!t.abort})}});function YI(r){if(!Yy.test(r))return!1;const t=r.replace(/[-_]/g,n=>n==="-"?"+":"/"),e=t.padEnd(Math.ceil(t.length/4)*4,"=");return rb(e)}const KI=A("$ZodBase64URL",(r,t)=>{t.pattern??(t.pattern=Yy),ge.init(r,t),r._zod.bag.contentEncoding="base64url",r._zod.check=e=>{YI(e.value)||e.issues.push({code:"invalid_format",format:"base64url",input:e.value,inst:r,continue:!t.abort})}}),JI=A("$ZodE164",(r,t)=>{t.pattern??(t.pattern=oI),ge.init(r,t)});function XI(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 QI=A("$ZodJWT",(r,t)=>{ge.init(r,t),r._zod.check=e=>{XI(e.value,t.alg)||e.issues.push({code:"invalid_format",format:"jwt",input:e.value,inst:r,continue:!t.abort})}}),nb=A("$ZodNumber",(r,t)=>{ve.init(r,t),r._zod.pattern=r._zod.bag.pattern??Xy,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}}),eC=A("$ZodNumberFormat",(r,t)=>{mI.init(r,t),nb.init(r,t)}),tC=A("$ZodBoolean",(r,t)=>{ve.init(r,t),r._zod.pattern=dI,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}}),rC=A("$ZodUnknown",(r,t)=>{ve.init(r,t),r._zod.parse=e=>e}),nC=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 Wg(r,t,e){r.issues.length&&t.issues.push(...zi(e,r.issues)),t.value[e]=r.value}const iC=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=>Wg(u,e,o))):Wg(c,e,o)}return s.length?Promise.all(s).then(()=>e):e}});function jl(r,t,e,n,i){if(r.issues.length){if(i&&!(e in n))return;t.issues.push(...zi(e,r.issues))}r.value===void 0?e in n&&(t.value[e]=void 0):t.value[e]=r.value}function ib(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=k$(r.shape);return{...r,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(e)}}function sb(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=>jl(m,e,f,t,h))):jl(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 sC=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=Rc(()=>ib(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=bo,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=>jl(I,a,y,u,E))):jl(x,a,y,u,E)}return s?sb(h,u,a,c,n.value,r):h.length?Promise.all(h).then(()=>a):a}}),oC=A("$ZodObjectJIT",(r,t)=>{sC.init(r,t);const e=r._zod.parse,n=Rc(()=>ib(t)),i=y=>{var V;const m=new TI(["shape","payload","ctx"]),E=n.value,x=N=>{const H=Hg(N);return`shape[${H}]._zod.run({ value: input[${H}], issues: [] }, ctx)`};m.write("const input = payload.value;");const I=Object.create(null);let L=0;for(const N of E.keys)I[N]=`key_${L++}`;m.write("const newResult = {};");for(const N of E.keys){const H=I[N],Y=Hg(N),j=y[N],ce=((V=j==null?void 0:j._zod)==null?void 0:V.optout)==="optional";m.write(`const ${H} = ${x(N)};`),ce?m.write(`
|
|
7
|
+
if (${H}.issues.length) {
|
|
8
8
|
if (${Y} in input) {
|
|
9
|
-
payload.issues = payload.issues.concat(${
|
|
9
|
+
payload.issues = payload.issues.concat(${H}.issues.map(iss => ({
|
|
10
10
|
...iss,
|
|
11
11
|
path: iss.path ? [${Y}, ...iss.path] : [${Y}]
|
|
12
12
|
})));
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
if (${
|
|
16
|
+
if (${H}.value === undefined) {
|
|
17
17
|
if (${Y} in input) {
|
|
18
18
|
newResult[${Y}] = undefined;
|
|
19
19
|
}
|
|
20
20
|
} else {
|
|
21
|
-
newResult[${Y}] = ${
|
|
21
|
+
newResult[${Y}] = ${H}.value;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
`):m.write(`
|
|
25
|
-
if (${
|
|
26
|
-
payload.issues = payload.issues.concat(${
|
|
25
|
+
if (${H}.issues.length) {
|
|
26
|
+
payload.issues = payload.issues.concat(${H}.issues.map(iss => ({
|
|
27
27
|
...iss,
|
|
28
28
|
path: iss.path ? [${Y}, ...iss.path] : [${Y}]
|
|
29
29
|
})));
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
if (${
|
|
32
|
+
if (${H}.value === undefined) {
|
|
33
33
|
if (${Y} in input) {
|
|
34
34
|
newResult[${Y}] = undefined;
|
|
35
35
|
}
|
|
36
36
|
} else {
|
|
37
|
-
newResult[${Y}] = ${
|
|
37
|
+
newResult[${Y}] = ${H}.value;
|
|
38
38
|
}
|
|
39
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>
|
|
40
|
+
`)}m.write("payload.value = newResult;"),m.write("return payload;");const R=m.compile();return(N,H)=>R(y,N,H)};let s;const o=bo,a=!Zy.jitless,u=a&&S$.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?sb([],E,y,m,f,r):y):e(y,m):(y.issues.push({expected:"object",code:"invalid_type",input:E,inst:r}),y)}});function Vg(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=>!Di(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=>on(o,n,sn())))}),t)}const ob=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=>op(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=>Vg(c,i,r,s)):Vg(a,i,r,s)}}),aC=A("$ZodDiscriminatedUnion",(r,t)=>{t.inclusive=!1,ob.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=Rc(()=>{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(!bo(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)}}),lC=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])=>Bg(e,c,u)):Bg(e,s,o)}});function xh(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(gs(r)&&gs(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=xh(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=xh(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 Bg(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}),Di(r))return r;const o=xh(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 cC=A("$ZodRecord",(r,t)=>{ve.init(r,t),r._zod.parse=(e,n)=>{const i=e.value;if(!gs(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(...zi(u,f.issues)),e.value[u]=f.value})):(h.issues.length&&e.issues.push(...zi(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"&&Xy.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=>on(f,n,sn())),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(...zi(a,f.issues)),e.value[c.value]=f.value})):(h.issues.length&&e.issues.push(...zi(a,h.issues)),e.value[c.value]=h.value)}}return s.length?Promise.all(s).then(()=>e):e}}),uC=A("$ZodEnum",(r,t)=>{ve.init(r,t);const e=Wy(t.entries),n=new Set(e);r._zod.values=n,r._zod.pattern=new RegExp(`^(${e.filter(i=>_$.has(typeof i)).map(i=>typeof i=="string"?ms(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}}),hC=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"?ms(n):n?ms(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}}),dC=A("$ZodTransform",(r,t)=>{ve.init(r,t),r._zod.parse=(e,n)=>{if(n.direction==="backward")throw new Hy(r.constructor.name);const i=t.transform(e.value,e);if(n.async)return(i instanceof Promise?i:Promise.resolve(i)).then(o=>(e.value=o,e));if(i instanceof Promise)throw new Ni;return e.value=i,e}});function jg(r,t){return r.issues.length&&t===void 0?{issues:[],value:void 0}:r}const ab=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(`^(${op(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=>jg(s,e.value)):jg(i,e.value)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),pC=A("$ZodExactOptional",(r,t)=>{ab.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)}),fC=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(`^(${op(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)}),gC=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=>Gg(s,t)):Gg(i,t)}});function Gg(r,t){return r.value===void 0&&(r.value=t.defaultValue),r}const mC=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))}),vC=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=>qg(s,r)):qg(i,r)}});function qg(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 yC=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=>on(o,n,sn()))},input:e.value}),e.issues=[]),e)):(e.value=i.value,i.issues.length&&(e.value=t.catchValue({...e,error:{issues:i.issues.map(s=>on(s,n,sn()))},input:e.value}),e.issues=[]),e)}}),bC=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=>al(o,t.in,n)):al(s,t.in,n)}const i=t.in._zod.run(e,n);return i instanceof Promise?i.then(s=>al(s,t.out,n)):al(i,t.out,n)}});function al(r,t,e){return r.issues.length?(r.aborted=!0,r):t._zod.run({value:r.value,issues:r.issues},e)}const wC=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(Yg):Yg(i)}});function Yg(r){return r.value=Object.freeze(r.value),r}const SC=A("$ZodCustom",(r,t)=>{ut.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=>Kg(s,e,n,r));Kg(i,e,n,r)}});function Kg(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(wo(i))}}var Jg;class _C{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 kC(){return new _C}(Jg=globalThis).__zod_globalRegistry??(Jg.__zod_globalRegistry=kC());const Ks=globalThis.__zod_globalRegistry;function xC(r,t){return new r({type:"string",...O(t)})}function EC(r,t){return new r({type:"string",format:"email",check:"string_format",abort:!1,...O(t)})}function Xg(r,t){return new r({type:"string",format:"guid",check:"string_format",abort:!1,...O(t)})}function AC(r,t){return new r({type:"string",format:"uuid",check:"string_format",abort:!1,...O(t)})}function TC(r,t){return new r({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...O(t)})}function $C(r,t){return new r({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...O(t)})}function IC(r,t){return new r({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...O(t)})}function CC(r,t){return new r({type:"string",format:"url",check:"string_format",abort:!1,...O(t)})}function RC(r,t){return new r({type:"string",format:"emoji",check:"string_format",abort:!1,...O(t)})}function PC(r,t){return new r({type:"string",format:"nanoid",check:"string_format",abort:!1,...O(t)})}function LC(r,t){return new r({type:"string",format:"cuid",check:"string_format",abort:!1,...O(t)})}function DC(r,t){return new r({type:"string",format:"cuid2",check:"string_format",abort:!1,...O(t)})}function zC(r,t){return new r({type:"string",format:"ulid",check:"string_format",abort:!1,...O(t)})}function OC(r,t){return new r({type:"string",format:"xid",check:"string_format",abort:!1,...O(t)})}function MC(r,t){return new r({type:"string",format:"ksuid",check:"string_format",abort:!1,...O(t)})}function NC(r,t){return new r({type:"string",format:"ipv4",check:"string_format",abort:!1,...O(t)})}function UC(r,t){return new r({type:"string",format:"ipv6",check:"string_format",abort:!1,...O(t)})}function FC(r,t){return new r({type:"string",format:"cidrv4",check:"string_format",abort:!1,...O(t)})}function HC(r,t){return new r({type:"string",format:"cidrv6",check:"string_format",abort:!1,...O(t)})}function ZC(r,t){return new r({type:"string",format:"base64",check:"string_format",abort:!1,...O(t)})}function WC(r,t){return new r({type:"string",format:"base64url",check:"string_format",abort:!1,...O(t)})}function VC(r,t){return new r({type:"string",format:"e164",check:"string_format",abort:!1,...O(t)})}function BC(r,t){return new r({type:"string",format:"jwt",check:"string_format",abort:!1,...O(t)})}function jC(r,t){return new r({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...O(t)})}function GC(r,t){return new r({type:"string",format:"date",check:"string_format",...O(t)})}function qC(r,t){return new r({type:"string",format:"time",check:"string_format",precision:null,...O(t)})}function YC(r,t){return new r({type:"string",format:"duration",check:"string_format",...O(t)})}function KC(r,t){return new r({type:"number",checks:[],...O(t)})}function JC(r,t){return new r({type:"number",check:"number_format",abort:!1,format:"safeint",...O(t)})}function XC(r,t){return new r({type:"boolean",...O(t)})}function QC(r){return new r({type:"unknown"})}function eR(r,t){return new r({type:"never",...O(t)})}function Qg(r,t){return new eb({check:"less_than",...O(t),value:r,inclusive:!1})}function Nu(r,t){return new eb({check:"less_than",...O(t),value:r,inclusive:!0})}function em(r,t){return new tb({check:"greater_than",...O(t),value:r,inclusive:!1})}function Uu(r,t){return new tb({check:"greater_than",...O(t),value:r,inclusive:!0})}function tm(r,t){return new gI({check:"multiple_of",...O(t),value:r})}function lb(r,t){return new vI({check:"max_length",...O(t),maximum:r})}function Gl(r,t){return new yI({check:"min_length",...O(t),minimum:r})}function cb(r,t){return new bI({check:"length_equals",...O(t),length:r})}function tR(r,t){return new wI({check:"string_format",format:"regex",...O(t),pattern:r})}function rR(r){return new SI({check:"string_format",format:"lowercase",...O(r)})}function nR(r){return new _I({check:"string_format",format:"uppercase",...O(r)})}function iR(r,t){return new kI({check:"string_format",format:"includes",...O(t),includes:r})}function sR(r,t){return new xI({check:"string_format",format:"starts_with",...O(t),prefix:r})}function oR(r,t){return new EI({check:"string_format",format:"ends_with",...O(t),suffix:r})}function $s(r){return new AI({check:"overwrite",tx:r})}function aR(r){return $s(t=>t.normalize(r))}function lR(){return $s(r=>r.trim())}function cR(){return $s(r=>r.toLowerCase())}function uR(){return $s(r=>r.toUpperCase())}function hR(){return $s(r=>w$(r))}function dR(r,t,e){return new r({type:"array",element:t,...O(e)})}function pR(r,t,e){return new r({type:"custom",check:"custom",fn:t,...O(e)})}function fR(r){const t=gR(e=>(e.addIssue=n=>{if(typeof n=="string")e.issues.push(wo(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(wo(i))}},r(e.value,e)));return t}function gR(r,t){const e=new ut({check:"custom",...O(t)});return e._zod.check=r,e}function ub(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)??Ks,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"&&Je(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 hb(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,L=r.external.uri??(V=>V);if(I)return{ref:L(I)};const R=h[1].defId??h[1].schema.id??`schema${r.counter++}`;return h[1].defId=R,{defId:R,ref:`${L("__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
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)}}/**
|
|
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 db(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:ql(t,"input",r.processors),output:ql(t,"output",r.processors)}},enumerable:!1,writable:!1}),u}catch{throw new Error("Error converting schema to JSON.")}}function Je(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 Je(n.element,e);if(n.type==="set")return Je(n.valueType,e);if(n.type==="lazy")return Je(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 Je(n.innerType,e);if(n.type==="intersection")return Je(n.left,e)||Je(n.right,e);if(n.type==="record"||n.type==="map")return Je(n.keyType,e)||Je(n.valueType,e);if(n.type==="pipe")return Je(n.in,e)||Je(n.out,e);if(n.type==="object"){for(const i in n.shape)if(Je(n.shape[i],e))return!0;return!1}if(n.type==="union"){for(const i of n.options)if(Je(i,e))return!0;return!1}if(n.type==="tuple"){for(const i of n.items)if(Je(i,e))return!0;return!!(n.rest&&Je(n.rest,e))}return!1}const mR=(r,t={})=>e=>{const n=ub({...e,processors:t});return Ee(r,n),hb(n,r),db(n,r)},ql=(r,t,e={})=>n=>{const{libraryOptions:i,target:s}=n??{},o=ub({...i??{},target:s,io:t,processors:e});return Ee(r,o),hb(o,r),db(o,r)},vR={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},yR=(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=vR[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}))])}},bR=(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)},wR=(r,t,e,n)=>{e.type="boolean"},SR=(r,t,e,n)=>{e.not={}},_R=(r,t,e,n)=>{},kR=(r,t,e,n)=>{const i=r._zod.def,s=Wy(i.entries);s.every(o=>typeof o=="number")&&(e.type="number"),s.every(o=>typeof o=="string")&&(e.type="string"),e.enum=s},xR=(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},ER=(r,t,e,n)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},AR=(r,t,e,n)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},TR=(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"]})},$R=(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)},IR=(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},CR=(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},RR=(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)}},PR=(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"}]},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},DR=(r,t,e,n)=>{const i=r._zod.def;Ee(i.innerType,t,n);const s=t.seen.get(r);s.ref=i.innerType,e.default=JSON.parse(JSON.stringify(i.defaultValue))},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,t.io==="input"&&(e._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},OR=(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},MR=(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},NR=(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},pb=(r,t,e,n)=>{const i=r._zod.def;Ee(i.innerType,t,n);const s=t.seen.get(r);s.ref=i.innerType},UR=A("ZodISODateTime",(r,t)=>{FI.init(r,t),be.init(r,t)});function FR(r){return jC(UR,r)}const HR=A("ZodISODate",(r,t)=>{HI.init(r,t),be.init(r,t)});function ZR(r){return GC(HR,r)}const WR=A("ZodISOTime",(r,t)=>{ZI.init(r,t),be.init(r,t)});function VR(r){return qC(WR,r)}const BR=A("ZodISODuration",(r,t)=>{WI.init(r,t),be.init(r,t)});function jR(r){return YC(BR,r)}const fb=(r,t)=>{Gy.init(r,t),r.name="ZodError",Object.defineProperties(r,{format:{value:e=>L$(r,e)},flatten:{value:e=>P$(r,e)},addIssue:{value:e=>{r.issues.push(e),r.message=JSON.stringify(r.issues,kh,2)}},addIssues:{value:e=>{r.issues.push(...e),r.message=JSON.stringify(r.issues,kh,2)}},isEmpty:{get(){return r.issues.length===0}}})},rm=A("ZodError",fb),Et=A("ZodError",fb,{Parent:Error}),GR=lp(Et),qR=cp(Et),YR=Pc(Et),KR=Lc(Et),JR=O$(Et),XR=M$(Et),QR=N$(Et),eP=U$(Et),tP=F$(Et),rP=H$(Et),nP=Z$(Et),iP=W$(Et),ye=A("ZodType",(r,t)=>(ve.init(r,t),Object.assign(r["~standard"],{jsonSchema:{input:ql(r,"input"),output:ql(r,"output")}}),r.toJSONSchema=mR(r,{}),r.def=t,r.type=t.type,Object.defineProperty(r,"_def",{value:t}),r.check=(...e)=>r.clone(hn(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)=>dn(r,e,n),r.brand=()=>r,r.register=(e,n)=>(e.add(r,n),r),r.parse=(e,n)=>GR(r,e,n,{callee:r.parse}),r.safeParse=(e,n)=>YR(r,e,n),r.parseAsync=async(e,n)=>qR(r,e,n,{callee:r.parseAsync}),r.safeParseAsync=async(e,n)=>KR(r,e,n),r.spa=r.safeParseAsync,r.encode=(e,n)=>JR(r,e,n),r.decode=(e,n)=>XR(r,e,n),r.encodeAsync=async(e,n)=>QR(r,e,n),r.decodeAsync=async(e,n)=>eP(r,e,n),r.safeEncode=(e,n)=>tP(r,e,n),r.safeDecode=(e,n)=>rP(r,e,n),r.safeEncodeAsync=async(e,n)=>nP(r,e,n),r.safeDecodeAsync=async(e,n)=>iP(r,e,n),r.refine=(e,n)=>r.check(KP(e,n)),r.superRefine=e=>r.check(JP(e)),r.overwrite=e=>r.check($s(e)),r.optional=()=>sm(r),r.exactOptional=()=>MP(r),r.nullable=()=>om(r),r.nullish=()=>sm(om(r)),r.nonoptional=e=>WP(r,e),r.array=()=>z(r),r.or=e=>B([r,e]),r.and=e=>zc(r,e),r.transform=e=>am(r,zP(e)),r.default=e=>FP(r,e),r.prefault=e=>ZP(r,e),r.catch=e=>BP(r,e),r.pipe=e=>am(r,e),r.readonly=()=>qP(r),r.describe=e=>{const n=r.clone();return Ks.add(n,{description:e}),n},Object.defineProperty(r,"description",{get(){var e;return(e=Ks.get(r))==null?void 0:e.description},configurable:!0}),r.meta=(...e)=>{if(e.length===0)return Ks.get(r);const n=r.clone();return Ks.add(n,e[0]),n},r.isOptional=()=>r.safeParse(void 0).success,r.isNullable=()=>r.safeParse(null).success,r.apply=e=>e(r),r)),gb=A("_ZodString",(r,t)=>{up.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(n,i,s)=>yR(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(tR(...n)),r.includes=(...n)=>r.check(iR(...n)),r.startsWith=(...n)=>r.check(sR(...n)),r.endsWith=(...n)=>r.check(oR(...n)),r.min=(...n)=>r.check(Gl(...n)),r.max=(...n)=>r.check(lb(...n)),r.length=(...n)=>r.check(cb(...n)),r.nonempty=(...n)=>r.check(Gl(1,...n)),r.lowercase=n=>r.check(rR(n)),r.uppercase=n=>r.check(nR(n)),r.trim=()=>r.check(lR()),r.normalize=(...n)=>r.check(aR(...n)),r.toLowerCase=()=>r.check(cR()),r.toUpperCase=()=>r.check(uR()),r.slugify=()=>r.check(hR())}),sP=A("ZodString",(r,t)=>{up.init(r,t),gb.init(r,t),r.email=e=>r.check(EC(oP,e)),r.url=e=>r.check(CC(aP,e)),r.jwt=e=>r.check(BC(_P,e)),r.emoji=e=>r.check(RC(lP,e)),r.guid=e=>r.check(Xg(nm,e)),r.uuid=e=>r.check(AC(ll,e)),r.uuidv4=e=>r.check(TC(ll,e)),r.uuidv6=e=>r.check($C(ll,e)),r.uuidv7=e=>r.check(IC(ll,e)),r.nanoid=e=>r.check(PC(cP,e)),r.guid=e=>r.check(Xg(nm,e)),r.cuid=e=>r.check(LC(uP,e)),r.cuid2=e=>r.check(DC(hP,e)),r.ulid=e=>r.check(zC(dP,e)),r.base64=e=>r.check(ZC(bP,e)),r.base64url=e=>r.check(WC(wP,e)),r.xid=e=>r.check(OC(pP,e)),r.ksuid=e=>r.check(MC(fP,e)),r.ipv4=e=>r.check(NC(gP,e)),r.ipv6=e=>r.check(UC(mP,e)),r.cidrv4=e=>r.check(FC(vP,e)),r.cidrv6=e=>r.check(HC(yP,e)),r.e164=e=>r.check(VC(SP,e)),r.datetime=e=>r.check(FR(e)),r.date=e=>r.check(ZR(e)),r.time=e=>r.check(VR(e)),r.duration=e=>r.check(jR(e))});function d(r){return xC(sP,r)}const be=A("ZodStringFormat",(r,t)=>{ge.init(r,t),gb.init(r,t)}),oP=A("ZodEmail",(r,t)=>{RI.init(r,t),be.init(r,t)}),nm=A("ZodGUID",(r,t)=>{II.init(r,t),be.init(r,t)}),ll=A("ZodUUID",(r,t)=>{CI.init(r,t),be.init(r,t)}),aP=A("ZodURL",(r,t)=>{PI.init(r,t),be.init(r,t)}),lP=A("ZodEmoji",(r,t)=>{LI.init(r,t),be.init(r,t)}),cP=A("ZodNanoID",(r,t)=>{DI.init(r,t),be.init(r,t)}),uP=A("ZodCUID",(r,t)=>{zI.init(r,t),be.init(r,t)}),hP=A("ZodCUID2",(r,t)=>{OI.init(r,t),be.init(r,t)}),dP=A("ZodULID",(r,t)=>{MI.init(r,t),be.init(r,t)}),pP=A("ZodXID",(r,t)=>{NI.init(r,t),be.init(r,t)}),fP=A("ZodKSUID",(r,t)=>{UI.init(r,t),be.init(r,t)}),gP=A("ZodIPv4",(r,t)=>{VI.init(r,t),be.init(r,t)}),mP=A("ZodIPv6",(r,t)=>{BI.init(r,t),be.init(r,t)}),vP=A("ZodCIDRv4",(r,t)=>{jI.init(r,t),be.init(r,t)}),yP=A("ZodCIDRv6",(r,t)=>{GI.init(r,t),be.init(r,t)}),bP=A("ZodBase64",(r,t)=>{qI.init(r,t),be.init(r,t)}),wP=A("ZodBase64URL",(r,t)=>{KI.init(r,t),be.init(r,t)}),SP=A("ZodE164",(r,t)=>{JI.init(r,t),be.init(r,t)}),_P=A("ZodJWT",(r,t)=>{QI.init(r,t),be.init(r,t)}),mb=A("ZodNumber",(r,t)=>{nb.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(n,i,s)=>bR(r,n,i),r.gt=(n,i)=>r.check(em(n,i)),r.gte=(n,i)=>r.check(Uu(n,i)),r.min=(n,i)=>r.check(Uu(n,i)),r.lt=(n,i)=>r.check(Qg(n,i)),r.lte=(n,i)=>r.check(Nu(n,i)),r.max=(n,i)=>r.check(Nu(n,i)),r.int=n=>r.check(im(n)),r.safe=n=>r.check(im(n)),r.positive=n=>r.check(em(0,n)),r.nonnegative=n=>r.check(Uu(0,n)),r.negative=n=>r.check(Qg(0,n)),r.nonpositive=n=>r.check(Nu(0,n)),r.multipleOf=(n,i)=>r.check(tm(n,i)),r.step=(n,i)=>r.check(tm(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 Z(r){return KC(mb,r)}const kP=A("ZodNumberFormat",(r,t)=>{eC.init(r,t),mb.init(r,t)});function im(r){return JC(kP,r)}const xP=A("ZodBoolean",(r,t)=>{tC.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(e,n,i)=>wR(r,e,n)});function De(r){return XC(xP,r)}const EP=A("ZodUnknown",(r,t)=>{rC.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(e,n,i)=>_R()});function _(){return QC(EP)}const AP=A("ZodNever",(r,t)=>{nC.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(e,n,i)=>SR(r,e,n)});function TP(r){return eR(AP,r)}const $P=A("ZodArray",(r,t)=>{iC.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(e,n,i)=>TR(r,e,n,i),r.element=t.element,r.min=(e,n)=>r.check(Gl(e,n)),r.nonempty=e=>r.check(Gl(1,e)),r.max=(e,n)=>r.check(lb(e,n)),r.length=(e,n)=>r.check(cb(e,n)),r.unwrap=()=>r.element});function z(r,t){return dR($P,r,t)}const vb=A("ZodObject",(r,t)=>{oC.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(e,n,i)=>$R(r,e,n,i),te(r,"shape",()=>t.shape),r.keyof=()=>wb(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:TP()}),r.strip=()=>r.clone({...r._zod.def,catchall:void 0}),r.extend=e=>T$(r,e),r.safeExtend=e=>$$(r,e),r.merge=e=>I$(r,e),r.pick=e=>E$(r,e),r.omit=e=>A$(r,e),r.partial=(...e)=>C$(Sb,r,e[0]),r.required=(...e)=>R$(_b,r,e[0])});function yb(r,t){const e={type:"object",shape:r??{},...O(t)};return new vb(e)}function v(r,t){return new vb({type:"object",shape:r,catchall:_(),...O(t)})}const bb=A("ZodUnion",(r,t)=>{ob.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(e,n,i)=>IR(r,e,n,i),r.options=t.options});function B(r,t){return new bb({type:"union",options:r,...O(t)})}const IP=A("ZodDiscriminatedUnion",(r,t)=>{bb.init(r,t),aC.init(r,t)});function CP(r,t,e){return new IP({type:"union",options:t,discriminator:r,...O(e)})}const RP=A("ZodIntersection",(r,t)=>{lC.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(e,n,i)=>CR(r,e,n,i)});function zc(r,t){return new RP({type:"intersection",left:r,right:t})}const PP=A("ZodRecord",(r,t)=>{cC.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(e,n,i)=>RR(r,e,n,i),r.keyType=t.keyType,r.valueType=t.valueType});function k(r,t,e){return new PP({type:"record",keyType:r,valueType:t,...O(e)})}const Eh=A("ZodEnum",(r,t)=>{uC.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(n,i,s)=>kR(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 Eh({...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 Eh({...t,checks:[],...O(i),entries:s})}});function wb(r,t){const e=Array.isArray(r)?Object.fromEntries(r.map(n=>[n,n])):r;return new Eh({type:"enum",entries:e,...O(t)})}const LP=A("ZodLiteral",(r,t)=>{hC.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(e,n,i)=>xR(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 LP({type:"literal",values:Array.isArray(r)?r:[r],...O(t)})}const DP=A("ZodTransform",(r,t)=>{dC.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(e,n,i)=>AR(r,e),r._zod.parse=(e,n)=>{if(n.direction==="backward")throw new Hy(r.constructor.name);e.addIssue=s=>{if(typeof s=="string")e.issues.push(wo(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(wo(o))}};const i=t.transform(e.value,e);return i instanceof Promise?i.then(s=>(e.value=s,e)):(e.value=i,e)}});function zP(r){return new DP({type:"transform",transform:r})}const Sb=A("ZodOptional",(r,t)=>{ab.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(e,n,i)=>pb(r,e,n,i),r.unwrap=()=>r._zod.def.innerType});function sm(r){return new Sb({type:"optional",innerType:r})}const OP=A("ZodExactOptional",(r,t)=>{pC.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(e,n,i)=>pb(r,e,n,i),r.unwrap=()=>r._zod.def.innerType});function MP(r){return new OP({type:"optional",innerType:r})}const NP=A("ZodNullable",(r,t)=>{fC.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(e,n,i)=>PR(r,e,n,i),r.unwrap=()=>r._zod.def.innerType});function om(r){return new NP({type:"nullable",innerType:r})}const UP=A("ZodDefault",(r,t)=>{gC.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(e,n,i)=>DR(r,e,n,i),r.unwrap=()=>r._zod.def.innerType,r.removeDefault=r.unwrap});function FP(r,t){return new UP({type:"default",innerType:r,get defaultValue(){return typeof t=="function"?t():By(t)}})}const HP=A("ZodPrefault",(r,t)=>{mC.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 ZP(r,t){return new HP({type:"prefault",innerType:r,get defaultValue(){return typeof t=="function"?t():By(t)}})}const _b=A("ZodNonOptional",(r,t)=>{vC.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(e,n,i)=>LR(r,e,n,i),r.unwrap=()=>r._zod.def.innerType});function WP(r,t){return new _b({type:"nonoptional",innerType:r,...O(t)})}const VP=A("ZodCatch",(r,t)=>{yC.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(e,n,i)=>OR(r,e,n,i),r.unwrap=()=>r._zod.def.innerType,r.removeCatch=r.unwrap});function BP(r,t){return new VP({type:"catch",innerType:r,catchValue:typeof t=="function"?t:()=>t})}const jP=A("ZodPipe",(r,t)=>{bC.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(e,n,i)=>MR(r,e,n,i),r.in=t.in,r.out=t.out});function am(r,t){return new jP({type:"pipe",in:r,out:t})}const GP=A("ZodReadonly",(r,t)=>{wC.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(e,n,i)=>NR(r,e,n,i),r.unwrap=()=>r._zod.def.innerType});function qP(r){return new GP({type:"readonly",innerType:r})}const YP=A("ZodCustom",(r,t)=>{SC.init(r,t),ye.init(r,t),r._zod.processJSONSchema=(e,n,i)=>ER(r,e)});function KP(r,t={}){return pR(YP,r,t)}function JP(r){return fR(r)}const XP=[".md",".markdown"];function kb(r){if(r.length===0)return!1;const t=r.at(-1);return t==="/"||t==="\\"}function xb(r){const t=r.lastIndexOf("/"),e=r.lastIndexOf("\\");return r.slice(Math.max(t,e)+1)}function QP(r){return xb(r).toLowerCase()}function eL(r,t){const e=QP(r);return t.some(n=>e.endsWith(n))}function Eb(r){return!kb(r)&&eL(r,XP)}function tL(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 rL=yb({id:d().min(1),kind:T("path"),title:d(),path:d()}).strict(),nL=yb({id:d().min(1),kind:T("url"),title:d(),url:d().refine(tL,{message:"url must be an http(s) URL"})}).strict();CP("kind",[rL,nL]);function Ab(r){return typeof r=="object"&&r!==null}function Tb(r){return!Ab(r)||r.type!=="ready"?!1:!("id"in r)}function $b(r){return!(!Ab(r)||r.type!=="update-content"||typeof r.id!="string"||typeof r.content!="string")}const iL="/views/markdown/",sL="/views/url-unsupported/";function Ib(r){return`/artifact/${encodeURIComponent(r)}`}function oL(r,t){return`${Ib(r)}/${encodeURIComponent(t)}`}function aL(r){return`/markdown/${encodeURIComponent(r)}`}function Yl(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:sL,contentURL:null};if(Eb(r.path)){const n={viewURL:iL,contentURL:aL(r.id)};return t.electron?{renderer:"url-webview",...n}:{renderer:"markdown",...n}}const e=kb(r.path)?`${Ib(r.id)}/`:oL(r.id,xb(r.path));return t.electron?{renderer:"url-webview",viewURL:e,contentURL:null}:{renderer:"proxy-iframe",viewURL:e,contentURL:null}}const lL="serverURL",cL="token",uL="mode",hL="desktopAppVersion",dL="electron";function Cb(r=window.location.search,t=window.location.origin){const n=new URLSearchParams(r).get(lL);return n?new URL(n).origin:new URL(t).origin}function pL(r=window.location.search){return new URLSearchParams(r).get(cL)}function cr(r=typeof window>"u"?"":window.location.search){return new URLSearchParams(r).get(uL)===dL}function fL(r=typeof window>"u"?"":window.location.search){return new URLSearchParams(r).get(hL)}const lm="tv.telemetry.clientId",gL=5,mL=60,vL=1e3,yL=gL*mL*vL,cm=["pointerdown","scroll","keydown"],um=["focus"],hm=["visibilitychange"],bL="hidden";function wL(r,t=EL){const e=r.getItem(lm);if(e)return e;const n=t();return r.setItem(lm,n),n}function SL(r){return{clientId:wL(r.storage,r.idFactory),userAgent:r.userAgent??(typeof navigator>"u"?"":navigator.userAgent),clientApp:r.clientApp,...r.desktopAppVersion?{desktopAppVersion:r.desktopAppVersion}:{}}}function _L(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 kL(r){return new xL(r)}var Ro,kr,Vr,Po,Lo,gt,Mn,Do,sc,Rb;class xL{constructor(t){w(this,sc);w(this,Ro);w(this,kr);w(this,Vr);w(this,Po);w(this,Lo);w(this,gt);w(this,Mn,!1);w(this,Do,Number.NEGATIVE_INFINITY);b(this,Ro,t.meta),b(this,kr,t.documentTarget),b(this,Vr,t.windowTarget),b(this,Po,t.send),b(this,Lo,t.nowMs??Date.now),b(this,gt,()=>p(this,sc,Rb).call(this))}start(){if(!l(this,Mn)){b(this,Mn,!0);for(const t of cm)l(this,Vr).addEventListener(t,l(this,gt)),l(this,kr).addEventListener(t,l(this,gt));for(const t of um)l(this,Vr).addEventListener(t,l(this,gt));for(const t of hm)l(this,kr).addEventListener(t,l(this,gt))}}stop(){if(l(this,Mn)){b(this,Mn,!1);for(const t of cm)l(this,Vr).removeEventListener(t,l(this,gt)),l(this,kr).removeEventListener(t,l(this,gt));for(const t of um)l(this,Vr).removeEventListener(t,l(this,gt));for(const t of hm)l(this,kr).removeEventListener(t,l(this,gt))}}}Ro=new WeakMap,kr=new WeakMap,Vr=new WeakMap,Po=new WeakMap,Lo=new WeakMap,gt=new WeakMap,Mn=new WeakMap,Do=new WeakMap,sc=new WeakSet,Rb=function(){if(l(this,kr).visibilityState===bL)return;const t=l(this,Lo).call(this);t-l(this,Do)<yL||(b(this,Do,t),l(this,Po).call(this,{type:zT,clientId:l(this,Ro).clientId}))};function EL(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():Cc().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"},AL=1,TL=v({_meta:k(d(),_()).nullish(),terminal:De().optional().default(!1)}),$L=v({_meta:k(d(),_()).nullish(),label:d().nullish(),name:d(),optional:De().optional().default(!1),secret:De().optional().default(!0)}),IL=v({_meta:k(d(),_()).nullish(),description:d().nullish(),id:d(),name:d()}),CL=v({_meta:k(d(),_()).nullish(),description:d().nullish(),id:d(),link:d().nullish(),name:d(),vars:z($L)}),RL=v({_meta:k(d(),_()).nullish(),args:z(d()).optional(),description:d().nullish(),env:k(d(),d()).optional(),id:d(),name:d()}),PL=B([CL.and(v({type:T("env_var")})),RL.and(v({type:T("terminal")})),IL]),LL=v({_meta:k(d(),_()).nullish(),methodId:d()}),DL=v({_meta:k(d(),_()).nullish()}),zL=v({_meta:k(d(),_()).nullish(),blob:d(),mimeType:d().nullish(),uri:d()}),OL=v({default:De().nullish(),description:d().nullish(),title:d().nullish()}),ML=v({_meta:k(d(),_()).nullish()}),NL=v({_meta:k(d(),_()).nullish()}),UL=v({amount:Z(),currency:d()}),FL=v({_meta:k(d(),_()).nullish(),terminalId:d()}),HL=v({_meta:k(d(),_()).nullish(),newText:d(),oldText:d().nullish(),path:d()}),ZL=B([d(),Z(),Z(),De(),z(d())]),WL=v({content:k(d(),ZL).nullish()}),VL=B([WL.and(v({action:T("accept")})),v({action:T("decline")}),v({action:T("cancel")})]),BL=v({_meta:k(d(),_()).nullish()}),Pb=d(),jL=v({_meta:k(d(),_()).nullish(),elicitationId:Pb}),GL=v({_meta:k(d(),_()).nullish(),action:VL}),qL=T("object"),YL=T("string"),KL=v({_meta:k(d(),_()).nullish()}),JL=v({_meta:k(d(),_()).nullish(),form:BL.nullish(),url:KL.nullish()}),XL=v({elicitationId:Pb,url:d().url()}),Lb=v({const:d(),title:d()}),Db=v({_meta:k(d(),_()).nullish(),name:d(),value:d()}),QL=B([T(-32700),T(-32600),T(-32601),T(-32602),T(-32603),T(-32800),T(-32e3),T(-32002),T(-32042),Z().int().min(-2147483648,{message:"Invalid value: Expected int32 to be >= -2147483648"}).max(2147483647,{message:"Invalid value: Expected int32 to be <= 2147483647"})]),zb=v({code:QL,data:_().optional(),message:d()}),Ob=_(),Mb=_(),Nb=_(),eD=v({_meta:k(d(),_()).nullish(),readTextFile:De().optional().default(!1),writeTextFile:De().optional().default(!1)}),Ub=v({_meta:k(d(),_()).nullish(),name:d(),value:d()}),Fb=v({_meta:k(d(),_()).nullish(),name:d(),title:d().nullish(),version:d()}),tD=v({default:Z().nullish(),description:d().nullish(),maximum:Z().nullish(),minimum:Z().nullish(),title:d().nullish()}),rD=v({_meta:k(d(),_()).nullish()}),nD=v({_meta:k(d(),_()).nullish(),additionalDirectories:z(d()).optional(),cursor:d().nullish(),cwd:d().nullish()}),iD=v({_meta:k(d(),_()).nullish()}),sD=v({_meta:k(d(),_()).nullish(),logout:iD.nullish()}),oD=v({_meta:k(d(),_()).nullish()}),aD=v({_meta:k(d(),_()).nullish()}),lD=v({_meta:k(d(),_()).nullish(),http:De().optional().default(!1),sse:De().optional().default(!1)}),cD=v({_meta:k(d(),_()).nullish(),headers:z(Ub),name:d(),url:d()}),uD=v({_meta:k(d(),_()).nullish(),headers:z(Ub),name:d(),url:d()}),hD=v({_meta:k(d(),_()).nullish(),args:z(d()),command:d(),env:z(Db),name:d()}),Oc=B([cD.and(v({type:T("http")})),uD.and(v({type:T("sse")})),hD]),hp=d(),dD=v({_meta:k(d(),_()).nullish(),description:d().nullish(),modelId:hp,name:d()}),pD=B([T("error"),T("warning"),T("information"),T("hint")]),fD=v({_meta:k(d(),_()).nullish()}),gD=v({_meta:k(d(),_()).nullish()}),mD=v({_meta:k(d(),_()).nullish()}),vD=v({_meta:k(d(),_()).nullish()}),yD=v({_meta:k(d(),_()).nullish()}),bD=v({_meta:k(d(),_()).nullish(),maxCount:Z().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),wD=v({diff:d(),uri:d()}),SD=v({endLine:Z().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),startLine:Z().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),text:d()}),_D=v({_meta:k(d(),_()).nullish()}),kD=v({_meta:k(d(),_()).nullish()}),xD=v({languageId:d(),text:d(),uri:d()}),ED=v({_meta:k(d(),_()).nullish(),maxCount:Z().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),AD=B([T("rejected"),T("ignored"),T("replaced"),T("cancelled")]),TD=v({excerpts:z(SD),uri:d()}),$D=v({_meta:k(d(),_()).nullish()}),ID=v({_meta:k(d(),_()).nullish()}),CD=v({name:d(),owner:d(),remoteUrl:d()}),RD=v({_meta:k(d(),_()).nullish()}),PD=v({_meta:k(d(),_()).nullish(),jump:_D.nullish(),rename:ID.nullish(),searchAndReplace:RD.nullish()}),LD=v({id:d(),isRegex:De().nullish(),replace:d(),search:d(),uri:d()}),DD=B([T("automatic"),T("diagnostic"),T("manual")]),zD=v({_meta:k(d(),_()).nullish(),maxCount:Z().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),OD=v({_meta:k(d(),_()).nullish(),diagnostics:fD.nullish(),editHistory:bD.nullish(),openFiles:kD.nullish(),recentFiles:ED.nullish(),relatedSnippets:$D.nullish(),userActions:zD.nullish()}),MD=v({_meta:k(d(),_()).nullish(),additionalDirectories:z(d()).optional(),cwd:d(),mcpServers:z(Oc)}),ND=v({default:Z().nullish(),description:d().nullish(),maximum:Z().nullish(),minimum:Z().nullish(),title:d().nullish()}),Hb=d(),UD=B([T("allow_once"),T("allow_always"),T("reject_once"),T("reject_always")]),FD=v({_meta:k(d(),_()).nullish(),kind:UD,name:d(),optionId:Hb}),HD=B([T("high"),T("medium"),T("low")]),ZD=B([T("pending"),T("in_progress"),T("completed")]),WD=v({_meta:k(d(),_()).nullish(),content:d(),priority:HD,status:ZD}),VD=v({_meta:k(d(),_()).nullish(),entries:z(WD)}),an=v({character:Z().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),line:Z().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"})}),BD=v({id:d(),position:an,uri:d()}),jD=v({id:d(),newName:d(),position:an,uri:d()}),GD=v({action:d(),position:an,timestampMs:Z(),uri:d()}),Zb=B([T("utf-16"),T("utf-32"),T("utf-8")]),qD=v({_meta:k(d(),_()).nullish(),auth:TL.optional().default({terminal:!1}),elicitation:JL.nullish(),fs:eD.optional().default({readTextFile:!1,writeTextFile:!1}),nes:PD.nullish(),positionEncodings:z(Zb).optional(),terminal:De().optional().default(!1)}),YD=v({_meta:k(d(),_()).nullish(),audio:De().optional().default(!1),embeddedContext:De().optional().default(!1),image:De().optional().default(!1)}),Wb=Z().int().gte(0).lte(65535),KD=v({_meta:k(d(),_()).nullish(),clientCapabilities:qD.optional().default({auth:{terminal:!1},fs:{readTextFile:!1,writeTextFile:!1},terminal:!1}),clientInfo:Fb.nullish(),protocolVersion:Wb}),Is=v({end:an,start:an}),JD=v({message:d(),range:Is,severity:pD,uri:d()}),XD=v({languageId:d(),lastFocusedMs:Z().nullish(),uri:d(),visibleRange:Is.nullish()}),QD=v({_meta:k(d(),_()).nullish(),diagnostics:z(JD).nullish(),editHistory:z(wD).nullish(),openFiles:z(XD).nullish(),recentFiles:z(xD).nullish(),relatedSnippets:z(TD).nullish(),userActions:z(GD).nullish()}),e2=v({newText:d(),range:Is}),t2=v({cursorPosition:an.nullish(),edits:z(e2),id:d(),uri:d()}),r2=B([t2.and(v({kind:T("edit")})),BD.and(v({kind:T("jump")})),jD.and(v({kind:T("rename")})),LD.and(v({kind:T("searchAndReplace")}))]),n2=v({_meta:k(d(),_()).nullish(),content:d()}),i2=v({_meta:k(d(),_()).nullish()}),ei=B([Z(),d()]).nullable();v({_meta:k(d(),_()).nullish(),requestId:ei});const s2=wb(["assistant","user"]),Na=v({_meta:k(d(),_()).nullish(),audience:z(s2).nullish(),lastModified:d().nullish(),priority:Z().nullish()}),o2=v({_meta:k(d(),_()).nullish(),annotations:Na.nullish(),data:d(),mimeType:d()}),a2=v({_meta:k(d(),_()).nullish(),annotations:Na.nullish(),data:d(),mimeType:d(),uri:d().nullish()}),l2=v({_meta:k(d(),_()).nullish(),annotations:Na.nullish(),description:d().nullish(),mimeType:d().nullish(),name:d(),size:Z().nullish(),title:d().nullish(),uri:d()}),c2=v({_meta:k(d(),_()).nullish(),optionId:Hb}),u2=B([v({outcome:T("cancelled")}),c2.and(v({outcome:T("selected")}))]),h2=v({_meta:k(d(),_()).nullish(),outcome:u2}),d2=v({_meta:k(d(),_()).nullish()}),p2=v({_meta:k(d(),_()).nullish()}),f2=v({currentValue:De()}),g2=d(),Vb=d(),m2=B([T("mode"),T("model"),T("thought_level"),d()]),dp=d(),Bb=v({_meta:k(d(),_()).nullish(),description:d().nullish(),name:d(),value:dp}),v2=v({_meta:k(d(),_()).nullish(),group:g2,name:d(),options:z(Bb)}),y2=B([z(Bb),z(v2)]),b2=v({currentValue:dp,options:y2}),Cs=zc(B([b2.and(v({type:T("select")})),f2.and(v({type:T("boolean")}))]),v({_meta:k(d(),_()).nullish(),category:m2.nullish(),description:d().nullish(),id:Vb,name:d()})),w2=v({_meta:k(d(),_()).nullish(),configOptions:z(Cs)}),S2=v({_meta:k(d(),_()).nullish()}),Q=d(),_2=v({_meta:k(d(),_()).nullish(),id:d(),sessionId:Q}),k2=v({_meta:k(d(),_()).nullish(),sessionId:Q}),x2=v({_meta:k(d(),_()).nullish(),sessionId:Q}),E2=v({_meta:k(d(),_()).nullish(),sessionId:Q}),jb=v({_meta:k(d(),_()).nullish(),args:z(d()).optional(),command:d(),cwd:d().nullish(),env:z(Db).optional(),outputByteLimit:Z().nullish(),sessionId:Q}),A2=v({_meta:k(d(),_()).nullish(),sessionId:Q,uri:d()}),T2=v({_meta:k(d(),_()).nullish(),position:an,sessionId:Q,uri:d(),version:Z(),visibleRange:Is}),$2=v({_meta:k(d(),_()).nullish(),languageId:d(),sessionId:Q,text:d(),uri:d(),version:Z()}),I2=v({_meta:k(d(),_()).nullish(),sessionId:Q,uri:d()}),C2=v({_meta:k(d(),_()).nullish(),additionalDirectories:z(d()).optional(),cwd:d(),mcpServers:z(Oc).optional(),sessionId:Q}),Gb=v({_meta:k(d(),_()).nullish(),sessionId:Q,terminalId:d()}),R2=v({_meta:k(d(),_()).nullish(),additionalDirectories:z(d()).optional(),cwd:d(),mcpServers:z(Oc),sessionId:Q}),qb=v({_meta:k(d(),_()).nullish(),limit:Z().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),line:Z().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:d(),sessionId:Q}),P2=v({_meta:k(d(),_()).nullish(),id:d(),reason:AD.nullish(),sessionId:Q}),Yb=v({_meta:k(d(),_()).nullish(),sessionId:Q,terminalId:d()}),L2=v({_meta:k(d(),_()).nullish(),additionalDirectories:z(d()).optional(),cwd:d(),mcpServers:z(Oc).optional(),sessionId:Q}),D2=v({_meta:k(d(),_()).nullish(),additionalDirectories:z(d()).optional(),cwd:d(),sessionId:Q,title:d().nullish(),updatedAt:d().nullish()}),z2=v({_meta:k(d(),_()).nullish(),nextCursor:d().nullish(),sessions:z(D2)}),O2=v({_meta:k(d(),_()).nullish(),title:d().nullish(),updatedAt:d().nullish()}),M2=v({_meta:k(d(),_()).nullish()}),Mc=d(),N2=v({_meta:k(d(),_()).nullish(),currentModeId:Mc}),U2=v({_meta:k(d(),_()).nullish(),description:d().nullish(),id:Mc,name:d()}),Nc=v({_meta:k(d(),_()).nullish(),availableModes:z(U2),currentModeId:Mc}),Uc=v({_meta:k(d(),_()).nullish(),availableModels:z(dD),currentModelId:hp}),F2=v({_meta:k(d(),_()).nullish(),configOptions:z(Cs).nullish(),models:Uc.nullish(),modes:Nc.nullish(),sessionId:Q}),H2=v({_meta:k(d(),_()).nullish(),configOptions:z(Cs).nullish(),models:Uc.nullish(),modes:Nc.nullish()}),Z2=v({_meta:k(d(),_()).nullish(),configOptions:z(Cs).nullish(),models:Uc.nullish(),modes:Nc.nullish(),sessionId:Q}),W2=v({_meta:k(d(),_()).nullish(),configOptions:z(Cs).nullish(),models:Uc.nullish(),modes:Nc.nullish()}),V2=v({_meta:k(d(),_()).nullish()}),B2=v({_meta:k(d(),_()).nullish(),additionalDirectories:d2.nullish(),close:p2.nullish(),fork:S2.nullish(),list:M2.nullish(),resume:V2.nullish()}),j2=zc(B([v({type:T("boolean"),value:De()}),v({value:dp})]),v({_meta:k(d(),_()).nullish(),configId:Vb,sessionId:Q})),G2=v({_meta:k(d(),_()).nullish(),configOptions:z(Cs)}),q2=v({_meta:k(d(),_()).nullish(),modeId:Mc,sessionId:Q}),Y2=v({_meta:k(d(),_()).nullish()}),K2=v({_meta:k(d(),_()).nullish(),modelId:hp,sessionId:Q}),J2=v({_meta:k(d(),_()).nullish()}),X2=v({_meta:k(d(),_()).nullish(),sessionId:Q}),Q2=B([T("end_turn"),T("max_tokens"),T("max_turn_requests"),T("refusal"),T("cancelled")]),ez=B([T("email"),T("uri"),T("date"),T("date-time")]),tz=v({default:d().nullish(),description:d().nullish(),enum:z(d()).nullish(),format:ez.nullish(),maxLength:Z().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),minLength:Z().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),oneOf:z(Lb).nullish(),pattern:d().nullish(),title:d().nullish()}),rz=v({_meta:k(d(),_()).nullish(),context:QD.nullish(),position:an,selection:Is.nullish(),sessionId:Q,triggerKind:DD,uri:d(),version:Z()}),nz=v({_meta:k(d(),_()).nullish(),suggestions:z(r2)}),iz=v({_meta:k(d(),_()).nullish(),terminalId:d()}),sz=v({_meta:k(d(),_()).nullish(),exitCode:Z().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:d().nullish()}),Kb=v({_meta:k(d(),_()).nullish(),sessionId:Q,terminalId:d()}),oz=v({_meta:k(d(),_()).nullish(),exitStatus:sz.nullish(),output:d(),truncated:De()}),az=v({_meta:k(d(),_()).nullish(),annotations:Na.nullish(),text:d()}),lz=v({range:Is.nullish(),text:d()}),cz=v({_meta:k(d(),_()).nullish(),contentChanges:z(lz),sessionId:Q,uri:d(),version:Z()});v({method:d(),params:B([k2,$2,cz,A2,I2,T2,_2,P2,Ob]).nullish()});const uz=B([T("full"),T("incremental")]),hz=v({_meta:k(d(),_()).nullish(),syncKind:uz}),dz=v({_meta:k(d(),_()).nullish(),didChange:hz.nullish(),didClose:gD.nullish(),didFocus:mD.nullish(),didOpen:vD.nullish(),didSave:yD.nullish()}),pz=v({_meta:k(d(),_()).nullish(),document:dz.nullish()}),fz=v({_meta:k(d(),_()).nullish(),context:OD.nullish(),events:pz.nullish()}),gz=v({_meta:k(d(),_()).nullish(),auth:sD.optional().default({}),loadSession:De().optional().default(!1),mcpCapabilities:lD.optional().default({http:!1,sse:!1}),nes:fz.nullish(),positionEncoding:Zb.nullish(),promptCapabilities:YD.optional().default({audio:!1,embeddedContext:!1,image:!1}),sessionCapabilities:B2.optional().default({})}),mz=v({_meta:k(d(),_()).nullish(),agentCapabilities:gz.optional().default({auth:{},loadSession:!1,mcpCapabilities:{http:!1,sse:!1},promptCapabilities:{audio:!1,embeddedContext:!1,image:!1},sessionCapabilities:{}}),agentInfo:Fb.nullish(),authMethods:z(PL).optional().default([]),protocolVersion:Wb}),vz=v({_meta:k(d(),_()).nullish(),mimeType:d().nullish(),text:d(),uri:d()}),yz=B([vz,zL]),bz=v({_meta:k(d(),_()).nullish(),annotations:Na.nullish(),resource:yz}),pp=B([az.and(v({type:T("text")})),a2.and(v({type:T("image")})),o2.and(v({type:T("audio")})),l2.and(v({type:T("resource_link")})),bz.and(v({type:T("resource")}))]),wz=v({_meta:k(d(),_()).nullish(),content:pp}),Fu=v({_meta:k(d(),_()).nullish(),content:pp,messageId:d().nullish()}),Sz=v({_meta:k(d(),_()).nullish(),messageId:d().nullish(),prompt:z(pp),sessionId:Q}),_z=v({anyOf:z(Lb)}),Jb=B([wz.and(v({type:T("content")})),HL.and(v({type:T("diff")})),iz.and(v({type:T("terminal")}))]),Xb=d(),Qb=v({_meta:k(d(),_()).nullish(),line:Z().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:d()}),ew=B([T("pending"),T("in_progress"),T("completed"),T("failed")]),tw=B([T("read"),T("edit"),T("delete"),T("move"),T("search"),T("execute"),T("think"),T("fetch"),T("switch_mode"),T("other")]),kz=v({_meta:k(d(),_()).nullish(),content:z(Jb).optional(),kind:tw.optional(),locations:z(Qb).optional(),rawInput:_().optional(),rawOutput:_().optional(),status:ew.optional(),title:d(),toolCallId:Xb}),rw=v({_meta:k(d(),_()).nullish(),content:z(Jb).nullish(),kind:tw.nullish(),locations:z(Qb).nullish(),rawInput:_().optional(),rawOutput:_().optional(),status:ew.nullish(),title:d().nullish(),toolCallId:Xb}),nw=v({_meta:k(d(),_()).nullish(),options:z(FD),sessionId:Q,toolCall:rw}),xz=v({_meta:k(d(),_()).nullish(),hint:d()}),Ez=xz,Az=v({_meta:k(d(),_()).nullish(),description:d(),input:Ez.nullish(),name:d()}),Tz=v({_meta:k(d(),_()).nullish(),availableCommands:z(Az)}),$z=v({enum:z(d()),type:YL}),Iz=B([$z,_z]),Cz=v({default:z(d()).nullish(),description:d().nullish(),items:Iz,maxItems:Z().nullish(),minItems:Z().nullish(),title:d().nullish()}),Rz=B([tz.and(v({type:T("string")})),ND.and(v({type:T("number")})),tD.and(v({type:T("integer")})),OL.and(v({type:T("boolean")})),Cz.and(v({type:T("array")}))]),Pz=v({description:d().nullish(),properties:k(d(),Rz).optional().default({}),required:z(d()).nullish(),title:d().nullish(),type:qL.optional().default("object")}),Lz=v({requestedSchema:Pz}),Dz=zc(B([Lz.and(v({mode:T("form")})),XL.and(v({mode:T("url")}))]),v({_meta:k(d(),_()).nullish(),message:d(),sessionId:Q})),zz=v({cachedReadTokens:Z().nullish(),cachedWriteTokens:Z().nullish(),inputTokens:Z(),outputTokens:Z(),thoughtTokens:Z().nullish(),totalTokens:Z()}),Oz=v({_meta:k(d(),_()).nullish(),stopReason:Q2,usage:zz.nullish(),userMessageId:d().nullish()});B([v({id:ei,result:B([mz,DL,aD,Z2,H2,z2,F2,W2,NL,Y2,G2,Oz,J2,X2,nz,ML,Nb])}),v({error:zb,id:ei})]);const Mz=v({_meta:k(d(),_()).nullish(),cost:UL.nullish(),size:Z(),used:Z()}),Nz=B([Fu.and(v({sessionUpdate:T("user_message_chunk")})),Fu.and(v({sessionUpdate:T("agent_message_chunk")})),Fu.and(v({sessionUpdate:T("agent_thought_chunk")})),kz.and(v({sessionUpdate:T("tool_call")})),rw.and(v({sessionUpdate:T("tool_call_update")})),VD.and(v({sessionUpdate:T("plan")})),Tz.and(v({sessionUpdate:T("available_commands_update")})),N2.and(v({sessionUpdate:T("current_mode_update")})),w2.and(v({sessionUpdate:T("config_option_update")})),O2.and(v({sessionUpdate:T("session_info_update")})),Mz.and(v({sessionUpdate:T("usage_update")}))]),iw=v({_meta:k(d(),_()).nullish(),sessionId:Q,update:Nz});v({method:d(),params:B([iw,jL,Ob]).nullish()});const sw=v({_meta:k(d(),_()).nullish(),sessionId:Q,terminalId:d()}),Uz=v({_meta:k(d(),_()).nullish(),exitCode:Z().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:d().nullish()}),Fz=v({name:d(),uri:d()}),Hz=v({_meta:k(d(),_()).nullish(),repository:CD.nullish(),workspaceFolders:z(Fz).nullish(),workspaceUri:d().nullish()});v({id:ei,method:d(),params:B([KD,LL,oD,MD,R2,nD,C2,L2,E2,q2,j2,Sz,K2,Hz,rz,x2,Mb]).nullish()});const ow=v({_meta:k(d(),_()).nullish(),content:d(),path:d(),sessionId:Q});v({id:ei,method:d(),params:B([ow,qb,nw,jb,Kb,Yb,sw,Gb,Dz,Mb]).nullish()});const Zz=v({_meta:k(d(),_()).nullish()});B([v({id:ei,result:B([Zz,n2,h2,FL,oz,i2,Uz,rD,GL,Nb])}),v({error:zb,id:ei})]);var X;class Wz{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=ow.parse(a);return(c=n.writeTextFile)==null?void 0:c.call(n,x)}case mr.fs_read_text_file:{const x=qb.parse(a);return(u=n.readTextFile)==null?void 0:u.call(n,x)}case mr.session_request_permission:{const x=nw.parse(a);return n.requestPermission(x)}case mr.terminal_create:{const x=jb.parse(a);return(h=n.createTerminal)==null?void 0:h.call(n,x)}case mr.terminal_output:{const x=Kb.parse(a);return(f=n.terminalOutput)==null?void 0:f.call(n,x)}case mr.terminal_release:{const x=Yb.parse(a);return await((y=n.releaseTerminal)==null?void 0:y.call(n,x))??{}}case mr.terminal_wait_for_exit:{const x=sw.parse(a);return(m=n.waitForTerminalExit)==null?void 0:m.call(n,x)}case mr.terminal_kill:{const x=Gb.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=iw.parse(a);return n.sessionUpdate(c)}default:if(n.extNotification)return n.extNotification(o,a);throw Ce.methodNotFound(o)}};b(this,X,new Vz(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 Br,oc,zo,Oo,Zi,Wi,qt,Mo,me,aw,Ah,lw,cw,uw,hw,Th,Js;class Vz{constructor(t,e,n){w(this,me);w(this,Br,new Map);w(this,oc,0);w(this,zo);w(this,Oo);w(this,Zi);w(this,Wi,Promise.resolve());w(this,qt,new AbortController);w(this,Mo);b(this,zo,t),b(this,Oo,e),b(this,Zi,n),b(this,Mo,new Promise(i=>{l(this,qt).signal.addEventListener("abort",()=>i())})),p(this,me,aw).call(this)}get signal(){return l(this,qt).signal}get closed(){return l(this,Mo)}async sendRequest(t,e){p(this,me,Th).call(this);const n=iu(this,oc)._++,i=new Promise((s,o)=>{l(this,Br).set(n,{resolve:s,reject:o})});return await p(this,me,Js).call(this,{jsonrpc:"2.0",id:n,method:t,params:e}),i}async sendNotification(t,e){p(this,me,Th).call(this),await p(this,me,Js).call(this,{jsonrpc:"2.0",method:t,params:e})}}Br=new WeakMap,oc=new WeakMap,zo=new WeakMap,Oo=new WeakMap,Zi=new WeakMap,Wi=new WeakMap,qt=new WeakMap,Mo=new WeakMap,me=new WeakSet,aw=async function(){let t;try{const e=l(this,Zi).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,lw).call(this,n)}catch(s){console.error("Unexpected error during message processing:",n,s),"id"in n&&n.id!==void 0&&p(this,me,Js).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,Ah).call(this,t)}},Ah=function(t){if(l(this,qt).signal.aborted)return;const e=t??new Error("ACP connection closed");for(const n of l(this,Br).values())n.reject(e);l(this,Br).clear(),l(this,qt).abort(e)},lw=async function(t){if("method"in t&&"id"in t){const e=await p(this,me,cw).call(this,t.method,t.params);"error"in e&&console.error("Error handling request",t,e.error),await p(this,me,Js).call(this,{jsonrpc:"2.0",id:t.id,...e})}else if("method"in t){const e=await p(this,me,uw).call(this,t.method,t.params);"error"in e&&console.error("Error handling notification",t,e.error)}else"id"in t?p(this,me,hw).call(this,t):console.error("Invalid message",{message:t})},cw=async function(t,e){try{return{result:await l(this,zo).call(this,t,e)??null}}catch(n){if(n instanceof Ce)return n.toResult();if(n instanceof rm)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()}}},uw=async function(t,e){try{return await l(this,Oo).call(this,t,e),{result:null}}catch(n){if(n instanceof Ce)return n.toResult();if(n instanceof rm)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()}}},hw=function(t){const e=l(this,Br).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,Br).delete(t.id)}else console.error("Got response to unknown request",t.id)},Th=function(){if(l(this,qt).signal.aborted)throw l(this,qt).signal.reason??new Error("ACP connection closed")},Js=async function(t){return b(this,Wi,l(this,Wi).then(async()=>{const e=l(this,Zi).writable.getWriter();try{await e.write(t)}finally{e.releaseLock()}}).catch(e=>{p(this,me,Ah).call(this,e)})),l(this,Wi)};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 Bz=/^Sender \(untrusted metadata\):\n```json\n[\s\S]*?\n```\n\n?/,jz=/^\[[^\n]*Working directory:[^\n]*\]\n\n?/,Gz=/\[Television screen context\][\s\S]*?\[\/Television screen context\]\n*/,qz=/\b(tv|television|screen|artifact|artifacts|viewer|filmstrip|layout|focus)\b/i,Yz=/\[\[\s*(?:reply_to_current|reply_to\s*:\s*[^\]\n]+|audio_as_voice)\s*\]\]\s*/gi,Kz="single_session",Jz={name:"television-acp-client",version:"0.0.0"},dw="agent:main:television",Xz=Ma(Nt);var Vi,Yt,dt,Kt,jr,It,xr,Jt,Xt,Gr,Ct,Bi,ji,Qt,Xe,Er,Gi,Nn,Ar,qr,No,Rt,er,ac,tr,$,$h,pw,fw,gw,xl,mw,vw,yw,bw,ww,Sw,_w,_n,Ei,Ai,yr,kw,Ti,Ih,Ch,El,xw,Al,Rh,Ph,Uo,Fo,Tl,$i,Lh,Ew;class Qz extends Xz{constructor(e){super();w(this,$);w(this,Vi,"disconnected");w(this,Yt,null);w(this,dt,new Map);w(this,Kt,null);w(this,jr,null);w(this,It,null);w(this,xr,null);w(this,Jt,null);w(this,Xt,null);w(this,Gr);w(this,Ct,null);w(this,Bi,0);w(this,ji,1);w(this,Qt,null);w(this,Xe,null);w(this,Er,!1);w(this,Gi,!1);w(this,Nn,!1);w(this,Ar,null);w(this,qr,new Set);w(this,No);w(this,Rt);w(this,er);w(this,ac,e=>{p(this,$,fw).call(this,e)});w(this,tr,null);w(this,Uo,()=>{p(this,$,$i).call(this,"ACP bridge websocket closed")});w(this,Fo,()=>{p(this,$,$i).call(this,"ACP bridge websocket error")});b(this,Rt,e),b(this,er,e.sessionMode??Kz),b(this,Gr,e.mappedSessionStore??eO()),b(this,No,e.createSocket??(n=>new WebSocket(n)))}get status(){return l(this,Vi)}get messages(){return[...l(this,dt).values()]}get enabled(){return l(this,Rt).enabled??!1}setToken(e){l(this,Rt).token=e??""}setEnabled(e){l(this,Rt).enabled=e,e||(p(this,$,Tl).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,jr)===null&&(b(this,Yt,null),b(this,jr,p(this,$,pw).call(this)));try{await l(this,jr),await p(this,$,xl).call(this)}catch(e){throw p(this,$,$i).call(this,Hu(e)),e}}}dispose(){p(this,$,Tl).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,Ct)!==p(this,$,Al).call(this))&&await p(this,$,xl).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,$,Ei).call(this,{id:p(this,$,Ti).call(this,"user"),kind:"user",text:n,status:"final"}),p(this,$,yr).call(this,"running");try{const i=await p(this,$,El).call(this).prompt({sessionId:p(this,$,Ch).call(this),prompt:[{type:"text",text:p(this,$,kw).call(this,n)}]});p(this,$,_n).call(this,i.stopReason==="cancelled"?"cancelled":"final"),p(this,$,yr).call(this,"ready")}catch(i){throw p(this,$,Ew).call(this)||(p(this,$,_n).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,$,Al).call(this);((n=l(this,Xt))==null?void 0:n.sessionIdStrategy)==="mapped"?l(this,Gr).clearActualSessionId(e):b(this,Bi,l(this,Bi)+1),b(this,It,null),b(this,xr,null),b(this,Jt,null),b(this,Ct,null),p(this,$,Lh).call(this)}async cancel(){this.status==="running"&&(p(this,$,yr).call(this,"cancelling"),await p(this,$,El).call(this).cancel({sessionId:p(this,$,Ch).call(this)}))}setScreenContext(e){var s,o,a;if(e===null){if(l(this,Xe)===null)return;b(this,Xe,null),b(this,Er,!1);return}const n={screenID:e.screenID,screenName:e.screenName};if(((s=l(this,Xe))==null?void 0:s.screenID)===n.screenID&&((o=l(this,Xe))==null?void 0:o.screenName)===n.screenName)return;const i=((a=l(this,Xe))==null?void 0:a.screenID)??null;if(b(this,Xe,n),l(this,er)==="single_session"){(!l(this,Ct)||i!==n.screenID)&&b(this,Er,!0);return}l(this,Ct)!==p(this,$,Rh).call(this,n.screenID)&&(b(this,It,null),b(this,xr,null),l(this,Kt)&&this.status==="ready"&&p(this,$,xl).call(this).catch(c=>{p(this,$,$i).call(this,Hu(c))}))}}Vi=new WeakMap,Yt=new WeakMap,dt=new WeakMap,Kt=new WeakMap,jr=new WeakMap,It=new WeakMap,xr=new WeakMap,Jt=new WeakMap,Xt=new WeakMap,Gr=new WeakMap,Ct=new WeakMap,Bi=new WeakMap,ji=new WeakMap,Qt=new WeakMap,Xe=new WeakMap,Er=new WeakMap,Gi=new WeakMap,Nn=new WeakMap,Ar=new WeakMap,qr=new WeakMap,No=new WeakMap,Rt=new WeakMap,er=new WeakMap,ac=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)})}},pw=async function(){try{const{stream:e,socket:n,metadata:i}=await iO({serverURL:l(this,Rt).serverURL,token:l(this,Rt).token,createSocket:l(this,No),onDisconnect:l(this,ac)});b(this,Xt,i),b(this,tr,n),n.addEventListener("close",l(this,Uo)),n.addEventListener("error",l(this,Fo)),b(this,Kt,new Wz(s=>({connection:s,sessionUpdate:async o=>{await p(this,$,vw).call(this,o)},requestPermission:async o=>p(this,$,yw).call(this,o)}),e)),await l(this,Kt).initialize({protocolVersion:AL,clientCapabilities:{},clientInfo:Jz})}catch(e){throw e}},fw=function(e){p(this,$,$i).call(this,Hu(e))},gw=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})`)},xl=async function(){const e=p(this,$,Al).call(this);if(l(this,It)&&l(this,xr)===e){await l(this,It);return}b(this,xr,e),b(this,It,p(this,$,mw).call(this,e)),await l(this,It)},mw=async function(e){var c;const n=p(this,$,El).call(this);p(this,$,Lh).call(this);let i,s=!1,o=null;const a={cwd:p(this,$,xw).call(this),mcpServers:[],_meta:{sessionKey:e}};try{if(b(this,Nn,!0),b(this,Ar,null),((c=l(this,Xt))==null?void 0:c.sessionIdStrategy)==="mapped"){const u=l(this,Gr).getActualSessionId(e);if(u)try{const h=await n.loadSession({...a,sessionId:u});if(tO(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,Gr).setActualSessionId(e,i),s=!1}else{const h=await n.newSession(a);o=h,i=h.sessionId,l(this,Gr).setActualSessionId(e,i),s=!1}}else try{o=await n.loadSession({...a,sessionId:e}),i=e,s=l(this,dt).size>0}catch{const u=await n.newSession(a);o=u,i=u.sessionId,s=!1}}finally{b(this,Nn,!1),b(this,Ar,null),p(this,$,_n).call(this,"final")}p(this,$,gw).call(this,o),await n.setSessionConfigOption({sessionId:i,configId:"verbose_level",value:"full"}),b(this,Jt,i),b(this,Ct,e),b(this,Gi,!0),s?(l(this,qr).add(e),l(this,er)==="single_session"&&b(this,Er,!1)):(l(this,qr).delete(e),b(this,Er,l(this,er)==="single_session")),b(this,Yt,null),p(this,$,yr).call(this,"ready")},vw=async function(e){const n=e.update;switch(n.sessionUpdate){case"user_message_chunk":n.content.type==="text"&&p(this,$,_w).call(this,n.content.text);return;case"agent_message_chunk":n.content.type==="text"&&p(this,$,bw).call(this,n.content.text);return;case"tool_call":p(this,$,ww).call(this,n);return;case"tool_call_update":p(this,$,Sw).call(this,n);return;case"agent_thought_chunk":return;default:return}},yw=async function(e){return{outcome:{outcome:"cancelled"}}},bw=function(e){b(this,Ar,null);const n=nO(e);if(!n)return;if(!l(this,Qt)){const s={id:p(this,$,Ti).call(this,"assistant"),kind:"assistant",text:n,status:"streaming"};b(this,Qt,s.id),p(this,$,Ei).call(this,s);return}const i=l(this,dt).get(l(this,Qt));if(!i||i.kind!=="assistant")throw new Error("Open assistant message invariant violated");p(this,$,Ai).call(this,{...i,text:`${i.text}${n}`,status:"streaming"})},ww=function(e){p(this,$,_n).call(this,"final");const n=p(this,$,Ih).call(this,e.toolCallId),i=pm("content"in e?e.content:void 0),s={id:(n==null?void 0:n.id)??p(this,$,Ti).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,$,Ai).call(this,s);return}p(this,$,Ei).call(this,s)},Sw=function(e){const n=p(this,$,Ih).call(this,e.toolCallId),i=(n==null?void 0:n.text)??"",s=pm(e.content),o=s?`${i}${s}`:i,a={id:(n==null?void 0:n.id)??p(this,$,Ti).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,$,Ai).call(this,a);return}p(this,$,Ei).call(this,a)},_w=function(e){if(p(this,$,_n).call(this,"final"),!e)return;const n=l(this,Nn)?l(this,Ar):null;if(!n){const s=dm(e);if(!s)return;const o={id:p(this,$,Ti).call(this,"user"),kind:"user",text:s,status:"final"};p(this,$,Ei).call(this,o),l(this,Nn)&&b(this,Ar,o.id);return}const i=l(this,dt).get(n);if(!i||i.kind!=="user")throw new Error("Replay user message invariant violated");p(this,$,Ai).call(this,{...i,text:dm(`${i.text}${e}`)})},_n=function(e){if(!l(this,Qt))return;const n=l(this,dt).get(l(this,Qt));(n==null?void 0:n.kind)==="assistant"&&p(this,$,Ai).call(this,{...n,status:e}),b(this,Qt,null)},Ei=function(e){l(this,dt).set(e.id,e),this.dispatchEvent(new zu("messages-changed"))},Ai=function(e){l(this,dt).set(e.id,e),this.dispatchEvent(new zu("messages-changed"))},yr=function(e){l(this,Vi)!==e&&(b(this,Vi,e),this.dispatchEvent(new ST("status-changed")))},kw=function(e){const n=l(this,Ct);if(!n)return e;const i=l(this,Xe)?l(this,er)==="single_session"?l(this,Er)||!l(this,qr).has(n):!l(this,qr).has(n):!1,s=l(this,Gi)&&(l(this,Xe)!==null||qz.test(e));if(!(s||i))return e;s&&b(this,Gi,!1),i&&(b(this,Er,!1),l(this,qr).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,Xe)?(a.push("This conversation is currently attached to the screen below."),a.push(`screen_id: ${l(this,Xe).screenID}`),a.push(`screen_name: ${l(this,Xe).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
|
+
`)},Ti=function(e){const n=`${e}-${l(this,ji)}`;return b(this,ji,l(this,ji)+1),n},Ih=function(e){for(const n of l(this,dt).values())if((n==null?void 0:n.kind)==="tool_call"&&n.toolCallId===e)return n;return null},Ch=function(){if(!l(this,Jt))throw new Error("ACP session is not ready");return l(this,Jt)},El=function(){if(!l(this,Kt))throw new Error("ACP connection is not ready");return l(this,Kt)},xw=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},Al=function(){var n;if(l(this,er)==="single_session")return p(this,$,Ph).call(this,`${dw}-${(l(this,Rt).clientGUID??"default-client").toLowerCase()}`);const e=(n=l(this,Xe))==null?void 0:n.screenID;if(!e)throw new Error("Screen context is required for per-screen session mode");return p(this,$,Rh).call(this,e)},Rh=function(e){return p(this,$,Ph).call(this,rO(l(this,er),e,l(this,Rt).clientGUID??"default-client"))},Ph=function(e){var n;return((n=l(this,Xt))==null?void 0:n.sessionIdStrategy)==="deterministic"&&l(this,Bi)>0?`${e}:epoch-${l(this,Bi)}`:e},Uo=new WeakMap,Fo=new WeakMap,Tl=function(){b(this,Kt,null),b(this,jr,null),b(this,It,null),b(this,xr,null),b(this,Jt,null),b(this,Ct,null),b(this,Xt,null),l(this,tr)&&(l(this,tr).removeEventListener("close",l(this,Uo)),l(this,tr).removeEventListener("error",l(this,Fo)),l(this,tr).close(),b(this,tr,null))},$i=function(e){const n=l(this,Kt)!==null||l(this,jr)!==null||l(this,It)!==null||l(this,xr)!==null||l(this,Jt)!==null||l(this,Ct)!==null||l(this,Xt)!==null||l(this,tr)!==null;this.disposed||this.status==="disconnected"&&!n||(p(this,$,_n).call(this,"error"),p(this,$,Tl).call(this),b(this,Yt,e??null),p(this,$,yr).call(this,"disconnected"))},Lh=function(){const e=l(this,dt).size>0;b(this,Qt,null),b(this,Ar,null),b(this,ji,1),l(this,dt).clear(),e&&this.dispatchEvent(new zu("messages-changed"))},Ew=function(){return this.status==="disconnected"};function eO(){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 tO(r){return r==null?!0:typeof r=="object"&&Object.keys(r).length===0}function rO(r,t,e){return r==="single_session"?`${dw}-${e.toLowerCase()}`:`agent:main:television-${e.toLowerCase()}-${t.toLowerCase()}`}function Aw(r){return r.replace(/^(?:\s*\n)+/,"")}function dm(r){let t=r;return t=t.replace(Bz,""),t=t.replace(jz,""),t=t.replace(Gz,""),t=Aw(t),t}function nO(r){let t=r;return t=t.replace(Yz,""),t=Aw(t),t}function pm(r){return!r||r.length===0?"":r.flatMap(t=>t.type==="content"&&t.content.type==="text"?[t.content.text]:[]).join("")}async function iO(r){const t=r.createSocket(aO(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=oO(x);if(!I)return;let L;try{L=JSON.parse(I)}catch(R){const V=R instanceof Error?R:new Error(String(R));i(V),u.error(V);return}switch(L.type){case"acp-bridge-status":if(L.status==="ready"){let R;try{R=sO(L)}catch(V){const N=V instanceof Error?V:new Error(String(V));e||i(N),u.error(N);return}e||(e=!0,n(R));return}if(L.status==="error"||L.status==="exited"){const R=new Error(L.error??`ACP bridge ${L.status}`);e||i(R),u.error(R)}return;case"acp-bridge-message":u.enqueue(L.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 sO(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 oO(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 aO(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 Hu(r){return r instanceof Error?r.message:String(r)}const fm="television.acpClientGUID",gm="television.acpMappedSessions",mm=1;var qi;class lO{constructor(){w(this,qi,new Map)}getActualSessionId(t){return l(this,qi).get(t)??null}setActualSessionId(t,e){l(this,qi).set(t,e)}clearActualSessionId(t){l(this,qi).delete(t)}}qi=new WeakMap;var Yi,Ho,pt,$l,Il,Dh;class cO{constructor(t,e){w(this,pt);w(this,Yi);w(this,Ho);b(this,Yi,t),b(this,Ho,e)}getActualSessionId(t){const e=p(this,pt,Il).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,Il).call(this);n[p(this,pt,$l).call(this,t)]=e,p(this,pt,Dh).call(this,n)}clearActualSessionId(t){const e=p(this,pt,Il).call(this);delete e[p(this,pt,$l).call(this,t)],p(this,pt,Dh).call(this,e)}}Yi=new WeakMap,Ho=new WeakMap,pt=new WeakSet,$l=function(t){return JSON.stringify([l(this,Ho),t])},Il=function(){const t=l(this,Yi).getItem(gm);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!==mm?{}:typeof n.entries!="object"||n.entries===null||Array.isArray(n.entries)?{}:Object.fromEntries(Object.entries(n.entries).filter(i=>typeof i[1]=="string"))},Dh=function(t){const e={version:mm,entries:t};l(this,Yi).setItem(gm,JSON.stringify(e))};function Tw(){return typeof window>"u"?null:window.localStorage}function uO(r){const t=r.getItem(fm);if(t)return t;const e=Cc().toLowerCase();return r.setItem(fm,e),e}const vm=4401,hO=401,cl=1e3,dO=3e4;class ho extends Error{constructor(t="Authentication required"){super(t),this.name="AuthError"}}class $w extends Nt{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",cl);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 GT(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 cO(e.acpStorage,this.url):new lO);this.acpClient=new Qz({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?kL({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=cl,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=Yl(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=Yl(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 qs("screens-changed"));break;case"screen-updated":this.screens.set(e.screen.id,structuredClone(e.screen)),this.dispatchEvent(new qs("screens-changed"));break;case"screen-removed":this.screens.delete(e.screenID),this.dispatchEvent(new qs("screens-changed"));break;case"artifact-created":{const n=this.screens.get(e.screenID);n&&!_l(n).includes(e.artifact.id)&&(n.layout=[...n.layout,Cy(e.artifact.id)]);break}case"artifact-removed":{const n=this.screens.get(e.screenID);n&&(n.layout=wy(n.layout,e.artifactID));break}case"artifact-updated":case"artifact-content-changed":case"screen-changed":case"theme-changed":case"artifact-focus":break;default:return pO(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(fO(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=cl,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 qs("screens-changed")),this.dispatchEvent(new yh("server-event",{serverURL:this.url,event:{type:"screen-changed",screenID:m.activeScreenID}})),c(),f&&this.connectAttempt===e&&this.dispatchEvent(new yy("server-reconnected",{serverURL:this.url}))}catch(y){if(vO(y)){u(new ho);return}u(y instanceof Error?y:new Error(String(y)))}};n.addEventListener("open",()=>{h()}),n.addEventListener("message",f=>{const y=mO(f);y&&(this.applyServerEvent(y),this.dispatchEvent(new yh("server-event",{serverURL:this.url,event:y})))}),n.addEventListener("close",f=>{if(this.connectAttempt!==e)return;this.socket=null;const y=gO(f);if(!a){u(y===vm?new ho:new Error("Connection closed before initialization"));return}if(y===vm){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 ho){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,dO),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=cl,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 pO(r,t){throw new Error(`Unexpected ${t}: ${JSON.stringify(r)}`)}function fO(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 _L(e))n.searchParams.set(i,s);return n.hash="",n.toString()}function gO(r){return typeof r=="object"&&r!==null&&"code"in r&&typeof r.code=="number"?r.code:null}function mO(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 vO(r){return r instanceof ip&&r.status===hO}const yO="Local";var Zo,zh;class bO extends Nt{constructor(e){super();w(this,Zo);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?Tw():e.acpStorage;this.acpStorage=n,this.clientGUID=e.clientGUID??(n?uO(n):Cc().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 yh("server-event",{serverURL:u.serverURL,event:u.event}))},a=()=>{this.dispatchEvent(new qs("screens-changed"))},c=u=>{this.dispatchEvent(new yy("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 Mu(this.localStore.get(),e)}setStoredAuthToken(e,n){this.localStore.set(n$(this.localStore.get(),e,n))}clearStoredAuthToken(e){const n=this.localStore.get(),i=i$(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:yO}]})}const s=this.localStore.get().servers;for(const a of s){const c=he(a.url),h=i!==null&&c===i?n??Mu(this.localStore.get(),c):Mu(this.localStore.get(),c),f=p(this,Zo,zh).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,Zo,zh).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)}}Zo=new WeakSet,zh=function(e){return new $w({url:e.url,name:e.name,token:e.token,createSocket:this.createSocket,clientGUID:this.clientGUID,acpStorage:this.acpStorage,telemetryMeta:this.telemetryMeta})};var Wo;class wO extends Nt{constructor(){super();w(this,Wo,e=>{const n=SO(e);n!==null&&(e.preventDefault(),this.dispatchEvent(new wT("shortcut-triggered",{shortcut:n})))});document.addEventListener("keydown",l(this,Wo))}dispose(){document.removeEventListener("keydown",l(this,Wo))}}Wo=new WeakMap;function SO(r){for(const[t,e]of Object.entries(qT))if(_O(r,e.trigger))return t;return null}function _O(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 Oh="tv-nav:",vs="tv-reload",ym=100,kO=1e3,xO=60,EO=60,AO=24,TO=30,$O=TO*AO*EO*xO*kO;function Pr(r){try{const t=new URL(r,window.location.href),e=t.searchParams.has(vs);return t.searchParams.delete(vs),t.origin===window.location.origin?`${t.pathname}${t.search}${t.hash}`:e?t.toString():r}catch{return r}}var Vo,Ki,ue,ne,Un,ke,Iw,Ur,Cw,Mh,Nh;class IO extends Nt{constructor(e,n){super();w(this,ke);w(this,Vo);w(this,Ki);w(this,ue,[]);w(this,ne,-1);w(this,Un,0);b(this,Vo,e),b(this,Ki,Pr(n)),p(this,ke,Iw).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=Pr(e);if(n===l(this,Ki)){if(l(this,ne)===-1)return;b(this,ne,-1),p(this,ke,Ur).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,Mh).call(this),p(this,ke,Ur).call(this)}replace(e){var i;if(l(this,ne)===-1){this.navigate(e);return}const n=Pr(e);if(n===l(this,Ki)){b(this,ue,l(this,ue).filter((s,o)=>o!==l(this,ne))),b(this,ne,-1),p(this,ke,Ur).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,Ur).call(this))}back(){l(this,ne)!==-1&&(b(this,ne,l(this,ne)-1),p(this,ke,Ur).call(this))}forward(){this.canGoForward&&(b(this,ne,l(this,ne)+1),p(this,ke,Ur).call(this))}reset(){l(this,ne)===-1&&l(this,ue).length===0||(b(this,ue,[]),b(this,ne,-1),p(this,ke,Ur).call(this))}}Vo=new WeakMap,Ki=new WeakMap,ue=new WeakMap,ne=new WeakMap,Un=new WeakMap,ke=new WeakSet,Iw=function(){const e=localStorage.getItem(l(this,ke,Nh));if(e!==null)try{const n=JSON.parse(e);if(!Rw(n))return;b(this,ue,n.entries.map(i=>({url:i.url}))),b(this,ne,n.cursor),b(this,Un,n.lastWritten),p(this,ke,Mh).call(this)}catch{b(this,ue,[]),b(this,ne,-1),b(this,Un,0)}},Ur=function(){b(this,Un,Date.now());try{localStorage.setItem(l(this,ke,Nh),JSON.stringify(p(this,ke,Cw).call(this)))}catch(e){if(!PO(e))throw e}this.dispatchEvent(new oe("change"))},Cw=function(){return{v:1,entries:l(this,ue).map(e=>({...e})),cursor:l(this,ne),lastWritten:l(this,Un)}},Mh=function(){if(l(this,ue).length<=ym)return;const e=l(this,ue).length-ym;b(this,ue,l(this,ue).slice(e)),b(this,ne,Math.max(-1,l(this,ne)-e))},Nh=function(){return CO(l(this,Vo))};function CO(r){return`${Oh}${r}`}function RO(r){const t=Date.now()-$O,e=[];for(let n=0;n<localStorage.length;n+=1){const i=localStorage.key(n);if(!(i!=null&&i.startsWith(Oh)))continue;const s=i.slice(Oh.length),o=localStorage.getItem(i);if(o===null)continue;let a;try{a=JSON.parse(o)}catch{e.push(i);continue}if(!Rw(a)){e.push(i);continue}!r.has(s)&&a.lastWritten<t&&e.push(i)}for(const n of e)localStorage.removeItem(n)}function PO(r){return r instanceof DOMException&&r.name==="QuotaExceededError"}function Rw(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 Nr=null;async function Pw(r,t){if(Nr==null||Nr.abort(),r===null){Nr=null,Vl();return}const e=new AbortController;Nr=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(Nr!==e)return;vy(o)}catch(n){if(n.name==="AbortError")return;Vl();const i=n instanceof Error?n.message:String(n);console.warn(`applyTheme: ${i}`)}finally{Nr===e&&(Nr=null)}}/**
|
|
44
44
|
* @license
|
|
45
45
|
* Copyright 2017 Google LLC
|
|
46
46
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
47
|
-
*/const
|
|
48
|
-
\f\r]`,
|
|
49
|
-
\f\r"'\`<>=]|("|')|))|$)`,"g"),
|
|
47
|
+
*/const po=globalThis,bm=r=>r,Kl=po.trustedTypes,wm=Kl?Kl.createPolicy("lit-html",{createHTML:r=>r}):void 0,Lw="$lit$",Hr=`lit$${Math.random().toFixed(9).slice(2)}$`,Dw="?"+Hr,LO=`<${Dw}>`,ti=document,So=()=>ti.createComment(""),_o=r=>r===null||typeof r!="object"&&typeof r!="function",fp=Array.isArray,DO=r=>fp(r)||typeof(r==null?void 0:r[Symbol.iterator])=="function",Zu=`[
|
|
48
|
+
\f\r]`,Us=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Sm=/-->/g,_m=/>/g,vn=RegExp(`>|${Zu}(?:([^\\s"'>=/]+)(${Zu}*=${Zu}*(?:[^
|
|
49
|
+
\f\r"'\`<>=]|("|')|))|$)`,"g"),km=/'/g,xm=/"/g,zw=/^(?:script|style|textarea|title)$/i,zO=r=>(t,...e)=>({_$litType$:r,strings:t,values:e}),P=zO(1),ri=Symbol.for("lit-noChange"),le=Symbol.for("lit-nothing"),Em=new WeakMap,Cn=ti.createTreeWalker(ti,129);function Ow(r,t){if(!fp(r)||!r.hasOwnProperty("raw"))throw Error("invalid template strings array");return wm!==void 0?wm.createHTML(t):t}const OO=(r,t)=>{const e=r.length-1,n=[];let i,s=t===2?"<svg>":t===3?"<math>":"",o=Us;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===Us?h[1]==="!--"?o=Sm:h[1]!==void 0?o=_m:h[2]!==void 0?(zw.test(h[2])&&(i=RegExp("</"+h[2],"g")),o=vn):h[3]!==void 0&&(o=vn):o===vn?h[0]===">"?(o=i??Us,f=-1):h[1]===void 0?f=-2:(f=o.lastIndex-h[2].length,u=h[1],o=h[3]===void 0?vn:h[3]==='"'?xm:km):o===xm||o===km?o=vn:o===Sm||o===_m?o=Us:(o=vn,i=void 0);const m=o===vn&&r[a+1].startsWith("/>")?" ":"";s+=o===Us?c+LO:f>=0?(n.push(u),c.slice(0,f)+Lw+c.slice(f)+Hr+m):c+Hr+(f===-2?a:m)}return[Ow(r,s+(r[e]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),n]};class ko{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]=OO(t,e);if(this.el=ko.createElement(u,n),Cn.currentNode=this.el.content,e===2||e===3){const f=this.el.content.firstChild;f.replaceWith(...f.childNodes)}for(;(i=Cn.nextNode())!==null&&c.length<a;){if(i.nodeType===1){if(i.hasAttributes())for(const f of i.getAttributeNames())if(f.endsWith(Lw)){const y=h[o++],m=i.getAttribute(f).split(Hr),E=/([.?@])?(.*)/.exec(y);c.push({type:1,index:s,name:E[2],strings:m,ctor:E[1]==="."?NO:E[1]==="?"?UO:E[1]==="@"?FO:Hc}),i.removeAttribute(f)}else f.startsWith(Hr)&&(c.push({type:6,index:s}),i.removeAttribute(f));if(zw.test(i.tagName)){const f=i.textContent.split(Hr),y=f.length-1;if(y>0){i.textContent=Kl?Kl.emptyScript:"";for(let m=0;m<y;m++)i.append(f[m],So()),Cn.nextNode(),c.push({type:2,index:++s});i.append(f[y],So())}}}else if(i.nodeType===8)if(i.data===Dw)c.push({type:2,index:s});else{let f=-1;for(;(f=i.data.indexOf(Hr,f+1))!==-1;)c.push({type:7,index:s}),f+=Hr.length-1}s++}}static createElement(t,e){const n=ti.createElement("template");return n.innerHTML=t,n}}function ys(r,t,e=r,n){var o,a;if(t===ri)return t;let i=n!==void 0?(o=e._$Co)==null?void 0:o[n]:e._$Cl;const s=_o(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=ys(r,i._$AS(r,t.values),i,n)),t}class MO{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)??ti).importNode(e,!0);Cn.currentNode=i;let s=Cn.nextNode(),o=0,a=0,c=n[0];for(;c!==void 0;){if(o===c.index){let u;c.type===2?u=new Fc(s,s.nextSibling,this,t):c.type===1?u=new c.ctor(s,c.name,c.strings,this,t):c.type===6&&(u=new HO(s,this,t)),this._$AV.push(u),c=n[++a]}o!==(c==null?void 0:c.index)&&(s=Cn.nextNode(),o++)}return Cn.currentNode=ti,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 Fc=class Mw{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=ys(this,t,e),_o(t)?t===le||t==null||t===""?(this._$AH!==le&&this._$AR(),this._$AH=le):t!==this._$AH&&t!==ri&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):DO(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&&_o(this._$AH)?this._$AA.nextSibling.data=t:this.T(ti.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=ko.createElement(Ow(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 MO(i,this),a=o.u(this.options);o.p(e),this.T(a),this._$AH=o}}_$AC(t){let e=Em.get(t.strings);return e===void 0&&Em.set(t.strings,e=new ko(t)),e}k(t){fp(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 Mw(this.O(So()),this.O(So()),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=bm(t).nextSibling;bm(t).remove(),t=i}}setConnected(t){var e;this._$AM===void 0&&(this._$Cv=t,(e=this._$AP)==null||e.call(this,t))}},Hc=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=ys(this,t,e,0),o=!_o(t)||t!==this._$AH&&t!==ri,o&&(this._$AH=t);else{const a=t;let c,u;for(t=s[0],c=0;c<s.length-1;c++)u=ys(this,a[n+c],e,c),u===ri&&(u=this._$AH[c]),o||(o=!_o(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??"")}},NO=class extends Hc{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===le?void 0:t}},UO=class extends Hc{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==le)}},FO=class extends Hc{constructor(t,e,n,i,s){super(t,e,n,i,s),this.type=5}_$AI(t,e=this){if((t=ys(this,t,e,0)??le)===ri)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 HO{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){ys(this,t)}}const ZO={I:Fc},Wu=po.litHtmlPolyfillSupport;Wu==null||Wu(ko,Fc),(po.litHtmlVersions??(po.litHtmlVersions=[])).push("3.3.2");const Ve=(r,t,e)=>{const n=t;let i=n._$litPart$;return i===void 0&&(n._$litPart$=i=new Fc(t.insertBefore(So(),null),null,void 0,{})),i._$AI(r),i};/**
|
|
50
50
|
* @license
|
|
51
51
|
* Copyright 2017 Google LLC
|
|
52
52
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
53
|
-
*/const
|
|
53
|
+
*/const gp={CHILD:2},Zc=r=>(...t)=>({_$litDirective$:r,values:t});let mp=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
54
|
* @license
|
|
55
55
|
* Copyright 2017 Google LLC
|
|
56
56
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
57
|
-
*/let
|
|
57
|
+
*/let Jl=class extends mp{constructor(t){if(super(t),this.it=le,t.type!==gp.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===ri)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:[]}}};Jl.directiveName="unsafeHTML",Jl.resultType=1;const WO=Zc(Jl);/**
|
|
58
58
|
* @license
|
|
59
59
|
* Copyright 2017 Google LLC
|
|
60
60
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
61
|
-
*/let
|
|
61
|
+
*/let Uh=class extends Jl{};Uh.directiveName="unsafeSVG",Uh.resultType=2;const Nw=Zc(Uh),VO={size:16,color:"currentColor",weight:"regular"};function BO(r){return typeof r=="string"?{regular:r}:r}function At(r,t="0 0 256 256"){const e=BO(r);return n=>{const{size:i,color:s,weight:o}={...VO,...n},a=e[o]??e.regular;return P`<svg
|
|
62
62
|
xmlns="http://www.w3.org/2000/svg"
|
|
63
63
|
data-ui-icon=""
|
|
64
64
|
width="${i}"
|
|
65
65
|
height="${i}"
|
|
66
66
|
viewBox="${t}"
|
|
67
67
|
fill="${s}"
|
|
68
|
-
>${
|
|
68
|
+
>${Nw(a)}</svg>`}}/**
|
|
69
69
|
* @license
|
|
70
70
|
* Copyright 2020 Google LLC
|
|
71
71
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
72
|
-
*/const{I:
|
|
72
|
+
*/const{I:jO}=ZO,Am=r=>r,GO=r=>r.strings===void 0,Tm=()=>document.createComment(""),Fs=(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(Tm(),i),a=n.insertBefore(Tm(),i);e=new jO(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=Am(u).nextSibling;Am(n).insertBefore(u,i),u=h}}}return e},yn=(r,t,e=r)=>(r._$AI(t,e),r),qO={},YO=(r,t=qO)=>r._$AH=t,KO=r=>r._$AH,Vu=r=>{r._$AR(),r._$AA.remove()};/**
|
|
73
73
|
* @license
|
|
74
74
|
* Copyright 2017 Google LLC
|
|
75
75
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
76
|
-
*/const
|
|
76
|
+
*/const fo=(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),fo(i,t);return!0},Xl=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)},Uw=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),QO(t)}};function JO(r){this._$AN!==void 0?(Xl(this),this._$AM=r,Uw(this)):this._$AM=r}function XO(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++)fo(n[s],!1),Xl(n[s]);else n!=null&&(fo(n,!1),Xl(n));else fo(this,r)}const QO=r=>{r.type==gp.CHILD&&(r._$AP??(r._$AP=XO),r._$AQ??(r._$AQ=JO))};class eM extends mp{constructor(){super(...arguments),this._$AN=void 0}_$AT(t,e,n){super._$AT(t,e,n),Uw(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&&(fo(this,t),Xl(this))}setValue(t){if(GO(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
77
|
* @license
|
|
78
78
|
* Copyright 2020 Google LLC
|
|
79
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
|
|
80
|
+
*/const Xs=()=>new tM;class tM{}const Bu=new WeakMap,Qs=Zc(class extends eM{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=Bu.get(t);e===void 0&&(e=new WeakMap,Bu.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=Bu.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)}}),vp=At('<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"/>'),rM=At('<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"/>'),nM=At('<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"/>'),Ql=At('<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"/>'),iM=At('<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"/>'),sM=At({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"/>'}),oM=At({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"/>'}),aM=At({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"/>'}),lM=At('<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"/>'),cM=At({regular:'<path d="M216,48H176V40a24,24,0,0,0-24-24H104A24,24,0,0,0,80,40v8H40a8,8,0,0,0,0,16h8V208a16,16,0,0,0,16,16H192a16,16,0,0,0,16-16V64h8a8,8,0,0,0,0-16ZM96,40a8,8,0,0,1,8-8h48a8,8,0,0,1,8,8v8H96Zm96,168H64V64H192ZM112,104v64a8,8,0,0,1-16,0V104a8,8,0,0,1,16,0Zm48,0v64a8,8,0,0,1-16,0V104a8,8,0,0,1,16,0Z"/>',bold:'<path d="M216,44H176V40a24,24,0,0,0-24-24H104A24,24,0,0,0,80,40v4H40a12,12,0,0,0,0,24h4V208a20,20,0,0,0,20,20H192a20,20,0,0,0,20-20V68h4a12,12,0,0,0,0-24ZM104,40h48v4H104Zm84,164H68V68H188Zm-84-48V120a12,12,0,0,1,24,0v36a12,12,0,0,1-24,0Zm40,0V120a12,12,0,0,1,24,0v36a12,12,0,0,1-24,0Z"/>'}),Fw=At({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"/>'}),uM=At('<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 hM extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}const $m='a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])',ju=4;var Fe,st,Fn,ot,Bo,Ji,Xi,W,Fh,Hh,Zw,Cl,Ww,Zh,Wh,jo,Go,Hn,Vw,Vh,Bw,jw,Rl,Ii;class Hw extends HTMLElement{constructor(){super();w(this,W);w(this,Fe,!1);w(this,st,null);w(this,Fn);w(this,ot,null);w(this,Bo,"bottom-start");w(this,Ji,!1);w(this,Xi,!1);w(this,jo,e=>{l(this,Fe)&&(l(this,Ji)||e.composedPath().includes(this)||(this.open=!1))});w(this,Go,e=>{if(l(this,Fe)){if(e.key==="Escape"){e.preventDefault(),this.open=!1;return}e.key==="Tab"&&p(this,W,Vw).call(this,e)}});w(this,Hn,()=>{l(this,Fe)&&p(this,W,Rl).call(this)});b(this,Fn,this.attachShadow({mode:"open"})),tp(l(this,Fn)),p(this,W,Hh).call(this,"anchor")}connectedCallback(){this.removeAttribute("popover"),this.hasAttribute("tone")||this.setAttribute("tone","light"),p(this,W,Hh).call(this,"open"),p(this,W,Ii).call(this),l(this,Fe)&&(p(this,W,Zh).call(this),p(this,W,Cl).call(this))}disconnectedCallback(){var e;p(this,W,Wh).call(this),(e=l(this,st))==null||e.removeAttribute("aria-expanded")}attributeChangedCallback(e){e==="open"?p(this,W,Zw).call(this,this.hasAttribute("open")):e==="material"&&l(this,Fe)&&(p(this,W,Ii).call(this),p(this,W,Cl).call(this))}get open(){return l(this,Fe)}set open(e){this.toggleAttribute("open",e)}get anchor(){return l(this,st)}set anchor(e){l(this,st)!==e&&(l(this,st)&&l(this,st).removeAttribute("aria-expanded"),b(this,st,e),p(this,W,Fh).call(this),l(this,Fe)&&p(this,W,Rl).call(this))}}Fe=new WeakMap,st=new WeakMap,Fn=new WeakMap,ot=new WeakMap,Bo=new WeakMap,Ji=new WeakMap,Xi=new WeakMap,W=new WeakSet,Fh=function(){l(this,st)&&l(this,st).setAttribute("aria-expanded",l(this,Fe)?"true":"false")},Hh=function(e){if(!Object.prototype.hasOwnProperty.call(this,e))return;const n=this,i=n[e];delete n[e],n[e]=i},Zw=function(e){var n,i,s;if(l(this,Fe)!==e){if(b(this,Fe,e),p(this,W,Fh).call(this),!this.isConnected){p(this,W,Ii).call(this);return}e?(b(this,Ji,!0),setTimeout(()=>{b(this,Ji,!1)},0),p(this,W,Ii).call(this),p(this,W,Zh).call(this),p(this,W,Cl).call(this)):(p(this,W,Wh).call(this),(i=(n=l(this,ot))==null?void 0:n.hidePopover)==null||i.call(n),p(this,W,Ii).call(this),(s=l(this,st))==null||s.focus(),this.dispatchEvent(new hM))}},Cl=function(){l(this,Xi)||(b(this,Xi,!0),queueMicrotask(()=>{b(this,Xi,!1),!(!l(this,Fe)||!this.isConnected)&&(p(this,W,Ww).call(this),p(this,W,jw).call(this))}))},Ww=function(){var e,n;if(l(this,ot)){try{(n=(e=l(this,ot)).showPopover)==null||n.call(e)}catch{}p(this,W,Rl).call(this)}},Zh=function(){document.addEventListener("click",l(this,jo)),document.addEventListener("keydown",l(this,Go),!0),window.addEventListener("resize",l(this,Hn)),window.addEventListener("scroll",l(this,Hn),!0)},Wh=function(){document.removeEventListener("click",l(this,jo)),document.removeEventListener("keydown",l(this,Go),!0),window.removeEventListener("resize",l(this,Hn)),window.removeEventListener("scroll",l(this,Hn),!0)},jo=new WeakMap,Go=new WeakMap,Hn=new WeakMap,Vw=function(e){const n=p(this,W,Vh).call(this);if(n.length===0){e.preventDefault();return}const i=n[0],s=n[n.length-1],o=p(this,W,Bw).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())},Vh=function(){if(!l(this,ot))return[];const e=l(this,ot).querySelector("slot");if(!(e instanceof HTMLSlotElement))return[];const n=[];for(const i of e.assignedElements({flatten:!0}))if(i instanceof HTMLElement){i.matches($m)&&n.push(i);for(const s of i.querySelectorAll($m))n.push(s)}return n},Bw=function(){var n;let e=document.activeElement;for(;e&&((n=e.shadowRoot)!=null&&n.activeElement);)e=e.shadowRoot.activeElement;return e},jw=function(){var n;const e=p(this,W,Vh).call(this);e.length>0?e[0].focus():(n=l(this,ot))==null||n.focus()},Rl=function(){if(!l(this,Fe)||!l(this,st)||!l(this,ot))return;const e=l(this,st).getBoundingClientRect(),n=l(this,ot).getBoundingClientRect(),s=window.innerHeight-e.bottom,o=n.height+ju,a=s<o&&e.top>o?"top-start":"bottom-start";b(this,Bo,a);const c=a==="bottom-start"?e.bottom+ju:e.top-n.height-ju,u=e.left;l(this,ot).style.transform=`translate(${u}px, ${c}px)`,l(this,ot).setAttribute("data-placement",a)},Ii=function(){this.toggleAttribute("open",l(this,Fe));const e=this.getAttribute("material")??"paper";Ve(l(this,Fe)?P`<div
|
|
81
81
|
class="panel"
|
|
82
82
|
part="panel"
|
|
83
83
|
popover="manual"
|
|
84
|
-
data-placement=${l(this,
|
|
84
|
+
data-placement=${l(this,Bo)}
|
|
85
85
|
tabindex="-1"
|
|
86
86
|
role="dialog"
|
|
87
87
|
material=${e}
|
|
88
88
|
level="1"
|
|
89
89
|
>
|
|
90
90
|
<slot></slot>
|
|
91
|
-
</div>`:le,l(this,
|
|
92
|
-
<slot name="trigger" @slotchange=${l(this,
|
|
91
|
+
</div>`:le,l(this,Fn)),b(this,ot,l(this,Fn).querySelector(".panel"))},g(Hw,"observedAttributes",["open","material"]);customElements.get("ui-popover")||customElements.define("ui-popover",Hw);class Gw extends Event{constructor(e){super("dropdown-item-select",{bubbles:!0,composed:!0});g(this,"value");this.value=e}}class dM extends Event{constructor(e){super("select",{bubbles:!0,composed:!0});g(this,"value");this.value=e}}var at,Pt,Yr,Kr,se,qo,Yo,M,Yw,eo,Kw,Jw,Bh,Xw,to,kn,Zn,Ko,lc,Jo,cc,Qw,e0,jh,ro,Gh,qh,br;class qw extends HTMLElement{constructor(){super();w(this,M);w(this,at,!1);w(this,Pt,null);w(this,Yr,null);w(this,Kr);w(this,se,null);w(this,qo,Xs());w(this,Yo,new MutationObserver(e=>p(this,M,Qw).call(this,e)));w(this,Zn,()=>{p(this,M,to).call(this,!l(this,at))});w(this,Ko,e=>{e.key!=="Enter"&&e.key!==" "||(e.preventDefault(),l(this,Zn).call(this))});w(this,lc,()=>{l(this,at)&&p(this,M,to).call(this,!1)});w(this,Jo,e=>{e instanceof Gw&&(e.stopPropagation(),b(this,at,!1),p(this,M,eo).call(this,e.value),p(this,M,br).call(this),this.dispatchEvent(new dM(e.value)))});w(this,cc,()=>{p(this,M,jh).call(this)});b(this,Kr,this.attachShadow({mode:"open"})),tp(l(this,Kr))}connectedCallback(){this.addEventListener("dropdown-item-select",l(this,Jo)),p(this,M,Yw).call(this),l(this,Yo).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,Jo)),l(this,Yo).disconnect(),p(this,M,qh).call(this)}attributeChangedCallback(e){if(e==="open"){p(this,M,to).call(this,this.hasAttribute("open"));return}p(this,M,br).call(this)}get open(){return l(this,at)}set open(e){this.toggleAttribute("open",e)}get title(){return this.getAttribute("title")??""}get value(){return l(this,Pt)}set value(e){e===null?(p(this,M,kn).call(this,null,null),p(this,M,Kw).call(this)):p(this,M,eo).call(this,e),p(this,M,br).call(this)}close(){p(this,M,to).call(this,!1)}}at=new WeakMap,Pt=new WeakMap,Yr=new WeakMap,Kr=new WeakMap,se=new WeakMap,qo=new WeakMap,Yo=new WeakMap,M=new WeakSet,Yw=function(){var n;const e=this.querySelector("dropdown-item[selected]");e&&p(this,M,kn).call(this,e.value,((n=e.textContent)==null?void 0:n.trim())??null)},eo=function(e){var n;for(const i of l(this,M,Bh))i.value===e?(p(this,M,kn).call(this,e,((n=i.textContent)==null?void 0:n.trim())??null),i.hasAttribute("selected")||i.setAttribute("selected","")):i.hasAttribute("selected")&&i.removeAttribute("selected")},Kw=function(){const e=this.querySelectorAll("dropdown-item[selected]");for(const n of e)n.removeAttribute("selected")},Jw=function(e){for(const n of l(this,M,Bh))if(n.value===e)return n;return null},Bh=function(){return this.querySelectorAll("dropdown-item")},Xw=function(){return l(this,Yr)??this.title},to=function(e){l(this,at)!==e&&(b(this,at,e),p(this,M,br).call(this))},kn=function(e,n){b(this,Pt,e),b(this,Yr,n)},Zn=new WeakMap,Ko=new WeakMap,lc=new WeakMap,Jo=new WeakMap,cc=new WeakMap,Qw=function(e){e.every(i=>i.target instanceof Element?i.target.closest('[slot="trigger"]')!==null:!1)||p(this,M,e0).call(this)},e0=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,Pt)!==s||l(this,Yr)!==o;p(this,M,kn).call(this,s,o),p(this,M,eo).call(this,s),a?p(this,M,br).call(this):p(this,M,ro).call(this);return}if(l(this,Pt)!==null){const s=p(this,M,Jw).call(this,l(this,Pt));if(s){const o=((i=s.textContent)==null?void 0:i.trim())??null,a=l(this,Yr)!==o;p(this,M,kn).call(this,l(this,Pt),o),p(this,M,eo).call(this,l(this,Pt)),a?p(this,M,br).call(this):p(this,M,ro).call(this);return}}if(l(this,Pt)!==null||l(this,Yr)!==null){p(this,M,kn).call(this,null,null),p(this,M,br).call(this);return}p(this,M,ro).call(this)},jh=function(){const e=l(this,Kr).querySelector('slot[name="trigger"]'),n=e instanceof HTMLSlotElement?e.assignedElements()[0]??null:null;l(this,se)!==n&&(p(this,M,qh).call(this),b(this,se,n),l(this,se)&&(l(this,se).addEventListener("click",l(this,Zn)),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,Ko))))),p(this,M,ro).call(this),p(this,M,Gh).call(this)},ro=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,at)?"true":"false"))},Gh=function(){const e=l(this,qo).value;if(!e)return;const n=l(this,Kr).querySelector("button.fallback-trigger");e.anchor=l(this,se)??n??null},qh=function(){l(this,se)&&(l(this,se).removeEventListener("click",l(this,Zn)),l(this,se).removeEventListener("keydown",l(this,Ko)),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,at)),Ve(P`
|
|
92
|
+
<slot name="trigger" @slotchange=${l(this,cc)}>
|
|
93
93
|
<button
|
|
94
94
|
class="fallback-trigger"
|
|
95
95
|
part="trigger"
|
|
96
96
|
type="button"
|
|
97
97
|
aria-haspopup="listbox"
|
|
98
|
-
aria-expanded=${l(this,
|
|
99
|
-
@click=${l(this,
|
|
98
|
+
aria-expanded=${l(this,at)?"true":"false"}
|
|
99
|
+
@click=${l(this,Zn)}
|
|
100
100
|
>
|
|
101
|
-
<span class="trigger-label" part="trigger-label">${l(this,M,
|
|
101
|
+
<span class="trigger-label" part="trigger-label">${l(this,M,Xw)}</span>
|
|
102
102
|
<span class="trigger-icon" part="trigger-icon" aria-hidden="true">
|
|
103
|
-
${
|
|
103
|
+
${Ql({size:16})}
|
|
104
104
|
</span>
|
|
105
105
|
</button>
|
|
106
106
|
</slot>
|
|
107
107
|
<ui-popover
|
|
108
108
|
class="dropdown-popover"
|
|
109
109
|
material="glass-frosted"
|
|
110
|
-
?open=${l(this,
|
|
111
|
-
@close=${l(this,
|
|
112
|
-
${
|
|
110
|
+
?open=${l(this,at)}
|
|
111
|
+
@close=${l(this,lc)}
|
|
112
|
+
${Qs(l(this,qo))}
|
|
113
113
|
>
|
|
114
|
-
${l(this,
|
|
114
|
+
${l(this,at)?P`<div class="dropdown-list" part="list" role="listbox">
|
|
115
115
|
<slot></slot>
|
|
116
116
|
</div>`:le}
|
|
117
117
|
</ui-popover>
|
|
118
|
-
`,l(this,
|
|
119
|
-
${this.open?
|
|
120
|
-
<div class="backdrop" part="backdrop" @click=${l(this,
|
|
118
|
+
`,l(this,Kr)),p(this,M,Gh).call(this),queueMicrotask(()=>p(this,M,jh).call(this))},g(qw,"observedAttributes",["title","open"]);class pM extends HTMLElement{}class fM extends HTMLElement{}class gM extends HTMLElement{}var si,Yh,r0,Xo,Qo;class t0 extends HTMLElement{constructor(){super(...arguments);w(this,si);w(this,Xo,()=>{this.action||p(this,si,r0).call(this)});w(this,Qo,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,Xo)),this.addEventListener("keydown",l(this,Qo)),p(this,si,Yh).call(this)}disconnectedCallback(){this.removeEventListener("click",l(this,Xo)),this.removeEventListener("keydown",l(this,Qo))}attributeChangedCallback(){p(this,si,Yh).call(this)}get value(){return this.getAttribute("value")??""}get selected(){return this.hasAttribute("selected")}get action(){return this.hasAttribute("action")}}si=new WeakSet,Yh=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")},r0=function(){this.dispatchEvent(new Gw(this.value))},Xo=new WeakMap,Qo=new WeakMap,g(t0,"observedAttributes",["action","selected","value"]);customElements.get("dropdown-menu")||customElements.define("dropdown-menu",qw);customElements.get("dropdown-group")||customElements.define("dropdown-group",pM);customElements.get("dropdown-label")||customElements.define("dropdown-label",fM);customElements.get("dropdown-divider")||customElements.define("dropdown-divider",gM);customElements.get("dropdown-item")||customElements.define("dropdown-item",t0);class mM extends Event{constructor(e){super("rename",{bubbles:!0,composed:!0});g(this,"value");this.value=e}}var rr,Lt,ie,He,no,ea,Kh,Pl,Jh,ta,ra,na;class n0 extends HTMLElement{constructor(){super(...arguments);w(this,He);w(this,rr,"");w(this,Lt,!1);w(this,ie,null);w(this,ea,e=>{l(this,Lt)||(e.preventDefault(),p(this,He,Kh).call(this))});w(this,ta,e=>{e.stopPropagation()});w(this,ra,e=>{var n,i;e.key==="Enter"?(e.preventDefault(),p(this,He,Pl).call(this,!0),(n=l(this,ie))==null||n.blur()):e.key==="Escape"&&(e.preventDefault(),p(this,He,Pl).call(this,!1),(i=l(this,ie))==null||i.blur())});w(this,na,()=>{p(this,He,Pl).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,no).call(this),this.addEventListener("dblclick",l(this,ea))}disconnectedCallback(){this.removeEventListener("dblclick",l(this,ea)),l(this,Lt)&&p(this,He,Jh).call(this)}attributeChangedCallback(e){if(e==="value"){const n=this.getAttribute("value")??"";b(this,rr,n),l(this,Lt)||p(this,He,no).call(this)}}get value(){return l(this,rr)}set value(e){b(this,rr,e),l(this,Lt)||p(this,He,no).call(this)}startEditing(){l(this,Lt)||p(this,He,Kh).call(this)}}rr=new WeakMap,Lt=new WeakMap,ie=new WeakMap,He=new WeakSet,no=function(){l(this,ie)&&(l(this,ie).textContent=l(this,rr),l(this,ie).scrollLeft=0)},ea=new WeakMap,Kh=function(){l(this,ie)&&(b(this,Lt,!0),l(this,ie).setAttribute("contenteditable","plaintext-only"),l(this,ie).setAttribute("spellcheck","false"),l(this,ie).addEventListener("keydown",l(this,ra)),l(this,ie).addEventListener("blur",l(this,na)),l(this,ie).addEventListener("mousedown",l(this,ta)),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))}))},Pl=function(e){if(!l(this,Lt)||!l(this,ie))return;const n=(l(this,ie).textContent??"").trim();b(this,Lt,!1),l(this,ie).removeAttribute("contenteditable"),l(this,ie).removeAttribute("spellcheck"),this.toggleAttribute("data-editing",!1),p(this,He,Jh).call(this),e&&n.length>0&&n!==l(this,rr)&&(b(this,rr,n),this.dispatchEvent(new mM(n))),p(this,He,no).call(this)},Jh=function(){var e,n,i;(e=l(this,ie))==null||e.removeEventListener("keydown",l(this,ra)),(n=l(this,ie))==null||n.removeEventListener("blur",l(this,na)),(i=l(this,ie))==null||i.removeEventListener("mousedown",l(this,ta))},ta=new WeakMap,ra=new WeakMap,na=new WeakMap,g(n0,"observedAttributes",["value"]);customElements.get("editable-text")||customElements.define("editable-text",n0);class vM extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}var ia,ln,Xh,uc,sa,Qh;class i0 extends HTMLElement{constructor(){super();w(this,ln);w(this,ia);w(this,uc,e=>{e.target===e.currentTarget&&p(this,ln,Xh).call(this)});w(this,sa,e=>{this.open&&e.key==="Escape"&&p(this,ln,Xh).call(this)});b(this,ia,this.attachShadow({mode:"open"}))}connectedCallback(){document.addEventListener("keydown",l(this,sa)),p(this,ln,Qh).call(this)}disconnectedCallback(){document.removeEventListener("keydown",l(this,sa))}attributeChangedCallback(){p(this,ln,Qh).call(this)}get open(){return this.hasAttribute("open")}}ia=new WeakMap,ln=new WeakSet,Xh=function(){this.dispatchEvent(new vM)},uc=new WeakMap,sa=new WeakMap,Qh=function(){Ve(P`
|
|
119
|
+
${this.open?P`
|
|
120
|
+
<div class="backdrop" part="backdrop" @click=${l(this,uc)}>
|
|
121
121
|
<slot></slot>
|
|
122
122
|
</div>
|
|
123
123
|
`:null}
|
|
124
|
-
`,l(this,
|
|
124
|
+
`,l(this,ia))},g(i0,"observedAttributes",["open"]);customElements.get("modal-overlay")||customElements.define("modal-overlay",i0);const yM=16,Gu=24,bM=32;var Qi;class s0 extends HTMLElement{constructor(){super();w(this,Qi);b(this,Qi,this.attachShadow({mode:"open"})),tp(l(this,Qi))}connectedCallback(){this.render()}attributeChangedCallback(){this.render()}getSize(){const e=this.getAttribute("size");if(e===null)return Gu;const n=Number(e);return n===yM||n===Gu||n===bM?n:Gu}getWeight(){return this.getAttribute("weight")==="bold"?"bold":"regular"}render(){Ve(P`<span class="spin">${Fw({size:this.getSize(),weight:this.getWeight()})}</span>`,l(this,Qi))}}Qi=new WeakMap,g(s0,"observedAttributes",["size","weight"]);customElements.get("ui-spinner")||customElements.define("ui-spinner",s0);class wM extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}class SM extends HTMLElement{}var oa,aa,ed;class o0 extends HTMLElement{constructor(){super();w(this,aa);w(this,oa);b(this,oa,this.attachShadow({mode:"open"}))}connectedCallback(){p(this,aa,ed).call(this)}attributeChangedCallback(){p(this,aa,ed).call(this)}get closable(){return this.hasAttribute("closable")}}oa=new WeakMap,aa=new WeakSet,ed=function(){const e=this.querySelector("panel-page");Ve(P`
|
|
125
125
|
<section class="panel" part="panel">
|
|
126
126
|
<header class="title-bar" part="header">
|
|
127
127
|
<h2 class="title" part="title">${(e==null?void 0:e.getAttribute("title"))??""}</h2>
|
|
128
|
-
${this.closable?
|
|
128
|
+
${this.closable?P`
|
|
129
129
|
<button
|
|
130
130
|
type="button"
|
|
131
131
|
class="title-button"
|
|
132
132
|
part="button close-button"
|
|
133
133
|
aria-label="Close"
|
|
134
|
-
@click=${()=>this.dispatchEvent(new
|
|
134
|
+
@click=${()=>this.dispatchEvent(new wM)}
|
|
135
135
|
>
|
|
136
|
-
<span class="close-icon" part="icon close-icon">${
|
|
136
|
+
<span class="close-icon" part="icon close-icon">${vp({size:16})}</span>
|
|
137
137
|
</button>
|
|
138
138
|
`:null}
|
|
139
139
|
</header>
|
|
140
140
|
<slot></slot>
|
|
141
141
|
</section>
|
|
142
|
-
`,l(this,
|
|
142
|
+
`,l(this,oa))},g(o0,"observedAttributes",["closable"]);customElements.get("panel-view")||customElements.define("panel-view",o0);customElements.get("panel-page")||customElements.define("panel-page",SM);const _M=`
|
|
143
143
|
<svg viewBox="0 0 12 12" aria-hidden="true" focusable="false">
|
|
144
144
|
<path d="M10.2 3.1 5.1 8.2 2.4 5.5" />
|
|
145
145
|
</svg>
|
|
146
|
-
`,
|
|
146
|
+
`,kM=`
|
|
147
147
|
:host {
|
|
148
148
|
display: block;
|
|
149
149
|
margin: var(--checkbox-list-margin, var(--space-12) 0);
|
|
@@ -153,7 +153,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
153
153
|
display: grid;
|
|
154
154
|
gap: var(--checkbox-list-gap, var(--space-6));
|
|
155
155
|
}
|
|
156
|
-
`,
|
|
156
|
+
`,xM=`
|
|
157
157
|
:host {
|
|
158
158
|
display: block;
|
|
159
159
|
--checkbox-size: 1em;
|
|
@@ -234,26 +234,26 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
234
234
|
text-decoration-line: var(--checkbox-checked-decoration);
|
|
235
235
|
text-decoration-thickness: var(--checkbox-checked-decoration-thickness);
|
|
236
236
|
}
|
|
237
|
-
`;var
|
|
238
|
-
<style>${
|
|
237
|
+
`;var la;class EM extends HTMLElement{constructor(){super();w(this,la);b(this,la,this.attachShadow({mode:"open"})),l(this,la).innerHTML=`<style>${kM}</style><div part="list"><slot></slot></div>`}connectedCallback(){this.hasAttribute("role")||this.setAttribute("role","list")}}la=new WeakMap;var es,ca,ua,td;class a0 extends HTMLElement{constructor(){super();w(this,ua);w(this,es);w(this,ca);b(this,es,this.attachShadow({mode:"open"})),l(this,es).innerHTML=`
|
|
238
|
+
<style>${xM}</style>
|
|
239
239
|
<label part="label">
|
|
240
240
|
<input type="checkbox" disabled tabindex="-1">
|
|
241
|
-
<span part="box"><span part="check">${
|
|
241
|
+
<span part="box"><span part="check">${_M}</span></span>
|
|
242
242
|
<span part="content"><slot></slot></span>
|
|
243
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`
|
|
244
|
+
`;const e=l(this,es).querySelector("input");if(!(e instanceof HTMLInputElement))throw new Error("checkbox-item failed to initialize input");b(this,ca,e)}connectedCallback(){this.hasAttribute("role")||this.setAttribute("role","listitem"),this.setAttribute("aria-disabled","true"),p(this,ua,td).call(this)}attributeChangedCallback(){p(this,ua,td).call(this)}}es=new WeakMap,ca=new WeakMap,ua=new WeakSet,td=function(){const e=this.hasAttribute("checked");l(this,ca).checked=e,this.setAttribute("aria-checked",e?"true":"false")},g(a0,"observedAttributes",["checked"]);customElements.get("checkbox-list")||customElements.define("checkbox-list",EM);customElements.get("checkbox-item")||customElements.define("checkbox-item",a0);const l0=Be(),c0="No handler registered for update-content",u0="handleUpdateContent: handler already registered",Im="television-artifact-bridge";function h0(r){return r instanceof Error&&typeof r.message=="string"?r.message:String(r)}const d0=Ma(Nt);var ts,rs,ns,Wn,Vn,ha,Ze,rd,p0,f0,io,nd,dv;let AM=(dv=class extends d0{constructor(e){super();w(this,Ze);w(this,ts);w(this,rs);w(this,ns);w(this,Wn,null);w(this,Vn,null);w(this,ha,!1);b(this,ts,e);const n=e.ownerDocument.defaultView;if(!n)throw new Error("ArtifactView: iframe has no owner window");b(this,rs,n),b(this,ns,i=>p(this,Ze,p0).call(this,i)),l(this,rs).addEventListener("message",l(this,ns))}get content(){return l(this,Vn)}set content(e){p(this,Ze,nd).call(this),b(this,Vn,e),l(this,ha)&&p(this,Ze,rd).call(this,e)}handleUpdateContent(e){if(p(this,Ze,nd).call(this),l(this,Wn)!==null)throw new Error(u0);b(this,Wn,e)}dispose(){l(this,rs).removeEventListener("message",l(this,ns)),b(this,Wn,null)}},ts=new WeakMap,rs=new WeakMap,ns=new WeakMap,Wn=new WeakMap,Vn=new WeakMap,ha=new WeakMap,Ze=new WeakSet,rd=function(e){const n={type:"content-updated",content:e};p(this,Ze,io).call(this,n)},p0=function(e){if(this.disposed||e.source!==l(this,ts).contentWindow)return;const n=e.data;if(Tb(n)){b(this,ha,!0),this.dispatchEvent(new l0("ready")),l(this,Vn)!==null&&p(this,Ze,rd).call(this,l(this,Vn));return}if($b(n)){p(this,Ze,f0).call(this,n);return}},f0=async function(e){const n=l(this,Wn);if(n===null){p(this,Ze,io).call(this,{type:"response",id:e.id,error:{message:c0}});return}try{await n(e.content)}catch(i){if(this.disposed)return;p(this,Ze,io).call(this,{type:"response",id:e.id,error:{message:h0(i)}});return}this.disposed||p(this,Ze,io).call(this,{type:"response",id:e.id,result:{}})},io=function(e){const n=l(this,ts).contentWindow;n&&n.postMessage(e,"*")},nd=function(){if(this.disposed)throw new Error("ArtifactView is disposed")},dv);var Bn,is,jn,Gn,da,We,id,g0,m0,so,sd;class TM extends d0{constructor(e){super();w(this,We);w(this,Bn);w(this,is);w(this,jn,null);w(this,Gn,null);w(this,da,!1);b(this,Bn,e),b(this,is,n=>p(this,We,g0).call(this,n)),l(this,Bn).addEventListener("ipc-message",l(this,is))}get content(){return l(this,Gn)}set content(e){p(this,We,sd).call(this),b(this,Gn,e),l(this,da)&&p(this,We,id).call(this,e)}handleUpdateContent(e){if(p(this,We,sd).call(this),l(this,jn)!==null)throw new Error(u0);b(this,jn,e)}dispose(){l(this,Bn).removeEventListener("ipc-message",l(this,is)),b(this,jn,null)}}Bn=new WeakMap,is=new WeakMap,jn=new WeakMap,Gn=new WeakMap,da=new WeakMap,We=new WeakSet,id=function(e){const n={type:"content-updated",content:e};p(this,We,so).call(this,n)},g0=function(e){var s;if(this.disposed)return;const n=e.detail??e;if(!n||n.channel!==Im)return;const i=(s=n.args)==null?void 0:s[0];if(Tb(i)){b(this,da,!0),this.dispatchEvent(new l0("ready")),l(this,Gn)!==null&&p(this,We,id).call(this,l(this,Gn));return}if($b(i)){p(this,We,m0).call(this,i);return}},m0=async function(e){const n=l(this,jn);if(n===null){p(this,We,so).call(this,{type:"response",id:e.id,error:{message:c0}});return}try{await n(e.content)}catch(i){if(this.disposed)return;p(this,We,so).call(this,{type:"response",id:e.id,error:{message:h0(i)}});return}this.disposed||p(this,We,so).call(this,{type:"response",id:e.id,result:{}})},so=function(e){var n,i;(i=(n=l(this,Bn)).send)==null||i.call(n,Im,e)},sd=function(){if(this.disposed)throw new Error("WebviewArtifactViewRuntime is disposed")};const Cm="television-artifact-bridge",Rm="/views/url-unsupported/",$M=404,v0=Be(),IM=Be(),CM=Be();class RM 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=tf(e.data),s=su(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(rf(e.data)){this.handleBridgeReady(e.data,n);return}if(i){this.handleBridgeLeaving(e.data.guid);return}if(nf(e.data)){this.dispatchArtifactWheel({deltaX:e.data.deltaX,shiftKey:e.data.shiftKey});return}if(sf(e.data)){this.markLegacyBridgeProofOfLife(e.data,n),this.dispatchArtifactFilmstripKey(e.data.direction);return}if(xS(e.data)){this.markLegacyBridgeProofOfLife(e.data,n),(u=n.contentWindow)==null||u.postMessage({type:ES,url:this.currentExternalTargetURL()},"*");return}if(of(e.data)){this.markLegacyBridgeProofOfLife(e.data,n),(h=n.contentWindow)==null||h.postMessage(this.currentMissingArtifactMessage(),"*");return}if(af(e.data)){this.markLegacyBridgeProofOfLife(e.data,n),this.handleProxyContentChanged();return}if(su(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!==Cm)return;const i=(o=n.args)==null?void 0:o[0];if(!i)return;const s=this._subscribedWebview;if(s){if(rf(i)){this.handleBridgeReady(i,s);return}if(tf(i)){this.handleBridgeLeaving(i.guid);return}if(of(i)){this.markLegacyBridgeProofOfLife(i,s);const c=this.currentMissingArtifactMessage();c&&((a=s.send)==null||a.call(s,Cm,c));return}if(su(i)){this.handleNavigationRequest(i);return}if(nf(i)){this.markLegacyBridgeProofOfLife(i,s),this.dispatchArtifactWheel({deltaX:i.deltaX,shiftKey:i.shiftKey});return}if(sf(i)){this.markLegacyBridgeProofOfLife(i,s),this.dispatchArtifactFilmstripKey(i.direction);return}af(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?!PM(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 v0("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&&qu(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:AS,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||LM(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===Rm||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 CM("artifact-filmstrip-key",{bubbles:!0,composed:!0,direction:e}))}dispatchArtifactWheel(e){this._standaloneScroll||this.dispatchEvent(new IM("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 IO(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=Yl(e,{electron:cr()}),i=this._viewURL??n.viewURL;return e.kind==="url"&&vr(e.url)||n.renderer==="url-webview"?Pr(i):Pm(i,i)}convertIframeNavigationURL(e){var i,s;if(((i=this._artifact)==null?void 0:i.kind)==="url"&&vr(this._artifact.url)&&vr(e))return Pr(e);const n=(s=this.querySelector(".artifact-frame"))==null?void 0:s.getAttribute("src");return Pm(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=Pr(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 TM(e):new AM(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 ip&&a.status===$M){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"&&Eb(this._artifact.path)}missingArtifactTemplate(e){return P`
|
|
245
245
|
<section class="artifact-missing artifact-content" role="status" aria-label="Artifact file not found">
|
|
246
246
|
<div class="artifact-missing-wrapper">
|
|
247
|
-
<h1>${
|
|
248
|
-
<p>${
|
|
247
|
+
<h1>${IS()}</h1>
|
|
248
|
+
<p>${CS()}</p>
|
|
249
249
|
<section class="artifact-missing-path" aria-label="Missing artifact path">
|
|
250
250
|
<p class="artifact-missing-path-label">Registered path:</p>
|
|
251
251
|
<p><code>${e.path}</code></p>
|
|
252
252
|
</section>
|
|
253
|
-
<p>${
|
|
253
|
+
<p>${RS()}</p>
|
|
254
254
|
</div>
|
|
255
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(
|
|
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(vs,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&&(DM(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?P`<webview allowpopups class="artifact-frame artifact-content" src=${a} data-content-url=${c} ?data-bridge-pending=${u}></webview>`:P`<webview allowpopups class="artifact-frame artifact-content" src=${a} ?data-bridge-pending=${u}></webview>`:i.renderer==="markdown"?P`<iframe class="artifact-frame artifact-content" src=${a} data-content-url=${c} ?data-bridge-pending=${u}></iframe>`:P`<iframe class="artifact-frame artifact-content" src=${a} ?data-bridge-pending=${u}></iframe>`}routeForCurrentNavigation(e){var s;const n=Yl(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 qu(i)&&!cr()?vr(i)?{renderer:"proxy-iframe",viewURL:i,contentURL:null}:{renderer:"proxy-iframe",viewURL:Rm,contentURL:null}:qu(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?P`
|
|
257
257
|
<button
|
|
258
258
|
icon-only
|
|
259
259
|
size="sm"
|
|
@@ -262,9 +262,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
262
262
|
@click=${()=>e.back()}
|
|
263
263
|
aria-label="Back"
|
|
264
264
|
>
|
|
265
|
-
${
|
|
265
|
+
${rM({size:16})}
|
|
266
266
|
</button>
|
|
267
|
-
`:
|
|
267
|
+
`:P`
|
|
268
268
|
<button
|
|
269
269
|
icon-only
|
|
270
270
|
size="sm"
|
|
@@ -273,9 +273,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
273
273
|
disabled
|
|
274
274
|
aria-label="No history"
|
|
275
275
|
>
|
|
276
|
-
${
|
|
276
|
+
${oM({size:16,weight:"duotone"})}
|
|
277
277
|
</button>
|
|
278
|
-
`}template(e={preserveFrameSrc:!1}){const n=this._artifact;return
|
|
278
|
+
`}template(e={preserveFrameSrc:!1}){const n=this._artifact;return P`
|
|
279
279
|
${this.contentTemplate(n,e)}
|
|
280
280
|
<footer class="artifact-title-bar" drag-handle material="glass-frosted">
|
|
281
281
|
<div class="artifact-title-group">
|
|
@@ -291,15 +291,15 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
291
291
|
@click=${()=>this.handleClose()}
|
|
292
292
|
aria-label="Close"
|
|
293
293
|
>
|
|
294
|
-
${
|
|
294
|
+
${vp({size:16})}
|
|
295
295
|
</button>
|
|
296
296
|
</div>
|
|
297
297
|
</footer>
|
|
298
|
-
`}render(e={}){this._artifact&&(this.setAttribute("kind",this._artifact.kind),
|
|
298
|
+
`}render(e={}){this._artifact&&(this.setAttribute("kind",this._artifact.kind),Ve(this.template({preserveFrameSrc:e.preserveFrameSrc??!1,frameSrcOverride:e.frameSrcOverride}),this),e.forceFrameSrc&&this.forceCurrentFrameSrc(),this.syncWebviewSubscription(),this.syncEmbedLoadState(),this.syncMarkdownHost())}}function qu(r){return r.startsWith("http://")||r.startsWith("https://")}function PM(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 LM(r){return typeof r=="object"&&r!==null&&"guid"in r}function DM(r,t){try{const e=new URL(r,window.location.href),n=new URL(t,window.location.href);return e.searchParams.delete(vs),n.searchParams.delete(vs),e.origin===n.origin&&e.pathname===n.pathname&&e.search===n.search}catch{return!1}}function Pm(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(vs),`${e.pathname}${e.search}${e.hash}`}}catch{return Pr(r)}return Pr(r)}customElements.define("artifact-view",RM);/**
|
|
299
299
|
* @license
|
|
300
300
|
* Copyright 2017 Google LLC
|
|
301
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`
|
|
302
|
+
*/const Lm=(r,t,e)=>{const n=new Map;for(let i=t;i<=e;i++)n.set(r[i],i);return n},Dm=Zc(class extends mp{constructor(r){if(super(r),r.type!==gp.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=KO(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]=yn(i[f],s[m]),f++,m++;else if(a[y]===o[E])c[E]=yn(i[y],s[E]),y--,E--;else if(a[f]===o[E])c[E]=yn(i[f],s[E]),Fs(r,c[E+1],i[f]),f++,E--;else if(a[y]===o[m])c[m]=yn(i[y],s[m]),Fs(r,i[f],i[y]),y--,m++;else if(u===void 0&&(u=Lm(o,m,E),h=Lm(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 L=Fs(r,i[f]);yn(L,s[m]),c[m]=L}else c[m]=yn(I,s[m]),Fs(r,i[f],I),i[x]=null;m++}else Vu(i[y]),y--;else Vu(i[f]),f++;for(;m<=E;){const x=Fs(r,c[E+1]);yn(x,s[m]),c[m++]=x}for(;f<=y;){const x=i[f++];x!==null&&Vu(x)}return this.ut=o,YO(r,c),ri}}),Ie=r=>({type:"px",...r}),$e=r=>({type:"unit",...r}),ul=2;class zM{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??Qn,n=this._viewport.y??yo,i=this._gap.x??ae,s=this._gap.y??ae,o=e<=kT,a=o?e-i*ul:Math.min(Qn,e-i*ul),c=o?n-s*ul:Math.min(yo,n-s*ul),u=(a-i*(Ye-1))/Ye,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 ni=1e-4,zt=1e-6,OM=40,MM=24;function y0(r,t){return Math.max(0,r-t*2)}function b0(r){const t=[0];for(const e of r)t.push((t[t.length-1]??0)+e);return t}function w0(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 S0(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+ni)break;n=a,i+=1}return Math.max(1,i)}function NM(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+ni)break;n=a,i+=1}return Math.max(1,i)}function UM(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+ni)break;e=o,n+=1}return Math.max(1,n)}function yp(r,t){if(r.length===0)return 0;const e=UM(r,t);return Math.max(0,r.length-e)}function zm(r,t,e){if(r.length===0)return 0;const n=S0(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 od(r,t,e){const n=r[t]??0;return e-n}function Ci(r,t,e,n,i){if(r.length===0)return 0;const s=yp(r,i),o=t[s]??0,a=Math.max(0,Math.min(o,e));let c=0;for(let H=0;H<s;H+=1){const Y=t[H]??0,j=t[H+1]??Y;if(a>=Y&&a<=j+ni){c=H;break}c=H+1}const u=Math.min(c+1,s),h=t[c]??0,f=t[u]??h,y=Math.max(f-h,ni),m=u===c?0:(a-h)/y,E=w0(r),x=zm(r,c,i),I=zm(r,u,i),L=(n-x)/2,R=(n-I)/2,V=od(E,c,L),N=od(E,u,R);return V+(N-V)*m}function FM(r,t,e,n,i){const s=yp(r,n),o=t[s]??0;let a=0,c=o;for(let u=0;u<OM;u+=1){const h=(a+c)/2;Ci(r,t,h,e,n)>i?a=h:c=h}return(a+c)/2}function HM(r,t,e){const n=w0(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 od(n,i,c)}function ZM(r,t,e){const n=S0(r,t,e);return[t,Math.min(r.length-1,t+n-1)]}function WM(r,t,e){const n=NM(r,t,e);return[Math.max(0,t-n+1),t]}function VM(r,t){return r[0]===t[0]&&r[1]===t[1]}function BM(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=y0(n,s),a=b0(t),c=yp(e,o),u=a[c]??0;function h(I){const L=HM(e,I,n),R=FM(e,a,n,o,L);return{nodeRange:I,anchor:Math.max(0,Math.min(u,R))}}const f=[];for(let I=0;I<i;){const L=ZM(e,I,o);f.push(h(L)),I=L[1]+1}const y=h(WM(e,i-1,o)),m=f.filter(I=>I.nodeRange[0]<y.nodeRange[0]),E=m[m.length-1];return{viewspans:E&&VM(E.nodeRange,y.nodeRange)?m:[...m,y],minScroll:0,maxScroll:u}}function Si(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+zt<n){n=o,e=s;continue}Math.abs(o-n)<=zt&&s<e&&(e=s)}return e}function jM(r,t,e){return e<=0?0:Math.max(0,Math.min(e-1,r+t))}function bn(r,t,e){return Math.max(t,Math.min(e,r))}function GM(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)<=zt)return n;return-1}function qM(r,t,e){var i,s;if(r.length===0)return t;const n=GM(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+zt)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-zt)return a.anchor}return((s=r[0])==null?void 0:s.anchor)??t}class YM extends Nt{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:Ci(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=bn(e.x??this._scroll,this._minScroll,this._maxScroll);Math.abs(n-this._scroll)<=zt||(this._scroll=n,this._activeViewspanIndex=Si(this._viewspans,this._scroll),this.dispatchEvent(new wi("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=BM({nodeCols:n,nodeWidthsPx:i,viewportWidthPx:s,gapPx:o});this._nodeWidthsPx=i,this._boundaryCols=b0(n),this._viewportWidthPx=s,this._framedViewportWidthPx=y0(s,o),this._viewspans=a.viewspans,this._minScroll=a.minScroll,this._maxScroll=a.maxScroll;const c=bn(this._scroll,this._minScroll,this._maxScroll);this._activeViewspanIndex=Si(this._viewspans,c);const h=e.snap!==!1?((y=this._viewspans[this._activeViewspanIndex])==null?void 0:y.anchor)??c:c,f=bn(h,this._minScroll,this._maxScroll);Math.abs(f-this._scroll)>zt&&(this._scroll=f,this.dispatchEvent(new wi("layout-scroll",{scroll:this.scroll})))}step(e){var o;if(this._viewspans.length===0)return;const n=jM(this._activeViewspanIndex,e,this._viewspans.length),i=((o=this._viewspans[n])==null?void 0:o.anchor)??this._scroll,s=bn(i,this._minScroll,this._maxScroll);this._activeViewspanIndex=n,!(Math.abs(s-this._scroll)<=zt)&&(this._scroll=s,this.dispatchEvent(new wi("layout-scroll",{scroll:this.scroll})))}snap(e){var s;if(this._viewspans.length===0)return;const n=e===void 0?((s=this._viewspans[Si(this._viewspans,this._scroll)])==null?void 0:s.anchor)??this._scroll:qM(this._viewspans,this._scroll,e),i=bn(n,this._minScroll,this._maxScroll);this._activeViewspanIndex=Si(this._viewspans,i),!(Math.abs(i-this._scroll)<=zt)&&(this._scroll=i,this.dispatchEvent(new wi("layout-scroll",{scroll:this.scroll})))}wheel(e){const n=bn(this._scroll+(e.x??0),this._minScroll,this._maxScroll);Math.abs(n-this._scroll)<=zt||(this._scroll=n,this._activeViewspanIndex=Si(this._viewspans,this._scroll),this.dispatchEvent(new wi("layout-scroll",{scroll:this.scroll})))}wheelPixels(e){const n=e.x??0;if(Math.abs(n)<=ni)return;const i=Ci(this._nodeWidthsPx,this._boundaryCols,this._scroll,this._viewportWidthPx,this._framedViewportWidthPx),s=i-n,o=Ci(this._nodeWidthsPx,this._boundaryCols,this._maxScroll,this._viewportWidthPx,this._framedViewportWidthPx),a=Ci(this._nodeWidthsPx,this._boundaryCols,this._minScroll,this._viewportWidthPx,this._framedViewportWidthPx),c=Math.max(o,Math.min(a,s));if(Math.abs(c-i)<=ni)return;let u=this._minScroll,h=this._maxScroll;for(let y=0;y<MM;y+=1){const m=(u+h)/2;Ci(this._nodeWidthsPx,this._boundaryCols,m,this._viewportWidthPx,this._framedViewportWidthPx)>c?u=m:h=m}const f=bn((u+h)/2,this._minScroll,this._maxScroll);Math.abs(f-this._scroll)<=zt||(this._scroll=f,this._activeViewspanIndex=Si(this._viewspans,this._scroll),this.dispatchEvent(new wi("layout-scroll",{scroll:this.scroll})))}}const Yu={"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}},KM=["stack-above","stack-below","reorder-before","reorder-after"];function Ku(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 wn(r,t,e){return r>=e.left&&r<e.left+e.width&&t>=e.top&&t<e.top+e.height}function Ui(r){return r.artifactID}function ad(r){return Number.isFinite(r)?Math.max(vo,Math.min(rp,Math.round(r))):vo}function JM(r,t,e){const n=r.findIndex(a=>a.type==="card"&&Ui(a)===t);if(n===-1)return r;const i=r[n];if(!i||i.type!=="card")return r;const s=ad(e);if(i.width===s)return r;const o=[...r];return o[n]={...i,width:s},o}function _0(r,t){for(const e of r){if(e.type==="card"&&Ui(e)===t)return e;if(e.type==="stack")for(const n of e.children){if(n.type==="card"&&Ui(n)===t)return n;if(n.type==="row"){for(const i of n.children)if(Ui(i)===t)return i}}}return null}function ld(r){const t=r.height===ft||r.height===nn?nn:r.height;return r.width===Ye&&r.height===t?r:{...r,width:Ye,height:t}}function cd(r){return r.height===nn?{...r,height:ft}:r}function XM(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"&&Ui(h)===e);if(!o||o.type!=="card")return r;const a=s.children.filter(h=>h.type!=="card"||Ui(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"?cd(h):h}else c[i]={...s,children:a};const u=Math.max(0,Math.min(n,c.length));return c.splice(u,0,cd(o)),c}const QM=Be(),eN=Be(),tN=50;function rN(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 et(r){return r.artifactID}function Om(r){return r.type==="card"?et(r):r.id}function Ua(r){return{id:et(r),type:"drop-target",width:r.width,height:r.height}}function Mm(r){return r.map(iN)}function nN(r){return r.type==="drop-target"?{type:"card",artifactID:r.id,width:r.width,height:r.height}:r}function iN(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(nN)}:r}function k0(r,t){return r.find(n=>n.type==="card"&&et(n)===t)??null}function Nm(r,t){return r.find(n=>n.type==="stack"&&n.id===t)??null}function sN(r,t){const e=[...t],n=e.findIndex(a=>a.type==="card"&&et(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"&&et(a)===r.nodeId);return o===-1?null:{base:e,visualDraggedIndex:o}}function oN(r,t,e,n){const i=[...r.base];i.splice(r.visualDraggedIndex,1);const s=i.findIndex(y=>y.type==="card"&&et(y)===e.targetCardId),o=s===-1?null:i[s];if(!o||o.type!=="card")return null;const a=k0(n,t.nodeId);if(!a)return null;const c=ld(a),u=ld(o),h=Ua(c),f=e.position==="above"?[h,u]:[u,h];return i[s]={id:et(o),type:"stack",children:f},i}function Ju(r,t){return r.parentStackId?lN(r,t):aN(r,t)}function aN(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,Ua(n)),i}if(e.type==="stack"){const n=sN(r,t);return n?oN(n,r,e,t)??[...t]:[...t]}return[...t]}function lN(r,t){const e=r.hitTarget;switch(e.type){case"stack-child-reorder":return cN(r,t,e.position);case"stack-child-extract":return uN(r,t,e.toIndex);case"stack-child-noop":return hN(r,t);default:return[...t]}}function cN(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=>et(y)===r.nodeId);if(o===-1)return[...t];const a=s[o],c=s.filter(y=>et(y)!==r.nodeId),u=Ua(a),h=e==="above"?[u,...c]:[...c,u],f=[...t];return f[n]={...i,children:h},f}function uN(r,t,e){if(!r.parentStackId)return[...t];const n=XM(t,r.parentStackId,r.nodeId,e);if(n===t)return[...t];const i=n.findIndex(a=>a.type==="card"&&et(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]=Ua(s),o}function hN(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"&&et(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]=Ua(s),o[e]={...n,children:a},o}function dN(r,t){return t.find(n=>n.type==="stack"&&n.id===r.id)?r.id:Cc()}function pN(r,t,e){if(r.type==="drop-target"){const n=_0(t,e);if(!n)throw new Error(`finalize: missing dragged card ${e}`);return ld(n)}return r}function fN(r,t,e){const n=r.children.map(s=>pN(s,t,e));return{id:dN(r,t),type:"stack",children:n}}function gN(r,t,e){if(r.type==="drop-target"){const n=_0(t,e);if(!n)throw new Error(`finalize: missing dragged card ${e}`);return k0(t,e)!==null?n:cd(n)}return r.type==="card"||r.type==="row"?r:fN(r,t,e)}function mN(r,t,e){return r.map(n=>gN(n,t,e))}function vN(r,t){return JSON.stringify(r)===JSON.stringify(t)}const yN=Ma(Nt);class bN extends yN{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)>=ET&&(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=Ju(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&&rN(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=Ju(this.active,e),s=mN(i,e,this.active.nodeId);vN(s,e)||(n=s)}catch{n=null}this.reset(),n&&this.dispatchEvent(new eN("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=Ju(this.active,this.active.baseLayout);this.dispatchEvent(new QM("drag",{nodeId:this.active.nodeId,source:{index:this.active.sourceIndex,parentId:this.active.parentStackId},grabOffset:Ie({x:this.active.grabOffsetX,y:this.active.grabOffsetY}),pointer:Ie({x:this.active.pointerX,y:this.active.pointerY}),size:Ie({x:this.active.width,y:this.active.height}),projectedLayout:e}))}getHitTargetForPointer(e,n,i,s){return this.active?this.isPointerInsideDragBounds(e,n,i.viewport)?this.active.parentStackId?this.getStackChildHitTarget(e,n,i,s):this.getTopLevelCardHitTarget(e,n,i,s):{type:"reorder",index:this.active.sourceIndex}:{type:"reorder",index:0}}getStackChildHitTarget(e,n,i,s){var u;if(!((u=this.active)!=null&&u.parentStackId))return{type:"stack-child-noop"};const o=this.getSourceStackInteractionRect(i.geometry);if(o&&wn(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&&wn(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=Nm(this.active.baseLayout,this.active.parentStackId);if(!n)return;const i=n.children.find(a=>{var c;return a.type==="card"&&et(a)!==((c=this.active)==null?void 0:c.nodeId)});if(i)return(o=e.find(a=>a.id===et(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=Nm(this.active.baseLayout,this.active.parentStackId);if(!i)return this.active.sourceStackRect;const s=i.children.find(a=>{var c;return a.type==="card"&&et(a)!==((c=this.active)==null?void 0:c.nodeId)});if(s){const a=e.find(c=>c.id===et(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)<=tN;for(const I of o){const L=I.rect;if(!wn(e,n,L))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(!wn(e,n,f.rect))continue;const y=Ku(f.rect,Yu["reorder-before"]);if(wn(e,n,y))return f.logicalIndex;const m=Ku(f.rect,Yu["reorder-after"]);if(wn(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=>[Om(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:Om(c),rect:a.rect,logicalIndex:o}),o+=1)}return s}resolveTopLevelTargetForCard(e,n,i,s,o){const a=i.rect;for(const c of KM){if(!o&&(c==="stack-above"||c==="stack-below"))continue;const u=Yu[c],h=Ku(a,u);if(wn(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 wN=100,SN=1e3;class _N{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)<TT?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-wN;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*SN}}function Oi(r){return r.artifactID}function kN(r){return r.type==="card"?Oi(r):r.id}function xN({baseLayout:r,visibleLayout:t,resolved:e,cardsByID:n,grid:i,dragState:s,isForeground:o}){var E;const a=new Map(t.map(x=>[kN(x),x])),c=e.nodes.map((x,I)=>{const L=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 H=n.get(N.artifactID);H&&R.push({key:Oi(H),kind:"card",card:H,placement:N,isTopLevelCard:(L==null?void 0:L.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 H={key:Oi(N),kind:"card",card:N,placement:null,isTopLevelCard:!1,isDragged:!0,sourceStackId:s.source.parentId},Y=EN(r,s.source.parentId,s.nodeId),j=Y<0?R.length:Math.min(Y,R.length);R.splice(j,0,H)}}const V=!!(s&&(L==null?void 0:L.type)==="card"&&Oi(L)===s.nodeId);return{key:V?`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:V,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=$n(r).nodes[s.source.index])==null?void 0:E.width)??Ye,y={key:h,kind:"ghost",nodeId:h,widthPx:0,widthUnits:f,layoutIndex:null,isForeground:!1,isPlaceholder:!1,slots:[{key:Oi(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 Um(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 EN(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"&&Oi(i)===e)}const AN=2,Fm=1e3,_i=1e-4,TN=120,Hm=!1;function Zm(r){return r.replace(/["\\]/g,"\\$&")}function we(r){return r.artifactID}function Fi(r){return r.type==="card"?we(r):r.id}function Wm(r,t,e){if(r===0)return 0;const n=t.toPixels($e({y:ft})).y??0;return(e-n)/AN}function Xu(r){const t=r.clientWidth>0?r.clientWidth:Qn,e=r.clientHeight>0?r.clientHeight:yo;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=yo+ae*2,c=Math.min(o,Math.max(0,s-a));return{width:t,height:s-c,offsetY:n}}function $N(r){return r.shiftKey&&r.deltaX===0&&r.deltaY!==0?r.deltaY:r.deltaX}function IN(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 CN extends Event{constructor(e){super("scroll",{bubbles:!0,composed:!0});g(this,"scrollPosition");this.scrollPosition=e}}class x0 extends Event{constructor(e){super("layout-change",{bubbles:!0,composed:!0});g(this,"layout");this.layout=e}}class RN extends HTMLElement{constructor(){super();g(this,"_layout",[]);g(this,"_scrollPosition",0);g(this,"layoutGrid",null);g(this,"layoutScroll",new YM($e({x:0})));g(this,"scrollModelKey","");g(this,"resizeObserver",null);g(this,"renderPending",!1);g(this,"animateNextRender",!0);g(this,"swipeGesture",new _N(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 bN);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=Um(e),s=LN(e.projectedLayout);if(n!==this.lastProjectedDragLayoutSignature||i!==this.lastDragDropIntent||s!==this.lastActivePlaceholderId){const u=Mm(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)<_i||(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"&&(IN(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=$N(e);Math.abs(n)<_i||(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(TS(e.data)){const i=typeof performance<"u"?performance.now():Date.now();this.swipeGesture.status==="idle"&&this.swipeGesture.start(i),this.swipeGesture.move(i,e.data.deltaX);return}if($S(e.data)){this.swipeGesture.status==="active"&&this.swipeGesture.end();return}}});g(this,"handleArtifactFilmstripKey",e=>{this._layout.length!==0&&this.stepFilmstrip(e.direction)});g(this,"handleArtifactWheel",e=>{this._layout.length!==0&&(Math.abs(e.deltaX)<_i||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=DN(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)??Fr)+ae;if(s<=0)return;const o=e.clientX-n.startClientX,a=ad(n.startWidth+o/s);a!==n.currentWidth&&(n.currentWidth=a,this.scheduleRender())});g(this,"handleResizePointerUp",e=>{const n=this.resizeState;if(!n||e.pointerId!==n.pointerId)return;const i=n.currentWidth,s=n.startWidth,o=n.cardId;this.endResize(e.pointerId),i!==s?this.commitLayout(JM(this._layout,o,i)):this.scheduleRender()});g(this,"handleResizePointerCancel",e=>{!this.resizeState||e.pointerId!==this.resizeState.pointerId||(this.endResize(e.pointerId),this.scheduleRender())});g(this,"handleResizeWindowBlur",()=>{this.resizeState&&(this.endResize(this.resizeState.pointerId),this.scheduleRender())});g(this,"handleResizeKeyDown",e=>{this.resizeState&&e.key==="Escape"&&(e.preventDefault(),this.endResize(this.resizeState.pointerId),this.scheduleRender())});g(this,"handleSwipePointerMove",e=>{if(this.swipePointerId===null||e.pointerId!==this.swipePointerId)return;if(!this.swipeActive){const i=e.clientX-this.swipeStartX,s=e.clientY-this.swipeStartY,o=Math.abs(i),a=Math.abs(s);if(o<Mg&&a<Mg)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)/Fm;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>_i?Math.abs(o)/n:0,Math.abs(o)>_i&&(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)<_i||(this.animateNextRender=!1,this.syncScrollModel(),this.layoutScroll.scroll=$e({x:e}))}get scrollPosition(){return this._scrollPosition}focusArtifact(e){const n=$n(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="${Zm(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 zM({basis:Ie({x:Fr,y:Fr}),min:Ie({x:zg,y:zg}),viewport:Ie({x:e,y:n}),gap:Ie({x:ae,y:ae})})}syncScrollModel(){const e=Xu(this),i=$n(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:Hm}))}emitScrollPositionChanged(e){this.dispatchEvent(new CN(e))}emitLayoutChanged(){this.dispatchEvent(new x0([...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()},TN)}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=ad(typeof s.width=="number"?s.width:Ye);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):Mm(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?P`
|
|
303
303
|
<div
|
|
304
304
|
class="card-slot card-placeholder"
|
|
305
305
|
data-layout-placeholder-for=${(n==null?void 0:n.nodeId)??""}
|
|
@@ -307,7 +307,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
307
307
|
data-layout-source-stack=${e.sourceStackId??""}
|
|
308
308
|
style=${this.getGridSlotStyle(e.placement)}
|
|
309
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
|
|
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 P`
|
|
311
311
|
<div
|
|
312
312
|
class="card-slot"
|
|
313
313
|
data-layout-card-id=${we(i)}
|
|
@@ -317,13 +317,13 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
317
317
|
style=${s}
|
|
318
318
|
>
|
|
319
319
|
<div class="card-content-mount" data-mount-for=${we(i)}></div>
|
|
320
|
-
${e.isTopLevelCard&&!e.isDragged?
|
|
320
|
+
${e.isTopLevelCard&&!e.isDragged?P`<div
|
|
321
321
|
class="resize-handle"
|
|
322
322
|
data-resize-handle=${we(i)}
|
|
323
323
|
data-test-resize-handle=${we(i)}
|
|
324
324
|
></div>`:null}
|
|
325
325
|
</div>
|
|
326
|
-
`}renderNode(e,n){return
|
|
326
|
+
`}renderNode(e,n){return P`
|
|
327
327
|
<div
|
|
328
328
|
class=${e.kind==="ghost"?"drag-source-node":"node"}
|
|
329
329
|
layout-node=${String(e.layoutIndex??"")}
|
|
@@ -334,14 +334,14 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
334
334
|
style=${e.kind==="visible"?`width: ${e.widthPx}px; --card-width-px: ${e.widthPx};`:""}
|
|
335
335
|
>
|
|
336
336
|
<div class="node-inner" style=${`grid-template-columns: repeat(${e.widthUnits}, var(--layout-unit-x));`}>
|
|
337
|
-
${
|
|
337
|
+
${Dm(e.slots,i=>i.key,i=>this.renderSlot(i,n))}
|
|
338
338
|
</div>
|
|
339
339
|
</div>
|
|
340
|
-
`}render(){var Y;const e=
|
|
340
|
+
`}render(){var Y;const e=Xu(this),n=this.createGrid(e.width,e.height);this.layoutGrid=n;const i=this.getVisibleLayout(),s=this.dragController.status==="active",o=$n(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:Hm}),this._scrollPosition=this.layoutScroll.scroll.x??this._scrollPosition);const u=PN(this._layout),h=n.unit.x??Fr,f=n.unit.y??Fr,y=s?this.dragTrackOffsetXPx:0,m=(this.layoutScroll.translate.x??0)+y,E=Wm(o.nodes.length,n,e.height),x=this.animateNextRender&&!s,I=[`transform: translate(${m}px, ${E}px);`,`transition-duration: ${x?xT: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 L=this.dragState,R=new Set;{let j=m;for(let ce=0;ce<o.nodes.length;ce+=1){const Tt=n.toPixels($e({x:o.nodes[ce].width})).x??0,pn=j+Tt;j>=-1&&pn<=e.width+1&&R.add(ce),j=pn+ae}}const V=j=>R.has(j),N=xN({baseLayout:this._layout,visibleLayout:i,resolved:o,cardsByID:u,grid:n,dragState:this.dragState,isForeground:V}),H=Um(this.dragState);if(H?this.setAttribute("data-test-drop-intent",H):this.removeAttribute("data-test-drop-intent"),this.dragState){let j=null;for(const ce of o.nodes){for(const Tt of ce.cards)if(Tt.artifactID===this.dragState.nodeId){j={width:n.toPixels($e({x:Tt.width})).x??0,height:n.toPixels($e({y:Tt.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;Ve(P`
|
|
341
341
|
<div class="track" style=${I}>
|
|
342
|
-
${
|
|
342
|
+
${Dm(N,j=>j.key,j=>this.renderNode(j,L))}
|
|
343
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`
|
|
344
|
+
`,this),this.syncCardElements(u,L?((Y=u.get(L.nodeId))==null?void 0:Y.artifactID)??null:null),this.syncDraggedSlotElement(L)}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*Fm,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+il,o=n.left+n.width-il,a=((u=this.layoutGrid)==null?void 0:u.unit.x)??Fr,c=AT*a;if(e<s){const h=Math.max(0,Math.min(1,(s-e)/il));return-(c*h**Og)*i}if(e>o){const h=Math.max(0,Math.min(1,(e-o)/il));return c*h**Og*i}return 0}measureLayoutGeometry(e,n=0){const i=this.layoutGrid;if(!i)return[];const s=$n(e),o=new Map(s.nodes.map(E=>[E.id,E.width])),a=i.toPixels($e({y:ft})).y??yo,c=Xu(this),u=(this.layoutScroll.translate.x??0)+n,h=Wm(s.nodes.length,i,c.height),f=c.offsetY+h,y=[];let m=u;for(const E of e){const x=Fi(E),I=o.get(x)??Ye,L=i.toPixels($e({x:I})).x??Qn,R={left:m,top:f,width:L,height:a};y.push({id:x,rect:R}),m+=L+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="${Zm(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?Bm(e,c,this.layoutGrid):jm(e,c,this.layoutGrid),h=s?Bm(n,c,this.layoutGrid):jm(n,c,this.layoutGrid);return u===null||h===null?a:a+(u-h)}getStableAnchorCardId(e,n,i){const s=Vm(e),o=new Set(Vm(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(Fi));for(const o of e){const a=Fi(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 PN(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 LN(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 DN(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 Vm(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 Bm(r,t,e){if(!e)return null;const n=$n(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(Fi(o))??Ye,c=e.toPixels($e({x:a})).x??Qn;s+=c+ae}return null}function jm(r,t,e){if(!e)return null;const n=$n(r),i=new Map(n.nodes.map(o=>[o.id,o.width]));let s=0;for(const o of r){if(Fi(o)===t)return s;const a=i.get(Fi(o))??Ye,c=e.toPixels($e({x:a})).x??Qn;s+=c+ae}return null}customElements.get("layout-view")||customElements.define("layout-view",RN);class zN 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 v0&&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 x0&&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){Ve(P``,this);return}Ve(P`
|
|
345
345
|
<layout-view
|
|
346
346
|
.layout=${n}
|
|
347
347
|
.cards=${i}
|
|
@@ -350,33 +350,34 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
350
350
|
@layout-change=${this.handleLayoutChanged}
|
|
351
351
|
@close-artifact=${this.handleCloseArtifact}
|
|
352
352
|
></layout-view>
|
|
353
|
-
`,this)}}customElements.define("screen-view",
|
|
354
|
-
${p(this,
|
|
353
|
+
`,this)}}customElements.define("screen-view",zN);function ec(r){return typeof r=="object"&&r!==null}const Qu=new WeakMap,Gm=Object.prototype.hasOwnProperty,ON=(()=>{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 MN(r,t){if(ec(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 NN(r,t){return ec(r)?t==null?null:r.serialize(t):r===Boolean?t?"":null:t==null?null:String(t)}var pa,ud,qn,mt,nr,ss,Yn,os,xe,Ri,E0,A0,T0,$0,Ll;const An=class An extends HTMLElement{constructor(){var i;super();w(this,xe);w(this,qn,new Map);w(this,mt,new Map);w(this,nr,new Map);w(this,ss,!1);w(this,Yn,!1);w(this,os,!1);const e=p(i=An,pa,ud).call(i,this.constructor),n=this;for(const s of e.properties)Gm.call(n,s)&&(l(this,nr).set(s,n[s]),delete n[s])}static get observedAttributes(){var e;return p(e=An,pa,ud).call(e,this).observedAttributes}connected(){}disconnected(){}changed(e){}connectedCallback(){if(p(this,xe,$0).call(this),!l(this,Yn))for(const e of p(this,xe,Ri).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,Ll).call(this)}disconnectedCallback(){this.dispatchEvent(new Event("reactive:disconnect")),this.disconnected()}attributeChangedCallback(e,n,i){if(n===i)return;const s=p(this,xe,Ri).call(this).byAttr.get(e);s&&(l(this,nr).has(s.property)||(this[s.property]=MN(s.type,i)))}};pa=new WeakSet,ud=function(e){const n=Qu.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(ON.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(ec(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,qn).get(u)},set(f){p(this,xe,E0).call(this,u,f)}})}const c={properties:i,observedAttributes:Object.keys(s),byAttr:o,byProp:a};return Qu.set(e,c),c},qn=new WeakMap,mt=new WeakMap,nr=new WeakMap,ss=new WeakMap,Yn=new WeakMap,os=new WeakMap,xe=new WeakSet,Ri=function(){return Qu.get(this.constructor)},E0=function(e,n){if(!l(this,os)&&l(this,nr).has(e))return;const i=l(this,qn).get(e);p(this,xe,A0).call(this,e,i,n)||(l(this,mt).has(e)||l(this,mt).set(e,i),l(this,qn).set(e,n),l(this,nr).delete(e),p(this,xe,T0).call(this,e,n),this.isConnected&&p(this,xe,Ll).call(this))},A0=function(e,n,i){if(Object.is(n,i))return!0;const s=p(this,xe,Ri).call(this).byProp.get(e);if(!s||!ec(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}},T0=function(e,n){const i=p(this,xe,Ri).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=NN(o,n);if(a===null){this.hasAttribute(s)&&this.removeAttribute(s);return}this.getAttribute(s)!==a&&this.setAttribute(s,a)},$0=function(){const e=this,n=p(this,xe,Ri).call(this);for(const i of n.properties){if(!Gm.call(e,i))continue;const s=e[i];delete e[i],!(l(this,nr).has(i)||l(this,qn).has(i))&&(e[i]=s)}b(this,os,!0);try{for(const[i,s]of l(this,nr))e[i]=s;l(this,nr).clear()}finally{b(this,os,!1)}},Ll=function(){l(this,ss)||!this.isConnected||l(this,Yn)&&l(this,mt).size===0||(b(this,ss,!0),queueMicrotask(()=>{if(b(this,ss,!1),!this.isConnected||l(this,Yn)&&l(this,mt).size===0)return;const e=new Map(l(this,mt));l(this,mt).clear(),b(this,Yn,!0);try{this.changed(e)}catch(n){console.error(n)}this.isConnected&&l(this,mt).size>0&&p(this,xe,Ll).call(this)}))},w(An,pa),g(An,"properties"),g(An,"attributes");let bs=An;var fe,Tr,Jr,as,Xr,$r,fa,ga,Te,ls,Ir,ir,F,I0,ma,va,ya,ba,hd,dd,pd,C0,R0,P0,L0,hc,dc,pc,fc,fd,D0,Dl,z0,wa,gc,mc,oo,vc,O0,M0,N0,U0,F0,H0,qe;class UN extends bs{constructor(){super(...arguments);w(this,F);w(this,fe,hr.resolve("ScreenManager"));w(this,Tr,hr.resolve("ServerManager"));w(this,Jr,null);w(this,as,new DisposableStack);w(this,Xr,Xs());w(this,$r,Xs());w(this,fa,Xs());w(this,ga,Xs());w(this,Te,{kind:"none"});w(this,ls,!1);w(this,Ir,null);w(this,ir,[]);w(this,ma,()=>{p(this,F,hd).call(this),b(this,Te,{kind:"none"}),l(this,qe).call(this)});w(this,va,()=>{l(this,qe).call(this)});w(this,ya,()=>{l(this,qe).call(this)});w(this,ba,()=>{l(this,qe).call(this)});w(this,hc,()=>{var i,s;if(l(this,Te).kind==="picker"){p(this,F,oo).call(this);return}b(this,ir,p(this,F,D0).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,qe).call(this),queueMicrotask(()=>{var o;(o=l(this,fa).value)==null||o.focus()})});w(this,dc,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,F,Dl).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,qe).call(this)});w(this,pc,e=>{var s;const n=l(this,Te);if(n.kind!=="picker"||e.target instanceof Element&&e.target.closest(".picker-row-delete")!==null)return;if(e.key==="Escape"){e.preventDefault(),p(this,F,oo).call(this),(s=l(this,Xr).value)==null||s.focus();return}const i=p(this,F,Dl).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,qe).call(this);return}if(e.key==="Enter"){e.preventDefault();const o=i.find(a=>a.screenID===n.highlightedID);o&&p(this,F,fd).call(this,o)}});w(this,fc,e=>{p(this,F,fd).call(this,e)});w(this,wa,()=>{var e;l(this,Ir)!==null&&(b(this,Ir,null),l(this,qe).call(this),(e=l(this,Xr).value)==null||e.focus())});w(this,gc,()=>{var i;const e=l(this,Ir);if(e===null)return;b(this,Ir,null),l(this,qe).call(this);const n=l(this,Tr).servers.get(e.serverURL);n==null||n.client.screens.remove({screenID:e.screenID}).catch(()=>{}),(i=l(this,Xr).value)==null||i.focus()});w(this,mc,e=>{l(this,Te).kind==="picker"&&e.target===l(this,$r).value&&(b(this,Te,{kind:"none"}),l(this,qe).call(this))});w(this,vc,async()=>{if(l(this,ls))return;const e=p(this,F,O0).call(this);if(e){b(this,ls,!0);try{const n=await e.createScreen(FN(new Date));l(this,fe).addTab(e.url,n.id),l(this,fe).setActive(e.url,n.id)}catch{}finally{b(this,ls,!1)}}});w(this,qe,()=>{const e=p(this,F,P0).call(this);Ve(P`
|
|
354
|
+
${p(this,F,M0).call(this)}
|
|
355
355
|
<div class="pills" role="group" aria-label="Open tabs">
|
|
356
|
-
${e.map(n=>p(this,
|
|
356
|
+
${e.map(n=>p(this,F,N0).call(this,n))}
|
|
357
357
|
</div>
|
|
358
|
-
${p(this,
|
|
359
|
-
|
|
358
|
+
${p(this,F,U0).call(this)}
|
|
359
|
+
${p(this,F,H0).call(this)}
|
|
360
|
+
`,this),l(this,$r).value&&(l(this,$r).value.anchor=l(this,Xr).value??null)})}connected(){l(this,fe).addEventListener("active-screen-changed",l(this,ma)),l(this,fe).addEventListener("tabs-changed",l(this,va)),l(this,Tr).addEventListener("screens-changed",l(this,ya)),p(this,F,hd).call(this),l(this,qe).call(this),p(this,F,I0).call(this),l(this,as).defer(()=>{l(this,fe).removeEventListener("active-screen-changed",l(this,ma)),l(this,fe).removeEventListener("tabs-changed",l(this,va)),l(this,Tr).removeEventListener("screens-changed",l(this,ya)),p(this,F,dd).call(this)})}disconnected(){l(this,as).dispose(),b(this,as,new DisposableStack)}}fe=new WeakMap,Tr=new WeakMap,Jr=new WeakMap,as=new WeakMap,Xr=new WeakMap,$r=new WeakMap,fa=new WeakMap,ga=new WeakMap,Te=new WeakMap,ls=new WeakMap,Ir=new WeakMap,ir=new WeakMap,F=new WeakSet,I0=async function(){const e=await fy(this);this.setAttribute("tone",e)},ma=new WeakMap,va=new WeakMap,ya=new WeakMap,ba=new WeakMap,hd=function(){var n;const e=l(this,fe).activeScreen;l(this,Jr)!==e&&(p(this,F,dd).call(this),b(this,Jr,e),(n=l(this,Jr))==null||n.addEventListener("change",l(this,ba)))},dd=function(){var e;(e=l(this,Jr))==null||e.removeEventListener("change",l(this,ba)),b(this,Jr,null)},pd=function(e,n){l(this,fe).setActive(e,n)},C0=function(e,n,i){i.stopPropagation();const s=l(this,fe).getTabs(e),o=p(this,F,L0).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())},R0=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,Tr).servers.get(e),a=o==null?void 0:o.screens.get(n);!o||!a||o.client.screens.update({screenID:n,name:i.value}).catch(()=>{})},P0=function(){const e=l(this,fe).activeScreen,n=[];for(const i of l(this,Tr).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},L0=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},hc=new WeakMap,dc=new WeakMap,pc=new WeakMap,fc=new WeakMap,fd=function(e){l(this,fe).addTab(e.serverURL,e.screenID),l(this,fe).setActive(e.serverURL,e.screenID),p(this,F,oo).call(this)},D0=function(){return l(this,fe).screens.map(e=>({serverURL:e.server.url,screenID:e.screen.id,name:e.screen.name}))},Dl=function(e,n){const i=n.trim().toLowerCase();return i.length===0?e:e.filter(s=>s.name.toLowerCase().includes(i))},z0=function(e,n){n.stopPropagation(),p(this,F,oo).call(this),b(this,Ir,e),l(this,qe).call(this),queueMicrotask(()=>{var i;(i=l(this,ga).value)==null||i.focus()})},wa=new WeakMap,gc=new WeakMap,mc=new WeakMap,oo=function(){l(this,Te).kind==="picker"&&(l(this,$r).value&&(l(this,$r).value.open=!1),b(this,Te,{kind:"none"}),l(this,qe).call(this))},vc=new WeakMap,O0=function(){for(const e of l(this,Tr).servers.values())return e;return null},M0=function(){return P`
|
|
360
361
|
<segmented-control variant="glass" role="group" aria-label="Screens">
|
|
361
362
|
<button
|
|
362
363
|
type="button"
|
|
363
364
|
?icon-only=${!0}
|
|
364
365
|
aria-label="Choose screen"
|
|
365
|
-
@click=${l(this,
|
|
366
|
-
${
|
|
366
|
+
@click=${l(this,hc)}
|
|
367
|
+
${Qs(l(this,Xr))}
|
|
367
368
|
>
|
|
368
|
-
${
|
|
369
|
+
${aM({size:16,weight:"regular"})}
|
|
369
370
|
</button>
|
|
370
371
|
<button
|
|
371
372
|
type="button"
|
|
372
373
|
?icon-only=${!0}
|
|
373
374
|
aria-label="New screen"
|
|
374
|
-
@click=${l(this,
|
|
375
|
+
@click=${l(this,vc)}
|
|
375
376
|
>
|
|
376
|
-
${
|
|
377
|
+
${lM({size:16,weight:"regular"})}
|
|
377
378
|
</button>
|
|
378
379
|
</segmented-control>
|
|
379
|
-
`},
|
|
380
|
+
`},N0=function(e){return P`
|
|
380
381
|
<span class="tab" ?data-active=${e.isActive}>
|
|
381
382
|
<button
|
|
382
383
|
type="button"
|
|
@@ -385,16 +386,16 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
385
386
|
aria-pressed=${e.isActive?"true":"false"}
|
|
386
387
|
aria-current=${e.isActive?"page":le}
|
|
387
388
|
aria-label=${e.isActive?`Current tab: ${e.name}`:`Switch to ${e.name}`}
|
|
388
|
-
@mousedown=${n=>{n.button===0&&p(this,
|
|
389
|
-
@click=${()=>p(this,
|
|
389
|
+
@mousedown=${n=>{n.button===0&&p(this,F,pd).call(this,e.serverURL,e.screenID)}}
|
|
390
|
+
@click=${()=>p(this,F,pd).call(this,e.serverURL,e.screenID)}
|
|
390
391
|
>
|
|
391
392
|
<span class="tab-leading">
|
|
392
|
-
${
|
|
393
|
+
${sM({weight:"bold"})}
|
|
393
394
|
</span>
|
|
394
395
|
<editable-text
|
|
395
396
|
class="tab-name"
|
|
396
397
|
.value=${e.name}
|
|
397
|
-
@rename=${n=>p(this,
|
|
398
|
+
@rename=${n=>p(this,F,R0).call(this,e.serverURL,e.screenID,n)}
|
|
398
399
|
></editable-text>
|
|
399
400
|
</button>
|
|
400
401
|
<button
|
|
@@ -404,19 +405,19 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
404
405
|
icon-only
|
|
405
406
|
class="tab-close"
|
|
406
407
|
aria-label=${`Close ${e.name}`}
|
|
407
|
-
@click=${n=>p(this,
|
|
408
|
+
@click=${n=>p(this,F,C0).call(this,e.serverURL,e.screenID,n)}
|
|
408
409
|
>
|
|
409
|
-
${
|
|
410
|
+
${vp({weight:"bold"})}
|
|
410
411
|
</button>
|
|
411
412
|
</span>
|
|
412
|
-
`},
|
|
413
|
+
`},U0=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,F,Dl).call(this,l(this,ir),e);return P`
|
|
413
414
|
<ui-popover
|
|
414
415
|
class="picker-popover"
|
|
415
416
|
material="glass-frosted"
|
|
416
417
|
?open=${l(this,Te).kind==="picker"}
|
|
417
|
-
@close=${l(this,
|
|
418
|
-
@keydown=${l(this,
|
|
419
|
-
${
|
|
418
|
+
@close=${l(this,mc)}
|
|
419
|
+
@keydown=${l(this,pc)}
|
|
420
|
+
${Qs(l(this,$r))}
|
|
420
421
|
>
|
|
421
422
|
<div class="picker">
|
|
422
423
|
<input
|
|
@@ -425,18 +426,18 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
425
426
|
placeholder="Filter screens"
|
|
426
427
|
aria-label="Filter screens"
|
|
427
428
|
.value=${e}
|
|
428
|
-
@input=${l(this,
|
|
429
|
-
${
|
|
429
|
+
@input=${l(this,dc)}
|
|
430
|
+
${Qs(l(this,fa))}
|
|
430
431
|
/>
|
|
431
|
-
${s.length===0?
|
|
432
|
+
${s.length===0?P`<p class="picker-empty">
|
|
432
433
|
${l(this,ir).length===0?"No screens":"No matches"}
|
|
433
|
-
</p>`:p(this,
|
|
434
|
+
</p>`:p(this,F,F0).call(this,s,n,i)}
|
|
434
435
|
</div>
|
|
435
436
|
</ui-popover>
|
|
436
|
-
`},
|
|
437
|
+
`},F0=function(e,n,i){return P`
|
|
437
438
|
<ul class="picker-list" role="listbox">
|
|
438
439
|
<li class="picker-section-label" role="presentation">Recent</li>
|
|
439
|
-
${e.map(s=>{const o=s.screenID===i;return
|
|
440
|
+
${e.map(s=>{const o=s.screenID===i;return P`
|
|
440
441
|
<li
|
|
441
442
|
class="picker-row"
|
|
442
443
|
role="option"
|
|
@@ -444,19 +445,68 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
444
445
|
aria-current=${o?"true":le}
|
|
445
446
|
?data-highlighted=${s.screenID===n}
|
|
446
447
|
?data-active=${o}
|
|
447
|
-
@click=${()=>l(this,
|
|
448
|
+
@click=${()=>l(this,fc).call(this,s)}
|
|
448
449
|
>
|
|
449
450
|
<span class="picker-name">${s.name}</span>
|
|
451
|
+
<button
|
|
452
|
+
type="button"
|
|
453
|
+
variant="ghost"
|
|
454
|
+
size="xs"
|
|
455
|
+
?icon-only=${!0}
|
|
456
|
+
class="picker-row-delete"
|
|
457
|
+
aria-label=${`Delete screen “${s.name}”`}
|
|
458
|
+
@click=${a=>p(this,F,z0).call(this,s,a)}
|
|
459
|
+
>
|
|
460
|
+
${cM({size:16,weight:"regular"})}
|
|
461
|
+
</button>
|
|
450
462
|
</li>
|
|
451
463
|
`})}
|
|
452
464
|
</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
|
-
|
|
455
|
-
|
|
465
|
+
`},H0=function(){const e=l(this,Ir);return P`
|
|
466
|
+
<modal-overlay
|
|
467
|
+
class="screen-delete-modal"
|
|
468
|
+
?open=${e!==null}
|
|
469
|
+
@close=${l(this,wa)}
|
|
470
|
+
>
|
|
471
|
+
<div
|
|
472
|
+
class="screen-delete-confirm"
|
|
473
|
+
material="paper"
|
|
474
|
+
level="1"
|
|
475
|
+
tone="light"
|
|
476
|
+
role="alertdialog"
|
|
477
|
+
aria-modal="true"
|
|
478
|
+
aria-labelledby="screen-delete-title"
|
|
479
|
+
aria-describedby="screen-delete-body"
|
|
480
|
+
>
|
|
481
|
+
<h3 id="screen-delete-title">Delete “${(e==null?void 0:e.name)??""}”?</h3>
|
|
482
|
+
<p id="screen-delete-body">
|
|
483
|
+
This will permanently delete this screen from Television.
|
|
484
|
+
</p>
|
|
485
|
+
<div class="screen-delete-actions">
|
|
486
|
+
<button
|
|
487
|
+
type="button"
|
|
488
|
+
@click=${l(this,wa)}
|
|
489
|
+
${Qs(l(this,ga))}
|
|
490
|
+
>
|
|
491
|
+
Cancel
|
|
492
|
+
</button>
|
|
493
|
+
<button
|
|
494
|
+
type="button"
|
|
495
|
+
variant="danger"
|
|
496
|
+
@click=${l(this,gc)}
|
|
497
|
+
>
|
|
498
|
+
Delete screen
|
|
499
|
+
</button>
|
|
500
|
+
</div>
|
|
501
|
+
</div>
|
|
502
|
+
</modal-overlay>
|
|
503
|
+
`},qe=new WeakMap;customElements.define("screen-select",UN);function FN(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:Z0,setPrototypeOf:qm,isFrozen:HN,getPrototypeOf:ZN,getOwnPropertyDescriptor:WN}=Object;let{freeze:rt,seal:_t,create:zl}=Object,{apply:gd,construct:md}=typeof Reflect<"u"&&Reflect;rt||(rt=function(t){return t});_t||(_t=function(t){return t});gd||(gd=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)});md||(md=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 hl=nt(Array.prototype.forEach),VN=nt(Array.prototype.lastIndexOf),Ym=nt(Array.prototype.pop),Hs=nt(Array.prototype.push),BN=nt(Array.prototype.splice),Ol=nt(String.prototype.toLowerCase),eh=nt(String.prototype.toString),th=nt(String.prototype.match),Zs=nt(String.prototype.replace),jN=nt(String.prototype.indexOf),GN=nt(String.prototype.trim),ht=nt(Object.prototype.hasOwnProperty),Ke=nt(RegExp.prototype.test),Ws=qN(TypeError);function nt(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 gd(r,t,n)}}function qN(r){return function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return md(r,e)}}function G(r,t){let e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Ol;qm&&qm(r,null);let n=t.length;for(;n--;){let i=t[n];if(typeof i=="string"){const s=e(i);s!==i&&(HN(t)||(t[n]=s),i=s)}r[i]=!0}return r}function YN(r){for(let t=0;t<r.length;t++)ht(r,t)||(r[t]=null);return r}function Vt(r){const t=zl(null);for(const[e,n]of Z0(r))ht(r,e)&&(Array.isArray(n)?t[e]=YN(n):n&&typeof n=="object"&&n.constructor===Object?t[e]=Vt(n):t[e]=n);return t}function Vs(r,t){for(;r!==null;){const n=WN(r,t);if(n){if(n.get)return nt(n.get);if(typeof n.value=="function")return nt(n.value)}r=ZN(r)}function e(){return null}return e}const Km=rt(["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"]),rh=rt(["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"]),nh=rt(["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"]),KN=rt(["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"]),ih=rt(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),JN=rt(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Jm=rt(["#text"]),Xm=rt(["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"]),sh=rt(["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"]),Qm=rt(["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"]),dl=rt(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),XN=_t(/\{\{[\w\W]*|[\w\W]*\}\}/gm),QN=_t(/<%[\w\W]*|[\w\W]*%>/gm),e6=_t(/\$\{[\w\W]*/gm),t6=_t(/^data-[\-\w.\u00B7-\uFFFF]+$/),r6=_t(/^aria-[\-\w]+$/),W0=_t(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),n6=_t(/^(?:\w+script|data):/i),i6=_t(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),V0=_t(/^html$/i),s6=_t(/^[a-z][.\w]*(-[.\w]+)+$/i);var ev=Object.freeze({__proto__:null,ARIA_ATTR:r6,ATTR_WHITESPACE:i6,CUSTOM_ELEMENT:s6,DATA_ATTR:t6,DOCTYPE_NAME:V0,ERB_EXPR:QN,IS_ALLOWED_URI:W0,IS_SCRIPT_OR_DATA:n6,MUSTACHE_EXPR:XN,TMPLIT_EXPR:e6});const Bs={element:1,text:3,progressingInstruction:7,comment:8,document:9},o6=function(){return typeof window>"u"?null:window},a6=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}},tv=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function B0(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:o6();const t=U=>B0(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=Vs(E,"cloneNode"),I=Vs(E,"remove"),L=Vs(E,"nextSibling"),R=Vs(E,"childNodes"),V=Vs(E,"parentNode");if(typeof o=="function"){const U=e.createElement("template");U.content&&U.content.ownerDocument&&(e=U.content.ownerDocument)}let N,H="";const{implementation:Y,createNodeIterator:j,createDocumentFragment:ce,getElementsByTagName:Tt}=e,{importNode:pn}=n;let ze=tv();t.isSupported=typeof Z0=="function"&&typeof V=="function"&&Y&&Y.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:fn,ERB_EXPR:Ut,TMPLIT_EXPR:Or,DATA_ATTR:Bc,ARIA_ATTR:Ha,IS_SCRIPT_OR_DATA:dS,ATTR_WHITESPACE:Cp,CUSTOM_ELEMENT:pS}=ev;let{IS_ALLOWED_URI:Rp}=ev,Re=null;const Pp=G({},[...Km,...rh,...nh,...ih,...Jm]);let Oe=null;const Lp=G({},[...Xm,...sh,...Qm,...dl]);let Se=Object.seal(zl(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}})),Ps=null,Za=null;const Mr=Object.seal(zl(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Dp=!0,jc=!0,zp=!1,Op=!0,ui=!1,Wa=!0,gn=!1,Gc=!1,qc=!1,hi=!1,Va=!1,Ba=!1,Mp=!0,Np=!1;const fS="user-content-";let Yc=!0,Ls=!1,di={},Ft=null;const Kc=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 Up=null;const Fp=G({},["audio","video","img","source","image","track"]);let Jc=null;const Hp=G({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),ja="http://www.w3.org/1998/Math/MathML",Ga="http://www.w3.org/2000/svg",dr="http://www.w3.org/1999/xhtml";let pi=dr,Xc=!1,Qc=null;const gS=G({},[ja,Ga,dr],eh);let qa=G({},["mi","mo","mn","ms","mtext"]),Ya=G({},["annotation-xml"]);const mS=G({},["title","style","font","a","script"]);let Ds=null;const vS=["application/xhtml+xml","text/html"],yS="text/html";let Ae=null,fi=null;const bS=e.createElement("form"),Zp=function(S){return S instanceof RegExp||S instanceof Function},eu=function(){let S=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(fi&&fi===S)){if((!S||typeof S!="object")&&(S={}),S=Vt(S),Ds=vS.indexOf(S.PARSER_MEDIA_TYPE)===-1?yS:S.PARSER_MEDIA_TYPE,Ae=Ds==="application/xhtml+xml"?eh:Ol,Re=ht(S,"ALLOWED_TAGS")?G({},S.ALLOWED_TAGS,Ae):Pp,Oe=ht(S,"ALLOWED_ATTR")?G({},S.ALLOWED_ATTR,Ae):Lp,Qc=ht(S,"ALLOWED_NAMESPACES")?G({},S.ALLOWED_NAMESPACES,eh):gS,Jc=ht(S,"ADD_URI_SAFE_ATTR")?G(Vt(Hp),S.ADD_URI_SAFE_ATTR,Ae):Hp,Up=ht(S,"ADD_DATA_URI_TAGS")?G(Vt(Fp),S.ADD_DATA_URI_TAGS,Ae):Fp,Ft=ht(S,"FORBID_CONTENTS")?G({},S.FORBID_CONTENTS,Ae):Kc,Ps=ht(S,"FORBID_TAGS")?G({},S.FORBID_TAGS,Ae):Vt({}),Za=ht(S,"FORBID_ATTR")?G({},S.FORBID_ATTR,Ae):Vt({}),di=ht(S,"USE_PROFILES")?S.USE_PROFILES:!1,Dp=S.ALLOW_ARIA_ATTR!==!1,jc=S.ALLOW_DATA_ATTR!==!1,zp=S.ALLOW_UNKNOWN_PROTOCOLS||!1,Op=S.ALLOW_SELF_CLOSE_IN_ATTR!==!1,ui=S.SAFE_FOR_TEMPLATES||!1,Wa=S.SAFE_FOR_XML!==!1,gn=S.WHOLE_DOCUMENT||!1,hi=S.RETURN_DOM||!1,Va=S.RETURN_DOM_FRAGMENT||!1,Ba=S.RETURN_TRUSTED_TYPE||!1,qc=S.FORCE_BODY||!1,Mp=S.SANITIZE_DOM!==!1,Np=S.SANITIZE_NAMED_PROPS||!1,Yc=S.KEEP_CONTENT!==!1,Ls=S.IN_PLACE||!1,Rp=S.ALLOWED_URI_REGEXP||W0,pi=S.NAMESPACE||dr,qa=S.MATHML_TEXT_INTEGRATION_POINTS||qa,Ya=S.HTML_INTEGRATION_POINTS||Ya,Se=S.CUSTOM_ELEMENT_HANDLING||{},S.CUSTOM_ELEMENT_HANDLING&&Zp(S.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(Se.tagNameCheck=S.CUSTOM_ELEMENT_HANDLING.tagNameCheck),S.CUSTOM_ELEMENT_HANDLING&&Zp(S.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(Se.attributeNameCheck=S.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),S.CUSTOM_ELEMENT_HANDLING&&typeof S.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(Se.allowCustomizedBuiltInElements=S.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),ui&&(jc=!1),Va&&(hi=!0),di&&(Re=G({},Jm),Oe=zl(null),di.html===!0&&(G(Re,Km),G(Oe,Xm)),di.svg===!0&&(G(Re,rh),G(Oe,sh),G(Oe,dl)),di.svgFilters===!0&&(G(Re,nh),G(Oe,sh),G(Oe,dl)),di.mathMl===!0&&(G(Re,ih),G(Oe,Qm),G(Oe,dl))),ht(S,"ADD_TAGS")||(Mr.tagCheck=null),ht(S,"ADD_ATTR")||(Mr.attributeCheck=null),S.ADD_TAGS&&(typeof S.ADD_TAGS=="function"?Mr.tagCheck=S.ADD_TAGS:(Re===Pp&&(Re=Vt(Re)),G(Re,S.ADD_TAGS,Ae))),S.ADD_ATTR&&(typeof S.ADD_ATTR=="function"?Mr.attributeCheck=S.ADD_ATTR:(Oe===Lp&&(Oe=Vt(Oe)),G(Oe,S.ADD_ATTR,Ae))),S.ADD_URI_SAFE_ATTR&&G(Jc,S.ADD_URI_SAFE_ATTR,Ae),S.FORBID_CONTENTS&&(Ft===Kc&&(Ft=Vt(Ft)),G(Ft,S.FORBID_CONTENTS,Ae)),S.ADD_FORBID_CONTENTS&&(Ft===Kc&&(Ft=Vt(Ft)),G(Ft,S.ADD_FORBID_CONTENTS,Ae)),Yc&&(Re["#text"]=!0),gn&&G(Re,["html","head","body"]),Re.table&&(G(Re,["tbody"]),delete Ps.tbody),S.TRUSTED_TYPES_POLICY){if(typeof S.TRUSTED_TYPES_POLICY.createHTML!="function")throw Ws('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof S.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Ws('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');N=S.TRUSTED_TYPES_POLICY,H=N.createHTML("")}else N===void 0&&(N=a6(m,i)),N!==null&&typeof H=="string"&&(H=N.createHTML(""));rt&&rt(S),fi=S}},Wp=G({},[...rh,...nh,...KN]),Vp=G({},[...ih,...JN]),wS=function(S){let C=V(S);(!C||!C.tagName)&&(C={namespaceURI:pi,tagName:"template"});const D=Ol(S.tagName),de=Ol(C.tagName);return Qc[S.namespaceURI]?S.namespaceURI===Ga?C.namespaceURI===dr?D==="svg":C.namespaceURI===ja?D==="svg"&&(de==="annotation-xml"||qa[de]):!!Wp[D]:S.namespaceURI===ja?C.namespaceURI===dr?D==="math":C.namespaceURI===Ga?D==="math"&&Ya[de]:!!Vp[D]:S.namespaceURI===dr?C.namespaceURI===Ga&&!Ya[de]||C.namespaceURI===ja&&!qa[de]?!1:!Vp[D]&&(mS[D]||!Wp[D]):!!(Ds==="application/xhtml+xml"&&Qc[S.namespaceURI]):!1},Ht=function(S){Hs(t.removed,{element:S});try{V(S).removeChild(S)}catch{I(S)}},mn=function(S,C){try{Hs(t.removed,{attribute:C.getAttributeNode(S),from:C})}catch{Hs(t.removed,{attribute:null,from:C})}if(C.removeAttribute(S),S==="is")if(hi||Va)try{Ht(C)}catch{}else try{C.setAttribute(S,"")}catch{}},Bp=function(S){let C=null,D=null;if(qc)S="<remove></remove>"+S;else{const _e=th(S,/^[\r\n\t ]+/);D=_e&&_e[0]}Ds==="application/xhtml+xml"&&pi===dr&&(S='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+S+"</body></html>");const de=N?N.createHTML(S):S;if(pi===dr)try{C=new y().parseFromString(de,Ds)}catch{}if(!C||!C.documentElement){C=Y.createDocument(pi,"template",null);try{C.documentElement.innerHTML=Xc?H:de}catch{}}const je=C.body||C.documentElement;return S&&D&&je.insertBefore(e.createTextNode(D),je.childNodes[0]||null),pi===dr?Tt.call(C,gn?"html":"body")[0]:gn?C.documentElement:je},jp=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)},tu=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")},Gp=function(S){return typeof a=="function"&&S instanceof a};function pr(U,S,C){hl(U,D=>{D.call(t,S,C,fi)})}const qp=function(S){let C=null;if(pr(ze.beforeSanitizeElements,S,null),tu(S))return Ht(S),!0;const D=Ae(S.nodeName);if(pr(ze.uponSanitizeElement,S,{tagName:D,allowedTags:Re}),Wa&&S.hasChildNodes()&&!Gp(S.firstElementChild)&&Ke(/<[/\w!]/g,S.innerHTML)&&Ke(/<[/\w!]/g,S.textContent)||S.nodeType===Bs.progressingInstruction||Wa&&S.nodeType===Bs.comment&&Ke(/<[/\w]/g,S.data))return Ht(S),!0;if(!(Mr.tagCheck instanceof Function&&Mr.tagCheck(D))&&(!Re[D]||Ps[D])){if(!Ps[D]&&Kp(D)&&(Se.tagNameCheck instanceof RegExp&&Ke(Se.tagNameCheck,D)||Se.tagNameCheck instanceof Function&&Se.tagNameCheck(D)))return!1;if(Yc&&!Ft[D]){const de=V(S)||S.parentNode,je=R(S)||S.childNodes;if(je&&de){const _e=je.length;for(let it=_e-1;it>=0;--it){const fr=x(je[it],!0);fr.__removalCount=(S.__removalCount||0)+1,de.insertBefore(fr,L(S))}}}return Ht(S),!0}return S instanceof c&&!wS(S)||(D==="noscript"||D==="noembed"||D==="noframes")&&Ke(/<\/no(script|embed|frames)/i,S.innerHTML)?(Ht(S),!0):(ui&&S.nodeType===Bs.text&&(C=S.textContent,hl([fn,Ut,Or],de=>{C=Zs(C,de," ")}),S.textContent!==C&&(Hs(t.removed,{element:S.cloneNode()}),S.textContent=C)),pr(ze.afterSanitizeElements,S,null),!1)},Yp=function(S,C,D){if(Za[C]||Mp&&(C==="id"||C==="name")&&(D in e||D in bS))return!1;if(!(jc&&!Za[C]&&Ke(Bc,C))){if(!(Dp&&Ke(Ha,C))){if(!(Mr.attributeCheck instanceof Function&&Mr.attributeCheck(C,S))){if(!Oe[C]||Za[C]){if(!(Kp(S)&&(Se.tagNameCheck instanceof RegExp&&Ke(Se.tagNameCheck,S)||Se.tagNameCheck instanceof Function&&Se.tagNameCheck(S))&&(Se.attributeNameCheck instanceof RegExp&&Ke(Se.attributeNameCheck,C)||Se.attributeNameCheck instanceof Function&&Se.attributeNameCheck(C,S))||C==="is"&&Se.allowCustomizedBuiltInElements&&(Se.tagNameCheck instanceof RegExp&&Ke(Se.tagNameCheck,D)||Se.tagNameCheck instanceof Function&&Se.tagNameCheck(D))))return!1}else if(!Jc[C]){if(!Ke(Rp,Zs(D,Cp,""))){if(!((C==="src"||C==="xlink:href"||C==="href")&&S!=="script"&&jN(D,"data:")===0&&Up[S])){if(!(zp&&!Ke(dS,Zs(D,Cp,"")))){if(D)return!1}}}}}}}return!0},Kp=function(S){return S!=="annotation-xml"&&th(S,pS)},Jp=function(S){pr(ze.beforeSanitizeAttributes,S,null);const{attributes:C}=S;if(!C||tu(S))return;const D={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Oe,forceKeepAttr:void 0};let de=C.length;for(;de--;){const je=C[de],{name:_e,namespaceURI:it,value:fr}=je,gi=Ae(_e),ru=fr;let Me=_e==="value"?ru:GN(ru);if(D.attrName=gi,D.attrValue=Me,D.keepAttr=!0,D.forceKeepAttr=void 0,pr(ze.uponSanitizeAttribute,S,D),Me=D.attrValue,Np&&(gi==="id"||gi==="name")&&(mn(_e,S),Me=fS+Me),Wa&&Ke(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,Me)){mn(_e,S);continue}if(gi==="attributename"&&th(Me,"href")){mn(_e,S);continue}if(D.forceKeepAttr)continue;if(!D.keepAttr){mn(_e,S);continue}if(!Op&&Ke(/\/>/i,Me)){mn(_e,S);continue}ui&&hl([fn,Ut,Or],Qp=>{Me=Zs(Me,Qp," ")});const Xp=Ae(S.nodeName);if(!Yp(Xp,gi,Me)){mn(_e,S);continue}if(N&&typeof m=="object"&&typeof m.getAttributeType=="function"&&!it)switch(m.getAttributeType(Xp,gi)){case"TrustedHTML":{Me=N.createHTML(Me);break}case"TrustedScriptURL":{Me=N.createScriptURL(Me);break}}if(Me!==ru)try{it?S.setAttributeNS(it,_e,Me):S.setAttribute(_e,Me),tu(S)?Ht(S):Ym(t.removed)}catch{mn(_e,S)}}pr(ze.afterSanitizeAttributes,S,null)},SS=function U(S){let C=null;const D=jp(S);for(pr(ze.beforeSanitizeShadowDOM,S,null);C=D.nextNode();)pr(ze.uponSanitizeShadowNode,C,null),qp(C),Jp(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,D=null,de=null,je=null;if(Xc=!U,Xc&&(U="<!-->"),typeof U!="string"&&!Gp(U))if(typeof U.toString=="function"){if(U=U.toString(),typeof U!="string")throw Ws("dirty is not a string, aborting")}else throw Ws("toString is not a function");if(!t.isSupported)return U;if(Gc||eu(S),t.removed=[],typeof U=="string"&&(Ls=!1),Ls){if(U.nodeName){const fr=Ae(U.nodeName);if(!Re[fr]||Ps[fr])throw Ws("root node is forbidden and cannot be sanitized in-place")}}else if(U instanceof a)C=Bp("<!---->"),D=C.ownerDocument.importNode(U,!0),D.nodeType===Bs.element&&D.nodeName==="BODY"||D.nodeName==="HTML"?C=D:C.appendChild(D);else{if(!hi&&!ui&&!gn&&U.indexOf("<")===-1)return N&&Ba?N.createHTML(U):U;if(C=Bp(U),!C)return hi?null:Ba?H:""}C&&qc&&Ht(C.firstChild);const _e=jp(Ls?U:C);for(;de=_e.nextNode();)qp(de),Jp(de),de.content instanceof s&&SS(de.content);if(Ls)return U;if(hi){if(Va)for(je=ce.call(C.ownerDocument);C.firstChild;)je.appendChild(C.firstChild);else je=C;return(Oe.shadowroot||Oe.shadowrootmode)&&(je=pn.call(n,je,!0)),je}let it=gn?C.outerHTML:C.innerHTML;return gn&&Re["!doctype"]&&C.ownerDocument&&C.ownerDocument.doctype&&C.ownerDocument.doctype.name&&Ke(V0,C.ownerDocument.doctype.name)&&(it="<!DOCTYPE "+C.ownerDocument.doctype.name+`>
|
|
504
|
+
`+it),ui&&hl([fn,Ut,Or],fr=>{it=Zs(it,fr," ")}),N&&Ba?N.createHTML(it):it},t.setConfig=function(){let U=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};eu(U),Gc=!0},t.clearConfig=function(){fi=null,Gc=!1},t.isValidAttribute=function(U,S,C){fi||eu({});const D=Ae(U),de=Ae(S);return Yp(D,de,C)},t.addHook=function(U,S){typeof S=="function"&&Hs(ze[U],S)},t.removeHook=function(U,S){if(S!==void 0){const C=VN(ze[U],S);return C===-1?void 0:BN(ze[U],C,1)[0]}return Ym(ze[U])},t.removeHooks=function(U){ze[U]=[]},t.removeAllHooks=function(){ze=tv()},t}var j0=B0();function bp(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var ci=bp();function G0(r){ci=r}var En={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(tt.caret,"$1"),e=e.replace(i,o),n},getRegex:()=>new RegExp(e,t)};return n}var l6=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),tt={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)}}>`)},c6=/^(?:[ \t]*(?:\n|$))+/,u6=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,h6=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Fa=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,d6=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,wp=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,q0=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Y0=J(q0).replace(/bull/g,wp).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(),p6=J(q0).replace(/bull/g,wp).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(),Sp=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,f6=/^[^\n]+/,_p=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,g6=J(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",_p).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),m6=J(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,wp).getRegex(),Wc="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",kp=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,v6=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",kp).replace("tag",Wc).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),K0=J(Sp).replace("hr",Fa).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",Wc).getRegex(),y6=J(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",K0).getRegex(),xp={blockquote:y6,code:u6,def:g6,fences:h6,heading:d6,hr:Fa,html:v6,lheading:Y0,list:m6,newline:c6,paragraph:K0,table:En,text:f6},rv=J("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Fa).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",Wc).getRegex(),b6={...xp,lheading:p6,table:rv,paragraph:J(Sp).replace("hr",Fa).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",rv).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",Wc).getRegex()},w6={...xp,html:J(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",kp).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:En,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:J(Sp).replace("hr",Fa).replace("heading",` *#{1,6} *[^
|
|
505
|
+
]`).replace("lheading",Y0).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},S6=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,_6=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,J0=/^( {2,}|\\)\n(?!\s*$)/,k6=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Rs=/[\p{P}\p{S}]/u,Vc=/[\s\p{P}\p{S}]/u,Ep=/[^\s\p{P}\p{S}]/u,x6=J(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Vc).getRegex(),X0=/(?!~)[\p{P}\p{S}]/u,E6=/(?!~)[\s\p{P}\p{S}]/u,A6=/(?:[^\s\p{P}\p{S}]|~)/u,T6=J(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",l6?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Q0=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,$6=J(Q0,"u").replace(/punct/g,Rs).getRegex(),I6=J(Q0,"u").replace(/punct/g,X0).getRegex(),eS="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",C6=J(eS,"gu").replace(/notPunctSpace/g,Ep).replace(/punctSpace/g,Vc).replace(/punct/g,Rs).getRegex(),R6=J(eS,"gu").replace(/notPunctSpace/g,A6).replace(/punctSpace/g,E6).replace(/punct/g,X0).getRegex(),P6=J("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Ep).replace(/punctSpace/g,Vc).replace(/punct/g,Rs).getRegex(),L6=J(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,Rs).getRegex(),D6="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",z6=J(D6,"gu").replace(/notPunctSpace/g,Ep).replace(/punctSpace/g,Vc).replace(/punct/g,Rs).getRegex(),O6=J(/\\(punct)/,"gu").replace(/punct/g,Rs).getRegex(),M6=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(),N6=J(kp).replace("(?:-->|$)","-->").getRegex(),U6=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",N6).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),tc=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,F6=J(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",tc).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),tS=J(/^!?\[(label)\]\[(ref)\]/).replace("label",tc).replace("ref",_p).getRegex(),rS=J(/^!?\[(ref)\](?:\[\])?/).replace("ref",_p).getRegex(),H6=J("reflink|nolink(?!\\()","g").replace("reflink",tS).replace("nolink",rS).getRegex(),nv=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Ap={_backpedal:En,anyPunctuation:O6,autolink:M6,blockSkip:T6,br:J0,code:_6,del:En,delLDelim:En,delRDelim:En,emStrongLDelim:$6,emStrongRDelimAst:C6,emStrongRDelimUnd:P6,escape:S6,link:F6,nolink:rS,punctuation:x6,reflink:tS,reflinkSearch:H6,tag:U6,text:k6,url:En},Z6={...Ap,link:J(/^!?\[(label)\]\((.*?)\)/).replace("label",tc).getRegex(),reflink:J(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",tc).getRegex()},vd={...Ap,emStrongRDelimAst:R6,emStrongLDelim:I6,delLDelim:L6,delRDelim:z6,url:J(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",nv).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",nv).getRegex()},W6={...vd,br:J(J0).replace("{2,}","*").getRegex(),text:J(vd.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},pl={normal:xp,gfm:b6,pedantic:w6},js={normal:Ap,gfm:vd,breaks:W6,pedantic:Z6},V6={"&":"&","<":"<",">":">",'"':""","'":"'"},iv=r=>V6[r];function Bt(r,t){if(t){if(tt.escapeTest.test(r))return r.replace(tt.escapeReplace,iv)}else if(tt.escapeTestNoEncode.test(r))return r.replace(tt.escapeReplaceNoEncode,iv);return r}function sv(r){try{r=encodeURI(r).replace(tt.percentDecode,"%")}catch{return null}return r}function ov(r,t){var s;let e=r.replace(tt.findPipe,(o,a,c)=>{let u=!1,h=a;for(;--h>=0&&c[h]==="\\";)u=!u;return u?"|":" |"}),n=e.split(tt.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(tt.slashPipe,"|");return n}function Gs(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 B6(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 j6(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 av(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 G6(r,t,e){let n=r.match(e.other.indentCodeCompensation);if(n===null)return t;let i=n[1];return t.split(`
|
|
456
506
|
`).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
|
|
458
|
-
`)}}}fences(r){let t=this.rules.block.fences.exec(r);if(t){let e=t[0],n=
|
|
459
|
-
`)}}blockquote(r){let t=this.rules.block.blockquote.exec(r);if(t){let e=
|
|
507
|
+
`)}var rc=class{constructor(r){g(this,"options");g(this,"rules");g(this,"lexer");this.options=r||ci}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:Gs(e,`
|
|
508
|
+
`)}}}fences(r){let t=this.rules.block.fences.exec(r);if(t){let e=t[0],n=G6(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=Gs(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:Gs(t[0],`
|
|
509
|
+
`)}}blockquote(r){let t=this.rules.block.blockquote.exec(r);if(t){let e=Gs(t[0],`
|
|
460
510
|
`).split(`
|
|
461
511
|
`),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
512
|
`),h=u.replace(this.rules.other.blockquoteSetextReplace,`
|
|
@@ -467,17 +517,17 @@ ${h}`:h;let f=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTo
|
|
|
467
517
|
`),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
518
|
`+e.join(`
|
|
469
519
|
`),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=
|
|
520
|
+
`);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=j6(t[2].split(`
|
|
471
521
|
`,1)[0],t[1].length),E=r.split(`
|
|
472
522
|
`,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
|
|
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," "),
|
|
475
|
-
`+ce.slice(I);else{if(x||m.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||
|
|
523
|
+
`,r=r.substring(E.length+1),h=!0),!h){let L=this.rules.other.nextBulletRegex(I),R=this.rules.other.hrRegex(I),V=this.rules.other.fencesBeginRegex(I),N=this.rules.other.headingBeginRegex(I),H=this.rules.other.htmlBeginRegex(I),Y=this.rules.other.blockquoteBeginRegex(I);for(;r;){let j=r.split(`
|
|
524
|
+
`,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," "),V.test(E)||N.test(E)||H.test(E)||Y.test(E)||L.test(E)||R.test(E))break;if(ce.search(this.rules.other.nonSpaceChar)>=I||!E.trim())y+=`
|
|
525
|
+
`+ce.slice(I);else{if(x||m.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||V.test(m)||N.test(m)||R.test(m))break;y+=`
|
|
476
526
|
`+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=
|
|
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(
|
|
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=
|
|
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(
|
|
527
|
+
`,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=ov(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(`
|
|
528
|
+
`):[],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(ov(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)===`
|
|
529
|
+
`?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=Gs(e.slice(0,-1),"\\");if((e.length-s.length)%2===0)return}else{let s=B6(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)),av(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 av(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}}}},Ot=class yd{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||ci,this.options.tokenizer=this.options.tokenizer||new rc,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:tt,block:pl.normal,inline:js.normal};this.options.pedantic?(e.block=pl.pedantic,e.inline=js.pedantic):this.options.gfm&&(e.block=pl.gfm,this.options.breaks?e.inline=js.breaks:e.inline=js.gfm),this.tokenizer.rules=e}static get rules(){return{block:pl,inline:js}}static lex(t,e){return new yd(e).lex(t)}static lexInline(t,e){return new yd(e).inlineTokens(t)}lex(t){t=t.replace(tt.carriageReturn,`
|
|
530
|
+
`),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(tt.tabCharGlobal," ").replace(tt.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
531
|
`: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
532
|
`)?"":`
|
|
483
533
|
`)+a.raw,u.text+=`
|
|
@@ -490,9 +540,9 @@ ${h}`:h;let f=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTo
|
|
|
490
540
|
`+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
541
|
`)?"":`
|
|
492
542
|
`)+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),
|
|
494
|
-
`;return n?'<pre><code class="language-'+
|
|
495
|
-
`:"<pre><code>"+(e?i:
|
|
543
|
+
`+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),L;this.options.extensions.startInline.forEach(R=>{L=R.call({lexer:this},I),typeof L=="number"&&L>=0&&(x=Math.min(x,L))}),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}},nc=class{constructor(r){g(this,"options");g(this,"parser");this.options=r||ci}space(r){return""}code({text:r,lang:t,escaped:e}){var s;let n=(s=(t||"").match(tt.notSpaceStart))==null?void 0:s[0],i=r.replace(tt.endingNewline,"")+`
|
|
544
|
+
`;return n?'<pre><code class="language-'+Bt(n)+'">'+(e?i:Bt(i,!0))+`</code></pre>
|
|
545
|
+
`:"<pre><code>"+(e?i:Bt(i,!0))+`</code></pre>
|
|
496
546
|
`}blockquote({tokens:r}){return`<blockquote>
|
|
497
547
|
${this.parser.parse(r)}</blockquote>
|
|
498
548
|
`}html({text:r}){return r}def(r){return""}heading({tokens:r,depth:t}){return`<h${t}>${this.parser.parseInline(r)}</h${t}>
|
|
@@ -508,26 +558,26 @@ ${this.parser.parse(r)}</blockquote>
|
|
|
508
558
|
`}tablerow({text:r}){return`<tr>
|
|
509
559
|
${r}</tr>
|
|
510
560
|
`}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>${
|
|
512
|
-
Please report this to https://github.com/markedjs/marked.`,r){let n="<p>An error occurred:</p><pre>"+
|
|
561
|
+
`}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>${Bt(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=sv(r);if(i===null)return n;r=i;let s='<a href="'+r+'"';return t&&(s+=' title="'+Bt(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=sv(r);if(i===null)return Bt(e);r=i;let s=`<img src="${r}" alt="${Bt(e)}"`;return t&&(s+=` title="${Bt(t)}"`),s+=">",s}text(r){return"tokens"in r&&r.tokens?this.parser.parseInline(r.tokens):"escaped"in r&&r.escaped?r.text:Bt(r.text)}},Tp=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}},Mt=class bd{constructor(t){g(this,"options");g(this,"renderer");g(this,"textRenderer");this.options=t||ci,this.options.renderer=this.options.renderer||new nc,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Tp}static parse(t,e){return new bd(e).parse(t)}static parseInline(t,e){return new bd(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}},fl,ao=(fl=class{constructor(r){g(this,"options");g(this,"block");this.options=r||ci}preprocess(r){return r}postprocess(r){return r}processAllTokens(r){return r}emStrongMask(r){return r}provideLexer(){return this.block?Ot.lex:Ot.lexInline}provideParser(){return this.block?Mt.parse:Mt.parseInline}},g(fl,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),g(fl,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),fl),q6=class{constructor(...r){g(this,"defaults",bp());g(this,"options",this.setOptions);g(this,"parse",this.parseMarkdown(!0));g(this,"parseInline",this.parseMarkdown(!1));g(this,"Parser",Mt);g(this,"Renderer",nc);g(this,"TextRenderer",Tp);g(this,"Lexer",Ot);g(this,"Tokenizer",rc);g(this,"Hooks",ao);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 nc(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 rc(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 ao;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];ao.passThroughHooks.has(s)?i[o]=u=>{if(this.defaults.async&&ao.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 Ot.lex(r,t??this.defaults)}parser(r,t){return Mt.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?Ot.lex:Ot.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?Mt.parse:Mt.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?Ot.lex:Ot.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?Mt.parse:Mt.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+=`
|
|
562
|
+
Please report this to https://github.com/markedjs/marked.`,r){let n="<p>An error occurred:</p><pre>"+Bt(e.message+"",!0)+"</pre>";return t?Promise.resolve(n):n}if(t)return Promise.reject(e);throw e}}},ii=new q6;function re(r,t){return ii.parse(r,t)}re.options=re.setOptions=function(r){return ii.setOptions(r),re.defaults=ii.defaults,G0(re.defaults),re};re.getDefaults=bp;re.defaults=ci;re.use=function(...r){return ii.use(...r),re.defaults=ii.defaults,G0(re.defaults),re};re.walkTokens=function(r,t){return ii.walkTokens(r,t)};re.parseInline=ii.parseInline;re.Parser=Mt;re.parser=Mt.parse;re.Renderer=nc;re.TextRenderer=Tp;re.Lexer=Ot;re.lexer=Ot.lex;re.Tokenizer=rc;re.Hooks=ao;re.parse=re;re.options;re.setOptions;re.use;re.walkTokens;re.parseInline;Mt.parse;Ot.lex;j0.addHook("afterSanitizeAttributes",r=>{r.tagName==="A"&&(r.setAttribute("target","_blank"),r.setAttribute("rel","noopener noreferrer"))});function Y6(r){const t=re.parse(r,{async:!1});return j0.sanitize(t,{USE_PROFILES:{html:!0}})}var Sa,Cr,sr,or,tn,nS,Ml;class wd extends bs{constructor(){super(...arguments);w(this,tn);g(this,"phase","thinking");g(this,"toolCalls",[]);g(this,"expanded",!1);g(this,"expandedTexts",new Set);w(this,Sa,`agent-activity-panel-${++X6}`);g(this,"overflowingTexts",new Set);w(this,Cr,null);w(this,sr,null);w(this,or,null);g(this,"handleToggle",()=>{this.toolCalls.length!==0&&(this.expanded=!this.expanded)})}changed(e){Ve(this.template(),this),p(this,tn,nS).call(this),l(this,sr)!==null&&cancelAnimationFrame(l(this,sr)),b(this,sr,requestAnimationFrame(()=>{b(this,sr,null),p(this,tn,Ml).call(this)})),e.has("expanded")&&(l(this,or)!==null&&clearTimeout(l(this,or)),b(this,or,window.setTimeout(()=>{b(this,or,null),p(this,tn,Ml).call(this)},J6)))}disconnected(){var e;(e=l(this,Cr))==null||e.disconnect(),b(this,Cr,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 P`
|
|
513
563
|
${this.barTemplate()}
|
|
514
564
|
${e?this.panelTemplate():null}
|
|
515
|
-
`}barTemplate(){return this.phase==="thinking"?
|
|
565
|
+
`}barTemplate(){return this.phase==="thinking"?P`<div class="bar bar-static" unselectable>${this.indicator()}${this.label({expanded:this.expanded})}</div>`:P`
|
|
516
566
|
<button
|
|
517
567
|
type="button"
|
|
518
568
|
variant="ghost"
|
|
519
569
|
class="bar"
|
|
520
570
|
unselectable
|
|
521
571
|
aria-expanded=${this.expanded?"true":"false"}
|
|
522
|
-
aria-controls=${l(this,
|
|
572
|
+
aria-controls=${l(this,Sa)}
|
|
523
573
|
@click=${this.handleToggle}
|
|
524
574
|
>
|
|
525
575
|
${this.indicator()}${this.label({expanded:this.expanded})}
|
|
526
576
|
</button>
|
|
527
|
-
`}panelTemplate(){return
|
|
577
|
+
`}panelTemplate(){return P`
|
|
528
578
|
<div
|
|
529
579
|
class="panel"
|
|
530
|
-
id=${l(this,
|
|
580
|
+
id=${l(this,Sa)}
|
|
531
581
|
role="region"
|
|
532
582
|
?inert=${!this.expanded}
|
|
533
583
|
aria-hidden=${this.expanded?"false":"true"}
|
|
@@ -538,44 +588,44 @@ Please report this to https://github.com/markedjs/marked.`,r){let n="<p>An error
|
|
|
538
588
|
</ol>
|
|
539
589
|
</div>
|
|
540
590
|
</div>
|
|
541
|
-
`}toolItemTemplate(e){const n=this.expandedTexts.has(e.toolCallId),i=this.overflowingTexts.has(e.toolCallId),s=n?"Show less":"Show more";return
|
|
591
|
+
`}toolItemTemplate(e){const n=this.expandedTexts.has(e.toolCallId),i=this.overflowingTexts.has(e.toolCallId),s=n?"Show less":"Show more";return P`
|
|
542
592
|
<li class="tool-item">
|
|
543
593
|
<span
|
|
544
594
|
class="tool-dot"
|
|
545
595
|
data-status=${e.status}
|
|
546
596
|
role="img"
|
|
547
|
-
aria-label=${
|
|
597
|
+
aria-label=${Q6(e.status)}
|
|
548
598
|
></span>
|
|
549
599
|
<span class="tool-title">${e.title}</span>
|
|
550
|
-
${e.text?
|
|
600
|
+
${e.text?P`
|
|
551
601
|
<div class="tool-output">
|
|
552
602
|
<pre
|
|
553
603
|
class="tool-text"
|
|
554
604
|
data-tool-call-id=${e.toolCallId}
|
|
555
605
|
?data-expanded=${n}
|
|
556
606
|
>${e.text}</pre>
|
|
557
|
-
${i?
|
|
607
|
+
${i?P`<button
|
|
558
608
|
type="button"
|
|
559
609
|
variant="ghost"
|
|
560
610
|
class="tool-text-toggle"
|
|
561
611
|
@click=${()=>this.toggleTextExpand(e.toolCallId)}
|
|
562
612
|
>
|
|
563
613
|
<span>${s}</span>
|
|
564
|
-
${n?
|
|
614
|
+
${n?iM({size:16}):Ql({size:16})}
|
|
565
615
|
</button>`:null}
|
|
566
616
|
</div>
|
|
567
617
|
`:null}
|
|
568
618
|
</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
|
|
570
|
-
>${e?
|
|
571
|
-
<div class="history-scroll" @scroll=${l(this,
|
|
572
|
-
${e.map(n=>{if(n.kind==="tool-run")return
|
|
619
|
+
`}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 P`<span class="indicator">${Ql({size:16})}</span>`;const e=this.phase==="thinking"||this.phase==="using";return P`<span class=${e?"indicator indicator-active":"indicator"}
|
|
620
|
+
>${e?Fw({size:16}):uM({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 K6(a)}return`${e.expanded?"Showing":"Used"} ${n} ${n===1?"tool":"tools"}`}}Sa=new WeakMap,Cr=new WeakMap,sr=new WeakMap,or=new WeakMap,tn=new WeakSet,nS=function(){if(!(typeof ResizeObserver>"u")){l(this,Cr)||b(this,Cr,new ResizeObserver(()=>p(this,tn,Ml).call(this))),l(this,Cr).disconnect();for(const e of this.querySelectorAll(".tool-text"))l(this,Cr).observe(e)}},Ml=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)}}e4(this.overflowingTexts,e)||(this.overflowingTexts=e)},g(wd,"properties",["phase","toolCalls","expanded","expandedTexts","overflowingTexts"]),g(wd,"attributes",{expanded:{type:Boolean}});function K6(r){switch(r){case"read":return"Reading files…";case"edit":return"Editing files…";case"delete":return"Deleting files…";case"move":return"Moving files…";case"search":return"Searching files…";case"execute":return"Running commands…";case"think":return"Thinking…";case"fetch":return"Fetching content…";case"switch_mode":return"Switching modes…";default:return"Working…"}}const J6=160;let X6=0;function Q6(r){switch(r){case"completed":return"Completed";case"failed":return"Failed";case"in_progress":return"In progress";default:return"Pending"}}function e4(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",wd);function t4(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 lv=8,cv=new WeakMap;function r4(r){const t=cv.get(r);if(t&&t.text===r.text)return t.html;const e=Y6(r.text);return cv.set(r,{text:r.text,html:e}),e}function uv(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,Kn,Jn,Qr,kt,sS,Sd,oS,yc,bc,_d;class iS extends bs{constructor(){super(...arguments);w(this,kt);g(this,"messages",[]);w(this,vt,!0);w(this,yt,null);w(this,Kn,null);w(this,Jn,null);w(this,Qr,!1);w(this,yc,()=>{if(l(this,Qr))return;const e=l(this,yt);if(!e)return;const i=e.scrollHeight-e.clientHeight-e.scrollTop<=lv;i!==l(this,vt)&&(b(this,vt,i),this.toggleAttribute("data-pinned",i))});w(this,bc,()=>{b(this,vt,!0),this.toggleAttribute("data-pinned",!0),p(this,kt,_d).call(this,!0)})}changed(e){let n=!1;if(e.has("messages")){const i=e.get("messages")??[],s=uv(this.messages);n=s!==null&&s!==uv(i),n&&b(this,vt,!0)}Ve(this.template(),this),l(this,yt)||(b(this,yt,this.querySelector(".history-scroll")),l(this,yt)&&p(this,kt,sS).call(this)),this.toggleAttribute("data-pinned",l(this,vt)),p(this,kt,Sd).call(this),p(this,kt,_d).call(this,n)}disconnected(){var e,n;(e=l(this,Kn))==null||e.disconnect(),b(this,Kn,null),(n=l(this,Jn))==null||n.disconnect(),b(this,Jn,null)}template(){const e=t4(this.messages);return P`
|
|
621
|
+
<div class="history-scroll" @scroll=${l(this,yc)}>
|
|
622
|
+
${e.map(n=>{if(n.kind==="tool-run")return P`<agent-activity
|
|
573
623
|
.phase=${n.live?"using":"final"}
|
|
574
624
|
.toolCalls=${n.toolCalls}
|
|
575
|
-
></agent-activity>`;if(n.kind==="thinking")return
|
|
625
|
+
></agent-activity>`;if(n.kind==="thinking")return P`<agent-activity
|
|
576
626
|
.phase=${"thinking"}
|
|
577
627
|
.toolCalls=${[]}
|
|
578
|
-
></agent-activity>`;const i=n.message,s=i.kind==="assistant"?
|
|
628
|
+
></agent-activity>`;const i=n.message,s=i.kind==="assistant"?WO(r4(i)):i.text;return P`<div
|
|
579
629
|
class="message message-${i.kind}"
|
|
580
630
|
data-message-id=${i.id}
|
|
581
631
|
>${s}</div>`})}
|
|
@@ -584,16 +634,16 @@ Please report this to https://github.com/markedjs/marked.`,r){let n="<p>An error
|
|
|
584
634
|
type="button"
|
|
585
635
|
class="history-jump"
|
|
586
636
|
aria-label="Jump to latest message"
|
|
587
|
-
@click=${l(this,
|
|
637
|
+
@click=${l(this,bc)}
|
|
588
638
|
>
|
|
589
|
-
${
|
|
639
|
+
${Ql({size:16})}
|
|
590
640
|
</button>
|
|
591
|
-
`}}vt=new WeakMap,yt=new WeakMap,
|
|
641
|
+
`}}vt=new WeakMap,yt=new WeakMap,Kn=new WeakMap,Jn=new WeakMap,Qr=new WeakMap,kt=new WeakSet,sS=function(){l(this,yt)&&(typeof ResizeObserver>"u"||(b(this,Kn,new ResizeObserver(()=>p(this,kt,oS).call(this))),b(this,Jn,new MutationObserver(()=>p(this,kt,Sd).call(this))),l(this,Jn).observe(l(this,yt),{childList:!0})))},Sd=function(){const e=l(this,yt),n=l(this,Kn);if(!(!e||!n)){n.disconnect();for(const i of Array.from(e.children))n.observe(i)}},oS=function(){const e=l(this,yt);if(!e)return;if(l(this,vt)){b(this,Qr,!0),e.scrollTop=e.scrollHeight-e.clientHeight,requestAnimationFrame(()=>{b(this,Qr,!1)});return}const i=e.scrollHeight-e.clientHeight-e.scrollTop<=lv;i!==l(this,vt)&&(b(this,vt,i),this.toggleAttribute("data-pinned",i))},yc=new WeakMap,bc=new WeakMap,_d=function(e){requestAnimationFrame(()=>{const n=l(this,yt);n&&(!l(this,vt)&&!e||(b(this,Qr,!0),n.scrollTop=n.scrollHeight-n.clientHeight,requestAnimationFrame(()=>{b(this,Qr,!1)})))})},g(iS,"properties",["messages"]);customElements.define("message-history",iS);var Dt,_a,cs,ar,us,hs,ka,ds,wc,Sc,_c,bt,Nl,xa,xd,Ed,Ea,Aa;class kd extends bs{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,Dt,hr.resolve("ServerManager"));w(this,_a,hr.resolve("ShortcutService"));w(this,cs,null);w(this,ar,null);w(this,us,()=>{var e;this.status=((e=l(this,ar))==null?void 0:e.status)??"disconnected"});w(this,hs,()=>{var e;this.messages=((e=l(this,ar))==null?void 0:e.messages)??[]});w(this,ka,()=>{var e,n;(e=l(this,ar))==null||e.removeEventListener("status-changed",l(this,us)),(n=l(this,ar))==null||n.removeEventListener("messages-changed",l(this,hs)),b(this,ar,null)});w(this,ds,()=>{var n;const e=((n=l(this,Dt).activeServer)==null?void 0:n.acpClient)??null;e!==l(this,ar)&&(l(this,ka).call(this),b(this,ar,e),e==null||e.addEventListener("status-changed",l(this,us)),e==null||e.addEventListener("messages-changed",l(this,hs)),l(this,us).call(this),l(this,hs).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,Dt).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,Nl).call(this,n);const s=(o=l(this,Dt).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,wc,e=>{p(this,bt,Nl).call(this,e.currentTarget)});w(this,Sc,e=>{var i;e.stopPropagation();const n=(i=l(this,Dt).activeServer)==null?void 0:i.acpClient;n&&n.cancel().catch(s=>{console.error("ACPClient.cancel() failed",s)})});w(this,_c,e=>{if(e.target instanceof HTMLTextAreaElement)return;const n=e.currentTarget.querySelector("textarea");n==null||n.focus()});w(this,xa,e=>{var s;if(e.shortcut!=="focusCommandInput")return;const n=(s=l(this,Dt).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,Ea,e=>{e.target instanceof Node&&(this.contains(e.target)||(this.open=!1))});w(this,Aa,e=>{e.key==="Escape"&&(this.open=!1)})}connected(){const e=new DisposableStack;b(this,cs,e),l(this,Dt).addEventListener("change",l(this,ds)),e.defer(()=>{l(this,Dt).removeEventListener("change",l(this,ds)),l(this,ka).call(this)}),l(this,ds).call(this),l(this,_a).addEventListener("shortcut-triggered",l(this,xa)),e.defer(()=>l(this,_a).removeEventListener("shortcut-triggered",l(this,xa))),this.open&&p(this,bt,xd).call(this)}disconnected(){var e;(e=l(this,cs))==null||e.dispose(),b(this,cs,null),p(this,bt,Ed).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")),Ve(this.template(),this),e.has("open"))if(this.open){p(this,bt,xd).call(this);const n=this.querySelector("textarea");n&&(p(this,bt,Nl).call(this,n),n.focus())}else p(this,bt,Ed).call(this)}template(){var i;const e=(i=l(this,Dt).activeServer)==null?void 0:i.acpClient;if(e&&!e.enabled||this.status==="disposed")return null;if(this.status==="disconnected")return P`
|
|
592
642
|
<div class="connecting" aria-disabled="true">
|
|
593
643
|
<ui-spinner size="16" weight="bold"></ui-spinner>
|
|
594
644
|
<span class="label">Connecting<span class="dots" aria-hidden="true"></span></span>
|
|
595
645
|
</div>
|
|
596
|
-
`;if(this.open){const s=this.status==="running"||this.status==="cancelling",o=this.status==="cancelling";return
|
|
646
|
+
`;if(this.open){const s=this.status==="running"||this.status==="cancelling",o=this.status==="cancelling";return P`
|
|
597
647
|
<div class="open">
|
|
598
648
|
<div
|
|
599
649
|
class="chat"
|
|
@@ -608,29 +658,29 @@ Please report this to https://github.com/markedjs/marked.`,r){let n="<p>An error
|
|
|
608
658
|
material="paper"
|
|
609
659
|
tone="dark"
|
|
610
660
|
level="overlay"
|
|
611
|
-
@click=${l(this,
|
|
661
|
+
@click=${l(this,_c)}
|
|
612
662
|
>
|
|
613
663
|
<textarea
|
|
614
664
|
class="textarea"
|
|
615
665
|
rows="1"
|
|
616
666
|
@keydown=${this.handleKeydown}
|
|
617
|
-
@input=${l(this,
|
|
667
|
+
@input=${l(this,wc)}
|
|
618
668
|
></textarea>
|
|
619
|
-
${s?
|
|
669
|
+
${s?P`
|
|
620
670
|
<button
|
|
621
671
|
type="button"
|
|
622
672
|
icon-only
|
|
623
673
|
variant="ghost"
|
|
624
674
|
aria-label=${o?"Cancelling…":"Stop generating"}
|
|
625
675
|
?disabled=${o}
|
|
626
|
-
@click=${l(this,
|
|
676
|
+
@click=${l(this,Sc)}
|
|
627
677
|
>
|
|
628
|
-
${o?
|
|
678
|
+
${o?P`<ui-spinner size="16" weight="bold"></ui-spinner>`:nM({size:16})}
|
|
629
679
|
</button>
|
|
630
680
|
`:null}
|
|
631
681
|
</div>
|
|
632
682
|
</div>
|
|
633
|
-
`}return
|
|
683
|
+
`}return P`
|
|
634
684
|
<div
|
|
635
685
|
class="trigger"
|
|
636
686
|
tabindex="0"
|
|
@@ -641,13 +691,13 @@ Please report this to https://github.com/markedjs/marked.`,r){let n="<p>An error
|
|
|
641
691
|
<span class="label">${this.placeholder}</span>
|
|
642
692
|
<span class="kbd" aria-hidden="true">⌘K</span>
|
|
643
693
|
</div>
|
|
644
|
-
`}}
|
|
694
|
+
`}}Dt=new WeakMap,_a=new WeakMap,cs=new WeakMap,ar=new WeakMap,us=new WeakMap,hs=new WeakMap,ka=new WeakMap,ds=new WeakMap,wc=new WeakMap,Sc=new WeakMap,_c=new WeakMap,bt=new WeakSet,Nl=function(e){e.style.height="auto",e.style.height=`${e.scrollHeight}px`},xa=new WeakMap,xd=function(){document.addEventListener("mousedown",l(this,Ea)),document.addEventListener("keydown",l(this,Aa))},Ed=function(){document.removeEventListener("mousedown",l(this,Ea)),document.removeEventListener("keydown",l(this,Aa))},Ea=new WeakMap,Aa=new WeakMap,g(kd,"properties",["placeholder","open","messages","status"]),g(kd,"attributes",{placeholder:{type:String},open:{type:Boolean}});customElements.define("command-panel",kd);const n4='<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 aS extends Event{constructor(e){super("auth-submit",{bubbles:!0,composed:!0});g(this,"token");this.token=e}}class i4 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 aS(n))}render(){Ve(P`
|
|
645
695
|
<modal-overlay open>
|
|
646
696
|
<system-modal material="glass-frosted" level="1" class="auth-modal">
|
|
647
697
|
<form class="auth-form" @submit=${n=>this.handleSubmit(n)}>
|
|
648
698
|
<header>
|
|
649
699
|
<span class="auth-modal-icon" aria-hidden="true">
|
|
650
|
-
<svg width="32" height="32" viewBox="0 0 256 256" fill="currentColor">${
|
|
700
|
+
<svg width="32" height="32" viewBox="0 0 256 256" fill="currentColor">${Nw(n4)}</svg>
|
|
651
701
|
</span>
|
|
652
702
|
<hgroup>
|
|
653
703
|
<h2>Enter access token</h2>
|
|
@@ -666,7 +716,7 @@ Please report this to https://github.com/markedjs/marked.`,r){let n="<p>An error
|
|
|
666
716
|
autofocus
|
|
667
717
|
required
|
|
668
718
|
/>
|
|
669
|
-
${this.invalid?
|
|
719
|
+
${this.invalid?P`<p class="auth-modal-error" role="alert">
|
|
670
720
|
The previous token was rejected. Try again.
|
|
671
721
|
</p>`:null}
|
|
672
722
|
</div>
|
|
@@ -676,43 +726,43 @@ Please report this to https://github.com/markedjs/marked.`,r){let n="<p>An error
|
|
|
676
726
|
</form>
|
|
677
727
|
</system-modal>
|
|
678
728
|
</modal-overlay>
|
|
679
|
-
`,this)}}customElements.get("auth-modal")||customElements.define("auth-modal",
|
|
729
|
+
`,this)}}customElements.get("auth-modal")||customElements.define("auth-modal",i4);const s4=250,o4=1e3;class lS 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()},s4))}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…";Ve(P`
|
|
680
730
|
<modal-overlay open role="status" aria-live="polite">
|
|
681
731
|
<system-modal material="glass-frosted" level="1" class="connecting-overlay-panel">
|
|
682
732
|
<header>
|
|
683
733
|
<ui-spinner size="32"></ui-spinner>
|
|
684
734
|
<hgroup>
|
|
685
735
|
<h2>${n}</h2>
|
|
686
|
-
${e?
|
|
736
|
+
${e?P`<p>${i}</p>`:null}
|
|
687
737
|
</hgroup>
|
|
688
738
|
</header>
|
|
689
739
|
</system-modal>
|
|
690
740
|
</modal-overlay>
|
|
691
|
-
`,this)}formatCountdown(e){const n=e-Date.now();return n<=0?"Reattempting now…":`Reattempting in ${Math.ceil(n/
|
|
741
|
+
`,this)}formatCountdown(e){const n=e-Date.now();return n<=0?"Reattempting now…":`Reattempting in ${Math.ceil(n/o4)}s…`}}g(lS,"observedAttributes",["next-retry-at","has-ever-connected"]);customElements.get("connecting-overlay")||customElements.define("connecting-overlay",lS);class a4 extends HTMLElement{constructor(){super(...arguments);g(this,"runtimeServerURL",Cb());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 aS?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=pL();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 $w({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 ho)?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 ho||(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;Ve(P`
|
|
692
742
|
<main class="auth-gate">
|
|
693
743
|
<auth-modal
|
|
694
744
|
.invalid=${!!h.token}
|
|
695
745
|
.tokenValue=${h.token??""}
|
|
696
746
|
></auth-modal>
|
|
697
747
|
</main>
|
|
698
|
-
`,this),this.updateLayoutChromeBalance();return}const o=n==="disconnected",a=(e==null?void 0:e.hasEverConnected)??!1,u=n==="connected"||o&&a;
|
|
748
|
+
`,this),this.updateLayoutChromeBalance();return}const o=n==="disconnected",a=(e==null?void 0:e.hasEverConnected)??!1,u=n==="connected"||o&&a;Ve(P`
|
|
699
749
|
<main>
|
|
700
|
-
${this.connectError?
|
|
701
|
-
${u?
|
|
750
|
+
${this.connectError?P`<p data-testid="auth-error">${this.connectError}</p>`:P`
|
|
751
|
+
${u?P`
|
|
702
752
|
<div class="top-row" electron-draggable>
|
|
703
753
|
<screen-select></screen-select>
|
|
704
754
|
</div>
|
|
705
755
|
`:null}
|
|
706
|
-
${s?
|
|
707
|
-
${u&&(e!=null&&e.acpClient.enabled)?
|
|
756
|
+
${s?P`<screen-view></screen-view>`:null}
|
|
757
|
+
${u&&(e!=null&&e.acpClient.enabled)?P`
|
|
708
758
|
<div class="command-panel-region">
|
|
709
759
|
<command-panel></command-panel>
|
|
710
760
|
</div>
|
|
711
761
|
`:null}
|
|
712
762
|
`}
|
|
713
|
-
${o?
|
|
763
|
+
${o?P`<connecting-overlay
|
|
714
764
|
.nextRetryAt=${(e==null?void 0:e.nextRetryAt)??null}
|
|
715
765
|
.hasEverConnected=${(e==null?void 0:e.hasEverConnected)??!1}
|
|
716
766
|
></connecting-overlay>`:null}
|
|
717
767
|
</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",
|
|
768
|
+
`,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",a4);const xo=cr(),$p=Cb(),cS=new r$(xo?"television-electron":"television-browser",JT($p)),hv=Tw(),l4=hv?SL({storage:hv,clientApp:xo?"desktop":"browser",desktopAppVersion:xo?fL():null}):null,ur=new bO({localStore:cS,localServerURL:$p,telemetryMeta:l4}),uS=new h$({localStore:cS,serverManager:ur}),c4=new wO,u4=()=>{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)));RO(e)}).catch(()=>{})},hS=()=>{const r=ur.activeServer;if(!r||r.status!=="connected"){Vl();return}u4(),r.client.display.get().then(t=>{if(!(ur.activeServer!==r||r.status!=="connected"))return Pw(t.activeThemeName,r)}).catch(()=>{ur.activeServer===r&&Vl()})};hS();ur.addEventListener("change",hS);ur.addEventListener("server-event",r=>{if(r.event.type!=="theme-changed")return;const t=ur.activeServer;!t||t.url!==r.serverURL||Pw(r.event.themeName,t)});hr.register("ServerManager",()=>ur);hr.register("ScreenManager",()=>uS);hr.register("ShortcutService",()=>c4);globalThis.__telepath={screenManager:uS,serverManager:ur};const Ip=document.createElement("television-app");Ip.runtimeServerURL=$p;Ip.electronMode=xo;xo&&document.body.classList.add("electron");document.body.appendChild(Ip);
|